From: Jaegeuk Kim <jaegeuk@kernel.org>
To: linux-f2fs-devel@lists.sourceforge.net
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Subject: [PATCH 4/4] fsck.f2fs: fix wrong hash_code made by previous buggy code
Date: Wed, 15 Oct 2014 20:59:11 -0700 [thread overview]
Message-ID: <1413431951-27137-4-git-send-email-jaegeuk@kernel.org> (raw)
In-Reply-To: <1413431951-27137-1-git-send-email-jaegeuk@kernel.org>
The previous f2fs remained wrong hash_code for international characters.
So, fsck.f2fs should fix that hash_code with current valid names.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fsck/fsck.c | 32 +++++++++++++++++++++++++++-----
1 file changed, 27 insertions(+), 5 deletions(-)
diff --git a/fsck/fsck.c b/fsck/fsck.c
index 8e3ecc8..9997d0c 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -401,6 +401,10 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
DBG(3, "ino[0x%x] has inline dentry!\n", nid);
ret = fsck_chk_inline_dentries(sbi, node_blk,
&child_cnt, &child_files);
+ if (ret < 0) {
+ /* should fix this bug all the time */
+ need_fix = 1;
+ }
goto check;
}
@@ -607,6 +611,7 @@ static int __chk_dentries(struct f2fs_sb_info *sbi, u32 *child_cnt,
u32 hash_code;
u16 name_len;;
int ret = 0;
+ int fixed = 0;
int i;
for (i = 0; i < max;) {
@@ -621,7 +626,12 @@ static int __chk_dentries(struct f2fs_sb_info *sbi, u32 *child_cnt,
hash_code = f2fs_dentry_hash((const unsigned char *)name,
name_len);
- ASSERT(le32_to_cpu(dentry[i].hash_code) == hash_code);
+ /* fix hash_code made by old buggy code */
+ if (le32_to_cpu(dentry[i].hash_code) != hash_code) {
+ dentry[i].hash_code = hash_code;
+ fixed = 1;
+ FIX_MSG("hash_code[%d] of %s", i, name);
+ }
ftype = dentry[i].file_type;
@@ -670,7 +680,7 @@ static int __chk_dentries(struct f2fs_sb_info *sbi, u32 *child_cnt,
*child_files = *child_files + 1;
free(name);
}
- return dentries;
+ return fixed ? -1 : dentries;
}
int fsck_chk_inline_dentries(struct f2fs_sb_info *sbi,
@@ -688,12 +698,17 @@ int fsck_chk_inline_dentries(struct f2fs_sb_info *sbi,
(unsigned long *)de_blk->dentry_bitmap,
de_blk->dentry, de_blk->filename,
NR_INLINE_DENTRY, 1);
- DBG(1, "[%3d] Inline Dentry Block Done : "
+ if (dentries < 0) {
+ DBG(1, "[%3d] Inline Dentry Block Fixed hash_codes\n\n",
+ fsck->dentry_depth);
+ } else {
+ DBG(1, "[%3d] Inline Dentry Block Done : "
"dentries:%d in %d slots (len:%d)\n\n",
fsck->dentry_depth, dentries,
(int)NR_INLINE_DENTRY, F2FS_NAME_LEN);
+ }
fsck->dentry_depth--;
- return 0;
+ return dentries;
}
int fsck_chk_dentry_blk(struct f2fs_sb_info *sbi, u32 blk_addr,
@@ -715,10 +730,17 @@ int fsck_chk_dentry_blk(struct f2fs_sb_info *sbi, u32 blk_addr,
de_blk->dentry, de_blk->filename,
NR_DENTRY_IN_BLOCK, last_blk);
- DBG(1, "[%3d] Dentry Block [0x%x] Done : "
+ if (dentries < 0) {
+ ret = dev_write_block(de_blk, blk_addr);
+ ASSERT(ret >= 0);
+ DBG(1, "[%3d] Dentry Block [0x%x] Fixed hash_codes\n\n",
+ fsck->dentry_depth, blk_addr);
+ } else {
+ DBG(1, "[%3d] Dentry Block [0x%x] Done : "
"dentries:%d in %d slots (len:%d)\n\n",
fsck->dentry_depth, blk_addr, dentries,
NR_DENTRY_IN_BLOCK, F2FS_NAME_LEN);
+ }
fsck->dentry_depth--;
free(de_blk);
return 0;
--
2.1.1
------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
prev parent reply other threads:[~2014-10-16 3:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-16 3:59 [PATCH 1/4] mkfs.f2fs: avoid build warning Jaegeuk Kim
2014-10-16 3:59 ` [PATCH 2/4] fsck.f2fs: fix superblock offset Jaegeuk Kim
2014-10-16 3:59 ` [PATCH 3/4] fsck.f2fs: support inline_dentry Jaegeuk Kim
2014-10-16 3:59 ` Jaegeuk Kim [this message]
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=1413431951-27137-4-git-send-email-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).