[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <165643958472.84360.12808478593932401447.stgit@manet.1015granger.net>
Date: Tue, 28 Jun 2022 14:06:24 -0400
From: Chuck Lever <chuck.lever@...cle.com>
To: linux-nfs@...r.kernel.org, netdev@...r.kernel.org
Cc: david@...morbit.com, jlayton@...hat.com, tgraf@...g.ch
Subject: [PATCH v2 06/31] NFSD: Add nfsd_file_lru_dispose_list() helper
Refactor the invariant part of nfsd_file_lru_walk_list() into a
separate helper function.
Signed-off-by: Chuck Lever <chuck.lever@...cle.com>
---
fs/nfsd/filecache.c | 29 ++++++++++++++++++++++-------
1 file changed, 22 insertions(+), 7 deletions(-)
diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c
index da48c51a2bf0..b278030e0a12 100644
--- a/fs/nfsd/filecache.c
+++ b/fs/nfsd/filecache.c
@@ -457,11 +457,31 @@ nfsd_file_lru_cb(struct list_head *item, struct list_lru_one *lru,
return LRU_SKIP;
}
+/*
+ * Unhash items on @dispose immediately, then queue them on the
+ * disposal workqueue to finish releasing them in the background.
+ *
+ * cel: Note that between the time list_lru_shrink_walk runs and
+ * now, these items are in the hash table but marked unhashed.
+ * Why release these outside of lru_cb ? There's no lock ordering
+ * problem since lru_cb currently takes no lock.
+ */
+static void nfsd_file_gc_dispose_list(struct list_head *dispose)
+{
+ struct nfsd_file *nf;
+
+ list_for_each_entry(nf, dispose, nf_lru) {
+ spin_lock(&nfsd_file_hashtbl[nf->nf_hashval].nfb_lock);
+ nfsd_file_do_unhash(nf);
+ spin_unlock(&nfsd_file_hashtbl[nf->nf_hashval].nfb_lock);
+ }
+ nfsd_file_dispose_list_delayed(dispose);
+}
+
static unsigned long
nfsd_file_lru_walk_list(struct shrink_control *sc)
{
LIST_HEAD(head);
- struct nfsd_file *nf;
unsigned long ret;
if (sc)
@@ -471,12 +491,7 @@ nfsd_file_lru_walk_list(struct shrink_control *sc)
ret = list_lru_walk(&nfsd_file_lru,
nfsd_file_lru_cb,
&head, LONG_MAX);
- list_for_each_entry(nf, &head, nf_lru) {
- spin_lock(&nfsd_file_hashtbl[nf->nf_hashval].nfb_lock);
- nfsd_file_do_unhash(nf);
- spin_unlock(&nfsd_file_hashtbl[nf->nf_hashval].nfb_lock);
- }
- nfsd_file_dispose_list_delayed(&head);
+ nfsd_file_gc_dispose_list(&head);
return ret;
}
Powered by blists - more mailing lists