1 ext4: use journal inode to determine journal overhead
3 From: Eric Whitney <enwlinux@gmail.com>
5 When a file system contains an internal journal that has not been
6 loaded, use the journal inode's i_size field to determine its
7 contribution to the file system's overhead. (The journal's j_maxlen
8 field is normally used to determine its size, but it's unavailable when
9 the journal has not been loaded.)
11 Signed-off-by: Eric Whitney <enwlinux@gmail.com>
12 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
14 fs/ext4/super.c | 19 +++++++++++++++++--
15 1 file changed, 17 insertions(+), 2 deletions(-)
17 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
18 index 4b0ca25..1a7b6fd 100644
21 @@ -3210,6 +3210,8 @@ int ext4_calculate_overhead(struct super_block *sb)
23 struct ext4_sb_info *sbi = EXT4_SB(sb);
24 struct ext4_super_block *es = sbi->s_es;
25 + struct inode *j_inode;
26 + unsigned int j_blocks, j_inum = le32_to_cpu(es->s_journal_inum);
27 ext4_group_t i, ngroups = ext4_get_groups_count(sb);
28 ext4_fsblk_t overhead = 0;
29 char *buf = (char *) get_zeroed_page(GFP_NOFS);
30 @@ -3240,10 +3242,23 @@ int ext4_calculate_overhead(struct super_block *sb)
31 memset(buf, 0, PAGE_SIZE);
34 - /* Add the internal journal blocks as well */
37 + * Add the internal journal blocks whether the journal has been
40 if (sbi->s_journal && !sbi->journal_bdev)
41 overhead += EXT4_NUM_B2C(sbi, sbi->s_journal->j_maxlen);
43 + else if (ext4_has_feature_journal(sb) && !sbi->s_journal) {
44 + j_inode = ext4_get_journal_inode(sb, j_inum);
46 + j_blocks = j_inode->i_size >> sb->s_blocksize_bits;
47 + overhead += EXT4_NUM_B2C(sbi, j_blocks);
50 + ext4_msg(sb, KERN_ERR, "can't get journal size");
53 sbi->s_overhead = overhead;
55 free_page((unsigned long) buf);