zonefs: move super block reading from page to folio
Subsystems (2)
Johannes Thumshirn
reviewerPATCH v2 1/1 zonefs: move super block reading from page to folio
From: Johannes Thumshirn <[email protected]>
Move reading of the on-disk superblock from page to folios.
Cc Matthew Wilcox <[email protected]>
Signed-off-by Johannes Thumshirn <[email protected]>
--- fs/zonefs/super.c | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-)
fs/zonefs/super.c +14 -21
@@ -1109,30 +1109,23 @@ 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_inode->i_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 -EINVAL ; - 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 +1133,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 +1148,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 +1157,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 +1166,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; }
Signature · 1 line
2.43.0
Quoted 16 lines · Johannes Thumshirn
From: Johannes Thumshirn <[email protected]>
Move reading of the on-disk superblock from page to folios.
Cc Matthew Wilcox <[email protected]>Signed-off-by Johannes Thumshirn <[email protected]>--- fs/zonefs/super.c | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-)fs/zonefs/super.c +0
-0@@ -1109,30 +1109,23 @@ static int zonefs_init_zgroups(struct super_block *sb)static int zonefs_read_super (struct super_block *sb)
fs/zonefs/super.c static int zonefs_init_zgroups(struct super_block *sb) · line 1118
Quoted 10 lines
fs/zonefs/super.c +2
-1{struct zonefs_sb_info *sbi =ZONEFS_SB (sb); +struct address_space *address_space = sb->s_bdev->bd_inode->i_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;
Args seen it to late, bio and bio_vec are unused now...
fs/zonefs/super.c static int zonefs_init_zgroups(struct super_block *sb) · line 1112
Quoted 4 lines · Johannes Thumshirn
static int
zonefs_read_super(struct super_block *sb){fs/zonefs/super.c +1
-0struct zonefs_sb_info *sbi =ZONEFS_SB (sb); +struct address_space *address_space = sb->s_bdev->bd_inode->i_mapping;
203c1ce0bb06 killed bd_inode. You want
struct address_space *address_space = sb->s_bdev->bd_mapping
fs/zonefs/super.c static int zonefs_init_zgroups(struct super_block *sb) · line 1122
Quoted 3 lines
fs/zonefs/super.c +3
-0+ folio =read_mapping_folio (address_space,0 ,NULL ); +if (IS_ERR (folio)) +return -EINVAL ;
Wouldn't it be better to return PTR_ERR(folio)?