summaryrefslogtreecommitdiff
path: root/README
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@suse.com>2021-02-05 15:55:37 +0300
committerDavid Sterba <dsterba@suse.com>2021-02-22 20:07:15 +0300
commit195a49eaf655eb914896c92cecd96bc863c9feb3 (patch)
tree4533076ca5d11b06ed8adfe84be4aab5c8134d26 /README
parent20903032cd9f0260b99aeab92e6540f0350e4a23 (diff)
downloadlinux-195a49eaf655eb914896c92cecd96bc863c9feb3.tar.xz
btrfs: fix race between writes to swap files and scrub
When we active a swap file, at btrfs_swap_activate(), we acquire the exclusive operation lock to prevent the physical location of the swap file extents to be changed by operations such as balance and device replace/resize/remove. We also call there can_nocow_extent() which, among other things, checks if the block group of a swap file extent is currently RO, and if it is we can not use the extent, since a write into it would result in COWing the extent. However we have no protection against a scrub operation running after we activate the swap file, which can result in the swap file extents to be COWed while the scrub is running and operating on the respective block group, because scrub turns a block group into RO before it processes it and then back again to RW mode after processing it. That means an attempt to write into a swap file extent while scrub is processing the respective block group, will result in COWing the extent, changing its physical location on disk. Fix this by making sure that block groups that have extents that are used by active swap files can not be turned into RO mode, therefore making it not possible for a scrub to turn them into RO mode. When a scrub finds a block group that can not be turned to RO due to the existence of extents used by swap files, it proceeds to the next block group and logs a warning message that mentions the block group was skipped due to active swap files - this is the same approach we currently use for balance. Fixes: ed46ff3d42378 ("Btrfs: support swap files") CC: stable@vger.kernel.org # 5.4+ Reviewed-by: Anand Jain <anand.jain@oracle.com> Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'README')
0 files changed, 0 insertions, 0 deletions