[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241225065908.1547645-4-yangerkun@huawei.com>
Date: Wed, 25 Dec 2024 14:59:07 +0800
From: Yang Erkun <yangerkun@...wei.com>
To: chuck.lever@...cle.com,
jlayton@...nel.org,
neilb@...e.de,
okorniev@...hat.com,
Dai.Ngo@...cle.com,
tom@...pey.com,
trondmy@...nel.org,
anna@...nel.org,
davem@...emloft.net,
edumazet@...gle.com,
kuba@...nel.org,
pabeni@...hat.com,
horms@...nel.org
Cc: linux-nfs@...r.kernel.org,
netdev@...r.kernel.org,
yangerkun@...wei.com,
yangerkun@...weicloud.com,
liumingrui@...wei.com
Subject: [PATCH v2 3/4] SUNRPC: no need get cache ref when protected by rcu
rcu_read_lock/rcu_read_unlock has already provide protection for the
pointer we will reference when we call c_show. Therefore, there is no
need to obtain a cache reference to help protect cache_head.
Additionally, the .put such as expkey_put/svc_export_put will invoke
dput, which can sleep and break rcu. Stop get cache reference to fix
them all.
Fixes: ae74136b4bb6 ("SUNRPC: Allow cache lookups to use RCU protection rather than the r/w spinlock")
Suggested-by: NeilBrown <neilb@...e.de>
Signed-off-by: Yang Erkun <yangerkun@...wei.com>
---
net/sunrpc/cache.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index 88f42a27c8cc..cb279eb9ac4b 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -1438,17 +1438,11 @@ static int c_show(struct seq_file *m, void *p)
seq_printf(m, "# expiry=%lld refcnt=%d flags=%lx\n",
convert_to_wallclock(cp->expiry_time),
kref_read(&cp->ref), cp->flags);
- if (!cache_get_rcu(cp))
- return 0;
- if (cache_check(cd, cp, NULL))
- /* cache_check does a cache_put on failure */
+ if (cache_check_rcu(cd, cp, NULL))
+ seq_puts(m, "# ");
+ else if (cache_is_expired(cd, cp))
seq_puts(m, "# ");
- else {
- if (cache_is_expired(cd, cp))
- seq_puts(m, "# ");
- cache_put(cp, cd);
- }
return cd->cache_show(m, cd, cp);
}
--
2.46.1
Powered by blists - more mailing lists