2023-05-18 09:33:11

by Chao Yu

[permalink] [raw]
Subject: [PATCH] f2fs: fix to use le32_to_cpu() in RAW_IS_INODE()

__le32 type variable should be converted w/ le32_to_cpu() before access.

Signed-off-by: Chao Yu <[email protected]>
---
fs/f2fs/f2fs.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 7f6c51a6b930..a4bff3b5b887 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -2840,7 +2840,11 @@ static inline void f2fs_radix_tree_insert(struct radix_tree_root *root,
cond_resched();
}

-#define RAW_IS_INODE(p) ((p)->footer.nid == (p)->footer.ino)
+static inline bool RAW_IS_INODE(struct f2fs_node *node)
+{
+ return le32_to_cpu(node->footer.ino) ==
+ le32_to_cpu(node->footer.nid);
+}

static inline bool IS_INODE(struct page *page)
{
--
2.40.1



2023-05-24 02:12:27

by Jaegeuk Kim

[permalink] [raw]
Subject: Re: [PATCH] f2fs: fix to use le32_to_cpu() in RAW_IS_INODE()

On 05/18, Chao Yu wrote:
> __le32 type variable should be converted w/ le32_to_cpu() before access.
>
> Signed-off-by: Chao Yu <[email protected]>
> ---
> fs/f2fs/f2fs.h | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index 7f6c51a6b930..a4bff3b5b887 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -2840,7 +2840,11 @@ static inline void f2fs_radix_tree_insert(struct radix_tree_root *root,
> cond_resched();
> }
>
> -#define RAW_IS_INODE(p) ((p)->footer.nid == (p)->footer.ino)

Does this compare the same __le32 types?

> +static inline bool RAW_IS_INODE(struct f2fs_node *node)
> +{
> + return le32_to_cpu(node->footer.ino) ==
> + le32_to_cpu(node->footer.nid);
> +}
>
> static inline bool IS_INODE(struct page *page)
> {
> --
> 2.40.1