Skip to content

Commit

Permalink
fsck.f2fs: Add progression feedback
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
aviallon authored and Jaegeuk Kim committed Jan 5, 2022
1 parent a096511 commit 45b3c75
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions fsck/fsck.c
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions fsck/fsck.h
Expand Up @@ -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;
Expand Down

0 comments on commit 45b3c75

Please sign in to comment.