Skip to content

Commit 1b10f0b

Browse files
Yang Erkunchucklever
authored andcommitted
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: ae74136 ("SUNRPC: Allow cache lookups to use RCU protection rather than the r/w spinlock") Suggested-by: NeilBrown <[email protected]> Signed-off-by: Yang Erkun <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent c224edc commit 1b10f0b

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

net/sunrpc/cache.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,17 +1438,11 @@ static int c_show(struct seq_file *m, void *p)
14381438
seq_printf(m, "# expiry=%lld refcnt=%d flags=%lx\n",
14391439
convert_to_wallclock(cp->expiry_time),
14401440
kref_read(&cp->ref), cp->flags);
1441-
if (!cache_get_rcu(cp))
1442-
return 0;
14431441

1444-
if (cache_check(cd, cp, NULL))
1445-
/* cache_check does a cache_put on failure */
1442+
if (cache_check_rcu(cd, cp, NULL))
1443+
seq_puts(m, "# ");
1444+
else if (cache_is_expired(cd, cp))
14461445
seq_puts(m, "# ");
1447-
else {
1448-
if (cache_is_expired(cd, cp))
1449-
seq_puts(m, "# ");
1450-
cache_put(cp, cd);
1451-
}
14521446

14531447
return cd->cache_show(m, cd, cp);
14541448
}

0 commit comments

Comments
 (0)