mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] Quota cleanups and fixes
@ 2008-03-13 12:03 Jan Kara
  2008-03-13 12:05 ` [PATCH 1/3] Add possibly missing iput() when quotaon and quotaoff races Jan Kara
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jan Kara @ 2008-03-13 12:03 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

  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
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

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

* [PATCH 1/3] Add possibly missing iput() when quotaon and quotaoff races
  2008-03-13 12:03 [PATCH 0/3] Quota cleanups and fixes Jan Kara
@ 2008-03-13 12:05 ` Jan Kara
  2008-03-13 21:42   ` Andrew Morton
  2008-03-13 12:06 ` [PATCH 2/3] Remove superfluous DQUOT_OFF() in fs/namespace.c Jan Kara
  2008-03-13 12:07 ` [PATCH 3/3] Various style cleanups Jan Kara
  2 siblings, 1 reply; 6+ messages in thread
From: Jan Kara @ 2008-03-13 12:05 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

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

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

---
 dquot.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/dquot.c b/fs/dquot.c
index f816d06..24eef58 100644
--- a/fs/dquot.c
+++ b/fs/dquot.c
@@ -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)

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

* [PATCH 2/3] Remove superfluous DQUOT_OFF() in fs/namespace.c
  2008-03-13 12:03 [PATCH 0/3] Quota cleanups and fixes Jan Kara
  2008-03-13 12:05 ` [PATCH 1/3] Add possibly missing iput() when quotaon and quotaoff races Jan Kara
@ 2008-03-13 12:06 ` Jan Kara
  2008-03-13 12:07 ` [PATCH 3/3] Various style cleanups Jan Kara
  2 siblings, 0 replies; 6+ messages in thread
From: Jan Kara @ 2008-03-13 12:06 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

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

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

---
 namespace.c |    2 --
 1 file changed, 2 deletions(-)

diff --git a/fs/namespace.c b/fs/namespace.c
index 7953c96..b6facef 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -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();
 		}

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

* [PATCH 3/3] Various style cleanups
  2008-03-13 12:03 [PATCH 0/3] Quota cleanups and fixes Jan Kara
  2008-03-13 12:05 ` [PATCH 1/3] Add possibly missing iput() when quotaon and quotaoff races Jan Kara
  2008-03-13 12:06 ` [PATCH 2/3] Remove superfluous DQUOT_OFF() in fs/namespace.c Jan Kara
