Re: [PATCH 0/4] Automatic quotaon on remount

Previous thread: Is there a wireless PCI/e card that is supported in the kernel? by Justin Piszcz on Thursday, March 13, 2008 - 5:39 am. (3 messages)

Next thread: [PATCH] Input: document i8042.noloop by Jiri Kosina on Thursday, March 13, 2008 - 6:25 am. (2 messages)
From: Jan Kara
Date: Thursday, March 13, 2008 - 5:59 am

Hi,

  the series of patches below implements automatic enabling of quotas on
remount read-write when filesystem with quotas enabled has previously been
remounted read-only (and thus quotas had to be disabled).
  The patches are split logically, but due to interface changes all four
patches need to be applied together or ext3, ext4 or reiserfs won't
compile.

[PATCH 1/4] quota: Quota core changes for quotaon on remount
[PATCH 2/4] ext3: Make ext3 handle quotaon on remount
[PATCH 3/4] ext4: Make ext4 handle quotaon on remount
[PATCH 4/4] reiserfs: Make reiserfs handle quotaon on remount

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

From: Jan Kara
Date: Thursday, March 13, 2008 - 6:04 am

Currently, we just turn quotas off on remount of filesystem to read-only
state. The patch below adds necessary framework so that we can turn quotas
off on remount RO but we are able to automatically reenable them again
when filesystem is remounted to RW state. All we need to do is to
keep references to inodes of quota files when remounting RO and using
these references to reenable quotas when remounting RW.

Signed-off-by: Jan Kara <jack@suse.cz>

---
 fs/dquot.c               |   77 +++++++++++++++++++++++++++++++++++++++++------
 fs/quota.c               |    5 +--
 fs/super.c               |   10 ++++--
 include/linux/quota.h    |   14 +++++++-
 include/linux/quotaops.h |   29 ++++++++++++++---
 5 files changed, 113 insertions(+), 22 deletions(-)

diff --git a/fs/dquot.c b/fs/dquot.c
index fc26d10..dfba162 100644
--- a/fs/dquot.c
+++ b/fs/dquot.c
@@ -1449,31 +1449,43 @@ static inline void set_enable_flags(struct quota_info *dqopt, int type)
 	switch (type) {
 		case USRQUOTA:
 			dqopt->flags |= DQUOT_USR_ENABLED;
+			dqopt->flags &= ~DQUOT_USR_SUSPENDED;
 			break;
 		case GRPQUOTA:
 			dqopt->flags |= DQUOT_GRP_ENABLED;
+			dqopt->flags &= ~DQUOT_GRP_SUSPENDED;
 			break;
 	}
 }
 
-static inline void reset_enable_flags(struct quota_info *dqopt, int type)
+static inline void reset_enable_flags(struct quota_info *dqopt, int type,
+				      int remount)
 {
 	switch (type) {
 		case USRQUOTA:
 			dqopt->flags &= ~DQUOT_USR_ENABLED;
+			if (remount)
+				dqopt->flags |= DQUOT_USR_SUSPENDED;
+			else
+				dqopt->flags &= ~DQUOT_USR_SUSPENDED;
 			break;
 		case GRPQUOTA:
 			dqopt->flags &= ~DQUOT_GRP_ENABLED;
+			if (remount)
+				dqopt->flags |= DQUOT_GRP_SUSPENDED;
+			else
+				dqopt->flags &= ~DQUOT_GRP_SUSPENDED;
 			break;
 	}
 }
 
+
 /*
  * Turn quota off on a device. type == -1 ==> quotaoff for all types (umount)
  */
-int vfs_quota_off(struct super_block *sb, int type)
+int vfs_quota_off(struct super_block *sb, int type, int remount)
 ...
From: Andrew Morton
Date: Thursday, March 13, 2008 - 2:48 pm

On Thu, 13 Mar 2008 14:04:12 +0100

That's about ten times too large to be inlined.  Oh well.

Sometime could you please take a look at uninlining some of the porkier
functions in quotaops.h, and maybe convert them to lower case?



For the latter we can do

	#define DQUOT_ON_REMOUNT(sb) dquot_on_remount(sb)

