mirror of https://github.com/vitalif/e2fsprogs
e2fsck: Fix ind/dind/tind statistics and add extent depth statistics
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>bitmap-optimize
parent
f4e2c991ef
commit
8da6d1a18a
|
@ -49,6 +49,8 @@ errcode_t e2fsck_allocate_context(e2fsck_t *ret)
|
|||
*/
|
||||
errcode_t e2fsck_reset_context(e2fsck_t ctx)
|
||||
{
|
||||
int i;
|
||||
|
||||
ctx->flags = 0;
|
||||
ctx->lost_and_found = 0;
|
||||
ctx->bad_lost_and_found = 0;
|
||||
|
@ -152,6 +154,9 @@ errcode_t e2fsck_reset_context(e2fsck_t ctx)
|
|||
ctx->fs_fragmented = 0;
|
||||
ctx->large_files = 0;
|
||||
|
||||
for (i=0; i < MAX_EXTENT_DEPTH_COUNT; i++)
|
||||
ctx->extent_depth_count[i] = 0;
|
||||
|
||||
/* Reset the superblock to the user's requested value */
|
||||
ctx->superblock = ctx->use_superblock;
|
||||
|
||||
|
|
|
@ -195,6 +195,8 @@ typedef struct ea_refcount *ext2_refcount_t;
|
|||
*/
|
||||
typedef struct e2fsck_struct *e2fsck_t;
|
||||
|
||||
#define MAX_EXTENT_DEPTH_COUNT 5
|
||||
|
||||
struct e2fsck_struct {
|
||||
ext2_filsys fs;
|
||||
const char *program_name;
|
||||
|
@ -329,6 +331,7 @@ struct e2fsck_struct {
|
|||
__u32 large_files;
|
||||
__u32 fs_ext_attr_inodes;
|
||||
__u32 fs_ext_attr_blocks;
|
||||
__u32 extent_depth_count[MAX_EXTENT_DEPTH_COUNT];
|
||||
|
||||
/* misc fields */
|
||||
time_t now;
|
||||
|
|
|
@ -1006,12 +1006,14 @@ void e2fsck_pass1(e2fsck_t ctx)
|
|||
ctx->fs_sockets_count++;
|
||||
} else
|
||||
mark_inode_bad(ctx, ino);
|
||||
if (inode->i_block[EXT2_IND_BLOCK])
|
||||
ctx->fs_ind_count++;
|
||||
if (inode->i_block[EXT2_DIND_BLOCK])
|
||||
ctx->fs_dind_count++;
|
||||
if (inode->i_block[EXT2_TIND_BLOCK])
|
||||
ctx->fs_tind_count++;
|
||||
if (!(inode->i_flags & EXT4_EXTENTS_FL)) {
|
||||
if (inode->i_block[EXT2_IND_BLOCK])
|
||||
ctx->fs_ind_count++;
|
||||
if (inode->i_block[EXT2_DIND_BLOCK])
|
||||
ctx->fs_dind_count++;
|
||||
if (inode->i_block[EXT2_TIND_BLOCK])
|
||||
ctx->fs_tind_count++;
|
||||
}
|
||||
if (!(inode->i_flags & EXT4_EXTENTS_FL) &&
|
||||
(inode->i_block[EXT2_IND_BLOCK] ||
|
||||
inode->i_block[EXT2_DIND_BLOCK] ||
|
||||
|
@ -1738,10 +1740,12 @@ static void scan_extent_node(e2fsck_t ctx, struct problem_context *pctx,
|
|||
static void check_blocks_extents(e2fsck_t ctx, struct problem_context *pctx,
|
||||
struct process_block_struct *pb)
|
||||
{
|
||||
struct ext2_extent_info info;
|
||||
struct ext2_inode *inode = pctx->inode;
|
||||
ext2_extent_handle_t ehandle;
|
||||
ext2_filsys fs = ctx->fs;
|
||||
ext2_ino_t ino = pctx->ino;
|
||||
errcode_t retval;
|
||||
|
||||
pctx->errcode = ext2fs_extent_open(fs, ino, &ehandle);
|
||||
if (pctx->errcode &&
|
||||
|
@ -1751,6 +1755,13 @@ static void check_blocks_extents(e2fsck_t ctx, struct problem_context *pctx,
|
|||
return;
|
||||
}
|
||||
|
||||
retval = ext2fs_extent_get_info(ehandle, &info);
|
||||
if (retval == 0) {
|
||||
if (info.max_depth >= MAX_EXTENT_DEPTH_COUNT)
|
||||
info.max_depth = MAX_EXTENT_DEPTH_COUNT-1;
|
||||
ctx->extent_depth_count[info.max_depth]++;
|
||||
}
|
||||
|
||||
scan_extent_node(ctx, pctx, pb, 0, ehandle);
|
||||
|
||||
if (pb->fragmented && pb->num_blocks < fs->super->s_blocks_per_group)
|
||||
|
|
|
@ -104,6 +104,7 @@ static void show_stats(e2fsck_t ctx)
|
|||
int dir_links;
|
||||
int num_files, num_links;
|
||||
int frag_percent;
|
||||
int i, j;
|
||||
|
||||
dir_links = 2 * ctx->fs_directory_count - 1;
|
||||
num_files = ctx->fs_total_count - dir_links;
|
||||
|
@ -133,6 +134,20 @@ static void show_stats(e2fsck_t ctx)
|
|||
ctx->fs_fragmented, frag_percent / 10, frag_percent % 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);
|
||||
|
||||
for (j=MAX_EXTENT_DEPTH_COUNT-1; j >=0; j--)
|
||||
if (ctx->extent_depth_count[j])
|
||||
break;
|
||||
if (++j) {
|
||||
printf (_(" Extent depth histogram: "));
|
||||
for (i=0; i < j; i++) {
|
||||
if (i)
|
||||
fputc('/', stdout);
|
||||
printf("%u", ctx->extent_depth_count[i]);
|
||||
}
|
||||
fputc('\n', stdout);
|
||||
}
|
||||
|
||||
printf (P_("%8u block used (%2.2f%%)\n", "%8u blocks used (%2.2f%%)\n",
|
||||
blocks_used), blocks_used, 100.0 * blocks_used / blocks);
|
||||
printf (P_("%8u bad block\n", "%8u bad blocks\n",
|
||||
|
|
Loading…
Reference in New Issue