mirror of
https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git
synced 2025-01-25 01:43:25 +08:00
Merge branch 'maint'
This commit is contained in:
commit
e07b71f294
@ -1848,11 +1848,11 @@ void e2fsck_clear_inode(e2fsck_t ctx, ext2_ino_t ino,
|
||||
|
||||
static void scan_extent_node(e2fsck_t ctx, struct problem_context *pctx,
|
||||
struct process_block_struct *pb,
|
||||
blk64_t start_block,
|
||||
blk64_t start_block, blk64_t end_block,
|
||||
ext2_extent_handle_t ehandle)
|
||||
{
|
||||
struct ext2fs_extent extent;
|
||||
blk64_t blk;
|
||||
blk64_t blk, last_lblk;
|
||||
e2_blkcnt_t blockcnt;
|
||||
unsigned int i;
|
||||
int is_dir, is_leaf;
|
||||
@ -1872,6 +1872,7 @@ static void scan_extent_node(e2fsck_t ctx, struct problem_context *pctx,
|
||||
failed_csum = 0;
|
||||
is_leaf = extent.e_flags & EXT2_EXTENT_FLAGS_LEAF;
|
||||
is_dir = LINUX_S_ISDIR(pctx->inode->i_mode);
|
||||
last_lblk = extent.e_lblk + extent.e_len - 1;
|
||||
|
||||
problem = 0;
|
||||
/* Ask to clear a corrupt extent block */
|
||||
@ -1891,6 +1892,8 @@ static void scan_extent_node(e2fsck_t ctx, struct problem_context *pctx,
|
||||
problem = PR_1_EXTENT_BAD_START_BLK;
|
||||
else if (extent.e_lblk < start_block)
|
||||
problem = PR_1_OUT_OF_ORDER_EXTENTS;
|
||||
else if (end_block && last_lblk > end_block)
|
||||
problem = PR_1_EXTENT_END_OUT_OF_BOUNDS;
|
||||
else if (is_leaf && extent.e_len == 0)
|
||||
problem = PR_1_EXTENT_LENGTH_ZERO;
|
||||
else if (is_leaf &&
|
||||
@ -1937,10 +1940,9 @@ fix_problem_now:
|
||||
}
|
||||
|
||||
if (!is_leaf) {
|
||||
blk64_t lblk;
|
||||
blk64_t lblk = extent.e_lblk;
|
||||
|
||||
blk = extent.e_pblk;
|
||||
lblk = extent.e_lblk;
|
||||
pctx->errcode = ext2fs_extent_get(ehandle,
|
||||
EXT2_EXTENT_DOWN, &extent);
|
||||
if (pctx->errcode) {
|
||||
@ -1965,7 +1967,8 @@ fix_problem_now:
|
||||
if (fix_problem(ctx, problem, pctx))
|
||||
ext2fs_extent_fix_parents(ehandle);
|
||||
}
|
||||
scan_extent_node(ctx, pctx, pb, extent.e_lblk, ehandle);
|
||||
scan_extent_node(ctx, pctx, pb, extent.e_lblk,
|
||||
last_lblk, ehandle);
|
||||
if (pctx->errcode)
|
||||
return;
|
||||
pctx->errcode = ext2fs_extent_get(ehandle,
|
||||
@ -2046,10 +2049,10 @@ fix_problem_now:
|
||||
if (is_dir && extent.e_len > 0)
|
||||
pb->last_db_block = blockcnt - 1;
|
||||
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 = last_lblk;
|
||||
if (is_leaf && !is_dir &&
|
||||
!(extent.e_flags & EXT2_EXTENT_FLAGS_UNINIT))
|
||||
pb->last_init_lblock = extent.e_lblk + extent.e_len - 1;
|
||||
pb->last_init_lblock = last_lblk;
|
||||
next:
|
||||
pctx->errcode = ext2fs_extent_get(ehandle,
|
||||
EXT2_EXTENT_NEXT_SIB,
|
||||
@ -2085,7 +2088,7 @@ static void check_blocks_extents(e2fsck_t ctx, struct problem_context *pctx,
|
||||
ctx->extent_depth_count[info.max_depth]++;
|
||||
}
|
||||
|
||||
scan_extent_node(ctx, pctx, pb, 0, ehandle);
|
||||
scan_extent_node(ctx, pctx, pb, 0, 0, ehandle);
|
||||
if (pctx->errcode &&
|
||||
fix_problem(ctx, PR_1_EXTENT_ITERATE_FAILURE, pctx)) {
|
||||
pb->num_blocks = 0;
|
||||
|
@ -1008,6 +1008,12 @@ static struct e2fsck_problem problem_table[] = {
|
||||
"Logical start %b does not match logical start %c at next level. "),
|
||||
PROMPT_FIX, 0 },
|
||||
|
||||
/* Extent end is out of bounds for the tree */
|
||||
{ PR_1_EXTENT_END_OUT_OF_BOUNDS,
|
||||
N_("@i %i, end of extent exceeds allowed value\n\t(logical @b %c, physical @b %b, len %N)\n"),
|
||||
PROMPT_CLEAR, 0 },
|
||||
|
||||
|
||||
/* Pass 1b errors */
|
||||
|
||||
/* Pass 1B: Rescan for duplicate/bad blocks */
|
||||
|
@ -589,6 +589,7 @@ struct problem_context {
|
||||
/* Index start doesn't match start of next extent down */
|
||||
#define PR_1_EXTENT_INDEX_START_INVALID 0x01006D
|
||||
|
||||
#define PR_1_EXTENT_END_OUT_OF_BOUNDS 0x01006E
|
||||
/*
|
||||
* Pass 1b errors
|
||||
*/
|
||||
|
24
tests/f_extent_oobounds/expect.1
Normal file
24
tests/f_extent_oobounds/expect.1
Normal file
@ -0,0 +1,24 @@
|
||||
Pass 1: Checking inodes, blocks, and sizes
|
||||
Inode 12, end of extent exceeds allowed value
|
||||
(logical block 15, physical block 200, len 30)
|
||||
Clear? yes
|
||||
|
||||
Inode 12, i_blocks is 154, should be 94. Fix? yes
|
||||
|
||||
Pass 2: Checking directory structure
|
||||
Pass 3: Checking directory connectivity
|
||||
Pass 4: Checking reference counts
|
||||
Pass 5: Checking group summary information
|
||||
Block bitmap differences: -(200--229)
|
||||
Fix? yes
|
||||
|
||||
Free blocks count wrong for group #0 (156, counted=186).
|
||||
Fix? yes
|
||||
|
||||
Free blocks count wrong (156, counted=186).
|
||||
Fix? yes
|
||||
|
||||
|
||||
test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
|
||||
test_filesys: 12/32 files (8.3% non-contiguous), 70/256 blocks
|
||||
Exit status is 1
|
7
tests/f_extent_oobounds/expect.2
Normal file
7
tests/f_extent_oobounds/expect.2
Normal file
@ -0,0 +1,7 @@
|
||||
Pass 1: Checking inodes, blocks, and sizes
|
||||
Pass 2: Checking directory structure
|
||||
Pass 3: Checking directory connectivity
|
||||
Pass 4: Checking reference counts
|
||||
Pass 5: Checking group summary information
|
||||
test_filesys: 12/32 files (8.3% non-contiguous), 70/256 blocks
|
||||
Exit status is 0
|
42
tests/f_extent_oobounds/script
Normal file
42
tests/f_extent_oobounds/script
Normal file
@ -0,0 +1,42 @@
|
||||
if test -x $DEBUGFS_EXE; then
|
||||
|
||||
SKIP_GUNZIP="true"
|
||||
TEST_DATA="$test_name.tmp"
|
||||
|
||||
dd if=/dev/zero of=$TMPFILE bs=1k count=256 > /dev/null 2>&1
|
||||
mke2fs -Ft ext4 $TMPFILE > /dev/null 2>&1
|
||||
debugfs -w $TMPFILE << EOF > /dev/null 2>&1
|
||||
write /dev/null testfile
|
||||
extent_open testfile
|
||||
insert_node 0 15 100
|
||||
insert_node --after 15 15 115
|
||||
insert_node --after 30 15 130
|
||||
insert_node --after 45 15 145
|
||||
split
|
||||
down
|
||||
split
|
||||
root
|
||||
down
|
||||
next
|
||||
replace_node 15 30 200
|
||||
extent_close
|
||||
set_inode_field testfile i_size 61400
|
||||
set_inode_field testfile i_blocks 154
|
||||
setb 100 15
|
||||
setb 130 30
|
||||
setb 200 30
|
||||
set_bg 0 free_blocks_count 156
|
||||
set_bg 0 bg_checksum calc
|
||||
set_super_value free_blocks_count 156
|
||||
q
|
||||
EOF
|
||||
|
||||
. $cmd_dir/run_e2fsck
|
||||
|
||||
rm -f $TEST_DATA
|
||||
|
||||
unset E2FSCK_TIME TEST_DATA
|
||||
|
||||
else #if test -x $DEBUGFS_EXE; then
|
||||
echo "$test_name: $test_description: skipped"
|
||||
fi
|
Loading…
Reference in New Issue
Block a user