diff mbox series

[15/21] btrfs: zoned: move finish_extent_writes_for_zoned to zoned code

Message ID 29caf2db50aa495339a2ae3d52b3248fcc19405e.1637745470.git.johannes.thumshirn@wdc.com (mailing list archive)
State New, archived
Headers show
Series btrfs: first batch of zoned cleanups | expand

Commit Message

Johannes Thumshirn Nov. 24, 2021, 9:30 a.m. UTC
finish_extent_writes_for_zoned() is only used on zoned filesystems so move
it to zoned code.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 fs/btrfs/scrub.c | 21 +--------------------
 fs/btrfs/zoned.c | 19 +++++++++++++++++++
 fs/btrfs/zoned.h |  8 ++++++++
 3 files changed, 28 insertions(+), 20 deletions(-)
diff mbox series

Patch

diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index 2e3ad26d30e30..97e19eca8da14 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -3523,25 +3523,6 @@  static noinline_for_stack int scrub_chunk(struct scrub_ctx *sctx,
 	return ret;
 }
 
-static int finish_extent_writes_for_zoned(struct btrfs_root *root,
-					  struct btrfs_block_group *cache)
-{
-	struct btrfs_fs_info *fs_info = cache->fs_info;
-	struct btrfs_trans_handle *trans;
-
-	if (!btrfs_is_zoned(fs_info))
-		return 0;
-
-	btrfs_wait_block_group_reservations(cache);
-	btrfs_wait_nocow_writers(cache);
-	btrfs_wait_ordered_roots(fs_info, U64_MAX, cache->start, cache->length);
-
-	trans = btrfs_join_transaction(root);
-	if (IS_ERR(trans))
-		return PTR_ERR(trans);
-	return btrfs_commit_transaction(trans);
-}
-
 static noinline_for_stack
 int scrub_enumerate_chunks(struct scrub_ctx *sctx,
 			   struct btrfs_device *scrub_dev, u64 start, u64 end)
@@ -3695,7 +3676,7 @@  int scrub_enumerate_chunks(struct scrub_ctx *sctx,
 		 */
 		ret = btrfs_inc_block_group_ro(cache, sctx->is_dev_replace);
 		if (!ret && sctx->is_dev_replace) {
-			ret = finish_extent_writes_for_zoned(root, cache);
+			ret = btrfs_finish_extent_writes_for_zoned(root, cache);
 			if (ret) {
 				btrfs_dec_block_group_ro(cache);
 				scrub_pause_off(fs_info);
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index bf0837e46592f..df84840eac4c0 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -2296,3 +2296,22 @@  void btrfs_sync_replace_for_zoned(struct scrub_ctx *sctx)
 
 	wait_event(sctx->list_wait, atomic_read(&sctx->bios_in_flight) == 0);
 }
+
+int btrfs_finish_extent_writes_for_zoned(struct btrfs_root *root,
+					 struct btrfs_block_group *cache)
+{
+	struct btrfs_fs_info *fs_info = cache->fs_info;
+	struct btrfs_trans_handle *trans;
+
+	if (!btrfs_is_zoned(fs_info))
+		return 0;
+
+	btrfs_wait_block_group_reservations(cache);
+	btrfs_wait_nocow_writers(cache);
+	btrfs_wait_ordered_roots(fs_info, U64_MAX, cache->start, cache->length);
+
+	trans = btrfs_join_transaction(root);
+	if (IS_ERR(trans))
+		return PTR_ERR(trans);
+	return btrfs_commit_transaction(trans);
+}
diff --git a/fs/btrfs/zoned.h b/fs/btrfs/zoned.h
index 53bf05be143a4..83e11f7ec31e8 100644
--- a/fs/btrfs/zoned.h
+++ b/fs/btrfs/zoned.h
@@ -89,6 +89,8 @@  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);
+int btrfs_finish_extent_writes_for_zoned(struct btrfs_root *root,
+					 struct btrfs_block_group *cache);
 #else /* CONFIG_BLK_DEV_ZONED */
 static inline int btrfs_get_dev_zone(struct btrfs_device *device, u64 pos,
 				     struct blk_zone *zone)
@@ -280,6 +282,12 @@  static inline int btrfs_sync_write_pointer_for_zoned(struct scrub_ctx *sctx,
 }
 
 static inline void btrfs_sync_replace_for_zoned(struct scrub_ctx *sctx) { }
+
+static inline int btrfs_finish_extent_writes_for_zoned(struct btrfs_root *root,
+					       struct btrfs_block_group *cache)
+{
+	return 0;
+}
 #endif
 
 static inline bool btrfs_dev_is_sequential(struct btrfs_device *device, u64 pos)