Skip to contentSkip to conversation

Quota cleanups and fixes

PATCH In review Jan Kara 2 participants 6 messages Mar 13, 2008 – Mar 17, 2008

Subsystems (2)
lore
Share & tools
lore

Jan Kara

author reviewer
#0 lore raw

cover Quota cleanups and fixes

Hello,

in the following emails will come three minor quota fixes and cleanups:

[PATCH 1/3] Add possibly missing iput() when quotaon and quotaoff races [PATCH 2/3] Remove superfluous DQUOT_OFF() in fs/namespace.c [PATCH 3/3] Various style cleanups

Would you please put them to -mm? Thanks.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
author reviewer
#1 lore raw

PATCH 1/3 Add possibly missing iput() when quotaon and quotaoff races

We should always put inode we have reference to, even if quota was reenabled in the mean time.

---
 dquot.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/dquot.c +1 -1
index f816d06..24eef58 100644
@@ -1522,8 +1522,8 @@ int vfs_quota_off(struct super_block *sb, int type)
 				truncate_inode_pages(&toputinode[cnt]->i_data, 0);
 				mutex_unlock(&toputinode[cnt]->i_mutex);
 				mark_inode_dirty(toputinode[cnt]);
-				iput(toputinode[cnt]);
 			}
+			iput(toputinode[cnt]);
 			mutex_unlock(&dqopt->dqonoff_mutex);
 		}
 	if (sb->s_bdev)
#2 lore raw

Re: [PATCH 1/3] Add possibly missing iput() when quotaon and quotaoff races

Quoted 14 lines · On Thu, 13 Mar 2008 13:05:52 +0100 Jan Kara <[email protected]> wrote:

We should always put inode we have reference to, even if quota was reenabled in the mean time.

---
 dquot.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/dquot.c +0 -0
index f816d06..24eef58 100644

fs/dquot.c int vfs_quota_off(struct super_block *sb, int type) · line 1529

Quoted 9 lines
fs/dquot.c +1 -1
@@ -1522,8 +1522,8 @@ int vfs_quota_off(struct super_block *sb, int type)
 				truncate_inode_pages(&toputinode[cnt]->i_data, 0);
 				mutex_unlock(&toputinode[cnt]->i_mutex);
 				mark_inode_dirty(toputinode[cnt]);
-				iput(toputinode[cnt]);
 			}
+			iput(toputinode[cnt]);
 			mutex_unlock(&dqopt->dqonoff_mutex);
 		}
 	if (sb->s_bdev)

This one looks like 2.6.25 material?

author reviewer
#3 lore raw

Re: [PATCH 1/3] Add possibly missing iput() when quotaon and quotaoff races

Quoted 12 lines · Andrew Morton
Quoted 9 lines · On Thu, 13 Mar 2008 13:05:52 +0100 Jan Kara <[email protected]> wrote:

We should always put inode we have reference to, even if quota was reenabled in the mean time.

---
 dquot.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines
Quoted 5 lines
fs/dquot.c +0 -0
index f816d06..24eef58 100644

fs/dquot.c int vfs_quota_off(struct super_block *sb, int type) · line 1529

Quoted 9 lines
fs/dquot.c +1 -1
@@ -1522,8 +1522,8 @@ int vfs_quota_off(struct super_block *sb, int type)
 				truncate_inode_pages(&toputinode[cnt]->i_data, 0);
 				mutex_unlock(&toputinode[cnt]->i_mutex);
 				mark_inode_dirty(toputinode[cnt]);
-				iput(toputinode[cnt]);
 			}
+			iput(toputinode[cnt]);
 			mutex_unlock(&dqopt->dqonoff_mutex);
 		}
 	if (sb->s_bdev)

This one looks like 2.6.25 material?

Yes, this can be nasty when triggered (Busy inodes after umount) and the
patch is safe.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
author reviewer
#4 lore raw

PATCH 2/3 Remove superfluous DQUOT_OFF() in fs/namespace.c

In reply to Jan Kara

We don't need to turn quotas off before remounting root ro, because do_remount_sb() already handles this.

---
 namespace.c |    2 --
 1 file changed, 2 deletions(-)
fs/namespace.c +0 -2
index 7953c96..b6facef 100644
@@ -14,7 +14,6 @@
 #include <linux/smp_lock.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
-#include <linux/quotaops.h>
 #include <linux/acct.h>
 #include <linux/capability.h>
 #include <linux/module.h>
@@ -638,7 +637,6 @@ static int do_umount(struct vfsmount *mnt, int flags)
 		down_write(&sb->s_umount);
 		if (!(sb->s_flags & MS_RDONLY)) {
 			lock_kernel();
-			DQUOT_OFF(sb);
 			retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
 			unlock_kernel();
 		}
author reviewer
#5 lore raw

PATCH 3/3 Various style cleanups

In reply to Jan Kara

Cleanups in quota code:
Change __inline__ to inline.
Change some macros to inline functions.
Remove vfs_quota_off_mount() macro.
DQUOT_OFF() should be (0) is CONFIG_QUOTA is disabled.
Move declaration of mark_dquot_dirty and dirty_dquot from quota.h to dquot.c

---
 fs/dquot.c               |   10 +++++-
 fs/reiserfs/super.c      |    2 -
 include/linux/quota.h    |    5 ---
 include/linux/quotaops.h |   71 +++++++++++++++++++++++++++++++++--------------
 4 files changed, 60 insertions(+), 28 deletions(-)
fs/dquot.c +9 -1
index 24eef58..fc26d10 100644
@@ -289,7 +289,15 @@ static void wait_on_dquot(struct dquot *dquot)
 	mutex_unlock(&dquot->dq_lock);
 }
 
-#define mark_dquot_dirty(dquot) ((dquot)->dq_sb->dq_op->mark_dirty(dquot))
+static inline int dquot_dirty(struct dquot *dquot)
+{
+	return test_bit(DQ_MOD_B, &dquot->dq_flags);
+}
+
+static inline int mark_dquot_dirty(struct dquot *dquot)
+{
+	return dquot->dq_sb->dq_op->mark_dirty(dquot);
+}
 
 int dquot_mark_dquot_dirty(struct dquot *dquot)
 {
fs/reiserfs/super.c +1 -1
index 393cc22..3e1972d 100644
@@ -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_mount(s, i);
+			vfs_quota_off(s, i);
 	}
 	if (ms_active_set)
 		/* Restore the flag back */
include/linux/quota.h +0 -5
index c1cdbb7..70ec455 100644
@@ -327,11 +327,6 @@ struct quota_info {
 	struct quota_format_ops *ops[MAXQUOTAS];	/* Operations for each type */
 };
 
-/* Inline would be better but we need to dereference super_block which is not defined yet */
-int mark_dquot_dirty(struct dquot *dquot);
-
-#define dquot_dirty(dquot) test_bit(DQ_MOD_B, &(dquot)->dq_flags)
-
 #define sb_has_quota_enabled(sb, type) ((type)==USRQUOTA ? \
 	(sb_dqopt(sb)->flags & DQUOT_USR_ENABLED) : (sb_dqopt(sb)->flags & DQUOT_GRP_ENABLED))
 
include/linux/quotaops.h +50 -21

159 lines not on this page · raw message