btrfs-progs/libbtrfsutil/python/tests
Omar Sandoval e9c2942f38 libbtrfsutil: fix race between subvolume iterator and deletion
Subvolume iteration has a window between when we get a root ref (with
BTRFS_IOC_TREE_SEARCH or BTRFS_IOC_GET_SUBVOL_ROOTREF) and when we look
up the path of the parent directory (with BTRFS_IOC_INO_LOOKUP{,_USER}).
If the subvolume is moved or deleted and its old parent directory is
deleted during that window, then BTRFS_IOC_INO_LOOKUP{,_USER} will fail
with ENOENT. The iteration will then fail with ENOENT as well.

We originally encountered this bug with an application that called
`btrfs subvolume show` (which iterates subvolumes to find snapshots) in
parallel with other threads creating and deleting subvolumes. It can be
reproduced almost instantly with the included test cases.

Subvolume iteration should be robust against concurrent modifications to
subvolumes. So, if a subvolume's parent directory no longer exists, just
skip the subvolume, as it must have been deleted or moved elsewhere.

Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2021-07-29 13:01:55 +02:00
..
__init__.py libbtrfsutil: fix race between subvolume iterator and deletion 2021-07-29 13:01:55 +02:00
test_filesystem.py libbtrfsutil: fix test case class name for python bindings 2021-05-06 16:41:47 +02:00
test_qgroup.py libbtrfsutil: add btrfs_util_create_snapshot() 2018-03-06 11:28:37 +01:00
test_subvolume.py libbtrfsutil: fix race between subvolume iterator and deletion 2021-07-29 13:01:55 +02:00