diff options
author | Theodore Ts'o <tytso@mit.edu> | 2008-12-08 21:33:11 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2008-12-08 21:33:11 -0500 |
commit | ce44d8cafa36e5c57f056be5b340d51c8ab819c6 (patch) | |
tree | 317556fe1abea99b5fcd308bb87e9c0cd86d7807 /e2fsck | |
parent | 42e89ce7f8823ad14099b03469c2f4e4f6530d05 (diff) | |
download | e2fsprogs-ce44d8cafa36e5c57f056be5b340d51c8ab819c6.tar.gz |
e2fsck: In verbose mode, distinguish between fragmented directories/files
Track the number of non-contiguous files and directories so we can
give more detailed information in verbose mode.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'e2fsck')
-rw-r--r-- | e2fsck/e2fsck.c | 1 | ||||
-rw-r--r-- | e2fsck/e2fsck.h | 1 | ||||
-rw-r--r-- | e2fsck/pass1.c | 16 | ||||
-rw-r--r-- | e2fsck/unix.c | 28 |
4 files changed, 35 insertions, 11 deletions
diff --git a/e2fsck/e2fsck.c b/e2fsck/e2fsck.c index bfa78fce..9f862ffa 100644 --- a/e2fsck/e2fsck.c +++ b/e2fsck/e2fsck.c @@ -152,6 +152,7 @@ errcode_t e2fsck_reset_context(e2fsck_t ctx) ctx->fs_dind_count = 0; ctx->fs_tind_count = 0; ctx->fs_fragmented = 0; + ctx->fs_fragmented_dir = 0; ctx->large_files = 0; for (i=0; i < MAX_EXTENT_DEPTH_COUNT; i++) diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h index e94b8716..9b916155 100644 --- a/e2fsck/e2fsck.h +++ b/e2fsck/e2fsck.h @@ -329,6 +329,7 @@ struct e2fsck_struct { __u32 fs_dind_count; __u32 fs_tind_count; __u32 fs_fragmented; + __u32 fs_fragmented_dir; __u32 large_files; __u32 fs_ext_attr_inodes; __u32 fs_ext_attr_blocks; diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index 3e1a94d0..cf46d88d 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -1772,8 +1772,12 @@ static void check_blocks_extents(e2fsck_t ctx, struct problem_context *pctx, scan_extent_node(ctx, pctx, pb, 0, ehandle); - if (pb->fragmented && pb->num_blocks < fs->super->s_blocks_per_group) - ctx->fs_fragmented++; + if (pb->fragmented && pb->num_blocks < fs->super->s_blocks_per_group) { + if (LINUX_S_ISDIR(inode->i_mode)) + ctx->fs_fragmented_dir++; + else + ctx->fs_fragmented++; + } ext2fs_extent_free(ehandle); } @@ -1847,8 +1851,12 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx, if (pctx->errcode) fix_problem(ctx, PR_1_BLOCK_ITERATE, pctx); - if (pb.fragmented && pb.num_blocks < fs->super->s_blocks_per_group) - ctx->fs_fragmented++; + if (pb.fragmented && pb.num_blocks < fs->super->s_blocks_per_group) { + if (LINUX_S_ISDIR(inode->i_mode)) + ctx->fs_fragmented_dir++; + else + ctx->fs_fragmented++; + } if (pb.clear) { e2fsck_clear_inode(ctx, ino, inode, E2F_FLAG_RESTART, diff --git a/e2fsck/unix.c b/e2fsck/unix.c index 64faebee..76baab7a 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -104,7 +104,7 @@ static void show_stats(e2fsck_t ctx) blk_t blocks, blocks_used; int dir_links; int num_files, num_links; - int frag_percent; + int frag_percent_file, frag_percent_dir, frag_percent_total; int i, j; dir_links = 2 * ctx->fs_directory_count - 1; @@ -117,22 +117,36 @@ static void show_stats(e2fsck_t ctx) blocks_used = (fs->super->s_blocks_count - fs->super->s_free_blocks_count); - frag_percent = (10000 * ctx->fs_fragmented) / inodes_used; - frag_percent = (frag_percent + 5) / 10; + frag_percent_file = (10000 * ctx->fs_fragmented) / inodes_used; + frag_percent_file = (frag_percent_file + 5) / 10; + + frag_percent_dir = (10000 * ctx->fs_fragmented_dir) / inodes_used; + frag_percent_dir = (frag_percent_dir + 5) / 10; + + frag_percent_total = ((10000 * (ctx->fs_fragmented + + ctx->fs_fragmented_dir)) + / inodes_used); + frag_percent_total = (frag_percent_total + 5) / 10; if (!verbose) { printf(_("%s: %u/%u files (%0d.%d%% non-contiguous), %u/%u blocks\n"), ctx->device_name, inodes_used, inodes, - frag_percent / 10, frag_percent % 10, + frag_percent_total / 10, frag_percent_total % 10, blocks_used, blocks); return; } printf (P_("\n%8u inode used (%2.2f%%)\n", "\n%8u inodes used (%2.2f%%)\n", inodes_used), inodes_used, 100.0 * inodes_used / inodes); - printf (P_("%8u non-contiguous inode (%0d.%d%%)\n", - "%8u non-contiguous inodes (%0d.%d%%)\n", + printf (P_("%8u non-contiguous file (%0d.%d%%)\n", + "%8u non-contiguous files (%0d.%d%%)\n", ctx->fs_fragmented), - ctx->fs_fragmented, frag_percent / 10, frag_percent % 10); + ctx->fs_fragmented, frag_percent_file / 10, + frag_percent_file % 10); + printf (P_("%8u non-contiguous directory (%0d.%d%%)\n", + "%8u non-contiguous directories (%0d.%d%%)\n", + ctx->fs_fragmented_dir), + ctx->fs_fragmented_dir, frag_percent_dir / 10, + frag_percent_dir % 10); printf (_(" # of inodes with ind/dind/tind blocks: %u/%u/%u\n"), ctx->fs_ind_count, ctx->fs_dind_count, ctx->fs_tind_count); |