All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] ext4: Don't allow quota mount options when quota feature enabled
@ 2013-02-25 23:36 Jan Kara
  2013-02-25 23:36 ` [PATCH 2/2] ext4: Enable quotas before orphan cleanup Jan Kara
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jan Kara @ 2013-02-25 23:36 UTC (permalink / raw)
  To: Ted Tso; +Cc: linux-ext4, Jan Kara

So far we silently ignored when quota mount options were set while quota
feature was enabled. But this can create confusion in userspace when
mount options are set but silently ignored and also creates opportunities
for bugs when we don't properly test all quota types. Actually
ext4_mark_dquot_dirty() forgets to test for quota feature so it was
dependent on journaled quota options being set. OTOH ext4_orphan_cleanup()
tries to enable journaled quota when quota options are specified which is
wrong when quota feature is enabled.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/ext4/super.c |   33 ++++++++++++++++++++++++++-------
 1 files changed, 26 insertions(+), 7 deletions(-)

I've spotted two issues with quota feature in kernel when reviewing Jeff's
patch. So here are the fixes.

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 161f043..1746a6e 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1345,6 +1345,11 @@ static int set_qf_name(struct super_block *sb, int qtype, substring_t *args)
 			"quota options when quota turned on");
 		return -1;
 	}
+	if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA)) {
+		ext4_msg(sb, KERN_ERR, "Cannot set journaled quota options "
+			 "when QUOTA feature is enabled");
+		return -1;
+	}
 	qname = match_strdup(args);
 	if (!qname) {
 		ext4_msg(sb, KERN_ERR,
@@ -1615,6 +1620,13 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
 					 "when quota turned on");
 				return -1;
 			}
+			if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
+						EXT4_FEATURE_RO_COMPAT_QUOTA)) {
+				ext4_msg(sb, KERN_ERR,
+					 "Cannot set journaled quota options "
+					 "when QUOTA feature is enabled");
+				return -1;
+			}
 			sbi->s_jquota_fmt = m->mount_opt;
 #endif
 		} else {
@@ -1667,6 +1679,12 @@ static int parse_options(char *options, struct super_block *sb,
 			return 0;
 	}
 #ifdef CONFIG_QUOTA
+	if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA) &&
+	    (test_opt(sb, USRQUOTA) || test_opt(sb, GRPQUOTA))) {
+		ext4_msg(sb, KERN_ERR, "Cannot set quota options when QUOTA "
+			 "feature is enabled");
+		return 0;
+	}
 	if (sbi->s_qf_names[USRQUOTA] || sbi->s_qf_names[GRPQUOTA]) {
 		if (test_opt(sb, USRQUOTA) && sbi->s_qf_names[USRQUOTA])
 			clear_opt(sb, USRQUOTA);
@@ -3783,13 +3801,11 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
 	sb->s_export_op = &ext4_export_ops;
 	sb->s_xattr = ext4_xattr_handlers;
 #ifdef CONFIG_QUOTA
-	sb->s_qcop = &ext4_qctl_operations;
 	sb->dq_op = &ext4_quota_operations;
-
-	if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA)) {
-		/* Use qctl operations for hidden quota files. */
+	if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA))
 		sb->s_qcop = &ext4_qctl_sysfile_operations;
-	}
+	else
+		sb->s_qcop = &ext4_qctl_operations;
 #endif
 	memcpy(sb->s_uuid, es->s_uuid, sizeof(es->s_uuid));
 
@@ -4887,9 +4903,12 @@ static int ext4_release_dquot(struct dquot *dquot)
 
 static int ext4_mark_dquot_dirty(struct dquot *dquot)
 {
+	struct super_block *sb = dquot->dq_sb;
+	struct ext4_sb_info *sbi = EXT4_SB(sb);
+
 	/* Are we journaling quotas? */
-	if (EXT4_SB(dquot->dq_sb)->s_qf_names[USRQUOTA] ||
-	    EXT4_SB(dquot->dq_sb)->s_qf_names[GRPQUOTA]) {
+	if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA) ||
+	    sbi->s_qf_names[USRQUOTA] || sbi->s_qf_names[GRPQUOTA]) {
 		dquot_mark_dquot_dirty(dquot);
 		return ext4_write_dquot(dquot);
 	} else {
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] ext4: Enable quotas before orphan cleanup
  2013-02-25 23:36 [PATCH 1/2] ext4: Don't allow quota mount options when quota feature enabled Jan Kara
@ 2013-02-25 23:36 ` Jan Kara
  2013-03-02 23:04   ` Theodore Ts'o
  2013-02-26  0:39 ` [PATCH 1/2] ext4: Don't allow quota mount options when quota feature enabled Theodore Ts'o
  2013-03-02 23:04 ` Theodore Ts'o
  2 siblings, 1 reply; 6+ messages in thread
From: Jan Kara @ 2013-02-25 23:36 UTC (permalink / raw)
  To: Ted Tso; +Cc: linux-ext4, Jan Kara

When using quota feature we need to enable quotas before orphan cleanup
so that changes happening during it are properly reflected in quota
accounting.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/ext4/super.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

This is based on Jeff Mahoney's patch to tear down kobj when quota init fails:
ext4: cleanup sbi->s_kobj after quota initialization failure

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 1746a6e..ef1c69e 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -4001,6 +4001,16 @@ no_journal:
 	if (err)
 		goto failed_mount7;
 
+#ifdef CONFIG_QUOTA
+	/* Enable quota usage during mount. */
+	if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA) &&
+	    !(sb->s_flags & MS_RDONLY)) {
+		err = ext4_enable_quotas(sb);
+		if (err)
+			goto failed_mount8;
+	}
+#endif  /* CONFIG_QUOTA */
+
 	EXT4_SB(sb)->s_mount_state |= EXT4_ORPHAN_FS;
 	ext4_orphan_cleanup(sb, es);
 	EXT4_SB(sb)->s_mount_state &= ~EXT4_ORPHAN_FS;
@@ -4018,16 +4028,6 @@ no_journal:
 	} else
 		descr = "out journal";
 
-#ifdef CONFIG_QUOTA
-	/* Enable quota usage during mount. */
-	if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA) &&
-	    !(sb->s_flags & MS_RDONLY)) {
-		err = ext4_enable_quotas(sb);
-		if (err)
-			goto failed_mount8;
-	}
-#endif  /* CONFIG_QUOTA */

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] ext4: Don't allow quota mount options when quota feature enabled
  2013-02-25 23:36 [PATCH 1/2] ext4: Don't allow quota mount options when quota feature enabled Jan Kara
  2013-02-25 23:36 ` [PATCH 2/2] ext4: Enable quotas before orphan cleanup Jan Kara
