]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
btrfs: zoned: requeue to unused block group list if zone finish failed
authorNaohiro Aota <naohiro.aota@wdc.com>
Sun, 29 Jun 2025 14:18:29 +0000 (23:18 +0900)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Jul 2025 22:09:23 +0000 (00:09 +0200)
btrfs_zone_finish() can fail for several reason. If it is -EAGAIN, we need
to try it again later. So, put the block group to the retry list properly.

Failing to do so will keep the removable block group intact until remount
and can causes unnecessary ENOSPC.

Fixes: 74e91b12b115 ("btrfs: zoned: zone finish unused block group")
CC: stable@vger.kernel.org # 6.1+
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/block-group.c

index 3ddf9fe52b9de493bc5bf6d695d8d9821d41fd11..47c6d040176c2b2678fc62a2d25bf5d76e6094f9 100644 (file)
@@ -1639,8 +1639,10 @@ void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info)
                ret = btrfs_zone_finish(block_group);
                if (ret < 0) {
                        btrfs_dec_block_group_ro(block_group);
-                       if (ret == -EAGAIN)
+                       if (ret == -EAGAIN) {
+                               btrfs_link_bg_list(block_group, &retry_list);
                                ret = 0;
+                       }
                        goto next;
                }