All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Thumshirn <johannes.thumshirn@wdc.com>
To: David Sterba <dsterba@suse.com>
Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com>,
	linux-btrfs@vger.kernel.org, Nikolay Borisov <nborisov@suse.com>,
	Naohiro Aota <Naohiro.Aota@wdc.com>
Subject: [PATCH 12/21] btrfs: zoned: sync_write_pointer_for_zoned to zoned code
Date: Wed, 24 Nov 2021 01:30:38 -0800	[thread overview]
Message-ID: <86b1dd2b2353205392b92acf682d983d2f3ac9a5.1637745470.git.johannes.thumshirn@wdc.com> (raw)
In-Reply-To: <cover.1637745470.git.johannes.thumshirn@wdc.com>

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(-)

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


  parent reply	other threads:[~2021-11-24  9:31 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-24  9:30 [PATCH 00/21] btrfs: first batch of zoned cleanups Johannes Thumshirn
2021-11-24  9:30 ` [PATCH 01/21] btrfs: zoned: encapsulate inode locking for zoned relocation Johannes Thumshirn
2021-11-24  9:30 ` [PATCH 02/21] btrfs: zoned: simplify btrfs_check_meta_write_pointer Johannes Thumshirn
2021-11-24  9:30 ` [PATCH 03/21] btrfs: zoned: sink zone check into btrfs_repair_one_zone Johannes Thumshirn
2021-11-24 16:28   ` Josef Bacik
2021-11-24 17:29   ` David Sterba
2021-11-25  7:13     ` Johannes Thumshirn
2021-11-24  9:30 ` [PATCH 04/21] btrfs: zoned: it's pointless to check for REQ_OP_ZONE_APPEND and btrfs_is_zoned Johannes Thumshirn
2021-11-24 17:33   ` David Sterba
2021-11-24  9:30 ` [PATCH 05/21] btrfs: zoned: move compatible fs flags check to zoned code Johannes Thumshirn
2021-11-24 17:36   ` David Sterba
2021-11-25 10:00     ` Johannes Thumshirn
2021-11-24  9:30 ` [PATCH 06/21] btrfs: zoned: move mark_block_group_to_copy " Johannes Thumshirn
2021-11-24 17:48   ` David Sterba
2021-11-24  9:30 ` [PATCH 07/21] btrfs: zoned: move btrfs_finish_block_group_to_copy " Johannes Thumshirn
2021-11-24  9:30 ` [PATCH 08/21] btrfs: zoned: move is_block_group_to_copy " Johannes Thumshirn
2021-11-24  9:30 ` [PATCH 09/21] btrfs: zoned: skip zoned check if block_group is marked as copy Johannes Thumshirn
2021-11-29  8:18   ` [btrfs] a323b5f59e: xfstests.btrfs.167.fail kernel test robot
2021-11-29  8:18     ` kernel test robot
2021-11-24  9:30 ` [PATCH 10/21] btrfs: move struct scrub_ctx to scrub.h Johannes Thumshirn
2021-11-26 16:48   ` David Sterba
2021-11-24  9:30 ` [PATCH 11/21] btrfs: zoned: move fill_writer_pointer_gap to zoned code Johannes Thumshirn
2021-11-24  9:30 ` Johannes Thumshirn [this message]
2021-11-24  9:30 ` [PATCH 13/21] btrfs: make scrub_submit and scrub_wr_submit non-static Johannes Thumshirn
2021-11-24  9:30 ` [PATCH 14/21] btrfs: zoned: move sync_replace_for_zoned to zoned code Johannes Thumshirn
2021-11-24  9:30 ` [PATCH 15/21] btrfs: zoned: move finish_extent_writes_for_zoned " Johannes Thumshirn
2021-11-24  9:30 ` [PATCH 16/21] btrfs: move btrfs_scrub_dev() definition to scrub.h Johannes Thumshirn
2021-11-24  9:30 ` [PATCH 17/21] btrfs: move btrfs_scrub_pause() " Johannes Thumshirn
2021-11-24  9:30 ` [PATCH 18/21] btrfs: move btrfs_scrub_continue() " Johannes Thumshirn
2021-11-24  9:30 ` [PATCH 19/21] btrfs: move btrfs_scrub_cancel() " Johannes Thumshirn
2021-11-24  9:30 ` [PATCH 20/21] btrfs: move btrfs_scrub_cancel_dev() " Johannes Thumshirn
2021-11-24  9:30 ` [PATCH 21/21] btrfs: move btrfs_scrub_progress() " Johannes Thumshirn
2021-11-24 16:34 ` [PATCH 00/21] btrfs: first batch of zoned cleanups Josef Bacik
2021-11-25  9:58   ` Johannes Thumshirn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86b1dd2b2353205392b92acf682d983d2f3ac9a5.1637745470.git.johannes.thumshirn@wdc.com \
    --to=johannes.thumshirn@wdc.com \
    --cc=Naohiro.Aota@wdc.com \
    --cc=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nborisov@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.