aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/ext3/super.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index cb14de1502c3..f3675cc630e9 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -1436,11 +1436,31 @@ static void ext3_orphan_cleanup (struct super_block * sb,
1436static loff_t ext3_max_size(int bits) 1436static loff_t ext3_max_size(int bits)
1437{ 1437{
1438 loff_t res = EXT3_NDIR_BLOCKS; 1438 loff_t res = EXT3_NDIR_BLOCKS;
1439 /* This constant is calculated to be the largest file size for a 1439 int meta_blocks;
1440 * dense, 4k-blocksize file such that the total number of 1440 loff_t upper_limit;
1441
1442 /* This is calculated to be the largest file size for a
1443 * dense, file such that the total number of
1441 * sectors in the file, including data and all indirect blocks, 1444 * sectors in the file, including data and all indirect blocks,
1442 * does not exceed 2^32. */ 1445 * does not exceed 2^32 -1
1443 const loff_t upper_limit = 0x1ff7fffd000LL; 1446 * __u32 i_blocks representing the total number of
1447 * 512 bytes blocks of the file
1448 */
1449 upper_limit = (1LL << 32) - 1;
1450
1451 /* total blocks in file system block size */
1452 upper_limit >>= (bits - 9);
1453
1454
1455 /* indirect blocks */
1456 meta_blocks = 1;
1457 /* double indirect blocks */
1458 meta_blocks += 1 + (1LL << (bits-2));
1459 /* tripple indirect blocks */
1460 meta_blocks += 1 + (1LL << (bits-2)) + (1LL << (2*(bits-2)));
1461
1462 upper_limit -= meta_blocks;
1463 upper_limit <<= bits;
1444 1464
1445 res += 1LL << (bits-2); 1465 res += 1LL << (bits-2);
1446 res += 1LL << (2*(bits-2)); 1466 res += 1LL << (2*(bits-2));
@@ -1448,6 +1468,10 @@ static loff_t ext3_max_size(int bits)
1448 res <<= bits; 1468 res <<= bits;
1449 if (res > upper_limit) 1469 if (res > upper_limit)
1450 res = upper_limit; 1470 res = upper_limit;
1471
1472 if (res > MAX_LFS_FILESIZE)
1473 res = MAX_LFS_FILESIZE;
1474
1451 return res; 1475 return res;
1452} 1476}
1453 1477