]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
btrfs: zoned: return error from btrfs_zone_finish_endio()
authorJohannes Thumshirn <johannes.thumshirn@wdc.com>
Tue, 22 Jul 2025 11:39:11 +0000 (13:39 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 2 Nov 2025 13:15:21 +0000 (22:15 +0900)
[ Upstream commit 3c44cd3c79fcb38a86836dea6ff8fec322a9e68c ]

Now that btrfs_zone_finish_endio_workfn() is directly calling
do_zone_finish() the only caller of btrfs_zone_finish_endio() is
btrfs_finish_one_ordered().

btrfs_finish_one_ordered() already has error handling in-place so
btrfs_zone_finish_endio() can return an error if the block group lookup
fails.

Also as btrfs_zone_finish_endio() already checks for zoned filesystems and
returns early, there's no need to do this in the caller.

Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/btrfs/inode.c
fs/btrfs/zoned.c
fs/btrfs/zoned.h

index 19c0ec9c327c155a8e764920720acb60ce736556..e32dd4193aea1ebdcad74f892e51c603bfab7f4e 100644 (file)
@@ -3174,9 +3174,10 @@ int btrfs_finish_one_ordered(struct btrfs_ordered_extent *ordered_extent)
                goto out;
        }
 
-       if (btrfs_is_zoned(fs_info))
-               btrfs_zone_finish_endio(fs_info, ordered_extent->disk_bytenr,
-                                       ordered_extent->disk_num_bytes);
+       ret = btrfs_zone_finish_endio(fs_info, ordered_extent->disk_bytenr,
+                                     ordered_extent->disk_num_bytes);
+       if (ret)
+               goto out;
 
        if (test_bit(BTRFS_ORDERED_TRUNCATED, &ordered_extent->flags)) {
                truncated = true;
index 4966b4f5a7d245478272d9bef92ec20e9902c7a2..64e0a5bf5f9a5dbb7a29ea136178d34840423daa 100644 (file)
@@ -2384,16 +2384,17 @@ bool btrfs_can_activate_zone(struct btrfs_fs_devices *fs_devices, u64 flags)
        return ret;
 }
 
-void btrfs_zone_finish_endio(struct btrfs_fs_info *fs_info, u64 logical, u64 length)
+int btrfs_zone_finish_endio(struct btrfs_fs_info *fs_info, u64 logical, u64 length)
 {
        struct btrfs_block_group *block_group;
        u64 min_alloc_bytes;
 
        if (!btrfs_is_zoned(fs_info))
-               return;
+               return 0;
 
        block_group = btrfs_lookup_block_group(fs_info, logical);
-       ASSERT(block_group);
+       if (WARN_ON_ONCE(!block_group))
+               return -ENOENT;
 
        /* No MIXED_BG on zoned btrfs. */
        if (block_group->flags & BTRFS_BLOCK_GROUP_DATA)
@@ -2410,6 +2411,7 @@ void btrfs_zone_finish_endio(struct btrfs_fs_info *fs_info, u64 logical, u64 len
 
 out:
        btrfs_put_block_group(block_group);
+       return 0;
 }
 
 static void btrfs_zone_finish_endio_workfn(struct work_struct *work)
index 7612e6572605304c66857e1178145b3bcbc94f86..f7171ab6ed71e05b1e3e42c5d2dcd96e1c049998 100644 (file)
@@ -83,7 +83,7 @@ int btrfs_sync_zone_write_pointer(struct btrfs_device *tgt_dev, u64 logical,
 bool btrfs_zone_activate(struct btrfs_block_group *block_group);
 int btrfs_zone_finish(struct btrfs_block_group *block_group);
 bool btrfs_can_activate_zone(struct btrfs_fs_devices *fs_devices, u64 flags);
-void btrfs_zone_finish_endio(struct btrfs_fs_info *fs_info, u64 logical,
+int btrfs_zone_finish_endio(struct btrfs_fs_info *fs_info, u64 logical,
                             u64 length);
 void btrfs_schedule_zone_finish_bg(struct btrfs_block_group *bg,
                                   struct extent_buffer *eb);
@@ -232,8 +232,11 @@ static inline bool btrfs_can_activate_zone(struct btrfs_fs_devices *fs_devices,
        return true;
 }
 
-static inline void btrfs_zone_finish_endio(struct btrfs_fs_info *fs_info,
-                                          u64 logical, u64 length) { }
+static inline int btrfs_zone_finish_endio(struct btrfs_fs_info *fs_info,
+                                          u64 logical, u64 length)
+{
+       return 0;
+}
 
 static inline void btrfs_schedule_zone_finish_bg(struct btrfs_block_group *bg,
                                                 struct extent_buffer *eb) { }