diff mbox series

[RFC,26/30] NFSD: Document nfsd_file_cache_purge() API contract

Message ID 165590733727.75778.2800164109345599121.stgit@manet.1015granger.net (mailing list archive)
State Superseded
Headers show
Series Overhaul NFSD filecache | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Chuck Lever June 22, 2022, 2:15 p.m. UTC
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(-)
diff mbox series

Patch

diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c
index 8b8d765a0df0..943db8cc87af 100644
--- a/fs/nfsd/filecache.c
+++ b/fs/nfsd/filecache.c
@@ -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();