From: Andreas Dilger <andreas.dilger@xxxxxxxxx> Fix handling of block preallocation support in cases where the kernel PAGE_SIZE is larger than the filesystem blocksize. Signed-off-by: Kalpak Shah <kalpak@xxxxxxxxxxxxx> Signed-off-by: Andreas Dilger <andreas.dilger@xxxxxxxxx> --- e2fsck/pass1.c | 11 ++++++++--- tests/f_eofblocks/expect.1 | 6 ++---- tests/f_eofblocks/expect.2 | 2 +- tests/f_eofblocks/image.gz | Bin 1364 -> 1372 bytes 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index f6623a6f..1d60cc88 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -3443,10 +3443,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 2e9133e1..34222480 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 2a2bca5c..0cce3148 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 2586a6a7670ad609ba7e66911a8f7a8f4df96321..e1177b3a7d6f33ce135fe91c7b6d11bbb1ee09a3 100644 GIT binary patch literal 1372 zcmeH^Z!p^j7{_gHWq)pV>s%4!*j5`dL&d)l)1f=FR9$4$E~jY_5rXTqM1E?z%@ET~ zC?TU&hAs^g6(yT0>Cr@5;w~-emPlNYREYQ`zdy5=z1!Qp+xNwD_x*nEp6BlQV(Xlp zkH0oee9@84%+94bY^|hxN20koJu5YR=A+da`a+}fKmJVwRX@nN%&LE@I!B3j+<Du6 z^6S78&drIw@8v7SC;FSS>-N&$c^OyzN_PS#JfUvk)De&33i*U#!OI}OQnoO~*SK^> zx|k-kz-p+W($M*W>8$&QY0UcaaUQL**psV`^JHuhZ%vTEoz?LWyrjpvn-{}4<{eFD z#F`qDsaMz1<`nH-=dSIKCOysAEAiBz1<$%7bFtvwLn7xqGD|L>yk*<?Vz>zXgCR({ zVOCNE`}*w`d_A9Iu~Lkj{f?0$ox+IoX7JHm@8z^!VPAB9Z*n6hj)T)PP`TcQl|8-R z#JjkueM$a?!(+C`pNg4FiP|h2e7LGTe&T{l)_{;p9S|;)g@r43th5-5;q}`r)>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