Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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@suse.de>
Signed-off-by: Yang Erkun <yangerkun@huawei.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>

authored by

Yang Erkun and committed by
Chuck Lever
1b10f0b6 c224edca

+3 -9
+3 -9
net/sunrpc/cache.c
··· 1438 1438 seq_printf(m, "# expiry=%lld refcnt=%d flags=%lx\n", 1439 1439 convert_to_wallclock(cp->expiry_time), 1440 1440 kref_read(&cp->ref), cp->flags); 1441 - if (!cache_get_rcu(cp)) 1442 - return 0; 1443 1441 1444 - if (cache_check(cd, cp, NULL)) 1445 - /* cache_check does a cache_put on failure */ 1442 + if (cache_check_rcu(cd, cp, NULL)) 1446 1443 seq_puts(m, "# "); 1447 - else { 1448 - if (cache_is_expired(cd, cp)) 1449 - seq_puts(m, "# "); 1450 - cache_put(cp, cd); 1451 - } 1444 + else if (cache_is_expired(cd, cp)) 1445 + seq_puts(m, "# "); 1452 1446 1453 1447 return cd->cache_show(m, cd, cp); 1454 1448 }