@@ -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)
@@ -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;
+}
@@ -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)
sync_write_pointer_for_zoned() is only used on a zoned filesystem, so move it to zoned code. Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> --- fs/btrfs/scrub.c | 28 +--------------------------- fs/btrfs/zoned.c | 26 ++++++++++++++++++++++++++ fs/btrfs/zoned.h | 9 +++++++++ 3 files changed, 36 insertions(+), 27 deletions(-)