@@ -1576,27 +1576,6 @@ static int scrub_write_page_to_dev_replace(struct scrub_block *sblock,
return scrub_add_page_to_wr_bio(sblock->sctx, spage);
}
-static int fill_writer_pointer_gap(struct scrub_ctx *sctx, u64 physical)
-{
- int ret = 0;
- u64 length;
-
- if (!btrfs_is_zoned(sctx->fs_info))
- return 0;
-
- if (!btrfs_dev_is_sequential(sctx->wr_tgtdev, physical))
- return 0;
-
- if (sctx->write_pointer < physical) {
- length = physical - sctx->write_pointer;
-
- ret = btrfs_zoned_issue_zeroout(sctx->wr_tgtdev,
- sctx->write_pointer, length);
- if (!ret)
- sctx->write_pointer = physical;
- }
- return ret;
-}
static int scrub_add_page_to_wr_bio(struct scrub_ctx *sctx,
struct scrub_page *spage)
@@ -1621,7 +1600,7 @@ static int scrub_add_page_to_wr_bio(struct scrub_ctx *sctx,
if (sbio->page_count == 0) {
struct bio *bio;
- ret = fill_writer_pointer_gap(sctx,
+ ret = btrfs_fill_writer_pointer_gap(sctx,
spage->physical_for_dev_replace);
if (ret) {
mutex_unlock(&sctx->wr_lock);
@@ -15,6 +15,7 @@
#include "transaction.h"
#include "dev-replace.h"
#include "space-info.h"
+#include "scrub.h"
/* Maximum number of zones to report per blkdev_report_zones() call */
#define BTRFS_REPORT_NR_ZONES 4096
@@ -2233,3 +2234,25 @@ bool btrfs_is_block_group_to_copy(struct btrfs_fs_info *fs_info, u64 logical)
btrfs_put_block_group(cache);
return ret;
}
+
+int btrfs_fill_writer_pointer_gap(struct scrub_ctx *sctx, u64 physical)
+{
+ int ret = 0;
+ u64 length;
+
+ if (!btrfs_is_zoned(sctx->fs_info))
+ return 0;
+
+ if (!btrfs_dev_is_sequential(sctx->wr_tgtdev, physical))
+ return 0;
+
+ if (sctx->write_pointer < physical) {
+ length = physical - sctx->write_pointer;
+
+ ret = btrfs_zoned_issue_zeroout(sctx->wr_tgtdev,
+ sctx->write_pointer, length);
+ if (!ret)
+ sctx->write_pointer = physical;
+ }
+ return ret;
+}
@@ -85,6 +85,7 @@ bool btrfs_finish_block_group_to_copy(struct btrfs_device *srcdev,
struct btrfs_block_group *cache,
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);
#else /* CONFIG_BLK_DEV_ZONED */
static inline int btrfs_get_dev_zone(struct btrfs_device *device, u64 pos,
struct blk_zone *zone)
@@ -262,6 +263,11 @@ static bool btrfs_is_block_group_to_copy(struct btrfs_fs_info *fs_info,
{
return false;
}
+static inline int btrfs_fill_writer_pointer_gap(struct scrub_ctx *sctx,
+ u64 physical)
+{
+ return 0;
+}
#endif
static inline bool btrfs_dev_is_sequential(struct btrfs_device *device, u64 pos)
fill_writer_pointer_gap() is only used in a zoned filesystem, so move it to zoned code. Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> --- fs/btrfs/scrub.c | 23 +---------------------- fs/btrfs/zoned.c | 23 +++++++++++++++++++++++ fs/btrfs/zoned.h | 6 ++++++ 3 files changed, 30 insertions(+), 22 deletions(-)