Skip to contentSkip to conversation

nfsd: NFSD_FILE_KEY_INODE only needs to find GC'ed entries

PATCH New Jeff Layton 1 participant 2 messages Jan 6, 2023

Subsystems (2)
lore
Share & tools
lore

Jeff Layton

author maintainer
#0 lore raw

PATCH v2 1/1 nfsd: NFSD_FILE_KEY_INODE only needs to find GC'ed entries

Since v4 files are expected to be long-lived, there's little value in closing them out of the cache when there is conflicting access.

Change the comparator to also match the gc value in the key. Change both of the current users of that key to set the gc value in the key to "true".

---
 fs/nfsd/filecache.c | 4 ++++
 1 file changed, 4 insertions(+)
fs/nfsd/filecache.c +4 -0
index d630b4b74783..3b52c1888421 100644
@@ -175,6 +175,8 @@ static int nfsd_file_obj_cmpfn(struct rhashtable_compare_arg *arg,
 
 	switch (key->type) {
 	case NFSD_FILE_KEY_INODE:
+		if (test_bit(NFSD_FILE_GC, &nf->nf_flags) != key->gc)
+			return 1;
 		if (nf->nf_inode != key->inode)
 			return 1;
 		break;
@@ -683,6 +685,7 @@ nfsd_file_queue_for_close(struct inode *inode, struct list_head *dispose)
 	struct nfsd_file_lookup_key key = {
 		.type	= NFSD_FILE_KEY_INODE,
 		.inode	= inode,
+		.gc	= true,
 	};
 	struct nfsd_file *nf;
 
@@ -1059,6 +1062,7 @@ nfsd_file_is_cached(struct inode *inode)
 	struct nfsd_file_lookup_key key = {
 		.type	= NFSD_FILE_KEY_INODE,
 		.inode	= inode,
+		.gc	= true,
 	};
 	bool ret = false;
 
Signature · 1 line
2.39.0
author maintainer
#1 lore raw

PATCH v2 1/1 nfsd: simplify test_bit return in NFSD_FILE_KEY_FULL comparator

test_bit returns bool, so we can just compare the result of that to the key->gc value without the "!!".

---
 fs/nfsd/filecache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfsd/filecache.c +1 -1
index 3b52c1888421..2e9576ab9478 100644
@@ -189,7 +189,7 @@ static int nfsd_file_obj_cmpfn(struct rhashtable_compare_arg *arg,
 			return 1;
 		if (!nfsd_match_cred(nf->nf_cred, key->cred))
 			return 1;
-		if (!!test_bit(NFSD_FILE_GC, &nf->nf_flags) != key->gc)
+		if (test_bit(NFSD_FILE_GC, &nf->nf_flags) != key->gc)
 			return 1;
 		if (test_bit(NFSD_FILE_HASHED, &nf->nf_flags) == 0)
 			return 1;
Signature · 1 line
2.39.0