Skip to content

Commit eb70542

Browse files
committed
ext4: update the cached overhead value in the superblock
If we (re-)calculate the file system overhead amount and it's different from the on-disk s_overhead_clusters value, update the on-disk version since this can take potentially quite a while on bigalloc file systems. Signed-off-by: Theodore Ts'o <[email protected]> Cc: [email protected]
1 parent 85d825d commit eb70542

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

fs/ext4/ext4.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3068,6 +3068,7 @@ int ext4_fileattr_set(struct user_namespace *mnt_userns,
30683068
struct dentry *dentry, struct fileattr *fa);
30693069
int ext4_fileattr_get(struct dentry *dentry, struct fileattr *fa);
30703070
extern void ext4_reset_inode_seed(struct inode *inode);
3071+
int ext4_update_overhead(struct super_block *sb);
30713072

30723073
/* migrate.c */
30733074
extern int ext4_ext_migrate(struct inode *);

fs/ext4/ioctl.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,3 +1652,19 @@ long ext4_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
16521652
return ext4_ioctl(file, cmd, (unsigned long) compat_ptr(arg));
16531653
}
16541654
#endif
1655+
1656+
static void set_overhead(struct ext4_super_block *es, const void *arg)
1657+
{
1658+
es->s_overhead_clusters = cpu_to_le32(*((unsigned long *) arg));
1659+
}
1660+
1661+
int ext4_update_overhead(struct super_block *sb)
1662+
{
1663+
struct ext4_sb_info *sbi = EXT4_SB(sb);
1664+
1665+
if (sb_rdonly(sb) || sbi->s_overhead == 0 ||
1666+
sbi->s_overhead == le32_to_cpu(sbi->s_es->s_overhead_clusters))
1667+
return 0;
1668+
1669+
return ext4_update_superblocks_fn(sb, set_overhead, &sbi->s_overhead);
1670+
}

fs/ext4/super.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5618,6 +5618,8 @@ static int ext4_fill_super(struct super_block *sb, struct fs_context *fc)
56185618
ext4_msg(sb, KERN_INFO, "mounted filesystem with%s. "
56195619
"Quota mode: %s.", descr, ext4_quota_mode(sb));
56205620

5621+
/* Update the s_overhead_clusters if necessary */
5622+
ext4_update_overhead(sb);
56215623
return 0;
56225624

56235625
free_sbi:

0 commit comments

Comments
 (0)