Skip to content

Commit 4e80ef3

Browse files
committed
nfsd: rework refcounting in filecache
Bugzilla: https://bugzilla.redhat.com/2138605 commit ac3a258 Author: Jeff Layton <jlayton@kernel.org> Date: Sun Dec 11 06:19:33 2022 -0500 nfsd: rework refcounting in filecache The filecache refcounting is a bit non-standard for something searchable by RCU, in that we maintain a sentinel reference while it's hashed. This in turn requires that we have to do things differently in the "put" depending on whether its hashed, which we believe to have led to races. There are other problems in here too. nfsd_file_close_inode_sync can end up freeing an nfsd_file while there are still outstanding references to it, and there are a number of subtle ToC/ToU races. Rework the code so that the refcount is what drives the lifecycle. When the refcount goes to zero, then unhash and rcu free the object. A task searching for a nfsd_file is allowed to bump its refcount, but only if it's not already 0. Ensure that we don't make any other changes to it until a reference is held. With this change, the LRU carries a reference. Take special care to deal with it when removing an entry from the list, and ensure that we only repurpose the nf_lru list_head when the refcount is 0 to ensure exclusive access to it. Signed-off-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Jeffrey Layton <jlayton@redhat.com>
1 parent 2146c00 commit 4e80ef3

File tree

2 files changed

+189
-180
lines changed

2 files changed

+189
-180
lines changed

0 commit comments

Comments
 (0)