linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org,
	"Md. Haris Iqbal" <haris.iqbal@ionos.com>,
	Jack Wang <jinpu.wang@ionos.com>, Coly Li <colyli@kernel.org>,
	Kent Overstreet <kent.overstreet@linux.dev>,
	Mike Snitzer <snitzer@kernel.org>,
	Mikulas Patocka <mpatocka@redhat.com>, Chris Mason <clm@fb.com>,
	Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>,
	Andreas Gruenbacher <agruenba@redhat.com>,
	Carlos Maiolino <cem@kernel.org>,
	Damien Le Moal <dlemoal@kernel.org>,
	Naohiro Aota <naohiro.aota@wdc.com>,
	Johannes Thumshirn <jth@kernel.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Pavel Machek <pavel@kernel.org>,
	linux-bcache@vger.kernel.org, dm-devel@lists.linux.dev,
	linux-btrfs@vger.kernel.org, gfs2@lists.linux.dev,
	linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org,
	linux-pm@vger.kernel.org
Subject: [PATCH 16/17] zonefs: use bdev_rw_virt in zonefs_read_super
Date: Tue, 22 Apr 2025 16:26:17 +0200	[thread overview]
Message-ID: <20250422142628.1553523-17-hch@lst.de> (raw)
In-Reply-To: <20250422142628.1553523-1-hch@lst.de>

Switch zonefs_read_super to allocate the superblock buffer using kmalloc
which falls back to the page allocator for PAGE_SIZE allocation but
gives us a kernel virtual address and then use bdev_rw_virt to perform
the synchronous read into it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/zonefs/super.c | 34 ++++++++++++----------------------
 1 file changed, 12 insertions(+), 22 deletions(-)

diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
index faf1eb87895d..d165eb979f21 100644
--- a/fs/zonefs/super.c
+++ b/fs/zonefs/super.c
@@ -1111,28 +1111,19 @@ static int zonefs_read_super(struct super_block *sb)
 	struct zonefs_sb_info *sbi = ZONEFS_SB(sb);
 	struct zonefs_super *super;
 	u32 crc, stored_crc;
-	struct page *page;
-	struct bio_vec bio_vec;
-	struct bio bio;
 	int ret;
 
-	page = alloc_page(GFP_KERNEL);
-	if (!page)
+	super = kmalloc(PAGE_SIZE, GFP_KERNEL);
+	if (!super)
 		return -ENOMEM;
 
-	bio_init(&bio, sb->s_bdev, &bio_vec, 1, REQ_OP_READ);
-	bio.bi_iter.bi_sector = 0;
-	__bio_add_page(&bio, page, PAGE_SIZE, 0);
-
-	ret = submit_bio_wait(&bio);
+	ret = bdev_rw_virt(sb->s_bdev, 0, super, PAGE_SIZE, REQ_OP_READ);
 	if (ret)
-		goto free_page;
-
-	super = page_address(page);
+		goto free_super;
 
 	ret = -EINVAL;
 	if (le32_to_cpu(super->s_magic) != ZONEFS_MAGIC)
-		goto free_page;
+		goto free_super;
 
 	stored_crc = le32_to_cpu(super->s_crc);
 	super->s_crc = 0;
@@ -1140,14 +1131,14 @@ static int zonefs_read_super(struct super_block *sb)
 	if (crc != stored_crc) {
 		zonefs_err(sb, "Invalid checksum (Expected 0x%08x, got 0x%08x)",
 			   crc, stored_crc);
-		goto free_page;
+		goto free_super;
 	}
 
 	sbi->s_features = le64_to_cpu(super->s_features);
 	if (sbi->s_features & ~ZONEFS_F_DEFINED_FEATURES) {
 		zonefs_err(sb, "Unknown features set 0x%llx\n",
 			   sbi->s_features);
-		goto free_page;
+		goto free_super;
 	}
 
 	if (sbi->s_features & ZONEFS_F_UID) {
@@ -1155,7 +1146,7 @@ static int zonefs_read_super(struct super_block *sb)
 				       le32_to_cpu(super->s_uid));
 		if (!uid_valid(sbi->s_uid)) {
 			zonefs_err(sb, "Invalid UID feature\n");
-			goto free_page;
+			goto free_super;
 		}
 	}
 
@@ -1164,7 +1155,7 @@ static int zonefs_read_super(struct super_block *sb)
 				       le32_to_cpu(super->s_gid));
 		if (!gid_valid(sbi->s_gid)) {
 			zonefs_err(sb, "Invalid GID feature\n");
-			goto free_page;
+			goto free_super;
 		}
 	}
 
@@ -1173,15 +1164,14 @@ static int zonefs_read_super(struct super_block *sb)
 
 	if (memchr_inv(super->s_reserved, 0, sizeof(super->s_reserved))) {
 		zonefs_err(sb, "Reserved area is being used\n");
-		goto free_page;
+		goto free_super;
 	}
 
 	import_uuid(&sbi->s_uuid, super->s_uuid);
 	ret = 0;
 
-free_page:
-	__free_page(page);
-
+free_super:
+	kfree(super);
 	return ret;
 }
 
