* [PATCH 1/4] mkfs.f2fs: avoid build warning
@ 2014-10-16 3:59 Jaegeuk Kim
2014-10-16 3:59 ` [PATCH 2/4] fsck.f2fs: fix superblock offset Jaegeuk Kim
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Jaegeuk Kim @ 2014-10-16 3:59 UTC (permalink / raw)
To: linux-f2fs-devel; +Cc: Jaegeuk Kim
Avoid build warning for printf.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
mkfs/f2fs_format_main.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c
index 19c52e4..e1f7c69 100644
--- a/mkfs/f2fs_format_main.c
+++ b/mkfs/f2fs_format_main.c
@@ -103,7 +103,8 @@ static void f2fs_parse_options(int argc, char *argv[])
if ((optind + 1) < argc) {
/* We have a sector count. */
config.total_sectors = atoll(argv[optind+1]);
- MSG(0, "\ttotal_sectors=%lu (%s bytes)\n", config.total_sectors, argv[optind+1]);
+ MSG(0, "\ttotal_sectors=%08"PRIx64" (%s bytes)\n",
+ config.total_sectors, argv[optind+1]);
}
config.reserved_segments =
--
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/4] fsck.f2fs: fix superblock offset
2014-10-16 3:59 [PATCH 1/4] mkfs.f2fs: avoid build warning Jaegeuk Kim
@ 2014-10-16 3:59 ` Jaegeuk Kim
2014-10-16 3:59 ` [PATCH 3/4] fsck.f2fs: support inline_dentry Jaegeuk Kim
2014-10-16 3:59 ` [PATCH 4/4] fsck.f2fs: fix wrong hash_code made by previous buggy code Jaegeuk Kim
2 siblings, 0 replies; 4+ messages in thread
From: Jaegeuk Kim @ 2014-10-16 3:59 UTC (permalink / raw)
To: linux-f2fs-devel; +Cc: Jaegeuk Kim
The second offset should be F2FS_BLKSIZE + F2FS_SUPER_OFFSET.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fsck/mount.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/fsck/mount.c b/fsck/mount.c
index 415f977..8b39d37 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -223,9 +223,14 @@ int sanity_check_raw_super(struct f2fs_super_block *raw_super)
int validate_super_block(struct f2fs_sb_info *sbi, int block)
{
- u64 offset = (block + 1) * F2FS_SUPER_OFFSET;
+ u64 offset;
sbi->raw_super = malloc(sizeof(struct f2fs_super_block));
+ if (block == 0)
+ offset = F2FS_SUPER_OFFSET;
+ else
+ offset = F2FS_BLKSIZE + F2FS_SUPER_OFFSET;
+
if (dev_read(sbi->raw_super, offset, sizeof(struct f2fs_super_block)))
return -1;
--
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/4] fsck.f2fs: support inline_dentry
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 ` Jaegeuk Kim
2014-10-16 3:59 ` [PATCH 4/4] fsck.f2fs: fix wrong hash_code made by previous buggy code Jaegeuk Kim
2 siblings, 0 replies; 4+ messages in thread
From: Jaegeuk Kim @ 2014-10-16 3:59 UTC (permalink / raw)
To: linux-f2fs-devel; +Cc: Jaegeuk Kim
This patch implements inline_dentry feature.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fsck/f2fs.h | 5 +++
fsck/fsck.c | 123 ++++++++++++++++++++++++++++++++++++------------------
fsck/fsck.h | 2 +
include/f2fs_fs.h | 20 +++++++++
4 files changed, 109 insertions(+), 41 deletions(-)
diff --git a/fsck/f2fs.h b/fsck/f2fs.h
index cdd61b8..47f785d 100644
--- a/fsck/f2fs.h
+++ b/fsck/f2fs.h
@@ -191,6 +191,11 @@ static inline struct sit_info *SIT_I(struct f2fs_sb_info *sbi)
return (struct sit_info *)(SM_I(sbi)->sit_info);
}
+static inline void *inline_data_addr(struct f2fs_node *node_blk)
+{
+ return (void *)&(node_blk->i.i_addr[1]);
+}
+
static inline unsigned long __bitmap_size(struct f2fs_sb_info *sbi, int flag)
{
struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
diff --git a/fsck/fsck.c b/fsck/fsck.c
index d0819c4..8e3ecc8 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -397,6 +397,12 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
DBG(3, "ino[0x%x] has inline data!\n", nid);
goto check;
}
+ if((node_blk->i.i_inline & F2FS_INLINE_DENTRY)){
+ DBG(3, "ino[0x%x] has inline dentry!\n", nid);
+ ret = fsck_chk_inline_dentries(sbi, node_blk,
+ &child_cnt, &child_files);
+ goto check;
+ }
/* check data blocks in inode */
for (idx = 0; idx < ADDRS_PER_INODE(&node_blk->i); idx++) {
@@ -546,7 +552,9 @@ int fsck_chk_didnode_blk(struct f2fs_sb_info *sbi, struct f2fs_inode *inode,
}
static void print_dentry(__u32 depth, __u8 *name,
- struct f2fs_dentry_block *de_blk, int idx, int last_blk)
+ unsigned long *bitmap,
+ struct f2fs_dir_entry *dentry,
+ int max, int idx, int last_blk)
{
int last_de = 0;
int next_idx = 0;
@@ -557,12 +565,11 @@ static void print_dentry(__u32 depth, __u8 *name,
if (config.dbg_lv != -1)
return;
- name_len = le16_to_cpu(de_blk->dentry[idx].name_len);
+ name_len = le16_to_cpu(dentry[idx].name_len);
next_idx = idx + (name_len + F2FS_SLOT_LEN - 1) / F2FS_SLOT_LEN;
- bit_offset = find_next_bit((unsigned long *)de_blk->dentry_bitmap,
- NR_DENTRY_IN_BLOCK, next_idx);
- if (bit_offset >= NR_DENTRY_IN_BLOCK && last_blk)
+ bit_offset = find_next_bit(bitmap, max, next_idx);
+ if (bit_offset >= max && last_blk)
last_de = 1;
if (tree_mark_size <= depth) {
@@ -582,47 +589,41 @@ static void print_dentry(__u32 depth, __u8 *name,
for (i = 1; i < depth; i++)
printf("%c ", tree_mark[i]);
printf("%c-- %s 0x%x\n", last_de ? '`' : '|',
- name, le32_to_cpu(de_blk->dentry[idx].ino));
+ name, le32_to_cpu(dentry[idx].ino));
}
-int fsck_chk_dentry_blk(struct f2fs_sb_info *sbi, u32 blk_addr,
- u32 *child_cnt, u32 *child_files, int last_blk)
+static int __chk_dentries(struct f2fs_sb_info *sbi, u32 *child_cnt,
+ u32* child_files,
+ unsigned long *bitmap,
+ struct f2fs_dir_entry *dentry,
+ __u8 (*filenames)[F2FS_SLOT_LEN],
+ int max, int last_blk)
{
struct f2fs_fsck *fsck = F2FS_FSCK(sbi);
- int i;
- int ret = 0;
+ enum FILE_TYPE ftype;
int dentries = 0;
+ u32 blk_cnt;
u8 *name;
u32 hash_code;
- u32 blk_cnt;
u16 name_len;;
+ int ret = 0;
+ int i;
- enum FILE_TYPE ftype;
- struct f2fs_dentry_block *de_blk;
-
- de_blk = (struct f2fs_dentry_block *)calloc(BLOCK_SZ, 1);
- ASSERT(de_blk != NULL);
-
- ret = dev_read_block(de_blk, blk_addr);
- ASSERT(ret >= 0);
-
- fsck->dentry_depth++;
-
- for (i = 0; i < NR_DENTRY_IN_BLOCK;) {
- if (test_bit(i, (unsigned long *)de_blk->dentry_bitmap) == 0) {
+ for (i = 0; i < max;) {
+ if (test_bit(i, bitmap) == 0) {
i++;
continue;
}
- name_len = le16_to_cpu(de_blk->dentry[i].name_len);
+ name_len = le16_to_cpu(dentry[i].name_len);
name = calloc(name_len + 1, 1);
- memcpy(name, de_blk->filename[i], name_len);
+ memcpy(name, filenames[i], name_len);
hash_code = f2fs_dentry_hash((const unsigned char *)name,
name_len);
- ASSERT(le32_to_cpu(de_blk->dentry[i].hash_code) == hash_code);
+ ASSERT(le32_to_cpu(dentry[i].hash_code) == hash_code);
- ftype = de_blk->dentry[i].file_type;
+ ftype = dentry[i].file_type;
/* Becareful. 'dentry.file_type' is not imode. */
if (ftype == F2FS_FT_DIR) {
@@ -638,30 +639,27 @@ int fsck_chk_dentry_blk(struct f2fs_sb_info *sbi, u32 blk_addr,
DBG(1, "[%3u]-[0x%x] name[%s] len[0x%x] ino[0x%x] type[0x%x]\n",
fsck->dentry_depth, i, name, name_len,
- le32_to_cpu(de_blk->dentry[i].ino),
- de_blk->dentry[i].file_type);
+ le32_to_cpu(dentry[i].ino),
+ dentry[i].file_type);
- print_dentry(fsck->dentry_depth, name, de_blk, i, last_blk);
+ print_dentry(fsck->dentry_depth, name, bitmap,
+ dentry, max, i, 1);
blk_cnt = 1;
ret = fsck_chk_node_blk(sbi,
- NULL,
- le32_to_cpu(de_blk->dentry[i].ino),
- ftype,
- TYPE_INODE,
- &blk_cnt);
+ NULL, le32_to_cpu(dentry[i].ino),
+ ftype, TYPE_INODE, &blk_cnt);
if (ret && config.fix_on) {
int j;
int slots = (name_len + F2FS_SLOT_LEN - 1) /
F2FS_SLOT_LEN;
for (j = 0; j < slots; j++)
- clear_bit(i + j,
- (unsigned long *)de_blk->dentry_bitmap);
+ clear_bit(i + j, bitmap);
FIX_MSG("Unlink [0x%x] - %s len[0x%x], type[0x%x]",
- le32_to_cpu(de_blk->dentry[i].ino),
+ le32_to_cpu(dentry[i].ino),
name, name_len,
- de_blk->dentry[i].file_type);
+ dentry[i].file_type);
i += slots;
free(name);
continue;
@@ -672,13 +670,56 @@ int fsck_chk_dentry_blk(struct f2fs_sb_info *sbi, u32 blk_addr,
*child_files = *child_files + 1;
free(name);
}
+ return dentries;
+}
+
+int fsck_chk_inline_dentries(struct f2fs_sb_info *sbi,
+ struct f2fs_node *node_blk, u32 *child_cnt, u32 *child_files)
+{
+ struct f2fs_fsck *fsck = F2FS_FSCK(sbi);
+ struct f2fs_inline_dentry *de_blk;
+ int dentries;
+
+ de_blk = inline_data_addr(node_blk);
+ ASSERT(de_blk != NULL);
+
+ fsck->dentry_depth++;
+ dentries = __chk_dentries(sbi, child_cnt, child_files,
+ (unsigned long *)de_blk->dentry_bitmap,
+ de_blk->dentry, de_blk->filename,
+ NR_INLINE_DENTRY, 1);
+ 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;
+}
+
+int fsck_chk_dentry_blk(struct f2fs_sb_info *sbi, u32 blk_addr,
+ u32 *child_cnt, u32 *child_files, int last_blk)
+{
+ struct f2fs_fsck *fsck = F2FS_FSCK(sbi);
+ struct f2fs_dentry_block *de_blk;
+ int dentries, ret;
+
+ de_blk = (struct f2fs_dentry_block *)calloc(BLOCK_SZ, 1);
+ ASSERT(de_blk != NULL);
+
+ ret = dev_read_block(de_blk, blk_addr);
+ ASSERT(ret >= 0);
+
+ fsck->dentry_depth++;
+ dentries = __chk_dentries(sbi, child_cnt, child_files,
+ (unsigned long *)de_blk->dentry_bitmap,
+ de_blk->dentry, de_blk->filename,
+ NR_DENTRY_IN_BLOCK, last_blk);
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;
}
diff --git a/fsck/fsck.h b/fsck/fsck.h
index 64b9984..49d6d1d 100644
--- a/fsck/fsck.h
+++ b/fsck/fsck.h
@@ -93,6 +93,8 @@ extern int fsck_chk_didnode_blk(struct f2fs_sb_info *, struct f2fs_inode *,
extern int fsck_chk_data_blk(struct f2fs_sb_info *sbi, u32, u32 *, u32 *,
int, enum FILE_TYPE, u32, u16, u8);
extern int fsck_chk_dentry_blk(struct f2fs_sb_info *, u32, u32 *, u32 *, int);
+int fsck_chk_inline_dentries(struct f2fs_sb_info *, struct f2fs_node *,
+ u32 *, u32 *);
extern void print_node_info(struct f2fs_node *);
extern void print_inode_info(struct f2fs_inode *);
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index df37cdf..ed4abb1 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -425,6 +425,8 @@ struct f2fs_extent {
#define F2FS_INLINE_XATTR 0x01 /* file inline xattr flag */
#define F2FS_INLINE_DATA 0x02 /* file inline data flag */
+#define F2FS_INLINE_DENTRY 0x04 /* file inline dentry flag */
+
#define MAX_INLINE_DATA (sizeof(__le32) * (DEF_ADDRS_PER_INODE - \
F2FS_INLINE_XATTR_ADDRS - 1))
@@ -697,6 +699,24 @@ struct f2fs_dentry_block {
__u8 filename[NR_DENTRY_IN_BLOCK][F2FS_SLOT_LEN];
} __attribute__((packed));
+/* for inline dir */
+#define NR_INLINE_DENTRY (MAX_INLINE_DATA * BITS_PER_BYTE / \
+ ((SIZE_OF_DIR_ENTRY + F2FS_SLOT_LEN) * \
+ BITS_PER_BYTE + 1))
+#define INLINE_DENTRY_BITMAP_SIZE ((NR_INLINE_DENTRY + \
+ BITS_PER_BYTE - 1) / BITS_PER_BYTE)
+#define INLINE_RESERVED_SIZE (MAX_INLINE_DATA - \
+ ((SIZE_OF_DIR_ENTRY + F2FS_SLOT_LEN) * \
+ NR_INLINE_DENTRY + INLINE_DENTRY_BITMAP_SIZE))
+
+/* inline directory entry structure */
+struct f2fs_inline_dentry {
+ __u8 dentry_bitmap[INLINE_DENTRY_BITMAP_SIZE];
+ __u8 reserved[INLINE_RESERVED_SIZE];
+ struct f2fs_dir_entry dentry[NR_INLINE_DENTRY];
+ __u8 filename[NR_INLINE_DENTRY][F2FS_SLOT_LEN];
+} __packed;
+
/* file types used in inode_info->flags */
enum FILE_TYPE {
F2FS_FT_UNKNOWN,
--
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 4/4] fsck.f2fs: fix wrong hash_code made by previous buggy code
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
2 siblings, 0 replies; 4+ messages in thread
From: Jaegeuk Kim @ 2014-10-16 3:59 UTC (permalink / raw)
To: linux-f2fs-devel; +Cc: Jaegeuk Kim
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-10-16 3:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 4/4] fsck.f2fs: fix wrong hash_code made by previous buggy code Jaegeuk Kim
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).