[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241216142156.4133267-5-yangerkun@huaweicloud.com>
Date: Mon, 16 Dec 2024 22:21:55 +0800
From: Yang Erkun <yangerkun@...weicloud.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,
linux-nfs@...r.kernel.org,
netdev@...r.kernel.org
Cc: yangerkun@...wei.com,
yangerkun@...weicloud.com,
yi.zhang@...wei.com
Subject: [RFC PATCH 4/5] SUNRPC: no need get cache ref when protected by rcu
From: Yang Erkun <yangerkun@...wei.com>
rcu_read_lock/rcu_read_unlock has already protect any ptr we will
when we call c_show. No need get cache ref. Besides, cache_put may drop
the last ref for cache_head, and the .put like expkey_put/svc_export_put
will call dput, which may sleep, and this will break rcu protection.
Fixes: ae74136b4bb6 ("SUNRPC: Allow cache lookups to use RCU protection rather than the r/w spinlock")
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 eaf4defd1fcf..01745a6f595d 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -1425,18 +1425,12 @@ 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_put(cp, cd);
+ if (cache_check(cd, cp, NULL))
/* cache_check does a cache_put on failure */
seq_puts(m, "# ");
- } else {
- if (cache_is_expired(cd, cp))
- seq_puts(m, "# ");
- cache_put(cp, cd);
- }
+ else if (cache_is_expired(cd, cp))
+ seq_puts(m, "# ");
return cd->cache_show(m, cd, cp);
}
--
2.39.2
Powered by blists - more mailing lists