@ 2013-02-26  0:39 ` Theodore Ts'o
  2013-02-26 13:18   ` Jan Kara
  2013-03-02 23:04 ` Theodore Ts'o
  2 siblings, 1 reply; 6+ messages in thread
From: Theodore Ts'o @ 2013-02-26  0:39 UTC (permalink / raw)
  To: Jan Kara; +Cc: linux-ext4

On Tue, Feb 26, 2013 at 12:36:08AM +0100, Jan Kara wrote:
> So far we silently ignored when quota mount options were set while quota
> feature was enabled. But this can create confusion in userspace when
> mount options are set but silently ignored and also creates opportunities
> for bugs when we don't properly test all quota types. Actually
> ext4_mark_dquot_dirty() forgets to test for quota feature so it was
> dependent on journaled quota options being set. OTOH ext4_orphan_cleanup()
> tries to enable journaled quota when quota options are specified which is
> wrong when quota feature is enabled.
> 
> Signed-off-by: Jan Kara <jack@suse.cz>

I've been using the quota mount options since it's the only way to
test the quota patches when using an older version of the quota
userspace package.

I can build a newer version of the userspace quota package for my own
use (since version 4.01 isn't in Debian Testing yet nor Ubuntu yet),
but we probably need to make sure we document that users may need to
build their own version of the quota package.

      	    		       	     - Ted

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] ext4: Don't allow quota mount options when quota feature enabled
  2013-02-26  0:39 ` [PATCH 1/2] ext4: Don't allow quota mount options when quota feature enabled Theodore Ts'o
