All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] fsck.f2fs: fix sit types seamlessly
@ 2015-01-23  0:48 Jaegeuk Kim
  2015-01-23  0:48 ` [PATCH 2/3] dump.f2fs: show checkpoint flag Jaegeuk Kim
  2015-01-23  0:48 ` [PATCH 3/3] fsck.f2fs: readahead node blocks to speed up Jaegeuk Kim
  0 siblings, 2 replies; 4+ messages in thread
From: Jaegeuk Kim @ 2015-01-23  0:48 UTC (permalink / raw)
  To: linux-f2fs-devel; +Cc: Jaegeuk Kim

SIT types can be wrong when active_logs are 2 or 4.
So, let's fix this implicitly.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fsck/fsck.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/fsck/fsck.c b/fsck/fsck.c
index 09bb26f..a5f9adc 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -1023,6 +1023,7 @@ int fsck_verify(struct f2fs_sb_info *sbi)
 {
 	unsigned int i = 0;
 	int ret = 0;
+	int force = 0;
 	u32 nr_unref_nid = 0;
 	struct f2fs_fsck *fsck = F2FS_FSCK(sbi);
 	struct hard_link_node *node = NULL;
@@ -1129,14 +1130,9 @@ int fsck_verify(struct f2fs_sb_info *sbi)
 		config.bug_on = 1;
 	}
 
-	printf("[FSCK] SIT types                                     ");
-	if (check_sit_types(sbi) == 0) {
-		printf(" [Ok..]\n");
-	} else {
-		printf(" [Fail]\n");
-		ret = EXIT_ERR_CODE;
-		config.bug_on = 1;
-	}
+	printf("[FSCK] fixing SIT types\n");
+	if (check_sit_types(sbi) != 0)
+		force = 1;
 
 	printf("[FSCK] other corrupted bugs                          ");
 	if (config.bug_on == 0) {
@@ -1147,7 +1143,7 @@ int fsck_verify(struct f2fs_sb_info *sbi)
 	}
 
 	/* fix global metadata */
