Skip to content

Commit e6fd5d3

Browse files
YuezhangMonamjaejeon
authored andcommitted
exfat: support modifying mount options via remount
Before this commit, all exfat-defined mount options could not be modified dynamically via remount, and no error was returned. After this commit, these three exfat-defined mount options (discard, zero_size_dir, and errors) can be modified dynamically via remount. While other exfat-defined mount options cannot be modified dynamically via remount because their old settings are cached in inodes or dentries, modifying them will be rejected with an error. Signed-off-by: Yuezhang Mo <[email protected]> Signed-off-by: Namjae Jeon <[email protected]>
1 parent 9fd6886 commit e6fd5d3

File tree

1 file changed

+38
-6
lines changed

1 file changed

+38
-6
lines changed

fs/exfat/super.c

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,11 @@ static const struct fs_parameter_spec exfat_parameters[] = {
243243
fsparam_u32oct("allow_utime", Opt_allow_utime),
244244
fsparam_string("iocharset", Opt_charset),
245245
fsparam_enum("errors", Opt_errors, exfat_param_enums),
246-
fsparam_flag("discard", Opt_discard),
246+
fsparam_flag_no("discard", Opt_discard),
247247
fsparam_flag("keep_last_dots", Opt_keep_last_dots),
248248
fsparam_flag("sys_tz", Opt_sys_tz),
249249
fsparam_s32("time_offset", Opt_time_offset),
250-
fsparam_flag("zero_size_dir", Opt_zero_size_dir),
250+
fsparam_flag_no("zero_size_dir", Opt_zero_size_dir),
251251
__fsparam(NULL, "utf8", Opt_utf8, fs_param_deprecated,
252252
NULL),
253253
__fsparam(NULL, "debug", Opt_debug, fs_param_deprecated,
@@ -299,7 +299,7 @@ static int exfat_parse_param(struct fs_context *fc, struct fs_parameter *param)
299299
opts->errors = result.uint_32;
300300
break;
301301
case Opt_discard:
302-
opts->discard = 1;
302+
opts->discard = !result.negated;
303303
break;
304304
case Opt_keep_last_dots:
305305
opts->keep_last_dots = 1;
@@ -317,7 +317,7 @@ static int exfat_parse_param(struct fs_context *fc, struct fs_parameter *param)
317317
opts->time_offset = result.int_32;
318318
break;
319319
case Opt_zero_size_dir:
320-
opts->zero_size_dir = true;
320+
opts->zero_size_dir = !result.negated;
321321
break;
322322
case Opt_utf8:
323323
case Opt_debug:
@@ -742,12 +742,44 @@ static void exfat_free(struct fs_context *fc)
742742
static int exfat_reconfigure(struct fs_context *fc)
743743
{
744744
struct super_block *sb = fc->root->d_sb;
745+
struct exfat_sb_info *remount_sbi = fc->s_fs_info;
746+
struct exfat_sb_info *sbi = EXFAT_SB(sb);
747+
struct exfat_mount_options *new_opts = &remount_sbi->options;
748+
struct exfat_mount_options *cur_opts = &sbi->options;
749+
745750
fc->sb_flags |= SB_NODIRATIME;
746751

747752
sync_filesystem(sb);
748-
mutex_lock(&EXFAT_SB(sb)->s_lock);
753+
mutex_lock(&sbi->s_lock);
749754
exfat_clear_volume_dirty(sb);
750-
mutex_unlock(&EXFAT_SB(sb)->s_lock);
755+
mutex_unlock(&sbi->s_lock);
756+
757+
if (new_opts->allow_utime == (unsigned short)-1)
758+
new_opts->allow_utime = ~new_opts->fs_dmask & 0022;
759+
760+
/*
761+
* Since the old settings of these mount options are cached in
762+
* inodes or dentries, they cannot be modified dynamically.
763+
*/
764+
if (strcmp(new_opts->iocharset, cur_opts->iocharset) ||
765+
new_opts->keep_last_dots != cur_opts->keep_last_dots ||
766+
new_opts->sys_tz != cur_opts->sys_tz ||
767+
new_opts->time_offset != cur_opts->time_offset ||
768+
!uid_eq(new_opts->fs_uid, cur_opts->fs_uid) ||
769+
!gid_eq(new_opts->fs_gid, cur_opts->fs_gid) ||
770+
new_opts->fs_fmask != cur_opts->fs_fmask ||
771+
new_opts->fs_dmask != cur_opts->fs_dmask ||
772+
new_opts->allow_utime != cur_opts->allow_utime)
773+
return -EINVAL;
774+
775+
if (new_opts->discard != cur_opts->discard &&
776+
new_opts->discard &&
777+
!bdev_max_discard_sectors(sb->s_bdev)) {
778+
exfat_warn(sb, "remounting with \"discard\" option, but the device does not support discard");
779+
return -EINVAL;
780+
}
781+
782+
swap(*cur_opts, *new_opts);
751783

752784
return 0;
753785
}

0 commit comments

Comments
 (0)