@ 2008-03-13 12:07 ` Jan Kara
  2 siblings, 0 replies; 6+ messages in thread
From: Jan Kara @ 2008-03-13 12:07 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

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

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

---
 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(-)

diff --git a/fs/dquot.c b/fs/dquot.c
index 24eef58..fc26d10 100644
--- a/fs/dquot.c
+++ b/fs/dquot.c
@@ -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)
 {
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index 393cc22..3e1972d 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_mount(s, i);
+			vfs_quota_off(s, i);
 	}
 	if (ms_active_set)
 		/* Restore the flag back */
diff --git a/include/linux/quota.h b/include/linux/quota.h
index c1cdbb7..70ec455 100644
--- a/include/linux/quota.h
+++ b/include/linux/quota.h
@@ -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))
 
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
index 5110201..b907382 100644
--- a/include/linux/quotaops.h
+++ b/include/linux/quotaops.h
@@ -41,7 +41,6 @@ extern int vfs_quota_on(struct super_block *sb, int type, int format_id, char *p
 extern int vfs_quota_on_mount(struct super_block *sb, char *qf_name,
 		int format_id, int type);
 extern int vfs_quota_off(struct super_block *sb, int type);
-#define vfs_quota_off_mount(sb, type) vfs_quota_off(sb, type)
 extern int vfs_quota_sync(struct super_block *sb, int type);
 extern int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii);
 extern int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii);
@@ -59,7 +58,7 @@ extern struct quotactl_ops vfs_quotactl_ops;
 
 /* It is better to call this function outside of any transaction as it might
  * need a lot of space in journal for dquot structure allocation. */
-static __inline__ void DQUOT_INIT(struct inode *inode)
+static inline void DQUOT_INIT(struct inode *inode)
 {
 	BUG_ON(!inode->i_sb);
 	if (sb_any_quota_enabled(inode->i_sb) && !IS_NOQUOTA(inode))
@@ -67,7 +66,7 @@ static __inline__ void DQUOT_INIT(struct inode *inode)
 }
 
 /* The same as with DQUOT_INIT */
-static __inline__ void DQUOT_DROP(struct inode *inode)
+static inline void DQUOT_DROP(struct inode *inode)
 {
 	/* Here we can get arbitrary inode from clear_inode() so we have
 	 * to be careful. OTOH we don't need locking as quota operations
@@ -90,7 +89,7 @@ static __inline__ void DQUOT_DROP(struct inode *inode)
 
 /* The following allocation/freeing/transfer functions *must* be called inside
  * a transaction (deadlocks possible otherwise) */
-static __inline__ int DQUOT_PREALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr)
+static inline int DQUOT_PREALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr)
 {
 	if (sb_any_quota_enabled(inode->i_sb)) {
 		/* Used space is updated in alloc_space() */
@@ -102,7 +101,7 @@ static __inline__ int DQUOT_PREALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t
 	return 0;
 }
 
-static __inline__ int DQUOT_PREALLOC_SPACE(struct inode *inode, qsize_t nr)
+static inline int DQUOT_PREALLOC_SPACE(struct inode *inode, qsize_t nr)
 {
 	int ret;
         if (!(ret =  DQUOT_PREALLOC_SPACE_NODIRTY(inode, nr)))
@@ -110,7 +109,7 @@ static __inline__ int DQUOT_PREALLOC_SPACE(struct inode *inode, qsize_t nr)
 	return ret;
 }
 
-static __inline__ int DQUOT_ALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr)
+static inline int DQUOT_ALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr)
 {
 	if (sb_any_quota_enabled(inode->i_sb)) {
 		/* Used space is updated in alloc_space() */
@@ -122,7 +121,7 @@ static __inline__ int DQUOT_ALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr)
 	return 0;
 }
 
-static __inline__ int DQUOT_ALLOC_SPACE(struct inode *inode, qsize_t nr)
+static inline int DQUOT_ALLOC_SPACE(struct inode *inode, qsize_t nr)
 {
 	int ret;
 	if (!(ret = DQUOT_ALLOC_SPACE_NODIRTY(inode, nr)))
@@ -130,7 +129,7 @@ static __inline__ int DQUOT_ALLOC_SPACE(struct inode *inode, qsize_t nr)
 	return ret;
 }
 
-static __inline__ int DQUOT_ALLOC_INODE(struct inode *inode)
+static inline int DQUOT_ALLOC_INODE(struct inode *inode)
 {
 	if (sb_any_quota_enabled(inode->i_sb)) {
 		DQUOT_INIT(inode);
@@ -140,7 +139,7 @@ static __inline__ int DQUOT_ALLOC_INODE(struct inode *inode)
 	return 0;
 }
 
-static __inline__ void DQUOT_FREE_SPACE_NODIRTY(struct inode *inode, qsize_t nr)
+static inline void DQUOT_FREE_SPACE_NODIRTY(struct inode *inode, qsize_t nr)
 {
 	if (sb_any_quota_enabled(inode->i_sb))
 		inode->i_sb->dq_op->free_space(inode, nr);
@@ -148,19 +147,19 @@ static __inline__ void DQUOT_FREE_SPACE_NODIRTY(struct inode *inode, qsize_t nr)
 		inode_sub_bytes(inode, nr);
 }
 
-static __inline__ void DQUOT_FREE_SPACE(struct inode *inode, qsize_t nr)
+static inline void DQUOT_FREE_SPACE(struct inode *inode, qsize_t nr)
 {
 	DQUOT_FREE_SPACE_NODIRTY(inode, nr);
 	mark_inode_dirty(inode);
 }
 
-static __inline__ void DQUOT_FREE_INODE(struct inode *inode)
+static inline void DQUOT_FREE_INODE(struct inode *inode)
 {
 	if (sb_any_quota_enabled(inode->i_sb))
 		inode->i_sb->dq_op->free_inode(inode, 1);
 }
 
-static __inline__ int DQUOT_TRANSFER(struct inode *inode, struct iattr *iattr)
+static inline int DQUOT_TRANSFER(struct inode *inode, struct iattr *iattr)
 {
 	if (sb_any_quota_enabled(inode->i_sb) && !IS_NOQUOTA(inode)) {
 		DQUOT_INIT(inode);
@@ -171,9 +170,12 @@ static __inline__ int DQUOT_TRANSFER(struct inode *inode, struct iattr *iattr)
 }
 
 /* The following two functions cannot be called inside a transaction */
-#define DQUOT_SYNC(sb)	sync_dquots(sb, -1)
+static inline void DQUOT_SYNC(struct super_block *sb)
+{
+	sync_dquots(sb, -1);
+}
 
-static __inline__ int DQUOT_OFF(struct super_block *sb)
+static inline int DQUOT_OFF(struct super_block *sb)
 {
 	int ret = -ENOSYS;
 
@@ -194,7 +196,7 @@ static __inline__ int DQUOT_OFF(struct super_block *sb)
 #define DQUOT_ALLOC_INODE(inode)		(0)
 #define DQUOT_FREE_INODE(inode)			do { } while(0)
 #define DQUOT_SYNC(sb)				do { } while(0)
-#define DQUOT_OFF(sb)				do { } while(0)
+#define DQUOT_OFF(sb)				(0)
 #define DQUOT_TRANSFER(inode, iattr)		(0)
 static inline int DQUOT_PREALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr)
 {
@@ -235,11 +237,38 @@ static inline void DQUOT_FREE_SPACE(struct inode *inode, qsize_t nr)
 
 #endif /* CONFIG_QUOTA */
 
-#define DQUOT_PREALLOC_BLOCK_NODIRTY(inode, nr)	DQUOT_PREALLOC_SPACE_NODIRTY(inode, ((qsize_t)(nr)) << (inode)->i_sb->s_blocksize_bits)
-#define DQUOT_PREALLOC_BLOCK(inode, nr)	DQUOT_PREALLOC_SPACE(inode, ((qsize_t)(nr)) << (inode)->i_sb->s_blocksize_bits)
-#define DQUOT_ALLOC_BLOCK_NODIRTY(inode, nr) DQUOT_ALLOC_SPACE_NODIRTY(inode, ((qsize_t)(nr)) << (inode)->i_sb->s_blocksize_bits)
-#define DQUOT_ALLOC_BLOCK(inode, nr) DQUOT_ALLOC_SPACE(inode, ((qsize_t)(nr)) << (inode)->i_sb->s_blocksize_bits)
-#define DQUOT_FREE_BLOCK_NODIRTY(inode, nr) DQUOT_FREE_SPACE_NODIRTY(inode, ((qsize_t)(nr)) << (inode)->i_sb->s_blocksize_bits)
-#define DQUOT_FREE_BLOCK(inode, nr) DQUOT_FREE_SPACE(inode, ((qsize_t)(nr)) << (inode)->i_sb->s_blocksize_bits)
+static inline int DQUOT_PREALLOC_BLOCK_NODIRTY(struct inode *inode, qsize_t nr)
+{
+	return DQUOT_PREALLOC_SPACE_NODIRTY(inode,
+			nr << inode->i_sb->s_blocksize_bits);
+}
+
+static inline int DQUOT_PREALLOC_BLOCK(struct inode *inode, qsize_t nr)
+{
+	return DQUOT_PREALLOC_SPACE(inode,
+			nr << inode->i_sb->s_blocksize_bits);
+}
+
+static inline int DQUOT_ALLOC_BLOCK_NODIRTY(struct inode *inode, qsize_t nr)
+{
+ 	return DQUOT_ALLOC_SPACE_NODIRTY(inode,
+			nr << inode->i_sb->s_blocksize_bits);
+}
+
+static inline int DQUOT_ALLOC_BLOCK(struct inode *inode, qsize_t nr)
+{
+	return DQUOT_ALLOC_SPACE(inode,
+			nr << inode->i_sb->s_blocksize_bits);
+}
+
+static inline void DQUOT_FREE_BLOCK_NODIRTY(struct inode *inode, qsize_t nr)
+{
+	DQUOT_FREE_SPACE_NODIRTY(inode, nr << inode->i_sb->s_blocksize_bits);
+}
+
+static inline void DQUOT_FREE_BLOCK(struct inode *inode, qsize_t nr)
+{
+	DQUOT_FREE_SPACE(inode, nr << inode->i_sb->s_blocksize_bits);
+}
 
 #endif /* _LINUX_QUOTAOPS_ */

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

* Re: [PATCH 1/3] Add possibly missing iput() when quotaon and quotaoff races
  2008-03-13 12:05 ` [PATCH 1/3] Add possibly missing iput() when quotaon and quotaoff races Jan Kara
