提交 56c50f11 编写于 作者: D Dmitry Monakhov 提交者: Theodore Ts'o

ext4: trivial quota cleanup

The patch is aimed to reorganize and simplify quota code a bit.
Quota code is itself complex enough, but we can make it more readable
in some places:
- Move quota option parsing to separate functions.
- Simplify old-quota and journaled-quota mix check.
Signed-off-by: NDmitry Monakhov <dmonakhov@openvz.org>
Acked-by: NJan Kara <jack@suse.cz>
Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
上级 482a7425
...@@ -1206,6 +1206,64 @@ static ext4_fsblk_t get_sb_block(void **data) ...@@ -1206,6 +1206,64 @@ static ext4_fsblk_t get_sb_block(void **data)
#define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3)) #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
#ifdef CONFIG_QUOTA
static int set_qf_name(struct super_block *sb, int qtype, substring_t *args)
{
struct ext4_sb_info *sbi = EXT4_SB(sb);
char *qname;
if (sb_any_quota_loaded(sb) &&
!sbi->s_qf_names[qtype]) {
ext4_msg(sb, KERN_ERR,
"Cannot change journaled "
"quota options when quota turned on");
return 0;
}
qname = match_strdup(args);
if (!qname) {
ext4_msg(sb, KERN_ERR,
"Not enough memory for storing quotafile name");
return 0;
}
if (sbi->s_qf_names[qtype] &&
strcmp(sbi->s_qf_names[qtype], qname)) {
ext4_msg(sb, KERN_ERR,
"%s quota file already specified", QTYPE2NAME(qtype));
kfree(qname);
return 0;
}
sbi->s_qf_names[qtype] = qname;
if (strchr(sbi->s_qf_names[qtype], '/')) {
ext4_msg(sb, KERN_ERR,
"quotafile must be on filesystem root");
kfree(sbi->s_qf_names[qtype]);
sbi->s_qf_names[qtype] = NULL;
return 0;
}
set_opt(sbi->s_mount_opt, QUOTA);
return 1;
}
static int clear_qf_name(struct super_block *sb, int qtype)
{
struct ext4_sb_info *sbi = EXT4_SB(sb);
if (sb_any_quota_loaded(sb) &&
sbi->s_qf_names[qtype]) {
ext4_msg(sb, KERN_ERR, "Cannot change journaled quota options"
" when quota turned on");
return 0;
}
/*
* The space will be released later when all options are confirmed
* to be correct
*/
sbi->s_qf_names[qtype] = NULL;
return 1;
}
#endif
static int parse_options(char *options, struct super_block *sb, static int parse_options(char *options, struct super_block *sb,
unsigned long *journal_devnum, unsigned long *journal_devnum,
unsigned int *journal_ioprio, unsigned int *journal_ioprio,
...@@ -1217,8 +1275,7 @@ static int parse_options(char *options, struct super_block *sb, ...@@ -1217,8 +1275,7 @@ static int parse_options(char *options, struct super_block *sb,
int data_opt = 0; int data_opt = 0;
int option; int option;
#ifdef CONFIG_QUOTA #ifdef CONFIG_QUOTA
int qtype, qfmt; int qfmt;
char *qname;
#endif #endif
if (!options) if (!options)
...@@ -1401,63 +1458,22 @@ static int parse_options(char *options, struct super_block *sb, ...@@ -1401,63 +1458,22 @@ static int parse_options(char *options, struct super_block *sb,
break; break;
#ifdef CONFIG_QUOTA #ifdef CONFIG_QUOTA
case Opt_usrjquota: case Opt_usrjquota:
qtype = USRQUOTA; if (!set_qf_name(sb, USRQUOTA, &args[0]))
goto set_qf_name;
case Opt_grpjquota:
qtype = GRPQUOTA;
set_qf_name:
if (sb_any_quota_loaded(sb) &&
!sbi->s_qf_names[qtype]) {
ext4_msg(sb, KERN_ERR,
"Cannot change journaled "
"quota options when quota turned on");
return 0; return 0;
} break;
qname = match_strdup(&args[0]); case Opt_grpjquota:
if (!qname) { if (!set_qf_name(sb, GRPQUOTA, &args[0]))
ext4_msg(sb, KERN_ERR,
"Not enough memory for "
"storing quotafile name");
return 0;
}
if (sbi->s_qf_names[qtype] &&
strcmp(sbi->s_qf_names[qtype], qname)) {
ext4_msg(sb, KERN_ERR,
"%s quota file already "
"specified", QTYPE2NAME(qtype));
kfree(qname);
return 0;
}
sbi->s_qf_names[qtype] = qname;
if (strchr(sbi->s_qf_names[qtype], '/')) {
ext4_msg(sb, KERN_ERR,
"quotafile must be on "
"filesystem root");
kfree(sbi->s_qf_names[qtype]);
sbi->s_qf_names[qtype] = NULL;
return 0; return 0;
}
set_opt(sbi->s_mount_opt, QUOTA);
break; break;
case Opt_offusrjquota: case Opt_offusrjquota:
qtype = USRQUOTA; if (!clear_qf_name(sb, USRQUOTA))
goto clear_qf_name; return 0;
break;
case Opt_offgrpjquota: case Opt_offgrpjquota:
qtype = GRPQUOTA; if (!clear_qf_name(sb, GRPQUOTA))
clear_qf_name:
if (sb_any_quota_loaded(sb) &&
sbi->s_qf_names[qtype]) {
ext4_msg(sb, KERN_ERR, "Cannot change "
"journaled quota options when "
"quota turned on");
return 0; return 0;
}
/*
* The space will be released later when all options
* are confirmed to be correct
*/
sbi->s_qf_names[qtype] = NULL;
break; break;
case Opt_jqfmt_vfsold: case Opt_jqfmt_vfsold:
qfmt = QFMT_VFS_OLD; qfmt = QFMT_VFS_OLD;
goto set_qf_format; goto set_qf_format;
...@@ -1630,8 +1646,7 @@ static int parse_options(char *options, struct super_block *sb, ...@@ -1630,8 +1646,7 @@ static int parse_options(char *options, struct super_block *sb,
if (test_opt(sb, GRPQUOTA) && sbi->s_qf_names[GRPQUOTA]) if (test_opt(sb, GRPQUOTA) && sbi->s_qf_names[GRPQUOTA])
clear_opt(sbi->s_mount_opt, GRPQUOTA); clear_opt(sbi->s_mount_opt, GRPQUOTA);
if ((sbi->s_qf_names[USRQUOTA] && test_opt(sb, GRPQUOTA)) || if (test_opt(sb, GRPQUOTA) || test_opt(sb, USRQUOTA)) {
(sbi->s_qf_names[GRPQUOTA] && test_opt(sb, USRQUOTA))) {
ext4_msg(sb, KERN_ERR, "old and new quota " ext4_msg(sb, KERN_ERR, "old and new quota "
"format mixing"); "format mixing");
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册