* [f2fs-dev] [PATCH] fsck.f2fs: clean up codes with IS_INODE()
@ 2023-05-28 8:07 Chao Yu
2023-05-30 22:58 ` Jaegeuk Kim
0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu @ 2023-05-28 8:07 UTC (permalink / raw)
To: jaegeuk; +Cc: linux-f2fs-devel
and use le32_to_cpu() in IS_INODE().
Signed-off-by: Chao Yu <chao@kernel.org>
---
fsck/fsck.c | 7 +++----
fsck/mount.c | 4 ++--
fsck/node.h | 3 ++-
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/fsck/fsck.c b/fsck/fsck.c
index e6ad71d..a4db2a3 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -247,7 +247,7 @@ static int is_valid_summary(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
goto out;
/* check its block address */
- if (node_blk->footer.nid == node_blk->footer.ino) {
+ if (IS_INODE(node_blk)) {
int ofs = get_extra_isize(node_blk);
if (ofs + ofs_in_node >= DEF_ADDRS_PER_INODE)
@@ -447,8 +447,7 @@ static int sanity_check_nid(struct f2fs_sb_info *sbi, u32 nid,
nid, ni->ino, le32_to_cpu(node_blk->footer.ino));
return -EINVAL;
}
- if (ntype != TYPE_INODE &&
- node_blk->footer.nid == node_blk->footer.ino) {
+ if (ntype != TYPE_INODE && IS_INODE(node_blk)) {
ASSERT_MSG("nid[0x%x] footer.nid[0x%x] footer.ino[0x%x]",
nid, le32_to_cpu(node_blk->footer.nid),
le32_to_cpu(node_blk->footer.ino));
@@ -3080,7 +3079,7 @@ static int fsck_reconnect_file(struct f2fs_sb_info *sbi)
ASSERT(err >= 0);
/* reconnection will restore these nodes if needed */
- if (node->footer.ino != node->footer.nid) {
+ if (!IS_INODE(node)) {
DBG(1, "Not support non-inode node [0x%x]\n",
nid);
continue;
diff --git a/fsck/mount.c b/fsck/mount.c
index f1fb525..90ecabf 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -2394,7 +2394,7 @@ void update_data_blkaddr(struct f2fs_sb_info *sbi, nid_t nid,
ASSERT(ret >= 0);
/* check its block address */
- if (node_blk->footer.nid == node_blk->footer.ino) {
+ if (IS_INODE(node_blk)) {
int ofs = get_extra_isize(node_blk);
oldaddr = le32_to_cpu(node_blk->i.i_addr[ofs + ofs_in_node]);
@@ -2409,7 +2409,7 @@ void update_data_blkaddr(struct f2fs_sb_info *sbi, nid_t nid,
}
/* check extent cache entry */
- if (node_blk->footer.nid != node_blk->footer.ino) {
+ if (!IS_INODE(node_blk)) {
get_node_info(sbi, le32_to_cpu(node_blk->footer.ino), &ni);
/* read inode block */
diff --git a/fsck/node.h b/fsck/node.h
index 99139b1..2ba7b8c 100644
--- a/fsck/node.h
+++ b/fsck/node.h
@@ -20,7 +20,8 @@
static inline int IS_INODE(struct f2fs_node *node)
{
- return ((node)->footer.nid == (node)->footer.ino);
+ return le32_to_cpu(node->footer.ino) ==
+ le32_to_cpu(node->footer.nid);
}
static inline unsigned int ADDRS_PER_PAGE(struct f2fs_sb_info *sbi,
--
2.40.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [f2fs-dev] [PATCH] fsck.f2fs: clean up codes with IS_INODE()
2023-05-28 8:07 [f2fs-dev] [PATCH] fsck.f2fs: clean up codes with IS_INODE() Chao Yu
@ 2023-05-30 22:58 ` Jaegeuk Kim
2023-05-31 1:07 ` Chao Yu
0 siblings, 1 reply; 3+ messages in thread
From: Jaegeuk Kim @ 2023-05-30 22:58 UTC (permalink / raw)
To: Chao Yu; +Cc: linux-f2fs-devel
On 05/28, Chao Yu wrote:
> and use le32_to_cpu() in IS_INODE().
>
> Signed-off-by: Chao Yu <chao@kernel.org>
> ---
> fsck/fsck.c | 7 +++----
> fsck/mount.c | 4 ++--
> fsck/node.h | 3 ++-
> 3 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/fsck/fsck.c b/fsck/fsck.c
> index e6ad71d..a4db2a3 100644
> --- a/fsck/fsck.c
> +++ b/fsck/fsck.c
> @@ -247,7 +247,7 @@ static int is_valid_summary(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
> goto out;
>
> /* check its block address */
> - if (node_blk->footer.nid == node_blk->footer.ino) {
> + if (IS_INODE(node_blk)) {
> int ofs = get_extra_isize(node_blk);
>
> if (ofs + ofs_in_node >= DEF_ADDRS_PER_INODE)
> @@ -447,8 +447,7 @@ static int sanity_check_nid(struct f2fs_sb_info *sbi, u32 nid,
> nid, ni->ino, le32_to_cpu(node_blk->footer.ino));
> return -EINVAL;
> }
> - if (ntype != TYPE_INODE &&
> - node_blk->footer.nid == node_blk->footer.ino) {
> + if (ntype != TYPE_INODE && IS_INODE(node_blk)) {
> ASSERT_MSG("nid[0x%x] footer.nid[0x%x] footer.ino[0x%x]",
> nid, le32_to_cpu(node_blk->footer.nid),
> le32_to_cpu(node_blk->footer.ino));
> @@ -3080,7 +3079,7 @@ static int fsck_reconnect_file(struct f2fs_sb_info *sbi)
> ASSERT(err >= 0);
>
> /* reconnection will restore these nodes if needed */
> - if (node->footer.ino != node->footer.nid) {
> + if (!IS_INODE(node)) {
> DBG(1, "Not support non-inode node [0x%x]\n",
> nid);
> continue;
> diff --git a/fsck/mount.c b/fsck/mount.c
> index f1fb525..90ecabf 100644
> --- a/fsck/mount.c
> +++ b/fsck/mount.c
> @@ -2394,7 +2394,7 @@ void update_data_blkaddr(struct f2fs_sb_info *sbi, nid_t nid,
> ASSERT(ret >= 0);
>
> /* check its block address */
> - if (node_blk->footer.nid == node_blk->footer.ino) {
> + if (IS_INODE(node_blk)) {
> int ofs = get_extra_isize(node_blk);
>
> oldaddr = le32_to_cpu(node_blk->i.i_addr[ofs + ofs_in_node]);
> @@ -2409,7 +2409,7 @@ void update_data_blkaddr(struct f2fs_sb_info *sbi, nid_t nid,
> }
>
> /* check extent cache entry */
> - if (node_blk->footer.nid != node_blk->footer.ino) {
> + if (!IS_INODE(node_blk)) {
> get_node_info(sbi, le32_to_cpu(node_blk->footer.ino), &ni);
>
> /* read inode block */
> diff --git a/fsck/node.h b/fsck/node.h
> index 99139b1..2ba7b8c 100644
> --- a/fsck/node.h
> +++ b/fsck/node.h
> @@ -20,7 +20,8 @@
>
> static inline int IS_INODE(struct f2fs_node *node)
return bool?
> {
> - return ((node)->footer.nid == (node)->footer.ino);
> + return le32_to_cpu(node->footer.ino) ==
> + le32_to_cpu(node->footer.nid);
Again, why do we need this conversion which looks uncessary?
> }
>
> static inline unsigned int ADDRS_PER_PAGE(struct f2fs_sb_info *sbi,
> --
> 2.40.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [f2fs-dev] [PATCH] fsck.f2fs: clean up codes with IS_INODE()
2023-05-30 22:58 ` Jaegeuk Kim
@ 2023-05-31 1:07 ` Chao Yu
0 siblings, 0 replies; 3+ messages in thread
From: Chao Yu @ 2023-05-31 1:07 UTC (permalink / raw)
To: Jaegeuk Kim; +Cc: linux-f2fs-devel
On 2023/5/31 6:58, Jaegeuk Kim wrote:
> On 05/28, Chao Yu wrote:
>> and use le32_to_cpu() in IS_INODE().
>>
>> Signed-off-by: Chao Yu <chao@kernel.org>
>> ---
>> fsck/fsck.c | 7 +++----
>> fsck/mount.c | 4 ++--
>> fsck/node.h | 3 ++-
>> 3 files changed, 7 insertions(+), 7 deletions(-)
>>
>> diff --git a/fsck/fsck.c b/fsck/fsck.c
>> index e6ad71d..a4db2a3 100644
>> --- a/fsck/fsck.c
>> +++ b/fsck/fsck.c
>> @@ -247,7 +247,7 @@ static int is_valid_summary(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
>> goto out;
>>
>> /* check its block address */
>> - if (node_blk->footer.nid == node_blk->footer.ino) {
>> + if (IS_INODE(node_blk)) {
>> int ofs = get_extra_isize(node_blk);
>>
>> if (ofs + ofs_in_node >= DEF_ADDRS_PER_INODE)
>> @@ -447,8 +447,7 @@ static int sanity_check_nid(struct f2fs_sb_info *sbi, u32 nid,
>> nid, ni->ino, le32_to_cpu(node_blk->footer.ino));
>> return -EINVAL;
>> }
>> - if (ntype != TYPE_INODE &&
>> - node_blk->footer.nid == node_blk->footer.ino) {
>> + if (ntype != TYPE_INODE && IS_INODE(node_blk)) {
>> ASSERT_MSG("nid[0x%x] footer.nid[0x%x] footer.ino[0x%x]",
>> nid, le32_to_cpu(node_blk->footer.nid),
>> le32_to_cpu(node_blk->footer.ino));
>> @@ -3080,7 +3079,7 @@ static int fsck_reconnect_file(struct f2fs_sb_info *sbi)
>> ASSERT(err >= 0);
>>
>> /* reconnection will restore these nodes if needed */
>> - if (node->footer.ino != node->footer.nid) {
>> + if (!IS_INODE(node)) {
>> DBG(1, "Not support non-inode node [0x%x]\n",
>> nid);
>> continue;
>> diff --git a/fsck/mount.c b/fsck/mount.c
>> index f1fb525..90ecabf 100644
>> --- a/fsck/mount.c
>> +++ b/fsck/mount.c
>> @@ -2394,7 +2394,7 @@ void update_data_blkaddr(struct f2fs_sb_info *sbi, nid_t nid,
>> ASSERT(ret >= 0);
>>
>> /* check its block address */
>> - if (node_blk->footer.nid == node_blk->footer.ino) {
>> + if (IS_INODE(node_blk)) {
>> int ofs = get_extra_isize(node_blk);
>>
>> oldaddr = le32_to_cpu(node_blk->i.i_addr[ofs + ofs_in_node]);
>> @@ -2409,7 +2409,7 @@ void update_data_blkaddr(struct f2fs_sb_info *sbi, nid_t nid,
>> }
>>
>> /* check extent cache entry */
>> - if (node_blk->footer.nid != node_blk->footer.ino) {
>> + if (!IS_INODE(node_blk)) {
>> get_node_info(sbi, le32_to_cpu(node_blk->footer.ino), &ni);
>>
>> /* read inode block */
>> diff --git a/fsck/node.h b/fsck/node.h
>> index 99139b1..2ba7b8c 100644
>> --- a/fsck/node.h
>> +++ b/fsck/node.h
>> @@ -20,7 +20,8 @@
>>
>> static inline int IS_INODE(struct f2fs_node *node)
>
> return bool?
Will change return value of IS_INODE.
>
>> {
>> - return ((node)->footer.nid == (node)->footer.ino);
>> + return le32_to_cpu(node->footer.ino) ==
>> + le32_to_cpu(node->footer.nid);
>
> Again, why do we need this conversion which looks uncessary?
Let me remove this in v2.
Thanks,
>
>> }
>>
>> static inline unsigned int ADDRS_PER_PAGE(struct f2fs_sb_info *sbi,
>> --
>> 2.40.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-05-31 1:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-28 8:07 [f2fs-dev] [PATCH] fsck.f2fs: clean up codes with IS_INODE() Chao Yu
2023-05-30 22:58 ` Jaegeuk Kim
2023-05-31 1:07 ` Chao Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).