btrfs-progs/libbtrfsutil/python
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
..
tests libbtrfsutil: fix race between subvolume iterator and deletion 2021-07-29 13:01:55 +02:00
.gitignore
btrfsutilpy.h libbtrfsutil: relicense to LGPLv2.1+ 2021-04-19 18:58:26 +02:00
error.c libbtrfsutil: relicense to LGPLv2.1+ 2021-04-19 18:58:26 +02:00
filesystem.c libbtrfsutil: relicense to LGPLv2.1+ 2021-04-19 18:58:26 +02:00
module.c libbtrfsutil: relicense to LGPLv2.1+ 2021-04-19 18:58:26 +02:00
qgroup.c libbtrfsutil: relicense to LGPLv2.1+ 2021-04-19 18:58:26 +02:00
setup.py libbtrfsutil: add warning about autogenerated constants.c 2021-05-06 16:41:47 +02:00
subvolume.c libbtrfsutil: relicense to LGPLv2.1+ 2021-04-19 18:58:26 +02:00