2018-06-14 13:39:25

by Anna Schumaker

[permalink] [raw]
Subject: [PATCH] NFS: Fix an rcu deadlock in nfs_delegation_find_inode()

From: Anna Schumaker <[email protected]>

I was able to reproduce this pretty regularily using xfstests
generic/013 on NFS v4.0.

Reported-by: Ross Zwisler <[email protected]>
Fixes: a337fe91 (NFSv4: Return NFS4ERR_DELAY when a delegation recall fails due to igrab())
Signed-off-by: Anna Schumaker <[email protected]>
---
fs/nfs/delegation.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index bbd0465535eb..f033f3a69a3b 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -883,8 +883,10 @@ struct inode *nfs_delegation_find_inode(struct nfs_client *clp,
rcu_read_lock();
list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) {
res = nfs_delegation_find_inode_server(server, fhandle);
- if (res != ERR_PTR(-ENOENT))
+ if (res != ERR_PTR(-ENOENT)) {
+ rcu_read_unlock();
return res;
+ }
}
rcu_read_unlock();
return ERR_PTR(-ENOENT);
--
2.17.1



2018-06-14 16:26:25

by Trond Myklebust

[permalink] [raw]
Subject: Re: [PATCH] NFS: Fix an rcu deadlock in nfs_delegation_find_inode()

T24gVGh1LCAyMDE4LTA2LTE0IGF0IDA5OjM5IC0wNDAwLCBzY2h1bWFrZXIuYW5uYUBnbWFpbC5j
b20gd3JvdGU6DQo+IEZyb206IEFubmEgU2NodW1ha2VyIDxBbm5hLlNjaHVtYWtlckBOZXRhcHAu
Y29tPg0KPiANCj4gSSB3YXMgYWJsZSB0byByZXByb2R1Y2UgdGhpcyBwcmV0dHkgcmVndWxhcmls
eSB1c2luZyB4ZnN0ZXN0cw0KPiBnZW5lcmljLzAxMyBvbiBORlMgdjQuMC4NCj4gDQo+IFJlcG9y
dGVkLWJ5OiBSb3NzIFp3aXNsZXIgPFJvc3MuWndpc2xlckBsaW51eC5pbnRlbC5jb20+DQo+IEZp
eG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