Skip to content

Commit de076aa

Browse files
morbidrsakdave
authored andcommitted
btrfs: zoned: return error from btrfs_zone_finish_endio()
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]>
1 parent 042bdfb commit de076aa

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

fs/btrfs/inode.c

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

3112-
if (btrfs_is_zoned(fs_info))
3113-
btrfs_zone_finish_endio(fs_info, ordered_extent->disk_bytenr,
3114-
ordered_extent->disk_num_bytes);
3112+
ret = btrfs_zone_finish_endio(fs_info, ordered_extent->disk_bytenr,
3113+
ordered_extent->disk_num_bytes);
3114+
if (ret)
3115+
goto out;
31153116

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

fs/btrfs/zoned.c

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

2434-
void btrfs_zone_finish_endio(struct btrfs_fs_info *fs_info, u64 logical, u64 length)
2434+
int btrfs_zone_finish_endio(struct btrfs_fs_info *fs_info, u64 logical, u64 length)
24352435
{
24362436
struct btrfs_block_group *block_group;
24372437
u64 min_alloc_bytes;
24382438

24392439
if (!btrfs_is_zoned(fs_info))
2440-
return;
2440+
return 0;
24412441

24422442
block_group = btrfs_lookup_block_group(fs_info, logical);
2443-
ASSERT(block_group);
2443+
if (WARN_ON_ONCE(!block_group))
2444+
return -ENOENT;
24442445

24452446
/* No MIXED_BG on zoned btrfs. */
24462447
if (block_group->flags & BTRFS_BLOCK_GROUP_DATA)
@@ -2457,6 +2458,7 @@ void btrfs_zone_finish_endio(struct btrfs_fs_info *fs_info, u64 logical, u64 len
24572458

24582459
out:
24592460
btrfs_put_block_group(block_group);
2461+
return 0;
24602462
}
24612463

24622464
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)