From: Jaegeuk Kim <jaegeuk@kernel.org>
To: linux-f2fs-devel@lists.sourceforge.net
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Subject: [f2fs-dev] [PATCH] f2fs: should use inode when updating file offset
Date: Wed, 12 Jul 2023 08:41:27 -0700 [thread overview]
Message-ID: <20230712154127.1332750-1-jaegeuk@kernel.org> (raw)
In indirect or double indirect node blocks, we should use parent inode
information to check the offset.
This fixes the below complaint with a reproducer.
$ mount -t f2fs -o discard,compress_extension=* /dev/$DEV $TESTDIR
$ f2fs_io write 1 3944 4 zero buffered $TESTDIR/a
$ umount /dev/$DEV
$ fsck.f2fs /dev/$DEV
Info: MKFS version
"Linux version 6.5.0-rc1-custom (root@file) (gcc (Ubuntu 11.2.0-7ubuntu2) 11.2.0, GNU ld (GNU Binutils for Ubuntu) 2.37) #19 SMP PREEMPT_DYNAMIC Mon Jul 10 19:18:40 UTC 2023"
Info: FSCK version
from "Linux version 6.5.0-rc1-custom (root@file) (gcc (Ubuntu 11.2.0-7ubuntu2) 11.2.0, GNU ld (GNU Binutils for Ubuntu) 2.37) #19 SMP PREEMPT_DYNAMIC Mon Jul 10 19:18:40 UTC 2023"
to "Linux version 6.5.0-rc1-custom (root@file) (gcc (Ubuntu 11.2.0-7ubuntu2) 11.2.0, GNU ld (GNU Binutils for Ubuntu) 2.37) #19 SMP PREEMPT_DYNAMIC Mon Jul 10 19:18:40 UTC 2023"
Info: superblock features = 3088 : extra_attr quota casefold compression
Info: superblock encrypt level = 0, salt = 00000000000000000000000000000000
Info: Segments per section = 1
Info: Sections per zone = 1
Info: total FS sectors = 134217728 (65536 MB)
Info: CKPT version = 284f1e2f
Info: Checked valid nat_bits in checkpoint
Info: checkpoint state = c5 : nat_bits crc compacted_summary unmount
[ASSERT] (fsck_chk_inode_blk:1189) --> ino: 0x6 has i_blocks: 00000007, but has 6 blocks
[FSCK] Max image size: 378 MB, Free space: 65158 MB
[FSCK] Unreachable nat entries [Ok..] [0x0]
[FSCK] SIT valid block bitmap checking [Ok..]
[FSCK] Hard link checking for regular file [Ok..] [0x0]
[FSCK] valid_block_count matching with CP [Fail] [0xf, 0xe]
[FSCK] valid_node_count matching with CP (de lookup) [Ok..] [0x6]
[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [0x6]
[FSCK] valid_inode_count matched with CP [Ok..] [0x4]
[FSCK] free segment_count matched with CP [Ok..] [0x7f3f]
[FSCK] next block offset is free [Ok..]
[FSCK] fixing SIT types
[FSCK] other corrupted bugs [Fail]
Do you want to fix this partition? [Y/N]
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fsck/fsck.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/fsck/fsck.c b/fsck/fsck.c
index 051510fb06b2..78ffdb651595 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -1430,7 +1430,7 @@ int fsck_chk_idnode_blk(struct f2fs_sb_info *sbi, struct f2fs_inode *inode,
FIX_MSG("Set indirect node 0x%x -> 0", i);
}
skip:
- child->pgofs += ADDRS_PER_BLOCK(&node_blk->i);
+ child->pgofs += ADDRS_PER_BLOCK(inode);
}
}
@@ -1472,8 +1472,7 @@ int fsck_chk_didnode_blk(struct f2fs_sb_info *sbi, struct f2fs_inode *inode,
FIX_MSG("Set double indirect node 0x%x -> 0", i);
}
skip:
- child->pgofs += ADDRS_PER_BLOCK(&node_blk->i) *
- NIDS_PER_BLOCK;
+ child->pgofs += ADDRS_PER_BLOCK(inode) * NIDS_PER_BLOCK;
}
}
--
2.41.0.255.g8b1d071c50-goog
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
reply other threads:[~2023-07-12 15:41 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230712154127.1332750-1-jaegeuk@kernel.org \
--to=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).