-	if (config.bug_on && config.fix_on) {
+	if (force || (config.bug_on && config.fix_on)) {
 		fix_nat_entries(sbi);
 		rewrite_sit_area_bitmap(sbi);
 		fix_checkpoint(sbi);
-- 
2.1.1


------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] dump.f2fs: show checkpoint flag
  2015-01-23  0:48 [PATCH 1/3] fsck.f2fs: fix sit types seamlessly Jaegeuk Kim
@ 2015-01-23  0:48 ` Jaegeuk Kim
  2015-01-29 21:43   ` [PATCH 2/3 v2] " Jaegeuk Kim
  2015-01-23  0:48 ` [PATCH 3/3] fsck.f2fs: readahead node blocks to speed up Jaegeuk Kim
  1 sibling, 1 reply; 4+ messages in thread
From: Jaegeuk Kim @ 2015-01-23  0:48 UTC (permalink / raw)
  To: linux-f2fs-devel; +Cc: Jaegeuk Kim

This patch is to show the checkpoint flag.
With this flag, we can guess the last status of the partition.
And, this can be used by xfstests.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fsck/main.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/fsck/main.c b/fsck/main.c
index e05e528..812d196 100644
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -157,6 +157,8 @@ static void do_fsck(struct f2fs_sb_info *sbi)
 static void do_dump(struct f2fs_sb_info *sbi)
 {
 	struct dump_option *opt = (struct dump_option *)config.private;
+	struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
+	u32 flag = le32_to_cpu(ckpt->ckpt_flags);
 
 	fsck_init(sbi);
 
@@ -172,6 +174,22 @@ static void do_dump(struct f2fs_sb_info *sbi)
 		dump_info_from_blkaddr(sbi, opt->blk_addr);
 		goto cleanup;
 	}
+
+	MSG(0, "Info: checkpoint state = %x : ", flag);
+	if (flag & CP_FSCK_FLAG)
+		MSG(0, "%s", " fsck");
+	if (flag & CP_ERROR_FLAG)
+		MSG(0, "%s", " error");
+	if (flag & CP_COMPACT_SUM_FLAG)
+		MSG(0, "%s", " compacted_summary");
+	if (flag & CP_ORPHAN_PRESENT_FLAG)
+		MSG(0, "%s", " orphan_inodes");
+	if (flag & CP_UMOUNT_FLAG)
+		MSG(0, "%s", " unmount");
+	else
+		MSG(0, "%s", " sudden-power-off");
+	MSG(0, "\n");
+
 	dump_node(sbi, opt->nid);
 cleanup:
 	fsck_free(sbi);
-- 
2.1.1


------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] fsck.f2fs: readahead node blocks to speed up
  2015-01-23  0:48 [PATCH 1/3] fsck.f2fs: fix sit types seamlessly Jaegeuk Kim
  2015-01-23  0:48 ` [PATCH 2/3] dump.f2fs: show checkpoint flag Jaegeuk Kim
@ 2015-01-23  0:48 ` Jaegeuk Kim
  1 sibling, 0 replies; 4+ messages in thread
From: Jaegeuk Kim @ 2015-01-23  0:48 UTC (permalink / raw)
  To: linux-f2fs-devel; +Cc: Jaegeuk Kim

This patch adds readahead system call to speed up node block reads.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fsck/fsck.c       | 34 +++++++++++++++++++++++++++++++++-
 include/f2fs_fs.h |  1 +
 lib/libf2fs_io.c  | 14 ++++++++++++++
 3 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/fsck/fsck.c b/fsck/fsck.c
index a5f9adc..9d6fc42 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -451,6 +451,19 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
 		goto check;
 	}
 
+	/* readahead node blocks */
+	for (idx = 0; idx < 5; idx++) {
+		u32 nid = le32_to_cpu(node_blk->i.i_nid[idx]);
+
+		if (nid != 0) {
+			struct node_info ni;
+
+			get_node_info(sbi, nid, &ni);
+			if (IS_VALID_BLK_ADDR(sbi, ni.blk_addr))
+				dev_reada_block(ni.blk_addr);
+		}
+	}
+
 	/* check data blocks in inode */
 	for (idx = 0; idx < ADDRS_PER_INODE(&node_blk->i); idx++) {
 		if (le32_to_cpu(node_blk->i.i_addr[idx]) != 0) {
@@ -651,12 +664,31 @@ static int __chk_dentries(struct f2fs_sb_info *sbi, u32 *child_cnt,
 	int dentries = 0;
 	u32 blk_cnt;
 	u8 *name;
-	u32 hash_code;
+	u32 hash_code, ino;
 	u16 name_len;;
 	int ret = 0;
 	int fixed = 0;
 	int i;
 
+	/* readahead inode blocks */
+	for (i = 0; i < max;) {
+		if (test_bit(i, bitmap) == 0) {
+			i++;
+			continue;
+		}
+		ino = le32_to_cpu(dentry[i].ino);
+
+		if (IS_VALID_NID(sbi, ino)) {
+			struct node_info ni;
+
+			get_node_info(sbi, ino, &ni);
+			if (IS_VALID_BLK_ADDR(sbi, ni.blk_addr))
+				dev_reada_block(ni.blk_addr);
+		}
+		name_len = le16_to_cpu(dentry[i].name_len);
+		i += (name_len + F2FS_SLOT_LEN - 1) / F2FS_SLOT_LEN;
+	}
+
 	for (i = 0; i < max;) {
 		if (test_bit(i, bitmap) == 0) {
 			i++;
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 4dc2426..8a9221c 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -780,6 +780,7 @@ extern int dev_fill(void *, __u64, size_t);
 
 extern int dev_read_block(void *, __u64);
 extern int dev_read_blocks(void *, __u64, __u32 );
+extern int dev_reada_block(__u64);
 
 extern int dev_read_version(void *, __u64, size_t);
 extern void get_kernel_version(__u8 *);
diff --git a/lib/libf2fs_io.c b/lib/libf2fs_io.c
index 6ed45fd..afa345f 100644
--- a/lib/libf2fs_io.c
+++ b/lib/libf2fs_io.c
@@ -46,6 +46,15 @@ int dev_read(void *buf, __u64 offset, size_t len)
 	return 0;
 }
 
+int dev_readahead(__u64 offset, size_t len)
+{
+#ifdef POSIX_FADV_WILLNEED
+	return posix_fadvise(config.fd, offset, len, POSIX_FADV_WILLNEED);
+#else
+	return 0;
+#endif
+}
+
 int dev_write(void *buf, __u64 offset, size_t len)
 {
 	if (lseek64(config.fd, (off64_t)offset, SEEK_SET) < 0)
@@ -91,6 +100,11 @@ int dev_read_blocks(void *buf, __u64 addr, __u32 nr_blks)
 	return dev_read(buf, addr * F2FS_BLKSIZE, nr_blks * F2FS_BLKSIZE);
 }
 
+int dev_reada_block(__u64 blk_addr)
+{
+	return dev_readahead(blk_addr * F2FS_BLKSIZE, F2FS_BLKSIZE);
+}
+
 void f2fs_finalize_device(struct f2fs_configuration *c)
 {
 	/*
-- 
2.1.1


------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/3 v2] dump.f2fs: show checkpoint flag
  2015-01-23  0:48 ` [PATCH 2/3] dump.f2fs: show checkpoint flag Jaegeuk Kim
@ 2015-01-29 21:43   ` Jaegeuk Kim
  0 siblings, 0 replies; 4+ messages in thread
From: Jaegeuk Kim @ 2015-01-29 21:43 UTC (permalink / raw)
  To: linux-f2fs-devel

Change log from v1:
 o add FASTBOOT_FLAG

>From b57708aecf07a7caa8fcce02f65735a11e987154 Mon Sep 17 00:00:00 2001
From: Jaegeuk Kim <jaegeuk@kernel.org>
Date: Wed, 14 Jan 2015 16:18:15 -0800
Subject: [PATCH] dump.f2fs: show checkpoint flag

This patch is to show the checkpoint flag.
With this flag, we can guess the last status of the partition.
And, this can be used by xfstests.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fsck/main.c       | 20 ++++++++++++++++++++
 include/f2fs_fs.h |  1 +
 2 files changed, 21 insertions(+)

diff --git a/fsck/main.c b/fsck/main.c
index e05e528..3606f62 100644
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -157,6 +157,8 @@ static void do_fsck(struct f2fs_sb_info *sbi)
 static void do_dump(struct f2fs_sb_info *sbi)
 {
 	struct dump_option *opt = (struct dump_option *)config.private;
+	struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
+	u32 flag = le32_to_cpu(ckpt->ckpt_flags);
 
 	fsck_init(sbi);
 
@@ -172,6 +174,24 @@ static void do_dump(struct f2fs_sb_info *sbi)
 		dump_info_from_blkaddr(sbi, opt->blk_addr);
 		goto cleanup;
 	}
+
+	MSG(0, "Info: checkpoint state = %x : ", flag);
+	if (flag & CP_FSCK_FLAG)
+		MSG(0, "%s", " fsck");
+	if (flag & CP_ERROR_FLAG)
+		MSG(0, "%s", " error");
+	if (flag & CP_COMPACT_SUM_FLAG)
+		MSG(0, "%s", " compacted_summary");
+	if (flag & CP_ORPHAN_PRESENT_FLAG)
+		MSG(0, "%s", " orphan_inodes");
+	if (flag & CP_FASTBOOT_FLAG)
+		MSG(0, "%s", " fastboot");
+	if (flag & CP_UMOUNT_FLAG)
+		MSG(0, "%s", " unmount");
+	else
+		MSG(0, "%s", " sudden-power-off");
+	MSG(0, "\n");
+
 	dump_node(sbi, opt->nid);
 cleanup:
 	fsck_free(sbi);
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 4dc2426..d062b7f 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -358,6 +358,7 @@ struct f2fs_super_block {
 /*
  * For checkpoint
  */
+#define CP_FASTBOOT_FLAG	0x00000020
 #define CP_FSCK_FLAG		0x00000010
 #define CP_ERROR_FLAG		0x00000008
 #define CP_COMPACT_SUM_FLAG	0x00000004
-- 
2.1.1


------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-01-29 21:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-23  0:48 [PATCH 1/3] fsck.f2fs: fix sit types seamlessly Jaegeuk Kim
2015-01-23  0:48 ` [PATCH 2/3] dump.f2fs: show checkpoint flag Jaegeuk Kim
2015-01-29 21:43   ` [PATCH 2/3 v2] " Jaegeuk Kim
2015-01-23  0:48 ` [PATCH 3/3] fsck.f2fs: readahead node blocks to speed up Jaegeuk Kim

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.