fs/nfs/unlink.c
Source file repositories/reference/linux-study-clean/fs/nfs/unlink.c
File Facts
- System
- Linux kernel
- Corpus path
fs/nfs/unlink.c- Extension
.c- Size
- 14699 bytes
- Lines
- 533
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source 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.
- 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/slab.hlinux/string.hlinux/dcache.hlinux/sunrpc/sched.hlinux/sunrpc/clnt.hlinux/nfs_fs.hlinux/sched.hlinux/wait.hlinux/namei.hlinux/fsnotify.hinternal.hnfs4_fs.hiostat.hdelegation.hnfstrace.h
Detected Declarations
function nfs_free_unlinkdatafunction nfs_async_unlink_donefunction nfs_async_unlink_releasefunction nfs_unlink_preparefunction nfs_do_call_unlinkfunction nfs_call_unlinkfunction nfs_async_unlinkfunction nfs_complete_unlinkfunction nfs_cancel_async_unlinkfunction nfs_async_rename_donefunction nfs_async_rename_releasefunction nfs_rename_preparefunction nfs_async_renamefunction nfs_complete_sillyrenamefunction nfs_sillyrename
Annotated Snippet
if (data->new_dir != data->old_dir) {
spin_lock(&data->new_dir->i_lock);
nfs_force_lookup_revalidate(data->new_dir);
spin_unlock(&data->new_dir->i_lock);
}
}
dput(data->old_dentry);
dput(data->new_dentry);
iput(data->old_dir);
iput(data->new_dir);
nfs_sb_deactive(sb);
put_cred(data->cred);
kfree(data);
}
static void nfs_rename_prepare(struct rpc_task *task, void *calldata)
{
struct nfs_renamedata *data = calldata;
NFS_PROTO(data->old_dir)->rename_rpc_prepare(task, data);
}
static const struct rpc_call_ops nfs_rename_ops = {
.rpc_call_done = nfs_async_rename_done,
.rpc_release = nfs_async_rename_release,
.rpc_call_prepare = nfs_rename_prepare,
};
/**
* nfs_async_rename - perform an asynchronous rename operation
* @old_dir: directory that currently holds the dentry to be renamed
* @new_dir: target directory for the rename
* @old_dentry: original dentry to be renamed
* @new_dentry: dentry to which the old_dentry should be renamed
* @complete: Function to run on successful completion
*
* It's expected that valid references to the dentries and inodes are held
*/
struct rpc_task *
nfs_async_rename(struct inode *old_dir, struct inode *new_dir,
struct dentry *old_dentry, struct dentry *new_dentry,
void (*complete)(struct rpc_task *, struct nfs_renamedata *))
{
struct nfs_renamedata *data;
struct rpc_message msg = { };
struct rpc_task_setup task_setup_data = {
.rpc_message = &msg,
.callback_ops = &nfs_rename_ops,
.workqueue = nfsiod_workqueue,
.rpc_client = NFS_CLIENT(old_dir),
.flags = RPC_TASK_ASYNC | RPC_TASK_CRED_NOREF,
};
if (nfs_server_capable(old_dir, NFS_CAP_MOVEABLE) &&
nfs_server_capable(new_dir, NFS_CAP_MOVEABLE))
task_setup_data.flags |= RPC_TASK_MOVEABLE;
data = kzalloc_obj(*data);
if (data == NULL)
return ERR_PTR(-ENOMEM);
task_setup_data.task = &data->task;
task_setup_data.callback_data = data;
data->cred = get_current_cred();
msg.rpc_argp = &data->args;
msg.rpc_resp = &data->res;
msg.rpc_cred = data->cred;
/* set up nfs_renamedata */
data->old_dir = old_dir;
ihold(old_dir);
data->new_dir = new_dir;
ihold(new_dir);
data->old_dentry = dget(old_dentry);
data->new_dentry = dget(new_dentry);
nfs_fattr_init(&data->old_fattr);
nfs_fattr_init(&data->new_fattr);
data->complete = complete;
/* set up nfs_renameargs */
data->args.old_dir = NFS_FH(old_dir);
data->args.old_name = &old_dentry->d_name;
data->args.new_dir = NFS_FH(new_dir);
data->args.new_name = &new_dentry->d_name;
/* set up nfs_renameres */
data->res.old_fattr = &data->old_fattr;
data->res.new_fattr = &data->new_fattr;
Annotation
- Immediate include surface: `linux/slab.h`, `linux/string.h`, `linux/dcache.h`, `linux/sunrpc/sched.h`, `linux/sunrpc/clnt.h`, `linux/nfs_fs.h`, `linux/sched.h`, `linux/wait.h`.
- Detected declarations: `function nfs_free_unlinkdata`, `function nfs_async_unlink_done`, `function nfs_async_unlink_release`, `function nfs_unlink_prepare`, `function nfs_do_call_unlink`, `function nfs_call_unlink`, `function nfs_async_unlink`, `function nfs_complete_unlink`, `function nfs_cancel_async_unlink`, `function nfs_async_rename_done`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source 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.