All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] zonefs: move super block reading from page to folio
@ 2024-05-23 15:02 Johannes Thumshirn
  2024-05-23 16:19 ` Matthew Wilcox
  2024-05-27  4:35 ` Damien Le Moal
  0 siblings, 2 replies; 3+ messages in thread
From: Johannes Thumshirn @ 2024-05-23 15:02 UTC (permalink / raw)
  To: Damien Le Moal; +Cc: linux-fsdevel, Matthew Wilcox, Johannes Thumshirn

From: Johannes Thumshirn <johannes.thumshirn@wdc.com>

Move reading of the on-disk superblock from page to folios.

Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---

Changes to v2:
- Rebase onto Linus' master
- Remove now unused varuabls
- Return read_mapping_folio()s error in case it fails

 fs/zonefs/super.c | 37 ++++++++++++++-----------------------
 1 file changed, 14 insertions(+), 23 deletions(-)

diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
index faf1eb87895d..e2bb7556a364 100644
--- a/fs/zonefs/super.c
+++ b/fs/zonefs/super.c
@@ -1109,30 +1109,21 @@ static int zonefs_init_zgroups(struct super_block *sb)
 static int zonefs_read_super(struct super_block *sb)
 {
 	struct zonefs_sb_info *sbi = ZONEFS_SB(sb);
+	struct address_space *address_space = sb->s_bdev->bd_mapping;
 	struct zonefs_super *super;
 	u32 crc, stored_crc;
-	struct page *page;
-	struct bio_vec bio_vec;
-	struct bio bio;
+	struct folio *folio;
 	int ret;
 
-	page = alloc_page(GFP_KERNEL);
-	if (!page)
-		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);
-	if (ret)
-		goto free_page;
+	folio = read_mapping_folio(address_space, 0, NULL);
+	if (IS_ERR(folio))
+		return PTR_ERR(folio);
 
-	super = page_address(page);
+	super = folio_address(folio);
 
 	ret = -EINVAL;
 	if (le32_to_cpu(super->s_magic) != ZONEFS_MAGIC)
-		goto free_page;
+		goto put_folio;
 
 	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 put_folio;
 	}
 
 	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 put_folio;
 	}
 
 	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 put_folio;
 		}
 	}
 
@@ -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 put_folio;
 		}
 	}
 
@@ -1173,14 +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 put_folio;
 	}
 
 	import_uuid(&sbi->s_uuid, super->s_uuid);
 	ret = 0;
 
-free_page:
-	__free_page(page);
+put_folio:
+	folio_put(folio);
 
 	return ret;
 }
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] zonefs: move super block reading from page to folio
  2024-05-23 15:02 [PATCH v3] zonefs: move super block reading from page to folio Johannes Thumshirn
@ 2024-05-23 16:19 ` Matthew Wilcox
  2024-05-27  4:35 ` Damien Le Moal
  1 sibling, 0 replies; 3+ messages in thread
From: Matthew Wilcox @ 2024-05-23 16:19 UTC (permalink / raw)
  To: Johannes Thumshirn; +Cc: Damien Le Moal, linux-fsdevel, Johannes Thumshirn

On Thu, May 23, 2024 at 05:02:53PM +0200, Johannes Thumshirn wrote:
> From: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> 
> Move reading of the on-disk superblock from page to folios.
> 
> Cc: Matthew Wilcox <willy@infradead.org>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] zonefs: move super block reading from page to folio
  2024-05-23 15:02 [PATCH v3] zonefs: move super block reading from page to folio Johannes Thumshirn
  2024-05-23 16:19 ` Matthew Wilcox
@ 2024-05-27  4:35 ` Damien Le Moal
  1 sibling, 0 replies; 3+ messages in thread
From: Damien Le Moal @ 2024-05-27  4:35 UTC (permalink / raw)
  To: Johannes Thumshirn; +Cc: linux-fsdevel, Matthew Wilcox, Johannes Thumshirn

On 5/24/24 12:02 AM, Johannes Thumshirn wrote:
> From: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> 
> Move reading of the on-disk superblock from page to folios.
> 
> Cc: Matthew Wilcox <willy@infradead.org>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

Applied to for-6.11. Thanks !

-- 
Damien Le Moal
Western Digital Research


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-05-27  4:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-23 15:02 [PATCH v3] zonefs: move super block reading from page to folio Johannes Thumshirn
2024-05-23 16:19 ` Matthew Wilcox
2024-05-27  4:35 ` Damien Le Moal

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.