aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@hammerspace.com>2018-11-13 16:37:54 -0500
committerTrond Myklebust <trond.myklebust@hammerspace.com>2018-11-13 17:15:17 -0500
commite39d8a186ed002854196668cb7562ffdfbc6d379 (patch)
treed184e95ec9eff9dc0f77b20d6c59aae9520570ea
parente3d5e573a54dabdc0f9f3cb039d799323372b251 (diff)
NFSv4: Fix an Oops during delegation callbacks
If the server sends a CB_GETATTR or a CB_RECALL while the filesystem is being unmounted, then we can Oops when releasing the inode in nfs4_callback_getattr() and nfs4_callback_recall(). Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
-rw-r--r--fs/nfs/callback_proc.c4
-rw-r--r--fs/nfs/delegation.c11
2 files changed, 11 insertions, 4 deletions
diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
index fa515d5ea5ba..7b861bbc0b43 100644
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -66,7 +66,7 @@ __be32 nfs4_callback_getattr(void *argp, void *resp,
66out_iput: 66out_iput:
67 rcu_read_unlock(); 67 rcu_read_unlock();
68 trace_nfs4_cb_getattr(cps->clp, &args->fh, inode, -ntohl(res->status)); 68 trace_nfs4_cb_getattr(cps->clp, &args->fh, inode, -ntohl(res->status));
69 iput(inode); 69 nfs_iput_and_deactive(inode);
70out: 70out:
71 dprintk("%s: exit with status = %d\n", __func__, ntohl(res->status)); 71 dprintk("%s: exit with status = %d\n", __func__, ntohl(res->status));
72 return res->status; 72 return res->status;
@@ -108,7 +108,7 @@ __be32 nfs4_callback_recall(void *argp, void *resp,
108 } 108 }
109 trace_nfs4_cb_recall(cps->clp, &args->fh, inode, 109 trace_nfs4_cb_recall(cps->clp, &args->fh, inode,
110 &args->stateid, -ntohl(res)); 110 &args->stateid, -ntohl(res));
111 iput(inode); 111 nfs_iput_and_deactive(inode);
112out: 112out:
113 dprintk("%s: exit with status = %d\n", __func__, ntohl(res)); 113 dprintk("%s: exit with status = %d\n", __func__, ntohl(res));
114 return res; 114 return res;
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index 07b839560576..6ec2f78c1e19 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -850,16 +850,23 @@ nfs_delegation_find_inode_server(struct nfs_server *server,
850 const struct nfs_fh *fhandle) 850 const struct nfs_fh *fhandle)
851{ 851{
852 struct nfs_delegation *delegation; 852 struct nfs_delegation *delegation;
853 struct inode *res = NULL; 853 struct inode *freeme, *res = NULL;
854 854
855 list_for_each_entry_rcu(delegation, &server->delegations, super_list) { 855 list_for_each_entry_rcu(delegation, &server->delegations, super_list) {
856 spin_lock(&delegation->lock); 856 spin_lock(&delegation->lock);
857 if (delegation->inode != NULL && 857 if (delegation->inode != NULL &&
858 nfs_compare_fh(fhandle, &NFS_I(delegation->inode)->fh) == 0) { 858 nfs_compare_fh(fhandle, &NFS_I(delegation->inode)->fh) == 0) {
859 res = igrab(delegation->inode); 859 freeme = igrab(delegation->inode);
860 if (freeme && nfs_sb_active(freeme->i_sb))
861 res = freeme;
860 spin_unlock(&delegation->lock); 862 spin_unlock(&delegation->lock);
861 if (res != NULL) 863 if (res != NULL)
862 return res; 864 return res;
865 if (freeme) {
866 rcu_read_unlock();
867 iput(freeme);
868 rcu_read_lock();
869 }
863 return ERR_PTR(-EAGAIN); 870 return ERR_PTR(-EAGAIN);
864 } 871 }
865 spin_unlock(&delegation->lock); 872 spin_unlock(&delegation->lock);