-- 
2.47.2


  parent reply	other threads:[~2025-04-22 14:27 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-22 14:26 add more bio helper Christoph Hellwig
2025-04-22 14:26 ` [PATCH 01/17] block: add a bio_add_virt_nofail helper Christoph Hellwig
2025-04-23  6:05   ` Hannes Reinecke
2025-04-24  5:56   ` Damien Le Moal
2025-04-29 11:02   ` Johannes Thumshirn
2025-04-22 14:26 ` [PATCH 02/17] block: add a bdev_rw_virt helper Christoph Hellwig
2025-04-23  6:07   ` Hannes Reinecke
2025-04-23  9:36     ` Christoph Hellwig
2025-04-24  5:59   ` Damien Le Moal
2025-04-24  6:26   ` John Garry
2025-04-29 11:03   ` Johannes Thumshirn
2025-04-22 14:26 ` [PATCH 03/17] block: add a bio_add_vmalloc helper Christoph Hellwig
2025-04-23  6:09   ` Hannes Reinecke
2025-04-24  6:06   ` Damien Le Moal
2025-04-29 11:05   ` Johannes Thumshirn
2025-04-22 14:26 ` [PATCH 04/17] block: remove the q argument from blk_rq_map_kern Christoph Hellwig
2025-04-23  6:10   ` Hannes Reinecke
2025-04-29 11:24     ` Johannes Thumshirn
2025-04-29 12:28       ` hch
2025-04-24  6:09   ` Damien Le Moal
2025-04-22 14:26 ` [PATCH 05/17] block: pass the operation to bio_{map,copy}_kern Christoph Hellwig
2025-04-23  6:11   ` Hannes Reinecke
2025-04-24  6:11   ` Damien Le Moal
2025-04-29 11:29   ` Johannes Thumshirn
2025-04-22 14:26 ` [PATCH 06/17] block: simplify bio_map_kern Christoph Hellwig
2025-04-23  6:14   ` Hannes Reinecke
2025-04-24  6:13   ` Damien Le Moal
2025-04-29 11:31   ` Johannes Thumshirn
2025-04-22 14:26 ` [PATCH 07/17] bcache: use bio_add_virt_nofail Christoph Hellwig
2025-04-24  6:14   ` Damien Le Moal
2025-04-29  2:06     ` Coly Li
2025-04-29 11:32   ` Johannes Thumshirn
2025-04-22 14:26 ` [PATCH 08/17] dm-bufio: " Christoph Hellwig
2025-04-24  6:14   ` Damien Le Moal
2025-04-29 11:33   ` Johannes Thumshirn
2025-04-22 14:26 ` [PATCH 09/17] dm-integrity: " Christoph Hellwig
2025-04-24  6:16   ` Damien Le Moal
2025-04-29 11:34   ` Johannes Thumshirn
2025-04-22 14:26 ` [PATCH 10/17] rnbd-srv: " Christoph Hellwig
2025-04-24  6:16   ` Damien Le Moal
2025-04-24  6:16   ` Damien Le Moal
2025-04-24  7:14   ` Jinpu Wang
2025-04-29 11:34   ` Johannes Thumshirn
2025-04-22 14:26 ` [PATCH 11/17] xfs: simplify xfs_buf_submit_bio Christoph Hellwig
2025-04-24  6:18   ` Damien Le Moal
2025-04-29 14:53   ` Darrick J. Wong
2025-04-22 14:26 ` [PATCH 12/17] xfs: simplify xfs_rw_bdev Christoph Hellwig
2025-04-24  6:20   ` Damien Le Moal
2025-04-29 14:53   ` Darrick J. Wong
2025-04-22 14:26 ` [PATCH 13/17] btrfs: use bdev_rw_virt in scrub_one_super Christoph Hellwig
2025-04-24  6:20   ` Damien Le Moal
2025-04-28  9:18   ` Johannes Thumshirn
2025-04-28  9:22   ` Qu Wenruo
2025-04-22 14:26 ` [PATCH 14/17] hfsplus: use bdev_rw_virt in hfsplus_submit_bio Christoph Hellwig
2025-04-24  6:21   ` Damien Le Moal
2025-04-29 11:39   ` Johannes Thumshirn
2025-04-22 14:26 ` [PATCH 15/17] gfs2: use bdev_rw_virt in gfs2_read_super Christoph Hellwig
2025-04-24  6:23   ` Damien Le Moal
2025-04-24  8:08     ` Andreas Gruenbacher
2025-04-22 14:26 ` Christoph Hellwig [this message]
2025-04-24  6:24   ` [PATCH 16/17] zonefs: use bdev_rw_virt in zonefs_read_super Damien Le Moal
2025-04-29 11:44   ` Johannes Thumshirn
2025-04-29 12:31     ` hch
2025-04-22 14:26 ` [PATCH 17/17] PM: hibernate: split and simplify hib_submit_io Christoph Hellwig
2025-04-24  6:26   ` Damien Le Moal
2025-04-29 11:12   ` Rafael J. Wysocki
2025-04-22 14:47 ` add more bio helper Kent Overstreet
2025-04-23  9:36   ` Christoph Hellwig
2025-04-23 10:37     ` Kent Overstreet
2025-04-23 16:07       ` Christoph Hellwig
2025-04-23 18:02         ` Kent Overstreet
2025-04-24  8:37           ` Christoph Hellwig
2025-04-24 12:01             ` Kent Overstreet

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=20250422142628.1553523-17-hch@lst.de \
    --to=hch@lst.de \
    --cc=agruenba@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=cem@kernel.org \
    --cc=clm@fb.com \
    --cc=colyli@kernel.org \
    --cc=dlemoal@kernel.org \
    --cc=dm-devel@lists.linux.dev \
    --cc=dsterba@suse.com \
    --cc=gfs2@lists.linux.dev \
    --cc=haris.iqbal@ionos.com \
    --cc=jinpu.wang@ionos.com \
    --cc=josef@toxicpanda.com \
    --cc=jth@kernel.org \
    --cc=kent.overstreet@linux.dev \
    --cc=linux-bcache@vger.kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=mpatocka@redhat.com \
    --cc=naohiro.aota@wdc.com \
    --cc=pavel@kernel.org \
    --cc=rafael@kernel.org \
    --cc=snitzer@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).