mirror of https://github.com/vitalif/e2fsprogs
e2fsck: Fix check to see if an extent-based file is fragmented
Also added support for "e2fsck -E fragcheck" which issues a comprehensive report of discontiguous file extents. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>bitmap-optimize
parent
57926c8c55
commit
63b5e354d9
|
@ -185,9 +185,14 @@ following options are supported:
|
||||||
.RS 1.2i
|
.RS 1.2i
|
||||||
.TP
|
.TP
|
||||||
.BI ea_ver= extended_attribute_version
|
.BI ea_ver= extended_attribute_version
|
||||||
Assume the format of the extended attribute blocks in the filesystem is
|
Set the version of the extended attribute blocks which
|
||||||
the specified version number. The version number may be 1 or 2. The
|
.B e2fsck
|
||||||
default extended attribute version format is 2.
|
will require while checking the filesystem. The version number may
|
||||||
|
be 1 or 2. The default extended attribute version format is 2.
|
||||||
|
.TP
|
||||||
|
.BI fragcheck
|
||||||
|
During pass 1, print a detailed report of any discontiguous blocks for
|
||||||
|
files in the filesystem.
|
||||||
.RE
|
.RE
|
||||||
.TP
|
.TP
|
||||||
.B \-f
|
.B \-f
|
||||||
|
|
|
@ -154,6 +154,7 @@ struct resource_track {
|
||||||
#define E2F_OPT_FORCE 0x0100
|
#define E2F_OPT_FORCE 0x0100
|
||||||
#define E2F_OPT_WRITECHECK 0x0200
|
#define E2F_OPT_WRITECHECK 0x0200
|
||||||
#define E2F_OPT_COMPRESS_DIRS 0x0400
|
#define E2F_OPT_COMPRESS_DIRS 0x0400
|
||||||
|
#define E2F_OPT_FRAGCHECK 0x0800
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* E2fsck flags
|
* E2fsck flags
|
||||||
|
|
|
@ -1694,6 +1694,18 @@ static void scan_extent_node(e2fsck_t ctx, struct problem_context *pctx,
|
||||||
goto next;
|
goto next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((pb->previous_block != 0) &&
|
||||||
|
(pb->previous_block+1 != extent.e_pblk)) {
|
||||||
|
if (ctx->options & E2F_OPT_FRAGCHECK)
|
||||||
|
printf(("%6lu: expecting %6lu actual extent "
|
||||||
|
"phys %6lu log %lu len %lu\n"),
|
||||||
|
(unsigned long) pctx->ino,
|
||||||
|
(unsigned long) pb->previous_block+1,
|
||||||
|
(unsigned long) extent.e_pblk,
|
||||||
|
(unsigned long) extent.e_lblk,
|
||||||
|
(unsigned long) extent.e_len);
|
||||||
|
pb->fragmented = 1;
|
||||||
|
}
|
||||||
for (blk = extent.e_pblk, blockcnt = extent.e_lblk, i = 0;
|
for (blk = extent.e_pblk, blockcnt = extent.e_lblk, i = 0;
|
||||||
i < extent.e_len;
|
i < extent.e_len;
|
||||||
blk++, blockcnt++, i++) {
|
blk++, blockcnt++, i++) {
|
||||||
|
@ -1712,6 +1724,7 @@ static void scan_extent_node(e2fsck_t ctx, struct problem_context *pctx,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pb->num_blocks += extent.e_len;
|
pb->num_blocks += extent.e_len;
|
||||||
|
pb->previous_block = extent.e_pblk + extent.e_len - 1;
|
||||||
start_block = pb->last_block = extent.e_lblk + extent.e_len - 1;
|
start_block = pb->last_block = extent.e_lblk + extent.e_len - 1;
|
||||||
next:
|
next:
|
||||||
pctx->errcode = ext2fs_extent_get(ehandle,
|
pctx->errcode = ext2fs_extent_get(ehandle,
|
||||||
|
@ -1740,6 +1753,9 @@ static void check_blocks_extents(e2fsck_t ctx, struct problem_context *pctx,
|
||||||
|
|
||||||
scan_extent_node(ctx, pctx, pb, 0, ehandle);
|
scan_extent_node(ctx, pctx, pb, 0, ehandle);
|
||||||
|
|
||||||
|
if (pb->fragmented && pb->num_blocks < fs->super->s_blocks_per_group)
|
||||||
|
ctx->fs_fragmented++;
|
||||||
|
|
||||||
ext2fs_extent_free(ehandle);
|
ext2fs_extent_free(ehandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2066,9 +2082,16 @@ static int process_block(ext2_filsys fs,
|
||||||
* file be contiguous. (Which can never be true for really
|
* file be contiguous. (Which can never be true for really
|
||||||
* big files that are greater than a block group.)
|
* big files that are greater than a block group.)
|
||||||
*/
|
*/
|
||||||
if (!HOLE_BLKADDR(p->previous_block)) {
|
if (!HOLE_BLKADDR(p->previous_block) && p->ino != EXT2_RESIZE_INO) {
|
||||||
if (p->previous_block+1 != blk)
|
if (p->previous_block+1 != blk) {
|
||||||
|
if (ctx->options & E2F_OPT_FRAGCHECK)
|
||||||
|
printf(_("%6lu: expecting %6lu got %6lu (%lu)\n"),
|
||||||
|
(unsigned long) pctx->ino,
|
||||||
|
(unsigned long) p->previous_block+1,
|
||||||
|
(unsigned long) blk,
|
||||||
|
(unsigned long) blockcnt);
|
||||||
p->fragmented = 1;
|
p->fragmented = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
p->previous_block = blk;
|
p->previous_block = blk;
|
||||||
|
|
||||||
|
|
|
@ -553,6 +553,9 @@ static void parse_extended_opts(e2fsck_t ctx, const char *opts)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ctx->ext_attr_ver = ea_ver;
|
ctx->ext_attr_ver = ea_ver;
|
||||||
|
} else if (strcmp(token, "fragcheck") == 0) {
|
||||||
|
ctx->options |= E2F_OPT_FRAGCHECK;
|
||||||
|
continue;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, _("Unknown extended option: %s\n"),
|
fprintf(stderr, _("Unknown extended option: %s\n"),
|
||||||
token);
|
token);
|
||||||
|
@ -565,8 +568,10 @@ static void parse_extended_opts(e2fsck_t ctx, const char *opts)
|
||||||
fputs(("\nExtended options are separated by commas, "
|
fputs(("\nExtended options are separated by commas, "
|
||||||
"and may take an argument which\n"
|
"and may take an argument which\n"
|
||||||
"is set off by an equals ('=') sign. "
|
"is set off by an equals ('=') sign. "
|
||||||
"Valid extended options are:\n"
|
"Valid extended options are:\n"), stderr);
|
||||||
"\tea_ver=<ea_version (1 or 2)>\n\n"), stderr);
|
fputs(("\tea_ver=<ea_version (1 or 2)>\n"), stderr);
|
||||||
|
fputs(("\tfragcheck\n"), stderr);
|
||||||
|
fputc('\n', stderr);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ Pass 2: Checking directory structure
|
||||||
Pass 3: Checking directory connectivity
|
Pass 3: Checking directory connectivity
|
||||||
Pass 4: Checking reference counts
|
Pass 4: Checking reference counts
|
||||||
Pass 5: Checking group summary information
|
Pass 5: Checking group summary information
|
||||||
test_filesys: 12/64 files (8.3% non-contiguous), 158/512 blocks
|
test_filesys: 12/64 files (0.0% non-contiguous), 158/512 blocks
|
||||||
Exit status is 0
|
Exit status is 0
|
||||||
debugfs -R ''dump test_data test.verify'' ./test.img
|
debugfs -R ''dump test_data test.verify'' ./test.img
|
||||||
Exit status is 0
|
Exit status is 0
|
||||||
|
|
|
@ -29,5 +29,5 @@ Creating journal (1024 blocks): Done.
|
||||||
*** journal has been re-created - filesystem is now ext3 again ***
|
*** journal has been re-created - filesystem is now ext3 again ***
|
||||||
|
|
||||||
test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
|
test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
|
||||||
test_filesys: 11/256 files (9.1% non-contiguous), 1112/8192 blocks
|
test_filesys: 11/256 files (0.0% non-contiguous), 1112/8192 blocks
|
||||||
Exit status is 1
|
Exit status is 1
|
||||||
|
|
|
@ -3,5 +3,5 @@ Pass 2: Checking directory structure
|
||||||
Pass 3: Checking directory connectivity
|
Pass 3: Checking directory connectivity
|
||||||
Pass 4: Checking reference counts
|
Pass 4: Checking reference counts
|
||||||
Pass 5: Checking group summary information
|
Pass 5: Checking group summary information
|
||||||
test_filesys: 11/256 files (9.1% non-contiguous), 1112/8192 blocks
|
test_filesys: 11/256 files (0.0% non-contiguous), 1112/8192 blocks
|
||||||
Exit status is 0
|
Exit status is 0
|
||||||
|
|
|
@ -3,5 +3,5 @@ Pass 2: Checking directory structure
|
||||||
Pass 3: Checking directory connectivity
|
Pass 3: Checking directory connectivity
|
||||||
Pass 4: Checking reference counts
|
Pass 4: Checking reference counts
|
||||||
Pass 5: Checking group summary information
|
Pass 5: Checking group summary information
|
||||||
test_filesys: 12/2560 files (16.7% non-contiguous), 485/10240 blocks
|
test_filesys: 12/2560 files (8.3% non-contiguous), 485/10240 blocks
|
||||||
Exit status is 0
|
Exit status is 0
|
||||||
|
|
|
@ -66,5 +66,5 @@ Fix? yes
|
||||||
|
|
||||||
|
|
||||||
test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
|
test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
|
||||||
test_filesys: 18/32 files (0.0% non-contiguous), 145/200 blocks
|
test_filesys: 18/32 files (44.4% non-contiguous), 145/200 blocks
|
||||||
Exit status is 1
|
Exit status is 1
|
||||||
|
|
|
@ -3,5 +3,5 @@ Pass 2: Checking directory structure
|
||||||
Pass 3: Checking directory connectivity
|
Pass 3: Checking directory connectivity
|
||||||
Pass 4: Checking reference counts
|
Pass 4: Checking reference counts
|
||||||
Pass 5: Checking group summary information
|
Pass 5: Checking group summary information
|
||||||
test_filesys: 18/32 files (0.0% non-contiguous), 145/200 blocks
|
test_filesys: 18/32 files (44.4% non-contiguous), 145/200 blocks
|
||||||
Exit status is 0
|
Exit status is 0
|
||||||
|
|
|
@ -3,5 +3,5 @@ Pass 2: Checking directory structure
|
||||||
Pass 3: Checking directory connectivity
|
Pass 3: Checking directory connectivity
|
||||||
Pass 4: Checking reference counts
|
Pass 4: Checking reference counts
|
||||||
Pass 5: Checking group summary information
|
Pass 5: Checking group summary information
|
||||||
test_filesys: 11/3744 files (9.1% non-contiguous), 685/769 blocks
|
test_filesys: 11/3744 files (0.0% non-contiguous), 685/769 blocks
|
||||||
Exit status is 0
|
Exit status is 0
|
||||||
|
|
|
@ -3,5 +3,5 @@ Pass 2: Checking directory structure
|
||||||
Pass 3: Checking directory connectivity
|
Pass 3: Checking directory connectivity
|
||||||
Pass 4: Checking reference counts
|
Pass 4: Checking reference counts
|
||||||
Pass 5: Checking group summary information
|
Pass 5: Checking group summary information
|
||||||
test_filesys: 11/3744 files (9.1% non-contiguous), 685/769 blocks
|
test_filesys: 11/3744 files (0.0% non-contiguous), 685/769 blocks
|
||||||
Exit status is 0
|
Exit status is 0
|
||||||
|
|
|
@ -5,5 +5,5 @@ Pass 2: Checking directory structure
|
||||||
Pass 3: Checking directory connectivity
|
Pass 3: Checking directory connectivity
|
||||||
Pass 4: Checking reference counts
|
Pass 4: Checking reference counts
|
||||||
Pass 5: Checking group summary information
|
Pass 5: Checking group summary information
|
||||||
test_filesys: 11/32 files (9.1% non-contiguous), 105/10000 blocks
|
test_filesys: 11/32 files (0.0% non-contiguous), 105/10000 blocks
|
||||||
Exit status is 0
|
Exit status is 0
|
||||||
|
|
|
@ -3,5 +3,5 @@ Pass 2: Checking directory structure
|
||||||
Pass 3: Checking directory connectivity
|
Pass 3: Checking directory connectivity
|
||||||
Pass 4: Checking reference counts
|
Pass 4: Checking reference counts
|
||||||
Pass 5: Checking group summary information
|
Pass 5: Checking group summary information
|
||||||
test_filesys: 11/32 files (9.1% non-contiguous), 105/10000 blocks
|
test_filesys: 11/32 files (0.0% non-contiguous), 105/10000 blocks
|
||||||
Exit status is 0
|
Exit status is 0
|
||||||
|
|
|
@ -6,5 +6,5 @@ Pass 4: Checking reference counts
|
||||||
Pass 5: Checking group summary information
|
Pass 5: Checking group summary information
|
||||||
|
|
||||||
test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
|
test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
|
||||||
test_filesys: 11/2512 files (9.1% non-contiguous), 415/10000 blocks
|
test_filesys: 11/2512 files (0.0% non-contiguous), 415/10000 blocks
|
||||||
Exit status is 1
|
Exit status is 1
|
||||||
|
|
|
@ -3,5 +3,5 @@ Pass 2: Checking directory structure
|
||||||
Pass 3: Checking directory connectivity
|
Pass 3: Checking directory connectivity
|
||||||
Pass 4: Checking reference counts
|
Pass 4: Checking reference counts
|
||||||
Pass 5: Checking group summary information
|
Pass 5: Checking group summary information
|
||||||
test_filesys: 11/2512 files (9.1% non-contiguous), 415/10000 blocks
|
test_filesys: 11/2512 files (0.0% non-contiguous), 415/10000 blocks
|
||||||
Exit status is 0
|
Exit status is 0
|
||||||
|
|
|
@ -22,7 +22,7 @@ Pass 2: Checking directory structure
|
||||||
Pass 3: Checking directory connectivity
|
Pass 3: Checking directory connectivity
|
||||||
Pass 4: Checking reference counts
|
Pass 4: Checking reference counts
|
||||||
Pass 5: Checking group summary information
|
Pass 5: Checking group summary information
|
||||||
test_filesys: 11/16384 files (9.1% non-contiguous), 1104/32768 blocks
|
test_filesys: 11/16384 files (0.0% non-contiguous), 1104/32768 blocks
|
||||||
Exit status is 0
|
Exit status is 0
|
||||||
|
|
||||||
Filesystem volume name: <none>
|
Filesystem volume name: <none>
|
||||||
|
|
|
@ -20,7 +20,7 @@ Pass 2: Checking directory structure
|
||||||
Pass 3: Checking directory connectivity
|
Pass 3: Checking directory connectivity
|
||||||
Pass 4: Checking reference counts
|
Pass 4: Checking reference counts
|
||||||
Pass 5: Checking group summary information
|
Pass 5: Checking group summary information
|
||||||
test_filesys: 11/64 files (9.1% non-contiguous), 17/16384 blocks
|
test_filesys: 11/64 files (0.0% non-contiguous), 17/16384 blocks
|
||||||
Exit status is 0
|
Exit status is 0
|
||||||
|
|
||||||
Filesystem volume name: <none>
|
Filesystem volume name: <none>
|
||||||
|
|
|
@ -22,7 +22,7 @@ Pass 2: Checking directory structure
|
||||||
Pass 3: Checking directory connectivity
|
Pass 3: Checking directory connectivity
|
||||||
Pass 4: Checking reference counts
|
Pass 4: Checking reference counts
|
||||||
Pass 5: Checking group summary information
|
Pass 5: Checking group summary information
|
||||||
test_filesys: 11/16384 files (9.1% non-contiguous), 3364/65536 blocks
|
test_filesys: 11/16384 files (0.0% non-contiguous), 3364/65536 blocks
|
||||||
Exit status is 0
|
Exit status is 0
|
||||||
|
|
||||||
Filesystem volume name: <none>
|
Filesystem volume name: <none>
|
||||||
|
|
|
@ -22,7 +22,7 @@ Pass 2: Checking directory structure
|
||||||
Pass 3: Checking directory connectivity
|
Pass 3: Checking directory connectivity
|
||||||
Pass 4: Checking reference counts
|
Pass 4: Checking reference counts
|
||||||
Pass 5: Checking group summary information
|
Pass 5: Checking group summary information
|
||||||
test_filesys: 11/32768 files (9.1% non-contiguous), 5691/131072 blocks
|
test_filesys: 11/32768 files (0.0% non-contiguous), 5691/131072 blocks
|
||||||
Exit status is 0
|
Exit status is 0
|
||||||
|
|
||||||
Filesystem volume name: <none>
|
Filesystem volume name: <none>
|
||||||
|
|
Loading…
Reference in New Issue