NFS: Add a delegation return into nfs4_proc_unlink_setup()
authorTrond Myklebust <trond.myklebust@primarydata.com>
Tue, 20 Mar 2018 20:43:17 +0000 (16:43 -0400)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Tue, 10 Apr 2018 20:06:22 +0000 (16:06 -0400)
Ensure that when we do finally delete the file, then we return the
delegation.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
fs/nfs/nfs3proc.c
fs/nfs/nfs4proc.c
fs/nfs/proc.c
fs/nfs/unlink.c
include/linux/nfs_xdr.h

index 08875dc17b524b4dec555c022badac516eddc8a7..ae03307bd8cdf1d4284186611a0bc0dc073d1d19 100644 (file)
@@ -411,7 +411,7 @@ out:
 }
 
 static void
-nfs3_proc_unlink_setup(struct rpc_message *msg, struct inode *dir)
+nfs3_proc_unlink_setup(struct rpc_message *msg, struct dentry *dentry)
 {
        msg->rpc_proc = &nfs3_procedures[NFS3PROC_REMOVE];
 }
index b06a820b570d0656ab8fde72de723b85cba14de8..21daeac114febd62a8b1bc9ce6fa392fe5f05369 100644 (file)
@@ -4231,17 +4231,20 @@ static int nfs4_proc_rmdir(struct inode *dir, const struct qstr *name)
        return err;
 }
 
-static void nfs4_proc_unlink_setup(struct rpc_message *msg, struct inode *dir)
+static void nfs4_proc_unlink_setup(struct rpc_message *msg, struct dentry *dentry)
 {
-       struct nfs_server *server = NFS_SERVER(dir);
        struct nfs_removeargs *args = msg->rpc_argp;
        struct nfs_removeres *res = msg->rpc_resp;
+       struct inode *inode = d_inode(dentry);
 
-       res->server = server;
+       res->server = NFS_SB(dentry->d_sb);
        msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_REMOVE];
        nfs4_init_sequence(&args->seq_args, &res->seq_res, 1);
 
        nfs_fattr_init(res->dir_attr);
+
+       if (inode)
+               nfs4_inode_return_delegation(inode);
 }
 
 static void nfs4_proc_unlink_rpc_prepare(struct rpc_task *task, struct nfs_unlinkdata *data)
index 39dc9276b1f63ae5b4f51b9ad1ff930916a4c752..318b3f34a6d02a24d63026f5ebbae730e91fc6a6 100644 (file)
@@ -321,7 +321,7 @@ nfs_proc_remove(struct inode *dir, struct dentry *dentry)
 }
 
 static void
-nfs_proc_unlink_setup(struct rpc_message *msg, struct inode *dir)
+nfs_proc_unlink_setup(struct rpc_message *msg, struct dentry *dentry)
 {
        msg->rpc_proc = &nfs_procedures[NFSPROC_REMOVE];
 }
index 44f101411422512d531f1b1f58249923ccb21f38..bf54fc9ae135fa3098bbfb4e713835cabde77c20 100644 (file)
@@ -105,7 +105,7 @@ static void nfs_do_call_unlink(struct nfs_unlinkdata *data)
        data->args.fh = NFS_FH(dir);
        nfs_fattr_init(data->res.dir_attr);
 
-       NFS_PROTO(dir)->unlink_setup(&msg, dir);
+       NFS_PROTO(dir)->unlink_setup(&msg, data->dentry);
 
        task_setup_data.rpc_client = NFS_CLIENT(dir);
        task = rpc_run_task(&task_setup_data);
index 4b87e2d726b1f4d84583ea0250a98d8df7acb08b..c4ba58b3c0f816c732642117b9bd706e0edf06cb 100644 (file)
@@ -1591,7 +1591,7 @@ struct nfs_rpc_ops {
        int     (*create)  (struct inode *, struct dentry *,
                            struct iattr *, int);
        int     (*remove)  (struct inode *, struct dentry *);
-       void    (*unlink_setup)  (struct rpc_message *, struct inode *dir);
+       void    (*unlink_setup)  (struct rpc_message *, struct dentry *);
        void    (*unlink_rpc_prepare) (struct rpc_task *, struct nfs_unlinkdata *);
        int     (*unlink_done) (struct rpc_task *, struct inode *);
        void    (*rename_setup)  (struct rpc_message *msg,