On 2022-07-04 00:53:06, Dan Aloni wrote: > On 2018-10-23 12:34:01, Trond Myklebust wrote: > > @@ -456,32 +495,24 @@ rpcauth_prune_expired(struct list_head *free, int nr_to_scan) > > > > if (nr_to_scan-- == 0) > > break; > > + if (atomic_read(&cred->cr_count) > 1) { > > + rpcauth_lru_remove_locked(cred); > > + continue; > > + } > > /* > > * Enforce a 60 second garbage collection moratorium > > * Note that the cred_unused list must be time-ordered. > > */ > > - if (time_in_range(cred->cr_expire, expired, jiffies) && > > - test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) != 0) { > > - freed = SHRINK_STOP; > > - break; > > - } > > - > > - list_del_init(&cred->cr_lru); > > - number_cred_unused--; > > - freed++; > > - if (atomic_read(&cred->cr_count) != 0) > > + if (!time_in_range(cred->cr_expire, expired, jiffies)) > > + continue; > > + if (!rpcauth_unhash_cred(cred)) > > continue; > > With `!` flipping the `time_in_range(...)` condition in this past > change, looks like we are skipping the head of the LRU which should be > pruned, so actual expiry does not happen at all in case there are more > than about 100 old items in the LRU. > > Reverting this, I saw the correct behavior taking place. v2: Made a better explanation in the commit message. -- >8 -- Subject: [PATCH] sunrpc: fix expiry of auth creds Before this commit, with a large enough LRU of expired items (100), the loop skipped all the expired items and was entirely ineffectual in trimming the LRU list. Fixes: 95cd623250ad ('SUNRPC: Clean up the AUTH cache code') Signed-off-by: Dan Aloni <dan.aloni@xxxxxxxxxxxx> --- net/sunrpc/auth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c index 682fcd24bf43..2324d1e58f21 100644 --- a/net/sunrpc/auth.c +++ b/net/sunrpc/auth.c @@ -445,7 +445,7 @@ rpcauth_prune_expired(struct list_head *free, int nr_to_scan) * Enforce a 60 second garbage collection moratorium * Note that the cred_unused list must be time-ordered. */ - if (!time_in_range(cred->cr_expire, expired, jiffies)) + if (time_in_range(cred->cr_expire, expired, jiffies)) continue; if (!rpcauth_unhash_cred(cred)) continue; -- 2.23.0 -- Dan Aloni