fs/lockd/clntproc.c
Source file repositories/reference/linux-study-clean/fs/lockd/clntproc.c
File Facts
- System
- Linux kernel
- Corpus path
fs/lockd/clntproc.c- Extension
.c- Size
- 23108 bytes
- Lines
- 890
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/module.hlinux/slab.hlinux/types.hlinux/errno.hlinux/fs.hlinux/filelock.hlinux/nfs_fs.hlinux/utsname.hlinux/freezer.hlinux/sunrpc/clnt.hlinux/sunrpc/svc.hlockd.htrace.h
Detected Declarations
function nlmclnt_next_cookiefunction nlmclnt_get_lockownerfunction nlmclnt_put_lockownerfunction nlm_pidbusyfunction __nlm_alloc_pidfunction nlmclnt_setlockargsfunction nlmclnt_release_lockargsfunction nlmclnt_procfunction nlmclnt_release_callfunction nlmclnt_rpc_releasefunction nlm_wait_on_gracefunction nlmclnt_callfunction nlm_do_async_callfunction nlm_async_callfunction nlm_async_replyfunction nlmclnt_async_callfunction nlmclnt_testfunction nlmclnt_locks_copy_lockfunction nlmclnt_locks_release_privatefunction nlmclnt_locks_init_privatefunction do_vfs_lockfunction nlmclnt_lockfunction nlmclnt_reclaimfunction nlmclnt_unlockfunction nlmclnt_unlock_preparefunction nlmclnt_unlock_callbackfunction nlmclnt_cancelfunction nlmclnt_cancel_callbackfunction nlm_stat_to_errnoexport nlmclnt_proc
Annotated Snippet
if (res == NULL && new != NULL) {
res = new;
refcount_set(&new->count, 1);
new->owner = owner;
new->pid = __nlm_alloc_pid(host);
new->host = nlm_get_host(host);
list_add(&new->list, &host->h_lockowners);
new = NULL;
}
}
spin_unlock(&host->h_lock);
kfree(new);
return res;
}
/*
* Initialize arguments for TEST/LOCK/UNLOCK/CANCEL calls
*/
static void nlmclnt_setlockargs(struct nlm_rqst *req, struct file_lock *fl)
{
struct lockd_args *argp = &req->a_args;
struct lockd_lock *lock = &argp->lock;
char *nodename = req->a_host->h_rpcclnt->cl_nodename;
nlmclnt_next_cookie(&argp->cookie);
memcpy(&lock->fh, NFS_FH(file_inode(fl->c.flc_file)),
sizeof(struct nfs_fh));
lock->caller = nodename;
lock->oh.data = req->a_owner;
lock->oh.len = snprintf(req->a_owner, sizeof(req->a_owner), "%u@%s",
(unsigned int)fl->fl_u.nfs_fl.owner->pid,
nodename);
lock->svid = fl->fl_u.nfs_fl.owner->pid;
lock->fl.fl_start = fl->fl_start;
lock->fl.fl_end = fl->fl_end;
lock->fl.c.flc_type = fl->c.flc_type;
}
static void nlmclnt_release_lockargs(struct nlm_rqst *req)
{
WARN_ON_ONCE(req->a_args.lock.fl.fl_ops != NULL);
}
/**
* nlmclnt_proc - Perform a single client-side lock request
* @host: address of a valid nlm_host context representing the NLM server
* @cmd: fcntl-style file lock operation to perform
* @fl: address of arguments for the lock operation
* @data: address of data to be sent to callback operations
*
*/
int nlmclnt_proc(struct nlm_host *host, int cmd, struct file_lock *fl, void *data)
{
struct nlm_rqst *call;
int status;
const struct nlmclnt_operations *nlmclnt_ops = host->h_nlmclnt_ops;
call = nlm_alloc_call(host);
if (call == NULL)
return -ENOMEM;
if (nlmclnt_ops && nlmclnt_ops->nlmclnt_alloc_call)
nlmclnt_ops->nlmclnt_alloc_call(data);
nlmclnt_locks_init_private(fl, host);
if (!fl->fl_u.nfs_fl.owner) {
/* lockowner allocation has failed */
nlmclnt_release_call(call);
return -ENOMEM;
}
/* Set up the argument struct */
nlmclnt_setlockargs(call, fl);
call->a_callback_data = data;
if (IS_SETLK(cmd) || IS_SETLKW(cmd)) {
if (fl->c.flc_type != F_UNLCK) {
call->a_args.block = IS_SETLKW(cmd) ? 1 : 0;
status = nlmclnt_lock(call, fl);
} else
status = nlmclnt_unlock(call, fl);
} else if (IS_GETLK(cmd))
status = nlmclnt_test(call, fl);
else
status = -EINVAL;
fl->fl_ops->fl_release_private(fl);
fl->fl_ops = NULL;
dprintk("lockd: clnt proc returns %d\n", status);
return status;
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `linux/types.h`, `linux/errno.h`, `linux/fs.h`, `linux/filelock.h`, `linux/nfs_fs.h`, `linux/utsname.h`.
- Detected declarations: `function nlmclnt_next_cookie`, `function nlmclnt_get_lockowner`, `function nlmclnt_put_lockowner`, `function nlm_pidbusy`, `function __nlm_alloc_pid`, `function nlmclnt_setlockargs`, `function nlmclnt_release_lockargs`, `function nlmclnt_proc`, `function nlmclnt_release_call`, `function nlmclnt_rpc_release`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: integration 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.