afs: Avoid needless W-locks for afs_FindVCache 56/12656/4
authorAndrew Deason <adeason@sinenomine.net>
Thu, 13 Jul 2017 22:40:36 +0000 (17:40 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Fri, 3 Jul 2020 01:46:45 +0000 (21:46 -0400)
commit6c808e05adb0609e02cd61e3c6c4c09eb93c1630
tree5fca02ab5d36a7baf5e925e3a65272f0b47cf862
parente44d6441c8786fdaaa1fad1b1ae77704c12f7d60
afs: Avoid needless W-locks for afs_FindVCache

The callers of afs_FindVCache must hold at least a read lock on
afs_xvcache; some hold a shared or write lock (and set IS_SLOCK or
IS_WLOCK in the given flags). Two callers (afs_EvalFakeStat_int and
afs_DoBulkStat) currently hold a write lock, but neither of them need
to.

In the optimal case, where afs_FindVCache finds the given vcache, this
means that we unnecessarily hold a write lock on afs_xvcache. This can
impact performance, since afs_xvcache can be a very frequently
accessed lock (a simple operation like afs_PutVCache briefly holds a
read lock, for example).

To avoid this, have afs_DoBulkStat hold a shared lock on afs_xvcache,
upgrading to a write lock when needed. afs_EvalFakeStat_int doesn't
ever need a write lock at all, so just convert it to a read lock.

Change-Id: I5bd58b9e3a577c9e1ebf1bc3719e65a6c0af5cb8
Reviewed-on: https://gerrit.openafs.org/12656
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
src/afs/VNOPS/afs_vnop_lookup.c