From: Sheng Yong <shengyong1@huawei.com>
To: Chao Yu <yuchao0@huawei.com>, jaegeuk@kernel.org
Cc: linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [RFC PATCH 7/8] fsck.f2fs: introduce sanity_check_inode
Date: Tue, 31 Oct 2017 17:21:19 +0800 [thread overview]
Message-ID: <93bd4aa0-f81d-14ba-b5db-c051be4d9f8c@huawei.com> (raw)
In-Reply-To: <c609e8f2-520f-a5ed-8a9e-f624de3cff63@huawei.com>
On 2017/10/31 16:04, Chao Yu wrote:
> On 2017/10/31 9:38, Sheng Yong wrote:
>> f2fs_iget checks if i_mode is valid. If it is not, the file cannot be
>> accessed as well as deleted. To make sure such files can be removed,
>> fsck adds the same check, and removes incorrect inode blocks.
>>
>> Signed-off-by: Sheng Yong <shengyong1@huawei.com>
>> ---
>> fsck/fsck.c | 21 +++++++++++++++++++++
>> fsck/mount.c | 4 ++--
>> 2 files changed, 23 insertions(+), 2 deletions(-)
>>
>> diff --git a/fsck/fsck.c b/fsck/fsck.c
>> index 56a47be..77490d8 100644
>> --- a/fsck/fsck.c
>> +++ b/fsck/fsck.c
>> @@ -458,6 +458,25 @@ static int sanity_check_nid(struct f2fs_sb_info *sbi, u32 nid,
>> return 0;
>> }
>>
>> +static int sanity_check_inode(struct f2fs_sb_info *sbi, struct f2fs_node *node)
>> +{
>> + struct f2fs_fsck *fsck = F2FS_FSCK(sbi);
>> + struct f2fs_inode *fi = &node->i;
>> +
>> + if (!(le16_to_cpu(fi->i_mode) & S_IFMT)) {
>> + ASSERT_MSG("i_mode is not valid. [0x%x]", le16_to_cpu(fi->i_mode));
>> + goto remove_node;
>> + }
>> +
>> + return 0;
>> +
>> +remove_node:> + f2fs_set_bit(le32_to_cpu(node->footer.ino), fsck->nat_area_bitmap);
>> + fsck->chk.valid_blk_cnt--;
>> + fsck->chk.valid_node_cnt--;
>> + return -EINVAL;
>> +}
>> +
>> static int fsck_chk_xattr_blk(struct f2fs_sb_info *sbi, u32 ino,
>> u32 x_nid, u32 *blk_cnt)
>> {
>> @@ -500,6 +519,8 @@ int fsck_chk_node_blk(struct f2fs_sb_info *sbi, struct f2fs_inode *inode,
>> goto err;
>>
>> if (ntype == TYPE_INODE) {
>> + if (sanity_check_inode(sbi, node_blk))
>> + goto err;
>> fsck_chk_inode_blk(sbi, nid, ftype, node_blk, blk_cnt, &ni);
>> } else {
>> switch (ntype) {
>> diff --git a/fsck/mount.c b/fsck/mount.c
>> index a9cd581..45341bc 100644
>> --- a/fsck/mount.c
>> +++ b/fsck/mount.c
>> @@ -1985,7 +1985,7 @@ void nullify_nat_entry(struct f2fs_sb_info *sbi, u32 nid)
>> if (le32_to_cpu(nid_in_journal(journal, i)) == nid) {
>> memset(&nat_in_journal(journal, i), 0,
>> sizeof(struct f2fs_nat_entry));
>> - FIX_MSG("Remove nid [0x%x] in nat journal\n", nid);
>> + FIX_MSG("Remove nid [0x%x] in nat journal", nid);
>> return;
>> }
>> }
>> @@ -2005,7 +2005,7 @@ void nullify_nat_entry(struct f2fs_sb_info *sbi, u32 nid)
>> } else {
>> memset(&nat_block->entries[entry_off], 0,
>> sizeof(struct f2fs_nat_entry));
>> - FIX_MSG("Remove nid [0x%x] in NAT\n", nid);
>> + FIX_MSG("Remove nid [0x%x] in NAT", nid);
>
> How about moving all message printing modification into one patch?
OK. I'll split these changes into different patches :)
thanks,
Sheng
>
> Thanks,
>
>> }
>>
>> ret = dev_write_block(nat_block, block_addr);
>>
>
>
> .
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
next prev parent reply other threads:[~2017-10-31 9:25 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-31 1:38 [RFC PATCH 1/8] fsck.f2fs: do not set fix_on directly Sheng Yong
2017-10-31 1:38 ` [RFC PATCH 2/8] fsck.f2fs: do not fix corrupted nat entries in build_nat_area_bitmap Sheng Yong
2017-10-31 7:20 ` Chao Yu
2017-10-31 8:57 ` Sheng Yong
2017-10-31 10:43 ` Chao Yu
2017-10-31 1:38 ` [RFC PATCH 3/8] dump/fsck: introduce print_xattr_entry Sheng Yong
2017-10-31 7:51 ` Chao Yu
2017-10-31 9:02 ` Sheng Yong
2017-10-31 10:44 ` Chao Yu
2017-10-31 1:38 ` [RFC PATCH 4/8] dump.f2fs: introduce dump_xattr Sheng Yong
2017-10-31 7:51 ` Chao Yu
2017-10-31 9:11 ` Sheng Yong
2017-10-31 10:46 ` Chao Yu
2017-10-31 1:38 ` [RFC PATCH 5/8] dump.f2fs: do not dump encrypted files Sheng Yong
2017-10-31 7:57 ` Chao Yu
2017-10-31 9:16 ` Sheng Yong
2017-10-31 11:09 ` Chao Yu
2017-10-31 1:38 ` [RFC PATCH 6/8] fsck.f2fs: introduce new option --dry-run Sheng Yong
2017-10-31 7:57 ` Chao Yu
2017-10-31 9:19 ` Sheng Yong
2017-10-31 11:10 ` Chao Yu
2017-10-31 1:38 ` [RFC PATCH 7/8] fsck.f2fs: introduce sanity_check_inode Sheng Yong
2017-10-31 8:04 ` Chao Yu
2017-10-31 9:21 ` Sheng Yong [this message]
2017-10-31 1:38 ` [RFC PATCH 8/8] f2fs-tools: remove unused list.h Sheng Yong
2017-10-31 8:05 ` Chao Yu
2017-10-31 7:06 ` [RFC PATCH 1/8] fsck.f2fs: do not set fix_on directly Chao Yu
2017-10-31 9:34 ` Sheng Yong
2017-10-31 11:12 ` Chao Yu
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=93bd4aa0-f81d-14ba-b5db-c051be4d9f8c@huawei.com \
--to=shengyong1@huawei.com \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=yuchao0@huawei.com \
/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).