Skip to content

Commit 74944c8

Browse files
josefbacikkdave
authored andcommitted
btrfs: reset RO counter on block group if we fail to relocate
With the automatic block group reclaim code we will preemptively try to mark the block group RO before we start the relocation. We do this to make sure we should actually try to relocate the block group. However if we hit an error during the actual relocation we won't clean up our RO counter and the block group will remain RO. This was observed internally with file systems reporting less space available from df when we had failed background relocations. Fix this by doing the dec_ro in the error case. Fixes: 18bb8bb ("btrfs: zoned: automatically reclaim zones") CC: [email protected] # 5.15+ Reviewed-by: Boris Burkov <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 0b078d9 commit 74944c8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/btrfs/block-group.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1640,9 +1640,11 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)
16401640
div64_u64(zone_unusable * 100, bg->length));
16411641
trace_btrfs_reclaim_block_group(bg);
16421642
ret = btrfs_relocate_chunk(fs_info, bg->start);
1643-
if (ret)
1643+
if (ret) {
1644+
btrfs_dec_block_group_ro(bg);
16441645
btrfs_err(fs_info, "error relocating chunk %llu",
16451646
bg->start);
1647+
}
16461648

16471649
next:
16481650
btrfs_put_block_group(bg);

0 commit comments

Comments
 (0)