summaryrefslogtreecommitdiffstats
path: root/fs/nfs/delegation.c
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@hammerspace.com>2018-11-13 16:37:54 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-12-01 09:37:33 +0100
commitb5ccf0038f34a5a207d9c33d8cc1e40b2faf6725 (patch)
tree6077272bdd892acf84b2d6d0531f3d1370e42538 /fs/nfs/delegation.c
parent2bc40f89f47e3b6fb63a2b186073ef1ce75dca53 (diff)
downloadlinux-stable-b5ccf0038f34a5a207d9c33d8cc1e40b2faf6725.tar.gz
linux-stable-b5ccf0038f34a5a207d9c33d8cc1e40b2faf6725.tar.bz2
linux-stable-b5ccf0038f34a5a207d9c33d8cc1e40b2faf6725.zip
NFSv4: Fix an Oops during delegation callbacks
[ Upstream commit e39d8a186ed002854196668cb7562ffdfbc6d379 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs/nfs/delegation.c')
-rw-r--r--fs/nfs/delegation.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index f033f3a69a3b..75fe92eaa681 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -849,16 +849,23 @@ nfs_delegation_find_inode_server(struct nfs_server *server,
const struct nfs_fh *fhandle)
{
struct nfs_delegation *delegation;
- struct inode *res = NULL;
+ struct inode *freeme, *res = NULL;
list_for_each_entry_rcu(delegation, &server->delegations, super_list) {
spin_lock(&delegation->lock);
if (delegation->inode != NULL &&
nfs_compare_fh(fhandle, &NFS_I(delegation->inode)->fh) == 0) {
- res = igrab(delegation->inode);
+ freeme = igrab(delegation->inode);
+ if (freeme && nfs_sb_active(freeme->i_sb))
+ res = freeme;
spin_unlock(&delegation->lock);
if (res != NULL)
return res;
+ if (freeme) {
+ rcu_read_unlock();
+ iput(freeme);
+ rcu_read_lock();
+ }
return ERR_PTR(-EAGAIN);
}
spin_unlock(&delegation->lock);