[PATCH 14/21] btrfs: zoned: move sync_replace_for_zoned to zoned code
From: Johannes Thumshirn <hidden>
Date: 2021-11-24 09:31:20
Subsystem:
btrfs file system, filesystems (vfs and infrastructure), the rest · Maintainers:
Chris Mason, David Sterba, Alexander Viro, Christian Brauner, Linus Torvalds
sync_replace_for_zoned( is only used on a zoned filesystem, so move it to zoned code. Signed-off-by: Johannes Thumshirn <redacted> --- fs/btrfs/scrub.c | 16 +--------------- fs/btrfs/zoned.c | 14 ++++++++++++++ fs/btrfs/zoned.h | 3 +++ 3 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index e8fa305f71a10..2e3ad26d30e30 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c@@ -3056,20 +3056,6 @@ static noinline_for_stack int scrub_raid56_parity(struct scrub_ctx *sctx, return ret < 0 ? ret : 0; } -static void sync_replace_for_zoned(struct scrub_ctx *sctx) -{ - if (!btrfs_is_zoned(sctx->fs_info)) - return; - - sctx->flush_all_writes = true; - btrfs_scrub_submit(sctx); - mutex_lock(&sctx->wr_lock); - btrfs_scrub_wr_submit(sctx); - mutex_unlock(&sctx->wr_lock); - - wait_event(sctx->list_wait, atomic_read(&sctx->bios_in_flight) == 0); -} - static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx, struct map_lookup *map, struct btrfs_device *scrub_dev,
@@ -3402,7 +3388,7 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx, goto out; if (sctx->is_dev_replace) - sync_replace_for_zoned(sctx); + btrfs_sync_replace_for_zoned(sctx); if (extent_logical + extent_len < key.objectid + bytes) {
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index 7f3e3e34fd783..bf0837e46592f 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c@@ -2282,3 +2282,17 @@ int btrfs_sync_write_pointer_for_zoned(struct scrub_ctx *sctx, u64 logical, return ret; } + +void btrfs_sync_replace_for_zoned(struct scrub_ctx *sctx) +{ + if (!btrfs_is_zoned(sctx->fs_info)) + return; + + sctx->flush_all_writes = true; + btrfs_scrub_submit(sctx); + mutex_lock(&sctx->wr_lock); + btrfs_scrub_wr_submit(sctx); + mutex_unlock(&sctx->wr_lock); + + wait_event(sctx->list_wait, atomic_read(&sctx->bios_in_flight) == 0); +}
diff --git a/fs/btrfs/zoned.h b/fs/btrfs/zoned.h
index db2baebab8f50..53bf05be143a4 100644
--- a/fs/btrfs/zoned.h
+++ b/fs/btrfs/zoned.h@@ -88,6 +88,7 @@ bool btrfs_is_block_group_to_copy(struct btrfs_fs_info *fs_info, u64 logical); int btrfs_fill_writer_pointer_gap(struct scrub_ctx *sctx, u64 physical); int btrfs_sync_write_pointer_for_zoned(struct scrub_ctx *sctx, u64 logical, u64 physical, u64 physical_end); +void btrfs_sync_replace_for_zoned(struct scrub_ctx *sctx); #else /* CONFIG_BLK_DEV_ZONED */ static inline int btrfs_get_dev_zone(struct btrfs_device *device, u64 pos, struct blk_zone *zone)
@@ -277,6 +278,8 @@ static inline int btrfs_sync_write_pointer_for_zoned(struct scrub_ctx *sctx, { return 0; } + +static inline void btrfs_sync_replace_for_zoned(struct scrub_ctx *sctx) { } #endif static inline bool btrfs_dev_is_sequential(struct btrfs_device *device, u64 pos)
--
2.31.1