* [PATCH] ext2: Fix the max file size for ext2 file system. @ 2007-10-22 14:55 Aneesh Kumar K.V 2007-10-22 14:55 ` [PATCH] ext3: Fix the max file size for ext3 " Aneesh Kumar K.V 0 siblings, 1 reply; 4+ messages in thread From: Aneesh Kumar K.V @ 2007-10-22 14:55 UTC (permalink / raw) To: akpm; +Cc: linux-ext4, Aneesh Kumar K.V The max file size for ext2 file system is now calculated with hardcoded 4K block size. The patch fixes it to be calculated with the right block size. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> --- fs/ext2/super.c | 32 ++++++++++++++++++++++++++++---- 1 files changed, 28 insertions(+), 4 deletions(-) diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 77bd5f9..3d2019e 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -676,11 +676,31 @@ static int ext2_check_descriptors (struct super_block * sb) static loff_t ext2_max_size(int bits) { loff_t res = EXT2_NDIR_BLOCKS; - /* This constant is calculated to be the largest file size for a - * dense, 4k-blocksize file such that the total number of + int meta_blocks; + loff_t upper_limit; + + /* This is calculated to be the largest file size for a + * dense, file such that the total number of * sectors in the file, including data and all indirect blocks, - * does not exceed 2^32. */ - const loff_t upper_limit = 0x1ff7fffd000LL; + * does not exceed 2^32 -1 + * __u32 i_blocks representing the total number of + * 512 bytes blocks of the file + */ + upper_limit = (1LL << 32) - 1; + + /* total blocks in file system block size */ + upper_limit >>= (bits - 9); + + + /* indirect blocks */ + meta_blocks = 1; + /* double indirect blocks */ + meta_blocks += 1 + (1LL << (bits-2)); + /* tripple indirect blocks */ + meta_blocks += 1 + (1LL << (bits-2)) + (1LL << (2*(bits-2))); + + upper_limit -= meta_blocks; + upper_limit <<= bits; res += 1LL << (bits-2); res += 1LL << (2*(bits-2)); @@ -688,6 +708,10 @@ static loff_t ext2_max_size(int bits) res <<= bits; if (res > upper_limit) res = upper_limit; + + if (res > MAX_LFS_FILESIZE) + res = MAX_LFS_FILESIZE; + return res; } -- 1.5.3.4.206.g58ba4-dirty ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] ext3: Fix the max file size for ext3 file system. 2007-10-22 14:55 [PATCH] ext2: Fix the max file size for ext2 file system Aneesh Kumar K.V @ 2007-10-22 14:55 ` Aneesh Kumar K.V 2007-10-22 14:55 ` [PATCH] ext4: Return after ext4_error in case of failures Aneesh Kumar K.V 0 siblings, 1 reply; 4+ messages in thread From: Aneesh Kumar K.V @ 2007-10-22 14:55 UTC (permalink / raw) To: akpm; +Cc: linux-ext4, Aneesh Kumar K.V The max file size for ext3 file system is now calculated with hardcoded 4K block size. The patch fixes it to be calculated with the right block size. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> --- fs/ext3/super.c | 32 ++++++++++++++++++++++++++++---- 1 files changed, 28 insertions(+), 4 deletions(-) diff --git a/fs/ext3/super.c b/fs/ext3/super.c index 81868c0..0bfd3dc 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c @@ -1431,11 +1431,31 @@ static void ext3_orphan_cleanup (struct super_block * sb, static loff_t ext3_max_size(int bits) { loff_t res = EXT3_NDIR_BLOCKS; - /* This constant is calculated to be the largest file size for a - * dense, 4k-blocksize file such that the total number of + int meta_blocks; + loff_t upper_limit; + + /* This is calculated to be the largest file size for a + * dense, file such that the total number of * sectors in the file, including data and all indirect blocks, - * does not exceed 2^32. */ - const loff_t upper_limit = 0x1ff7fffd000LL; + * does not exceed 2^32 -1 + * __u32 i_blocks representing the total number of + * 512 bytes blocks of the file + */ + upper_limit = (1LL << 32) - 1; + + /* total blocks in file system block size */ + upper_limit >>= (bits - 9); + + + /* indirect blocks */ + meta_blocks = 1; + /* double indirect blocks */ + meta_blocks += 1 + (1LL << (bits-2)); + /* tripple indirect blocks */ + meta_blocks += 1 + (1LL << (bits-2)) + (1LL << (2*(bits-2))); + + upper_limit -= meta_blocks; + upper_limit <<= bits; res += 1LL << (bits-2); res += 1LL << (2*(bits-2)); @@ -1443,6 +1463,10 @@ static loff_t ext3_max_size(int bits) res <<= bits; if (res > upper_limit) res = upper_limit; + + if (res > MAX_LFS_FILESIZE) + res = MAX_LFS_FILESIZE; + return res; } -- 1.5.3.4.206.g58ba4-dirty ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] ext4: Return after ext4_error in case of failures 2007-10-22 14:55 ` [PATCH] ext3: Fix the max file size for ext3 " Aneesh Kumar K.V @ 2007-10-22 14:55 ` Aneesh Kumar K.V 0 siblings, 0 replies; 4+ messages in thread From: Aneesh Kumar K.V @ 2007-10-22 14:55 UTC (permalink / raw) To: akpm; +Cc: linux-ext4, Aneesh Kumar K.V This fix some instances where we were continuing after calling ext4_error. ext4_error call panic only if errors=panic mount option is set. So we need to make sure we return correctly after ext4_error call Reported by: Adrian Bunk <bunk@kernel.org> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> --- fs/ext4/balloc.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c index e906b65..8517dd7 100644 --- a/fs/ext4/balloc.c +++ b/fs/ext4/balloc.c @@ -234,11 +234,13 @@ read_block_bitmap(struct super_block *sb, unsigned int block_group) } else { bh = sb_bread(sb, bitmap_blk); } - if (!bh) + if (!bh) { ext4_error (sb, __FUNCTION__, "Cannot read block bitmap - " "block_group = %d, block_bitmap = %llu", block_group, bitmap_blk); + return NULL; + } /* check whether block bitmap block number is set */ if (!block_in_use(bitmap_blk, sb, bh->b_data)) { @@ -628,11 +630,13 @@ do_more: in_range(ext4_inode_bitmap(sb, desc), block, count) || in_range(block, ext4_inode_table(sb, desc), sbi->s_itb_per_group) || in_range(block + count - 1, ext4_inode_table(sb, desc), - sbi->s_itb_per_group)) + sbi->s_itb_per_group)) { ext4_error (sb, "ext4_free_blocks", "Freeing blocks in system zones - " "Block = %llu, count = %lu", block, count); + goto error_return; + } /* * We are about to start releasing blocks in the bitmap, @@ -1733,11 +1737,13 @@ allocated: in_range(ret_block, ext4_inode_table(sb, gdp), EXT4_SB(sb)->s_itb_per_group) || in_range(ret_block + num - 1, ext4_inode_table(sb, gdp), - EXT4_SB(sb)->s_itb_per_group)) + EXT4_SB(sb)->s_itb_per_group)) { ext4_error(sb, "ext4_new_block", "Allocating block in system zone - " "blocks from %llu, length %lu", ret_block, num); + goto out; + } performed_allocation = 1; -- 1.5.3.4.206.g58ba4-dirty ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] ext2: Fix the max file size for ext2 file system. @ 2007-10-11 14:50 Aneesh Kumar K.V 2007-10-11 14:50 ` [PATCH] ext3: Fix the max file size for ext3 " Aneesh Kumar K.V 0 siblings, 1 reply; 4+ messages in thread From: Aneesh Kumar K.V @ 2007-10-11 14:50 UTC (permalink / raw) To: akpm; +Cc: linux-ext4, Aneesh Kumar K.V The max file size for ext2 file system is now calculated with hardcoded 4K block size. The patch fixes it to be calculated with the right block size. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> --- fs/ext2/super.c | 32 ++++++++++++++++++++++++++++---- 1 files changed, 28 insertions(+), 4 deletions(-) diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 639a32c..a433a53 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -603,11 +603,31 @@ static int ext2_check_descriptors (struct super_block * sb) static loff_t ext2_max_size(int bits) { loff_t res = EXT2_NDIR_BLOCKS; - /* This constant is calculated to be the largest file size for a - * dense, 4k-blocksize file such that the total number of + int meta_blocks; + loff_t upper_limit; + + /* This is calculated to be the largest file size for a + * dense, file such that the total number of * sectors in the file, including data and all indirect blocks, - * does not exceed 2^32. */ - const loff_t upper_limit = 0x1ff7fffd000LL; + * does not exceed 2^32 -1 + * __u32 i_blocks representing the total number of + * 512 bytes blocks of the file + */ + upper_limit = (1LL << 32) - 1; + + /* total blocks in file system block size */ + upper_limit >>= (bits - 9); + + + /* indirect blocks */ + meta_blocks = 1; + /* double indirect blocks */ + meta_blocks += 1 + (1LL << (bits-2)); + /* tripple indirect blocks */ + meta_blocks += 1 + (1LL << (bits-2)) + (1LL << (2*(bits-2))); + + upper_limit -= meta_blocks; + upper_limit <<= bits; res += 1LL << (bits-2); res += 1LL << (2*(bits-2)); @@ -615,6 +635,10 @@ static loff_t ext2_max_size(int bits) res <<= bits; if (res > upper_limit) res = upper_limit; + + if (res > MAX_LFS_FILESIZE) + res = MAX_LFS_FILESIZE; + return res; } -- 1.5.3.4.206.g58ba4-dirty ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] ext3: Fix the max file size for ext3 file system. 2007-10-11 14:50 [PATCH] ext2: Fix the max file size for ext2 file system Aneesh Kumar K.V @ 2007-10-11 14:50 ` Aneesh Kumar K.V 0 siblings, 0 replies; 4+ messages in thread From: Aneesh Kumar K.V @ 2007-10-11 14:50 UTC (permalink / raw) To: akpm; +Cc: linux-ext4, Aneesh Kumar K.V The max file size for ext3 file system is now calculated with hardcoded 4K block size. The patch fixes it to be calculated with the right block size. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> --- fs/ext3/super.c | 32 ++++++++++++++++++++++++++++---- 1 files changed, 28 insertions(+), 4 deletions(-) diff --git a/fs/ext3/super.c b/fs/ext3/super.c index 9537316..4f0de11 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c @@ -1362,11 +1362,31 @@ static void ext3_orphan_cleanup (struct super_block * sb, static loff_t ext3_max_size(int bits) { loff_t res = EXT3_NDIR_BLOCKS; - /* This constant is calculated to be the largest file size for a - * dense, 4k-blocksize file such that the total number of + int meta_blocks; + loff_t upper_limit; + + /* This is calculated to be the largest file size for a + * dense, file such that the total number of * sectors in the file, including data and all indirect blocks, - * does not exceed 2^32. */ - const loff_t upper_limit = 0x1ff7fffd000LL; + * does not exceed 2^32 -1 + * __u32 i_blocks representing the total number of + * 512 bytes blocks of the file + */ + upper_limit = (1LL << 32) - 1; + + /* total blocks in file system block size */ + upper_limit >>= (bits - 9); + + + /* indirect blocks */ + meta_blocks = 1; + /* double indirect blocks */ + meta_blocks += 1 + (1LL << (bits-2)); + /* tripple indirect blocks */ + meta_blocks += 1 + (1LL << (bits-2)) + (1LL << (2*(bits-2))); + + upper_limit -= meta_blocks; + upper_limit <<= bits; res += 1LL << (bits-2); res += 1LL << (2*(bits-2)); @@ -1374,6 +1394,10 @@ static loff_t ext3_max_size(int bits) res <<= bits; if (res > upper_limit) res = upper_limit; + + if (res > MAX_LFS_FILESIZE) + res = MAX_LFS_FILESIZE; + return res; } -- 1.5.3.4.206.g58ba4-dirty ^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-10-22 14:55 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-10-22 14:55 [PATCH] ext2: Fix the max file size for ext2 file system Aneesh Kumar K.V 2007-10-22 14:55 ` [PATCH] ext3: Fix the max file size for ext3 " Aneesh Kumar K.V 2007-10-22 14:55 ` [PATCH] ext4: Return after ext4_error in case of failures Aneesh Kumar K.V -- strict thread matches above, loose matches on Subject: below -- 2007-10-11 14:50 [PATCH] ext2: Fix the max file size for ext2 file system Aneesh Kumar K.V 2007-10-11 14:50 ` [PATCH] ext3: Fix the max file size for ext3 " Aneesh Kumar K.V
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.