etc, then remove those macros when everything has been converted and we've
given any out-of-tree filesytem developers time to update, etc.

Thanks.
--

From: Jan Kara
Date: Monday, March 17, 2008 - 6:17 am

Good idea. Will do.

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

From: Jan Kara
Date: Thursday, March 13, 2008 - 6:04 am

Update ext3 handle quotaon on remount RW.

Signed-off-by: Jan Kara <jack@suse.cz>

---
 super.c |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index ad53606..5711d24 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -685,7 +685,7 @@ static int ext3_acquire_dquot(struct dquot *dquot);
 static int ext3_release_dquot(struct dquot *dquot);
 static int ext3_mark_dquot_dirty(struct dquot *dquot);
 static int ext3_write_info(struct super_block *sb, int type);
-static int ext3_quota_on(struct super_block *sb, int type, int format_id, char *path);
+static int ext3_quota_on(struct super_block *sb, int type, int format_id, char *path, int remount);
 static int ext3_quota_on_mount(struct super_block *sb, int type);
 static ssize_t ext3_quota_read(struct super_block *sb, int type, char *data,
 			       size_t len, loff_t off);
@@ -1415,7 +1415,7 @@ static void ext3_orphan_cleanup (struct super_block * sb,
 	/* Turn quotas off */
 	for (i = 0; i < MAXQUOTAS; i++) {
 		if (sb_dqopt(sb)->files[i])
-			vfs_quota_off(sb, i);
+			vfs_quota_off(sb, i, 0);
 	}
 #endif
 	sb->s_flags = s_flags; /* Restore MS_RDONLY status */
@@ -2743,17 +2743,17 @@ static int ext3_quota_on_mount(struct super_block *sb, int type)
  * Standard function to be called on quota_on
  */
 static int ext3_quota_on(struct super_block *sb, int type, int format_id,
-			 char *path)
+			 char *path, int remount)
 {
 	int err;
 	struct nameidata nd;
 
 	if (!test_opt(sb, QUOTA))
 		return -EINVAL;
-	/* Not journalling quota? */
-	if (!EXT3_SB(sb)->s_qf_names[USRQUOTA] &&
-	    !EXT3_SB(sb)->s_qf_names[GRPQUOTA])
-		return vfs_quota_on(sb, type, format_id, path);
+	/* Not journalling quota or remount? */
+	if ((!EXT3_SB(sb)->s_qf_names[USRQUOTA] &&
+	    !EXT3_SB(sb)->s_qf_names[GRPQUOTA]) || remount)
+		return vfs_quota_on(sb, type, format_id, path, remount);
 	err = path_lookup(path, LOOKUP_FOLLOW, &nd);
 	if (err)
 		return ...
From: Jan Kara
Date: Thursday, March 13, 2008 - 6:05 am

Update ext4 to handle quotaon on remount RW.

Signed-off-by: Jan Kara <jack@suse.cz>

---
 super.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 13383ba..5aaf03c 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -813,7 +813,7 @@ static int ext4_acquire_dquot(struct dquot *dquot);
 static int ext4_release_dquot(struct dquot *dquot);
 static int ext4_mark_dquot_dirty(struct dquot *dquot);
 static int ext4_write_info(struct super_block *sb, int type);
-static int ext4_quota_on(struct super_block *sb, int type, int format_id, char *path);
+static int ext4_quota_on(struct super_block *sb, int type, int format_id, char *path, int remount);
 static int ext4_quota_on_mount(struct super_block *sb, int type);
 static ssize_t ext4_quota_read(struct super_block *sb, int type, char *data,
 			       size_t len, loff_t off);
@@ -1632,7 +1632,7 @@ static void ext4_orphan_cleanup (struct super_block * sb,
 	/* Turn quotas off */
 	for (i = 0; i < MAXQUOTAS; i++) {
 		if (sb_dqopt(sb)->files[i])
-			vfs_quota_off(sb, i);
+			vfs_quota_off(sb, i, 0);
 	}
 #endif
 	sb->s_flags = s_flags; /* Restore MS_RDONLY status */
@@ -3143,7 +3143,7 @@ static int ext4_quota_on_mount(struct super_block *sb, int type)
  * Standard function to be called on quota_on
  */
 static int ext4_quota_on(struct super_block *sb, int type, int format_id,
-			 char *path)
+			 char *path, int remount)
 {
 	int err;
 	struct nameidata nd;
@@ -3151,9 +3151,9 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id,
 	if (!test_opt(sb, QUOTA))
 		return -EINVAL;
 	/* Not journalling quota? */
-	if (!EXT4_SB(sb)->s_qf_names[USRQUOTA] &&
-	    !EXT4_SB(sb)->s_qf_names[GRPQUOTA])
-		return vfs_quota_on(sb, type, format_id, path);
+	if ((!EXT4_SB(sb)->s_qf_names[USRQUOTA] &&
+	    !EXT4_SB(sb)->s_qf_names[GRPQUOTA]) || remount)
+		return vfs_quota_on(sb, type, format_id, path, remount);
 	err = path_lookup(path, ...
From: Jan Kara
Date: Thursday, March 13, 2008 - 6:06 am

Update reiserfs to handle quotaon on remount RW.

Signed-off-by: Jan Kara <jack@suse.cz>

---
 super.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index 3e1972d..f8f9a47 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -304,7 +304,7 @@ static int finish_unfinished(struct super_block *s)
 	/* Turn quotas off */
 	for (i = 0; i < MAXQUOTAS; i++) {
 		if (sb_dqopt(s)->files[i])
-			vfs_quota_off(s, i);
+			vfs_quota_off(s, i, 0);
 	}
 	if (ms_active_set)
 		/* Restore the flag back */
@@ -634,7 +634,7 @@ static int reiserfs_acquire_dquot(struct dquot *);
 static int reiserfs_release_dquot(struct dquot *);
 static int reiserfs_mark_dquot_dirty(struct dquot *);
 static int reiserfs_write_info(struct super_block *, int);
-static int reiserfs_quota_on(struct super_block *, int, int, char *);
+static int reiserfs_quota_on(struct super_block *, int, int, char *, int);
 
 static struct dquot_operations reiserfs_quota_operations = {
 	.initialize = reiserfs_dquot_initialize,
@@ -2015,13 +2015,16 @@ static int reiserfs_quota_on_mount(struct super_block *sb, int type)
  * Standard function to be called on quota_on
  */
 static int reiserfs_quota_on(struct super_block *sb, int type, int format_id,
-			     char *path)
+			     char *path, int remount)
 {
 	int err;
 	struct nameidata nd;
 
 	if (!(REISERFS_SB(sb)->s_mount_opt & (1 << REISERFS_QUOTA)))
 		return -EINVAL;
+	/* No more checks needed? Path and format_id are bogus anyway... */
+	if (remount)
+		return vfs_quota_on(sb, type, format_id, path, 1);
 	err = path_lookup(path, LOOKUP_FOLLOW, &nd);
 	if (err)
 		return err;
@@ -2041,7 +2044,7 @@ static int reiserfs_quota_on(struct super_block *sb, int type, int format_id,
 	if (!REISERFS_SB(sb)->s_qf_names[USRQUOTA] &&
 	    !REISERFS_SB(sb)->s_qf_names[GRPQUOTA]) {
 		path_put(&nd.path);
-		return vfs_quota_on(sb, type, format_id, path);
+		return vfs_quota_on(sb, type, ...
From: Christoph Hellwig
Date: Thursday, March 13, 2008 - 9:37 am

No need to touch jfs?

--

From: Jan Kara
Date: Thursday, March 13, 2008 - 9:47 am

No, since JFS doesn't use quota_on callback and doesn't do journaled
quotas which require calling vfs_quota_on/off during journal replay. But
thanks for the suggestion :).

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

Previous thread: Is there a wireless PCI/e card that is supported in the kernel? by Justin Piszcz on Thursday, March 13, 2008 - 5:39 am. (3 messages)

Next thread: [PATCH] Input: document i8042.noloop by Jiri Kosina on Thursday, March 13, 2008 - 6:25 am. (2 messages)