[PATCH 12/21] btrfs: zoned: sync_write_pointer_for_zoned to zoned code
From: Johannes Thumshirn <hidden>
Date: 2021-11-24 09:31:13
Subsystem:
btrfs file system, filesystems (vfs and infrastructure), the rest · Maintainers:
Chris Mason, David Sterba, Alexander Viro, Christian Brauner, Linus Torvalds
sync_write_pointer_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 | 28 +--------------------------- fs/btrfs/zoned.c | 26 ++++++++++++++++++++++++++ fs/btrfs/zoned.h | 9 +++++++++ 3 files changed, 36 insertions(+), 27 deletions(-)
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index 64728ca585c52..ccb74f2e75b92 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c@@ -3071,32 +3071,6 @@ static void sync_replace_for_zoned(struct scrub_ctx *sctx) wait_event(sctx->list_wait, atomic_read(&sctx->bios_in_flight) == 0); } -static int sync_write_pointer_for_zoned(struct scrub_ctx *sctx, u64 logical, - u64 physical, u64 physical_end) -{ - struct btrfs_fs_info *fs_info = sctx->fs_info; - int ret = 0; - - if (!btrfs_is_zoned(fs_info)) - return 0; - - wait_event(sctx->list_wait, atomic_read(&sctx->bios_in_flight) == 0); - - mutex_lock(&sctx->wr_lock); - if (sctx->write_pointer < physical_end) { - ret = btrfs_sync_zone_write_pointer(sctx->wr_tgtdev, logical, - physical, - sctx->write_pointer); - if (ret) - btrfs_err(fs_info, - "zoned: failed to recover write pointer"); - } - mutex_unlock(&sctx->wr_lock); - btrfs_dev_clear_zone_empty(sctx->wr_tgtdev, physical); - - return ret; -} - static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx, struct map_lookup *map, struct btrfs_device *scrub_dev,
@@ -3502,7 +3476,7 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx, if (sctx->is_dev_replace && ret >= 0) { int ret2; - ret2 = sync_write_pointer_for_zoned(sctx, base + offset, + ret2 = btrfs_sync_write_pointer_for_zoned(sctx, base + offset, map->stripes[num].physical, physical_end); if (ret2)
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index 8493093aea849..7f3e3e34fd783 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c@@ -2256,3 +2256,29 @@ int btrfs_fill_writer_pointer_gap(struct scrub_ctx *sctx, u64 physical) } return ret; } + +int btrfs_sync_write_pointer_for_zoned(struct scrub_ctx *sctx, u64 logical, + u64 physical, u64 physical_end) +{ + struct btrfs_fs_info *fs_info = sctx->fs_info; + int ret = 0; + + if (!btrfs_is_zoned(fs_info)) + return 0; + + wait_event(sctx->list_wait, atomic_read(&sctx->bios_in_flight) == 0); + + mutex_lock(&sctx->wr_lock); + if (sctx->write_pointer < physical_end) { + ret = btrfs_sync_zone_write_pointer(sctx->wr_tgtdev, logical, + physical, + sctx->write_pointer); + if (ret) + btrfs_err(fs_info, + "zoned: failed to recover write pointer"); + } + mutex_unlock(&sctx->wr_lock); + btrfs_dev_clear_zone_empty(sctx->wr_tgtdev, physical); + + return ret; +}
diff --git a/fs/btrfs/zoned.h b/fs/btrfs/zoned.h
index 5701f659b1c39..db2baebab8f50 100644
--- a/fs/btrfs/zoned.h
+++ b/fs/btrfs/zoned.h@@ -86,6 +86,8 @@ bool btrfs_finish_block_group_to_copy(struct btrfs_device *srcdev, u64 physical); 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); #else /* CONFIG_BLK_DEV_ZONED */ static inline int btrfs_get_dev_zone(struct btrfs_device *device, u64 pos, struct blk_zone *zone)
@@ -268,6 +270,13 @@ static inline int btrfs_fill_writer_pointer_gap(struct scrub_ctx *sctx, { return 0; } + +static inline int btrfs_sync_write_pointer_for_zoned(struct scrub_ctx *sctx, + u64 logical, u64 physical, + u64 physical_end) +{ + return 0; +} #endif static inline bool btrfs_dev_is_sequential(struct btrfs_device *device, u64 pos)
--
2.31.1