linux-stable/fs/afs
David Howells 453924de62 afs: Overhaul invalidation handling to better support RO volumes
Overhaul the third party-induced invalidation handling, making use of the
previously added volume-level event counters (cb_scrub and cb_ro_snapshot)
that are now being parsed out of the VolSync record returned by the
fileserver in many of its replies.

This allows better handling of RO (and Backup) volumes.  Since these are
snapshot of a RW volume that are updated atomically simultantanously across
all servers that host them, they only require a single callback promise for
the entire volume.  The currently upstream code assumes that RO volumes
operate in the same manner as RW volumes, and that each file has its own
individual callback - which means that it does a status fetch for *every*
file in a RO volume, whether or not the volume got "released" (volume
callback breaks can occur for other reasons too, such as the volumeserver
taking ownership of a volume from a fileserver).

To this end, make the following changes:

 (1) Change the meaning of the volume's cb_v_break counter so that it is
     now a hint that we need to issue a status fetch to work out the state
     of a volume.  cb_v_break is incremented by volume break callbacks and
     by server initialisation callbacks.

 (2) Add a second counter, cb_v_check, to the afs_volume struct such that
     if this differs from cb_v_break, we need to do a check.  When the
     check is complete, cb_v_check is advanced to what cb_v_break was at
     the start of the status fetch.

 (3) Move the list of mmap'd vnodes to the volume and trigger removal of
     PTEs that map to files on a volume break rather than on a server
     break.

 (4) When a server reinitialisation callback comes in, use the
     server-to-volume reverse mapping added in a preceding patch to iterate
     over all the volumes using that server and clear the volume callback
     promises for that server and the general volume promise as a whole to
     trigger reanalysis.

 (5) Replace the AFS_VNODE_CB_PROMISED flag with an AFS_NO_CB_PROMISE
     (TIME64_MIN) value in the cb_expires_at field, reducing the number of
     checks we need to make.

 (6) Change afs_check_validity() to quickly see if various event counters
     have been incremented or if the vnode or volume callback promise is
     due to expire/has expired without making any changes to the state.
     That is now left to afs_validate() as this may get more complicated in
     future as we may have to examine server records too.

 (7) Overhaul afs_validate() so that it does a single status fetch if we
     need to check the state of either the vnode or the volume - and do so
     under appropriate locking.  The function does the following steps:

     (A) If the vnode/volume is no longer seen as valid, then we take the
     vnode validation lock and, if the volume promise has expired, the
     volume check lock also.  The latter prevents redundant checks being
     made to find out if a new version of the volume got released.

     (B) If a previous RPC call found that the volsync changed unexpectedly
     or that a RO volume was updated, then we unmap all PTEs pointing to
     the file to stop mmap being used for access.

     (C) If the vnode is still seen to be of uncertain validity, then we
     perform an FS.FetchStatus RPC op to jointly update the volume status
     and the vnode status.  This assessment is done as part of parsing the
     reply:

	If the RO volume creation timestamp advances, cb_ro_snapshot is
	incremented; if either the creation or update timestamps changes in
	an unexpected way, the cb_scrub counter is incremented

	If the Data Version returned doesn't match the copy we have
	locally, then we ask for the pagecache to be zapped.  This takes
	care of handling RO update.

     (D) If cb_scrub differs between volume and vnode, the vnode's
     pagecache is zapped and the vnode's cb_scrub is updated unless the
     file is marked as having been deleted.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org
