Skip to content

Commit 57f73c2

Browse files
committed
ext4: fix handling of journalled quota options
Commit 26092bf broke handling of journalled quota mount options by trying to parse argument of every mount option as a number. Fix this by dealing with the quota options before we call match_int(). Thanks to Jan Kara for discovering this regression. Signed-off-by: "Theodore Ts'o" <[email protected]> Reviewed-by: Jan Kara <[email protected]>
1 parent 9cd70b3 commit 57f73c2

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

fs/ext4/super.c

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,28 +1305,28 @@ static int set_qf_name(struct super_block *sb, int qtype, substring_t *args)
13051305
ext4_msg(sb, KERN_ERR,
13061306
"Cannot change journaled "
13071307
"quota options when quota turned on");
1308-
return 0;
1308+
return -1;
13091309
}
13101310
qname = match_strdup(args);
13111311
if (!qname) {
13121312
ext4_msg(sb, KERN_ERR,
13131313
"Not enough memory for storing quotafile name");
1314-
return 0;
1314+
return -1;
13151315
}
13161316
if (sbi->s_qf_names[qtype] &&
13171317
strcmp(sbi->s_qf_names[qtype], qname)) {
13181318
ext4_msg(sb, KERN_ERR,
13191319
"%s quota file already specified", QTYPE2NAME(qtype));
13201320
kfree(qname);
1321-
return 0;
1321+
return -1;
13221322
}
13231323
sbi->s_qf_names[qtype] = qname;
13241324
if (strchr(sbi->s_qf_names[qtype], '/')) {
13251325
ext4_msg(sb, KERN_ERR,
13261326
"quotafile must be on filesystem root");
13271327
kfree(sbi->s_qf_names[qtype]);
13281328
sbi->s_qf_names[qtype] = NULL;
1329-
return 0;
1329+
return -1;
13301330
}
13311331
set_opt(sb, QUOTA);
13321332
return 1;
@@ -1341,7 +1341,7 @@ static int clear_qf_name(struct super_block *sb, int qtype)
13411341
sbi->s_qf_names[qtype]) {
13421342
ext4_msg(sb, KERN_ERR, "Cannot change journaled quota options"
13431343
" when quota turned on");
1344-
return 0;
1344+
return -1;
13451345
}
13461346
/*
13471347
* The space will be released later when all options are confirmed
@@ -1450,6 +1450,16 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
14501450
const struct mount_opts *m;
14511451
int arg = 0;
14521452

1453+
#ifdef CONFIG_QUOTA
1454+
if (token == Opt_usrjquota)
1455+
return set_qf_name(sb, USRQUOTA, &args[0]);
1456+
else if (token == Opt_grpjquota)
1457+
return set_qf_name(sb, GRPQUOTA, &args[0]);
1458+
else if (token == Opt_offusrjquota)
1459+
return clear_qf_name(sb, USRQUOTA);
1460+
else if (token == Opt_offgrpjquota)
1461+
return clear_qf_name(sb, GRPQUOTA);
1462+
#endif
14531463
if (args->from && match_int(args, &arg))
14541464
return -1;
14551465
switch (token) {
@@ -1549,18 +1559,6 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
15491559
sbi->s_mount_opt |= m->mount_opt;
15501560
}
15511561
#ifdef CONFIG_QUOTA
1552-
} else if (token == Opt_usrjquota) {
1553-
if (!set_qf_name(sb, USRQUOTA, &args[0]))
1554-
return -1;
1555-
} else if (token == Opt_grpjquota) {
1556-
if (!set_qf_name(sb, GRPQUOTA, &args[0]))
1557-
return -1;
1558-
} else if (token == Opt_offusrjquota) {
1559-
if (!clear_qf_name(sb, USRQUOTA))
1560-
return -1;
1561-
} else if (token == Opt_offgrpjquota) {
1562-
if (!clear_qf_name(sb, GRPQUOTA))
1563-
return -1;
15641562
} else if (m->flags & MOPT_QFMT) {
15651563
if (sb_any_quota_loaded(sb) &&
15661564
sbi->s_jquota_fmt != m->mount_opt) {

0 commit comments

Comments
 (0)