From: Eric Sandeen Date: Mon, 7 Jul 2008 04:02:47 +0000 (-0500) Subject: e2fsck: Fix i_size checking for large extent-based files X-Git-Tag: android-x86-6.0-r1~26^2~1329 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=7c1e090ce129e093c88403087ed03509d6d07d6a;p=android-x86%2Fexternal-e2fsprogs.git e2fsck: Fix i_size checking for large extent-based files This: Truncating bigfile to 14680064000000 Pass 1: Checking inodes, blocks, and sizes Inode 49154, i_size is 14680064000000, should be 0. Fix? is a bit unexpected. It's because the size is being checked against the max sizes for bitmap files, not extent-based files. Nick saw this with his 14TB file. Patch below applies different size limits to the different file formats. Signed-off-by: Eric Sandeen Signed-off-by: "Theodore Ts'o" --- diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index 3e08b611..c240195f 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -1756,6 +1756,7 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx, struct ext2_inode *inode = pctx->inode; int bad_size = 0; int dirty_inode = 0; + int extent_fs; __u64 size; pb.ino = ino; @@ -1775,6 +1776,9 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx, pctx->ino = ino; pctx->errcode = 0; + extent_fs = (ctx->fs->super->s_feature_incompat & + EXT3_FEATURE_INCOMPAT_EXTENTS); + if (inode->i_flags & EXT2_COMPRBLK_FL) { if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_COMPRESSION) @@ -1794,9 +1798,7 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx, } if (ext2fs_inode_has_valid_blocks(inode)) { - if ((ctx->fs->super->s_feature_incompat & - EXT3_FEATURE_INCOMPAT_EXTENTS) && - (inode->i_flags & EXT4_EXTENTS_FL)) + if (extent_fs && (inode->i_flags & EXT4_EXTENTS_FL)) check_blocks_extents(ctx, pctx, &pb); else pctx->errcode = ext2fs_block_iterate2(fs, ino, @@ -1892,8 +1894,14 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx, (pb.last_block / blkpg * blkpg != pb.last_block || size < (__u64)(pb.last_block & ~(blkpg-1)) *fs->blocksize)) bad_size = 3; - else if (size > ext2_max_sizes[fs->super->s_log_block_size]) + else if (!(extent_fs && (inode->i_flags & EXT4_EXTENTS_FL)) && + size > ext2_max_sizes[fs->super->s_log_block_size]) + /* too big for a direct/indirect-mapped file */ bad_size = 4; + else if ((extent_fs && (inode->i_flags & EXT4_EXTENTS_FL)) && + size > (1LL << (32 + fs->super->s_log_block_size) - 1)) + /* too big for an extent-based file - 32bit ee_block */ + bad_size = 6; } /* i_size for symlinks is checked elsewhere */ if (bad_size && !LINUX_S_ISLNK(inode->i_mode)) {