mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	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 <tytso@mit.edu> Cc: stable@kernel.org
This commit is contained in:
		
							parent
							
								
									85d825dbf4
								
							
						
					
					
						commit
						eb7054212e
					
				
					 3 changed files with 19 additions and 0 deletions
				
			
		| 
						 | 
					@ -3068,6 +3068,7 @@ int ext4_fileattr_set(struct user_namespace *mnt_userns,
 | 
				
			||||||
		      struct dentry *dentry, struct fileattr *fa);
 | 
							      struct dentry *dentry, struct fileattr *fa);
 | 
				
			||||||
int ext4_fileattr_get(struct dentry *dentry, struct fileattr *fa);
 | 
					int ext4_fileattr_get(struct dentry *dentry, struct fileattr *fa);
 | 
				
			||||||
extern void ext4_reset_inode_seed(struct inode *inode);
 | 
					extern void ext4_reset_inode_seed(struct inode *inode);
 | 
				
			||||||
 | 
					int ext4_update_overhead(struct super_block *sb);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* migrate.c */
 | 
					/* migrate.c */
 | 
				
			||||||
extern int ext4_ext_migrate(struct inode *);
 | 
					extern int ext4_ext_migrate(struct inode *);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1652,3 +1652,19 @@ long ext4_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 | 
				
			||||||
	return ext4_ioctl(file, cmd, (unsigned long) compat_ptr(arg));
 | 
						return ext4_ioctl(file, cmd, (unsigned long) compat_ptr(arg));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void set_overhead(struct ext4_super_block *es, const void *arg)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						es->s_overhead_clusters = cpu_to_le32(*((unsigned long *) arg));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int ext4_update_overhead(struct super_block *sb)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct ext4_sb_info *sbi = EXT4_SB(sb);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (sb_rdonly(sb) || sbi->s_overhead == 0 ||
 | 
				
			||||||
 | 
						    sbi->s_overhead == le32_to_cpu(sbi->s_es->s_overhead_clusters))
 | 
				
			||||||
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return ext4_update_superblocks_fn(sb, set_overhead, &sbi->s_overhead);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5618,6 +5618,8 @@ static int ext4_fill_super(struct super_block *sb, struct fs_context *fc)
 | 
				
			||||||
		ext4_msg(sb, KERN_INFO, "mounted filesystem with%s. "
 | 
							ext4_msg(sb, KERN_INFO, "mounted filesystem with%s. "
 | 
				
			||||||
			 "Quota mode: %s.", descr, ext4_quota_mode(sb));
 | 
								 "Quota mode: %s.", descr, ext4_quota_mode(sb));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* Update the s_overhead_clusters if necessary */
 | 
				
			||||||
 | 
						ext4_update_overhead(sb);
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
free_sbi:
 | 
					free_sbi:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue