linux-stable/fs/afs
David Howells a9e5c87ca7 afs: Fix speculative status fetch going out of order wrt to modifications
When doing a lookup in a directory, the afs filesystem uses a bulk
status fetch to speculatively retrieve the statuses of up to 48 other
vnodes found in the same directory and it will then either update extant
inodes or create new ones - effectively doing 'lookup ahead'.

To avoid the possibility of deadlocking itself, however, the filesystem
doesn't lock all of those inodes; rather just the directory inode is
locked (by the VFS).

When the operation completes, afs_inode_init_from_status() or
afs_apply_status() is called, depending on whether the inode already
exists, to commit the new status.

A case exists, however, where the speculative status fetch operation may
straddle a modification operation on one of those vnodes.  What can then
happen is that the speculative bulk status RPC retrieves the old status,
and whilst that is happening, the modification happens - which returns
an updated status, then the modification status is committed, then we
attempt to commit the speculative status.

This results in something like the following being seen in dmesg:

	kAFS: vnode modified {100058:861} 8->9 YFS.InlineBulkStatus

showing that for vnode 861 on volume 100058, we saw YFS.InlineBulkStatus
say that the vnode had data version 8 when we'd already recorded version
9 due to a local modification.  This was causing the cache to be
invalidated for that vnode when it shouldn't have been.  If it happens
on a data file, this might lead to local changes being lost.

Fix this by ignoring speculative status updates if the data version
doesn't match the expected value.

Note that it is possible to get a DV regression if a volume gets
restored from a backup - but we should get a callback break in such a
case that should trigger a recheck anyway.  It might be worth checking
the volume creation time in the volsync info and, if a change is
observed in that (as would happen on a restore), invalidate all caches
associated with the volume.

Fixes: 5cf9dd55a0 ("afs: Prospectively look up extra files when doing a single lookup")
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-11-22 11:27:03 -08:00
..
Kconfig docs: filesystems: fix renamed references 2020-04-20 15:45:22 -06:00
Makefile afs: Detect cell aliases 1 - Cells with root volumes 2020-06-04 15:37:57 +01:00
addr_list.c afs: Use kfree_rcu() instead of casting kfree() to rcu_callback_t 2020-03-13 10:47:33 -07:00
afs.h afs: Implement client support for the YFSVL.GetCellName RPC op 2020-06-04 15:37:57 +01: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
cache.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
callback.c afs: Fix the by-UUID server tree to allow servers with the same UUID 2020-06-04 15:37:57 +01:00
cell.c afs: Fix tracing deref-before-check 2020-10-27 22:05:56 +00:00
cmservice.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
dir.c afs: Fix speculative status fetch going out of order wrt to modifications 2020-11-22 11:27:03 -08:00
dir_edit.c afs: Fix to take ref on page when PG_private is set 2020-10-29 13:53:04 +00:00
dir_silly.c afs: Fix silly rename 2020-06-16 22:00:28 +01:00
dynroot.c afs: Add tracing for cell refcount and active user count 2020-10-16 14:39:21 +01:00
file.c afs: Fix afs_invalidatepage to adjust the dirty region 2020-10-29 13:53:04 +00:00
flock.c afs: Remove erroneous fallthough annotation 2020-08-27 14:33:01 -05:00
fs_operation.c afs: Fix key ref leak in afs_put_operation() 2020-08-20 10:41:45 -07:00
fs_probe.c rxrpc: Make rxrpc_kernel_get_srtt() indicate validity 2020-08-20 18:21:28 +01:00
fsclient.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
inode.c afs: Fix speculative status fetch going out of order wrt to modifications 2020-11-22 11:27:03 -08:00
internal.h afs: Fix speculative status fetch going out of order wrt to modifications 2020-11-22 11:27:03 -08:00
main.c afs: Fix rapid cell addition/removal by not using RCU on cells tree 2020-10-16 14:04:59 +01:00
misc.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
mntpt.c afs: Add tracing for cell refcount and active user count 2020-10-16 14:39:21 +01:00
proc.c afs: Add tracing for cell refcount and active user count 2020-10-16 14:39: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: Implement client support for the YFSVL.GetCellName RPC op 2020-06-04 15:37:57 +01:00
rotate.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
rxrpc.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
security.c treewide: Remove uninitialized_var() usage 2020-07-16 12:35:15 -07:00
server.c afs: Don't assert on unpurgeable server records 2020-10-16 14:39:34 +01:00
server_list.c afs: Reorganise volume and server trees to be rooted on the cell 2020-06-04 15:37:57 +01:00
super.c afs fixes 2020-10-16 15:22:41 -07:00
vl_alias.c afs: Add tracing for cell refcount and active user count 2020-10-16 14:39:21 +01:00
vl_list.c afs: Don't use VL probe running state to make decisions outside probe code 2020-08-20 18:21:28 +01:00
vl_probe.c afs: Don't use VL probe running state to make decisions outside probe code 2020-08-20 18:21:28 +01:00
vl_rotate.c afs: Add tracing for cell refcount and active user count 2020-10-16 14:39:21 +01:00
vlclient.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
volume.c afs: Add tracing for cell refcount and active user count 2020-10-16 14:39:21 +01:00
write.c afs: Fix afs_write_end() when called with copied == 0 [ver #3] 2020-11-14 11:51:18 -08:00
xattr.c afs: Fix incorrect freeing of the ACL passed to the YFS ACL store op 2020-11-03 09:53:40 -08:00
xdr_fs.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 36 2019-05-24 17:27:11 +02:00
yfsclient.c afs: Fix warning due to unadvanced marshalling pointer 2020-11-03 09:53:40 -08:00