@@ -786,7 +786,10 @@ nfsd_file_cache_init(void)
goto out;
}
-/*
+/**
+ * nfsd_file_cache_purge - Remove all cache items associated with @net
+ * @net: target net namespace
+ *
* Note this can deadlock with nfsd_file_lru_cb.
*/
void
@@ -798,6 +801,8 @@ nfsd_file_cache_purge(struct net *net)
LIST_HEAD(dispose);
bool del;
+ lockdep_assert_held(&nfsd_mutex);
+
if (!nfsd_file_hashtbl)
return;
@@ -1000,6 +1005,7 @@ nfsd_do_file_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp,
inode = d_inode(fhp->fh_dentry);
hashval = (unsigned int)hash_long(inode->i_ino, NFSD_FILE_HASH_BITS);
retry:
+ /* Avoid allocation if the item is already in cache */
rcu_read_lock();
nf = nfsd_file_find_locked(inode, may_flags, hashval, net);
rcu_read_unlock();
In particular, document that the caller must hold nfsd_mutex. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> --- fs/nfsd/filecache.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)