aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2014-03-17 07:06:54 -0400
committerTrond Myklebust <trond.myklebust@primarydata.com>2014-03-17 15:14:16 -0400
commit96f9d8c0740264c5e2975361389ff2c21f2c5a4d (patch)
tree31cb4f6c6ca48895094c0ea0811a06aae844a5db /fs
parent4f14c194a996e75c01e44a8832f1d983ccaeefc0 (diff)
nfs: abstract out code needed to complete a sillyrename
The async rename code is currently "polluted" with some parts that are really just for sillyrenames. Add a new "complete" operation vector to the nfs_renamedata to separate out the stuff that just needs to be done for a sillyrename. Signed-off-by: Jeff Layton <jlayton@redhat.com> Tested-by: Anna Schumaker <Anna.Schumaker@netapp.com> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfs/unlink.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/fs/nfs/unlink.c b/fs/nfs/unlink.c
index 11d78944de79..3e6798c9ba1f 100644
--- a/fs/nfs/unlink.c
+++ b/fs/nfs/unlink.c
@@ -353,8 +353,8 @@ static void nfs_async_rename_done(struct rpc_task *task, void *calldata)
353 return; 353 return;
354 } 354 }
355 355
356 if (task->tk_status != 0) 356 if (data->complete)
357 nfs_cancel_async_unlink(old_dentry); 357 data->complete(task, data);
358} 358}
359 359
360/** 360/**
@@ -401,7 +401,8 @@ static const struct rpc_call_ops nfs_rename_ops = {
401 */ 401 */
402static struct rpc_task * 402static struct rpc_task *
403nfs_async_rename(struct inode *old_dir, struct inode *new_dir, 403nfs_async_rename(struct inode *old_dir, struct inode *new_dir,
404 struct dentry *old_dentry, struct dentry *new_dentry) 404 struct dentry *old_dentry, struct dentry *new_dentry,
405 void (*complete)(struct rpc_task *, struct nfs_renamedata *))
405{ 406{
406 struct nfs_renamedata *data; 407 struct nfs_renamedata *data;
407 struct rpc_message msg = { }; 408 struct rpc_message msg = { };
@@ -438,6 +439,7 @@ nfs_async_rename(struct inode *old_dir, struct inode *new_dir,
438 data->new_dentry = dget(new_dentry); 439 data->new_dentry = dget(new_dentry);
439 nfs_fattr_init(&data->old_fattr); 440 nfs_fattr_init(&data->old_fattr);
440 nfs_fattr_init(&data->new_fattr); 441 nfs_fattr_init(&data->new_fattr);
442 data->complete = complete;
441 443
442 /* set up nfs_renameargs */ 444 /* set up nfs_renameargs */
443 data->args.old_dir = NFS_FH(old_dir); 445 data->args.old_dir = NFS_FH(old_dir);
@@ -456,6 +458,17 @@ nfs_async_rename(struct inode *old_dir, struct inode *new_dir,
456 return rpc_run_task(&task_setup_data); 458 return rpc_run_task(&task_setup_data);
457} 459}
458 460
461/*
462 * Perform tasks needed when a sillyrename is done such as cancelling the
463 * queued async unlink if it failed.
464 */
465static void
466nfs_complete_sillyrename(struct rpc_task *task, struct nfs_renamedata *data)
467{
468 if (task->tk_status != 0)
469 nfs_cancel_async_unlink(data->old_dentry);
470}
471
459#define SILLYNAME_PREFIX ".nfs" 472#define SILLYNAME_PREFIX ".nfs"
460#define SILLYNAME_PREFIX_LEN ((unsigned)sizeof(SILLYNAME_PREFIX) - 1) 473#define SILLYNAME_PREFIX_LEN ((unsigned)sizeof(SILLYNAME_PREFIX) - 1)
461#define SILLYNAME_FILEID_LEN ((unsigned)sizeof(u64) << 1) 474#define SILLYNAME_FILEID_LEN ((unsigned)sizeof(u64) << 1)
@@ -548,7 +561,8 @@ nfs_sillyrename(struct inode *dir, struct dentry *dentry)
548 } 561 }
549 562
550 /* run the rename task, undo unlink if it fails */ 563 /* run the rename task, undo unlink if it fails */
551 task = nfs_async_rename(dir, dir, dentry, sdentry); 564 task = nfs_async_rename(dir, dir, dentry, sdentry,
565 nfs_complete_sillyrename);
552 if (IS_ERR(task)) { 566 if (IS_ERR(task)) {
553 error = -EBUSY; 567 error = -EBUSY;
554 nfs_cancel_async_unlink(dentry); 568 nfs_cancel_async_unlink(dentry);