All of lore.kernel.org
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH] fsck.f2fs: Add progression feedback
@ 2021-12-30  0:25 Antoine Viallon via Linux-f2fs-devel
  0 siblings, 0 replies; 9+ messages in thread
From: Antoine Viallon via Linux-f2fs-devel @ 2021-12-30  0:25 UTC (permalink / raw)
  To: linux-f2fs-devel, antoine

On large SSDs filled with lots of data, fsck.f2fs can be very long to finish.
For instance, on my 1TB SSD filled at 99%, it takes literally 5 minutes to
complete.

Currently, the only way to have some feedback is to enable debug output,
but it is very verbose and doesn't tell the actual progress.

This patch implements a simple progress report in the longest
running part of the check (in fsck_chk_node_blk).
The number of checked node / total valid nodes is printed
every 1000 nodes checked, and the percentage of progress
is also calculated and printed.


Signed-off-by: Antoine Viallon <antoine@lesviallon.fr>
---
 fsck/fsck.c | 9 +++++++++
 fsck/fsck.h | 1 +
 2 files changed, 10 insertions(+)

diff --git a/fsck/fsck.c b/fsck/fsck.c
index ecd87af..7a64339 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -546,6 +546,15 @@ int fsck_chk_node_blk(struct f2fs_sb_info *sbi, struct f2fs_inode *inode,
 	node_blk = (struct f2fs_node *)calloc(BLOCK_SZ, 1);
 	ASSERT(node_blk != NULL);
 
+	/* Progress report */
+	sbi->fsck->chk.checked_blk_cnt++;
+
+	if (sbi->fsck->chk.checked_blk_cnt % 1000 == 0)
+		printf("[FSCK] Checked node %lu / %u (%.2f%%)\n",
+			   sbi->fsck->chk.checked_blk_cnt,
+			   sbi->total_valid_node_count,
+			   100 * (float)(sbi->fsck->chk.checked_blk_cnt) / sbi->total_valid_node_count);
+
 	if (sanity_check_nid(sbi, nid, node_blk, ftype, ntype, &ni))
 		goto err;
 
diff --git a/fsck/fsck.h b/fsck/fsck.h
index 11846e1..dd679b5 100644
--- a/fsck/fsck.h
+++ b/fsck/fsck.h
@@ -91,6 +91,7 @@ struct f2fs_fsck {
 
 	struct orphan_info orphani;
 	struct chk_result {
+		u64 checked_blk_cnt;
 		u64 valid_blk_cnt;
 		u32 valid_nat_entry_cnt;
 		u32 valid_node_cnt;
-- 
2.34.1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 9+ messages in thread
* [f2fs-dev] [PATCH] fsck.f2fs: Add progression feedback
@ 2021-12-30  0:29 Antoine Viallon via Linux-f2fs-devel
  2021-12-30  0:59 ` Antoine Viallon via Linux-f2fs-devel
  2022-01-06 11:40 ` Antoine Viallon via Linux-f2fs-devel
  0 siblings, 2 replies; 9+ messages in thread
From: Antoine Viallon via Linux-f2fs-devel @ 2021-12-30  0:29 UTC (permalink / raw)
  To: linux-f2fs-devel, antoine

On large SSDs filled with lots of data, fsck.f2fs can be very long to finish.
For instance, on my 1TB SSD filled at 99%, it takes literally 5 minutes to
complete.

Currently, the only way to have some feedback is to enable debug output,
but it is very verbose and doesn't tell the actual progress.

This patch implements a simple progress report in the longest
running part of the check (in fsck_chk_node_blk).
The number of checked node / total valid nodes is printed
every 1000 nodes checked, and the percentage of progress
is also calculated and printed.


Signed-off-by: Antoine Viallon <antoine@lesviallon.fr>
---
 fsck/fsck.c | 9 +++++++++
 fsck/fsck.h | 1 +
 2 files changed, 10 insertions(+)

diff --git a/fsck/fsck.c b/fsck/fsck.c
index ecd87af..7a64339 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -546,6 +546,15 @@ int fsck_chk_node_blk(struct f2fs_sb_info *sbi, struct f2fs_inode *inode,
 	node_blk = (struct f2fs_node *)calloc(BLOCK_SZ, 1);
 	ASSERT(node_blk != NULL);
 
+	/* Progress report */
+	sbi->fsck->chk.checked_blk_cnt++;
+
+	if (sbi->fsck->chk.checked_blk_cnt % 1000 == 0)
+		printf("[FSCK] Checked node %lu / %u (%.2f%%)\n",
+			   sbi->fsck->chk.checked_blk_cnt,
+			   sbi->total_valid_node_count,
+			   100 * (float)(sbi->fsck->chk.checked_blk_cnt) / sbi->total_valid_node_count);
+
 	if (sanity_check_nid(sbi, nid, node_blk, ftype, ntype, &ni))
 		goto err;
 
diff --git a/fsck/fsck.h b/fsck/fsck.h
index 11846e1..dd679b5 100644
--- a/fsck/fsck.h
+++ b/fsck/fsck.h
@@ -91,6 +91,7 @@ struct f2fs_fsck {
 
 	struct orphan_info orphani;
 	struct chk_result {
+		u64 checked_blk_cnt;
 		u64 valid_blk_cnt;
 		u32 valid_nat_entry_cnt;
 		u32 valid_node_cnt;
-- 
2.34.1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

end of thread, other threads:[~2022-01-06 19:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-30  0:25 [f2fs-dev] [PATCH] fsck.f2fs: Add progression feedback Antoine Viallon via Linux-f2fs-devel
2021-12-30  0:29 Antoine Viallon via Linux-f2fs-devel
2021-12-30  0:59 ` Antoine Viallon via Linux-f2fs-devel
2022-01-06 11:48   ` Chao Yu via Linux-f2fs-devel
2022-01-06 11:48   ` Chao Yu
2022-01-06 15:33   ` Antoine Viallon via Linux-f2fs-devel
2022-01-06 15:42     ` Chao Yu
2022-01-06 19:48       ` Jaegeuk Kim
2022-01-06 11:40 ` Antoine Viallon via Linux-f2fs-devel

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.