Skip to content

Commit a545d81

Browse files
morbidrsagregkh
authored andcommitted
btrfs: zoned: return error from btrfs_zone_finish_endio()
[ 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 <[email protected]> Signed-off-by: Johannes Thumshirn <[email protected]> Signed-off-by: David Sterba <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent e587f12 commit a545d81

3 files changed

Lines changed: 15 additions & 9 deletions

File tree

fs/btrfs/inode.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3107,9 +3107,10 @@ int btrfs_finish_one_ordered(struct btrfs_ordered_extent *ordered_extent)
31073107
goto out;
31083108
}
31093109

3110-
if (btrfs_is_zoned(fs_info))
3111-
btrfs_zone_finish_endio(fs_info, ordered_extent->disk_bytenr,
3112-
ordered_extent->disk_num_bytes);
3110+
ret = btrfs_zone_finish_endio(fs_info, ordered_extent->disk_bytenr,
3111+
ordered_extent->disk_num_bytes);
3112+
if (ret)
3113+
goto out;
31133114

31143115
if (test_bit(BTRFS_ORDERED_TRUNCATED, &ordered_extent->flags)) {
31153116
truncated = true;

fs/btrfs/zoned.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2464,16 +2464,17 @@ bool btrfs_can_activate_zone(struct btrfs_fs_devices *fs_devices, u64 flags)
24642464
return ret;
24652465
}
24662466

2467-
void btrfs_zone_finish_endio(struct btrfs_fs_info *fs_info, u64 logical, u64 length)
2467+
int btrfs_zone_finish_endio(struct btrfs_fs_info *fs_info, u64 logical, u64 length)
24682468
{
24692469
struct btrfs_block_group *block_group;
24702470
u64 min_alloc_bytes;
24712471

24722472
if (!btrfs_is_zoned(fs_info))
2473-
return;
2473+
return 0;
24742474

24752475
block_group = btrfs_lookup_block_group(fs_info, logical);
2476-
ASSERT(block_group);
2476+
if (WARN_ON_ONCE(!block_group))
2477+
return -ENOENT;
24772478

24782479
/* No MIXED_BG on zoned btrfs. */
24792480
if (block_group->flags & BTRFS_BLOCK_GROUP_DATA)
@@ -2490,6 +2491,7 @@ void btrfs_zone_finish_endio(struct btrfs_fs_info *fs_info, u64 logical, u64 len
24902491

24912492
out:
24922493
btrfs_put_block_group(block_group);
2494+
return 0;
24932495
}
24942496

24952497
static void btrfs_zone_finish_endio_workfn(struct work_struct *work)

fs/btrfs/zoned.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ int btrfs_sync_zone_write_pointer(struct btrfs_device *tgt_dev, u64 logical,
8383
bool btrfs_zone_activate(struct btrfs_block_group *block_group);
8484
int btrfs_zone_finish(struct btrfs_block_group *block_group);
8585
bool btrfs_can_activate_zone(struct btrfs_fs_devices *fs_devices, u64 flags);
86-
void btrfs_zone_finish_endio(struct btrfs_fs_info *fs_info, u64 logical,
86+
int btrfs_zone_finish_endio(struct btrfs_fs_info *fs_info, u64 logical,
8787
u64 length);
8888
void btrfs_schedule_zone_finish_bg(struct btrfs_block_group *bg,
8989
struct extent_buffer *eb);
@@ -234,8 +234,11 @@ static inline bool btrfs_can_activate_zone(struct btrfs_fs_devices *fs_devices,
234234
return true;
235235
}
236236

237-
static inline void btrfs_zone_finish_endio(struct btrfs_fs_info *fs_info,
238-
u64 logical, u64 length) { }
237+
static inline int btrfs_zone_finish_endio(struct btrfs_fs_info *fs_info,
238+
u64 logical, u64 length)
239+
{
240+
return 0;
241+
}
239242

240243
static inline void btrfs_schedule_zone_finish_bg(struct btrfs_block_group *bg,
241244
struct extent_buffer *eb) { }

0 commit comments

Comments
 (0)