* Find a reasonable journal file size (in blocks) given the number of blocks
* in the filesystem. For very small filesystems, it is not reasonable to
* have a journal that fills more than half of the filesystem.
+ *
+ * n.b. comments assume 4k blocks
*/
int ext2fs_default_journal_size(__u64 num_blocks)
{
if (num_blocks < 2048)
return -1;
- if (num_blocks < 32768)
- return (1024);
- if (num_blocks < 256*1024)
- return (4096);
- if (num_blocks < 512*1024)
- return (8192);
- if (num_blocks < 1024*1024)
- return (16384);
- return 32768;
+ if (num_blocks < 32768) /* 128 MB */
+ return (1024); /* 4 MB */
+ if (num_blocks < 256*1024) /* 1 GB */
+ return (4096); /* 16 MB */
+ if (num_blocks < 512*1024) /* 2 GB */
+ return (8192); /* 32 MB */
+ if (num_blocks < 4096*1024) /* 16 GB */
+ return (16384); /* 64 MB */
+ if (num_blocks < 8192*1024) /* 32 GB */
+ return (32768); /* 128 MB */
+ if (num_blocks < 16384*1024) /* 64 GB */
+ return (65536); /* 256 MB */
+ if (num_blocks < 32768*1024) /* 128 GB */
+ return (131072); /* 512 MB */
+ return 262144; /* 1 GB */
}
int ext2fs_journal_sb_start(int blocksize)
Allocating group tables: \b\b\b\b\bdone
Writing inode tables: \b\b\b\b\bdone
-Creating journal (32768 blocks): done
+Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: \b\b\b\b\bdone
Pass 1: Checking inodes, blocks, and sizes
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
-test_filesys: 11/262144 files (0.0% non-contiguous), 51278/1048576 blocks
+test_filesys: 11/262144 files (0.0% non-contiguous), 34894/1048576 blocks
Exit status is 0
dumpe2fs output
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
-test_filesys: 11/65536 files (0.0% non-contiguous), 52294/1048576 blocks
+test_filesys: 11/65536 files (0.0% non-contiguous), 35910/1048576 blocks
mke2fs -q -t ext4 -O bigalloc -F -o Linux -b 1024 -C 8192 test.img 10G
tune2fs -f -O ^uninit_bg test.img
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
-test_filesys: 11/655360 files (0.0% non-contiguous), 199864/10485760 blocks
+test_filesys: 11/655360 files (0.0% non-contiguous), 232632/10485760 blocks