From: Andreas Dilger Date: Sat, 23 Jun 2018 18:30:52 +0000 (-0400) Subject: e2fsck: handle preallocation for large PAGE_SIZE X-Git-Tag: v1.44.3-rc1~26 X-Git-Url: https://git.whamcloud.com/tools/e2fsprogs.git/?a=commitdiff_plain;h=8d541f641ef3861276f7138b2f3e601036f03110;p=tools%2Fe2fsprogs.git e2fsck: handle preallocation for large PAGE_SIZE Fix handling of block preallocation support in cases where the kernel PAGE_SIZE is larger than the filesystem blocksize. Signed-off-by: Kalpak Shah Signed-off-by: Andreas Dilger Signed-off-by: Theodore Ts'o --- diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index c5149e5..98e8017 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -3448,10 +3448,15 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx, size = EXT2_I_SIZE(inode); if ((pb.last_init_lblock >= 0) && - /* allow allocated blocks to end of PAGE_SIZE */ + /* if size is smaller than expected by the block count, + * allow allocated blocks to end of PAGE_SIZE. + * last_init_lblock is the last in-use block, so it is + * the minimum expected file size, but +1 because it is + * the base-zero block number and not the block count. */ (size < (__u64)pb.last_init_lblock * fs->blocksize) && - (pb.last_init_lblock / blkpg * blkpg != pb.last_init_lblock || - size < (__u64)(pb.last_init_lblock & ~(blkpg-1)) * + ((pb.last_init_lblock + 1) / blkpg * blkpg != + (pb.last_init_lblock + 1) || + size < (__u64)(pb.last_init_lblock & ~(blkpg - 1)) * fs->blocksize)) bad_size = 3; else if (!(extent_fs && (inode->i_flags & EXT4_EXTENTS_FL)) && diff --git a/tests/f_eofblocks/expect.1 b/tests/f_eofblocks/expect.1 index 2e9133e..3422248 100644 --- a/tests/f_eofblocks/expect.1 +++ b/tests/f_eofblocks/expect.1 @@ -1,7 +1,5 @@ Pass 1: Checking inodes, blocks, and sizes -Inode 30, i_size is 2048, should be 4096. Fix? yes - -Inode 31, i_size is 2048, should be 4096. Fix? yes +Inode 31, i_size is 2048, should be 6144. Fix? yes Pass 2: Checking directory structure Pass 3: Checking directory connectivity @@ -9,5 +7,5 @@ Pass 4: Checking reference counts Pass 5: Checking group summary information test_filesys: ***** FILE SYSTEM WAS MODIFIED ***** -test_filesys: 31/56 files (29.0% non-contiguous), 83/400 blocks +test_filesys: 31/56 files (29.0% non-contiguous), 85/400 blocks Exit status is 1 diff --git a/tests/f_eofblocks/expect.2 b/tests/f_eofblocks/expect.2 index 2a2bca5..0cce314 100644 --- a/tests/f_eofblocks/expect.2 +++ b/tests/f_eofblocks/expect.2 @@ -3,5 +3,5 @@ Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information -test_filesys: 31/56 files (29.0% non-contiguous), 83/400 blocks +test_filesys: 31/56 files (29.0% non-contiguous), 85/400 blocks Exit status is 0 diff --git a/tests/f_eofblocks/image.gz b/tests/f_eofblocks/image.gz index 2586a6a..e1177b3 100644 Binary files a/tests/f_eofblocks/image.gz and b/tests/f_eofblocks/image.gz differ