Skip to content

Commit 554aed7

Browse files
morbidrsakdave
authored andcommitted
btrfs: zoned: sink zone check into btrfs_repair_one_zone
Sink zone check into btrfs_repair_one_zone() so we don't need to do it in all callers. Also as btrfs_repair_one_zone() doesn't return a sensible error, make it a boolean function and return false in case it got called on a non-zoned filesystem and true on a zoned filesystem. Reviewed-by: Josef Bacik <[email protected]> Signed-off-by: Johannes Thumshirn <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 8fdf54f commit 554aed7

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

fs/btrfs/extent_io.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2314,8 +2314,8 @@ static int repair_io_failure(struct btrfs_fs_info *fs_info, u64 ino, u64 start,
23142314
ASSERT(!(fs_info->sb->s_flags & SB_RDONLY));
23152315
BUG_ON(!mirror_num);
23162316

2317-
if (btrfs_is_zoned(fs_info))
2318-
return btrfs_repair_one_zone(fs_info, logical);
2317+
if (btrfs_repair_one_zone(fs_info, logical))
2318+
return 0;
23192319

23202320
bio = btrfs_bio_alloc(1);
23212321
bio->bi_iter.bi_size = 0;

fs/btrfs/scrub.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -845,8 +845,8 @@ static int scrub_handle_errored_block(struct scrub_block *sblock_to_check)
845845
have_csum = sblock_to_check->pagev[0]->have_csum;
846846
dev = sblock_to_check->pagev[0]->dev;
847847

848-
if (btrfs_is_zoned(fs_info) && !sctx->is_dev_replace)
849-
return btrfs_repair_one_zone(fs_info, logical);
848+
if (!sctx->is_dev_replace && btrfs_repair_one_zone(fs_info, logical))
849+
return 0;
850850

851851
/*
852852
* We must use GFP_NOFS because the scrub task might be waiting for a

fs/btrfs/volumes.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8341,29 +8341,32 @@ static int relocating_repair_kthread(void *data)
83418341
return ret;
83428342
}
83438343

8344-
int btrfs_repair_one_zone(struct btrfs_fs_info *fs_info, u64 logical)
8344+
bool btrfs_repair_one_zone(struct btrfs_fs_info *fs_info, u64 logical)
83458345
{
83468346
struct btrfs_block_group *cache;
83478347

8348+
if (!btrfs_is_zoned(fs_info))
8349+
return false;
8350+
83488351
/* Do not attempt to repair in degraded state */
83498352
if (btrfs_test_opt(fs_info, DEGRADED))
8350-
return 0;
8353+
return true;
83518354

83528355
cache = btrfs_lookup_block_group(fs_info, logical);
83538356
if (!cache)
8354-
return 0;
8357+
return true;
83558358

83568359
spin_lock(&cache->lock);
83578360
if (cache->relocating_repair) {
83588361
spin_unlock(&cache->lock);
83598362
btrfs_put_block_group(cache);
8360-
return 0;
8363+
return true;
83618364
}
83628365
cache->relocating_repair = 1;
83638366
spin_unlock(&cache->lock);
83648367

83658368
kthread_run(relocating_repair_kthread, cache,
83668369
"btrfs-relocating-repair");
83678370

8368-
return 0;
8371+
return true;
83698372
}

fs/btrfs/volumes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,6 @@ enum btrfs_raid_types __attribute_const__ btrfs_bg_flags_to_raid_index(u64 flags
637637
int btrfs_bg_type_to_factor(u64 flags);
638638
const char *btrfs_bg_type_to_raid_name(u64 flags);
639639
int btrfs_verify_dev_extents(struct btrfs_fs_info *fs_info);
640-
int btrfs_repair_one_zone(struct btrfs_fs_info *fs_info, u64 logical);
640+
bool btrfs_repair_one_zone(struct btrfs_fs_info *fs_info, u64 logical);
641641

642642
#endif

0 commit comments

Comments
 (0)