Skip to content

Commit 02ee654

Browse files
asjkdave
authored andcommitted
btrfs: fix crash when trying to resume balance without the resume flag
We set the BTRFS_BALANCE_RESUME flag in the btrfs_recover_balance() only, which isn't called during the remount. So when resuming from the paused balance we hit the bug: kernel: kernel BUG at fs/btrfs/volumes.c:3890! :: kernel: balance_kthread+0x51/0x60 [btrfs] kernel: kthread+0x111/0x130 :: kernel: RIP: btrfs_balance+0x12e1/0x1570 [btrfs] RSP: ffffba7d0090bde8 Reproducer: On a mounted filesystem: btrfs balance start --full-balance /btrfs btrfs balance pause /btrfs mount -o remount,ro /dev/sdb /btrfs mount -o remount,rw /dev/sdb /btrfs To fix this set the BTRFS_BALANCE_RESUME flag in btrfs_resume_balance_async(). CC: [email protected] # 4.4+ Signed-off-by: Anand Jain <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent fe816d0 commit 02ee654

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

fs/btrfs/volumes.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4052,6 +4052,15 @@ int btrfs_resume_balance_async(struct btrfs_fs_info *fs_info)
40524052
return 0;
40534053
}
40544054

4055+
/*
4056+
* A ro->rw remount sequence should continue with the paused balance
4057+
* regardless of who pauses it, system or the user as of now, so set
4058+
* the resume flag.
4059+
*/
4060+
spin_lock(&fs_info->balance_lock);
4061+
fs_info->balance_ctl->flags |= BTRFS_BALANCE_RESUME;
4062+
spin_unlock(&fs_info->balance_lock);
4063+
40554064
tsk = kthread_run(balance_kthread, fs_info, "btrfs-balance");
40564065
return PTR_ERR_OR_ZERO(tsk);
40574066
}

0 commit comments

Comments
 (0)