Skip to content

Commit 5bbb7a7

Browse files
tytsogregkh
authored andcommitted
ext4: update the cached overhead value in the superblock
commit eb70542 upstream. 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] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent b95e34b commit 5bbb7a7

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
@@ -3066,6 +3066,7 @@ int ext4_fileattr_set(struct user_namespace *mnt_userns,
30663066
struct dentry *dentry, struct fileattr *fa);
30673067
int ext4_fileattr_get(struct dentry *dentry, struct fileattr *fa);
30683068
extern void ext4_reset_inode_seed(struct inode *inode);
3069+
int ext4_update_overhead(struct super_block *sb);
30693070

30703071
/* migrate.c */
30713072
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
@@ -5597,6 +5597,8 @@ static int ext4_fill_super(struct super_block *sb, struct fs_context *fc)
55975597
ext4_msg(sb, KERN_INFO, "mounted filesystem with%s. "
55985598
"Quota mode: %s.", descr, ext4_quota_mode(sb));
55995599

5600+
/* Update the s_overhead_clusters if necessary */
5601+
ext4_update_overhead(sb);
56005602
return 0;
56015603

56025604
free_sbi:

0 commit comments

Comments
 (0)