Skip to content

Commit 2da2116

Browse files
Anna SchumakerTrond Myklebust
authored andcommitted
NFS: Request a directory delegation during RENAME
If we notice that we're renaming a file within a directory then we take that as a sign that the user is working with the current directory and may want a delegation to avoid extra revalidations when possible. The nfs_request_directory_delegation() function exists within the NFS v4 module, so I add an extra flag to rename_setup() to indicate if a dentry is being renamed within the same parent directory. Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
1 parent 156b094 commit 2da2116

5 files changed

Lines changed: 12 additions & 5 deletions

File tree

fs/nfs/nfs3proc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,8 @@ nfs3_proc_unlink_done(struct rpc_task *task, struct inode *dir)
483483
static void
484484
nfs3_proc_rename_setup(struct rpc_message *msg,
485485
struct dentry *old_dentry,
486-
struct dentry *new_dentry)
486+
struct dentry *new_dentry,
487+
struct inode *same_parent)
487488
{
488489
msg->rpc_proc = &nfs3_procedures[NFS3PROC_RENAME];
489490
}

fs/nfs/nfs4proc.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5060,7 +5060,8 @@ static int nfs4_proc_unlink_done(struct rpc_task *task, struct inode *dir)
50605060

50615061
static void nfs4_proc_rename_setup(struct rpc_message *msg,
50625062
struct dentry *old_dentry,
5063-
struct dentry *new_dentry)
5063+
struct dentry *new_dentry,
5064+
struct inode *same_parent)
50645065
{
50655066
struct nfs_renameargs *arg = msg->rpc_argp;
50665067
struct nfs_renameres *res = msg->rpc_resp;
@@ -5071,6 +5072,8 @@ static void nfs4_proc_rename_setup(struct rpc_message *msg,
50715072
nfs4_inode_make_writeable(old_inode);
50725073
if (new_inode)
50735074
nfs4_inode_return_delegation(new_inode);
5075+
if (same_parent)
5076+
nfs_request_directory_delegation(same_parent);
50745077
msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENAME];
50755078
res->server = NFS_SB(old_dentry->d_sb);
50765079
nfs4_init_sequence(&arg->seq_args, &res->seq_res, 1, 0);

fs/nfs/proc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,8 @@ static int nfs_proc_unlink_done(struct rpc_task *task, struct inode *dir)
353353
static void
354354
nfs_proc_rename_setup(struct rpc_message *msg,
355355
struct dentry *old_dentry,
356-
struct dentry *new_dentry)
356+
struct dentry *new_dentry,
357+
struct inode *same_parent)
357358
{
358359
msg->rpc_proc = &nfs_procedures[NFSPROC_RENAME];
359360
}

fs/nfs/unlink.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,8 @@ nfs_async_rename(struct inode *old_dir, struct inode *new_dir,
390390

391391
nfs_sb_active(old_dir->i_sb);
392392

393-
NFS_PROTO(data->old_dir)->rename_setup(&msg, old_dentry, new_dentry);
393+
NFS_PROTO(data->old_dir)->rename_setup(&msg, old_dentry, new_dentry,
394+
old_dir == new_dir ? old_dir : NULL);
394395

395396
return rpc_run_task(&task_setup_data);
396397
}

include/linux/nfs_xdr.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1808,7 +1808,8 @@ struct nfs_rpc_ops {
18081808
int (*unlink_done) (struct rpc_task *, struct inode *);
18091809
void (*rename_setup) (struct rpc_message *msg,
18101810
struct dentry *old_dentry,
1811-
struct dentry *new_dentry);
1811+
struct dentry *new_dentry,
1812+
struct inode *same_parent);
18121813
void (*rename_rpc_prepare)(struct rpc_task *task, struct nfs_renamedata *);
18131814
int (*rename_done) (struct rpc_task *task, struct inode *old_dir, struct inode *new_dir);
18141815
int (*link) (struct inode *, struct inode *, const struct qstr *);

0 commit comments

Comments
 (0)