fs/nfsd/nfs4state.c
Source file repositories/reference/linux-study-clean/fs/nfsd/nfs4state.c
File Facts
- System
- Linux kernel
- Corpus path
fs/nfsd/nfs4state.c- Extension
.c- Size
- 260082 bytes
- Lines
- 9706
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/file.hlinux/fs.hlinux/slab.hlinux/namei.hlinux/swap.hlinux/pagemap.hlinux/ratelimit.hlinux/sunrpc/svcauth_gss.hlinux/sunrpc/addr.hlinux/jhash.hlinux/string_helpers.hlinux/fsnotify.hlinux/rhashtable.hlinux/nfs_ssc.hxdr4.hxdr4cb.hvfs.hcurrent_stateid.hnetns.hpnfs.hfilecache.htrace.h
Detected Declarations
struct laundry_timeenum nfsd4_st_mutex_lock_subclassenum rp_lockfunction nfsd4_create_laundry_wqfunction nfsd4_destroy_laundry_wqfunction is_session_deadfunction mark_session_dead_lockedfunction is_client_expiredfunction nfsd4_dec_courtesy_client_countfunction get_client_lockedfunction renew_client_lockedfunction put_client_renew_lockedfunction put_client_renewfunction nfsd4_get_session_lockedfunction nfsd4_put_session_lockedfunction nfsd4_put_sessionfunction find_blocked_lockfunction find_or_allocate_blockfunction free_nblfunction free_blocked_lockfunction remove_blocked_locksfunction nfsd4_cb_notify_lock_preparefunction nfsd4_cb_notify_lock_donefunction nfsd4_cb_notify_lock_releasefunction bmap_to_share_modefunction set_accessfunction clear_accessfunction test_accessfunction set_denyfunction clear_denyfunction test_denyfunction nfs4_access_to_omodefunction access_permit_readfunction access_permit_writefunction nfs4_get_stateownerfunction same_owner_strfunction find_openstateowner_strfunction list_for_each_entryfunction opaque_hashvalfunction put_nfs4_filefunction find_writeable_file_lockedfunction find_writeable_filefunction find_readable_file_lockedfunction find_readable_filefunction find_any_filefunction statefunction nfs4_resolve_deny_conflicts_lockedfunction __nfs4_file_get_access
Annotated Snippet
static const struct file_operations client_states_fops = {
.open = client_states_open,
.read = seq_read,
.llseek = seq_lseek,
.release = client_opens_release,
};
/*
* Normally we refuse to destroy clients that are in use, but here the
* administrator is telling us to just do it. We also want to wait
* so the caller has a guarantee that the client's locks are gone by
* the time the write returns:
*/
static void force_expire_client(struct nfs4_client *clp)
{
struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id);
bool already_expired;
trace_nfsd_clid_admin_expired(&clp->cl_clientid);
spin_lock(&nn->client_lock);
clp->cl_time = 0;
spin_unlock(&nn->client_lock);
wait_event(expiry_wq, atomic_read(&clp->cl_rpc_users) == 0);
spin_lock(&nn->client_lock);
already_expired = list_empty(&clp->cl_lru);
if (!already_expired)
unhash_client_locked(clp);
spin_unlock(&nn->client_lock);
if (!already_expired)
expire_client(clp);
else
wait_event(expiry_wq, clp->cl_nfsd_dentry == NULL);
}
static ssize_t client_ctl_write(struct file *file, const char __user *buf,
size_t size, loff_t *pos)
{
char *data;
struct nfs4_client *clp;
data = simple_transaction_get(file, buf, size);
if (IS_ERR(data))
return PTR_ERR(data);
if (size != 7 || 0 != memcmp(data, "expire\n", 7))
return -EINVAL;
clp = get_nfsdfs_clp(file_inode(file));
if (!clp)
return -ENXIO;
force_expire_client(clp);
nfsd4_put_client(clp);
return 7;
}
static const struct file_operations client_ctl_fops = {
.write = client_ctl_write,
.release = simple_transaction_release,
};
static const struct tree_descr client_files[] = {
[0] = {"info", &client_info_fops, S_IRUSR},
[1] = {"states", &client_states_fops, S_IRUSR},
[2] = {"ctl", &client_ctl_fops, S_IWUSR},
[3] = {""},
};
static int
nfsd4_cb_recall_any_done(struct nfsd4_callback *cb,
struct rpc_task *task)
{
trace_nfsd_cb_recall_any_done(cb, task);
switch (task->tk_status) {
case -NFS4ERR_DELAY:
rpc_delay(task, 2 * HZ);
return 0;
default:
return 1;
}
}
static void
nfsd4_cb_recall_any_release(struct nfsd4_callback *cb)
{
struct nfs4_client *clp = cb->cb_clp;
nfsd4_put_client(clp);
}
Annotation
- Immediate include surface: `linux/file.h`, `linux/fs.h`, `linux/slab.h`, `linux/namei.h`, `linux/swap.h`, `linux/pagemap.h`, `linux/ratelimit.h`, `linux/sunrpc/svcauth_gss.h`.
- Detected declarations: `struct laundry_time`, `enum nfsd4_st_mutex_lock_subclass`, `enum rp_lock`, `function nfsd4_create_laundry_wq`, `function nfsd4_destroy_laundry_wq`, `function is_session_dead`, `function mark_session_dead_locked`, `function is_client_expired`, `function nfsd4_dec_courtesy_client_count`, `function get_client_locked`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.