All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Andrew Morton <akpm@linux-foundation.org>,
	Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>,
	Dave Kleikamp <shaggy@kernel.org>, Mark Fasheh <mark@fasheh.com>,
	Joel Becker <jlbec@evilplan.org>,
	Joseph Qi <joseph.qi@linux.alibaba.com>,
	Evgeniy Dushistov <dushistov@mail.ru>,
	"Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: linux-btrfs@vger.kernel.org,
	jfs-discussion@lists.sourceforge.net, ocfs2-devel@oss.oracle.com,
	linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
	Johannes Thumshirn <johannes.thumshirn@wdc.com>
Subject: [PATCH 1/7] btrfs: don't read the disk superblock for zoned devices in btrfs_scratch_superblocks
Date: Sun,  8 Jan 2023 17:56:39 +0100	[thread overview]
Message-ID: <20230108165645.381077-2-hch@lst.de> (raw)
In-Reply-To: <20230108165645.381077-1-hch@lst.de>

For zoned devices, btrfs_scratch_superblocks just resets the sb zones,
which means there is no need to even read the previous superblock.
Split the code to read, zero and write the superblock for conventional
devices into a separate helper so that it isn't called for zoned
devices.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 fs/btrfs/volumes.c | 51 +++++++++++++++++++++++-----------------------
 1 file changed, 26 insertions(+), 25 deletions(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index aa25fa335d3ed1..1378f5ad5ed4c4 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2005,42 +2005,43 @@ static u64 btrfs_num_devices(struct btrfs_fs_info *fs_info)
 	return num_devices;
 }
 
+static void btrfs_scratch_superblock(struct btrfs_fs_info *fs_info,
+				     struct block_device *bdev, int copy_num)
+{
+	struct btrfs_super_block *disk_super;
+	struct page *page;
+	int ret;
+
+	disk_super = btrfs_read_dev_one_super(bdev, copy_num, false);
+	if (IS_ERR(disk_super))
+		return;
+	memset(&disk_super->magic, 0, sizeof(disk_super->magic));
+	page = virt_to_page(disk_super);
+	set_page_dirty(page);
+	lock_page(page);
+	/* write_on_page() unlocks the page */
+	ret = write_one_page(page);
+	if (ret)
+		btrfs_warn(fs_info,
+			"error clearing superblock number %d (%d)",
+			copy_num, ret);
+	btrfs_release_disk_super(disk_super);
+}
+
 void btrfs_scratch_superblocks(struct btrfs_fs_info *fs_info,
 			       struct block_device *bdev,
 			       const char *device_path)
 {
-	struct btrfs_super_block *disk_super;
 	int copy_num;
 
 	if (!bdev)
 		return;
 
 	for (copy_num = 0; copy_num < BTRFS_SUPER_MIRROR_MAX; copy_num++) {
-		struct page *page;
-		int ret;
-
-		disk_super = btrfs_read_dev_one_super(bdev, copy_num, false);
-		if (IS_ERR(disk_super))
-			continue;
-
-		if (bdev_is_zoned(bdev)) {
+		if (bdev_is_zoned(bdev))
 			btrfs_reset_sb_log_zones(bdev, copy_num);
-			continue;
-		}
-
-		memset(&disk_super->magic, 0, sizeof(disk_super->magic));
-
-		page = virt_to_page(disk_super);
-		set_page_dirty(page);
-		lock_page(page);
-		/* write_on_page() unlocks the page */
-		ret = write_one_page(page);
-		if (ret)
-			btrfs_warn(fs_info,
-				"error clearing superblock number %d (%d)",
-				copy_num, ret);
-		btrfs_release_disk_super(disk_super);
-
+		else
+			btrfs_scratch_superblock(fs_info, bdev, copy_num);
 	}
 
 	/* Notify udev that device has changed */
-- 
2.35.1


WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig via Ocfs2-devel <ocfs2-devel@oss.oracle.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>,
	Dave Kleikamp <shaggy@kernel.org>, Mark Fasheh <mark@fasheh.com>,
	Joel Becker <jlbec@evilplan.org>,
	Joseph Qi <joseph.qi@linux.alibaba.com>,
	Evgeniy Dushistov <dushistov@mail.ru>,
	"Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: jfs-discussion@lists.sourceforge.net,
	Johannes Thumshirn <johannes.thumshirn@wdc.com>,
	linux-mm@kvack.org, linux-btrfs@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH 1/7] btrfs: don't read the disk superblock for zoned devices in btrfs_scratch_superblocks