@ 2008-03-13 21:42   ` Andrew Morton
  2008-03-17 13:13     ` Jan Kara
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2008-03-13 21:42 UTC (permalink / raw)
  To: Jan Kara; +Cc: linux-kernel

On Thu, 13 Mar 2008 13:05:52 +0100
Jan Kara <jack@suse.cz> wrote:

> We should always put inode we have reference to, even if quota was reenabled
> in the mean time.
> 
> Signed-off-by: Jan Kara <jack@suse.cz>
> 
> ---
>  dquot.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/dquot.c b/fs/dquot.c
> index f816d06..24eef58 100644
> --- a/fs/dquot.c
> +++ b/fs/dquot.c
> @@ -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?

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

* Re: [PATCH 1/3] Add possibly missing iput() when quotaon and quotaoff races
  2008-03-13 21:42   ` Andrew Morton
@ 2008-03-17 13:13     ` Jan Kara
  0 siblings, 0 replies; 6+ messages in thread
From: Jan Kara @ 2008-03-17 13:13 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

On Thu 13-03-08 14:42:11, Andrew Morton wrote:
> On Thu, 13 Mar 2008 13:05:52 +0100
> Jan Kara <jack@suse.cz> wrote:
> 
> > We should always put inode we have reference to, even if quota was reenabled
> > in the mean time.
> > 
> > Signed-off-by: Jan Kara <jack@suse.cz>
> > 
> > ---
> >  dquot.c |    2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/fs/dquot.c b/fs/dquot.c
> > index f816d06..24eef58 100644
> > --- a/fs/dquot.c
> > +++ b/fs/dquot.c
> > @@ -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
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

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

end of thread, other threads:[~2008-03-17 13:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-13 12:03 [PATCH 0/3] Quota cleanups and fixes Jan Kara
2008-03-13 12:05 ` [PATCH 1/3] Add possibly missing iput() when quotaon and quotaoff races Jan Kara
2008-03-13 21:42   ` Andrew Morton
2008-03-17 13:13     ` Jan Kara
2008-03-13 12:06 ` [PATCH 2/3] Remove superfluous DQUOT_OFF() in fs/namespace.c Jan Kara
2008-03-13 12:07 ` [PATCH 3/3] Various style cleanups Jan Kara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome