* [PATCH] zonefs: Call page_address() on page acquired with GFP_KERNEL flag
@ 2022-07-05 14:22 Fabio M. De Francesco
2022-07-05 21:40 ` Ira Weiny
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Fabio M. De Francesco @ 2022-07-05 14:22 UTC (permalink / raw)
To: Damien Le Moal, Naohiro Aota, Johannes Thumshirn, linux-fsdevel,
linux-kernel
Cc: Fabio M. De Francesco, Ira Weiny
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 <ira.weiny@intel.com>
Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
---
fs/zonefs/super.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
index 053299758deb..bd4e4be97a68 100644
--- a/fs/zonefs/super.c
+++ b/fs/zonefs/super.c
@@ -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);
--
2.36.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] zonefs: Call page_address() on page acquired with GFP_KERNEL flag
2022-07-05 14:22 [PATCH] zonefs: Call page_address() on page acquired with GFP_KERNEL flag Fabio M. De Francesco
@ 2022-07-05 21:40 ` Ira Weiny
2022-07-06 16:54 ` Johannes Thumshirn
2022-07-06 22:37 ` Damien Le Moal
2 siblings, 0 replies; 4+ messages in thread
From: Ira Weiny @ 2022-07-05 21:40 UTC (permalink / raw)
To: Fabio M. De Francesco
Cc: Damien Le Moal, Naohiro Aota, Johannes Thumshirn, linux-fsdevel,
linux-kernel
On Tue, Jul 05, 2022 at 04:22:02PM +0200, Fabio M. De Francesco wrote:
> 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 <ira.weiny@intel.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
> Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
> ---
> fs/zonefs/super.c | 16 +++++++---------
> 1 file changed, 7 insertions(+), 9 deletions(-)
>
> diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
> index 053299758deb..bd4e4be97a68 100644
> --- a/fs/zonefs/super.c
> +++ b/fs/zonefs/super.c
> @@ -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);
>
> --
> 2.36.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] zonefs: Call page_address() on page acquired with GFP_KERNEL flag
2022-07-05 14:22 [PATCH] zonefs: Call page_address() on page acquired with GFP_KERNEL flag Fabio M. De Francesco
2022-07-05 21:40 ` Ira Weiny
@ 2022-07-06 16:54 ` Johannes Thumshirn
2022-07-06 22:37 ` Damien Le Moal
2 siblings, 0 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2022-07-06 16:54 UTC (permalink / raw)
To: Fabio M. De Francesco, Damien Le Moal, Naohiro Aota,
Johannes Thumshirn, linux-fsdevel, linux-kernel
Cc: Ira Weiny
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] zonefs: Call page_address() on page acquired with GFP_KERNEL flag
2022-07-05 14:22 [PATCH] zonefs: Call page_address() on page acquired with GFP_KERNEL flag Fabio M. De Francesco
2022-07-05 21:40 ` Ira Weiny
2022-07-06 16:54 ` Johannes Thumshirn
@ 2022-07-06 22:37 ` Damien Le Moal
2 siblings, 0 replies; 4+ messages in thread
From: Damien Le Moal @ 2022-07-06 22:37 UTC (permalink / raw)
To: Fabio M. De Francesco, Naohiro Aota, Johannes Thumshirn,
linux-fsdevel, linux-kernel
Cc: Ira Weiny
On 7/5/22 23:22, Fabio M. De Francesco wrote:
> 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 <ira.weiny@intel.com>
> Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Applied to for-5.20. Thanks !
> ---
> fs/zonefs/super.c | 16 +++++++---------
> 1 file changed, 7 insertions(+), 9 deletions(-)
>
> diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
> index 053299758deb..bd4e4be97a68 100644
> --- a/fs/zonefs/super.c
> +++ b/fs/zonefs/super.c
> @@ -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);
>
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-07-06 22:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-05 14:22 [PATCH] zonefs: Call page_address() on page acquired with GFP_KERNEL flag Fabio M. De Francesco
2022-07-05 21:40 ` Ira Weiny
2022-07-06 16:54 ` Johannes Thumshirn
2022-07-06 22:37 ` 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.