2024-01-01 16:37:27 +00:00
..
Kconfig afs: Convert afs to use the new fscache API 2022-01-07 13:44:47 +00:00
Makefile afs: Move the vnode/volume validity checking code into its own file 2024-01-01 16:37:27 +00:00
addr_list.c afs: Remove the unimplemented afs_cmp_addr_list() 2024-01-01 16:37:26 +00:00
addr_prefs.c afs: Mark address lists with configured priorities 2024-01-01 16:37:27 +00:00
afs.h afs: Parse the VolSync record in the reply of a number of RPC ops 2024-01-01 16:37:27 +00:00
afs_cm.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
afs_fs.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
afs_vl.h afs: Implement client support for the YFSVL.GetCellName RPC op 2020-06-04 15:37:57 +01:00
callback.c afs: Overhaul invalidation handling to better support RO volumes 2024-01-01 16:37:27 +00:00
cell.c afs: Overhaul invalidation handling to better support RO volumes 2024-01-01 16:37:27 +00:00
cmservice.c rxrpc, afs: Allow afs to pin rxrpc_peer objects 2023-12-24 15:22:50 +00:00
dir.c afs: Overhaul invalidation handling to better support RO volumes 2024-01-01 16:37:27 +00:00
dir_edit.c afs: fix the afs_dir_get_folio return value 2023-05-06 10:10:08 -07:00
dir_silly.c afs: Simplify error handling 2023-12-24 15:22:53 +00:00
dynroot.c afs: Fix dynamic root lookup DNS check 2023-12-20 11:57:47 +00:00
file.c afs: Overhaul invalidation handling to better support RO volumes 2024-01-01 16:37:27 +00:00
flock.c fs: remove locks_inode 2023-01-11 06:52:43 -05:00
fs_operation.c afs: Overhaul invalidation handling to better support RO volumes 2024-01-01 16:37:27 +00:00
fs_probe.c afs: Combine the endpoint state bools into a bitmask 2024-01-01 16:37:27 +00:00
fsclient.c afs: Parse the VolSync record in the reply of a number of RPC ops 2024-01-01 16:37:27 +00:00
inode.c afs: Overhaul invalidation handling to better support RO volumes 2024-01-01 16:37:27 +00:00
internal.h afs: Overhaul invalidation handling to better support RO volumes 2024-01-01 16:37:27 +00:00
main.c afs: Provide a way to configure address priorities 2024-01-01 16:37:26 +00:00
misc.c afs: Simplify error handling 2023-12-24 15:22:53 +00:00
mntpt.c afs: Remove check of PageError 2022-06-29 08:51:06 -04:00
proc.c afs: Overhaul invalidation handling to better support RO volumes 2024-01-01 16:37:27 +00:00
protocol_afs.h afs: Fix corruption in reads at fpos 2G-4G from an OpenAFS server 2021-09-13 09:14:21 +01:00
protocol_uae.h afs: Add support for the UAE error table 2019-06-28 18:37:53 +01:00
protocol_yfs.h afs: Fix corruption in reads at fpos 2G-4G from an OpenAFS server 2021-09-13 09:14:21 +01:00
rotate.c afs: Overhaul invalidation handling to better support RO volumes 2024-01-01 16:37:27 +00:00
rxrpc.c afs: Fold the afs_addr_cursor struct in 2023-12-24 15:22:55 +00:00
security.c fs: port ->permission() to pass mnt_idmap 2023-01-19 09:24:28 +01:00
server.c afs: Apply server breaks to mmap'd files in the call processor 2024-01-01 16:37:27 +00:00
server_list.c afs: Overhaul invalidation handling to better support RO volumes 2024-01-01 16:37:27 +00:00
super.c afs: Defer volume record destruction to a workqueue 2024-01-01 16:37:27 +00:00
validation.c afs: Overhaul invalidation handling to better support RO volumes 2024-01-01 16:37:27 +00:00
vl_alias.c afs: Defer volume record destruction to a workqueue 2024-01-01 16:37:27 +00:00
vl_list.c afs: Dispatch vlserver probes in priority order 2024-01-01 16:37:27 +00:00
vl_probe.c afs: Keep a record of the current fileserver endpoint state 2024-01-01 16:37:27 +00:00
vl_rotate.c afs: Add some more info to /proc/net/afs/servers 2024-01-01 16:36:58 +00:00
vlclient.c afs: Don't leave DONTUSE/NEWREPSITE servers out of server list 2024-01-01 16:37:27 +00:00
volume.c afs: Overhaul invalidation handling to better support RO volumes 2024-01-01 16:37:27 +00:00
write.c afs: Wrap most op->error accesses with inline funcs 2023-12-24 15:22:53 +00:00
xattr.c afs: move afs_xattr_handlers to .rodata 2023-10-09 16:24:16 +02:00
xdr_fs.h afs: Fix directory entry size calculation 2021-01-04 12:25:19 +00:00
yfsclient.c afs: Parse the VolSync record in the reply of a number of RPC ops 2024-01-01 16:37:27 +00:00