Commit 0320b353 authored by Naohiro Aota's avatar Naohiro Aota Committed by David Sterba

btrfs: assert that relocation is protected with sb_start_write()

Relocation of a data block group creates ordered extents. They can cause
a hang when a process is trying to thaw the filesystem.

We should have called sb_start_write(), so the filesystem is not being
frozen. Add an ASSERT to check it is protected.
Reviewed-by: default avatarFilipe Manana <fdmanana@suse.com>
Signed-off-by: default avatarNaohiro Aota <naohiro.aota@wdc.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 7f8d12ea
...@@ -3978,6 +3978,17 @@ int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start) ...@@ -3978,6 +3978,17 @@ int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start)
if (!bg) if (!bg)
return -ENOENT; return -ENOENT;
/*
* Relocation of a data block group creates ordered extents. Without
* sb_start_write(), we can freeze the filesystem while unfinished
* ordered extents are left. Such ordered extents can cause a deadlock
* e.g. when syncfs() is waiting for their completion but they can't
* finish because they block when joining a transaction, due to the
* fact that the freeze locks are being held in write mode.
*/
if (bg->flags & BTRFS_BLOCK_GROUP_DATA)
ASSERT(sb_write_started(fs_info->sb));
if (btrfs_pinned_by_swapfile(fs_info, bg)) { if (btrfs_pinned_by_swapfile(fs_info, bg)) {
btrfs_put_block_group(bg); btrfs_put_block_group(bg);
return -ETXTBSY; return -ETXTBSY;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment