diff options
author | Antoine Viallon <antoine@lesviallon.fr> | 2021-12-30 01:29:42 +0100 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2022-01-11 19:04:50 -0800 |
commit | 028af9f6067c1345023af9cd8ecbb76a770241ae (patch) | |
tree | 35f083fd7c447e89859a7b78dc0fb212979b4de0 | |
parent | 972d71073af32a1854aeece018746a9f8021dd14 (diff) | |
download | f2fs-tools-028af9f6067c1345023af9cd8ecbb76a770241ae.tar.gz |
fsck.f2fs: Add progression feedback
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>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r-- | fsck/fsck.c | 15 | ||||
-rw-r--r-- | fsck/fsck.h | 1 |
2 files changed, 16 insertions, 0 deletions
diff --git a/fsck/fsck.c b/fsck/fsck.c index ecd87af..ddcede3 100644 --- a/fsck/fsck.c +++ b/fsck/fsck.c @@ -493,8 +493,23 @@ static int sanity_check_nid(struct f2fs_sb_info *sbi, u32 nid, ni->blk_addr); if (f2fs_test_main_bitmap(sbi, ni->blk_addr) == 0) { + fsck->chk.valid_blk_cnt++; fsck->chk.valid_node_cnt++; + + /* Progress report */ + if (sbi->total_valid_node_count > 1000) { + unsigned int p10 = sbi->total_valid_node_count / 10; + + if (sbi->fsck->chk.checked_node_cnt++ % p10) + return 0; + + printf("[FSCK] Check node %"PRIu64" / %u (%.2f%%)\n", + sbi->fsck->chk.checked_node_cnt, + sbi->total_valid_node_count, + 10 * (float)sbi->fsck->chk.checked_node_cnt / + p10); + } } return 0; } diff --git a/fsck/fsck.h b/fsck/fsck.h index 11846e1..ce5fffe 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_node_cnt; u64 valid_blk_cnt; u32 valid_nat_entry_cnt; u32 valid_node_cnt; |