zonefs: Call page_address() on page acquired with GFP_KERNEL flag
Subsystems (2)
PATCH 1/1 zonefs: Call page_address() on page acquired with GFP_KERNEL flag
zonefs_read_super() acquires a page with alloc_page(GFP_KERNEL). That page cannot come from ZONE_HIGHMEM, thus there's no need to map it with kmap().
Therefore, use a plain page_address() on that page.
Suggested-by Ira Weiny <[email protected]>
Signed-off-by Fabio M. De Francesco <[email protected]>
--- fs/zonefs/super.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
fs/zonefs/super.c +7 -9
@@ -1687,11 +1687,11 @@ static int zonefs_read_super(struct super_block *sb)if (ret) goto free_page; - super =kmap (page); + super =page_address (page); ret = -EINVAL ;if (le32_to_cpu (super->s_magic) !=ZONEFS_MAGIC ) - goto unmap; + goto free_page; stored_crc =le32_to_cpu (super->s_crc); super->s_crc =0 ;
@@ -1699,14 +1699,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 unmap; + goto free_page; } 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 unmap; + goto free_page; }if (sbi->s_features &ZONEFS_F_UID ) {
@@ -1714,7 +1714,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 unmap; + goto free_page; } }
@@ -1723,7 +1723,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 unmap; + goto free_page; } }
@@ -1732,14 +1732,12 @@ 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 unmap; + goto free_page; }import_uuid (&sbi->s_uuid, super->s_uuid); ret =0 ; -unmap: -kunmap (page); free_page:__free_page (page);
Signature · 1 line
2.36.1
Quoted 7 lines · Fabio M. De Francesco
zonefs_read_super()acquires a page withalloc_page(GFP_KERNEL). That page cannot come fromZONE_HIGHMEM, thus there's no need to map it withkmap().Therefore, use a plain
page_address()on that page.Suggested-by Ira Weiny <[email protected]>
Reviewed-by Ira Weiny <[email protected]>
Quoted 77 lines
Signed-off-by Fabio M. De Francesco <[email protected]>--- fs/zonefs/super.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)fs/zonefs/super.c +7
-9@@ -1687,11 +1687,11 @@ static int zonefs_read_super(struct super_block *sb)if (ret) goto free_page; - super =kmap (page); + super =page_address (page); ret = -EINVAL ;if (le32_to_cpu (super->s_magic) !=ZONEFS_MAGIC ) - goto unmap; + goto free_page; stored_crc =le32_to_cpu (super->s_crc); super->s_crc =0 ;@@ -1699,14 +1699,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 unmap; + goto free_page; } 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 unmap; + goto free_page; }if (sbi->s_features &ZONEFS_F_UID ) {@@ -1714,7 +1714,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 unmap; + goto free_page; } }@@ -1723,7 +1723,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 unmap; + goto free_page; } }@@ -1732,14 +1732,12 @@ 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 unmap; + goto free_page; }import_uuid (&sbi->s_uuid, super->s_uuid); ret =0 ; -unmap: -kunmap (page); free_page:__free_page (page);Signature · 1 line
2.36.1
Looks good,
Reviewed-by Johannes Thumshirn <[email protected]>
Damien Le Moal
AppliedQuoted 8 lines · Fabio M. De Francesco
zonefs_read_super()acquires a page withalloc_page(GFP_KERNEL). That page cannot come fromZONE_HIGHMEM, thus there's no need to map it withkmap().Therefore, use a plain
page_address()on that page.Suggested-by Ira Weiny <[email protected]>Signed-off-by Fabio M. De Francesco <[email protected]>
Applied to for-5.20. Thanks !
Quoted 73 lines
--- fs/zonefs/super.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)fs/zonefs/super.c +7
-9@@ -1687,11 +1687,11 @@ static int zonefs_read_super(struct super_block *sb)if (ret) goto free_page; - super =kmap (page); + super =page_address (page); ret = -EINVAL ;if (le32_to_cpu (super->s_magic) !=ZONEFS_MAGIC ) - goto unmap; + goto free_page; stored_crc =le32_to_cpu (super->s_crc); super->s_crc =0 ;@@ -1699,14 +1699,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 unmap; + goto free_page; } 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 unmap; + goto free_page; }if (sbi->s_features &ZONEFS_F_UID ) {@@ -1714,7 +1714,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 unmap; + goto free_page; } }@@ -1723,7 +1723,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 unmap; + goto free_page; } }@@ -1732,14 +1732,12 @@ 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 unmap; + goto free_page; }import_uuid (&sbi->s_uuid, super->s_uuid); ret =0 ; -unmap: -kunmap (page); free_page:__free_page (page);
Signature · 2 lines
Damien Le Moal Western Digital Research