MCPcopy Create free account
hub / github.com/bobranten/Ext4Fsd / ext3_max_bitmap_size

Function ext3_max_bitmap_size

Ext4Fsd/ext3/generic.c:2304–2360  ·  view source on GitHub ↗

* Maximal bitmap file size. There is a direct, and {,double-,triple-}indirect * block limit, and also a limit of (2^48 - 1) 512-byte sectors in i_blocks. * We need to be 1 filesystem block less than the 2^48 sector limit. */

Source from the content-addressed store, hash-verified

2302 * We need to be 1 filesystem block less than the 2^48 sector limit.
2303 */
2304loff_t ext3_max_bitmap_size(int bits, int has_huge_files)
2305{
2306 loff_t res = EXT3_NDIR_BLOCKS;
2307 int meta_blocks;
2308 loff_t upper_limit;
2309 /* This is calculated to be the largest file size for a
2310 * dense, bitmapped file such that the total number of
2311 * sectors in the file, including data and all indirect blocks,
2312 * does not exceed 2^48 -1
2313 * __u32 i_blocks_lo and _u16 i_blocks_high representing the
2314 * total number of 512 bytes blocks of the file
2315 */
2316
2317 if (!has_huge_files) {
2318 /*
2319 * !has_huge_files or CONFIG_LBD is not enabled
2320 * implies the inode i_block represent total blocks in
2321 * 512 bytes 32 == size of vfs inode i_blocks * 8
2322 */
2323 upper_limit = ((loff_t)1 << 32) - 1;
2324
2325 /* total blocks in file system block size */
2326 upper_limit >>= (bits - 9);
2327
2328 } else {
2329 /*
2330 * We use 48 bit ext4_inode i_blocks
2331 * With EXT4_HUGE_FILE_FL set the i_blocks
2332 * represent total number of blocks in
2333 * file system block size
2334 */
2335 upper_limit = ((loff_t)1 << 48) - 1;
2336
2337 }
2338
2339 /* indirect blocks */
2340 meta_blocks = 1;
2341 /* double indirect blocks */
2342 meta_blocks += 1 + ((loff_t)1 << (bits-2));
2343 /* tripple indirect blocks */
2344 meta_blocks += 1 + ((loff_t)1 << (bits-2)) + ((loff_t)1 << (2*(bits-2)));
2345
2346 upper_limit -= meta_blocks;
2347 upper_limit <<= bits;
2348
2349 res += (loff_t)1 << (bits-2);
2350 res += (loff_t)1 << (2*(bits-2));
2351 res += (loff_t)1 << (3*(bits-2));
2352 res <<= bits;
2353 if (res > upper_limit)
2354 res = upper_limit;
2355
2356 if (res > MAX_LFS_FILESIZE)
2357 res = MAX_LFS_FILESIZE;
2358
2359 return res;
2360}
2361

Callers 1

Ext2InitializeVcbFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected