afs: Make callback processing more efficient.
authorDavid Howells <dhowells@redhat.com>
Fri, 27 Mar 2020 15:02:44 +0000 (15:02 +0000)
committerDavid Howells <dhowells@redhat.com>
Sun, 31 May 2020 14:19:51 +0000 (15:19 +0100)
commit8230fd8217b7ea76f838ae88e4a5a8e54f37099f
treec395ba533ee29c24e1ce7e4c0b9f65f8b14e0972
parent6d043a578265e8c24384648f9c74c8874b429f28
afs: Make callback processing more efficient.

afs_vol_interest objects represent the volume IDs currently being accessed
from a fileserver.  These hold lists of afs_cb_interest objects that
repesent the superblocks using that volume ID on that server.

When a callback notification from the server telling of a modification by
another client arrives, the volume ID specified in the notification is
looked up in the server's afs_vol_interest list.  Through the
afs_cb_interest list, the relevant superblocks can be iterated over and the
specific inode looked up and marked in each one.

Make the following efficiency improvements:

 (1) Hold rcu_read_lock() over the entire processing rather than locking it
     each time.

 (2) Do all the callbacks for each vid together rather than individually.
     Each volume then only needs to be looked up once.

 (3) afs_vol_interest objects are now stored in an rb_tree rather than a
     flat list to reduce the lookup step count.

 (4) afs_vol_interest lookup is now done with RCU, but because it's in an
     rb_tree which may rotate under us, a seqlock is used so that if it
     changes during the walk, we repeat the walk with a lock held.

With this and the preceding patch which adds RCU-based lookups in the inode
cache, target volumes/vnodes can be taken without the need to take any
locks, except on the target itself.

Signed-off-by: David Howells <dhowells@redhat.com>
fs/afs/callback.c
fs/afs/internal.h
fs/afs/server.c