@ 2013-02-26 13:18   ` Jan Kara
  0 siblings, 0 replies; 6+ messages in thread
From: Jan Kara @ 2013-02-26 13:18 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: Jan Kara, linux-ext4

On Mon 25-02-13 19:39:43, Ted Tso wrote:
> On Tue, Feb 26, 2013 at 12:36:08AM +0100, Jan Kara wrote:
> > So far we silently ignored when quota mount options were set while quota
> > feature was enabled. But this can create confusion in userspace when
> > mount options are set but silently ignored and also creates opportunities
> > for bugs when we don't properly test all quota types. Actually
> > ext4_mark_dquot_dirty() forgets to test for quota feature so it was
> > dependent on journaled quota options being set. OTOH ext4_orphan_cleanup()
> > tries to enable journaled quota when quota options are specified which is
> > wrong when quota feature is enabled.
> > 
> > Signed-off-by: Jan Kara <jack@suse.cz>
> 
> I've been using the quota mount options since it's the only way to
> test the quota patches when using an older version of the quota
> userspace package.
  Yeah, I know it's useful at moments to be able to use quota mount options
even with quota feature. But older quota tools behave strangely with quota
feature anyway at times so for production use I'd suggest at least version
4.01 anyway. That's why I decided forcing quota mount options off with
quota feature because that's going to cause the least confusion long term
IMHO.

> I can build a newer version of the userspace quota package for my own
> use (since version 4.01 isn't in Debian Testing yet nor Ubuntu yet),
> but we probably need to make sure we document that users may need to
> build their own version of the quota package.
  True, I guess adding that to mke2fs manpage would be appropriate?

								Honza
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] ext4: Don't allow quota mount options when quota feature enabled
  2013-02-25 23:36 [PATCH 1/2] ext4: Don't allow quota mount options when quota feature enabled Jan Kara
  2013-02-25 23:36 ` [PATCH 2/2] ext4: Enable quotas before orphan cleanup Jan Kara
  2013-02-26  0:39 ` [PATCH 1/2] ext4: Don't allow quota mount options when quota feature enabled Theodore Ts'o
@ 2013-03-02 23:04 ` Theodore Ts'o
  2 siblings, 0 replies; 6+ messages in thread
From: Theodore Ts'o @ 2013-03-02 23:04 UTC (permalink / raw)
  To: Jan Kara; +Cc: linux-ext4

On Tue, Feb 26, 2013 at 12:36:08AM +0100, Jan Kara wrote:
> So far we silently ignored when quota mount options were set while quota
> feature was enabled. But this can create confusion in userspace when
> mount options are set but silently ignored and also creates opportunities
> for bugs when we don't properly test all quota types. Actually
> ext4_mark_dquot_dirty() forgets to test for quota feature so it was
> dependent on journaled quota options being set. OTOH ext4_orphan_cleanup()
> tries to enable journaled quota when quota options are specified which is
> wrong when quota feature is enabled.
> 
> Signed-off-by: Jan Kara <jack@suse.cz>

Thanks, applied.

					- Ted

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] ext4: Enable quotas before orphan cleanup
  2013-02-25 23:36 ` [PATCH 2/2] ext4: Enable quotas before orphan cleanup Jan Kara
@ 2013-03-02 23:04   ` Theodore Ts'o
  0 siblings, 0 replies; 6+ messages in thread
From: Theodore Ts'o @ 2013-03-02 23:04 UTC (permalink / raw)
  To: Jan Kara; +Cc: linux-ext4

On Tue, Feb 26, 2013 at 12:36:09AM +0100, Jan Kara wrote:
> When using quota feature we need to enable quotas before orphan cleanup
> so that changes happening during it are properly reflected in quota
> accounting.
> 
> Signed-off-by: Jan Kara <jack@suse.cz>

Thanks, applied.

					- Ted

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-03-02 23:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-25 23:36 [PATCH 1/2] ext4: Don't allow quota mount options when quota feature enabled Jan Kara
2013-02-25 23:36 ` [PATCH 2/2] ext4: Enable quotas before orphan cleanup Jan Kara
2013-03-02 23:04   ` Theodore Ts'o
2013-02-26  0:39 ` [PATCH 1/2] ext4: Don't allow quota mount options when quota feature enabled Theodore Ts'o
2013-02-26 13:18   ` Jan Kara
2013-03-02 23:04 ` Theodore Ts'o

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.