ext4: factor out ext4_set_def_opts()
Factor out ext4_set_def_opts(). No functional change. Signed-off-by: Jason Yan <yanaijie@huawei.com> Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com> Link: https://lore.kernel.org/r/20220916141527.1012715-4-yanaijie@huawei.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
parent
a5fc511935
commit
5f6d662d12
105
fs/ext4/super.c
105
fs/ext4/super.c
@ -4282,6 +4282,61 @@ err_out:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ext4_set_def_opts(struct super_block *sb,
|
||||||
|
struct ext4_super_block *es)
|
||||||
|
{
|
||||||
|
unsigned long def_mount_opts;
|
||||||
|
|
||||||
|
/* Set defaults before we parse the mount options */
|
||||||
|
def_mount_opts = le32_to_cpu(es->s_default_mount_opts);
|
||||||
|
set_opt(sb, INIT_INODE_TABLE);
|
||||||
|
if (def_mount_opts & EXT4_DEFM_DEBUG)
|
||||||
|
set_opt(sb, DEBUG);
|
||||||
|
if (def_mount_opts & EXT4_DEFM_BSDGROUPS)
|
||||||
|
set_opt(sb, GRPID);
|
||||||
|
if (def_mount_opts & EXT4_DEFM_UID16)
|
||||||
|
set_opt(sb, NO_UID32);
|
||||||
|
/* xattr user namespace & acls are now defaulted on */
|
||||||
|
set_opt(sb, XATTR_USER);
|
||||||
|
#ifdef CONFIG_EXT4_FS_POSIX_ACL
|
||||||
|
set_opt(sb, POSIX_ACL);
|
||||||
|
#endif
|
||||||
|
if (ext4_has_feature_fast_commit(sb))
|
||||||
|
set_opt2(sb, JOURNAL_FAST_COMMIT);
|
||||||
|
/* don't forget to enable journal_csum when metadata_csum is enabled. */
|
||||||
|
if (ext4_has_metadata_csum(sb))
|
||||||
|
set_opt(sb, JOURNAL_CHECKSUM);
|
||||||
|
|
||||||
|
if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_DATA)
|
||||||
|
set_opt(sb, JOURNAL_DATA);
|
||||||
|
else if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_ORDERED)
|
||||||
|
set_opt(sb, ORDERED_DATA);
|
||||||
|
else if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_WBACK)
|
||||||
|
set_opt(sb, WRITEBACK_DATA);
|
||||||
|
|
||||||
|
if (le16_to_cpu(es->s_errors) == EXT4_ERRORS_PANIC)
|
||||||
|
set_opt(sb, ERRORS_PANIC);
|
||||||
|
else if (le16_to_cpu(es->s_errors) == EXT4_ERRORS_CONTINUE)
|
||||||
|
set_opt(sb, ERRORS_CONT);
|
||||||
|
else
|
||||||
|
set_opt(sb, ERRORS_RO);
|
||||||
|
/* block_validity enabled by default; disable with noblock_validity */
|
||||||
|
set_opt(sb, BLOCK_VALIDITY);
|
||||||
|
if (def_mount_opts & EXT4_DEFM_DISCARD)
|
||||||
|
set_opt(sb, DISCARD);
|
||||||
|
|
||||||
|
if ((def_mount_opts & EXT4_DEFM_NOBARRIER) == 0)
|
||||||
|
set_opt(sb, BARRIER);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* enable delayed allocation by default
|
||||||
|
* Use -o nodelalloc to turn it off
|
||||||
|
*/
|
||||||
|
if (!IS_EXT3_SB(sb) && !IS_EXT2_SB(sb) &&
|
||||||
|
((def_mount_opts & EXT4_DEFM_NODELALLOC) == 0))
|
||||||
|
set_opt(sb, DELALLOC);
|
||||||
|
}
|
||||||
|
|
||||||
static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
|
static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
|
||||||
{
|
{
|
||||||
struct buffer_head *bh, **group_desc;
|
struct buffer_head *bh, **group_desc;
|
||||||
@ -4291,7 +4346,6 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
|
|||||||
ext4_fsblk_t block;
|
ext4_fsblk_t block;
|
||||||
ext4_fsblk_t logical_sb_block;
|
ext4_fsblk_t logical_sb_block;
|
||||||
unsigned long offset = 0;
|
unsigned long offset = 0;
|
||||||
unsigned long def_mount_opts;
|
|
||||||
struct inode *root;
|
struct inode *root;
|
||||||
int ret = -ENOMEM;
|
int ret = -ENOMEM;
|
||||||
int blocksize, clustersize;
|
int blocksize, clustersize;
|
||||||
@ -4391,43 +4445,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
|
|||||||
sbi->s_csum_seed = ext4_chksum(sbi, ~0, es->s_uuid,
|
sbi->s_csum_seed = ext4_chksum(sbi, ~0, es->s_uuid,
|
||||||
sizeof(es->s_uuid));
|
sizeof(es->s_uuid));
|
||||||
|
|
||||||
/* Set defaults before we parse the mount options */
|
ext4_set_def_opts(sb, es);
|
||||||
def_mount_opts = le32_to_cpu(es->s_default_mount_opts);
|
|
||||||
set_opt(sb, INIT_INODE_TABLE);
|
|
||||||
if (def_mount_opts & EXT4_DEFM_DEBUG)
|
|
||||||
set_opt(sb, DEBUG);
|
|
||||||
if (def_mount_opts & EXT4_DEFM_BSDGROUPS)
|
|
||||||
set_opt(sb, GRPID);
|
|
||||||
if (def_mount_opts & EXT4_DEFM_UID16)
|
|
||||||
set_opt(sb, NO_UID32);
|
|
||||||
/* xattr user namespace & acls are now defaulted on */
|
|
||||||
set_opt(sb, XATTR_USER);
|
|
||||||
#ifdef CONFIG_EXT4_FS_POSIX_ACL
|
|
||||||
set_opt(sb, POSIX_ACL);
|
|
||||||
#endif
|
|
||||||
if (ext4_has_feature_fast_commit(sb))
|
|
||||||
set_opt2(sb, JOURNAL_FAST_COMMIT);
|
|
||||||
/* don't forget to enable journal_csum when metadata_csum is enabled. */
|
|
||||||
if (ext4_has_metadata_csum(sb))
|
|
||||||
set_opt(sb, JOURNAL_CHECKSUM);
|
|
||||||
|
|
||||||
if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_DATA)
|
|
||||||
set_opt(sb, JOURNAL_DATA);
|
|
||||||
else if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_ORDERED)
|
|
||||||
set_opt(sb, ORDERED_DATA);
|
|
||||||
else if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_WBACK)
|
|
||||||
set_opt(sb, WRITEBACK_DATA);
|
|
||||||
|
|
||||||
if (le16_to_cpu(sbi->s_es->s_errors) == EXT4_ERRORS_PANIC)
|
|
||||||
set_opt(sb, ERRORS_PANIC);
|
|
||||||
else if (le16_to_cpu(sbi->s_es->s_errors) == EXT4_ERRORS_CONTINUE)
|
|
||||||
set_opt(sb, ERRORS_CONT);
|
|
||||||
else
|
|
||||||
set_opt(sb, ERRORS_RO);
|
|
||||||
/* block_validity enabled by default; disable with noblock_validity */
|
|
||||||
set_opt(sb, BLOCK_VALIDITY);
|
|
||||||
if (def_mount_opts & EXT4_DEFM_DISCARD)
|
|
||||||
set_opt(sb, DISCARD);
|
|
||||||
|
|
||||||
sbi->s_resuid = make_kuid(&init_user_ns, le16_to_cpu(es->s_def_resuid));
|
sbi->s_resuid = make_kuid(&init_user_ns, le16_to_cpu(es->s_def_resuid));
|
||||||
sbi->s_resgid = make_kgid(&init_user_ns, le16_to_cpu(es->s_def_resgid));
|
sbi->s_resgid = make_kgid(&init_user_ns, le16_to_cpu(es->s_def_resgid));
|
||||||
@ -4435,17 +4453,6 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
|
|||||||
sbi->s_min_batch_time = EXT4_DEF_MIN_BATCH_TIME;
|
sbi->s_min_batch_time = EXT4_DEF_MIN_BATCH_TIME;
|
||||||
sbi->s_max_batch_time = EXT4_DEF_MAX_BATCH_TIME;
|
sbi->s_max_batch_time = EXT4_DEF_MAX_BATCH_TIME;
|
||||||
|
|
||||||
if ((def_mount_opts & EXT4_DEFM_NOBARRIER) == 0)
|
|
||||||
set_opt(sb, BARRIER);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* enable delayed allocation by default
|
|
||||||
* Use -o nodelalloc to turn it off
|
|
||||||
*/
|
|
||||||
if (!IS_EXT3_SB(sb) && !IS_EXT2_SB(sb) &&
|
|
||||||
((def_mount_opts & EXT4_DEFM_NODELALLOC) == 0))
|
|
||||||
set_opt(sb, DELALLOC);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* set default s_li_wait_mult for lazyinit, for the case there is
|
* set default s_li_wait_mult for lazyinit, for the case there is
|
||||||
* no mount option specified.
|
* no mount option specified.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user