Date: Sun,  8 Jan 2023 17:56:39 +0100	[thread overview]
Message-ID: <20230108165645.381077-2-hch@lst.de> (raw)
In-Reply-To: <20230108165645.381077-1-hch@lst.de>

For zoned devices, btrfs_scratch_superblocks just resets the sb zones,
which means there is no need to even read the previous superblock.
Split the code to read, zero and write the superblock for conventional
devices into a separate helper so that it isn't called for zoned
devices.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 fs/btrfs/volumes.c | 51 +++++++++++++++++++++++-----------------------
 1 file changed, 26 insertions(+), 25 deletions(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index aa25fa335d3ed1..1378f5ad5ed4c4 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2005,42 +2005,43 @@ static u64 btrfs_num_devices(struct btrfs_fs_info *fs_info)
 	return num_devices;
 }
 
+static void btrfs_scratch_superblock(struct btrfs_fs_info *fs_info,
+				     struct block_device *bdev, int copy_num)
+{
+	struct btrfs_super_block *disk_super;
+	struct page *page;
+	int ret;
+
+	disk_super = btrfs_read_dev_one_super(bdev, copy_num, false);
+	if (IS_ERR(disk_super))
+		return;
+	memset(&disk_super->magic, 0, sizeof(disk_super->magic));
+	page = virt_to_page(disk_super);
+	set_page_dirty(page);
+	lock_page(page);
+	/* write_on_page() unlocks the page */
+	ret = write_one_page(page);
+	if (ret)
+		btrfs_warn(fs_info,
+			"error clearing superblock number %d (%d)",
+			copy_num, ret);
+	btrfs_release_disk_super(disk_super);
+}
+
 void btrfs_scratch_superblocks(struct btrfs_fs_info *fs_info,
 			       struct block_device *bdev,
 			       const char *device_path)
 {
-	struct btrfs_super_block *disk_super;
 	int copy_num;
 
 	if (!bdev)
 		return;
 
 	for (copy_num = 0; copy_num < BTRFS_SUPER_MIRROR_MAX; copy_num++) {
-		struct page *page;
-		int ret;
-
-		disk_super = btrfs_read_dev_one_super(bdev, copy_num, false);
-		if (IS_ERR(disk_super))
-			continue;
-
-		if (bdev_is_zoned(bdev)) {
+		if (bdev_is_zoned(bdev))
 			btrfs_reset_sb_log_zones(bdev, copy_num);
-			continue;
-		}
-
-		memset(&disk_super->magic, 0, sizeof(disk_super->magic));
-
-		page = virt_to_page(disk_super);
-		set_page_dirty(page);
-		lock_page(page);
-		/* write_on_page() unlocks the page */
-		ret = write_one_page(page);
-		if (ret)
-			btrfs_warn(fs_info,
-				"error clearing superblock number %d (%d)",
-				copy_num, ret);
-		btrfs_release_disk_super(disk_super);
-
+		else
+			btrfs_scratch_superblock(fs_info, bdev, copy_num);
 	}
 
 	/* Notify udev that device has changed */
-- 
2.35.1


_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel

  reply	other threads:[~2023-01-08 16:57 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-08 16:56 remove write_one_page / folio_write_one Christoph Hellwig
2023-01-08 16:56 ` [Ocfs2-devel] " Christoph Hellwig via Ocfs2-devel
2023-01-08 16:56 ` Christoph Hellwig [this message]
2023-01-08 16:56   ` [Ocfs2-devel] [PATCH 1/7] btrfs: don't read the disk superblock for zoned devices in btrfs_scratch_superblocks Christoph Hellwig via Ocfs2-devel
2023-01-08 16:56 ` [PATCH 2/7] btrfs: stop using write_one_page in btrfs_scratch_superblock Christoph Hellwig
2023-01-08 16:56   ` [Ocfs2-devel] " Christoph Hellwig via Ocfs2-devel
2023-01-08 21:13   ` Matthew Wilcox via Ocfs2-devel
2023-01-08 21:13     ` Matthew Wilcox
2023-01-08 16:56 ` [PATCH 3/7] minix: don't flush page immediately for DIRSYNC directories Christoph Hellwig
2023-01-08 16:56   ` [Ocfs2-devel] " Christoph Hellwig via Ocfs2-devel
2023-01-08 21:17   ` Matthew Wilcox
2023-01-08 21:17     ` [Ocfs2-devel] " Matthew Wilcox via Ocfs2-devel
2023-01-10  8:22     ` Christoph Hellwig
2023-01-10  8:22       ` [Ocfs2-devel] " Christoph Hellwig via Ocfs2-devel
2023-01-11  2:20       ` Al Viro
2023-01-11  2:20         ` [Ocfs2-devel] " Al Viro via Ocfs2-devel
2023-01-11  4:26         ` Christoph Hellwig via Ocfs2-devel
2023-01-11  4:26           ` Christoph Hellwig
2023-01-11  4:58           ` Al Viro
2023-01-11  4:58             ` [Ocfs2-devel] " Al Viro via Ocfs2-devel
2023-01-08 16:56 ` [PATCH 4/7] sysv: " Christoph Hellwig
2023-01-08 16:56   ` [Ocfs2-devel] " Christoph Hellwig via Ocfs2-devel
2023-01-08 21:19   ` Matthew Wilcox
2023-01-08 21:19     ` [Ocfs2-devel] " Matthew Wilcox via Ocfs2-devel
2023-01-10  8:24     ` Christoph Hellwig via Ocfs2-devel
2023-01-10  8:24       ` Christoph Hellwig
2023-01-08 16:56 ` [PATCH 5/7] ufs: " Christoph Hellwig
2023-01-08 16:56   ` [Ocfs2-devel] " Christoph Hellwig via Ocfs2-devel
2023-01-08 16:56 ` [PATCH 6/7] ocfs2: don't use write_one_page in ocfs2_duplicate_clusters_by_page Christoph Hellwig
2023-01-08 16:56   ` [Ocfs2-devel] " Christoph Hellwig via Ocfs2-devel
2023-01-09 17:03   ` Jan Kara via Ocfs2-devel
2023-01-09 17:03     ` Jan Kara
2023-01-10  3:03   ` [Ocfs2-devel] " Joseph Qi via Ocfs2-devel
2023-01-10  3:03     ` Joseph Qi
2023-01-08 16:56 ` [PATCH 7/7] mm,jfs: move write_one_page/folio_write_one to jfs Christoph Hellwig
2023-01-08 16:56   ` [Ocfs2-devel] [PATCH 7/7] mm, jfs: " Christoph Hellwig via Ocfs2-devel
2023-01-08 21:31 ` remove write_one_page / folio_write_one Matthew Wilcox
2023-01-08 21:31   ` [Ocfs2-devel] " Matthew Wilcox via Ocfs2-devel
2023-01-09 19:53 ` David Sterba
2023-01-09 19:53   ` [Ocfs2-devel] " David Sterba via Ocfs2-devel
2023-01-10  8:16   ` Christoph Hellwig
2023-01-10  8:16     ` [Ocfs2-devel] " Christoph Hellwig via Ocfs2-devel
2023-01-10 13:00     ` David Sterba
2023-01-10 13:00       ` [Ocfs2-devel] " David Sterba via Ocfs2-devel
2023-01-10 15:32       ` Christoph Hellwig via Ocfs2-devel
2023-01-10 15:32         ` Christoph Hellwig
2023-01-11 19:20         ` David Sterba
2023-01-11 19:20           ` [Ocfs2-devel] " David Sterba via Ocfs2-devel
2023-01-12  8:02           ` Christoph Hellwig
2023-01-12  8:02             ` [Ocfs2-devel] " Christoph Hellwig via Ocfs2-devel

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=20230108165645.381077-2-hch@lst.de \
    --to=hch@lst.de \
    --cc=akpm@linux-foundation.org \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=dushistov@mail.ru \
    --cc=jfs-discussion@lists.sourceforge.net \
    --cc=jlbec@evilplan.org \
    --cc=johannes.thumshirn@wdc.com \
    --cc=josef@toxicpanda.com \
    --cc=joseph.qi@linux.alibaba.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mark@fasheh.com \
    --cc=ocfs2-devel@oss.oracle.com \
    --cc=shaggy@kernel.org \
    --cc=willy@infradead.org \
    /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.