Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 77885
b: refs/heads/master
c: 902be4c
h: refs/heads/master
i:
  77883: 1da4838
v: v3
  • Loading branch information
Aneesh Kumar K.V authored and Theodore Ts'o committed Jan 29, 2008
1 parent ac0f1e5 commit 67c4826
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e2b4657453c0d5571bd3c7256585c486ed42d364
refs/heads/master: 902be4c5efe0289594c3acf43da40fe7ff0a138b
32 changes: 28 additions & 4 deletions trunk/fs/ext2/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,18 +680,42 @@ 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));
res += 1LL << (3*(bits-2));
res <<= bits;
if (res > upper_limit)
res = upper_limit;

if (res > MAX_LFS_FILESIZE)
res = MAX_LFS_FILESIZE;

return res;
}

Expand Down

0 comments on commit 67c4826

Please sign in to comment.