diff mbox series

[v3,5/5] ext4: record overhead in super block

Message ID 20191120043448.249988-5-dongyangli@ddn.com
State New
Headers show
Series [v3,1/5] libext2fs: optimize ext2fs_convert_subcluster_bitmap() | expand

Commit Message

Li Dongyang Nov. 20, 2019, 4:35 a.m. UTC
Store the overhead in super block so we don't have
to calculate again during next mount.
It also gets updated after online resizing.

Signed-off-by: Li Dongyang <dongyangli@ddn.com>
---
 fs/ext4/resize.c | 1 +
 fs/ext4/super.c  | 4 ++++
 2 files changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index c0e9aef376a7..edab58c8ff20 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -1431,6 +1431,7 @@  static void ext4_update_super(struct super_block *sb,
 	 * Update the fs overhead information
 	 */
 	ext4_calculate_overhead(sb);
+	es->s_overhead_clusters = cpu_to_le32(sbi->s_overhead);
 
 	if (test_opt(sb, DEBUG))
 		printk(KERN_DEBUG "EXT4-fs: added group %u:"
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index dd654e53ba3d..c859c67cd5db 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -4467,6 +4467,10 @@  static int ext4_fill_super(struct super_block *sb, void *data, int silent)
 		err = ext4_calculate_overhead(sb);
 		if (err)
 			goto failed_mount_wq;
+		if (!sb_rdonly(sb)) {
+			es->s_overhead_clusters = cpu_to_le32(sbi->s_overhead);
+			ext4_commit_super(sb, 1);
+		}
 	}
 
 	/*