All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/8] dquot interface cleanups
@ 2010-02-20 11:51 Christoph Hellwig
  2010-02-20 11:51 ` [PATCH 1/8] dquot: cleanup space allocation / freeing routines Christoph Hellwig
                   ` (7 more replies)
  0 siblings, 8 replies; 26+ messages in thread
From: Christoph Hellwig @ 2010-02-20 11:51 UTC (permalink / raw)
  To: jack; +Cc: linux-fsdevel

Get rid of the dquot operations that were used for calls from the
filesystems into the dquot code, clean up the namespace for calls
to the dquot code to always be dquot_, and move the few calls into
the dquot code that were in the VFS into the filesystems.

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

* [PATCH 1/8] dquot: cleanup space allocation / freeing routines
  2010-02-20 11:51 [PATCH 0/8] dquot interface cleanups Christoph Hellwig
@ 2010-02-20 11:51 ` Christoph Hellwig
  2010-02-24 22:09   ` Jan Kara
  2010-02-20 11:51 ` [PATCH 2/8] dquot: cleanup inode " Christoph Hellwig
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 26+ messages in thread
From: Christoph Hellwig @ 2010-02-20 11:51 UTC (permalink / raw)
  To: jack; +Cc: linux-fsdevel

[-- Attachment #1: quota-kill-alloc_space --]
[-- Type: text/plain, Size: 52394 bytes --]

Get rid of the alloc_space, free_space, reserve_space, claim_space and
release_rsv dquot operations - they are always called from the filesystem
and if a filesystem really needs their own (which none currently does)
it can just call into it's own routine directly.

Move shared logic into the common __dquot_alloc_space,
dquot_claim_space_nodirty and __dquot_free_space low-level methods,
and rationalize the wrappers around it to move as much as possible
code into the common block for CONFIG_QUOTA vs not.  Also rename
all these helpers to be named dquot_* instead of vfs_dq_*.

Signed-off-by: Christoph Hellwig <hch@lst.de>

Index: linux-2.6/include/linux/quotaops.h
===================================================================
--- linux-2.6.orig/include/linux/quotaops.h	2010-02-20 11:45:37.608004431 +0100
+++ linux-2.6/include/linux/quotaops.h	2010-02-20 11:46:29.731254186 +0100
@@ -33,14 +33,13 @@ int dquot_scan_active(struct super_block
 struct dquot *dquot_alloc(struct super_block *sb, int type);
 void dquot_destroy(struct dquot *dquot);
 
-int dquot_alloc_space(struct inode *inode, qsize_t number, int prealloc);
-int dquot_alloc_inode(const struct inode *inode, qsize_t number);
+int __dquot_alloc_space(struct inode *inode, qsize_t number,
+		int warn, int reserve);
+void __dquot_free_space(struct inode *inode, qsize_t number, int reserve);
 
-int dquot_reserve_space(struct inode *inode, qsize_t number, int prealloc);
-int dquot_claim_space(struct inode *inode, qsize_t number);
-void dquot_release_reserved_space(struct inode *inode, qsize_t number);
+int dquot_alloc_inode(const struct inode *inode, qsize_t number);
 
-int dquot_free_space(struct inode *inode, qsize_t number);
+int dquot_claim_space_nodirty(struct inode *inode, qsize_t number);
 int dquot_free_inode(const struct inode *inode, qsize_t number);
 
 int dquot_transfer(struct inode *inode, qid_t *chid, unsigned long mask);
@@ -149,60 +148,6 @@ static inline void vfs_dq_init(struct in
 		inode->i_sb->dq_op->initialize(inode, -1);
 }
 
-/* The following allocation/freeing/transfer functions *must* be called inside
- * a transaction (deadlocks possible otherwise) */
-static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr)
-{
-	if (sb_any_quota_active(inode->i_sb)) {
-		/* Used space is updated in alloc_space() */
-		if (inode->i_sb->dq_op->alloc_space(inode, nr, 1) == NO_QUOTA)
-			return 1;
-	}
-	else
-		inode_add_bytes(inode, nr);
-	return 0;
-}
-
-static inline int vfs_dq_prealloc_space(struct inode *inode, qsize_t nr)
-{
-	int ret;
-        if (!(ret =  vfs_dq_prealloc_space_nodirty(inode, nr)))
-		mark_inode_dirty(inode);
-	return ret;
-}
-
-static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr)
-{
-	if (sb_any_quota_active(inode->i_sb)) {
-		/* Used space is updated in alloc_space() */
-		if (inode->i_sb->dq_op->alloc_space(inode, nr, 0) == NO_QUOTA)
-			return 1;
-	}
-	else
-		inode_add_bytes(inode, nr);
-	return 0;
-}
-
-static inline int vfs_dq_alloc_space(struct inode *inode, qsize_t nr)
-{
-	int ret;
-	if (!(ret = vfs_dq_alloc_space_nodirty(inode, nr)))
-		mark_inode_dirty(inode);
-	return ret;
-}
-
-static inline int vfs_dq_reserve_space(struct inode *inode, qsize_t nr)
-{
-	if (sb_any_quota_active(inode->i_sb)) {
-		/* Used space is updated in alloc_space() */
-		if (inode->i_sb->dq_op->reserve_space(inode, nr, 0) == NO_QUOTA)
-			return 1;
-	}
-	else
-		inode_add_rsv_space(inode, nr);
-	return 0;
-}
-
 static inline int vfs_dq_alloc_inode(struct inode *inode)
 {
 	if (sb_any_quota_active(inode->i_sb)) {
@@ -214,45 +159,8 @@ static inline int vfs_dq_alloc_inode(str
 }
 
 /*
- * Convert in-memory reserved quotas to real consumed quotas
- */
-static inline int vfs_dq_claim_space(struct inode *inode, qsize_t nr)
-{
-	if (sb_any_quota_active(inode->i_sb)) {
-		if (inode->i_sb->dq_op->claim_space(inode, nr) == NO_QUOTA)
-			return 1;
-	} else
-		inode_claim_rsv_space(inode, nr);
-
-	mark_inode_dirty(inode);
-	return 0;
-}
-
-/*
  * Release reserved (in-memory) quotas
  */
-static inline
-void vfs_dq_release_reservation_space(struct inode *inode, qsize_t nr)
-{
-	if (sb_any_quota_active(inode->i_sb))
-		inode->i_sb->dq_op->release_rsv(inode, nr);
-	else
-		inode_sub_rsv_space(inode, nr);
-}
-
-static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr)
-{
-	if (sb_any_quota_active(inode->i_sb))
-		inode->i_sb->dq_op->free_space(inode, nr);
-	else
-		inode_sub_bytes(inode, nr);
-}
-
-static inline void vfs_dq_free_space(struct inode *inode, qsize_t nr)
-{
-	vfs_dq_free_space_nodirty(inode, nr);
-	mark_inode_dirty(inode);
-}
 
 static inline void vfs_dq_free_inode(struct inode *inode)
 {
@@ -351,105 +259,109 @@ static inline int vfs_dq_transfer(struct
 	return 0;
 }
 
-static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr)
+static inline int __dquot_alloc_space(struct inode *inode, qsize_t number,
+		int warn, int reserve)
 {
-	inode_add_bytes(inode, nr);
+	if (!reserve)
+		inode_add_bytes(inode, number);
 	return 0;
 }
 
-static inline int vfs_dq_prealloc_space(struct inode *inode, qsize_t nr)
+static inline void __dquot_free_space(struct inode *inode, qsize_t number,
+		int reserve)
+{
+	if (!reserve)
+		inode_sub_bytes(inode, number);
 {
-	vfs_dq_prealloc_space_nodirty(inode, nr);
-	mark_inode_dirty(inode);
-	return 0;
-}
 
-static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr)
+static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
 {
-	inode_add_bytes(inode, nr);
+	inode_add_bytes(inode, number);
 	return 0;
 }
 
-static inline int vfs_dq_alloc_space(struct inode *inode, qsize_t nr)
+#endif /* CONFIG_QUOTA */
+
+static inline int dquot_alloc_space_nodirty(struct inode *inode, qsize_t nr)
 {
-	vfs_dq_alloc_space_nodirty(inode, nr);
-	mark_inode_dirty(inode);
-	return 0;
+	return __dquot_alloc_space(inode, nr, 0, 0);
 }
 
-static inline int vfs_dq_reserve_space(struct inode *inode, qsize_t nr)
+static inline int dquot_alloc_space(struct inode *inode, qsize_t nr)
 {
-	return 0;
+	int ret;
+
+	ret = dquot_alloc_space_nodirty(inode, nr);
+	if (!ret)
+		mark_inode_dirty(inode);
+	return ret;
 }
 
-static inline int vfs_dq_claim_space(struct inode *inode, qsize_t nr)
+static inline int dquot_alloc_block_nodirty(struct inode *inode, qsize_t nr)
 {
-	return vfs_dq_alloc_space(inode, nr);
+	return dquot_alloc_space_nodirty(inode, nr << inode->i_blkbits);
 }
 
-static inline
-int vfs_dq_release_reservation_space(struct inode *inode, qsize_t nr)
+static inline int dquot_alloc_block(struct inode *inode, qsize_t nr)
 {
-	return 0;
+	return dquot_alloc_space(inode, nr << inode->i_blkbits);
 }
 
-static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr)
+static inline int dquot_prealloc_block_nodirty(struct inode *inode, qsize_t nr)
 {
-	inode_sub_bytes(inode, nr);
+	return __dquot_alloc_space(inode, nr << inode->i_blkbits, 1, 0);
 }
 
-static inline void vfs_dq_free_space(struct inode *inode, qsize_t nr)
+static inline int dquot_prealloc_block(struct inode *inode, qsize_t nr)
 {
-	vfs_dq_free_space_nodirty(inode, nr);
-	mark_inode_dirty(inode);
-}	
-
-#endif /* CONFIG_QUOTA */
+	int ret;
 
-static inline int vfs_dq_prealloc_block_nodirty(struct inode *inode, qsize_t nr)
-{
-	return vfs_dq_prealloc_space_nodirty(inode, nr << inode->i_blkbits);
+	ret = dquot_prealloc_block_nodirty(inode, nr);
+	if (!ret)
+		mark_inode_dirty(inode);
+	return ret;
 }
 
-static inline int vfs_dq_prealloc_block(struct inode *inode, qsize_t nr)
+static inline int dquot_reserve_block(struct inode *inode, qsize_t nr)
 {
-	return vfs_dq_prealloc_space(inode, nr << inode->i_blkbits);
+	return __dquot_alloc_space(inode, nr << inode->i_blkbits, 0, 1);
 }
 
-static inline int vfs_dq_alloc_block_nodirty(struct inode *inode, qsize_t nr)
+static inline int dquot_claim_block(struct inode *inode, qsize_t nr)
 {
-	return vfs_dq_alloc_space_nodirty(inode, nr << inode->i_blkbits);
-}
+	int ret;
 
-static inline int vfs_dq_alloc_block(struct inode *inode, qsize_t nr)
-{
-	return vfs_dq_alloc_space(inode, nr << inode->i_blkbits);
+	ret = dquot_claim_space_nodirty(inode, nr << inode->i_blkbits);
+	if (!ret)
+		mark_inode_dirty(inode);
+	return ret;
 }
 
-static inline int vfs_dq_reserve_block(struct inode *inode, qsize_t nr)
+static inline void dquot_free_space_nodirty(struct inode *inode, qsize_t nr)
 {
-	return vfs_dq_reserve_space(inode, nr << inode->i_blkbits);
+	__dquot_free_space(inode, nr, 0);
 }
 
-static inline int vfs_dq_claim_block(struct inode *inode, qsize_t nr)
+static inline void dquot_free_space(struct inode *inode, qsize_t nr)
 {
-	return vfs_dq_claim_space(inode, nr << inode->i_blkbits);
+	dquot_free_space_nodirty(inode, nr);
+	mark_inode_dirty(inode);
 }
 
-static inline
-void vfs_dq_release_reservation_block(struct inode *inode, qsize_t nr)
+static inline void dquot_free_block_nodirty(struct inode *inode, qsize_t nr)
 {
-	vfs_dq_release_reservation_space(inode, nr << inode->i_blkbits);
+	dquot_free_space_nodirty(inode, nr << inode->i_blkbits);
 }
 
-static inline void vfs_dq_free_block_nodirty(struct inode *inode, qsize_t nr)
+static inline void dquot_free_block(struct inode *inode, qsize_t nr)
 {
-	vfs_dq_free_space_nodirty(inode, nr << inode->i_blkbits);
+	dquot_free_space(inode, nr << inode->i_blkbits);
 }
 
-static inline void vfs_dq_free_block(struct inode *inode, qsize_t nr)
+static inline void dquot_release_reservation_block(struct inode *inode,
+		qsize_t nr)
 {
-	vfs_dq_free_space(inode, nr << inode->i_blkbits);
+	__dquot_free_space(inode, nr << inode->i_blkbits, 1);
 }
 
 #endif /* _LINUX_QUOTAOPS_ */
Index: linux-2.6/Documentation/filesystems/Locking
===================================================================
--- linux-2.6.orig/Documentation/filesystems/Locking	2010-02-20 11:45:37.632013162 +0100
+++ linux-2.6/Documentation/filesystems/Locking	2010-02-20 11:46:29.732254256 +0100
@@ -462,9 +462,7 @@ in sys_read() and friends.
 prototypes:
 	int (*initialize) (struct inode *, int);
 	int (*drop) (struct inode *);
-	int (*alloc_space) (struct inode *, qsize_t, int);
 	int (*alloc_inode) (const struct inode *, unsigned long);
-	int (*free_space) (struct inode *, qsize_t);
 	int (*free_inode) (const struct inode *, unsigned long);
 	int (*transfer) (struct inode *, struct iattr *);
 	int (*write_dquot) (struct dquot *);
@@ -481,9 +479,7 @@ What filesystem should expect from the g
 		FS recursion	Held locks when called
 initialize:	yes		maybe dqonoff_sem
 drop:		yes		-
-alloc_space:	->mark_dirty()	-
 alloc_inode:	->mark_dirty()	-
-free_space:	->mark_dirty()	-
 free_inode:	->mark_dirty()	-
 transfer:	yes		-
 write_dquot:	yes		dqonoff_sem or dqptr_sem
@@ -495,7 +491,7 @@ write_info:	yes		dqonoff_sem
 FS recursion means calling ->quota_read() and ->quota_write() from superblock
 operations.
 
-->alloc_space(), ->alloc_inode(), ->free_space(), ->free_inode() are called
+->alloc_inode(), ->free_inode() are called
 only directly by the filesystem and do not call any fs functions only
 the ->mark_dirty() operation.
 
Index: linux-2.6/fs/ext3/super.c
===================================================================
--- linux-2.6.orig/fs/ext3/super.c	2010-02-20 11:45:37.641003873 +0100
+++ linux-2.6/fs/ext3/super.c	2010-02-20 11:46:29.743440315 +0100
@@ -752,9 +752,7 @@ static ssize_t ext3_quota_write(struct s
 static const struct dquot_operations ext3_quota_operations = {
 	.initialize	= dquot_initialize,
 	.drop		= dquot_drop,
-	.alloc_space	= dquot_alloc_space,
 	.alloc_inode	= dquot_alloc_inode,
-	.free_space	= dquot_free_space,
 	.free_inode	= dquot_free_inode,
 	.transfer	= dquot_transfer,
 	.write_dquot	= ext3_write_dquot,
Index: linux-2.6/fs/ext4/super.c
===================================================================
--- linux-2.6.orig/fs/ext4/super.c	2010-02-20 11:45:37.679003593 +0100
+++ linux-2.6/fs/ext4/super.c	2010-02-20 11:46:29.762194960 +0100
@@ -1014,15 +1014,10 @@ static ssize_t ext4_quota_write(struct s
 static const struct dquot_operations ext4_quota_operations = {
 	.initialize	= dquot_initialize,
 	.drop		= dquot_drop,
-	.alloc_space	= dquot_alloc_space,
-	.reserve_space	= dquot_reserve_space,
-	.claim_space	= dquot_claim_space,
-	.release_rsv	= dquot_release_reserved_space,
 #ifdef CONFIG_QUOTA
 	.get_reserved_space = ext4_get_reserved_space,
 #endif
 	.alloc_inode	= dquot_alloc_inode,
-	.free_space	= dquot_free_space,
 	.free_inode	= dquot_free_inode,
 	.transfer	= dquot_transfer,
 	.write_dquot	= ext4_write_dquot,
Index: linux-2.6/fs/ocfs2/quota_global.c
===================================================================
--- linux-2.6.orig/fs/ocfs2/quota_global.c	2010-02-20 11:45:37.715011695 +0100
+++ linux-2.6/fs/ocfs2/quota_global.c	2010-02-20 11:46:29.772255792 +0100
@@ -853,9 +853,7 @@ static void ocfs2_destroy_dquot(struct d
 const struct dquot_operations ocfs2_quota_operations = {
 	.initialize	= dquot_initialize,
 	.drop		= dquot_drop,
-	.alloc_space	= dquot_alloc_space,
 	.alloc_inode	= dquot_alloc_inode,
-	.free_space	= dquot_free_space,
 	.free_inode	= dquot_free_inode,
 	.transfer	= dquot_transfer,
 	.write_dquot	= ocfs2_write_dquot,
Index: linux-2.6/fs/quota/dquot.c
===================================================================
--- linux-2.6.orig/fs/quota/dquot.c	2010-02-20 11:45:37.774253768 +0100
+++ linux-2.6/fs/quota/dquot.c	2010-02-20 11:47:23.752007784 +0100
@@ -1464,28 +1464,29 @@ static void inode_decr_space(struct inod
 }
 
 /*
- * Following four functions update i_blocks+i_bytes fields and
- * quota information (together with appropriate checks)
- * NOTE: We absolutely rely on the fact that caller dirties
- * the inode (usually macros in quotaops.h care about this) and
- * holds a handle for the current transaction so that dquot write and
- * inode write go into the same transaction.
+ * This functions updates i_blocks+i_bytes fields and quota information
+ * (together with appropriate checks).
+ *
+ * NOTE: We absolutely rely on the fact that caller dirties the inode
+ * (usually helpers in quotaops.h care about this) and holds a handle for
+ * the current transaction so that dquot write and inode write go into the
+ * same transaction.
  */
 
 /*
  * This operation can block, but only after everything is updated
  */
 int __dquot_alloc_space(struct inode *inode, qsize_t number,
-			int warn, int reserve)
+		int warn, int reserve)
 {
-	int cnt, ret = QUOTA_OK;
+	int cnt, ret = 0;
 	char warntype[MAXQUOTAS];
 
 	/*
 	 * First test before acquiring mutex - solves deadlocks when we
 	 * re-enter the quota code and are already holding the mutex
 	 */
-	if (IS_NOQUOTA(inode)) {
+	if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode)) {
 		inode_incr_space(inode, number, reserve);
 		goto out;
 	}
@@ -1500,7 +1501,7 @@ int __dquot_alloc_space(struct inode *in
 			continue;
 		if (check_bdq(inode->i_dquot[cnt], number, warn, warntype+cnt)
 		    == NO_QUOTA) {
-			ret = NO_QUOTA;
+			ret = 1;
 			spin_unlock(&dq_data_lock);
 			goto out_flush_warn;
 		}
@@ -1525,18 +1526,7 @@ out_flush_warn:
 out:
 	return ret;
 }
-
-int dquot_alloc_space(struct inode *inode, qsize_t number, int warn)
-{
-	return __dquot_alloc_space(inode, number, warn, 0);
-}
-EXPORT_SYMBOL(dquot_alloc_space);
-
-int dquot_reserve_space(struct inode *inode, qsize_t number, int warn)
-{
-	return __dquot_alloc_space(inode, number, warn, 1);
-}
-EXPORT_SYMBOL(dquot_reserve_space);
+EXPORT_SYMBOL(__dquot_alloc_space);
 
 /*
  * This operation can block, but only after everything is updated
@@ -1578,14 +1568,16 @@ warn_put_all:
 }
 EXPORT_SYMBOL(dquot_alloc_inode);
 
-int dquot_claim_space(struct inode *inode, qsize_t number)
+/*
+ * Convert in-memory reserved quotas to real consumed quotas
+ */
+int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
 {
 	int cnt;
-	int ret = QUOTA_OK;
 
-	if (IS_NOQUOTA(inode)) {
+	if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode)) {
 		inode_claim_rsv_space(inode, number);
-		goto out;
+		return 0;
 	}
 
 	down_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
@@ -1601,24 +1593,23 @@ int dquot_claim_space(struct inode *inod
 	spin_unlock(&dq_data_lock);
 	mark_all_dquot_dirty(inode->i_dquot);
 	up_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
-out:
-	return ret;
+	return 0;
 }
-EXPORT_SYMBOL(dquot_claim_space);
+EXPORT_SYMBOL(dquot_claim_space_nodirty);
 
 /*
  * This operation can block, but only after everything is updated
  */
-int __dquot_free_space(struct inode *inode, qsize_t number, int reserve)
+void __dquot_free_space(struct inode *inode, qsize_t number, int reserve)
 {
 	unsigned int cnt;
 	char warntype[MAXQUOTAS];
 
 	/* First test before acquiring mutex - solves deadlocks when we
          * re-enter the quota code and are already holding the mutex */
-	if (IS_NOQUOTA(inode)) {
+	if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode)) {
 		inode_decr_space(inode, number, reserve);
-		return QUOTA_OK;
+		return;
 	}
 
 	down_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
@@ -1641,24 +1632,8 @@ int __dquot_free_space(struct inode *ino
 out_unlock:
 	flush_warnings(inode->i_dquot, warntype);
 	up_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
-	return QUOTA_OK;
-}
-
-int dquot_free_space(struct inode *inode, qsize_t number)
-{
-	return  __dquot_free_space(inode, number, 0);
-}
-EXPORT_SYMBOL(dquot_free_space);
-
-/*
- * Release reserved quota space
- */
-void dquot_release_reserved_space(struct inode *inode, qsize_t number)
-{
-	__dquot_free_space(inode, number, 1);
-
 }
-EXPORT_SYMBOL(dquot_release_reserved_space);
+EXPORT_SYMBOL(__dquot_free_space);
 
 /*
  * This operation can block, but only after everything is updated
@@ -1840,9 +1815,7 @@ EXPORT_SYMBOL(dquot_commit_info);
 const struct dquot_operations dquot_operations = {
 	.initialize	= dquot_initialize,
 	.drop		= dquot_drop,
-	.alloc_space	= dquot_alloc_space,
 	.alloc_inode	= dquot_alloc_inode,
-	.free_space	= dquot_free_space,
 	.free_inode	= dquot_free_inode,
 	.transfer	= dquot_transfer,
 	.write_dquot	= dquot_commit,
Index: linux-2.6/fs/reiserfs/super.c
===================================================================
--- linux-2.6.orig/fs/reiserfs/super.c	2010-02-20 11:45:37.783274162 +0100
+++ linux-2.6/fs/reiserfs/super.c	2010-02-20 11:46:29.785031041 +0100
@@ -618,9 +618,7 @@ static int reiserfs_quota_on(struct supe
 static const struct dquot_operations reiserfs_quota_operations = {
 	.initialize = dquot_initialize,
 	.drop = dquot_drop,
-	.alloc_space = dquot_alloc_space,
 	.alloc_inode = dquot_alloc_inode,
-	.free_space = dquot_free_space,
 	.free_inode = dquot_free_inode,
 	.transfer = dquot_transfer,
 	.write_dquot = reiserfs_write_dquot,
Index: linux-2.6/include/linux/quota.h
===================================================================
--- linux-2.6.orig/include/linux/quota.h	2010-02-20 11:45:37.622004711 +0100
+++ linux-2.6/include/linux/quota.h	2010-02-20 11:46:29.798033346 +0100
@@ -297,9 +297,7 @@ struct quota_format_ops {
 struct dquot_operations {
 	int (*initialize) (struct inode *, int);
 	int (*drop) (struct inode *);
-	int (*alloc_space) (struct inode *, qsize_t, int);
 	int (*alloc_inode) (const struct inode *, qsize_t);
-	int (*free_space) (struct inode *, qsize_t);
 	int (*free_inode) (const struct inode *, qsize_t);
 	int (*transfer) (struct inode *, qid_t *, unsigned long);
 	int (*write_dquot) (struct dquot *);		/* Ordinary dquot write */
@@ -309,12 +307,6 @@ struct dquot_operations {
 	int (*release_dquot) (struct dquot *);		/* Quota is going to be deleted from disk */
 	int (*mark_dirty) (struct dquot *);		/* Dquot is marked dirty */
 	int (*write_info) (struct super_block *, int);	/* Write of quota "superblock" */
-	/* reserve quota for delayed block allocation */
-	int (*reserve_space) (struct inode *, qsize_t, int);
-	/* claim reserved quota for delayed alloc */
-	int (*claim_space) (struct inode *, qsize_t);
-	/* release rsved quota for delayed alloc */
-	void (*release_rsv) (struct inode *, qsize_t);
 	/* get reserved quota for delayed alloc, value returned is managed by
 	 * quota code only */
 	qsize_t *(*get_reserved_space) (struct inode *);
Index: linux-2.6/fs/ext2/balloc.c
===================================================================
--- linux-2.6.orig/fs/ext2/balloc.c	2010-02-20 11:45:37.813024895 +0100
+++ linux-2.6/fs/ext2/balloc.c	2010-02-20 11:46:29.805005828 +0100
@@ -570,7 +570,7 @@ do_more:
 error_return:
 	brelse(bitmap_bh);
 	release_blocks(sb, freed);
-	vfs_dq_free_block(inode, freed);
+	dquot_free_block(inode, freed);
 }
 
 /**
@@ -1247,7 +1247,7 @@ ext2_fsblk_t ext2_new_blocks(struct inod
 	/*
 	 * Check quota for allocation of this block.
 	 */
-	if (vfs_dq_alloc_block(inode, num)) {
+	if (dquot_alloc_block(inode, num)) {
 		*errp = -EDQUOT;
 		return 0;
 	}
@@ -1409,7 +1409,7 @@ allocated:
 
 	*errp = 0;
 	brelse(bitmap_bh);
-	vfs_dq_free_block(inode, *count-num);
+	dquot_free_block(inode, *count-num);
 	*count = num;
 	return ret_block;
 
@@ -1420,7 +1420,7 @@ out:
 	 * Undo the block allocation
 	 */
 	if (!performed_allocation)
-		vfs_dq_free_block(inode, *count);
+		dquot_free_block(inode, *count);
 	brelse(bitmap_bh);
 	return 0;
 }
Index: linux-2.6/fs/ext2/xattr.c
===================================================================
--- linux-2.6.orig/fs/ext2/xattr.c	2010-02-20 11:45:37.825003384 +0100
+++ linux-2.6/fs/ext2/xattr.c	2010-02-20 11:46:29.817255793 +0100
@@ -645,7 +645,7 @@ ext2_xattr_set2(struct inode *inode, str
 				ea_bdebug(new_bh, "reusing block");
 
 				error = -EDQUOT;
-				if (vfs_dq_alloc_block(inode, 1)) {
+				if (dquot_alloc_block(inode, 1)) {
 					unlock_buffer(new_bh);
 					goto cleanup;
 				}
@@ -702,7 +702,7 @@ ext2_xattr_set2(struct inode *inode, str
 		 * as if nothing happened and cleanup the unused block */
 		if (error && error != -ENOSPC) {
 			if (new_bh && new_bh != old_bh)
-				vfs_dq_free_block(inode, 1);
+				dquot_free_block(inode, 1);
 			goto cleanup;
 		}
 	} else
@@ -734,7 +734,7 @@ ext2_xattr_set2(struct inode *inode, str
 			le32_add_cpu(&HDR(old_bh)->h_refcount, -1);
 			if (ce)
 				mb_cache_entry_release(ce);
-			vfs_dq_free_block(inode, 1);
+			dquot_free_block(inode, 1);
 			mark_buffer_dirty(old_bh);
 			ea_bdebug(old_bh, "refcount now=%d",
 				le32_to_cpu(HDR(old_bh)->h_refcount));
@@ -797,7 +797,7 @@ ext2_xattr_delete_inode(struct inode *in
 		mark_buffer_dirty(bh);
 		if (IS_SYNC(inode))
 			sync_dirty_buffer(bh);
-		vfs_dq_free_block(inode, 1);
+		dquot_free_block(inode, 1);
 	}
 	EXT2_I(inode)->i_file_acl = 0;
 
Index: linux-2.6/fs/ext3/balloc.c
===================================================================
--- linux-2.6.orig/fs/ext3/balloc.c	2010-02-20 11:45:37.650003873 +0100
+++ linux-2.6/fs/ext3/balloc.c	2010-02-20 11:46:29.825255862 +0100
@@ -676,7 +676,7 @@ void ext3_free_blocks(handle_t *handle, 
 	}
 	ext3_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks);
 	if (dquot_freed_blocks)
-		vfs_dq_free_block(inode, dquot_freed_blocks);
+		dquot_free_block(inode, dquot_freed_blocks);
 	return;
 }
 
@@ -1502,7 +1502,7 @@ ext3_fsblk_t ext3_new_blocks(handle_t *h
 	/*
 	 * Check quota for allocation of this block.
 	 */
-	if (vfs_dq_alloc_block(inode, num)) {
+	if (dquot_alloc_block(inode, num)) {
 		*errp = -EDQUOT;
 		return 0;
 	}
@@ -1713,7 +1713,7 @@ allocated:
 
 	*errp = 0;
 	brelse(bitmap_bh);
-	vfs_dq_free_block(inode, *count-num);
+	dquot_free_block(inode, *count-num);
 	*count = num;
 	return ret_block;
 
@@ -1728,7 +1728,7 @@ out:
 	 * Undo the block allocation
 	 */
 	if (!performed_allocation)
-		vfs_dq_free_block(inode, *count);
+		dquot_free_block(inode, *count);
 	brelse(bitmap_bh);
 	return 0;
 }
Index: linux-2.6/fs/ext3/inode.c
===================================================================
--- linux-2.6.orig/fs/ext3/inode.c	2010-02-20 11:45:37.659007435 +0100
+++ linux-2.6/fs/ext3/inode.c	2010-02-20 11:46:29.838255793 +0100
@@ -3328,7 +3328,7 @@ int ext3_mark_inode_dirty(handle_t *hand
  * i_size has been changed by generic_commit_write() and we thus need
  * to include the updated inode in the current transaction.
  *
- * Also, vfs_dq_alloc_space() will always dirty the inode when blocks
+ * Also, dquot_alloc_space() will always dirty the inode when blocks
  * are allocated to the file.
  *
  * If the inode is marked synchronous, we don't honour that here - doing
Index: linux-2.6/fs/ext3/xattr.c
===================================================================
--- linux-2.6.orig/fs/ext3/xattr.c	2010-02-20 11:45:37.668004292 +0100
+++ linux-2.6/fs/ext3/xattr.c	2010-02-20 11:46:29.846004851 +0100
@@ -500,7 +500,7 @@ ext3_xattr_release_block(handle_t *handl
 		error = ext3_journal_dirty_metadata(handle, bh);
 		if (IS_SYNC(inode))
 			handle->h_sync = 1;
-		vfs_dq_free_block(inode, 1);
+		dquot_free_block(inode, 1);
 		ea_bdebug(bh, "refcount now=%d; releasing",
 			  le32_to_cpu(BHDR(bh)->h_refcount));
 		if (ce)
@@ -776,7 +776,7 @@ inserted:
 				/* The old block is released after updating
 				   the inode. */
 				error = -EDQUOT;
-				if (vfs_dq_alloc_block(inode, 1))
+				if (dquot_alloc_block(inode, 1))
 					goto cleanup;
 				error = ext3_journal_get_write_access(handle,
 								      new_bh);
@@ -850,7 +850,7 @@ cleanup:
 	return error;
 
 cleanup_dquot:
-	vfs_dq_free_block(inode, 1);
+	dquot_free_block(inode, 1);
 	goto cleanup;
 
 bad_block:
Index: linux-2.6/fs/ext4/inode.c
===================================================================
--- linux-2.6.orig/fs/ext4/inode.c	2010-02-20 11:45:37.689004362 +0100
+++ linux-2.6/fs/ext4/inode.c	2010-02-20 11:46:29.854255514 +0100
@@ -1093,9 +1093,9 @@ void ext4_da_update_reserve_space(struct
 
 	/* Update quota subsystem */
 	if (quota_claim) {
-		vfs_dq_claim_block(inode, used);
+		dquot_claim_block(inode, used);
 		if (mdb_free)
-			vfs_dq_release_reservation_block(inode, mdb_free);
+			dquot_release_reservation_block(inode, mdb_free);
 	} else {
 		/*
 		 * We did fallocate with an offset that is already delayed
@@ -1106,8 +1106,8 @@ void ext4_da_update_reserve_space(struct
 		 * that
 		 */
 		if (allocated_meta_blocks)
-			vfs_dq_claim_block(inode, allocated_meta_blocks);
-		vfs_dq_release_reservation_block(inode, mdb_free + used);
+			dquot_claim_block(inode, allocated_meta_blocks);
+		dquot_release_reservation_block(inode, mdb_free + used);
 	}
 
 	/*
@@ -1853,11 +1853,11 @@ repeat:
 	 * later. Real quota accounting is done at pages writeout
 	 * time.
 	 */
-	if (vfs_dq_reserve_block(inode, md_needed + 1))
+	if (dquot_reserve_block(inode, md_needed + 1))
 		return -EDQUOT;
 
 	if (ext4_claim_free_blocks(sbi, md_needed + 1)) {
-		vfs_dq_release_reservation_block(inode, md_needed + 1);
+		dquot_release_reservation_block(inode, md_needed + 1);
 		if (ext4_should_retry_alloc(inode->i_sb, &retries)) {
 			yield();
 			goto repeat;
@@ -1914,7 +1914,7 @@ static void ext4_da_release_space(struct
 
 	spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
 
-	vfs_dq_release_reservation_block(inode, to_free);
+	dquot_release_reservation_block(inode, to_free);
 }
 
 static void ext4_da_page_release_reservation(struct page *page,
@@ -5641,7 +5641,7 @@ int ext4_mark_inode_dirty(handle_t *hand
  * i_size has been changed by generic_commit_write() and we thus need
  * to include the updated inode in the current transaction.
  *
- * Also, vfs_dq_alloc_block() will always dirty the inode when blocks
+ * Also, dquot_alloc_block() will always dirty the inode when blocks
  * are allocated to the file.
  *
  * If the inode is marked synchronous, we don't honour that here - doing
Index: linux-2.6/fs/ext4/mballoc.c
===================================================================
--- linux-2.6.orig/fs/ext4/mballoc.c	2010-02-20 11:45:37.698025314 +0100
+++ linux-2.6/fs/ext4/mballoc.c	2010-02-20 11:46:29.871006037 +0100
@@ -4254,7 +4254,7 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t
 			return 0;
 		}
 		reserv_blks = ar->len;
-		while (ar->len && vfs_dq_alloc_block(ar->inode, ar->len)) {
+		while (ar->len && dquot_alloc_block(ar->inode, ar->len)) {
 			ar->flags |= EXT4_MB_HINT_NOPREALLOC;
 			ar->len--;
 		}
@@ -4331,7 +4331,7 @@ out2:
 	kmem_cache_free(ext4_ac_cachep, ac);
 out1:
 	if (inquota && ar->len < inquota)
-		vfs_dq_free_block(ar->inode, inquota - ar->len);
+		dquot_free_block(ar->inode, inquota - ar->len);
 out3:
 	if (!ar->len) {
 		if (!EXT4_I(ar->inode)->i_delalloc_reserved_flag)
@@ -4646,7 +4646,7 @@ do_more:
 	sb->s_dirt = 1;
 error_return:
 	if (freed)
-		vfs_dq_free_block(inode, freed);
+		dquot_free_block(inode, freed);
 	brelse(bitmap_bh);
 	ext4_std_error(sb, err);
 	if (ac)
Index: linux-2.6/fs/ext4/xattr.c
===================================================================
--- linux-2.6.orig/fs/ext4/xattr.c	2010-02-20 11:45:37.707004012 +0100
+++ linux-2.6/fs/ext4/xattr.c	2010-02-20 11:46:29.899255304 +0100
@@ -494,7 +494,7 @@ ext4_xattr_release_block(handle_t *handl
 		error = ext4_handle_dirty_metadata(handle, inode, bh);
 		if (IS_SYNC(inode))
 			ext4_handle_sync(handle);
-		vfs_dq_free_block(inode, 1);
+		dquot_free_block(inode, 1);
 		ea_bdebug(bh, "refcount now=%d; releasing",
 			  le32_to_cpu(BHDR(bh)->h_refcount));
 		if (ce)
@@ -788,7 +788,7 @@ inserted:
 				/* The old block is released after updating
 				   the inode. */
 				error = -EDQUOT;
-				if (vfs_dq_alloc_block(inode, 1))
+				if (dquot_alloc_block(inode, 1))
 					goto cleanup;
 				error = ext4_journal_get_write_access(handle,
 								      new_bh);
@@ -876,7 +876,7 @@ cleanup:
 	return error;
 
 cleanup_dquot:
-	vfs_dq_free_block(inode, 1);
+	dquot_free_block(inode, 1);
 	goto cleanup;
 
 bad_block:
Index: linux-2.6/fs/jfs/jfs_dtree.c
===================================================================
--- linux-2.6.orig/fs/jfs/jfs_dtree.c	2010-02-20 11:45:37.833003873 +0100
+++ linux-2.6/fs/jfs/jfs_dtree.c	2010-02-20 11:46:29.912255933 +0100
@@ -381,10 +381,10 @@ static u32 add_index(tid_t tid, struct i
 		 * It's time to move the inline table to an external
 		 * page and begin to build the xtree
 		 */
-		if (vfs_dq_alloc_block(ip, sbi->nbperpage))
+		if (dquot_alloc_block(ip, sbi->nbperpage))
 			goto clean_up;
 		if (dbAlloc(ip, 0, sbi->nbperpage, &xaddr)) {
-			vfs_dq_free_block(ip, sbi->nbperpage);
+			dquot_free_block(ip, sbi->nbperpage);
 			goto clean_up;
 		}
 
@@ -408,7 +408,7 @@ static u32 add_index(tid_t tid, struct i
 			memcpy(&jfs_ip->i_dirtable, temp_table,
 			       sizeof (temp_table));
 			dbFree(ip, xaddr, sbi->nbperpage);
-			vfs_dq_free_block(ip, sbi->nbperpage);
+			dquot_free_block(ip, sbi->nbperpage);
 			goto clean_up;
 		}
 		ip->i_size = PSIZE;
@@ -1027,7 +1027,7 @@ static int dtSplitUp(tid_t tid,
 			n = xlen;
 
 		/* Allocate blocks to quota. */
-		if (vfs_dq_alloc_block(ip, n)) {
+		if (dquot_alloc_block(ip, n)) {
 			rc = -EDQUOT;
 			goto extendOut;
 		}
@@ -1308,7 +1308,7 @@ static int dtSplitUp(tid_t tid,
 
 	/* Rollback quota allocation */
 	if (rc && quota_allocation)
-		vfs_dq_free_block(ip, quota_allocation);
+		dquot_free_block(ip, quota_allocation);
 
       dtSplitUp_Exit:
 
@@ -1369,7 +1369,7 @@ static int dtSplitPage(tid_t tid, struct
 		return -EIO;
 
 	/* Allocate blocks to quota. */
-	if (vfs_dq_alloc_block(ip, lengthPXD(pxd))) {
+	if (dquot_alloc_block(ip, lengthPXD(pxd))) {
 		release_metapage(rmp);
 		return -EDQUOT;
 	}
@@ -1916,7 +1916,7 @@ static int dtSplitRoot(tid_t tid,
 	rp = rmp->data;
 
 	/* Allocate blocks to quota. */
-	if (vfs_dq_alloc_block(ip, lengthPXD(pxd))) {
+	if (dquot_alloc_block(ip, lengthPXD(pxd))) {
 		release_metapage(rmp);
 		return -EDQUOT;
 	}
@@ -2287,7 +2287,7 @@ static int dtDeleteUp(tid_t tid, struct 
 	xlen = lengthPXD(&fp->header.self);
 
 	/* Free quota allocation. */
-	vfs_dq_free_block(ip, xlen);
+	dquot_free_block(ip, xlen);
 
 	/* free/invalidate its buffer page */
 	discard_metapage(fmp);
@@ -2363,7 +2363,7 @@ static int dtDeleteUp(tid_t tid, struct 
 				xlen = lengthPXD(&p->header.self);
 
 				/* Free quota allocation */
-				vfs_dq_free_block(ip, xlen);
+				dquot_free_block(ip, xlen);
 
 				/* free/invalidate its buffer page */
 				discard_metapage(mp);
Index: linux-2.6/fs/jfs/jfs_extent.c
===================================================================
--- linux-2.6.orig/fs/jfs/jfs_extent.c	2010-02-20 11:45:37.842003524 +0100
+++ linux-2.6/fs/jfs/jfs_extent.c	2010-02-20 11:46:29.922314530 +0100
@@ -141,7 +141,7 @@ extAlloc(struct inode *ip, s64 xlen, s64
 	}
 
 	/* Allocate blocks to quota. */
-	if (vfs_dq_alloc_block(ip, nxlen)) {
+	if (dquot_alloc_block(ip, nxlen)) {
 		dbFree(ip, nxaddr, (s64) nxlen);
 		mutex_unlock(&JFS_IP(ip)->commit_mutex);
 		return -EDQUOT;
@@ -164,7 +164,7 @@ extAlloc(struct inode *ip, s64 xlen, s64
 	 */
 	if (rc) {
 		dbFree(ip, nxaddr, nxlen);
-		vfs_dq_free_block(ip, nxlen);
+		dquot_free_block(ip, nxlen);
 		mutex_unlock(&JFS_IP(ip)->commit_mutex);
 		return (rc);
 	}
@@ -256,7 +256,7 @@ int extRealloc(struct inode *ip, s64 nxl
 		goto exit;
 
 	/* Allocat blocks to quota. */
-	if (vfs_dq_alloc_block(ip, nxlen)) {
+	if (dquot_alloc_block(ip, nxlen)) {
 		dbFree(ip, nxaddr, (s64) nxlen);
 		mutex_unlock(&JFS_IP(ip)->commit_mutex);
 		return -EDQUOT;
@@ -297,7 +297,7 @@ int extRealloc(struct inode *ip, s64 nxl
 		/* extend the extent */
 		if ((rc = xtExtend(0, ip, xoff + xlen, (int) nextend, 0))) {
 			dbFree(ip, xaddr + xlen, delta);
-			vfs_dq_free_block(ip, nxlen);
+			dquot_free_block(ip, nxlen);
 			goto exit;
 		}
 	} else {
@@ -308,7 +308,7 @@ int extRealloc(struct inode *ip, s64 nxl
 		 */
 		if ((rc = xtTailgate(0, ip, xoff, (int) ntail, nxaddr, 0))) {
 			dbFree(ip, nxaddr, nxlen);
-			vfs_dq_free_block(ip, nxlen);
+			dquot_free_block(ip, nxlen);
 			goto exit;
 		}
 	}
Index: linux-2.6/fs/jfs/jfs_xtree.c
===================================================================
--- linux-2.6.orig/fs/jfs/jfs_xtree.c	2010-02-20 11:45:37.851004571 +0100
+++ linux-2.6/fs/jfs/jfs_xtree.c	2010-02-20 11:46:29.928005130 +0100
@@ -585,10 +585,10 @@ int xtInsert(tid_t tid,		/* transaction 
 			hint = addressXAD(xad) + lengthXAD(xad) - 1;
 		} else
 			hint = 0;
-		if ((rc = vfs_dq_alloc_block(ip, xlen)))
+		if ((rc = dquot_alloc_block(ip, xlen)))
 			goto out;
 		if ((rc = dbAlloc(ip, hint, (s64) xlen, &xaddr))) {
-			vfs_dq_free_block(ip, xlen);
+			dquot_free_block(ip, xlen);
 			goto out;
 		}
 	}
@@ -617,7 +617,7 @@ int xtInsert(tid_t tid,		/* transaction 
 			/* undo data extent allocation */
 			if (*xaddrp == 0) {
 				dbFree(ip, xaddr, (s64) xlen);
-				vfs_dq_free_block(ip, xlen);
+				dquot_free_block(ip, xlen);
 			}
 			return rc;
 		}
@@ -985,7 +985,7 @@ xtSplitPage(tid_t tid, struct inode *ip,
 	rbn = addressPXD(pxd);
 
 	/* Allocate blocks to quota. */
-	if (vfs_dq_alloc_block(ip, lengthPXD(pxd))) {
+	if (dquot_alloc_block(ip, lengthPXD(pxd))) {
 		rc = -EDQUOT;
 		goto clean_up;
 	}
@@ -1195,7 +1195,7 @@ xtSplitPage(tid_t tid, struct inode *ip,
 
 	/* Rollback quota allocation. */
 	if (quota_allocation)
-		vfs_dq_free_block(ip, quota_allocation);
+		dquot_free_block(ip, quota_allocation);
 
 	return (rc);
 }
@@ -1252,7 +1252,7 @@ xtSplitRoot(tid_t tid,
 		return -EIO;
 
 	/* Allocate blocks to quota. */
-	if (vfs_dq_alloc_block(ip, lengthPXD(pxd))) {
+	if (dquot_alloc_block(ip, lengthPXD(pxd))) {
 		release_metapage(rmp);
 		return -EDQUOT;
 	}
@@ -3680,7 +3680,7 @@ s64 xtTruncate(tid_t tid, struct inode *
 		ip->i_size = newsize;
 
 	/* update quota allocation to reflect freed blocks */
-	vfs_dq_free_block(ip, nfreed);
+	dquot_free_block(ip, nfreed);
 
 	/*
 	 * free tlock of invalidated pages
Index: linux-2.6/fs/jfs/xattr.c
===================================================================
--- linux-2.6.orig/fs/jfs/xattr.c	2010-02-20 11:45:37.860004082 +0100
+++ linux-2.6/fs/jfs/xattr.c	2010-02-20 11:46:29.937005689 +0100
@@ -260,14 +260,14 @@ static int ea_write(struct inode *ip, st
 	nblocks = (size + (sb->s_blocksize - 1)) >> sb->s_blocksize_bits;
 
 	/* Allocate new blocks to quota. */
-	if (vfs_dq_alloc_block(ip, nblocks)) {
+	if (dquot_alloc_block(ip, nblocks)) {
 		return -EDQUOT;
 	}
 
 	rc = dbAlloc(ip, INOHINT(ip), nblocks, &blkno);
 	if (rc) {
 		/*Rollback quota allocation. */
-		vfs_dq_free_block(ip, nblocks);
+		dquot_free_block(ip, nblocks);
 		return rc;
 	}
 
@@ -332,7 +332,7 @@ static int ea_write(struct inode *ip, st
 
       failed:
 	/* Rollback quota allocation. */
-	vfs_dq_free_block(ip, nblocks);
+	dquot_free_block(ip, nblocks);
 
 	dbFree(ip, blkno, nblocks);
 	return rc;
@@ -538,7 +538,7 @@ static int ea_get(struct inode *inode, s
 
 	if (blocks_needed > current_blocks) {
 		/* Allocate new blocks to quota. */
-		if (vfs_dq_alloc_block(inode, blocks_needed))
+		if (dquot_alloc_block(inode, blocks_needed))
 			return -EDQUOT;
 
 		quota_allocation = blocks_needed;
@@ -602,7 +602,7 @@ static int ea_get(struct inode *inode, s
       clean_up:
 	/* Rollback quota allocation */
 	if (quota_allocation)
-		vfs_dq_free_block(inode, quota_allocation);
+		dquot_free_block(inode, quota_allocation);
 
 	return (rc);
 }
@@ -677,7 +677,7 @@ static int ea_put(tid_t tid, struct inod
 
 	/* If old blocks exist, they must be removed from quota allocation. */
 	if (old_blocks)
-		vfs_dq_free_block(inode, old_blocks);
+		dquot_free_block(inode, old_blocks);
 
 	inode->i_ctime = CURRENT_TIME;
 
Index: linux-2.6/fs/ocfs2/alloc.c
===================================================================
--- linux-2.6.orig/fs/ocfs2/alloc.c	2010-02-20 11:45:37.725003873 +0100
+++ linux-2.6/fs/ocfs2/alloc.c	2010-02-20 11:46:29.945005828 +0100
@@ -5712,7 +5712,7 @@ int ocfs2_remove_btree_range(struct inod
 		goto out;
 	}
 
-	vfs_dq_free_space_nodirty(inode,
+	dquot_free_space_nodirty(inode,
 				  ocfs2_clusters_to_bytes(inode->i_sb, len));
 
 	ret = ocfs2_remove_extent(handle, et, cpos, len, meta_ac, dealloc);
@@ -6935,7 +6935,7 @@ static int ocfs2_do_truncate(struct ocfs
 		goto bail;
 	}
 
-	vfs_dq_free_space_nodirty(inode,
+	dquot_free_space_nodirty(inode,
 			ocfs2_clusters_to_bytes(osb->sb, clusters_to_del));
 	spin_lock(&OCFS2_I(inode)->ip_lock);
 	OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters) -
@@ -7300,7 +7300,7 @@ int ocfs2_convert_inline_data_to_extents
 		unsigned int page_end;
 		u64 phys;
 
-		if (vfs_dq_alloc_space_nodirty(inode,
+		if (dquot_alloc_space_nodirty(inode,
 				       ocfs2_clusters_to_bytes(osb->sb, 1))) {
 			ret = -EDQUOT;
 			goto out_commit;
@@ -7380,7 +7380,7 @@ int ocfs2_convert_inline_data_to_extents
 
 out_commit:
 	if (ret < 0 && did_quota)
-		vfs_dq_free_space_nodirty(inode,
+		dquot_free_space_nodirty(inode,
 					  ocfs2_clusters_to_bytes(osb->sb, 1));
 
 	ocfs2_commit_trans(osb, handle);
Index: linux-2.6/fs/ocfs2/aops.c
===================================================================
--- linux-2.6.orig/fs/ocfs2/aops.c	2010-02-20 11:45:37.734004082 +0100
+++ linux-2.6/fs/ocfs2/aops.c	2010-02-20 11:46:29.981025384 +0100
@@ -1763,7 +1763,7 @@ int ocfs2_write_begin_nolock(struct addr
 
 	wc->w_handle = handle;
 
-	if (clusters_to_alloc && vfs_dq_alloc_space_nodirty(inode,
+	if (clusters_to_alloc && dquot_alloc_space_nodirty(inode,
 			ocfs2_clusters_to_bytes(osb->sb, clusters_to_alloc))) {
 		ret = -EDQUOT;
 		goto out_commit;
@@ -1809,7 +1809,7 @@ success:
 	return 0;
 out_quota:
 	if (clusters_to_alloc)
-		vfs_dq_free_space(inode,
+		dquot_free_space(inode,
 			  ocfs2_clusters_to_bytes(osb->sb, clusters_to_alloc));
 out_commit:
 	ocfs2_commit_trans(osb, handle);
Index: linux-2.6/fs/ocfs2/dir.c
===================================================================
--- linux-2.6.orig/fs/ocfs2/dir.c	2010-02-20 11:45:37.742253977 +0100
+++ linux-2.6/fs/ocfs2/dir.c	2010-02-20 11:46:29.995004850 +0100
@@ -2964,7 +2964,7 @@ static int ocfs2_expand_inline_dir(struc
 		goto out;
 	}
 
-	if (vfs_dq_alloc_space_nodirty(dir,
+	if (dquot_alloc_space_nodirty(dir,
 				ocfs2_clusters_to_bytes(osb->sb,
 							alloc + dx_alloc))) {
 		ret = -EDQUOT;
@@ -3178,7 +3178,7 @@ static int ocfs2_expand_inline_dir(struc
 
 out_commit:
 	if (ret < 0 && did_quota)
-		vfs_dq_free_space_nodirty(dir, bytes_allocated);
+		dquot_free_space_nodirty(dir, bytes_allocated);
 
 	ocfs2_commit_trans(osb, handle);
 
@@ -3221,7 +3221,7 @@ static int ocfs2_do_extend_dir(struct su
 	if (extend) {
 		u32 offset = OCFS2_I(dir)->ip_clusters;
 
-		if (vfs_dq_alloc_space_nodirty(dir,
+		if (dquot_alloc_space_nodirty(dir,
 					ocfs2_clusters_to_bytes(sb, 1))) {
 			status = -EDQUOT;
 			goto bail;
@@ -3254,7 +3254,7 @@ static int ocfs2_do_extend_dir(struct su
 	status = 0;
 bail:
 	if (did_quota && status < 0)
-		vfs_dq_free_space_nodirty(dir, ocfs2_clusters_to_bytes(sb, 1));
+		dquot_free_space_nodirty(dir, ocfs2_clusters_to_bytes(sb, 1));
 	mlog_exit(status);
 	return status;
 }
@@ -3889,7 +3889,7 @@ static int ocfs2_dx_dir_rebalance(struct
 		goto out;
 	}
 
-	if (vfs_dq_alloc_space_nodirty(dir,
+	if (dquot_alloc_space_nodirty(dir,
 				       ocfs2_clusters_to_bytes(dir->i_sb, 1))) {
 		ret = -EDQUOT;
 		goto out_commit;
@@ -3983,7 +3983,7 @@ static int ocfs2_dx_dir_rebalance(struct
 
 out_commit:
 	if (ret < 0 && did_quota)
-		vfs_dq_free_space_nodirty(dir,
+		dquot_free_space_nodirty(dir,
 				ocfs2_clusters_to_bytes(dir->i_sb, 1));
 
 	ocfs2_commit_trans(osb, handle);
@@ -4165,7 +4165,7 @@ static int ocfs2_expand_inline_dx_root(s
 		goto out;
 	}
 
-	if (vfs_dq_alloc_space_nodirty(dir,
+	if (dquot_alloc_space_nodirty(dir,
 				       ocfs2_clusters_to_bytes(osb->sb, 1))) {
 		ret = -EDQUOT;
 		goto out_commit;
@@ -4229,7 +4229,7 @@ static int ocfs2_expand_inline_dx_root(s
 
 out_commit:
 	if (ret < 0 && did_quota)
-		vfs_dq_free_space_nodirty(dir,
+		dquot_free_space_nodirty(dir,
 					  ocfs2_clusters_to_bytes(dir->i_sb, 1));
 
 	ocfs2_commit_trans(osb, handle);
Index: linux-2.6/fs/ocfs2/file.c
===================================================================
--- linux-2.6.orig/fs/ocfs2/file.c	2010-02-20 11:45:37.750262358 +0100
+++ linux-2.6/fs/ocfs2/file.c	2010-02-20 11:46:30.009005758 +0100
@@ -629,7 +629,7 @@ restart_all:
 	}
 
 restarted_transaction:
-	if (vfs_dq_alloc_space_nodirty(inode, ocfs2_clusters_to_bytes(osb->sb,
+	if (dquot_alloc_space_nodirty(inode, ocfs2_clusters_to_bytes(osb->sb,
 	    clusters_to_add))) {
 		status = -EDQUOT;
 		goto leave;
@@ -674,7 +674,7 @@ restarted_transaction:
 	clusters_to_add -= (OCFS2_I(inode)->ip_clusters - prev_clusters);
 	spin_unlock(&OCFS2_I(inode)->ip_lock);
 	/* Release unused quota reservation */
-	vfs_dq_free_space(inode,
+	dquot_free_space(inode,
 			ocfs2_clusters_to_bytes(osb->sb, clusters_to_add));
 	did_quota = 0;
 
@@ -710,7 +710,7 @@ restarted_transaction:
 
 leave:
 	if (status < 0 && did_quota)
-		vfs_dq_free_space(inode,
+		dquot_free_space(inode,
 			ocfs2_clusters_to_bytes(osb->sb, clusters_to_add));
 	if (handle) {
 		ocfs2_commit_trans(osb, handle);
Index: linux-2.6/fs/ocfs2/namei.c
===================================================================
--- linux-2.6.orig/fs/ocfs2/namei.c	2010-02-20 11:45:37.760254117 +0100
+++ linux-2.6/fs/ocfs2/namei.c	2010-02-20 11:46:30.014005898 +0100
@@ -1716,7 +1716,7 @@ static int ocfs2_symlink(struct inode *d
 		u32 offset = 0;
 
 		inode->i_op = &ocfs2_symlink_inode_operations;
-		if (vfs_dq_alloc_space_nodirty(inode,
+		if (dquot_alloc_space_nodirty(inode,
 		    ocfs2_clusters_to_bytes(osb->sb, 1))) {
 			status = -EDQUOT;
 			goto bail;
@@ -1788,7 +1788,7 @@ static int ocfs2_symlink(struct inode *d
 	d_instantiate(dentry, inode);
 bail:
 	if (status < 0 && did_quota)
-		vfs_dq_free_space_nodirty(inode,
+		dquot_free_space_nodirty(inode,
 					ocfs2_clusters_to_bytes(osb->sb, 1));
 	if (status < 0 && did_quota_inode)
 		vfs_dq_free_inode(inode);
Index: linux-2.6/fs/reiserfs/bitmap.c
===================================================================
--- linux-2.6.orig/fs/reiserfs/bitmap.c	2010-02-20 11:45:37.793255444 +0100
+++ linux-2.6/fs/reiserfs/bitmap.c	2010-02-20 11:46:30.019253977 +0100
@@ -425,7 +425,7 @@ static void _reiserfs_free_block(struct 
 
 	journal_mark_dirty(th, s, sbh);
 	if (for_unformatted)
-		vfs_dq_free_block_nodirty(inode, 1);
+		dquot_free_block_nodirty(inode, 1);
 }
 
 void reiserfs_free_block(struct reiserfs_transaction_handle *th,
@@ -1049,7 +1049,7 @@ static inline int blocknrs_and_prealloc_
 			       amount_needed, hint->inode->i_uid);
 #endif
 		quota_ret =
-		    vfs_dq_alloc_block_nodirty(hint->inode, amount_needed);
+		    dquot_alloc_block_nodirty(hint->inode, amount_needed);
 		if (quota_ret)	/* Quota exceeded? */
 			return QUOTA_EXCEEDED;
 		if (hint->preallocate && hint->prealloc_size) {
@@ -1058,7 +1058,7 @@ static inline int blocknrs_and_prealloc_
 				       "reiserquota: allocating (prealloc) %d blocks id=%u",
 				       hint->prealloc_size, hint->inode->i_uid);
 #endif
-			quota_ret = vfs_dq_prealloc_block_nodirty(hint->inode,
+			quota_ret = dquot_prealloc_block_nodirty(hint->inode,
 							 hint->prealloc_size);
 			if (quota_ret)
 				hint->preallocate = hint->prealloc_size = 0;
@@ -1092,7 +1092,7 @@ static inline int blocknrs_and_prealloc_
 					       hint->inode->i_uid);
 #endif
 				/* Free not allocated blocks */
-				vfs_dq_free_block_nodirty(hint->inode,
+				dquot_free_block_nodirty(hint->inode,
 					amount_needed + hint->prealloc_size -
 					nr_allocated);
 			}
@@ -1125,7 +1125,7 @@ static inline int blocknrs_and_prealloc_
 			       REISERFS_I(hint->inode)->i_prealloc_count,
 			       hint->inode->i_uid);
 #endif
-		vfs_dq_free_block_nodirty(hint->inode, amount_needed +
+		dquot_free_block_nodirty(hint->inode, amount_needed +
 					 hint->prealloc_size - nr_allocated -
 					 REISERFS_I(hint->inode)->
 					 i_prealloc_count);
Index: linux-2.6/fs/reiserfs/stree.c
===================================================================
--- linux-2.6.orig/fs/reiserfs/stree.c	2010-02-20 11:45:37.805254396 +0100
+++ linux-2.6/fs/reiserfs/stree.c	2010-02-20 11:46:30.025032787 +0100
@@ -1299,7 +1299,7 @@ int reiserfs_delete_item(struct reiserfs
 		       "reiserquota delete_item(): freeing %u, id=%u type=%c",
 		       quota_cut_bytes, inode->i_uid, head2type(&s_ih));
 #endif
-	vfs_dq_free_space_nodirty(inode, quota_cut_bytes);
+	dquot_free_space_nodirty(inode, quota_cut_bytes);
 
 	/* Return deleted body length */
 	return ret_value;
@@ -1383,7 +1383,7 @@ void reiserfs_delete_solid_item(struct r
 					       quota_cut_bytes, inode->i_uid,
 					       key2type(key));
 #endif
-				vfs_dq_free_space_nodirty(inode,
+				dquot_free_space_nodirty(inode,
 							 quota_cut_bytes);
 			}
 			break;
@@ -1733,7 +1733,7 @@ int reiserfs_cut_from_item(struct reiser
 		       "reiserquota cut_from_item(): freeing %u id=%u type=%c",
 		       quota_cut_bytes, inode->i_uid, '?');
 #endif
-	vfs_dq_free_space_nodirty(inode, quota_cut_bytes);
+	dquot_free_space_nodirty(inode, quota_cut_bytes);
 	return ret_value;
 }
 
@@ -1968,7 +1968,7 @@ int reiserfs_paste_into_item(struct reis
 		       key2type(&(key->on_disk_key)));
 #endif
 
-	if (vfs_dq_alloc_space_nodirty(inode, pasted_size)) {
+	if (dquot_alloc_space_nodirty(inode, pasted_size)) {
 		pathrelse(search_path);
 		return -EDQUOT;
 	}
@@ -2024,7 +2024,7 @@ int reiserfs_paste_into_item(struct reis
 		       pasted_size, inode->i_uid,
 		       key2type(&(key->on_disk_key)));
 #endif
-	vfs_dq_free_space_nodirty(inode, pasted_size);
+	dquot_free_space_nodirty(inode, pasted_size);
 	return retval;
 }
 
@@ -2062,7 +2062,7 @@ int reiserfs_insert_item(struct reiserfs
 #endif
 		/* We can't dirty inode here. It would be immediately written but
 		 * appropriate stat item isn't inserted yet... */
-		if (vfs_dq_alloc_space_nodirty(inode, quota_bytes)) {
+		if (dquot_alloc_space_nodirty(inode, quota_bytes)) {
 			pathrelse(path);
 			return -EDQUOT;
 		}
@@ -2113,6 +2113,6 @@ int reiserfs_insert_item(struct reiserfs
 		       quota_bytes, inode->i_uid, head2type(ih));
 #endif
 	if (inode)
-		vfs_dq_free_space_nodirty(inode, quota_bytes);
+		dquot_free_space_nodirty(inode, quota_bytes);
 	return retval;
 }
Index: linux-2.6/fs/udf/balloc.c
===================================================================
--- linux-2.6.orig/fs/udf/balloc.c	2010-02-20 11:45:37.870026432 +0100
+++ linux-2.6/fs/udf/balloc.c	2010-02-20 11:46:30.043006247 +0100
@@ -208,7 +208,7 @@ static void udf_bitmap_free_blocks(struc
 					((char *)bh->b_data)[(bit + i) >> 3]);
 			} else {
 				if (inode)
-					vfs_dq_free_block(inode, 1);
+					dquot_free_block(inode, 1);
 				udf_add_free_space(sb, sbi->s_partition, 1);
 			}
 		}
@@ -260,11 +260,11 @@ static int udf_bitmap_prealloc_blocks(st
 		while (bit < (sb->s_blocksize << 3) && block_count > 0) {
 			if (!udf_test_bit(bit, bh->b_data))
 				goto out;
-			else if (vfs_dq_prealloc_block(inode, 1))
+			else if (dquot_prealloc_block(inode, 1))
 				goto out;
 			else if (!udf_clear_bit(bit, bh->b_data)) {
 				udf_debug("bit already cleared for block %d\n", bit);
-				vfs_dq_free_block(inode, 1);
+				dquot_free_block(inode, 1);
 				goto out;
 			}
 			block_count--;
@@ -390,7 +390,7 @@ got_block:
 	/*
 	 * Check quota for allocation of this block.
 	 */
-	if (inode && vfs_dq_alloc_block(inode, 1)) {
+	if (inode && dquot_alloc_block(inode, 1)) {
 		mutex_unlock(&sbi->s_alloc_mutex);
 		*err = -EDQUOT;
 		return 0;
@@ -449,7 +449,7 @@ static void udf_table_free_blocks(struct
 	/* We do this up front - There are some error conditions that
 	   could occure, but.. oh well */
 	if (inode)
-		vfs_dq_free_block(inode, count);
+		dquot_free_block(inode, count);
 	udf_add_free_space(sb, sbi->s_partition, count);
 
 	start = bloc->logicalBlockNum + offset;
@@ -694,7 +694,7 @@ static int udf_table_prealloc_blocks(str
 		epos.offset -= adsize;
 
 		alloc_count = (elen >> sb->s_blocksize_bits);
-		if (inode && vfs_dq_prealloc_block(inode,
+		if (inode && dquot_prealloc_block(inode,
 			alloc_count > block_count ? block_count : alloc_count))
 			alloc_count = 0;
 		else if (alloc_count > block_count) {
@@ -798,7 +798,7 @@ static int udf_table_new_block(struct su
 	goal_eloc.logicalBlockNum++;
 	goal_elen -= sb->s_blocksize;
 
-	if (inode && vfs_dq_alloc_block(inode, 1)) {
+	if (inode && dquot_alloc_block(inode, 1)) {
 		brelse(goal_epos.bh);
 		mutex_unlock(&sbi->s_alloc_mutex);
 		*err = -EDQUOT;
Index: linux-2.6/fs/ufs/balloc.c
===================================================================
--- linux-2.6.orig/fs/ufs/balloc.c	2010-02-20 11:45:37.880004082 +0100
+++ linux-2.6/fs/ufs/balloc.c	2010-02-20 11:46:30.051005828 +0100
@@ -85,7 +85,7 @@ void ufs_free_fragments(struct inode *in
 				   "bit already cleared for fragment %u", i);
 	}
 	
-	vfs_dq_free_block(inode, count);
+	dquot_free_block(inode, count);
 
 	
 	fs32_add(sb, &ucg->cg_cs.cs_nffree, count);
@@ -195,7 +195,7 @@ do_more:
 		ubh_setblock(UCPI_UBH(ucpi), ucpi->c_freeoff, blkno);
 		if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD)
 			ufs_clusteracct (sb, ucpi, blkno, 1);
-		vfs_dq_free_block(inode, uspi->s_fpb);
+		dquot_free_block(inode, uspi->s_fpb);
 
 		fs32_add(sb, &ucg->cg_cs.cs_nbfree, 1);
 		uspi->cs_total.cs_nbfree++;
@@ -556,7 +556,7 @@ static u64 ufs_add_fragments(struct inod
 		fs32_add(sb, &ucg->cg_frsum[fragsize - count], 1);
 	for (i = oldcount; i < newcount; i++)
 		ubh_clrbit (UCPI_UBH(ucpi), ucpi->c_freeoff, fragno + i);
-	if (vfs_dq_alloc_block(inode, count)) {
+	if (dquot_alloc_block(inode, count)) {
 		*err = -EDQUOT;
 		return 0;
 	}
@@ -664,7 +664,7 @@ cg_found:
 		for (i = count; i < uspi->s_fpb; i++)
 			ubh_setbit (UCPI_UBH(ucpi), ucpi->c_freeoff, goal + i);
 		i = uspi->s_fpb - count;
-		vfs_dq_free_block(inode, i);
+		dquot_free_block(inode, i);
 
 		fs32_add(sb, &ucg->cg_cs.cs_nffree, i);
 		uspi->cs_total.cs_nffree += i;
@@ -676,7 +676,7 @@ cg_found:
 	result = ufs_bitmap_search (sb, ucpi, goal, allocsize);
 	if (result == INVBLOCK)
 		return 0;
-	if (vfs_dq_alloc_block(inode, count)) {
+	if (dquot_alloc_block(inode, count)) {
 		*err = -EDQUOT;
 		return 0;
 	}
@@ -747,7 +747,7 @@ gotit:
 	ubh_clrblock (UCPI_UBH(ucpi), ucpi->c_freeoff, blkno);
 	if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD)
 		ufs_clusteracct (sb, ucpi, blkno, -1);
-	if (vfs_dq_alloc_block(inode, uspi->s_fpb)) {
+	if (dquot_alloc_block(inode, uspi->s_fpb)) {
 		*err = -EDQUOT;
 		return INVBLOCK;
 	}


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

* [PATCH 2/8] dquot: cleanup inode allocation / freeing routines
  2010-02-20 11:51 [PATCH 0/8] dquot interface cleanups Christoph Hellwig
  2010-02-20 11:51 ` [PATCH 1/8] dquot: cleanup space allocation / freeing routines Christoph Hellwig
@ 2010-02-20 11:51 ` Christoph Hellwig
  2010-02-24 22:39   ` Jan Kara
  2010-02-20 11:51 ` [PATCH 3/8] dquot: move dquot transfer responsibiliy into the filesystem Christoph Hellwig
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 26+ messages in thread
From: Christoph Hellwig @ 2010-02-20 11:51 UTC (permalink / raw)
  To: jack; +Cc: linux-fsdevel

[-- Attachment #1: quota-kill-alloc_inode --]
[-- Type: text/plain, Size: 18954 bytes --]

Get rid of the alloc_inode and free_inode dquot operations - they are
always called from the filesystem and if a filesystem really needs
their own (which none currently does) it can just call into it's
own routine directly.

Also get rid of the vfs_dq_alloc/vfs_dq_free wrappers and always
call the lowlevel dquot_alloc_inode / dqout_free_inode routines
directly, which now lose the number argument which is always 1.

Signed-off-by: Christoph Hellwig <hch@lst.de>

Index: linux-2.6/Documentation/filesystems/Locking
===================================================================
--- linux-2.6.orig/Documentation/filesystems/Locking	2010-02-20 11:46:29.732254256 +0100
+++ linux-2.6/Documentation/filesystems/Locking	2010-02-20 12:15:36.974004850 +0100
@@ -462,8 +462,6 @@ in sys_read() and friends.
 prototypes:
 	int (*initialize) (struct inode *, int);
 	int (*drop) (struct inode *);
-	int (*alloc_inode) (const struct inode *, unsigned long);
-	int (*free_inode) (const struct inode *, unsigned long);
 	int (*transfer) (struct inode *, struct iattr *);
 	int (*write_dquot) (struct dquot *);
 	int (*acquire_dquot) (struct dquot *);
@@ -479,8 +477,6 @@ What filesystem should expect from the g
 		FS recursion	Held locks when called
 initialize:	yes		maybe dqonoff_sem
 drop:		yes		-
-alloc_inode:	->mark_dirty()	-
-free_inode:	->mark_dirty()	-
 transfer:	yes		-
 write_dquot:	yes		dqonoff_sem or dqptr_sem
 acquire_dquot:	yes		dqonoff_sem or dqptr_sem
@@ -491,10 +487,6 @@ write_info:	yes		dqonoff_sem
 FS recursion means calling ->quota_read() and ->quota_write() from superblock
 operations.
 
-->alloc_inode(), ->free_inode() are called
-only directly by the filesystem and do not call any fs functions only
-the ->mark_dirty() operation.
-
 More details about quota locking can be found in fs/dquot.c.
 
 --------------------------- vm_operations_struct -----------------------------
Index: linux-2.6/fs/ext3/super.c
===================================================================
--- linux-2.6.orig/fs/ext3/super.c	2010-02-20 11:46:29.743440315 +0100
+++ linux-2.6/fs/ext3/super.c	2010-02-20 12:15:36.983004151 +0100
@@ -752,8 +752,6 @@ static ssize_t ext3_quota_write(struct s
 static const struct dquot_operations ext3_quota_operations = {
 	.initialize	= dquot_initialize,
 	.drop		= dquot_drop,
-	.alloc_inode	= dquot_alloc_inode,
-	.free_inode	= dquot_free_inode,
 	.transfer	= dquot_transfer,
 	.write_dquot	= ext3_write_dquot,
 	.acquire_dquot	= ext3_acquire_dquot,
Index: linux-2.6/fs/ext4/super.c
===================================================================
--- linux-2.6.orig/fs/ext4/super.c	2010-02-20 11:46:29.762194960 +0100
+++ linux-2.6/fs/ext4/super.c	2010-02-20 12:15:37.003004221 +0100
@@ -1017,8 +1017,6 @@ static const struct dquot_operations ext
 #ifdef CONFIG_QUOTA
 	.get_reserved_space = ext4_get_reserved_space,
 #endif
-	.alloc_inode	= dquot_alloc_inode,
-	.free_inode	= dquot_free_inode,
 	.transfer	= dquot_transfer,
 	.write_dquot	= ext4_write_dquot,
 	.acquire_dquot	= ext4_acquire_dquot,
Index: linux-2.6/fs/ocfs2/namei.c
===================================================================
--- linux-2.6.orig/fs/ocfs2/namei.c	2010-02-20 11:46:30.014005898 +0100
+++ linux-2.6/fs/ocfs2/namei.c	2010-02-20 12:15:27.774010507 +0100
@@ -348,10 +348,7 @@ static int ocfs2_mknod(struct inode *dir
 		goto leave;
 	}
 
-	/* We don't use standard VFS wrapper because we don't want vfs_dq_init
-	 * to be called. */
-	if (sb_any_quota_active(osb->sb) &&
-	    osb->sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA) {
+	if (dquot_alloc_inode(inode)) {
 		status = -EDQUOT;
 		goto leave;
 	}
@@ -431,7 +428,7 @@ static int ocfs2_mknod(struct inode *dir
 	status = 0;
 leave:
 	if (status < 0 && did_quota_inode)
-		vfs_dq_free_inode(inode);
+		dquot_free_inode(inode);
 	if (handle)
 		ocfs2_commit_trans(osb, handle);
 
@@ -1688,10 +1685,7 @@ static int ocfs2_symlink(struct inode *d
 		goto bail;
 	}
 
-	/* We don't use standard VFS wrapper because we don't want vfs_dq_init
-	 * to be called. */
-	if (sb_any_quota_active(osb->sb) &&
-	    osb->sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA) {
+	if (dquot_alloc_inode(inode)) {
 		status = -EDQUOT;
 		goto bail;
 	}
@@ -1791,7 +1785,7 @@ bail:
 		dquot_free_space_nodirty(inode,
 					ocfs2_clusters_to_bytes(osb->sb, 1));
 	if (status < 0 && did_quota_inode)
-		vfs_dq_free_inode(inode);
+		dquot_free_inode(inode);
 	if (handle)
 		ocfs2_commit_trans(osb, handle);
 
@@ -2099,10 +2093,7 @@ int ocfs2_create_inode_in_orphan(struct 
 		goto leave;
 	}
 
-	/* We don't use standard VFS wrapper because we don't want vfs_dq_init
-	 * to be called. */
-	if (sb_any_quota_active(osb->sb) &&
-	    osb->sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA) {
+	if (dquot_alloc_inode(inode)) {
 		status = -EDQUOT;
 		goto leave;
 	}
@@ -2140,7 +2131,7 @@ int ocfs2_create_inode_in_orphan(struct 
 	insert_inode_hash(inode);
 leave:
 	if (status < 0 && did_quota_inode)
-		vfs_dq_free_inode(inode);
+		dquot_free_inode(inode);
 	if (handle)
 		ocfs2_commit_trans(osb, handle);
 
Index: linux-2.6/fs/ocfs2/quota_global.c
===================================================================
--- linux-2.6.orig/fs/ocfs2/quota_global.c	2010-02-20 11:46:29.772255792 +0100
+++ linux-2.6/fs/ocfs2/quota_global.c	2010-02-20 12:15:37.025253208 +0100
@@ -853,8 +853,6 @@ static void ocfs2_destroy_dquot(struct d
 const struct dquot_operations ocfs2_quota_operations = {
 	.initialize	= dquot_initialize,
 	.drop		= dquot_drop,
-	.alloc_inode	= dquot_alloc_inode,
-	.free_inode	= dquot_free_inode,
 	.transfer	= dquot_transfer,
 	.write_dquot	= ocfs2_write_dquot,
 	.acquire_dquot	= ocfs2_acquire_dquot,
Index: linux-2.6/fs/quota/dquot.c
===================================================================
--- linux-2.6.orig/fs/quota/dquot.c	2010-02-20 11:47:23.752007784 +0100
+++ linux-2.6/fs/quota/dquot.c	2010-02-20 12:15:37.043254605 +0100
@@ -1531,15 +1531,15 @@ EXPORT_SYMBOL(__dquot_alloc_space);
 /*
  * This operation can block, but only after everything is updated
  */
-int dquot_alloc_inode(const struct inode *inode, qsize_t number)
+int dquot_alloc_inode(const struct inode *inode)
 {
-	int cnt, ret = NO_QUOTA;
+	int cnt, ret = 1;
 	char warntype[MAXQUOTAS];
 
 	/* First test before acquiring mutex - solves deadlocks when we
          * re-enter the quota code and are already holding the mutex */
-	if (IS_NOQUOTA(inode))
-		return QUOTA_OK;
+	if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode))
+		return 0;
 	for (cnt = 0; cnt < MAXQUOTAS; cnt++)
 		warntype[cnt] = QUOTA_NL_NOWARN;
 	down_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
@@ -1547,7 +1547,7 @@ int dquot_alloc_inode(const struct inode
 	for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
 		if (!inode->i_dquot[cnt])
 			continue;
-		if (check_idq(inode->i_dquot[cnt], number, warntype+cnt)
+		if (check_idq(inode->i_dquot[cnt], 1, warntype+cnt)
 		    == NO_QUOTA)
 			goto warn_put_all;
 	}
@@ -1555,12 +1555,12 @@ int dquot_alloc_inode(const struct inode
 	for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
 		if (!inode->i_dquot[cnt])
 			continue;
-		dquot_incr_inodes(inode->i_dquot[cnt], number);
+		dquot_incr_inodes(inode->i_dquot[cnt], 1);
 	}
-	ret = QUOTA_OK;
+	ret = 0;
 warn_put_all:
 	spin_unlock(&dq_data_lock);
-	if (ret == QUOTA_OK)
+	if (ret == 0)
 		mark_all_dquot_dirty(inode->i_dquot);
 	flush_warnings(inode->i_dquot, warntype);
 	up_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
@@ -1638,29 +1638,28 @@ EXPORT_SYMBOL(__dquot_free_space);
 /*
  * This operation can block, but only after everything is updated
  */
-int dquot_free_inode(const struct inode *inode, qsize_t number)
+void dquot_free_inode(const struct inode *inode)
 {
 	unsigned int cnt;
 	char warntype[MAXQUOTAS];
 
 	/* First test before acquiring mutex - solves deadlocks when we
          * re-enter the quota code and are already holding the mutex */
-	if (IS_NOQUOTA(inode))
-		return QUOTA_OK;
+	if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode))
+		return;
 
 	down_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
 	spin_lock(&dq_data_lock);
 	for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
 		if (!inode->i_dquot[cnt])
 			continue;
-		warntype[cnt] = info_idq_free(inode->i_dquot[cnt], number);
-		dquot_decr_inodes(inode->i_dquot[cnt], number);
+		warntype[cnt] = info_idq_free(inode->i_dquot[cnt], 1);
+		dquot_decr_inodes(inode->i_dquot[cnt], 1);
 	}
 	spin_unlock(&dq_data_lock);
 	mark_all_dquot_dirty(inode->i_dquot);
 	flush_warnings(inode->i_dquot, warntype);
 	up_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
-	return QUOTA_OK;
 }
 EXPORT_SYMBOL(dquot_free_inode);
 
@@ -1815,8 +1814,6 @@ EXPORT_SYMBOL(dquot_commit_info);
 const struct dquot_operations dquot_operations = {
 	.initialize	= dquot_initialize,
 	.drop		= dquot_drop,
-	.alloc_inode	= dquot_alloc_inode,
-	.free_inode	= dquot_free_inode,
 	.transfer	= dquot_transfer,
 	.write_dquot	= dquot_commit,
 	.acquire_dquot	= dquot_acquire,
Index: linux-2.6/fs/reiserfs/super.c
===================================================================
--- linux-2.6.orig/fs/reiserfs/super.c	2010-02-20 11:46:29.785031041 +0100
+++ linux-2.6/fs/reiserfs/super.c	2010-02-20 12:15:37.058262148 +0100
@@ -618,8 +618,6 @@ static int reiserfs_quota_on(struct supe
 static const struct dquot_operations reiserfs_quota_operations = {
 	.initialize = dquot_initialize,
 	.drop = dquot_drop,
-	.alloc_inode = dquot_alloc_inode,
-	.free_inode = dquot_free_inode,
 	.transfer = dquot_transfer,
 	.write_dquot = reiserfs_write_dquot,
 	.acquire_dquot = reiserfs_acquire_dquot,
Index: linux-2.6/include/linux/quota.h
===================================================================
--- linux-2.6.orig/include/linux/quota.h	2010-02-20 11:46:29.798033346 +0100
+++ linux-2.6/include/linux/quota.h	2010-02-20 12:15:37.108003732 +0100
@@ -297,8 +297,6 @@ struct quota_format_ops {
 struct dquot_operations {
 	int (*initialize) (struct inode *, int);
 	int (*drop) (struct inode *);
-	int (*alloc_inode) (const struct inode *, qsize_t);
-	int (*free_inode) (const struct inode *, qsize_t);
 	int (*transfer) (struct inode *, qid_t *, unsigned long);
 	int (*write_dquot) (struct dquot *);		/* Ordinary dquot write */
 	struct dquot *(*alloc_dquot)(struct super_block *, int);	/* Allocate memory for new dquot */
Index: linux-2.6/include/linux/quotaops.h
===================================================================
--- linux-2.6.orig/include/linux/quotaops.h	2010-02-20 11:46:29.731254186 +0100
+++ linux-2.6/include/linux/quotaops.h	2010-02-20 12:18:10.302065681 +0100
@@ -37,10 +37,10 @@ int __dquot_alloc_space(struct inode *in
 		int warn, int reserve);
 void __dquot_free_space(struct inode *inode, qsize_t number, int reserve);
 
-int dquot_alloc_inode(const struct inode *inode, qsize_t number);
+int dquot_alloc_inode(const struct inode *inode);
 
 int dquot_claim_space_nodirty(struct inode *inode, qsize_t number);
-int dquot_free_inode(const struct inode *inode, qsize_t number);
+void dquot_free_inode(const struct inode *inode);
 
 int dquot_transfer(struct inode *inode, qid_t *chid, unsigned long mask);
 int dquot_commit(struct dquot *dquot);
@@ -148,26 +148,6 @@ static inline void vfs_dq_init(struct in
 		inode->i_sb->dq_op->initialize(inode, -1);
 }
 
-static inline int vfs_dq_alloc_inode(struct inode *inode)
-{
-	if (sb_any_quota_active(inode->i_sb)) {
-		vfs_dq_init(inode);
-		if (inode->i_sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA)
-			return 1;
-	}
-	return 0;
-}
-
-/*
- * Release reserved (in-memory) quotas
- */
-
-static inline void vfs_dq_free_inode(struct inode *inode)
-{
-	if (sb_any_quota_active(inode->i_sb))
-		inode->i_sb->dq_op->free_inode(inode, 1);
-}
-
 /* Cannot be called inside a transaction */
 static inline int vfs_dq_off(struct super_block *sb, int remount)
 {
@@ -235,12 +215,12 @@ static inline void vfs_dq_drop(struct in
 {
 }
 
-static inline int vfs_dq_alloc_inode(struct inode *inode)
+static inline int dquot_alloc_inode(const struct inode *inode)
 {
 	return 0;
 }
 
-static inline void vfs_dq_free_inode(struct inode *inode)
+static inline void dquot_free_inode(const struct inode *inode)
 {
 }
 
@@ -272,7 +252,7 @@ static inline void __dquot_free_space(st
 {
 	if (!reserve)
 		inode_sub_bytes(inode, number);
-{
+}
 
 static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
 {
Index: linux-2.6/fs/ext2/ialloc.c
===================================================================
--- linux-2.6.orig/fs/ext2/ialloc.c	2010-02-20 11:40:50.536254256 +0100
+++ linux-2.6/fs/ext2/ialloc.c	2010-02-20 12:15:28.810254674 +0100
@@ -121,7 +121,7 @@ void ext2_free_inode (struct inode * ino
 	if (!is_bad_inode(inode)) {
 		/* Quota is already initialized in iput() */
 		ext2_xattr_delete_inode(inode);
-		vfs_dq_free_inode(inode);
+		dquot_free_inode(inode);
 		vfs_dq_drop(inode);
 	}
 
@@ -586,7 +586,8 @@ got:
 		goto fail_drop;
 	}
 
-	if (vfs_dq_alloc_inode(inode)) {
+	vfs_dq_init(inode);
+	if (dquot_alloc_inode(inode)) {
 		err = -EDQUOT;
 		goto fail_drop;
 	}
@@ -605,7 +606,7 @@ got:
 	return inode;
 
 fail_free_drop:
-	vfs_dq_free_inode(inode);
+	dquot_free_inode(inode);
 
 fail_drop:
 	vfs_dq_drop(inode);
Index: linux-2.6/fs/ext3/ialloc.c
===================================================================
--- linux-2.6.orig/fs/ext3/ialloc.c	2010-02-20 11:40:50.444254116 +0100
+++ linux-2.6/fs/ext3/ialloc.c	2010-02-20 12:15:28.748003592 +0100
@@ -125,7 +125,7 @@ void ext3_free_inode (handle_t *handle, 
 	 */
 	vfs_dq_init(inode);
 	ext3_xattr_delete_inode(handle, inode);
-	vfs_dq_free_inode(inode);
+	dquot_free_inode(inode);
 	vfs_dq_drop(inode);
 
 	is_directory = S_ISDIR(inode->i_mode);
@@ -588,7 +588,8 @@ got:
 		sizeof(struct ext3_inode) - EXT3_GOOD_OLD_INODE_SIZE : 0;
 
 	ret = inode;
-	if (vfs_dq_alloc_inode(inode)) {
+	vfs_dq_init(inode);
+	if (dquot_alloc_inode(inode)) {
 		err = -EDQUOT;
 		goto fail_drop;
 	}
@@ -619,7 +620,7 @@ really_out:
 	return ret;
 
 fail_free_drop:
-	vfs_dq_free_inode(inode);
+	dquot_free_inode(inode);
 
 fail_drop:
 	vfs_dq_drop(inode);
Index: linux-2.6/fs/ext4/ialloc.c
===================================================================
--- linux-2.6.orig/fs/ext4/ialloc.c	2010-02-20 11:40:50.462027618 +0100
+++ linux-2.6/fs/ext4/ialloc.c	2010-02-20 12:15:28.766003592 +0100
@@ -219,7 +219,7 @@ void ext4_free_inode(handle_t *handle, s
 	 */
 	vfs_dq_init(inode);
 	ext4_xattr_delete_inode(handle, inode);
-	vfs_dq_free_inode(inode);
+	dquot_free_inode(inode);
 	vfs_dq_drop(inode);
 
 	is_directory = S_ISDIR(inode->i_mode);
@@ -1034,7 +1034,8 @@ got:
 	ei->i_extra_isize = EXT4_SB(sb)->s_want_extra_isize;
 
 	ret = inode;
-	if (vfs_dq_alloc_inode(inode)) {
+	vfs_dq_init(inode);
+	if (dquot_alloc_inode(inode)) {
 		err = -EDQUOT;
 		goto fail_drop;
 	}
@@ -1074,7 +1075,7 @@ really_out:
 	return ret;
 
 fail_free_drop:
-	vfs_dq_free_inode(inode);
+	dquot_free_inode(inode);
 
 fail_drop:
 	vfs_dq_drop(inode);
Index: linux-2.6/fs/jfs/inode.c
===================================================================
--- linux-2.6.orig/fs/jfs/inode.c	2010-02-20 11:40:50.545274091 +0100
+++ linux-2.6/fs/jfs/inode.c	2010-02-20 12:15:28.827253627 +0100
@@ -159,7 +159,7 @@ void jfs_delete_inode(struct inode *inod
 		 * Free the inode from the quota allocation.
 		 */
 		vfs_dq_init(inode);
-		vfs_dq_free_inode(inode);
+		dquot_free_inode(inode);
 		vfs_dq_drop(inode);
 	}
 
Index: linux-2.6/fs/jfs/jfs_inode.c
===================================================================
--- linux-2.6.orig/fs/jfs/jfs_inode.c	2010-02-20 11:40:50.556254186 +0100
+++ linux-2.6/fs/jfs/jfs_inode.c	2010-02-20 12:15:28.835255512 +0100
@@ -116,7 +116,8 @@ struct inode *ialloc(struct inode *paren
 	/*
 	 * Allocate inode to quota.
 	 */
-	if (vfs_dq_alloc_inode(inode)) {
+	vfs_dq_init(inode);
+	if (dquot_alloc_inode(inode)) {
 		rc = -EDQUOT;
 		goto fail_drop;
 	}
Index: linux-2.6/fs/ocfs2/inode.c
===================================================================
--- linux-2.6.orig/fs/ocfs2/inode.c	2010-02-20 11:40:50.497003942 +0100
+++ linux-2.6/fs/ocfs2/inode.c	2010-02-20 12:15:30.316254255 +0100
@@ -665,7 +665,7 @@ static int ocfs2_remove_inode(struct ino
 	}
 
 	ocfs2_remove_from_cache(INODE_CACHE(inode), di_bh);
-	vfs_dq_free_inode(inode);
+	dquot_free_inode(inode);
 
 	status = ocfs2_free_dinode(handle, inode_alloc_inode,
 				   inode_alloc_bh, di);
Index: linux-2.6/fs/reiserfs/inode.c
===================================================================
--- linux-2.6.orig/fs/reiserfs/inode.c	2010-02-20 11:40:50.524004501 +0100
+++ linux-2.6/fs/reiserfs/inode.c	2010-02-20 12:15:37.067254326 +0100
@@ -54,7 +54,7 @@ void reiserfs_delete_inode(struct inode 
 		 * after delete_object so that quota updates go into the same transaction as
 		 * stat data deletion */
 		if (!err) 
-			vfs_dq_free_inode(inode);
+			dquot_free_inode(inode);
 
 		if (journal_end(&th, inode->i_sb, jbegin_count))
 			goto out;
@@ -1765,7 +1765,8 @@ int reiserfs_new_inode(struct reiserfs_t
 
 	BUG_ON(!th->t_trans_id);
 
-	if (vfs_dq_alloc_inode(inode)) {
+	vfs_dq_init(inode);
+	if (dquot_alloc_inode(inode)) {
 		err = -EDQUOT;
 		goto out_end_trans;
 	}
@@ -1959,7 +1960,7 @@ int reiserfs_new_inode(struct reiserfs_t
 	INODE_PKEY(inode)->k_objectid = 0;
 
 	/* Quota change must be inside a transaction for journaling */
-	vfs_dq_free_inode(inode);
+	dquot_free_inode(inode);
 
       out_end_trans:
 	journal_end(th, th->t_super, th->t_blocks_allocated);
Index: linux-2.6/fs/udf/ialloc.c
===================================================================
--- linux-2.6.orig/fs/udf/ialloc.c	2010-02-20 11:40:50.567004361 +0100
+++ linux-2.6/fs/udf/ialloc.c	2010-02-20 12:15:28.864012951 +0100
@@ -36,7 +36,7 @@ void udf_free_inode(struct inode *inode)
 	 * Note: we must free any quota before locking the superblock,
 	 * as writing the quota to disk may need the lock as well.
 	 */
-	vfs_dq_free_inode(inode);
+	dquot_free_inode(inode);
 	vfs_dq_drop(inode);
 
 	clear_inode(inode);
@@ -153,7 +153,8 @@ struct inode *udf_new_inode(struct inode
 	insert_inode_hash(inode);
 	mark_inode_dirty(inode);
 
-	if (vfs_dq_alloc_inode(inode)) {
+	vfs_dq_init(inode);
+	if (dquot_alloc_inode(inode)) {
 		vfs_dq_drop(inode);
 		inode->i_flags |= S_NOQUOTA;
 		inode->i_nlink = 0;
Index: linux-2.6/fs/ufs/ialloc.c
===================================================================
--- linux-2.6.orig/fs/ufs/ialloc.c	2010-02-20 11:40:50.578011834 +0100
+++ linux-2.6/fs/ufs/ialloc.c	2010-02-20 12:15:28.874275417 +0100
@@ -95,7 +95,7 @@ void ufs_free_inode (struct inode * inod
 
 	is_directory = S_ISDIR(inode->i_mode);
 
-	vfs_dq_free_inode(inode);
+	dquot_free_inode(inode);
 	vfs_dq_drop(inode);
 
 	clear_inode (inode);
@@ -355,7 +355,8 @@ cg_found:
 
 	unlock_super (sb);
 
-	if (vfs_dq_alloc_inode(inode)) {
+	vfs_dq_init(inode);
+	if (dquot_alloc_inode(inode)) {
 		vfs_dq_drop(inode);
 		err = -EDQUOT;
 		goto fail_without_unlock;


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

* [PATCH 3/8] dquot: move dquot transfer responsibiliy into the filesystem
  2010-02-20 11:51 [PATCH 0/8] dquot interface cleanups Christoph Hellwig
  2010-02-20 11:51 ` [PATCH 1/8] dquot: cleanup space allocation / freeing routines Christoph Hellwig
  2010-02-20 11:51 ` [PATCH 2/8] dquot: cleanup inode " Christoph Hellwig
@ 2010-02-20 11:51 ` Christoph Hellwig
  2010-02-24 23:06   ` Jan Kara
  2010-02-20 11:51 ` [PATCH 4/8] dquot: cleanup dquot transfer routine Christoph Hellwig
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 26+ messages in thread
From: Christoph Hellwig @ 2010-02-20 11:51 UTC (permalink / raw)
  To: jack; +Cc: linux-fsdevel

[-- Attachment #1: quota-move-transfer --]
[-- Type: text/plain, Size: 6503 bytes --]

Currently notify_change calls vfs_dq_transfer directly.  This means
we tie the quota code into the VFS.  Get rid of that and make the
filesystem responsibly for the transfer.  Most filesystems already
do this, only ufs needs the code added, and for jfs it needs to be
enabled unconditionally instead of only when ACLs are enabled.

Signed-off-by: Christoph Hellwig <hch@lst.de>

Index: linux-2.6/fs/attr.c
===================================================================
--- linux-2.6.orig/fs/attr.c	2010-02-19 11:45:24.904272974 +0100
+++ linux-2.6/fs/attr.c	2010-02-19 11:45:43.050005619 +0100
@@ -12,7 +12,6 @@
 #include <linux/capability.h>
 #include <linux/fsnotify.h>
 #include <linux/fcntl.h>
-#include <linux/quotaops.h>
 #include <linux/security.h>
 
 /* Taken over from the old code... */
@@ -212,14 +211,8 @@ int notify_change(struct dentry * dentry
 		error = inode->i_op->setattr(dentry, attr);
 	} else {
 		error = inode_change_ok(inode, attr);
-		if (!error) {
-			if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
-			    (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
-				error = vfs_dq_transfer(inode, attr) ?
-					-EDQUOT : 0;
-			if (!error)
-				error = inode_setattr(inode, attr);
-		}
+		if (!error)
+			error = inode_setattr(inode, attr);
 	}
 
 	if (ia_valid & ATTR_SIZE)
Index: linux-2.6/fs/ufs/truncate.c
===================================================================
--- linux-2.6.orig/fs/ufs/truncate.c	2010-02-19 11:45:24.913004221 +0100
+++ linux-2.6/fs/ufs/truncate.c	2010-02-19 15:08:15.042023986 +0100
@@ -44,6 +44,7 @@
 #include <linux/buffer_head.h>
 #include <linux/blkdev.h>
 #include <linux/sched.h>
+#include <linux/quotaops.h>
 
 #include "ufs_fs.h"
 #include "ufs.h"
@@ -517,6 +518,12 @@ static int ufs_setattr(struct dentry *de
 	if (error)
 		return error;
 
+	if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
+	    (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
+		error = vfs_dq_transfer(inode, attr) ? -EDQUOT : 0;
+		if (error)
+			return error;
+	}
 	if (ia_valid & ATTR_SIZE &&
 	    attr->ia_size != i_size_read(inode)) {
 		loff_t old_i_size = inode->i_size;
Index: linux-2.6/fs/jfs/acl.c
===================================================================
--- linux-2.6.orig/fs/jfs/acl.c	2010-02-19 11:45:24.919010367 +0100
+++ linux-2.6/fs/jfs/acl.c	2010-02-19 11:45:32.078271367 +0100
@@ -20,7 +20,6 @@
 
 #include <linux/sched.h>
 #include <linux/fs.h>
-#include <linux/quotaops.h>
 #include <linux/posix_acl_xattr.h>
 #include "jfs_incore.h"
 #include "jfs_txnmgr.h"
@@ -174,7 +173,7 @@ cleanup:
 	return rc;
 }
 
-static int jfs_acl_chmod(struct inode *inode)
+int jfs_acl_chmod(struct inode *inode)
 {
 	struct posix_acl *acl, *clone;
 	int rc;
@@ -205,26 +204,3 @@ static int jfs_acl_chmod(struct inode *i
 	posix_acl_release(clone);
 	return rc;
 }
-
-int jfs_setattr(struct dentry *dentry, struct iattr *iattr)
-{
-	struct inode *inode = dentry->d_inode;
-	int rc;
-
-	rc = inode_change_ok(inode, iattr);
-	if (rc)
-		return rc;
-
-	if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
-	    (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
-		if (vfs_dq_transfer(inode, iattr))
-			return -EDQUOT;
-	}
-
-	rc = inode_setattr(inode, iattr);
-
-	if (!rc && (iattr->ia_valid & ATTR_MODE))
-		rc = jfs_acl_chmod(inode);
-
-	return rc;
-}
Index: linux-2.6/fs/jfs/file.c
===================================================================
--- linux-2.6.orig/fs/jfs/file.c	2010-02-19 11:45:24.929004081 +0100
+++ linux-2.6/fs/jfs/file.c	2010-02-19 15:08:02.655004431 +0100
@@ -18,6 +18,7 @@
  */
 
 #include <linux/fs.h>
+#include <linux/quotaops.h>
 #include "jfs_incore.h"
 #include "jfs_inode.h"
 #include "jfs_dmap.h"
@@ -88,14 +89,37 @@ static int jfs_release(struct inode *ino
 	return 0;
 }
 
+int jfs_setattr(struct dentry *dentry, struct iattr *iattr)
+{
+	struct inode *inode = dentry->d_inode;
+	int rc;
+
+	rc = inode_change_ok(inode, iattr);
+	if (rc)
+		return rc;
+
+	if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
+	    (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
+		if (vfs_dq_transfer(inode, iattr))
+			return -EDQUOT;
+	}
+
+	rc = inode_setattr(inode, iattr);
+
+	if (!rc && (iattr->ia_valid & ATTR_MODE))
+		rc = jfs_acl_chmod(inode);
+
+	return rc;
+}
+
 const struct inode_operations jfs_file_inode_operations = {
 	.truncate	= jfs_truncate,
 	.setxattr	= jfs_setxattr,
 	.getxattr	= jfs_getxattr,
 	.listxattr	= jfs_listxattr,
 	.removexattr	= jfs_removexattr,
-#ifdef CONFIG_JFS_POSIX_ACL
 	.setattr	= jfs_setattr,
+#ifdef CONFIG_JFS_POSIX_ACL
 	.check_acl	= jfs_check_acl,
 #endif
 };
Index: linux-2.6/fs/jfs/jfs_acl.h
===================================================================
--- linux-2.6.orig/fs/jfs/jfs_acl.h	2010-02-19 11:45:24.936025523 +0100
+++ linux-2.6/fs/jfs/jfs_acl.h	2010-02-19 11:45:32.085271437 +0100
@@ -22,7 +22,7 @@
 
 int jfs_check_acl(struct inode *, int);
 int jfs_init_acl(tid_t, struct inode *, struct inode *);
-int jfs_setattr(struct dentry *, struct iattr *);
+int jfs_acl_chmod(struct inode *inode);
 
 #else
 
@@ -32,5 +32,10 @@ static inline int jfs_init_acl(tid_t tid
 	return 0;
 }
 
+static inline int jfs_acl_chmod(struct inode *inode)
+{
+	return 0;
+}
+
 #endif
 #endif		/* _H_JFS_ACL */
Index: linux-2.6/fs/jfs/jfs_inode.h
===================================================================
--- linux-2.6.orig/fs/jfs/jfs_inode.h	2010-02-19 11:45:24.944024894 +0100
+++ linux-2.6/fs/jfs/jfs_inode.h	2010-02-19 11:45:32.090281355 +0100
@@ -40,6 +40,7 @@ extern struct dentry *jfs_fh_to_parent(s
 	int fh_len, int fh_type);
 extern void jfs_set_inode_flags(struct inode *);
 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
+extern int jfs_setattr(struct dentry *, struct iattr *);
 
 extern const struct address_space_operations jfs_aops;
 extern const struct inode_operations jfs_dir_inode_operations;
Index: linux-2.6/fs/jfs/namei.c
===================================================================
--- linux-2.6.orig/fs/jfs/namei.c	2010-02-19 11:45:24.955254046 +0100
+++ linux-2.6/fs/jfs/namei.c	2010-02-19 14:53:30.838004431 +0100
@@ -1541,8 +1541,8 @@ const struct inode_operations jfs_dir_in
 	.getxattr	= jfs_getxattr,
 	.listxattr	= jfs_listxattr,
 	.removexattr	= jfs_removexattr,
-#ifdef CONFIG_JFS_POSIX_ACL
 	.setattr	= jfs_setattr,
+#ifdef CONFIG_JFS_POSIX_ACL
 	.check_acl	= jfs_check_acl,
 #endif
 };


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

* [PATCH 4/8] dquot: cleanup dquot transfer routine
  2010-02-20 11:51 [PATCH 0/8] dquot interface cleanups Christoph Hellwig
                   ` (2 preceding siblings ...)
  2010-02-20 11:51 ` [PATCH 3/8] dquot: move dquot transfer responsibiliy into the filesystem Christoph Hellwig
@ 2010-02-20 11:51 ` Christoph Hellwig
  2010-02-24 23:14   ` Jan Kara
  2010-02-20 11:51 ` [PATCH 5/8] dquot: move dquot drop responsibiliy into the filesystem Christoph Hellwig
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 26+ messages in thread
From: Christoph Hellwig @ 2010-02-20 11:51 UTC (permalink / raw)
  To: jack; +Cc: linux-fsdevel

[-- Attachment #1: quota-kill-transfer --]
[-- Type: text/plain, Size: 12369 bytes --]

Get rid of the transfer dquot operation - it is now always called from
the filesystem and if a filesystem really needs it's own (which none
currently does) it can just call into it's own routine directly.

Rename the now static low-level dquot_transfer helper to __dquot_transfer
and vfs_dq_transfer to dquot_transfer to have a consistent namespace,
and make the new dquot_transfer return a normal negative errno value
which all callers expect.

Signed-off-by: Christoph Hellwig <hch@lst.de>

Index: linux-2.6/Documentation/filesystems/Locking
===================================================================
--- linux-2.6.orig/Documentation/filesystems/Locking	2010-02-20 11:48:48.624253837 +0100
+++ linux-2.6/Documentation/filesystems/Locking	2010-02-20 11:55:53.694023148 +0100
@@ -462,7 +462,6 @@ in sys_read() and friends.
 prototypes:
 	int (*initialize) (struct inode *, int);
 	int (*drop) (struct inode *);
-	int (*transfer) (struct inode *, struct iattr *);
 	int (*write_dquot) (struct dquot *);
 	int (*acquire_dquot) (struct dquot *);
 	int (*release_dquot) (struct dquot *);
@@ -477,7 +476,6 @@ What filesystem should expect from the g
 		FS recursion	Held locks when called
 initialize:	yes		maybe dqonoff_sem
 drop:		yes		-
-transfer:	yes		-
 write_dquot:	yes		dqonoff_sem or dqptr_sem
 acquire_dquot:	yes		dqonoff_sem or dqptr_sem
 release_dquot:	yes		dqonoff_sem or dqptr_sem
Index: linux-2.6/fs/ext3/super.c
===================================================================
--- linux-2.6.orig/fs/ext3/super.c	2010-02-20 11:48:48.626253697 +0100
+++ linux-2.6/fs/ext3/super.c	2010-02-20 11:55:53.695023428 +0100
@@ -752,7 +752,6 @@ static ssize_t ext3_quota_write(struct s
 static const struct dquot_operations ext3_quota_operations = {
 	.initialize	= dquot_initialize,
 	.drop		= dquot_drop,
-	.transfer	= dquot_transfer,
 	.write_dquot	= ext3_write_dquot,
 	.acquire_dquot	= ext3_acquire_dquot,
 	.release_dquot	= ext3_release_dquot,
Index: linux-2.6/fs/ext4/super.c
===================================================================
--- linux-2.6.orig/fs/ext4/super.c	2010-02-20 11:48:48.633253627 +0100
+++ linux-2.6/fs/ext4/super.c	2010-02-20 11:55:53.706254954 +0100
@@ -1017,7 +1017,6 @@ static const struct dquot_operations ext
 #ifdef CONFIG_QUOTA
 	.get_reserved_space = ext4_get_reserved_space,
 #endif
-	.transfer	= dquot_transfer,
 	.write_dquot	= ext4_write_dquot,
 	.acquire_dquot	= ext4_acquire_dquot,
 	.release_dquot	= ext4_release_dquot,
Index: linux-2.6/fs/ocfs2/quota_global.c
===================================================================
--- linux-2.6.orig/fs/ocfs2/quota_global.c	2010-02-20 11:48:48.666256212 +0100
+++ linux-2.6/fs/ocfs2/quota_global.c	2010-02-20 11:55:53.733255653 +0100
@@ -853,7 +853,6 @@ static void ocfs2_destroy_dquot(struct d
 const struct dquot_operations ocfs2_quota_operations = {
 	.initialize	= dquot_initialize,
 	.drop		= dquot_drop,
-	.transfer	= dquot_transfer,
 	.write_dquot	= ocfs2_write_dquot,
 	.acquire_dquot	= ocfs2_acquire_dquot,
 	.release_dquot	= ocfs2_release_dquot,
Index: linux-2.6/fs/quota/dquot.c
===================================================================
--- linux-2.6.orig/fs/quota/dquot.c	2010-02-20 11:50:33.509255304 +0100
+++ linux-2.6/fs/quota/dquot.c	2010-02-20 11:55:53.742255234 +0100
@@ -1669,7 +1669,7 @@ EXPORT_SYMBOL(dquot_free_inode);
  * This operation can block, but only after everything is updated
  * A transaction must be started when entering this function.
  */
-int dquot_transfer(struct inode *inode, qid_t *chid, unsigned long mask)
+static int __dquot_transfer(struct inode *inode, qid_t *chid, unsigned long mask)
 {
 	qsize_t space, cur_space;
 	qsize_t rsv_space = 0;
@@ -1766,12 +1766,11 @@ over_quota:
 	ret = NO_QUOTA;
 	goto warn_put_all;
 }
-EXPORT_SYMBOL(dquot_transfer);
 
 /* Wrapper for transferring ownership of an inode for uid/gid only
  * Called from FSXXX_setattr()
  */
-int vfs_dq_transfer(struct inode *inode, struct iattr *iattr)
+int dquot_transfer(struct inode *inode, struct iattr *iattr)
 {
 	qid_t chid[MAXQUOTAS];
 	unsigned long mask = 0;
@@ -1786,12 +1785,12 @@ int vfs_dq_transfer(struct inode *inode,
 	}
 	if (sb_any_quota_active(inode->i_sb) && !IS_NOQUOTA(inode)) {
 		vfs_dq_init(inode);
-		if (inode->i_sb->dq_op->transfer(inode, chid, mask) == NO_QUOTA)
-			return 1;
+		if (__dquot_transfer(inode, chid, mask) == NO_QUOTA)
+			return -EDQUOT;
 	}
 	return 0;
 }
-EXPORT_SYMBOL(vfs_dq_transfer);
+EXPORT_SYMBOL(dquot_transfer);
 
 /*
  * Write info of quota file to disk
@@ -1814,7 +1813,6 @@ EXPORT_SYMBOL(dquot_commit_info);
 const struct dquot_operations dquot_operations = {
 	.initialize	= dquot_initialize,
 	.drop		= dquot_drop,
-	.transfer	= dquot_transfer,
 	.write_dquot	= dquot_commit,
 	.acquire_dquot	= dquot_acquire,
 	.release_dquot	= dquot_release,
Index: linux-2.6/fs/reiserfs/super.c
===================================================================
--- linux-2.6.orig/fs/reiserfs/super.c	2010-02-20 11:48:48.691005897 +0100
+++ linux-2.6/fs/reiserfs/super.c	2010-02-20 11:55:53.756256212 +0100
@@ -618,7 +618,6 @@ static int reiserfs_quota_on(struct supe
 static const struct dquot_operations reiserfs_quota_operations = {
 	.initialize = dquot_initialize,
 	.drop = dquot_drop,
-	.transfer = dquot_transfer,
 	.write_dquot = reiserfs_write_dquot,
 	.acquire_dquot = reiserfs_acquire_dquot,
 	.release_dquot = reiserfs_release_dquot,
Index: linux-2.6/include/linux/quota.h
===================================================================
--- linux-2.6.orig/include/linux/quota.h	2010-02-20 11:48:48.696005828 +0100
+++ linux-2.6/include/linux/quota.h	2010-02-20 11:55:53.761255862 +0100
@@ -297,7 +297,6 @@ struct quota_format_ops {
 struct dquot_operations {
 	int (*initialize) (struct inode *, int);
 	int (*drop) (struct inode *);
-	int (*transfer) (struct inode *, qid_t *, unsigned long);
 	int (*write_dquot) (struct dquot *);		/* Ordinary dquot write */
 	struct dquot *(*alloc_dquot)(struct super_block *, int);	/* Allocate memory for new dquot */
 	void (*destroy_dquot)(struct dquot *);		/* Free memory for dquot */
Index: linux-2.6/include/linux/quotaops.h
===================================================================
--- linux-2.6.orig/include/linux/quotaops.h	2010-02-20 11:48:48.698006456 +0100
+++ linux-2.6/include/linux/quotaops.h	2010-02-20 11:55:53.763255583 +0100
@@ -42,7 +42,6 @@ int dquot_alloc_inode(const struct inode
 int dquot_claim_space_nodirty(struct inode *inode, qsize_t number);
 void dquot_free_inode(const struct inode *inode);
 
-int dquot_transfer(struct inode *inode, qid_t *chid, unsigned long mask);
 int dquot_commit(struct dquot *dquot);
 int dquot_acquire(struct dquot *dquot);
 int dquot_release(struct dquot *dquot);
@@ -66,7 +65,7 @@ int vfs_get_dqblk(struct super_block *sb
 int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di);
 
 void vfs_dq_drop(struct inode *inode);
-int vfs_dq_transfer(struct inode *inode, struct iattr *iattr);
+int dquot_transfer(struct inode *inode, struct iattr *iattr);
 int vfs_dq_quota_on_remount(struct super_block *sb);
 
 static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type)
@@ -234,7 +233,7 @@ static inline int vfs_dq_quota_on_remoun
 	return 0;
 }
 
-static inline int vfs_dq_transfer(struct inode *inode, struct iattr *iattr)
+static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
 {
 	return 0;
 }
Index: linux-2.6/drivers/staging/pohmelfs/inode.c
===================================================================
--- linux-2.6.orig/drivers/staging/pohmelfs/inode.c	2010-02-20 11:40:49.947004081 +0100
+++ linux-2.6/drivers/staging/pohmelfs/inode.c	2010-02-20 11:55:53.767255443 +0100
@@ -969,7 +969,7 @@ int pohmelfs_setattr_raw(struct inode *i
 
 	if ((attr->ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
 	    (attr->ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
-		err = vfs_dq_transfer(inode, attr) ? -EDQUOT : 0;
+		err = dquot_transfer(inode, attr);
 		if (err)
 			goto err_out_exit;
 	}
Index: linux-2.6/fs/ext2/inode.c
===================================================================
--- linux-2.6.orig/fs/ext2/inode.c	2010-02-20 11:40:49.886253766 +0100
+++ linux-2.6/fs/ext2/inode.c	2010-02-20 11:55:53.772255862 +0100
@@ -1459,7 +1459,7 @@ int ext2_setattr(struct dentry *dentry, 
 		return error;
 	if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
 	    (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
-		error = vfs_dq_transfer(inode, iattr) ? -EDQUOT : 0;
+		error = dquot_transfer(inode, iattr);
 		if (error)
 			return error;
 	}
Index: linux-2.6/fs/ext3/inode.c
===================================================================
--- linux-2.6.orig/fs/ext3/inode.c	2010-02-20 11:46:29.838255793 +0100
+++ linux-2.6/fs/ext3/inode.c	2010-02-20 11:55:53.781265570 +0100
@@ -3152,7 +3152,7 @@ int ext3_setattr(struct dentry *dentry, 
 			error = PTR_ERR(handle);
 			goto err_out;
 		}
-		error = vfs_dq_transfer(inode, attr) ? -EDQUOT : 0;
+		error = dquot_transfer(inode, attr);
 		if (error) {
 			ext3_journal_stop(handle);
 			return error;
Index: linux-2.6/fs/ext4/inode.c
===================================================================
--- linux-2.6.orig/fs/ext4/inode.c	2010-02-20 11:46:29.854255514 +0100
+++ linux-2.6/fs/ext4/inode.c	2010-02-20 11:55:53.804005688 +0100
@@ -5261,7 +5261,7 @@ int ext4_setattr(struct dentry *dentry, 
 			error = PTR_ERR(handle);
 			goto err_out;
 		}
-		error = vfs_dq_transfer(inode, attr) ? -EDQUOT : 0;
+		error = dquot_transfer(inode, attr);
 		if (error) {
 			ext4_journal_stop(handle);
 			return error;
Index: linux-2.6/fs/ocfs2/file.c
===================================================================
--- linux-2.6.orig/fs/ocfs2/file.c	2010-02-20 11:46:30.009005758 +0100
+++ linux-2.6/fs/ocfs2/file.c	2010-02-20 11:55:53.836005270 +0100
@@ -1021,7 +1021,7 @@ int ocfs2_setattr(struct dentry *dentry,
 		/*
 		 * Gather pointers to quota structures so that allocation /
 		 * freeing of quota structures happens here and not inside
-		 * vfs_dq_transfer() where we have problems with lock ordering
+		 * dquot_transfer() where we have problems with lock ordering
 		 */
 		if (attr->ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid
 		    && OCFS2_HAS_RO_COMPAT_FEATURE(sb,
@@ -1054,7 +1054,7 @@ int ocfs2_setattr(struct dentry *dentry,
 			mlog_errno(status);
 			goto bail_unlock;
 		}
-		status = vfs_dq_transfer(inode, attr) ? -EDQUOT : 0;
+		status = dquot_transfer(inode, attr);
 		if (status < 0)
 			goto bail_commit;
 	} else {
Index: linux-2.6/fs/reiserfs/inode.c
===================================================================
--- linux-2.6.orig/fs/reiserfs/inode.c	2010-02-20 11:48:48.735005688 +0100
+++ linux-2.6/fs/reiserfs/inode.c	2010-02-20 11:55:53.847006037 +0100
@@ -3135,8 +3135,7 @@ int reiserfs_setattr(struct dentry *dent
 						  jbegin_count);
 				if (error)
 					goto out;
-				error =
-				    vfs_dq_transfer(inode, attr) ? -EDQUOT : 0;
+				error = dquot_transfer(inode, attr);
 				if (error) {
 					journal_end(&th, inode->i_sb,
 						    jbegin_count);
Index: linux-2.6/fs/ufs/truncate.c
===================================================================
--- linux-2.6.orig/fs/ufs/truncate.c	2010-02-20 11:53:51.125252859 +0100
+++ linux-2.6/fs/ufs/truncate.c	2010-02-20 11:55:53.855009459 +0100
@@ -520,7 +520,7 @@ static int ufs_setattr(struct dentry *de
 
 	if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
 	    (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
-		error = vfs_dq_transfer(inode, attr) ? -EDQUOT : 0;
+		error = dquot_transfer(inode, attr);
 		if (error)
 			return error;
 	}
Index: linux-2.6/fs/jfs/file.c
===================================================================
--- linux-2.6.orig/fs/jfs/file.c	2010-02-20 11:53:51.132291971 +0100
+++ linux-2.6/fs/jfs/file.c	2010-02-20 11:55:53.857256072 +0100
@@ -100,8 +100,9 @@ int jfs_setattr(struct dentry *dentry, s
 
 	if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
 	    (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
-		if (vfs_dq_transfer(inode, iattr))
-			return -EDQUOT;
+		rc = dquot_transfer(inode, iattr);
+		if (rc)
+			return rc;
 	}
 
 	rc = inode_setattr(inode, iattr);


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

* [PATCH 5/8] dquot: move dquot drop responsibiliy into the filesystem
  2010-02-20 11:51 [PATCH 0/8] dquot interface cleanups Christoph Hellwig
                   ` (3 preceding siblings ...)
  2010-02-20 11:51 ` [PATCH 4/8] dquot: cleanup dquot transfer routine Christoph Hellwig
@ 2010-02-20 11:51 ` Christoph Hellwig
  2010-02-25  0:00   ` Jan Kara
  2010-02-20 11:51 ` [PATCH 6/8] dquot: cleanup dquot drop routine Christoph Hellwig
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 26+ messages in thread
From: Christoph Hellwig @ 2010-02-20 11:51 UTC (permalink / raw)
  To: jack; +Cc: linux-fsdevel

[-- Attachment #1: quota-move-drop --]
[-- Type: text/plain, Size: 5558 bytes --]

Currently clear_inode calls vfs_dq_drop directly.  This means
we tie the quota code into the VFS.  Get rid of that and make the
filesystem responsibly for the drop inside the ->clear_inode
superblock operation.

Signed-off-by: Christoph Hellwig <hch@lst.de>

Index: linux-2.6/fs/ext2/super.c
===================================================================
--- linux-2.6.orig/fs/ext2/super.c	2010-02-19 00:34:37.825004031 +0100
+++ linux-2.6/fs/ext2/super.c	2010-02-19 00:36:12.220253508 +0100
@@ -194,6 +194,8 @@ static void destroy_inodecache(void)
 static void ext2_clear_inode(struct inode *inode)
 {
 	struct ext2_block_alloc_info *rsv = EXT2_I(inode)->i_block_alloc_info;
+
+	vfs_dq_drop(inode);
 	ext2_discard_reservation(inode);
 	EXT2_I(inode)->i_block_alloc_info = NULL;
 	if (unlikely(rsv))
Index: linux-2.6/fs/ext3/super.c
===================================================================
--- linux-2.6.orig/fs/ext3/super.c	2010-02-19 00:36:11.342272784 +0100
+++ linux-2.6/fs/ext3/super.c	2010-02-19 00:37:51.823255463 +0100
@@ -528,6 +528,8 @@ static void destroy_inodecache(void)
 static void ext3_clear_inode(struct inode *inode)
 {
 	struct ext3_block_alloc_info *rsv = EXT3_I(inode)->i_block_alloc_info;
+
+	vfs_dq_drop(inode);
 	ext3_discard_reservation(inode);
 	EXT3_I(inode)->i_block_alloc_info = NULL;
 	if (unlikely(rsv))
Index: linux-2.6/fs/ext4/super.c
===================================================================
--- linux-2.6.orig/fs/ext4/super.c	2010-02-19 00:36:11.349253577 +0100
+++ linux-2.6/fs/ext4/super.c	2010-02-19 00:37:56.031005358 +0100
@@ -761,6 +761,7 @@ static void destroy_inodecache(void)
 
 static void ext4_clear_inode(struct inode *inode)
 {
+	vfs_dq_drop(inode);
 	ext4_discard_preallocations(inode);
 	if (EXT4_JOURNAL(inode))
 		jbd2_journal_release_jbd_inode(EXT4_SB(inode->i_sb)->s_journal,
Index: linux-2.6/fs/inode.c
===================================================================
--- linux-2.6.orig/fs/inode.c	2010-02-19 00:34:37.871003961 +0100
+++ linux-2.6/fs/inode.c	2010-02-19 00:36:12.241255672 +0100
@@ -314,7 +314,6 @@ void clear_inode(struct inode *inode)
 	BUG_ON(!(inode->i_state & I_FREEING));
 	BUG_ON(inode->i_state & I_CLEAR);
 	inode_sync_wait(inode);
-	vfs_dq_drop(inode);
 	if (inode->i_sb->s_op->clear_inode)
 		inode->i_sb->s_op->clear_inode(inode);
 	if (S_ISBLK(inode->i_mode) && inode->i_bdev)
Index: linux-2.6/fs/jfs/super.c
===================================================================
--- linux-2.6.orig/fs/jfs/super.c	2010-02-19 00:34:37.880003612 +0100
+++ linux-2.6/fs/jfs/super.c	2010-02-19 00:36:12.253005987 +0100
@@ -131,6 +131,11 @@ static void jfs_destroy_inode(struct ino
 	kmem_cache_free(jfs_inode_cachep, ji);
 }
 
+static void jfs_clear_inode(struct inode *inode)
+{
+	vfs_dq_drop(inode);
+}
+
 static int jfs_statfs(struct dentry *dentry, struct kstatfs *buf)
 {
 	struct jfs_sb_info *sbi = JFS_SBI(dentry->d_sb);
@@ -745,6 +750,7 @@ static const struct super_operations jfs
 	.dirty_inode	= jfs_dirty_inode,
 	.write_inode	= jfs_write_inode,
 	.delete_inode	= jfs_delete_inode,
+	.clear_inode	= jfs_clear_inode,
 	.put_super	= jfs_put_super,
 	.sync_fs	= jfs_sync_fs,
 	.freeze_fs	= jfs_freeze,
Index: linux-2.6/fs/ocfs2/inode.c
===================================================================
--- linux-2.6.orig/fs/ocfs2/inode.c	2010-02-19 00:36:09.946254765 +0100
+++ linux-2.6/fs/ocfs2/inode.c	2010-02-19 00:36:12.260023517 +0100
@@ -1087,6 +1087,8 @@ void ocfs2_clear_inode(struct inode *ino
 	mlog_bug_on_msg(OCFS2_SB(inode->i_sb) == NULL,
 			"Inode=%lu\n", inode->i_ino);
 
+	vfs_dq_drop(inode);
+
 	/* To preven remote deletes we hold open lock before, now it
 	 * is time to unlock PR and EX open locks. */
 	ocfs2_open_unlock(inode);
Index: linux-2.6/fs/reiserfs/super.c
===================================================================
--- linux-2.6.orig/fs/reiserfs/super.c	2010-02-19 00:36:11.387274530 +0100
+++ linux-2.6/fs/reiserfs/super.c	2010-02-19 00:38:03.698255045 +0100
@@ -578,6 +578,11 @@ out:
 	reiserfs_write_unlock_once(inode->i_sb, lock_depth);
 }
 
+static void reiserfs_clear_inode(struct inode *inode)
+{
+	vfs_dq_drop(inode);
+}
+
 #ifdef CONFIG_QUOTA
 static ssize_t reiserfs_quota_write(struct super_block *, int, const char *,
 				    size_t, loff_t);
@@ -590,6 +595,7 @@ static const struct super_operations rei
 	.destroy_inode = reiserfs_destroy_inode,
 	.write_inode = reiserfs_write_inode,
 	.dirty_inode = reiserfs_dirty_inode,
+	.clear_inode = reiserfs_clear_inode,
 	.delete_inode = reiserfs_delete_inode,
 	.put_super = reiserfs_put_super,
 	.write_super = reiserfs_write_super,
Index: linux-2.6/fs/ufs/super.c
===================================================================
--- linux-2.6.orig/fs/ufs/super.c	2010-02-19 00:34:37.940003822 +0100
+++ linux-2.6/fs/ufs/super.c	2010-02-19 00:36:12.284254834 +0100
@@ -1432,6 +1432,11 @@ static void destroy_inodecache(void)
 	kmem_cache_destroy(ufs_inode_cachep);
 }
 
+static void ufs_clear_inode(struct inode *inode)
+{
+	vfs_dq_drop(inode);
+}
+
 #ifdef CONFIG_QUOTA
 static ssize_t ufs_quota_read(struct super_block *, int, char *,size_t, loff_t);
 static ssize_t ufs_quota_write(struct super_block *, int, const char *, size_t, loff_t);
@@ -1442,6 +1447,7 @@ static const struct super_operations ufs
 	.destroy_inode	= ufs_destroy_inode,
 	.write_inode	= ufs_write_inode,
 	.delete_inode	= ufs_delete_inode,
+	.clear_inode	= ufs_clear_inode,
 	.put_super	= ufs_put_super,
 	.write_super	= ufs_write_super,
 	.sync_fs	= ufs_sync_fs,


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

* [PATCH 6/8] dquot: cleanup dquot drop routine
  2010-02-20 11:51 [PATCH 0/8] dquot interface cleanups Christoph Hellwig
                   ` (4 preceding siblings ...)
  2010-02-20 11:51 ` [PATCH 5/8] dquot: move dquot drop responsibiliy into the filesystem Christoph Hellwig
@ 2010-02-20 11:51 ` Christoph Hellwig
  2010-02-25  0:08   ` Jan Kara
  2010-02-20 11:51 ` [PATCH 7/8] dquot: move dquot initialization responsibiliy into the filesystem Christoph Hellwig
  2010-02-20 11:51 ` [PATCH 8/8] dquot: cleanup dquot initialize routine Christoph Hellwig
  7 siblings, 1 reply; 26+ messages in thread
From: Christoph Hellwig @ 2010-02-20 11:51 UTC (permalink / raw)
  To: jack; +Cc: linux-fsdevel

[-- Attachment #1: quota-kill-drop --]
[-- Type: text/plain, Size: 16014 bytes --]

Get rid of the drop dquot operation - it is now always called from
the filesystem and if a filesystem really needs it's own (which none
currently does) it can just call into it's own routine directly.

Rename the now static low-level dquot_drop helper to __dquot_drop
and vfs_dq_drop to dquot_drop to have a consistent namespace.

Signed-off-by: Christoph Hellwig <hch@lst.de>

Index: linux-2.6/fs/ext3/super.c
===================================================================
--- linux-2.6.orig/fs/ext3/super.c	2010-02-20 11:58:09.776023847 +0100
+++ linux-2.6/fs/ext3/super.c	2010-02-20 11:59:10.736253977 +0100
@@ -529,7 +529,7 @@ static void ext3_clear_inode(struct inod
 {
 	struct ext3_block_alloc_info *rsv = EXT3_I(inode)->i_block_alloc_info;
 
-	vfs_dq_drop(inode);
+	dquot_drop(inode);
 	ext3_discard_reservation(inode);
 	EXT3_I(inode)->i_block_alloc_info = NULL;
 	if (unlikely(rsv))
@@ -753,7 +753,6 @@ static ssize_t ext3_quota_write(struct s
 
 static const struct dquot_operations ext3_quota_operations = {
 	.initialize	= dquot_initialize,
-	.drop		= dquot_drop,
 	.write_dquot	= ext3_write_dquot,
 	.acquire_dquot	= ext3_acquire_dquot,
 	.release_dquot	= ext3_release_dquot,
Index: linux-2.6/fs/ext4/super.c
===================================================================
--- linux-2.6.orig/fs/ext4/super.c	2010-02-20 11:58:09.783026990 +0100
+++ linux-2.6/fs/ext4/super.c	2010-02-20 11:59:10.738253837 +0100
@@ -761,7 +761,7 @@ static void destroy_inodecache(void)
 
 static void ext4_clear_inode(struct inode *inode)
 {
-	vfs_dq_drop(inode);
+	dquot_drop(inode);
 	ext4_discard_preallocations(inode);
 	if (EXT4_JOURNAL(inode))
 		jbd2_journal_release_jbd_inode(EXT4_SB(inode->i_sb)->s_journal,
@@ -1014,7 +1014,6 @@ static ssize_t ext4_quota_write(struct s
 
 static const struct dquot_operations ext4_quota_operations = {
 	.initialize	= dquot_initialize,
-	.drop		= dquot_drop,
 #ifdef CONFIG_QUOTA
 	.get_reserved_space = ext4_get_reserved_space,
 #endif
Index: linux-2.6/fs/reiserfs/super.c
===================================================================
--- linux-2.6.orig/fs/reiserfs/super.c	2010-02-20 11:58:09.832006177 +0100
+++ linux-2.6/fs/reiserfs/super.c	2010-02-20 11:59:10.746276675 +0100
@@ -580,7 +580,7 @@ out:
 
 static void reiserfs_clear_inode(struct inode *inode)
 {
-	vfs_dq_drop(inode);
+	dquot_drop(inode);
 }
 
 #ifdef CONFIG_QUOTA
@@ -623,7 +623,6 @@ static int reiserfs_quota_on(struct supe
 
 static const struct dquot_operations reiserfs_quota_operations = {
 	.initialize = dquot_initialize,
-	.drop = dquot_drop,
 	.write_dquot = reiserfs_write_dquot,
 	.acquire_dquot = reiserfs_acquire_dquot,
 	.release_dquot = reiserfs_release_dquot,
Index: linux-2.6/fs/ext2/ialloc.c
===================================================================
--- linux-2.6.orig/fs/ext2/ialloc.c	2010-02-20 11:48:48.700024475 +0100
+++ linux-2.6/fs/ext2/ialloc.c	2010-02-20 11:59:10.751275697 +0100
@@ -122,7 +122,7 @@ void ext2_free_inode (struct inode * ino
 		/* Quota is already initialized in iput() */
 		ext2_xattr_delete_inode(inode);
 		dquot_free_inode(inode);
-		vfs_dq_drop(inode);
+		dquot_drop(inode);
 	}
 
 	es = EXT2_SB(sb)->s_es;
@@ -609,7 +609,7 @@ fail_free_drop:
 	dquot_free_inode(inode);
 
 fail_drop:
-	vfs_dq_drop(inode);
+	dquot_drop(inode);
 	inode->i_flags |= S_NOQUOTA;
 	inode->i_nlink = 0;
 	unlock_new_inode(inode);
Index: linux-2.6/fs/ext3/ialloc.c
===================================================================
--- linux-2.6.orig/fs/ext3/ialloc.c	2010-02-20 11:48:48.704006037 +0100
+++ linux-2.6/fs/ext3/ialloc.c	2010-02-20 11:59:10.755255373 +0100
@@ -126,7 +126,7 @@ void ext3_free_inode (handle_t *handle, 
 	vfs_dq_init(inode);
 	ext3_xattr_delete_inode(handle, inode);
 	dquot_free_inode(inode);
-	vfs_dq_drop(inode);
+	dquot_drop(inode);
 
 	is_directory = S_ISDIR(inode->i_mode);
 
@@ -623,7 +623,7 @@ fail_free_drop:
 	dquot_free_inode(inode);
 
 fail_drop:
-	vfs_dq_drop(inode);
+	dquot_drop(inode);
 	inode->i_flags |= S_NOQUOTA;
 	inode->i_nlink = 0;
 	unlock_new_inode(inode);
Index: linux-2.6/fs/ext4/ialloc.c
===================================================================
--- linux-2.6.orig/fs/ext4/ialloc.c	2010-02-20 11:48:48.707005688 +0100
+++ linux-2.6/fs/ext4/ialloc.c	2010-02-20 11:59:10.764254954 +0100
@@ -220,7 +220,7 @@ void ext4_free_inode(handle_t *handle, s
 	vfs_dq_init(inode);
 	ext4_xattr_delete_inode(handle, inode);
 	dquot_free_inode(inode);
-	vfs_dq_drop(inode);
+	dquot_drop(inode);
 
 	is_directory = S_ISDIR(inode->i_mode);
 
@@ -1078,7 +1078,7 @@ fail_free_drop:
 	dquot_free_inode(inode);
 
 fail_drop:
-	vfs_dq_drop(inode);
+	dquot_drop(inode);
 	inode->i_flags |= S_NOQUOTA;
 	inode->i_nlink = 0;
 	unlock_new_inode(inode);
Index: linux-2.6/fs/jfs/inode.c
===================================================================
--- linux-2.6.orig/fs/jfs/inode.c	2010-02-20 11:48:48.713005548 +0100
+++ linux-2.6/fs/jfs/inode.c	2010-02-20 11:59:10.775005758 +0100
@@ -160,7 +160,7 @@ void jfs_delete_inode(struct inode *inod
 		 */
 		vfs_dq_init(inode);
 		dquot_free_inode(inode);
-		vfs_dq_drop(inode);
+		dquot_drop(inode);
 	}
 
 	clear_inode(inode);
Index: linux-2.6/fs/jfs/jfs_inode.c
===================================================================
--- linux-2.6.orig/fs/jfs/jfs_inode.c	2010-02-20 11:48:48.718033206 +0100
+++ linux-2.6/fs/jfs/jfs_inode.c	2010-02-20 11:59:10.780255583 +0100
@@ -163,7 +163,7 @@ struct inode *ialloc(struct inode *paren
 	return inode;
 
 fail_drop:
-	vfs_dq_drop(inode);
+	dquot_drop(inode);
 	inode->i_flags |= S_NOQUOTA;
 fail_unlock:
 	inode->i_nlink = 0;
Index: linux-2.6/fs/quota/dquot.c
===================================================================
--- linux-2.6.orig/fs/quota/dquot.c	2010-02-20 11:55:53.742255234 +0100
+++ linux-2.6/fs/quota/dquot.c	2010-02-20 11:59:10.787005967 +0100
@@ -1358,7 +1358,7 @@ EXPORT_SYMBOL(dquot_initialize);
 /*
  * 	Release all quotas referenced by inode
  */
-int dquot_drop(struct inode *inode)
+static void __dquot_drop(struct inode *inode)
 {
 	int cnt;
 	struct dquot *put[MAXQUOTAS];
@@ -1370,32 +1370,31 @@ int dquot_drop(struct inode *inode)
 	}
 	up_write(&sb_dqopt(inode->i_sb)->dqptr_sem);
 	dqput_all(put);
-	return 0;
 }
-EXPORT_SYMBOL(dquot_drop);
 
-/* Wrapper to remove references to quota structures from inode */
-void vfs_dq_drop(struct inode *inode)
+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
-	 * are allowed to change only at mount time */
-	if (!IS_NOQUOTA(inode) && inode->i_sb && inode->i_sb->dq_op
-	    && inode->i_sb->dq_op->drop) {
-		int cnt;
-		/* Test before calling to rule out calls from proc and such
-                 * where we are not allowed to block. Note that this is
-		 * actually reliable test even without the lock - the caller
-		 * must assure that nobody can come after the DQUOT_DROP and
-		 * add quota pointers back anyway */
-		for (cnt = 0; cnt < MAXQUOTAS; cnt++)
-			if (inode->i_dquot[cnt])
-				break;
-		if (cnt < MAXQUOTAS)
-			inode->i_sb->dq_op->drop(inode);
+	int cnt;
+
+	if (IS_NOQUOTA(inode))
+		return;
+
+	/*
+	 * Test before calling to rule out calls from proc and such
+	 * where we are not allowed to block. Note that this is
+	 * actually reliable test even without the lock - the caller
+	 * must assure that nobody can come after the DQUOT_DROP and
+	 * add quota pointers back anyway.
+	 */
+	for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
+		if (inode->i_dquot[cnt])
+			break;
 	}
+
+	if (cnt < MAXQUOTAS)
+		__dquot_drop(inode);
 }
-EXPORT_SYMBOL(vfs_dq_drop);
+EXPORT_SYMBOL(dquot_drop);
 
 /*
  * inode_reserved_space is managed internally by quota, and protected by
@@ -1812,7 +1811,6 @@ EXPORT_SYMBOL(dquot_commit_info);
  */
 const struct dquot_operations dquot_operations = {
 	.initialize	= dquot_initialize,
-	.drop		= dquot_drop,
 	.write_dquot	= dquot_commit,
 	.acquire_dquot	= dquot_acquire,
 	.release_dquot	= dquot_release,
@@ -2027,7 +2025,7 @@ static int vfs_load_quota_inode(struct i
 		 * When S_NOQUOTA is set, remove dquot references as no more
 		 * references can be added
 		 */
-		sb->dq_op->drop(inode);
+		__dquot_drop(inode);
 	}
 
 	error = -EIO;
Index: linux-2.6/fs/reiserfs/inode.c
===================================================================
--- linux-2.6.orig/fs/reiserfs/inode.c	2010-02-20 11:55:53.847006037 +0100
+++ linux-2.6/fs/reiserfs/inode.c	2010-02-20 11:59:10.802007224 +0100
@@ -1965,7 +1965,7 @@ int reiserfs_new_inode(struct reiserfs_t
       out_end_trans:
 	journal_end(th, th->t_super, th->t_blocks_allocated);
 	/* Drop can be outside and it needs more credits so it's better to have it outside */
-	vfs_dq_drop(inode);
+	dquot_drop(inode);
 	inode->i_flags |= S_NOQUOTA;
 	make_bad_inode(inode);
 
Index: linux-2.6/fs/reiserfs/namei.c
===================================================================
--- linux-2.6.orig/fs/reiserfs/namei.c	2010-02-20 11:40:49.040003731 +0100
+++ linux-2.6/fs/reiserfs/namei.c	2010-02-20 11:59:10.814006596 +0100
@@ -546,7 +546,7 @@ static int reiserfs_add_entry(struct rei
 */
 static int drop_new_inode(struct inode *inode)
 {
-	vfs_dq_drop(inode);
+	dquot_drop(inode);
 	make_bad_inode(inode);
 	inode->i_flags |= S_NOQUOTA;
 	iput(inode);
Index: linux-2.6/fs/udf/ialloc.c
===================================================================
--- linux-2.6.orig/fs/udf/ialloc.c	2010-02-20 11:48:48.752005967 +0100
+++ linux-2.6/fs/udf/ialloc.c	2010-02-20 11:59:10.818035510 +0100
@@ -37,7 +37,7 @@ void udf_free_inode(struct inode *inode)
 	 * as writing the quota to disk may need the lock as well.
 	 */
 	dquot_free_inode(inode);
-	vfs_dq_drop(inode);
+	dquot_drop(inode);
 
 	clear_inode(inode);
 
@@ -155,7 +155,7 @@ struct inode *udf_new_inode(struct inode
 
 	vfs_dq_init(inode);
 	if (dquot_alloc_inode(inode)) {
-		vfs_dq_drop(inode);
+		dquot_drop(inode);
 		inode->i_flags |= S_NOQUOTA;
 		inode->i_nlink = 0;
 		iput(inode);
Index: linux-2.6/fs/ufs/ialloc.c
===================================================================
--- linux-2.6.orig/fs/ufs/ialloc.c	2010-02-20 11:48:48.755040748 +0100
+++ linux-2.6/fs/ufs/ialloc.c	2010-02-20 11:59:10.819293437 +0100
@@ -96,7 +96,7 @@ void ufs_free_inode (struct inode * inod
 	is_directory = S_ISDIR(inode->i_mode);
 
 	dquot_free_inode(inode);
-	vfs_dq_drop(inode);
+	dquot_drop(inode);
 
 	clear_inode (inode);
 
@@ -357,7 +357,7 @@ cg_found:
 
 	vfs_dq_init(inode);
 	if (dquot_alloc_inode(inode)) {
-		vfs_dq_drop(inode);
+		dquot_drop(inode);
 		err = -EDQUOT;
 		goto fail_without_unlock;
 	}
Index: linux-2.6/include/linux/quotaops.h
===================================================================
--- linux-2.6.orig/include/linux/quotaops.h	2010-02-20 11:55:53.763255583 +0100
+++ linux-2.6/include/linux/quotaops.h	2010-02-20 11:59:10.821253697 +0100
@@ -24,7 +24,7 @@ void inode_claim_rsv_space(struct inode 
 void inode_sub_rsv_space(struct inode *inode, qsize_t number);
 
 int dquot_initialize(struct inode *inode, int type);
-int dquot_drop(struct inode *inode);
+void dquot_drop(struct inode *inode);
 struct dquot *dqget(struct super_block *sb, unsigned int id, int type);
 void dqput(struct dquot *dquot);
 int dquot_scan_active(struct super_block *sb,
@@ -64,7 +64,6 @@ int vfs_set_dqinfo(struct super_block *s
 int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di);
 int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di);
 
-void vfs_dq_drop(struct inode *inode);
 int dquot_transfer(struct inode *inode, struct iattr *iattr);
 int vfs_dq_quota_on_remount(struct super_block *sb);
 
@@ -210,7 +209,7 @@ static inline void vfs_dq_init(struct in
 {
 }
 
-static inline void vfs_dq_drop(struct inode *inode)
+static inline void dquot_drop(struct inode *inode)
 {
 }
 
Index: linux-2.6/fs/ocfs2/quota_global.c
===================================================================
--- linux-2.6.orig/fs/ocfs2/quota_global.c	2010-02-20 11:55:53.733255653 +0100
+++ linux-2.6/fs/ocfs2/quota_global.c	2010-02-20 11:59:10.823282332 +0100
@@ -852,7 +852,6 @@ static void ocfs2_destroy_dquot(struct d
 
 const struct dquot_operations ocfs2_quota_operations = {
 	.initialize	= dquot_initialize,
-	.drop		= dquot_drop,
 	.write_dquot	= ocfs2_write_dquot,
 	.acquire_dquot	= ocfs2_acquire_dquot,
 	.release_dquot	= ocfs2_release_dquot,
Index: linux-2.6/Documentation/filesystems/Locking
===================================================================
--- linux-2.6.orig/Documentation/filesystems/Locking	2010-02-20 11:55:53.694023148 +0100
+++ linux-2.6/Documentation/filesystems/Locking	2010-02-20 11:59:10.826282123 +0100
@@ -461,7 +461,6 @@ in sys_read() and friends.
 --------------------------- dquot_operations -------------------------------
 prototypes:
 	int (*initialize) (struct inode *, int);
-	int (*drop) (struct inode *);
 	int (*write_dquot) (struct dquot *);
 	int (*acquire_dquot) (struct dquot *);
 	int (*release_dquot) (struct dquot *);
@@ -475,7 +474,6 @@ What filesystem should expect from the g
 
 		FS recursion	Held locks when called
 initialize:	yes		maybe dqonoff_sem
-drop:		yes		-
 write_dquot:	yes		dqonoff_sem or dqptr_sem
 acquire_dquot:	yes		dqonoff_sem or dqptr_sem
 release_dquot:	yes		dqonoff_sem or dqptr_sem
Index: linux-2.6/include/linux/quota.h
===================================================================
--- linux-2.6.orig/include/linux/quota.h	2010-02-20 11:55:53.761255862 +0100
+++ linux-2.6/include/linux/quota.h	2010-02-20 11:59:10.833269202 +0100
@@ -296,7 +296,6 @@ struct quota_format_ops {
 /* Operations working with dquots */
 struct dquot_operations {
 	int (*initialize) (struct inode *, int);
-	int (*drop) (struct inode *);
 	int (*write_dquot) (struct dquot *);		/* Ordinary dquot write */
 	struct dquot *(*alloc_dquot)(struct super_block *, int);	/* Allocate memory for new dquot */
 	void (*destroy_dquot)(struct dquot *);		/* Free memory for dquot */
Index: linux-2.6/fs/ext2/super.c
===================================================================
--- linux-2.6.orig/fs/ext2/super.c	2010-02-20 11:58:09.774023498 +0100
+++ linux-2.6/fs/ext2/super.c	2010-02-20 11:59:10.840255164 +0100
@@ -195,7 +195,7 @@ static void ext2_clear_inode(struct inod
 {
 	struct ext2_block_alloc_info *rsv = EXT2_I(inode)->i_block_alloc_info;
 
-	vfs_dq_drop(inode);
+	dquot_drop(inode);
 	ext2_discard_reservation(inode);
 	EXT2_I(inode)->i_block_alloc_info = NULL;
 	if (unlikely(rsv))
Index: linux-2.6/fs/jfs/super.c
===================================================================
--- linux-2.6.orig/fs/jfs/super.c	2010-02-20 11:58:09.812006247 +0100
+++ linux-2.6/fs/jfs/super.c	2010-02-20 11:59:10.853017421 +0100
@@ -133,7 +133,7 @@ static void jfs_destroy_inode(struct ino
 
 static void jfs_clear_inode(struct inode *inode)
 {
-	vfs_dq_drop(inode);
+	dquot_drop(inode);
 }
 
 static int jfs_statfs(struct dentry *dentry, struct kstatfs *buf)
Index: linux-2.6/fs/ocfs2/inode.c
===================================================================
--- linux-2.6.orig/fs/ocfs2/inode.c	2010-02-20 11:58:09.821281005 +0100
+++ linux-2.6/fs/ocfs2/inode.c	2010-02-20 11:59:10.860254535 +0100
@@ -1087,7 +1087,7 @@ void ocfs2_clear_inode(struct inode *ino
 	mlog_bug_on_msg(OCFS2_SB(inode->i_sb) == NULL,
 			"Inode=%lu\n", inode->i_ino);
 
-	vfs_dq_drop(inode);
+	dquot_drop(inode);
 
 	/* To preven remote deletes we hold open lock before, now it
 	 * is time to unlock PR and EX open locks. */
Index: linux-2.6/fs/ufs/super.c
===================================================================
--- linux-2.6.orig/fs/ufs/super.c	2010-02-20 11:58:09.845005897 +0100
+++ linux-2.6/fs/ufs/super.c	2010-02-20 11:59:10.870255373 +0100
@@ -1434,7 +1434,7 @@ static void destroy_inodecache(void)
 
 static void ufs_clear_inode(struct inode *inode)
 {
-	vfs_dq_drop(inode);
+	dquot_drop(inode);
 }
 
 #ifdef CONFIG_QUOTA


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

* [PATCH 7/8] dquot: move dquot initialization responsibiliy into the filesystem
  2010-02-20 11:51 [PATCH 0/8] dquot interface cleanups Christoph Hellwig
                   ` (5 preceding siblings ...)
  2010-02-20 11:51 ` [PATCH 6/8] dquot: cleanup dquot drop routine Christoph Hellwig
@ 2010-02-20 11:51 ` Christoph Hellwig
  2010-02-25  0:29   ` Jan Kara
  2010-03-02 18:44   ` Jan Kara
  2010-02-20 11:51 ` [PATCH 8/8] dquot: cleanup dquot initialize routine Christoph Hellwig
  7 siblings, 2 replies; 26+ messages in thread
From: Christoph Hellwig @ 2010-02-20 11:51 UTC (permalink / raw)
  To: jack; +Cc: linux-fsdevel

[-- Attachment #1: quota-move-init --]
[-- Type: text/plain, Size: 35639 bytes --]

Currently various places in the VFS call vfs_dq_init directly.  This means
we tie the quota code into the VFS.  Get rid of that and make the
filesystem responsibly for the initialization.   For most metadata operations
this is a straight forward move into the methods, but for truncate and
open it's a bit more complicated.

For truncate we currently only call vfs_dq_init for the sys_truncate case
because open already takes care of it for ftruncate and open(O_TRUNC) - the
new code causes an additional vfs_dq_init for those which is harmless.

For open the initialization is moved from do_filp_open into the open method,
which means it happens slightly earlier now, and only for regular files.
The latter is fine because we don't need to initialize it for operations
on special files, and we already do it as part of the namespace operations
for directories.

Add a dquot_file_open helper that filesystems that support generic quotas
can use to fill in ->open.

Signed-off-by: Christoph Hellwig <hch@lst.de>


Index: linux-2.6/fs/ext2/inode.c
===================================================================
--- linux-2.6.orig/fs/ext2/inode.c	2010-02-20 11:55:53.772255862 +0100
+++ linux-2.6/fs/ext2/inode.c	2010-02-20 12:00:45.486253976 +0100
@@ -58,6 +58,8 @@ static inline int ext2_inode_is_fast_sym
  */
 void ext2_delete_inode (struct inode * inode)
 {
+	if (!is_bad_inode(inode))
+		vfs_dq_init(inode);
 	truncate_inode_pages(&inode->i_data, 0);
 
 	if (is_bad_inode(inode))
@@ -1457,6 +1459,9 @@ int ext2_setattr(struct dentry *dentry, 
 	error = inode_change_ok(inode, iattr);
 	if (error)
 		return error;
+
+	if (iattr->ia_valid & ATTR_SIZE)
+		vfs_dq_init(inode);
 	if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
 	    (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
 		error = dquot_transfer(inode, iattr);
Index: linux-2.6/fs/ext3/inode.c
===================================================================
--- linux-2.6.orig/fs/ext3/inode.c	2010-02-20 11:55:53.781265570 +0100
+++ linux-2.6/fs/ext3/inode.c	2010-02-20 12:00:45.488257957 +0100
@@ -196,6 +196,9 @@ void ext3_delete_inode (struct inode * i
 {
 	handle_t *handle;
 
+	if (!is_bad_inode(inode))
+		vfs_dq_init(inode);
+
 	truncate_inode_pages(&inode->i_data, 0);
 
 	if (is_bad_inode(inode))
@@ -3140,6 +3143,8 @@ int ext3_setattr(struct dentry *dentry, 
 	if (error)
 		return error;
 
+	if (ia_valid & ATTR_SIZE)
+		vfs_dq_init(inode);
 	if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
 		(ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
 		handle_t *handle;
Index: linux-2.6/fs/ext4/inode.c
===================================================================
--- linux-2.6.orig/fs/ext4/inode.c	2010-02-20 11:55:53.804005688 +0100
+++ linux-2.6/fs/ext4/inode.c	2010-02-20 12:00:45.505255373 +0100
@@ -170,6 +170,9 @@ void ext4_delete_inode(struct inode *ino
 	handle_t *handle;
 	int err;
 
+	if (!is_bad_inode(inode))
+		vfs_dq_init(inode);
+
 	if (ext4_should_order_data(inode))
 		ext4_begin_ordered_truncate(inode, 0);
 	truncate_inode_pages(&inode->i_data, 0);
@@ -5249,6 +5252,8 @@ int ext4_setattr(struct dentry *dentry, 
 	if (error)
 		return error;
 
+	if (ia_valid & ATTR_SIZE)
+		vfs_dq_init(inode);
 	if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
 		(ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
 		handle_t *handle;
Index: linux-2.6/fs/inode.c
===================================================================
--- linux-2.6.orig/fs/inode.c	2010-02-20 11:58:09.796005478 +0100
+++ linux-2.6/fs/inode.c	2010-02-20 12:00:45.538255584 +0100
@@ -8,7 +8,6 @@
 #include <linux/mm.h>
 #include <linux/dcache.h>
 #include <linux/init.h>
-#include <linux/quotaops.h>
 #include <linux/slab.h>
 #include <linux/writeback.h>
 #include <linux/module.h>
@@ -1210,8 +1209,6 @@ void generic_delete_inode(struct inode *
 
 	if (op->delete_inode) {
 		void (*delete)(struct inode *) = op->delete_inode;
-		if (!is_bad_inode(inode))
-			vfs_dq_init(inode);
 		/* Filesystems implementing their own
 		 * s_op->delete_inode are required to call
 		 * truncate_inode_pages and clear_inode()
Index: linux-2.6/fs/jfs/inode.c
===================================================================
--- linux-2.6.orig/fs/jfs/inode.c	2010-02-20 11:59:10.775005758 +0100
+++ linux-2.6/fs/jfs/inode.c	2010-02-20 12:00:45.545255374 +0100
@@ -146,6 +146,9 @@ void jfs_delete_inode(struct inode *inod
 {
 	jfs_info("In jfs_delete_inode, inode = 0x%p", inode);
 
+	if (!is_bad_inode(inode))
+		vfs_dq_init(inode);
+
 	if (!is_bad_inode(inode) &&
 	    (JFS_IP(inode)->fileset == FILESYSTEM_I)) {
 		truncate_inode_pages(&inode->i_data, 0);
Index: linux-2.6/fs/ocfs2/inode.c
===================================================================
--- linux-2.6.orig/fs/ocfs2/inode.c	2010-02-20 11:59:10.860254535 +0100
+++ linux-2.6/fs/ocfs2/inode.c	2010-02-20 12:00:45.548255793 +0100
@@ -971,6 +971,8 @@ void ocfs2_delete_inode(struct inode *in
 		goto bail;
 	}
 
+	vfs_dq_init(inode);
+
 	if (!ocfs2_inode_is_valid_to_delete(inode)) {
 		/* It's probably not necessary to truncate_inode_pages
 		 * here but we do it for safety anyway (it will most
Index: linux-2.6/fs/reiserfs/inode.c
===================================================================
--- linux-2.6.orig/fs/reiserfs/inode.c	2010-02-20 11:59:10.802007224 +0100
+++ linux-2.6/fs/reiserfs/inode.c	2010-02-20 12:00:45.554256073 +0100
@@ -34,6 +34,9 @@ void reiserfs_delete_inode(struct inode 
 	int depth;
 	int err;
 
+	if (!is_bad_inode(inode))
+		vfs_dq_init(inode);
+
 	truncate_inode_pages(&inode->i_data, 0);
 
 	depth = reiserfs_write_lock_once(inode->i_sb);
@@ -3073,6 +3076,8 @@ int reiserfs_setattr(struct dentry *dent
 	ia_valid = attr->ia_valid &= ~(ATTR_KILL_SUID|ATTR_KILL_SGID);
 
 	depth = reiserfs_write_lock_once(inode->i_sb);
+	if (ia_valid & ATTR_SIZE)
+		vfs_dq_init(inode);
 	if (attr->ia_valid & ATTR_SIZE) {
 		/* version 2 items will be caught by the s_maxbytes check
 		 ** done for us in vmtruncate
Index: linux-2.6/fs/ufs/inode.c
===================================================================
--- linux-2.6.orig/fs/ufs/inode.c	2010-02-20 11:40:48.574254465 +0100
+++ linux-2.6/fs/ufs/inode.c	2010-02-20 12:00:45.560257050 +0100
@@ -36,6 +36,7 @@
 #include <linux/mm.h>
 #include <linux/smp_lock.h>
 #include <linux/buffer_head.h>
+#include <linux/quotaops.h>
 
 #include "ufs_fs.h"
 #include "ufs.h"
@@ -908,6 +909,9 @@ void ufs_delete_inode (struct inode * in
 {
 	loff_t old_i_size;
 
+	if (!is_bad_inode(inode))
+		vfs_dq_init(inode);
+
 	truncate_inode_pages(&inode->i_data, 0);
 	if (is_bad_inode(inode))
 		goto no_delete;
Index: linux-2.6/fs/namei.c
===================================================================
--- linux-2.6.orig/fs/namei.c	2010-02-20 11:40:48.597274509 +0100
+++ linux-2.6/fs/namei.c	2010-02-20 12:00:45.565255863 +0100
@@ -19,7 +19,6 @@
 #include <linux/slab.h>
 #include <linux/fs.h>
 #include <linux/namei.h>
-#include <linux/quotaops.h>
 #include <linux/pagemap.h>
 #include <linux/fsnotify.h>
 #include <linux/personality.h>
@@ -1451,7 +1450,6 @@ int vfs_create(struct inode *dir, struct
 	error = security_inode_create(dir, dentry, mode);
 	if (error)
 		return error;
-	vfs_dq_init(dir);
 	error = dir->i_op->create(dir, dentry, mode, nd);
 	if (!error)
 		fsnotify_create(dir, dentry);
@@ -1803,9 +1801,6 @@ ok:
 		}
 	}
 	if (!IS_ERR(filp)) {
-		if (acc_mode & MAY_WRITE)
-			vfs_dq_init(nd.path.dentry->d_inode);
-
 		if (will_truncate) {
 			error = handle_truncate(&nd.path);
 			if (error) {
@@ -1986,7 +1981,6 @@ int vfs_mknod(struct inode *dir, struct 
 	if (error)
 		return error;
 
-	vfs_dq_init(dir);
 	error = dir->i_op->mknod(dir, dentry, mode, dev);
 	if (!error)
 		fsnotify_create(dir, dentry);
@@ -2085,7 +2079,6 @@ int vfs_mkdir(struct inode *dir, struct 
 	if (error)
 		return error;
 
-	vfs_dq_init(dir);
 	error = dir->i_op->mkdir(dir, dentry, mode);
 	if (!error)
 		fsnotify_mkdir(dir, dentry);
@@ -2171,8 +2164,6 @@ int vfs_rmdir(struct inode *dir, struct 
 	if (!dir->i_op->rmdir)
 		return -EPERM;
 
-	vfs_dq_init(dir);
-
 	mutex_lock(&dentry->d_inode->i_mutex);
 	dentry_unhash(dentry);
 	if (d_mountpoint(dentry))
@@ -2258,8 +2249,6 @@ int vfs_unlink(struct inode *dir, struct
 	if (!dir->i_op->unlink)
 		return -EPERM;
 
-	vfs_dq_init(dir);
-
 	mutex_lock(&dentry->d_inode->i_mutex);
 	if (d_mountpoint(dentry))
 		error = -EBUSY;
@@ -2369,7 +2358,6 @@ int vfs_symlink(struct inode *dir, struc
 	if (error)
 		return error;
 
-	vfs_dq_init(dir);
 	error = dir->i_op->symlink(dir, dentry, oldname);
 	if (!error)
 		fsnotify_create(dir, dentry);
@@ -2453,7 +2441,6 @@ int vfs_link(struct dentry *old_dentry, 
 		return error;
 
 	mutex_lock(&inode->i_mutex);
-	vfs_dq_init(dir);
 	error = dir->i_op->link(old_dentry, dir, new_dentry);
 	mutex_unlock(&inode->i_mutex);
 	if (!error)
@@ -2652,9 +2639,6 @@ int vfs_rename(struct inode *old_dir, st
 	if (!old_dir->i_op->rename)
 		return -EPERM;
 
-	vfs_dq_init(old_dir);
-	vfs_dq_init(new_dir);
-
 	old_name = fsnotify_oldname_init(old_dentry->d_name.name);
 
 	if (is_dir)
Index: linux-2.6/fs/ext2/namei.c
===================================================================
--- linux-2.6.orig/fs/ext2/namei.c	2010-02-20 11:40:48.390272694 +0100
+++ linux-2.6/fs/ext2/namei.c	2010-02-20 12:00:45.577006037 +0100
@@ -31,6 +31,7 @@
  */
 
 #include <linux/pagemap.h>
+#include <linux/quotaops.h>
 #include "ext2.h"
 #include "xattr.h"
 #include "acl.h"
@@ -99,24 +100,27 @@ struct dentry *ext2_get_parent(struct de
  */
 static int ext2_create (struct inode * dir, struct dentry * dentry, int mode, struct nameidata *nd)
 {
-	struct inode * inode = ext2_new_inode (dir, mode);
-	int err = PTR_ERR(inode);
-	if (!IS_ERR(inode)) {
-		inode->i_op = &ext2_file_inode_operations;
-		if (ext2_use_xip(inode->i_sb)) {
-			inode->i_mapping->a_ops = &ext2_aops_xip;
-			inode->i_fop = &ext2_xip_file_operations;
-		} else if (test_opt(inode->i_sb, NOBH)) {
-			inode->i_mapping->a_ops = &ext2_nobh_aops;
-			inode->i_fop = &ext2_file_operations;
-		} else {
-			inode->i_mapping->a_ops = &ext2_aops;
-			inode->i_fop = &ext2_file_operations;
-		}
-		mark_inode_dirty(inode);
-		err = ext2_add_nondir(dentry, inode);
+	struct inode *inode;
+
+	vfs_dq_init(dir);
+
+	inode = ext2_new_inode(dir, mode);
+	if (IS_ERR(inode))
+		return PTR_ERR(inode);
+
+	inode->i_op = &ext2_file_inode_operations;
+	if (ext2_use_xip(inode->i_sb)) {
+		inode->i_mapping->a_ops = &ext2_aops_xip;
+		inode->i_fop = &ext2_xip_file_operations;
+	} else if (test_opt(inode->i_sb, NOBH)) {
+		inode->i_mapping->a_ops = &ext2_nobh_aops;
+		inode->i_fop = &ext2_file_operations;
+	} else {
+		inode->i_mapping->a_ops = &ext2_aops;
+		inode->i_fop = &ext2_file_operations;
 	}
-	return err;
+	mark_inode_dirty(inode);
+	return ext2_add_nondir(dentry, inode);
 }
 
 static int ext2_mknod (struct inode * dir, struct dentry *dentry, int mode, dev_t rdev)
@@ -127,6 +131,8 @@ static int ext2_mknod (struct inode * di
 	if (!new_valid_dev(rdev))
 		return -EINVAL;
 
+	vfs_dq_init(dir);
+
 	inode = ext2_new_inode (dir, mode);
 	err = PTR_ERR(inode);
 	if (!IS_ERR(inode)) {
@@ -151,6 +157,8 @@ static int ext2_symlink (struct inode * 
 	if (l > sb->s_blocksize)
 		goto out;
 
+	vfs_dq_init(dir);
+
 	inode = ext2_new_inode (dir, S_IFLNK | S_IRWXUGO);
 	err = PTR_ERR(inode);
 	if (IS_ERR(inode))
@@ -194,6 +202,8 @@ static int ext2_link (struct dentry * ol
 	if (inode->i_nlink >= EXT2_LINK_MAX)
 		return -EMLINK;
 
+	vfs_dq_init(dir);
+
 	inode->i_ctime = CURRENT_TIME_SEC;
 	inode_inc_link_count(inode);
 	atomic_inc(&inode->i_count);
@@ -216,6 +226,8 @@ static int ext2_mkdir(struct inode * dir
 	if (dir->i_nlink >= EXT2_LINK_MAX)
 		goto out;
 
+	vfs_dq_init(dir);
+
 	inode_inc_link_count(dir);
 
 	inode = ext2_new_inode (dir, S_IFDIR | mode);
@@ -262,6 +274,8 @@ static int ext2_unlink(struct inode * di
 	struct page * page;
 	int err = -ENOENT;
 
+	vfs_dq_init(dir);
+
 	de = ext2_find_entry (dir, &dentry->d_name, &page);
 	if (!de)
 		goto out;
@@ -304,6 +318,9 @@ static int ext2_rename (struct inode * o
 	struct ext2_dir_entry_2 * old_de;
 	int err = -ENOENT;
 
+	vfs_dq_init(old_dir);
+	vfs_dq_init(new_dir);
+
 	old_de = ext2_find_entry (old_dir, &old_dentry->d_name, &old_page);
 	if (!old_de)
 		goto out;
Index: linux-2.6/fs/ext3/namei.c
===================================================================
--- linux-2.6.orig/fs/ext3/namei.c	2010-02-20 11:40:48.419254255 +0100
+++ linux-2.6/fs/ext3/namei.c	2010-02-20 12:00:45.584007015 +0100
@@ -1696,6 +1696,8 @@ static int ext3_create (struct inode * d
 	struct inode * inode;
 	int err, retries = 0;
 
+	vfs_dq_init(dir);
+
 retry:
 	handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
 					EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 +
@@ -1730,6 +1732,8 @@ static int ext3_mknod (struct inode * di
 	if (!new_valid_dev(rdev))
 		return -EINVAL;
 
+	vfs_dq_init(dir);
+
 retry:
 	handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
 					EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 +
@@ -1766,6 +1770,8 @@ static int ext3_mkdir(struct inode * dir
 	if (dir->i_nlink >= EXT3_LINK_MAX)
 		return -EMLINK;
 
+	vfs_dq_init(dir);
+
 retry:
 	handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
 					EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 +
@@ -2060,7 +2066,9 @@ static int ext3_rmdir (struct inode * di
 
 	/* Initialize quotas before so that eventual writes go in
 	 * separate transaction */
+	vfs_dq_init(dir);
 	vfs_dq_init(dentry->d_inode);
+
 	handle = ext3_journal_start(dir, EXT3_DELETE_TRANS_BLOCKS(dir->i_sb));
 	if (IS_ERR(handle))
 		return PTR_ERR(handle);
@@ -2119,7 +2127,9 @@ static int ext3_unlink(struct inode * di
 
 	/* Initialize quotas before so that eventual writes go
 	 * in separate transaction */
+	vfs_dq_init(dir);
 	vfs_dq_init(dentry->d_inode);
+
 	handle = ext3_journal_start(dir, EXT3_DELETE_TRANS_BLOCKS(dir->i_sb));
 	if (IS_ERR(handle))
 		return PTR_ERR(handle);
@@ -2174,6 +2184,8 @@ static int ext3_symlink (struct inode * 
 	if (l > dir->i_sb->s_blocksize)
 		return -ENAMETOOLONG;
 
+	vfs_dq_init(dir);
+
 retry:
 	handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
 					EXT3_INDEX_EXTRA_TRANS_BLOCKS + 5 +
@@ -2228,6 +2240,9 @@ static int ext3_link (struct dentry * ol
 
 	if (inode->i_nlink >= EXT3_LINK_MAX)
 		return -EMLINK;
+
+	vfs_dq_init(dir);
+
 	/*
 	 * Return -ENOENT if we've raced with unlink and i_nlink is 0.  Doing
 	 * otherwise has the potential to corrupt the orphan inode list.
@@ -2278,6 +2293,9 @@ static int ext3_rename (struct inode * o
 	struct ext3_dir_entry_2 * old_de, * new_de;
 	int retval, flush_file = 0;
 
+	vfs_dq_init(old_dir);
+	vfs_dq_init(new_dir);
+
 	old_bh = new_bh = dir_bh = NULL;
 
 	/* Initialize quotas before so that eventual writes go
Index: linux-2.6/fs/ext4/namei.c
===================================================================
--- linux-2.6.orig/fs/ext4/namei.c	2010-02-20 11:40:48.450275138 +0100
+++ linux-2.6/fs/ext4/namei.c	2010-02-20 12:00:45.602005827 +0100
@@ -1766,6 +1766,8 @@ static int ext4_create(struct inode *dir
 	struct inode *inode;
 	int err, retries = 0;
 
+	vfs_dq_init(dir);
+
 retry:
 	handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
 					EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
@@ -1800,6 +1802,8 @@ static int ext4_mknod(struct inode *dir,
 	if (!new_valid_dev(rdev))
 		return -EINVAL;
 
+	vfs_dq_init(dir);
+
 retry:
 	handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
 					EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
@@ -1837,6 +1841,8 @@ static int ext4_mkdir(struct inode *dir,
 	if (EXT4_DIR_LINK_MAX(dir))
 		return -EMLINK;
 
+	vfs_dq_init(dir);
+
 retry:
 	handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
 					EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
@@ -2136,7 +2142,9 @@ static int ext4_rmdir(struct inode *dir,
 
 	/* Initialize quotas before so that eventual writes go in
 	 * separate transaction */
+	vfs_dq_init(dir);
 	vfs_dq_init(dentry->d_inode);
+
 	handle = ext4_journal_start(dir, EXT4_DELETE_TRANS_BLOCKS(dir->i_sb));
 	if (IS_ERR(handle))
 		return PTR_ERR(handle);
@@ -2195,7 +2203,9 @@ static int ext4_unlink(struct inode *dir
 
 	/* Initialize quotas before so that eventual writes go
 	 * in separate transaction */
+	vfs_dq_init(dir);
 	vfs_dq_init(dentry->d_inode);
+
 	handle = ext4_journal_start(dir, EXT4_DELETE_TRANS_BLOCKS(dir->i_sb));
 	if (IS_ERR(handle))
 		return PTR_ERR(handle);
@@ -2250,6 +2260,8 @@ static int ext4_symlink(struct inode *di
 	if (l > dir->i_sb->s_blocksize)
 		return -ENAMETOOLONG;
 
+	vfs_dq_init(dir);
+
 retry:
 	handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
 					EXT4_INDEX_EXTRA_TRANS_BLOCKS + 5 +
@@ -2308,6 +2320,8 @@ static int ext4_link(struct dentry *old_
 	if (inode->i_nlink >= EXT4_LINK_MAX)
 		return -EMLINK;
 
+	vfs_dq_init(dir);
+
 	/*
 	 * Return -ENOENT if we've raced with unlink and i_nlink is 0.  Doing
 	 * otherwise has the potential to corrupt the orphan inode list.
@@ -2358,6 +2372,9 @@ static int ext4_rename(struct inode *old
 	struct ext4_dir_entry_2 *old_de, *new_de;
 	int retval, force_da_alloc = 0;
 
+	vfs_dq_init(old_dir);
+	vfs_dq_init(new_dir);
+
 	old_bh = new_bh = dir_bh = NULL;
 
 	/* Initialize quotas before so that eventual writes go
Index: linux-2.6/fs/jfs/namei.c
===================================================================
--- linux-2.6.orig/fs/jfs/namei.c	2010-02-20 11:53:51.140254046 +0100
+++ linux-2.6/fs/jfs/namei.c	2010-02-20 12:00:45.617005478 +0100
@@ -85,6 +85,8 @@ static int jfs_create(struct inode *dip,
 
 	jfs_info("jfs_create: dip:0x%p name:%s", dip, dentry->d_name.name);
 
+	vfs_dq_init(dip);
+
 	/*
 	 * search parent directory for entry/freespace
 	 * (dtSearch() returns parent directory page pinned)
@@ -215,6 +217,8 @@ static int jfs_mkdir(struct inode *dip, 
 
 	jfs_info("jfs_mkdir: dip:0x%p name:%s", dip, dentry->d_name.name);
 
+	vfs_dq_init(dip);
+
 	/* link count overflow on parent directory ? */
 	if (dip->i_nlink == JFS_LINK_MAX) {
 		rc = -EMLINK;
@@ -356,6 +360,7 @@ static int jfs_rmdir(struct inode *dip, 
 	jfs_info("jfs_rmdir: dip:0x%p name:%s", dip, dentry->d_name.name);
 
 	/* Init inode for quota operations. */
+	vfs_dq_init(dip);
 	vfs_dq_init(ip);
 
 	/* directory must be empty to be removed */
@@ -483,6 +488,7 @@ static int jfs_unlink(struct inode *dip,
 	jfs_info("jfs_unlink: dip:0x%p name:%s", dip, dentry->d_name.name);
 
 	/* Init inode for quota operations. */
+	vfs_dq_init(dip);
 	vfs_dq_init(ip);
 
 	if ((rc = get_UCSname(&dname, dentry)))
@@ -805,6 +811,8 @@ static int jfs_link(struct dentry *old_d
 	if (ip->i_nlink == 0)
 		return -ENOENT;
 
+	vfs_dq_init(dir);
+
 	tid = txBegin(ip->i_sb, 0);
 
 	mutex_lock_nested(&JFS_IP(dir)->commit_mutex, COMMIT_MUTEX_PARENT);
@@ -896,6 +904,8 @@ static int jfs_symlink(struct inode *dip
 
 	jfs_info("jfs_symlink: dip:0x%p name:%s", dip, name);
 
+	vfs_dq_init(dip);
+
 	ssize = strlen(name) + 1;
 
 	/*
@@ -1087,6 +1097,9 @@ static int jfs_rename(struct inode *old_
 	jfs_info("jfs_rename: %s %s", old_dentry->d_name.name,
 		 new_dentry->d_name.name);
 
+	vfs_dq_init(old_dir);
+	vfs_dq_init(new_dir);
+
 	old_ip = old_dentry->d_inode;
 	new_ip = new_dentry->d_inode;
 
@@ -1360,6 +1373,8 @@ static int jfs_mknod(struct inode *dir, 
 
 	jfs_info("jfs_mknod: %s", dentry->d_name.name);
 
+	vfs_dq_init(dir);
+
 	if ((rc = get_UCSname(&dname, dentry)))
 		goto out;
 
Index: linux-2.6/fs/ocfs2/namei.c
===================================================================
--- linux-2.6.orig/fs/ocfs2/namei.c	2010-02-20 11:48:48.651005199 +0100
+++ linux-2.6/fs/ocfs2/namei.c	2010-02-20 12:00:45.625285195 +0100
@@ -244,6 +244,8 @@ static int ocfs2_mknod(struct inode *dir
 		   (unsigned long)dev, dentry->d_name.len,
 		   dentry->d_name.name);
 
+	vfs_dq_init(dir);
+
 	/* get our super block */
 	osb = OCFS2_SB(dir->i_sb);
 
@@ -633,6 +635,8 @@ static int ocfs2_link(struct dentry *old
 	if (S_ISDIR(inode->i_mode))
 		return -EPERM;
 
+	vfs_dq_init(dir);
+
 	err = ocfs2_inode_lock_nested(dir, &parent_fe_bh, 1, OI_LS_PARENT);
 	if (err < 0) {
 		if (err != -ENOENT)
@@ -788,6 +792,8 @@ static int ocfs2_unlink(struct inode *di
 	mlog_entry("(0x%p, 0x%p, '%.*s')\n", dir, dentry,
 		   dentry->d_name.len, dentry->d_name.name);
 
+	vfs_dq_init(dir);
+
 	BUG_ON(dentry->d_parent->d_inode != dir);
 
 	mlog(0, "ino = %llu\n", (unsigned long long)OCFS2_I(inode)->ip_blkno);
@@ -1048,6 +1054,9 @@ static int ocfs2_rename(struct inode *ol
 		   old_dentry->d_name.len, old_dentry->d_name.name,
 		   new_dentry->d_name.len, new_dentry->d_name.name);
 
+	vfs_dq_init(old_dir);
+	vfs_dq_init(new_dir);
+
 	osb = OCFS2_SB(old_dir->i_sb);
 
 	if (new_inode) {
@@ -1596,6 +1605,8 @@ static int ocfs2_symlink(struct inode *d
 	mlog_entry("(0x%p, 0x%p, symname='%s' actual='%.*s')\n", dir,
 		   dentry, symname, dentry->d_name.len, dentry->d_name.name);
 
+	vfs_dq_init(dir);
+
 	sb = dir->i_sb;
 	osb = OCFS2_SB(sb);
 
Index: linux-2.6/fs/reiserfs/namei.c
===================================================================
--- linux-2.6.orig/fs/reiserfs/namei.c	2010-02-20 11:59:10.814006596 +0100
+++ linux-2.6/fs/reiserfs/namei.c	2010-02-20 12:00:45.631256001 +0100
@@ -594,6 +594,8 @@ static int reiserfs_create(struct inode 
 	struct reiserfs_transaction_handle th;
 	struct reiserfs_security_handle security;
 
+	vfs_dq_init(dir);
+
 	if (!(inode = new_inode(dir->i_sb))) {
 		return -ENOMEM;
 	}
@@ -666,6 +668,8 @@ static int reiserfs_mknod(struct inode *
 	if (!new_valid_dev(rdev))
 		return -EINVAL;
 
+	vfs_dq_init(dir);
+
 	if (!(inode = new_inode(dir->i_sb))) {
 		return -ENOMEM;
 	}
@@ -739,6 +743,8 @@ static int reiserfs_mkdir(struct inode *
 	    2 * (REISERFS_QUOTA_INIT_BLOCKS(dir->i_sb) +
 		 REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb));
 
+	vfs_dq_init(dir);
+
 #ifdef DISPLACE_NEW_PACKING_LOCALITIES
 	/* set flag that new packing locality created and new blocks for the content     * of that directory are not displaced yet */
 	REISERFS_I(dir)->new_packing_locality = 1;
@@ -842,6 +848,8 @@ static int reiserfs_rmdir(struct inode *
 	    JOURNAL_PER_BALANCE_CNT * 2 + 2 +
 	    4 * REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb);
 
+	vfs_dq_init(dir);
+
 	reiserfs_write_lock(dir->i_sb);
 	retval = journal_begin(&th, dir->i_sb, jbegin_count);
 	if (retval)
@@ -923,6 +931,8 @@ static int reiserfs_unlink(struct inode 
 	unsigned long savelink;
 	int depth;
 
+	vfs_dq_init(dir);
+
 	inode = dentry->d_inode;
 
 	/* in this transaction we can be doing at max two balancings and update
@@ -1024,6 +1034,8 @@ static int reiserfs_symlink(struct inode
 	    2 * (REISERFS_QUOTA_INIT_BLOCKS(parent_dir->i_sb) +
 		 REISERFS_QUOTA_TRANS_BLOCKS(parent_dir->i_sb));
 
+	vfs_dq_init(parent_dir);
+
 	if (!(inode = new_inode(parent_dir->i_sb))) {
 		return -ENOMEM;
 	}
@@ -1111,6 +1123,8 @@ static int reiserfs_link(struct dentry *
 	    JOURNAL_PER_BALANCE_CNT * 3 +
 	    2 * REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb);
 
+	vfs_dq_init(dir);
+
 	reiserfs_write_lock(dir->i_sb);
 	if (inode->i_nlink >= REISERFS_LINK_MAX) {
 		//FIXME: sd_nlink is 32 bit for new files
@@ -1235,6 +1249,9 @@ static int reiserfs_rename(struct inode 
 	    JOURNAL_PER_BALANCE_CNT * 3 + 5 +
 	    4 * REISERFS_QUOTA_TRANS_BLOCKS(old_dir->i_sb);
 
+	vfs_dq_init(old_dir);
+	vfs_dq_init(new_dir);
+
 	old_inode = old_dentry->d_inode;
 	new_dentry_inode = new_dentry->d_inode;
 
Index: linux-2.6/fs/reiserfs/xattr.c
===================================================================
--- linux-2.6.orig/fs/reiserfs/xattr.c	2010-02-20 11:40:48.552254116 +0100
+++ linux-2.6/fs/reiserfs/xattr.c	2010-02-20 12:00:45.635255512 +0100
@@ -61,7 +61,6 @@
 static int xattr_create(struct inode *dir, struct dentry *dentry, int mode)
 {
 	BUG_ON(!mutex_is_locked(&dir->i_mutex));
-	vfs_dq_init(dir);
 	return dir->i_op->create(dir, dentry, mode, NULL);
 }
 #endif
@@ -69,7 +68,6 @@ static int xattr_create(struct inode *di
 static int xattr_mkdir(struct inode *dir, struct dentry *dentry, int mode)
 {
 	BUG_ON(!mutex_is_locked(&dir->i_mutex));
-	vfs_dq_init(dir);
 	return dir->i_op->mkdir(dir, dentry, mode);
 }
 
@@ -81,7 +79,6 @@ static int xattr_unlink(struct inode *di
 {
 	int error;
 	BUG_ON(!mutex_is_locked(&dir->i_mutex));
-	vfs_dq_init(dir);
 
 	reiserfs_mutex_lock_nested_safe(&dentry->d_inode->i_mutex,
 					I_MUTEX_CHILD, dir->i_sb);
@@ -97,7 +94,6 @@ static int xattr_rmdir(struct inode *dir
 {
 	int error;
 	BUG_ON(!mutex_is_locked(&dir->i_mutex));
-	vfs_dq_init(dir);
 
 	reiserfs_mutex_lock_nested_safe(&dentry->d_inode->i_mutex,
 					I_MUTEX_CHILD, dir->i_sb);
Index: linux-2.6/fs/ufs/namei.c
===================================================================
--- linux-2.6.orig/fs/ufs/namei.c	2010-02-20 11:40:48.582254325 +0100
+++ linux-2.6/fs/ufs/namei.c	2010-02-20 12:00:45.638255862 +0100
@@ -30,6 +30,7 @@
 #include <linux/time.h>
 #include <linux/fs.h>
 #include <linux/smp_lock.h>
+#include <linux/quotaops.h>
 
 #include "ufs_fs.h"
 #include "ufs.h"
@@ -84,6 +85,9 @@ static int ufs_create (struct inode * di
 	int err;
 
 	UFSD("BEGIN\n");
+
+	vfs_dq_init(dir);
+
 	inode = ufs_new_inode(dir, mode);
 	err = PTR_ERR(inode);
 
@@ -107,6 +111,9 @@ static int ufs_mknod (struct inode * dir
 
 	if (!old_valid_dev(rdev))
 		return -EINVAL;
+
+	vfs_dq_init(dir);
+
 	inode = ufs_new_inode(dir, mode);
 	err = PTR_ERR(inode);
 	if (!IS_ERR(inode)) {
@@ -131,6 +138,8 @@ static int ufs_symlink (struct inode * d
 	if (l > sb->s_blocksize)
 		goto out_notlocked;
 
+	vfs_dq_init(dir);
+
 	lock_kernel();
 	inode = ufs_new_inode(dir, S_IFLNK | S_IRWXUGO);
 	err = PTR_ERR(inode);
@@ -176,6 +185,8 @@ static int ufs_link (struct dentry * old
 		return -EMLINK;
 	}
 
+	vfs_dq_init(dir);
+
 	inode->i_ctime = CURRENT_TIME_SEC;
 	inode_inc_link_count(inode);
 	atomic_inc(&inode->i_count);
@@ -193,6 +204,8 @@ static int ufs_mkdir(struct inode * dir,
 	if (dir->i_nlink >= UFS_LINK_MAX)
 		goto out;
 
+	vfs_dq_init(dir);
+
 	lock_kernel();
 	inode_inc_link_count(dir);
 
@@ -237,6 +250,8 @@ static int ufs_unlink(struct inode *dir,
 	struct page *page;
 	int err = -ENOENT;
 
+	vfs_dq_init(dir);
+
 	de = ufs_find_entry(dir, &dentry->d_name, &page);
 	if (!de)
 		goto out;
@@ -281,6 +296,9 @@ static int ufs_rename(struct inode *old_
 	struct ufs_dir_entry *old_de;
 	int err = -ENOENT;
 
+	vfs_dq_init(old_dir);
+	vfs_dq_init(new_dir);
+
 	old_de = ufs_find_entry(old_dir, &old_dentry->d_name, &old_page);
 	if (!old_de)
 		goto out;
Index: linux-2.6/fs/nfsd/vfs.c
===================================================================
--- linux-2.6.orig/fs/nfsd/vfs.c	2010-02-20 11:40:48.611254535 +0100
+++ linux-2.6/fs/nfsd/vfs.c	2010-02-20 12:00:45.641255652 +0100
@@ -20,7 +20,6 @@
 #include <linux/fcntl.h>
 #include <linux/namei.h>
 #include <linux/delay.h>
-#include <linux/quotaops.h>
 #include <linux/fsnotify.h>
 #include <linux/posix_acl_xattr.h>
 #include <linux/xattr.h>
@@ -377,7 +376,6 @@ nfsd_setattr(struct svc_rqst *rqstp, str
 			put_write_access(inode);
 			goto out_nfserr;
 		}
-		vfs_dq_init(inode);
 	}
 
 	/* sanitize the mode change */
@@ -745,8 +743,6 @@ nfsd_open(struct svc_rqst *rqstp, struct
 			flags = O_RDWR|O_LARGEFILE;
 		else
 			flags = O_WRONLY|O_LARGEFILE;
-
-		vfs_dq_init(inode);
 	}
 	*filp = dentry_open(dget(dentry), mntget(fhp->fh_export->ex_path.mnt),
 			    flags, current_cred());
Index: linux-2.6/fs/ocfs2/file.c
===================================================================
--- linux-2.6.orig/fs/ocfs2/file.c	2010-02-20 11:55:53.836005270 +0100
+++ linux-2.6/fs/ocfs2/file.c	2010-02-20 12:00:45.648255722 +0100
@@ -107,6 +107,9 @@ static int ocfs2_file_open(struct inode 
 	mlog_entry("(0x%p, 0x%p, '%.*s')\n", inode, file,
 		   file->f_path.dentry->d_name.len, file->f_path.dentry->d_name.name);
 
+	if (file->f_mode & FMODE_WRITE)
+		vfs_dq_init(inode);
+
 	spin_lock(&oi->ip_lock);
 
 	/* Check that the inode hasn't been wiped from disk by another
@@ -976,6 +979,9 @@ int ocfs2_setattr(struct dentry *dentry,
 	if (status)
 		return status;
 
+	if (attr->ia_valid & ATTR_SIZE)
+		vfs_dq_init(inode);
+
 	size_change = S_ISREG(inode->i_mode) && attr->ia_valid & ATTR_SIZE;
 	if (size_change) {
 		status = ocfs2_rw_lock(inode, 1);
Index: linux-2.6/fs/open.c
===================================================================
--- linux-2.6.orig/fs/open.c	2010-02-20 11:40:48.619003522 +0100
+++ linux-2.6/fs/open.c	2010-02-20 12:00:45.664005758 +0100
@@ -8,7 +8,6 @@
 #include <linux/mm.h>
 #include <linux/file.h>
 #include <linux/fdtable.h>
-#include <linux/quotaops.h>
 #include <linux/fsnotify.h>
 #include <linux/module.h>
 #include <linux/slab.h>
@@ -278,10 +277,8 @@ static long do_sys_truncate(const char _
 	error = locks_verify_truncate(inode, NULL, length);
 	if (!error)
 		error = security_path_truncate(&path, length, 0);
-	if (!error) {
-		vfs_dq_init(inode);
+	if (!error)
 		error = do_truncate(path.dentry, length, 0, NULL);
-	}
 
 put_write_and_out:
 	put_write_access(inode);
Index: linux-2.6/fs/jfs/file.c
===================================================================
--- linux-2.6.orig/fs/jfs/file.c	2010-02-20 11:55:53.857256072 +0100
+++ linux-2.6/fs/jfs/file.c	2010-02-20 12:00:45.672027269 +0100
@@ -48,7 +48,7 @@ static int jfs_open(struct inode *inode,
 {
 	int rc;
 
-	if ((rc = generic_file_open(inode, file)))
+	if ((rc = dquot_file_open(inode, file)))
 		return rc;
 
 	/*
@@ -98,6 +98,8 @@ int jfs_setattr(struct dentry *dentry, s
 	if (rc)
 		return rc;
 
+	if (iattr->ia_valid & ATTR_SIZE)
+		vfs_dq_init(inode);
 	if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
 	    (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
 		rc = dquot_transfer(inode, iattr);
Index: linux-2.6/fs/ext2/file.c
===================================================================
--- linux-2.6.orig/fs/ext2/file.c	2010-02-20 11:40:48.399254325 +0100
+++ linux-2.6/fs/ext2/file.c	2010-02-20 12:00:45.675031669 +0100
@@ -70,7 +70,7 @@ const struct file_operations ext2_file_o
 	.compat_ioctl	= ext2_compat_ioctl,
 #endif
 	.mmap		= generic_file_mmap,
-	.open		= generic_file_open,
+	.open		= dquot_file_open,
 	.release	= ext2_release_file,
 	.fsync		= ext2_fsync,
 	.splice_read	= generic_file_splice_read,
@@ -87,7 +87,7 @@ const struct file_operations ext2_xip_fi
 	.compat_ioctl	= ext2_compat_ioctl,
 #endif
 	.mmap		= xip_file_mmap,
-	.open		= generic_file_open,
+	.open		= dquot_file_open,
 	.release	= ext2_release_file,
 	.fsync		= ext2_fsync,
 };
Index: linux-2.6/fs/ext3/file.c
===================================================================
--- linux-2.6.orig/fs/ext3/file.c	2010-02-20 11:40:48.431254674 +0100
+++ linux-2.6/fs/ext3/file.c	2010-02-20 12:00:45.679005408 +0100
@@ -62,7 +62,7 @@ const struct file_operations ext3_file_o
 	.compat_ioctl	= ext3_compat_ioctl,
 #endif
 	.mmap		= generic_file_mmap,
-	.open		= generic_file_open,
+	.open		= dquot_file_open,
 	.release	= ext3_release_file,
 	.fsync		= ext3_sync_file,
 	.splice_read	= generic_file_splice_read,
Index: linux-2.6/fs/ext4/file.c
===================================================================
--- linux-2.6.orig/fs/ext4/file.c	2010-02-20 11:40:48.461254604 +0100
+++ linux-2.6/fs/ext4/file.c	2010-02-20 12:00:45.682007294 +0100
@@ -127,7 +127,7 @@ static int ext4_file_open(struct inode *
 			sb->s_dirt = 1;
 		}
 	}
-	return generic_file_open(inode, filp);
+	return dquot_file_open(inode, filp);
 }
 
 const struct file_operations ext4_file_operations = {
Index: linux-2.6/fs/quota/dquot.c
===================================================================
--- linux-2.6.orig/fs/quota/dquot.c	2010-02-20 11:59:10.787005967 +0100
+++ linux-2.6/fs/quota/dquot.c	2010-02-20 12:00:45.687005339 +0100
@@ -1821,6 +1821,20 @@ const struct dquot_operations dquot_oper
 };
 
 /*
+ * Generic helper for ->open on filesystems supporting disk quotas.
+ */
+int dquot_file_open(struct inode *inode, struct file *file)
+{
+	int error;
+
+	error = generic_file_open(inode, file);
+	if (!error && (file->f_mode & FMODE_WRITE))
+		vfs_dq_init(inode);
+	return error;
+}
+EXPORT_SYMBOL(dquot_file_open);
+
+/*
  * Turn quota off on a device. type == -1 ==> quotaoff for all types (umount)
  */
 int vfs_quota_disable(struct super_block *sb, int type, unsigned int flags)
Index: linux-2.6/fs/reiserfs/file.c
===================================================================
--- linux-2.6.orig/fs/reiserfs/file.c	2010-02-20 11:40:48.561275487 +0100
+++ linux-2.6/fs/reiserfs/file.c	2010-02-20 12:00:45.697024196 +0100
@@ -289,7 +289,7 @@ const struct file_operations reiserfs_fi
 	.compat_ioctl = reiserfs_compat_ioctl,
 #endif
 	.mmap = reiserfs_file_mmap,
-	.open = generic_file_open,
+	.open = dquot_file_open,
 	.release = reiserfs_file_release,
 	.fsync = reiserfs_sync_file,
 	.aio_read = generic_file_aio_read,
Index: linux-2.6/fs/ufs/file.c
===================================================================
--- linux-2.6.orig/fs/ufs/file.c	2010-02-20 11:40:48.590259424 +0100
+++ linux-2.6/fs/ufs/file.c	2010-02-20 12:00:45.699274231 +0100
@@ -40,7 +40,7 @@ const struct file_operations ufs_file_op
 	.write		= do_sync_write,
 	.aio_write	= generic_file_aio_write,
 	.mmap		= generic_file_mmap,
-	.open           = generic_file_open,
+	.open           = dquot_file_open,
 	.fsync		= simple_fsync,
 	.splice_read	= generic_file_splice_read,
 };
Index: linux-2.6/include/linux/quotaops.h
===================================================================
--- linux-2.6.orig/include/linux/quotaops.h	2010-02-20 11:59:10.821253697 +0100
+++ linux-2.6/include/linux/quotaops.h	2010-02-20 12:00:45.701253558 +0100
@@ -23,7 +23,7 @@ void inode_add_rsv_space(struct inode *i
 void inode_claim_rsv_space(struct inode *inode, qsize_t number);
 void inode_sub_rsv_space(struct inode *inode, qsize_t number);
 
-int dquot_initialize(struct inode *inode, int type);
+void dquot_initialize(struct inode *inode);
 void dquot_drop(struct inode *inode);
 struct dquot *dqget(struct super_block *sb, unsigned int id, int type);
 void dqput(struct dquot *dquot);
@@ -48,6 +48,8 @@ int dquot_release(struct dquot *dquot);
 int dquot_commit_info(struct super_block *sb, int type);
 int dquot_mark_dquot_dirty(struct dquot *dquot);
 
+int dquot_file_open(struct inode *inode, struct file *file);
+
 int vfs_quota_on(struct super_block *sb, int type, int format_id,
  	char *path, int remount);
 int vfs_quota_enable(struct inode *inode, int type, int format_id,
@@ -137,15 +139,6 @@ extern const struct quotactl_ops vfs_quo
 #define sb_dquot_ops (&dquot_operations)
 #define sb_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 vfs_dq_init(struct inode *inode)
-{
-	BUG_ON(!inode->i_sb);
-	if (sb_any_quota_active(inode->i_sb) && !IS_NOQUOTA(inode))
-		inode->i_sb->dq_op->initialize(inode, -1);
-}
-
 /* Cannot be called inside a transaction */
 static inline int vfs_dq_off(struct super_block *sb, int remount)
 {
@@ -205,7 +198,7 @@ static inline int sb_any_quota_active(st
 #define sb_dquot_ops				(NULL)
 #define sb_quotactl_ops				(NULL)
 
-static inline void vfs_dq_init(struct inode *inode)
+static inline void dquot_initialize(struct inode *inode)
 {
 }
 
@@ -342,4 +335,6 @@ static inline void dquot_release_reserva
 	__dquot_free_space(inode, nr << inode->i_blkbits, 1);
 }
 
+#define dquot_file_open		generic_file_open
+
 #endif /* _LINUX_QUOTAOPS_ */


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

* [PATCH 8/8] dquot: cleanup dquot initialize routine
  2010-02-20 11:51 [PATCH 0/8] dquot interface cleanups Christoph Hellwig
                   ` (6 preceding siblings ...)
  2010-02-20 11:51 ` [PATCH 7/8] dquot: move dquot initialization responsibiliy into the filesystem Christoph Hellwig
@ 2010-02-20 11:51 ` Christoph Hellwig
  7 siblings, 0 replies; 26+ messages in thread
From: Christoph Hellwig @ 2010-02-20 11:51 UTC (permalink / raw)
  To: jack; +Cc: linux-fsdevel

[-- Attachment #1: quota-kill-initialize --]
[-- Type: text/plain, Size: 38653 bytes --]

Get rid of the initialize dquot operation - it is now always called from
the filesystem and if a filesystem really needs it's own (which none
currently does) it can just call into it's own routine directly.

Rename the now static low-level dquot_initialize helper to __dquot_initialize
and vfs_dq_init to dquot_initialize to have a consistent namespace.

Signed-off-by: Christoph Hellwig <hch@lst.de>

Index: linux-2.6/Documentation/filesystems/Locking
===================================================================
--- linux-2.6.orig/Documentation/filesystems/Locking	2010-02-20 11:59:10.826282123 +0100
+++ linux-2.6/Documentation/filesystems/Locking	2010-02-20 12:04:17.076004291 +0100
@@ -460,7 +460,6 @@ in sys_read() and friends.
 
 --------------------------- dquot_operations -------------------------------
 prototypes:
-	int (*initialize) (struct inode *, int);
 	int (*write_dquot) (struct dquot *);
 	int (*acquire_dquot) (struct dquot *);
 	int (*release_dquot) (struct dquot *);
@@ -473,7 +472,6 @@ a proper locking wrt the filesystem and 
 What filesystem should expect from the generic quota functions:
 
 		FS recursion	Held locks when called
-initialize:	yes		maybe dqonoff_sem
 write_dquot:	yes		dqonoff_sem or dqptr_sem
 acquire_dquot:	yes		dqonoff_sem or dqptr_sem
 release_dquot:	yes		dqonoff_sem or dqptr_sem
Index: linux-2.6/fs/ext2/ialloc.c
===================================================================
--- linux-2.6.orig/fs/ext2/ialloc.c	2010-02-20 11:59:10.751275697 +0100
+++ linux-2.6/fs/ext2/ialloc.c	2010-02-20 12:04:17.077004431 +0100
@@ -586,7 +586,7 @@ got:
 		goto fail_drop;
 	}
 
-	vfs_dq_init(inode);
+	dquot_initialize(inode);
 	if (dquot_alloc_inode(inode)) {
 		err = -EDQUOT;
 		goto fail_drop;
Index: linux-2.6/fs/ext2/inode.c
===================================================================
--- linux-2.6.orig/fs/ext2/inode.c	2010-02-20 12:00:45.486253976 +0100
+++ linux-2.6/fs/ext2/inode.c	2010-02-20 12:04:17.083004640 +0100
@@ -59,7 +59,7 @@ static inline int ext2_inode_is_fast_sym
 void ext2_delete_inode (struct inode * inode)
 {
 	if (!is_bad_inode(inode))
-		vfs_dq_init(inode);
+		dquot_initialize(inode);
 	truncate_inode_pages(&inode->i_data, 0);
 
 	if (is_bad_inode(inode))
@@ -1461,7 +1461,7 @@ int ext2_setattr(struct dentry *dentry, 
 		return error;
 
 	if (iattr->ia_valid & ATTR_SIZE)
-		vfs_dq_init(inode);
+		dquot_initialize(inode);
 	if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
 	    (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
 		error = dquot_transfer(inode, iattr);
Index: linux-2.6/fs/ext3/ialloc.c
===================================================================
--- linux-2.6.orig/fs/ext3/ialloc.c	2010-02-20 11:59:10.755255373 +0100
+++ linux-2.6/fs/ext3/ialloc.c	2010-02-20 12:04:17.097261729 +0100
@@ -123,7 +123,7 @@ void ext3_free_inode (handle_t *handle, 
 	 * Note: we must free any quota before locking the superblock,
 	 * as writing the quota to disk may need the lock as well.
 	 */
-	vfs_dq_init(inode);
+	dquot_initialize(inode);
 	ext3_xattr_delete_inode(handle, inode);
 	dquot_free_inode(inode);
 	dquot_drop(inode);
@@ -588,7 +588,7 @@ got:
 		sizeof(struct ext3_inode) - EXT3_GOOD_OLD_INODE_SIZE : 0;
 
 	ret = inode;
-	vfs_dq_init(inode);
+	dquot_initialize(inode);
 	if (dquot_alloc_inode(inode)) {
 		err = -EDQUOT;
 		goto fail_drop;
Index: linux-2.6/fs/ext3/inode.c
===================================================================
--- linux-2.6.orig/fs/ext3/inode.c	2010-02-20 12:00:45.488257957 +0100
+++ linux-2.6/fs/ext3/inode.c	2010-02-20 12:04:17.104177430 +0100
@@ -197,7 +197,7 @@ void ext3_delete_inode (struct inode * i
 	handle_t *handle;
 
 	if (!is_bad_inode(inode))
-		vfs_dq_init(inode);
+		dquot_initialize(inode);
 
 	truncate_inode_pages(&inode->i_data, 0);
 
@@ -3144,7 +3144,7 @@ int ext3_setattr(struct dentry *dentry, 
 		return error;
 
 	if (ia_valid & ATTR_SIZE)
-		vfs_dq_init(inode);
+		dquot_initialize(inode);
 	if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
 		(ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
 		handle_t *handle;
@@ -3242,7 +3242,7 @@ static int ext3_writepage_trans_blocks(s
 		ret = 2 * (bpp + indirects) + 2;
 
 #ifdef CONFIG_QUOTA
-	/* We know that structure was already allocated during vfs_dq_init so
+	/* We know that structure was already allocated during dquot_initialize so
 	 * we will be updating only the data blocks + inodes */
 	ret += EXT3_MAXQUOTAS_TRANS_BLOCKS(inode->i_sb);
 #endif
Index: linux-2.6/fs/ext3/namei.c
===================================================================
--- linux-2.6.orig/fs/ext3/namei.c	2010-02-20 12:00:45.584007015 +0100
+++ linux-2.6/fs/ext3/namei.c	2010-02-20 12:04:17.113255723 +0100
@@ -1696,7 +1696,7 @@ static int ext3_create (struct inode * d
 	struct inode * inode;
 	int err, retries = 0;
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 retry:
 	handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
@@ -1732,7 +1732,7 @@ static int ext3_mknod (struct inode * di
 	if (!new_valid_dev(rdev))
 		return -EINVAL;
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 retry:
 	handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
@@ -1770,7 +1770,7 @@ static int ext3_mkdir(struct inode * dir
 	if (dir->i_nlink >= EXT3_LINK_MAX)
 		return -EMLINK;
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 retry:
 	handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
@@ -2066,8 +2066,8 @@ static int ext3_rmdir (struct inode * di
 
 	/* Initialize quotas before so that eventual writes go in
 	 * separate transaction */
-	vfs_dq_init(dir);
-	vfs_dq_init(dentry->d_inode);
+	dquot_initialize(dir);
+	dquot_initialize(dentry->d_inode);
 
 	handle = ext3_journal_start(dir, EXT3_DELETE_TRANS_BLOCKS(dir->i_sb));
 	if (IS_ERR(handle))
@@ -2127,8 +2127,8 @@ static int ext3_unlink(struct inode * di
 
 	/* Initialize quotas before so that eventual writes go
 	 * in separate transaction */
-	vfs_dq_init(dir);
-	vfs_dq_init(dentry->d_inode);
+	dquot_initialize(dir);
+	dquot_initialize(dentry->d_inode);
 
 	handle = ext3_journal_start(dir, EXT3_DELETE_TRANS_BLOCKS(dir->i_sb));
 	if (IS_ERR(handle))
@@ -2184,7 +2184,7 @@ static int ext3_symlink (struct inode * 
 	if (l > dir->i_sb->s_blocksize)
 		return -ENAMETOOLONG;
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 retry:
 	handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
@@ -2241,7 +2241,7 @@ static int ext3_link (struct dentry * ol
 	if (inode->i_nlink >= EXT3_LINK_MAX)
 		return -EMLINK;
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 	/*
 	 * Return -ENOENT if we've raced with unlink and i_nlink is 0.  Doing
@@ -2293,15 +2293,15 @@ static int ext3_rename (struct inode * o
 	struct ext3_dir_entry_2 * old_de, * new_de;
 	int retval, flush_file = 0;
 
-	vfs_dq_init(old_dir);
-	vfs_dq_init(new_dir);
+	dquot_initialize(old_dir);
+	dquot_initialize(new_dir);
 
 	old_bh = new_bh = dir_bh = NULL;
 
 	/* Initialize quotas before so that eventual writes go
 	 * in separate transaction */
 	if (new_dentry->d_inode)
-		vfs_dq_init(new_dentry->d_inode);
+		dquot_initialize(new_dentry->d_inode);
 	handle = ext3_journal_start(old_dir, 2 *
 					EXT3_DATA_TRANS_BLOCKS(old_dir->i_sb) +
 					EXT3_INDEX_EXTRA_TRANS_BLOCKS + 2);
Index: linux-2.6/fs/ext3/super.c
===================================================================
--- linux-2.6.orig/fs/ext3/super.c	2010-02-20 11:59:10.736253977 +0100
+++ linux-2.6/fs/ext3/super.c	2010-02-20 12:04:17.120255792 +0100
@@ -752,7 +752,6 @@ static ssize_t ext3_quota_write(struct s
 				const char *data, size_t len, loff_t off);
 
 static const struct dquot_operations ext3_quota_operations = {
-	.initialize	= dquot_initialize,
 	.write_dquot	= ext3_write_dquot,
 	.acquire_dquot	= ext3_acquire_dquot,
 	.release_dquot	= ext3_release_dquot,
@@ -1480,7 +1479,7 @@ static void ext3_orphan_cleanup (struct 
 		}
 
 		list_add(&EXT3_I(inode)->i_orphan, &EXT3_SB(sb)->s_orphan);
-		vfs_dq_init(inode);
+		dquot_initialize(inode);
 		if (inode->i_nlink) {
 			printk(KERN_DEBUG
 				"%s: truncating inode %lu to %Ld bytes\n",
@@ -2736,7 +2735,7 @@ static int ext3_statfs (struct dentry * 
  * Process 1                         Process 2
  * ext3_create()                     quota_sync()
  *   journal_start()                   write_dquot()
- *   vfs_dq_init()                       down(dqio_mutex)
+ *   dquot_initialize()                       down(dqio_mutex)
  *     down(dqio_mutex)                    journal_start()
  *
  */
Index: linux-2.6/fs/ext4/ialloc.c
===================================================================
--- linux-2.6.orig/fs/ext4/ialloc.c	2010-02-20 11:59:10.764254954 +0100
+++ linux-2.6/fs/ext4/ialloc.c	2010-02-20 12:04:17.131257259 +0100
@@ -217,7 +217,7 @@ void ext4_free_inode(handle_t *handle, s
 	 * Note: we must free any quota before locking the superblock,
 	 * as writing the quota to disk may need the lock as well.
 	 */
-	vfs_dq_init(inode);
+	dquot_initialize(inode);
 	ext4_xattr_delete_inode(handle, inode);
 	dquot_free_inode(inode);
 	dquot_drop(inode);
@@ -1034,7 +1034,7 @@ got:
 	ei->i_extra_isize = EXT4_SB(sb)->s_want_extra_isize;
 
 	ret = inode;
-	vfs_dq_init(inode);
+	dquot_initialize(inode);
 	if (dquot_alloc_inode(inode)) {
 		err = -EDQUOT;
 		goto fail_drop;
Index: linux-2.6/fs/ext4/inode.c
===================================================================
--- linux-2.6.orig/fs/ext4/inode.c	2010-02-20 12:00:45.505255373 +0100
+++ linux-2.6/fs/ext4/inode.c	2010-02-20 12:04:17.147255024 +0100
@@ -171,7 +171,7 @@ void ext4_delete_inode(struct inode *ino
 	int err;
 
 	if (!is_bad_inode(inode))
-		vfs_dq_init(inode);
+		dquot_initialize(inode);
 
 	if (ext4_should_order_data(inode))
 		ext4_begin_ordered_truncate(inode, 0);
@@ -5253,7 +5253,7 @@ int ext4_setattr(struct dentry *dentry, 
 		return error;
 
 	if (ia_valid & ATTR_SIZE)
-		vfs_dq_init(inode);
+		dquot_initialize(inode);
 	if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
 		(ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
 		handle_t *handle;
Index: linux-2.6/fs/ext4/namei.c
===================================================================
--- linux-2.6.orig/fs/ext4/namei.c	2010-02-20 12:00:45.602005827 +0100
+++ linux-2.6/fs/ext4/namei.c	2010-02-20 12:04:17.182254466 +0100
@@ -1766,7 +1766,7 @@ static int ext4_create(struct inode *dir
 	struct inode *inode;
 	int err, retries = 0;
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 retry:
 	handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
@@ -1802,7 +1802,7 @@ static int ext4_mknod(struct inode *dir,
 	if (!new_valid_dev(rdev))
 		return -EINVAL;
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 retry:
 	handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
@@ -1841,7 +1841,7 @@ static int ext4_mkdir(struct inode *dir,
 	if (EXT4_DIR_LINK_MAX(dir))
 		return -EMLINK;
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 retry:
 	handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
@@ -2142,8 +2142,8 @@ static int ext4_rmdir(struct inode *dir,
 
 	/* Initialize quotas before so that eventual writes go in
 	 * separate transaction */
-	vfs_dq_init(dir);
-	vfs_dq_init(dentry->d_inode);
+	dquot_initialize(dir);
+	dquot_initialize(dentry->d_inode);
 
 	handle = ext4_journal_start(dir, EXT4_DELETE_TRANS_BLOCKS(dir->i_sb));
 	if (IS_ERR(handle))
@@ -2203,8 +2203,8 @@ static int ext4_unlink(struct inode *dir
 
 	/* Initialize quotas before so that eventual writes go
 	 * in separate transaction */
-	vfs_dq_init(dir);
-	vfs_dq_init(dentry->d_inode);
+	dquot_initialize(dir);
+	dquot_initialize(dentry->d_inode);
 
 	handle = ext4_journal_start(dir, EXT4_DELETE_TRANS_BLOCKS(dir->i_sb));
 	if (IS_ERR(handle))
@@ -2260,7 +2260,7 @@ static int ext4_symlink(struct inode *di
 	if (l > dir->i_sb->s_blocksize)
 		return -ENAMETOOLONG;
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 retry:
 	handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
@@ -2320,7 +2320,7 @@ static int ext4_link(struct dentry *old_
 	if (inode->i_nlink >= EXT4_LINK_MAX)
 		return -EMLINK;
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 	/*
 	 * Return -ENOENT if we've raced with unlink and i_nlink is 0.  Doing
@@ -2372,15 +2372,15 @@ static int ext4_rename(struct inode *old
 	struct ext4_dir_entry_2 *old_de, *new_de;
 	int retval, force_da_alloc = 0;
 
-	vfs_dq_init(old_dir);
-	vfs_dq_init(new_dir);
+	dquot_initialize(old_dir);
+	dquot_initialize(new_dir);
 
 	old_bh = new_bh = dir_bh = NULL;
 
 	/* Initialize quotas before so that eventual writes go
 	 * in separate transaction */
 	if (new_dentry->d_inode)
-		vfs_dq_init(new_dentry->d_inode);
+		dquot_initialize(new_dentry->d_inode);
 	handle = ext4_journal_start(old_dir, 2 *
 					EXT4_DATA_TRANS_BLOCKS(old_dir->i_sb) +
 					EXT4_INDEX_EXTRA_TRANS_BLOCKS + 2);
Index: linux-2.6/fs/ext4/super.c
===================================================================
--- linux-2.6.orig/fs/ext4/super.c	2010-02-20 11:59:10.738253837 +0100
+++ linux-2.6/fs/ext4/super.c	2010-02-20 12:04:17.201255373 +0100
@@ -1013,7 +1013,6 @@ static ssize_t ext4_quota_write(struct s
 				const char *data, size_t len, loff_t off);
 
 static const struct dquot_operations ext4_quota_operations = {
-	.initialize	= dquot_initialize,
 #ifdef CONFIG_QUOTA
 	.get_reserved_space = ext4_get_reserved_space,
 #endif
@@ -1931,7 +1930,7 @@ static void ext4_orphan_cleanup(struct s
 		}
 
 		list_add(&EXT4_I(inode)->i_orphan, &EXT4_SB(sb)->s_orphan);
-		vfs_dq_init(inode);
+		dquot_initialize(inode);
 		if (inode->i_nlink) {
 			ext4_msg(sb, KERN_DEBUG,
 				"%s: truncating inode %lu to %lld bytes",
@@ -3700,7 +3699,7 @@ static int ext4_statfs(struct dentry *de
  * Process 1                         Process 2
  * ext4_create()                     quota_sync()
  *   jbd2_journal_start()                  write_dquot()
- *   vfs_dq_init()                         down(dqio_mutex)
+ *   dquot_initialize()                         down(dqio_mutex)
  *     down(dqio_mutex)                    jbd2_journal_start()
  *
  */
Index: linux-2.6/fs/jfs/inode.c
===================================================================
--- linux-2.6.orig/fs/jfs/inode.c	2010-02-20 12:00:45.545255374 +0100
+++ linux-2.6/fs/jfs/inode.c	2010-02-20 12:04:17.209005478 +0100
@@ -147,7 +147,7 @@ void jfs_delete_inode(struct inode *inod
 	jfs_info("In jfs_delete_inode, inode = 0x%p", inode);
 
 	if (!is_bad_inode(inode))
-		vfs_dq_init(inode);
+		dquot_initialize(inode);
 
 	if (!is_bad_inode(inode) &&
 	    (JFS_IP(inode)->fileset == FILESYSTEM_I)) {
@@ -161,7 +161,7 @@ void jfs_delete_inode(struct inode *inod
 		/*
 		 * Free the inode from the quota allocation.
 		 */
-		vfs_dq_init(inode);
+		dquot_initialize(inode);
 		dquot_free_inode(inode);
 		dquot_drop(inode);
 	}
Index: linux-2.6/fs/jfs/jfs_inode.c
===================================================================
--- linux-2.6.orig/fs/jfs/jfs_inode.c	2010-02-20 11:59:10.780255583 +0100
+++ linux-2.6/fs/jfs/jfs_inode.c	2010-02-20 12:04:17.212005897 +0100
@@ -116,7 +116,7 @@ struct inode *ialloc(struct inode *paren
 	/*
 	 * Allocate inode to quota.
 	 */
-	vfs_dq_init(inode);
+	dquot_initialize(inode);
 	if (dquot_alloc_inode(inode)) {
 		rc = -EDQUOT;
 		goto fail_drop;
Index: linux-2.6/fs/jfs/namei.c
===================================================================
--- linux-2.6.orig/fs/jfs/namei.c	2010-02-20 12:00:45.617005478 +0100
+++ linux-2.6/fs/jfs/namei.c	2010-02-20 12:04:17.215285056 +0100
@@ -85,7 +85,7 @@ static int jfs_create(struct inode *dip,
 
 	jfs_info("jfs_create: dip:0x%p name:%s", dip, dentry->d_name.name);
 
-	vfs_dq_init(dip);
+	dquot_initialize(dip);
 
 	/*
 	 * search parent directory for entry/freespace
@@ -217,7 +217,7 @@ static int jfs_mkdir(struct inode *dip, 
 
 	jfs_info("jfs_mkdir: dip:0x%p name:%s", dip, dentry->d_name.name);
 
-	vfs_dq_init(dip);
+	dquot_initialize(dip);
 
 	/* link count overflow on parent directory ? */
 	if (dip->i_nlink == JFS_LINK_MAX) {
@@ -360,8 +360,8 @@ static int jfs_rmdir(struct inode *dip, 
 	jfs_info("jfs_rmdir: dip:0x%p name:%s", dip, dentry->d_name.name);
 
 	/* Init inode for quota operations. */
-	vfs_dq_init(dip);
-	vfs_dq_init(ip);
+	dquot_initialize(dip);
+	dquot_initialize(ip);
 
 	/* directory must be empty to be removed */
 	if (!dtEmpty(ip)) {
@@ -488,8 +488,8 @@ static int jfs_unlink(struct inode *dip,
 	jfs_info("jfs_unlink: dip:0x%p name:%s", dip, dentry->d_name.name);
 
 	/* Init inode for quota operations. */
-	vfs_dq_init(dip);
-	vfs_dq_init(ip);
+	dquot_initialize(dip);
+	dquot_initialize(ip);
 
 	if ((rc = get_UCSname(&dname, dentry)))
 		goto out;
@@ -811,7 +811,7 @@ static int jfs_link(struct dentry *old_d
 	if (ip->i_nlink == 0)
 		return -ENOENT;
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 	tid = txBegin(ip->i_sb, 0);
 
@@ -904,7 +904,7 @@ static int jfs_symlink(struct inode *dip
 
 	jfs_info("jfs_symlink: dip:0x%p name:%s", dip, name);
 
-	vfs_dq_init(dip);
+	dquot_initialize(dip);
 
 	ssize = strlen(name) + 1;
 
@@ -1097,8 +1097,8 @@ static int jfs_rename(struct inode *old_
 	jfs_info("jfs_rename: %s %s", old_dentry->d_name.name,
 		 new_dentry->d_name.name);
 
-	vfs_dq_init(old_dir);
-	vfs_dq_init(new_dir);
+	dquot_initialize(old_dir);
+	dquot_initialize(new_dir);
 
 	old_ip = old_dentry->d_inode;
 	new_ip = new_dentry->d_inode;
@@ -1149,7 +1149,7 @@ static int jfs_rename(struct inode *old_
 	} else if (new_ip) {
 		IWRITE_LOCK(new_ip, RDWRLOCK_NORMAL);
 		/* Init inode for quota operations. */
-		vfs_dq_init(new_ip);
+		dquot_initialize(new_ip);
 	}
 
 	/*
@@ -1373,7 +1373,7 @@ static int jfs_mknod(struct inode *dir, 
 
 	jfs_info("jfs_mknod: %s", dentry->d_name.name);
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 	if ((rc = get_UCSname(&dname, dentry)))
 		goto out;
Index: linux-2.6/fs/ocfs2/inode.c
===================================================================
--- linux-2.6.orig/fs/ocfs2/inode.c	2010-02-20 12:00:45.548255793 +0100
+++ linux-2.6/fs/ocfs2/inode.c	2010-02-20 12:04:17.220257329 +0100
@@ -971,7 +971,7 @@ void ocfs2_delete_inode(struct inode *in
 		goto bail;
 	}
 
-	vfs_dq_init(inode);
+	dquot_initialize(inode);
 
 	if (!ocfs2_inode_is_valid_to_delete(inode)) {
 		/* It's probably not necessary to truncate_inode_pages
Index: linux-2.6/fs/ocfs2/namei.c
===================================================================
--- linux-2.6.orig/fs/ocfs2/namei.c	2010-02-20 12:00:45.625285195 +0100
+++ linux-2.6/fs/ocfs2/namei.c	2010-02-20 12:04:17.224281983 +0100
@@ -212,7 +212,7 @@ static struct inode *ocfs2_get_init_inod
 	} else
 		inode->i_gid = current_fsgid();
 	inode->i_mode = mode;
-	vfs_dq_init(inode);
+	dquot_initialize(inode);
 	return inode;
 }
 
@@ -244,7 +244,7 @@ static int ocfs2_mknod(struct inode *dir
 		   (unsigned long)dev, dentry->d_name.len,
 		   dentry->d_name.name);
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 	/* get our super block */
 	osb = OCFS2_SB(dir->i_sb);
@@ -635,7 +635,7 @@ static int ocfs2_link(struct dentry *old
 	if (S_ISDIR(inode->i_mode))
 		return -EPERM;
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 	err = ocfs2_inode_lock_nested(dir, &parent_fe_bh, 1, OI_LS_PARENT);
 	if (err < 0) {
@@ -792,7 +792,7 @@ static int ocfs2_unlink(struct inode *di
 	mlog_entry("(0x%p, 0x%p, '%.*s')\n", dir, dentry,
 		   dentry->d_name.len, dentry->d_name.name);
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 	BUG_ON(dentry->d_parent->d_inode != dir);
 
@@ -1054,8 +1054,8 @@ static int ocfs2_rename(struct inode *ol
 		   old_dentry->d_name.len, old_dentry->d_name.name,
 		   new_dentry->d_name.len, new_dentry->d_name.name);
 
-	vfs_dq_init(old_dir);
-	vfs_dq_init(new_dir);
+	dquot_initialize(old_dir);
+	dquot_initialize(new_dir);
 
 	osb = OCFS2_SB(old_dir->i_sb);
 
@@ -1605,7 +1605,7 @@ static int ocfs2_symlink(struct inode *d
 	mlog_entry("(0x%p, 0x%p, symname='%s' actual='%.*s')\n", dir,
 		   dentry, symname, dentry->d_name.len, dentry->d_name.name);
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 	sb = dir->i_sb;
 	osb = OCFS2_SB(sb);
Index: linux-2.6/fs/ocfs2/quota_global.c
===================================================================
--- linux-2.6.orig/fs/ocfs2/quota_global.c	2010-02-20 11:59:10.823282332 +0100
+++ linux-2.6/fs/ocfs2/quota_global.c	2010-02-20 12:04:17.235255094 +0100
@@ -851,7 +851,6 @@ static void ocfs2_destroy_dquot(struct d
 }
 
 const struct dquot_operations ocfs2_quota_operations = {
-	.initialize	= dquot_initialize,
 	.write_dquot	= ocfs2_write_dquot,
 	.acquire_dquot	= ocfs2_acquire_dquot,
 	.release_dquot	= ocfs2_release_dquot,
Index: linux-2.6/fs/ocfs2/refcounttree.c
===================================================================
--- linux-2.6.orig/fs/ocfs2/refcounttree.c	2010-02-20 11:40:47.758025663 +0100
+++ linux-2.6/fs/ocfs2/refcounttree.c	2010-02-20 12:04:17.247255512 +0100
@@ -4390,7 +4390,7 @@ static int ocfs2_vfs_reflink(struct dent
 	}
 
 	mutex_lock(&inode->i_mutex);
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 	error = ocfs2_reflink(old_dentry, dir, new_dentry, preserve);
 	mutex_unlock(&inode->i_mutex);
 	if (!error)
Index: linux-2.6/fs/quota/dquot.c
===================================================================
--- linux-2.6.orig/fs/quota/dquot.c	2010-02-20 12:00:45.687005339 +0100
+++ linux-2.6/fs/quota/dquot.c	2010-02-20 12:04:17.274255304 +0100
@@ -230,6 +230,7 @@ struct dqstats dqstats;
 EXPORT_SYMBOL(dqstats);
 
 static qsize_t inode_get_rsv_space(struct inode *inode);
+static void __dquot_initialize(struct inode *inode, int type);
 
 static inline unsigned int
 hashfn(const struct super_block *sb, unsigned int id, int type)
@@ -890,7 +891,7 @@ static void add_dquot_ref(struct super_b
 		spin_unlock(&inode_lock);
 
 		iput(old_inode);
-		sb->dq_op->initialize(inode, type);
+		__dquot_initialize(inode, type);
 		/* We hold a reference to 'inode' so it couldn't have been
 		 * removed from s_inodes list while we dropped the inode_lock.
 		 * We cannot iput the inode now as we can be holding the last
@@ -1293,22 +1294,26 @@ static int info_bdq_free(struct dquot *d
 }
 
 /*
- *	Initialize quota pointers in inode
- *	We do things in a bit complicated way but by that we avoid calling
- *	dqget() and thus filesystem callbacks under dqptr_sem.
+ * Initialize quota pointers in inode
+ *
+ * We do things in a bit complicated way but by that we avoid calling
+ * dqget() and thus filesystem callbacks under dqptr_sem.
+ *
+ * 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.
  */
-int dquot_initialize(struct inode *inode, int type)
+static void __dquot_initialize(struct inode *inode, int type)
 {
 	unsigned int id = 0;
-	int cnt, ret = 0;
+	int cnt;
 	struct dquot *got[MAXQUOTAS];
 	struct super_block *sb = inode->i_sb;
 	qsize_t rsv;
 
 	/* First test before acquiring mutex - solves deadlocks when we
          * re-enter the quota code and are already holding the mutex */
-	if (IS_NOQUOTA(inode))
-		return 0;
+	if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode))
+		return;
 
 	/* First get references to structures we might need. */
 	for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
@@ -1351,7 +1356,11 @@ out_err:
 	up_write(&sb_dqopt(sb)->dqptr_sem);
 	/* Drop unused references */
 	dqput_all(got);
-	return ret;
+}
+
+void dquot_initialize(struct inode *inode)
+{
+	__dquot_initialize(inode, -1);
 }
 EXPORT_SYMBOL(dquot_initialize);
 
@@ -1783,7 +1792,7 @@ int dquot_transfer(struct inode *inode, 
 		chid[GRPQUOTA] = iattr->ia_gid;
 	}
 	if (sb_any_quota_active(inode->i_sb) && !IS_NOQUOTA(inode)) {
-		vfs_dq_init(inode);
+		dquot_initialize(inode);
 		if (__dquot_transfer(inode, chid, mask) == NO_QUOTA)
 			return -EDQUOT;
 	}
@@ -1810,7 +1819,6 @@ EXPORT_SYMBOL(dquot_commit_info);
  * Definitions of diskquota operations.
  */
 const struct dquot_operations dquot_operations = {
-	.initialize	= dquot_initialize,
 	.write_dquot	= dquot_commit,
 	.acquire_dquot	= dquot_acquire,
 	.release_dquot	= dquot_release,
@@ -1829,7 +1837,7 @@ int dquot_file_open(struct inode *inode,
 
 	error = generic_file_open(inode, file);
 	if (!error && (file->f_mode & FMODE_WRITE))
-		vfs_dq_init(inode);
+		dquot_initialize(inode);
 	return error;
 }
 EXPORT_SYMBOL(dquot_file_open);
Index: linux-2.6/fs/reiserfs/inode.c
===================================================================
--- linux-2.6.orig/fs/reiserfs/inode.c	2010-02-20 12:00:45.554256073 +0100
+++ linux-2.6/fs/reiserfs/inode.c	2010-02-20 12:04:17.290256002 +0100
@@ -35,7 +35,7 @@ void reiserfs_delete_inode(struct inode 
 	int err;
 
 	if (!is_bad_inode(inode))
-		vfs_dq_init(inode);
+		dquot_initialize(inode);
 
 	truncate_inode_pages(&inode->i_data, 0);
 
@@ -1768,7 +1768,7 @@ int reiserfs_new_inode(struct reiserfs_t
 
 	BUG_ON(!th->t_trans_id);
 
-	vfs_dq_init(inode);
+	dquot_initialize(inode);
 	if (dquot_alloc_inode(inode)) {
 		err = -EDQUOT;
 		goto out_end_trans;
@@ -3077,7 +3077,7 @@ int reiserfs_setattr(struct dentry *dent
 
 	depth = reiserfs_write_lock_once(inode->i_sb);
 	if (ia_valid & ATTR_SIZE)
-		vfs_dq_init(inode);
+		dquot_initialize(inode);
 	if (attr->ia_valid & ATTR_SIZE) {
 		/* version 2 items will be caught by the s_maxbytes check
 		 ** done for us in vmtruncate
Index: linux-2.6/fs/reiserfs/namei.c
===================================================================
--- linux-2.6.orig/fs/reiserfs/namei.c	2010-02-20 12:00:45.631256001 +0100
+++ linux-2.6/fs/reiserfs/namei.c	2010-02-20 12:04:17.302255234 +0100
@@ -554,7 +554,7 @@ static int drop_new_inode(struct inode *
 }
 
 /* utility function that does setup for reiserfs_new_inode.
-** vfs_dq_init needs lots of credits so it's better to have it
+** dquot_initialize needs lots of credits so it's better to have it
 ** outside of a transaction, so we had to pull some bits of
 ** reiserfs_new_inode out into this func.
 */
@@ -577,7 +577,7 @@ static int new_inode_init(struct inode *
 	} else {
 		inode->i_gid = current_fsgid();
 	}
-	vfs_dq_init(inode);
+	dquot_initialize(inode);
 	return 0;
 }
 
@@ -594,7 +594,7 @@ static int reiserfs_create(struct inode 
 	struct reiserfs_transaction_handle th;
 	struct reiserfs_security_handle security;
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 	if (!(inode = new_inode(dir->i_sb))) {
 		return -ENOMEM;
@@ -668,7 +668,7 @@ static int reiserfs_mknod(struct inode *
 	if (!new_valid_dev(rdev))
 		return -EINVAL;
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 	if (!(inode = new_inode(dir->i_sb))) {
 		return -ENOMEM;
@@ -743,7 +743,7 @@ static int reiserfs_mkdir(struct inode *
 	    2 * (REISERFS_QUOTA_INIT_BLOCKS(dir->i_sb) +
 		 REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb));
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 #ifdef DISPLACE_NEW_PACKING_LOCALITIES
 	/* set flag that new packing locality created and new blocks for the content     * of that directory are not displaced yet */
@@ -848,7 +848,7 @@ static int reiserfs_rmdir(struct inode *
 	    JOURNAL_PER_BALANCE_CNT * 2 + 2 +
 	    4 * REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb);
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 	reiserfs_write_lock(dir->i_sb);
 	retval = journal_begin(&th, dir->i_sb, jbegin_count);
@@ -931,7 +931,7 @@ static int reiserfs_unlink(struct inode 
 	unsigned long savelink;
 	int depth;
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 	inode = dentry->d_inode;
 
@@ -1034,7 +1034,7 @@ static int reiserfs_symlink(struct inode
 	    2 * (REISERFS_QUOTA_INIT_BLOCKS(parent_dir->i_sb) +
 		 REISERFS_QUOTA_TRANS_BLOCKS(parent_dir->i_sb));
 
-	vfs_dq_init(parent_dir);
+	dquot_initialize(parent_dir);
 
 	if (!(inode = new_inode(parent_dir->i_sb))) {
 		return -ENOMEM;
@@ -1123,7 +1123,7 @@ static int reiserfs_link(struct dentry *
 	    JOURNAL_PER_BALANCE_CNT * 3 +
 	    2 * REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb);
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 	reiserfs_write_lock(dir->i_sb);
 	if (inode->i_nlink >= REISERFS_LINK_MAX) {
@@ -1249,8 +1249,8 @@ static int reiserfs_rename(struct inode 
 	    JOURNAL_PER_BALANCE_CNT * 3 + 5 +
 	    4 * REISERFS_QUOTA_TRANS_BLOCKS(old_dir->i_sb);
 
-	vfs_dq_init(old_dir);
-	vfs_dq_init(new_dir);
+	dquot_initialize(old_dir);
+	dquot_initialize(new_dir);
 
 	old_inode = old_dentry->d_inode;
 	new_dentry_inode = new_dentry->d_inode;
Index: linux-2.6/fs/reiserfs/super.c
===================================================================
--- linux-2.6.orig/fs/reiserfs/super.c	2010-02-20 11:59:10.746276675 +0100
+++ linux-2.6/fs/reiserfs/super.c	2010-02-20 12:04:17.307283729 +0100
@@ -246,7 +246,7 @@ static int finish_unfinished(struct supe
 			retval = remove_save_link_only(s, &save_link_key, 0);
 			continue;
 		}
-		vfs_dq_init(inode);
+		dquot_initialize(inode);
 
 		if (truncate && S_ISDIR(inode->i_mode)) {
 			/* We got a truncate request for a dir which is impossible.
@@ -622,7 +622,6 @@ static int reiserfs_write_info(struct su
 static int reiserfs_quota_on(struct super_block *, int, int, char *, int);
 
 static const struct dquot_operations reiserfs_quota_operations = {
-	.initialize = dquot_initialize,
 	.write_dquot = reiserfs_write_dquot,
 	.acquire_dquot = reiserfs_acquire_dquot,
 	.release_dquot = reiserfs_release_dquot,
Index: linux-2.6/fs/udf/ialloc.c
===================================================================
--- linux-2.6.orig/fs/udf/ialloc.c	2010-02-20 11:59:10.818035510 +0100
+++ linux-2.6/fs/udf/ialloc.c	2010-02-20 12:04:17.312280167 +0100
@@ -153,7 +153,7 @@ struct inode *udf_new_inode(struct inode
 	insert_inode_hash(inode);
 	mark_inode_dirty(inode);
 
-	vfs_dq_init(inode);
+	dquot_initialize(inode);
 	if (dquot_alloc_inode(inode)) {
 		dquot_drop(inode);
 		inode->i_flags |= S_NOQUOTA;
Index: linux-2.6/fs/ufs/ialloc.c
===================================================================
--- linux-2.6.orig/fs/ufs/ialloc.c	2010-02-20 11:59:10.819293437 +0100
+++ linux-2.6/fs/ufs/ialloc.c	2010-02-20 12:04:17.314255653 +0100
@@ -355,7 +355,7 @@ cg_found:
 
 	unlock_super (sb);
 
-	vfs_dq_init(inode);
+	dquot_initialize(inode);
 	if (dquot_alloc_inode(inode)) {
 		dquot_drop(inode);
 		err = -EDQUOT;
Index: linux-2.6/fs/ufs/inode.c
===================================================================
--- linux-2.6.orig/fs/ufs/inode.c	2010-02-20 12:00:45.560257050 +0100
+++ linux-2.6/fs/ufs/inode.c	2010-02-20 12:04:17.317260053 +0100
@@ -910,7 +910,7 @@ void ufs_delete_inode (struct inode * in
 	loff_t old_i_size;
 
 	if (!is_bad_inode(inode))
-		vfs_dq_init(inode);
+		dquot_initialize(inode);
 
 	truncate_inode_pages(&inode->i_data, 0);
 	if (is_bad_inode(inode))
Index: linux-2.6/include/linux/quota.h
===================================================================
--- linux-2.6.orig/include/linux/quota.h	2010-02-20 11:59:10.833269202 +0100
+++ linux-2.6/include/linux/quota.h	2010-02-20 12:04:17.321005059 +0100
@@ -295,7 +295,6 @@ struct quota_format_ops {
 
 /* Operations working with dquots */
 struct dquot_operations {
-	int (*initialize) (struct inode *, int);
 	int (*write_dquot) (struct dquot *);		/* Ordinary dquot write */
 	struct dquot *(*alloc_dquot)(struct super_block *, int);	/* Allocate memory for new dquot */
 	void (*destroy_dquot)(struct dquot *);		/* Free memory for dquot */
Index: linux-2.6/include/linux/quotaops.h
===================================================================
--- linux-2.6.orig/include/linux/quotaops.h	2010-02-20 12:00:45.701253558 +0100
+++ linux-2.6/include/linux/quotaops.h	2010-02-20 12:04:17.323004850 +0100
@@ -251,6 +251,8 @@ static inline int dquot_claim_space_nodi
 	return 0;
 }
 
+#define dquot_file_open		generic_file_open
+
 #endif /* CONFIG_QUOTA */
 
 static inline int dquot_alloc_space_nodirty(struct inode *inode, qsize_t nr)
@@ -335,6 +337,4 @@ static inline void dquot_release_reserva
 	__dquot_free_space(inode, nr << inode->i_blkbits, 1);
 }
 
-#define dquot_file_open		generic_file_open
-
 #endif /* _LINUX_QUOTAOPS_ */
Index: linux-2.6/fs/ext2/namei.c
===================================================================
--- linux-2.6.orig/fs/ext2/namei.c	2010-02-20 12:00:45.577006037 +0100
+++ linux-2.6/fs/ext2/namei.c	2010-02-20 12:04:17.327005897 +0100
@@ -102,7 +102,7 @@ static int ext2_create (struct inode * d
 {
 	struct inode *inode;
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 	inode = ext2_new_inode(dir, mode);
 	if (IS_ERR(inode))
@@ -131,7 +131,7 @@ static int ext2_mknod (struct inode * di
 	if (!new_valid_dev(rdev))
 		return -EINVAL;
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 	inode = ext2_new_inode (dir, mode);
 	err = PTR_ERR(inode);
@@ -157,7 +157,7 @@ static int ext2_symlink (struct inode * 
 	if (l > sb->s_blocksize)
 		goto out;
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 	inode = ext2_new_inode (dir, S_IFLNK | S_IRWXUGO);
 	err = PTR_ERR(inode);
@@ -202,7 +202,7 @@ static int ext2_link (struct dentry * ol
 	if (inode->i_nlink >= EXT2_LINK_MAX)
 		return -EMLINK;
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 	inode->i_ctime = CURRENT_TIME_SEC;
 	inode_inc_link_count(inode);
@@ -226,7 +226,7 @@ static int ext2_mkdir(struct inode * dir
 	if (dir->i_nlink >= EXT2_LINK_MAX)
 		goto out;
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 	inode_inc_link_count(dir);
 
@@ -274,7 +274,7 @@ static int ext2_unlink(struct inode * di
 	struct page * page;
 	int err = -ENOENT;
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 	de = ext2_find_entry (dir, &dentry->d_name, &page);
 	if (!de)
@@ -318,8 +318,8 @@ static int ext2_rename (struct inode * o
 	struct ext2_dir_entry_2 * old_de;
 	int err = -ENOENT;
 
-	vfs_dq_init(old_dir);
-	vfs_dq_init(new_dir);
+	dquot_initialize(old_dir);
+	dquot_initialize(new_dir);
 
 	old_de = ext2_find_entry (old_dir, &old_dentry->d_name, &old_page);
 	if (!old_de)
Index: linux-2.6/fs/jfs/file.c
===================================================================
--- linux-2.6.orig/fs/jfs/file.c	2010-02-20 12:00:45.672027269 +0100
+++ linux-2.6/fs/jfs/file.c	2010-02-20 12:04:17.332255653 +0100
@@ -99,7 +99,7 @@ int jfs_setattr(struct dentry *dentry, s
 		return rc;
 
 	if (iattr->ia_valid & ATTR_SIZE)
-		vfs_dq_init(inode);
+		dquot_initialize(inode);
 	if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
 	    (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
 		rc = dquot_transfer(inode, iattr);
Index: linux-2.6/fs/ocfs2/file.c
===================================================================
--- linux-2.6.orig/fs/ocfs2/file.c	2010-02-20 12:00:45.648255722 +0100
+++ linux-2.6/fs/ocfs2/file.c	2010-02-20 12:04:17.337268643 +0100
@@ -108,7 +108,7 @@ static int ocfs2_file_open(struct inode 
 		   file->f_path.dentry->d_name.len, file->f_path.dentry->d_name.name);
 
 	if (file->f_mode & FMODE_WRITE)
-		vfs_dq_init(inode);
+		dquot_initialize(inode);
 
 	spin_lock(&oi->ip_lock);
 
@@ -980,7 +980,7 @@ int ocfs2_setattr(struct dentry *dentry,
 		return status;
 
 	if (attr->ia_valid & ATTR_SIZE)
-		vfs_dq_init(inode);
+		dquot_initialize(inode);
 
 	size_change = S_ISREG(inode->i_mode) && attr->ia_valid & ATTR_SIZE;
 	if (size_change) {
Index: linux-2.6/fs/ufs/namei.c
===================================================================
--- linux-2.6.orig/fs/ufs/namei.c	2010-02-20 12:00:45.638255862 +0100
+++ linux-2.6/fs/ufs/namei.c	2010-02-20 12:04:17.353254675 +0100
@@ -86,7 +86,7 @@ static int ufs_create (struct inode * di
 
 	UFSD("BEGIN\n");
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 	inode = ufs_new_inode(dir, mode);
 	err = PTR_ERR(inode);
@@ -112,7 +112,7 @@ static int ufs_mknod (struct inode * dir
 	if (!old_valid_dev(rdev))
 		return -EINVAL;
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 	inode = ufs_new_inode(dir, mode);
 	err = PTR_ERR(inode);
@@ -138,7 +138,7 @@ static int ufs_symlink (struct inode * d
 	if (l > sb->s_blocksize)
 		goto out_notlocked;
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 	lock_kernel();
 	inode = ufs_new_inode(dir, S_IFLNK | S_IRWXUGO);
@@ -185,7 +185,7 @@ static int ufs_link (struct dentry * old
 		return -EMLINK;
 	}
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 	inode->i_ctime = CURRENT_TIME_SEC;
 	inode_inc_link_count(inode);
@@ -204,7 +204,7 @@ static int ufs_mkdir(struct inode * dir,
 	if (dir->i_nlink >= UFS_LINK_MAX)
 		goto out;
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 	lock_kernel();
 	inode_inc_link_count(dir);
@@ -250,7 +250,7 @@ static int ufs_unlink(struct inode *dir,
 	struct page *page;
 	int err = -ENOENT;
 
-	vfs_dq_init(dir);
+	dquot_initialize(dir);
 
 	de = ufs_find_entry(dir, &dentry->d_name, &page);
 	if (!de)
@@ -296,8 +296,8 @@ static int ufs_rename(struct inode *old_
 	struct ufs_dir_entry *old_de;
 	int err = -ENOENT;
 
-	vfs_dq_init(old_dir);
-	vfs_dq_init(new_dir);
+	dquot_initialize(old_dir);
+	dquot_initialize(new_dir);
 
 	old_de = ufs_find_entry(old_dir, &old_dentry->d_name, &old_page);
 	if (!old_de)
Index: linux-2.6/fs/ext2/file.c
===================================================================
--- linux-2.6.orig/fs/ext2/file.c	2010-02-20 12:00:45.675031669 +0100
+++ linux-2.6/fs/ext2/file.c	2010-02-20 12:04:17.357255234 +0100
@@ -20,6 +20,7 @@
 
 #include <linux/time.h>
 #include <linux/pagemap.h>
+#include <linux/quotaops.h>
 #include "ext2.h"
 #include "xattr.h"
 #include "acl.h"
Index: linux-2.6/fs/ext3/file.c
===================================================================
--- linux-2.6.orig/fs/ext3/file.c	2010-02-20 12:00:45.679005408 +0100
+++ linux-2.6/fs/ext3/file.c	2010-02-20 12:04:17.360281844 +0100
@@ -21,6 +21,7 @@
 #include <linux/time.h>
 #include <linux/fs.h>
 #include <linux/jbd.h>
+#include <linux/quotaops.h>
 #include <linux/ext3_fs.h>
 #include <linux/ext3_jbd.h>
 #include "xattr.h"
Index: linux-2.6/fs/ext4/file.c
===================================================================
--- linux-2.6.orig/fs/ext4/file.c	2010-02-20 12:00:45.682007294 +0100
+++ linux-2.6/fs/ext4/file.c	2010-02-20 12:04:17.363282472 +0100
@@ -23,6 +23,7 @@
 #include <linux/jbd2.h>
 #include <linux/mount.h>
 #include <linux/path.h>
+#include <linux/quotaops.h>
 #include "ext4.h"
 #include "ext4_jbd2.h"
 #include "xattr.h"
Index: linux-2.6/fs/ufs/file.c
===================================================================
--- linux-2.6.orig/fs/ufs/file.c	2010-02-20 12:00:45.699274231 +0100
+++ linux-2.6/fs/ufs/file.c	2010-02-20 12:04:17.366284079 +0100
@@ -24,6 +24,7 @@
  */
 
 #include <linux/fs.h>
+#include <linux/quotaops.h>
 
 #include "ufs_fs.h"
 #include "ufs.h"


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

* Re: [PATCH 1/8] dquot: cleanup space allocation / freeing routines
  2010-02-20 11:51 ` [PATCH 1/8] dquot: cleanup space allocation / freeing routines Christoph Hellwig
@ 2010-02-24 22:09   ` Jan Kara
  0 siblings, 0 replies; 26+ messages in thread
From: Jan Kara @ 2010-02-24 22:09 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: jack, linux-fsdevel

On Sat 20-02-10 06:51:02, Christoph Hellwig wrote:
> Get rid of the alloc_space, free_space, reserve_space, claim_space and
> release_rsv dquot operations - they are always called from the filesystem
> and if a filesystem really needs their own (which none currently does)
> it can just call into it's own routine directly.
> 
> Move shared logic into the common __dquot_alloc_space,
> dquot_claim_space_nodirty and __dquot_free_space low-level methods,
> and rationalize the wrappers around it to move as much as possible
> code into the common block for CONFIG_QUOTA vs not.  Also rename
> all these helpers to be named dquot_* instead of vfs_dq_*.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
  Looks fine. I've just fixed up compilation failure in case CONFIG_QUOTA
was disabled and inverted numbers passed as 'warn' argument because they
were historically the other way around than the name of the argument
suggests.

								Honza

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

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

* Re: [PATCH 2/8] dquot: cleanup inode allocation / freeing routines
  2010-02-20 11:51 ` [PATCH 2/8] dquot: cleanup inode " Christoph Hellwig
@ 2010-02-24 22:39   ` Jan Kara
  0 siblings, 0 replies; 26+ messages in thread
From: Jan Kara @ 2010-02-24 22:39 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: jack, linux-fsdevel

On Sat 20-02-10 06:51:03, Christoph Hellwig wrote:
> Get rid of the alloc_inode and free_inode dquot operations - they are
> always called from the filesystem and if a filesystem really needs
> their own (which none currently does) it can just call into it's
> own routine directly.
> 
> Also get rid of the vfs_dq_alloc/vfs_dq_free wrappers and always
> call the lowlevel dquot_alloc_inode / dqout_free_inode routines
> directly, which now lose the number argument which is always 1.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
  Looks good. Merged.

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

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

* Re: [PATCH 3/8] dquot: move dquot transfer responsibiliy into the filesystem
  2010-02-20 11:51 ` [PATCH 3/8] dquot: move dquot transfer responsibiliy into the filesystem Christoph Hellwig
@ 2010-02-24 23:06   ` Jan Kara
  0 siblings, 0 replies; 26+ messages in thread
From: Jan Kara @ 2010-02-24 23:06 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: jack, linux-fsdevel

On Sat 20-02-10 06:51:04, Christoph Hellwig wrote:
> Currently notify_change calls vfs_dq_transfer directly.  This means
> we tie the quota code into the VFS.  Get rid of that and make the
> filesystem responsibly for the transfer.  Most filesystems already
> do this, only ufs needs the code added, and for jfs it needs to be
> enabled unconditionally instead of only when ACLs are enabled.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
  Looks good. Merged.

								Honza

> Index: linux-2.6/fs/attr.c
> ===================================================================
> --- linux-2.6.orig/fs/attr.c	2010-02-19 11:45:24.904272974 +0100
> +++ linux-2.6/fs/attr.c	2010-02-19 11:45:43.050005619 +0100
> @@ -12,7 +12,6 @@
>  #include <linux/capability.h>
>  #include <linux/fsnotify.h>
>  #include <linux/fcntl.h>
> -#include <linux/quotaops.h>
>  #include <linux/security.h>
>  
>  /* Taken over from the old code... */
> @@ -212,14 +211,8 @@ int notify_change(struct dentry * dentry
>  		error = inode->i_op->setattr(dentry, attr);
>  	} else {
>  		error = inode_change_ok(inode, attr);
> -		if (!error) {
> -			if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
> -			    (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
> -				error = vfs_dq_transfer(inode, attr) ?
> -					-EDQUOT : 0;
> -			if (!error)
> -				error = inode_setattr(inode, attr);
> -		}
> +		if (!error)
> +			error = inode_setattr(inode, attr);
>  	}
>  
>  	if (ia_valid & ATTR_SIZE)
> Index: linux-2.6/fs/ufs/truncate.c
> ===================================================================
> --- linux-2.6.orig/fs/ufs/truncate.c	2010-02-19 11:45:24.913004221 +0100
> +++ linux-2.6/fs/ufs/truncate.c	2010-02-19 15:08:15.042023986 +0100
> @@ -44,6 +44,7 @@
>  #include <linux/buffer_head.h>
>  #include <linux/blkdev.h>
>  #include <linux/sched.h>
> +#include <linux/quotaops.h>
>  
>  #include "ufs_fs.h"
>  #include "ufs.h"
> @@ -517,6 +518,12 @@ static int ufs_setattr(struct dentry *de
>  	if (error)
>  		return error;
>  
> +	if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
> +	    (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
> +		error = vfs_dq_transfer(inode, attr) ? -EDQUOT : 0;
> +		if (error)
> +			return error;
> +	}
>  	if (ia_valid & ATTR_SIZE &&
>  	    attr->ia_size != i_size_read(inode)) {
>  		loff_t old_i_size = inode->i_size;
> Index: linux-2.6/fs/jfs/acl.c
> ===================================================================
> --- linux-2.6.orig/fs/jfs/acl.c	2010-02-19 11:45:24.919010367 +0100
> +++ linux-2.6/fs/jfs/acl.c	2010-02-19 11:45:32.078271367 +0100
> @@ -20,7 +20,6 @@
>  
>  #include <linux/sched.h>
>  #include <linux/fs.h>
> -#include <linux/quotaops.h>
>  #include <linux/posix_acl_xattr.h>
>  #include "jfs_incore.h"
>  #include "jfs_txnmgr.h"
> @@ -174,7 +173,7 @@ cleanup:
>  	return rc;
>  }
>  
> -static int jfs_acl_chmod(struct inode *inode)
> +int jfs_acl_chmod(struct inode *inode)
>  {
>  	struct posix_acl *acl, *clone;
>  	int rc;
> @@ -205,26 +204,3 @@ static int jfs_acl_chmod(struct inode *i
>  	posix_acl_release(clone);
>  	return rc;
>  }
> -
> -int jfs_setattr(struct dentry *dentry, struct iattr *iattr)
> -{
> -	struct inode *inode = dentry->d_inode;
> -	int rc;
> -
> -	rc = inode_change_ok(inode, iattr);
> -	if (rc)
> -		return rc;
> -
> -	if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
> -	    (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
> -		if (vfs_dq_transfer(inode, iattr))
> -			return -EDQUOT;
> -	}
> -
> -	rc = inode_setattr(inode, iattr);
> -
> -	if (!rc && (iattr->ia_valid & ATTR_MODE))
> -		rc = jfs_acl_chmod(inode);
> -
> -	return rc;
> -}
> Index: linux-2.6/fs/jfs/file.c
> ===================================================================
> --- linux-2.6.orig/fs/jfs/file.c	2010-02-19 11:45:24.929004081 +0100
> +++ linux-2.6/fs/jfs/file.c	2010-02-19 15:08:02.655004431 +0100
> @@ -18,6 +18,7 @@
>   */
>  
>  #include <linux/fs.h>
> +#include <linux/quotaops.h>
>  #include "jfs_incore.h"
>  #include "jfs_inode.h"
>  #include "jfs_dmap.h"
> @@ -88,14 +89,37 @@ static int jfs_release(struct inode *ino
>  	return 0;
>  }
>  
> +int jfs_setattr(struct dentry *dentry, struct iattr *iattr)
> +{
> +	struct inode *inode = dentry->d_inode;
> +	int rc;
> +
> +	rc = inode_change_ok(inode, iattr);
> +	if (rc)
> +		return rc;
> +
> +	if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
> +	    (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
> +		if (vfs_dq_transfer(inode, iattr))
> +			return -EDQUOT;
> +	}
> +
> +	rc = inode_setattr(inode, iattr);
> +
> +	if (!rc && (iattr->ia_valid & ATTR_MODE))
> +		rc = jfs_acl_chmod(inode);
> +
> +	return rc;
> +}
> +
>  const struct inode_operations jfs_file_inode_operations = {
>  	.truncate	= jfs_truncate,
>  	.setxattr	= jfs_setxattr,
>  	.getxattr	= jfs_getxattr,
>  	.listxattr	= jfs_listxattr,
>  	.removexattr	= jfs_removexattr,
> -#ifdef CONFIG_JFS_POSIX_ACL
>  	.setattr	= jfs_setattr,
> +#ifdef CONFIG_JFS_POSIX_ACL
>  	.check_acl	= jfs_check_acl,
>  #endif
>  };
> Index: linux-2.6/fs/jfs/jfs_acl.h
> ===================================================================
> --- linux-2.6.orig/fs/jfs/jfs_acl.h	2010-02-19 11:45:24.936025523 +0100
> +++ linux-2.6/fs/jfs/jfs_acl.h	2010-02-19 11:45:32.085271437 +0100
> @@ -22,7 +22,7 @@
>  
>  int jfs_check_acl(struct inode *, int);
>  int jfs_init_acl(tid_t, struct inode *, struct inode *);
> -int jfs_setattr(struct dentry *, struct iattr *);
> +int jfs_acl_chmod(struct inode *inode);
>  
>  #else
>  
> @@ -32,5 +32,10 @@ static inline int jfs_init_acl(tid_t tid
>  	return 0;
>  }
>  
> +static inline int jfs_acl_chmod(struct inode *inode)
> +{
> +	return 0;
> +}
> +
>  #endif
>  #endif		/* _H_JFS_ACL */
> Index: linux-2.6/fs/jfs/jfs_inode.h
> ===================================================================
> --- linux-2.6.orig/fs/jfs/jfs_inode.h	2010-02-19 11:45:24.944024894 +0100
> +++ linux-2.6/fs/jfs/jfs_inode.h	2010-02-19 11:45:32.090281355 +0100
> @@ -40,6 +40,7 @@ extern struct dentry *jfs_fh_to_parent(s
>  	int fh_len, int fh_type);
>  extern void jfs_set_inode_flags(struct inode *);
>  extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
> +extern int jfs_setattr(struct dentry *, struct iattr *);
>  
>  extern const struct address_space_operations jfs_aops;
>  extern const struct inode_operations jfs_dir_inode_operations;
> Index: linux-2.6/fs/jfs/namei.c
> ===================================================================
> --- linux-2.6.orig/fs/jfs/namei.c	2010-02-19 11:45:24.955254046 +0100
> +++ linux-2.6/fs/jfs/namei.c	2010-02-19 14:53:30.838004431 +0100
> @@ -1541,8 +1541,8 @@ const struct inode_operations jfs_dir_in
>  	.getxattr	= jfs_getxattr,
>  	.listxattr	= jfs_listxattr,
>  	.removexattr	= jfs_removexattr,
> -#ifdef CONFIG_JFS_POSIX_ACL
>  	.setattr	= jfs_setattr,
> +#ifdef CONFIG_JFS_POSIX_ACL
>  	.check_acl	= jfs_check_acl,
>  #endif
>  };
> 
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

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

* Re: [PATCH 4/8] dquot: cleanup dquot transfer routine
  2010-02-20 11:51 ` [PATCH 4/8] dquot: cleanup dquot transfer routine Christoph Hellwig
@ 2010-02-24 23:14   ` Jan Kara
  2010-03-01  9:50     ` Christoph Hellwig
  0 siblings, 1 reply; 26+ messages in thread
From: Jan Kara @ 2010-02-24 23:14 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: jack, linux-fsdevel

On Sat 20-02-10 06:51:05, Christoph Hellwig wrote:
> Get rid of the transfer dquot operation - it is now always called from
> the filesystem and if a filesystem really needs it's own (which none
> currently does) it can just call into it's own routine directly.
> 
> Rename the now static low-level dquot_transfer helper to __dquot_transfer
> and vfs_dq_transfer to dquot_transfer to have a consistent namespace,
> and make the new dquot_transfer return a normal negative errno value
> which all callers expect.
  Looks good. I just wonder - if you made dquot_transfer() return error
code, shouldn't also dquot_alloc_inode, dquot_alloc_space and similar
return error code instead of 1? It would seem more consistent.
  Hmm, I guess I'll just go and modify your patches to do it.

								Honza

> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> 
> Index: linux-2.6/Documentation/filesystems/Locking
> ===================================================================
> --- linux-2.6.orig/Documentation/filesystems/Locking	2010-02-20 11:48:48.624253837 +0100
> +++ linux-2.6/Documentation/filesystems/Locking	2010-02-20 11:55:53.694023148 +0100
> @@ -462,7 +462,6 @@ in sys_read() and friends.
>  prototypes:
>  	int (*initialize) (struct inode *, int);
>  	int (*drop) (struct inode *);
> -	int (*transfer) (struct inode *, struct iattr *);
>  	int (*write_dquot) (struct dquot *);
>  	int (*acquire_dquot) (struct dquot *);
>  	int (*release_dquot) (struct dquot *);
> @@ -477,7 +476,6 @@ What filesystem should expect from the g
>  		FS recursion	Held locks when called
>  initialize:	yes		maybe dqonoff_sem
>  drop:		yes		-
> -transfer:	yes		-
>  write_dquot:	yes		dqonoff_sem or dqptr_sem
>  acquire_dquot:	yes		dqonoff_sem or dqptr_sem
>  release_dquot:	yes		dqonoff_sem or dqptr_sem
> Index: linux-2.6/fs/ext3/super.c
> ===================================================================
> --- linux-2.6.orig/fs/ext3/super.c	2010-02-20 11:48:48.626253697 +0100
> +++ linux-2.6/fs/ext3/super.c	2010-02-20 11:55:53.695023428 +0100
> @@ -752,7 +752,6 @@ static ssize_t ext3_quota_write(struct s
>  static const struct dquot_operations ext3_quota_operations = {
>  	.initialize	= dquot_initialize,
>  	.drop		= dquot_drop,
> -	.transfer	= dquot_transfer,
>  	.write_dquot	= ext3_write_dquot,
>  	.acquire_dquot	= ext3_acquire_dquot,
>  	.release_dquot	= ext3_release_dquot,
> Index: linux-2.6/fs/ext4/super.c
> ===================================================================
> --- linux-2.6.orig/fs/ext4/super.c	2010-02-20 11:48:48.633253627 +0100
> +++ linux-2.6/fs/ext4/super.c	2010-02-20 11:55:53.706254954 +0100
> @@ -1017,7 +1017,6 @@ static const struct dquot_operations ext
>  #ifdef CONFIG_QUOTA
>  	.get_reserved_space = ext4_get_reserved_space,
>  #endif
> -	.transfer	= dquot_transfer,
>  	.write_dquot	= ext4_write_dquot,
>  	.acquire_dquot	= ext4_acquire_dquot,
>  	.release_dquot	= ext4_release_dquot,
> Index: linux-2.6/fs/ocfs2/quota_global.c
> ===================================================================
> --- linux-2.6.orig/fs/ocfs2/quota_global.c	2010-02-20 11:48:48.666256212 +0100
> +++ linux-2.6/fs/ocfs2/quota_global.c	2010-02-20 11:55:53.733255653 +0100
> @@ -853,7 +853,6 @@ static void ocfs2_destroy_dquot(struct d
>  const struct dquot_operations ocfs2_quota_operations = {
>  	.initialize	= dquot_initialize,
>  	.drop		= dquot_drop,
> -	.transfer	= dquot_transfer,
>  	.write_dquot	= ocfs2_write_dquot,
>  	.acquire_dquot	= ocfs2_acquire_dquot,
>  	.release_dquot	= ocfs2_release_dquot,
> Index: linux-2.6/fs/quota/dquot.c
> ===================================================================
> --- linux-2.6.orig/fs/quota/dquot.c	2010-02-20 11:50:33.509255304 +0100
> +++ linux-2.6/fs/quota/dquot.c	2010-02-20 11:55:53.742255234 +0100
> @@ -1669,7 +1669,7 @@ EXPORT_SYMBOL(dquot_free_inode);
>   * This operation can block, but only after everything is updated
>   * A transaction must be started when entering this function.
>   */
> -int dquot_transfer(struct inode *inode, qid_t *chid, unsigned long mask)
> +static int __dquot_transfer(struct inode *inode, qid_t *chid, unsigned long mask)
>  {
>  	qsize_t space, cur_space;
>  	qsize_t rsv_space = 0;
> @@ -1766,12 +1766,11 @@ over_quota:
>  	ret = NO_QUOTA;
>  	goto warn_put_all;
>  }
> -EXPORT_SYMBOL(dquot_transfer);
>  
>  /* Wrapper for transferring ownership of an inode for uid/gid only
>   * Called from FSXXX_setattr()
>   */
> -int vfs_dq_transfer(struct inode *inode, struct iattr *iattr)
> +int dquot_transfer(struct inode *inode, struct iattr *iattr)
>  {
>  	qid_t chid[MAXQUOTAS];
>  	unsigned long mask = 0;
> @@ -1786,12 +1785,12 @@ int vfs_dq_transfer(struct inode *inode,
>  	}
>  	if (sb_any_quota_active(inode->i_sb) && !IS_NOQUOTA(inode)) {
>  		vfs_dq_init(inode);
> -		if (inode->i_sb->dq_op->transfer(inode, chid, mask) == NO_QUOTA)
> -			return 1;
> +		if (__dquot_transfer(inode, chid, mask) == NO_QUOTA)
> +			return -EDQUOT;
>  	}
>  	return 0;
>  }
> -EXPORT_SYMBOL(vfs_dq_transfer);
> +EXPORT_SYMBOL(dquot_transfer);
>  
>  /*
>   * Write info of quota file to disk
> @@ -1814,7 +1813,6 @@ EXPORT_SYMBOL(dquot_commit_info);
>  const struct dquot_operations dquot_operations = {
>  	.initialize	= dquot_initialize,
>  	.drop		= dquot_drop,
> -	.transfer	= dquot_transfer,
>  	.write_dquot	= dquot_commit,
>  	.acquire_dquot	= dquot_acquire,
>  	.release_dquot	= dquot_release,
> Index: linux-2.6/fs/reiserfs/super.c
> ===================================================================
> --- linux-2.6.orig/fs/reiserfs/super.c	2010-02-20 11:48:48.691005897 +0100
> +++ linux-2.6/fs/reiserfs/super.c	2010-02-20 11:55:53.756256212 +0100
> @@ -618,7 +618,6 @@ static int reiserfs_quota_on(struct supe
>  static const struct dquot_operations reiserfs_quota_operations = {
>  	.initialize = dquot_initialize,
>  	.drop = dquot_drop,
> -	.transfer = dquot_transfer,
>  	.write_dquot = reiserfs_write_dquot,
>  	.acquire_dquot = reiserfs_acquire_dquot,
>  	.release_dquot = reiserfs_release_dquot,
> Index: linux-2.6/include/linux/quota.h
> ===================================================================
> --- linux-2.6.orig/include/linux/quota.h	2010-02-20 11:48:48.696005828 +0100
> +++ linux-2.6/include/linux/quota.h	2010-02-20 11:55:53.761255862 +0100
> @@ -297,7 +297,6 @@ struct quota_format_ops {
>  struct dquot_operations {
>  	int (*initialize) (struct inode *, int);
>  	int (*drop) (struct inode *);
> -	int (*transfer) (struct inode *, qid_t *, unsigned long);
>  	int (*write_dquot) (struct dquot *);		/* Ordinary dquot write */
>  	struct dquot *(*alloc_dquot)(struct super_block *, int);	/* Allocate memory for new dquot */
>  	void (*destroy_dquot)(struct dquot *);		/* Free memory for dquot */
> Index: linux-2.6/include/linux/quotaops.h
> ===================================================================
> --- linux-2.6.orig/include/linux/quotaops.h	2010-02-20 11:48:48.698006456 +0100
> +++ linux-2.6/include/linux/quotaops.h	2010-02-20 11:55:53.763255583 +0100
> @@ -42,7 +42,6 @@ int dquot_alloc_inode(const struct inode
>  int dquot_claim_space_nodirty(struct inode *inode, qsize_t number);
>  void dquot_free_inode(const struct inode *inode);
>  
> -int dquot_transfer(struct inode *inode, qid_t *chid, unsigned long mask);
>  int dquot_commit(struct dquot *dquot);
>  int dquot_acquire(struct dquot *dquot);
>  int dquot_release(struct dquot *dquot);
> @@ -66,7 +65,7 @@ int vfs_get_dqblk(struct super_block *sb
>  int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di);
>  
>  void vfs_dq_drop(struct inode *inode);
> -int vfs_dq_transfer(struct inode *inode, struct iattr *iattr);
> +int dquot_transfer(struct inode *inode, struct iattr *iattr);
>  int vfs_dq_quota_on_remount(struct super_block *sb);
>  
>  static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type)
> @@ -234,7 +233,7 @@ static inline int vfs_dq_quota_on_remoun
>  	return 0;
>  }
>  
> -static inline int vfs_dq_transfer(struct inode *inode, struct iattr *iattr)
> +static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
>  {
>  	return 0;
>  }
> Index: linux-2.6/drivers/staging/pohmelfs/inode.c
> ===================================================================
> --- linux-2.6.orig/drivers/staging/pohmelfs/inode.c	2010-02-20 11:40:49.947004081 +0100
> +++ linux-2.6/drivers/staging/pohmelfs/inode.c	2010-02-20 11:55:53.767255443 +0100
> @@ -969,7 +969,7 @@ int pohmelfs_setattr_raw(struct inode *i
>  
>  	if ((attr->ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
>  	    (attr->ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
> -		err = vfs_dq_transfer(inode, attr) ? -EDQUOT : 0;
> +		err = dquot_transfer(inode, attr);
>  		if (err)
>  			goto err_out_exit;
>  	}
> Index: linux-2.6/fs/ext2/inode.c
> ===================================================================
> --- linux-2.6.orig/fs/ext2/inode.c	2010-02-20 11:40:49.886253766 +0100
> +++ linux-2.6/fs/ext2/inode.c	2010-02-20 11:55:53.772255862 +0100
> @@ -1459,7 +1459,7 @@ int ext2_setattr(struct dentry *dentry, 
>  		return error;
>  	if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
>  	    (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
> -		error = vfs_dq_transfer(inode, iattr) ? -EDQUOT : 0;
> +		error = dquot_transfer(inode, iattr);
>  		if (error)
>  			return error;
>  	}
> Index: linux-2.6/fs/ext3/inode.c
> ===================================================================
> --- linux-2.6.orig/fs/ext3/inode.c	2010-02-20 11:46:29.838255793 +0100
> +++ linux-2.6/fs/ext3/inode.c	2010-02-20 11:55:53.781265570 +0100
> @@ -3152,7 +3152,7 @@ int ext3_setattr(struct dentry *dentry, 
>  			error = PTR_ERR(handle);
>  			goto err_out;
>  		}
> -		error = vfs_dq_transfer(inode, attr) ? -EDQUOT : 0;
> +		error = dquot_transfer(inode, attr);
>  		if (error) {
>  			ext3_journal_stop(handle);
>  			return error;
> Index: linux-2.6/fs/ext4/inode.c
> ===================================================================
> --- linux-2.6.orig/fs/ext4/inode.c	2010-02-20 11:46:29.854255514 +0100
> +++ linux-2.6/fs/ext4/inode.c	2010-02-20 11:55:53.804005688 +0100
> @@ -5261,7 +5261,7 @@ int ext4_setattr(struct dentry *dentry, 
>  			error = PTR_ERR(handle);
>  			goto err_out;
>  		}
> -		error = vfs_dq_transfer(inode, attr) ? -EDQUOT : 0;
> +		error = dquot_transfer(inode, attr);
>  		if (error) {
>  			ext4_journal_stop(handle);
>  			return error;
> Index: linux-2.6/fs/ocfs2/file.c
> ===================================================================
> --- linux-2.6.orig/fs/ocfs2/file.c	2010-02-20 11:46:30.009005758 +0100
> +++ linux-2.6/fs/ocfs2/file.c	2010-02-20 11:55:53.836005270 +0100
> @@ -1021,7 +1021,7 @@ int ocfs2_setattr(struct dentry *dentry,
>  		/*
>  		 * Gather pointers to quota structures so that allocation /
>  		 * freeing of quota structures happens here and not inside
> -		 * vfs_dq_transfer() where we have problems with lock ordering
> +		 * dquot_transfer() where we have problems with lock ordering
>  		 */
>  		if (attr->ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid
>  		    && OCFS2_HAS_RO_COMPAT_FEATURE(sb,
> @@ -1054,7 +1054,7 @@ int ocfs2_setattr(struct dentry *dentry,
>  			mlog_errno(status);
>  			goto bail_unlock;
>  		}
> -		status = vfs_dq_transfer(inode, attr) ? -EDQUOT : 0;
> +		status = dquot_transfer(inode, attr);
>  		if (status < 0)
>  			goto bail_commit;
>  	} else {
> Index: linux-2.6/fs/reiserfs/inode.c
> ===================================================================
> --- linux-2.6.orig/fs/reiserfs/inode.c	2010-02-20 11:48:48.735005688 +0100
> +++ linux-2.6/fs/reiserfs/inode.c	2010-02-20 11:55:53.847006037 +0100
> @@ -3135,8 +3135,7 @@ int reiserfs_setattr(struct dentry *dent
>  						  jbegin_count);
>  				if (error)
>  					goto out;
> -				error =
> -				    vfs_dq_transfer(inode, attr) ? -EDQUOT : 0;
> +				error = dquot_transfer(inode, attr);
>  				if (error) {
>  					journal_end(&th, inode->i_sb,
>  						    jbegin_count);
> Index: linux-2.6/fs/ufs/truncate.c
> ===================================================================
> --- linux-2.6.orig/fs/ufs/truncate.c	2010-02-20 11:53:51.125252859 +0100
> +++ linux-2.6/fs/ufs/truncate.c	2010-02-20 11:55:53.855009459 +0100
> @@ -520,7 +520,7 @@ static int ufs_setattr(struct dentry *de
>  
>  	if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
>  	    (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
> -		error = vfs_dq_transfer(inode, attr) ? -EDQUOT : 0;
> +		error = dquot_transfer(inode, attr);
>  		if (error)
>  			return error;
>  	}
> Index: linux-2.6/fs/jfs/file.c
> ===================================================================
> --- linux-2.6.orig/fs/jfs/file.c	2010-02-20 11:53:51.132291971 +0100
> +++ linux-2.6/fs/jfs/file.c	2010-02-20 11:55:53.857256072 +0100
> @@ -100,8 +100,9 @@ int jfs_setattr(struct dentry *dentry, s
>  
>  	if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
>  	    (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
> -		if (vfs_dq_transfer(inode, iattr))
> -			return -EDQUOT;
> +		rc = dquot_transfer(inode, iattr);
> +		if (rc)
> +			return rc;
>  	}
>  
>  	rc = inode_setattr(inode, iattr);
> 
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

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

* Re: [PATCH 5/8] dquot: move dquot drop responsibiliy into the filesystem
  2010-02-20 11:51 ` [PATCH 5/8] dquot: move dquot drop responsibiliy into the filesystem Christoph Hellwig
@ 2010-02-25  0:00   ` Jan Kara
  0 siblings, 0 replies; 26+ messages in thread
From: Jan Kara @ 2010-02-25  0:00 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: jack, linux-fsdevel

On Sat 20-02-10 06:51:06, Christoph Hellwig wrote:
> Currently clear_inode calls vfs_dq_drop directly.  This means
> we tie the quota code into the VFS.  Get rid of that and make the
> filesystem responsibly for the drop inside the ->clear_inode
> superblock operation.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
  Looks good. Merged.

								Honza
> 
> Index: linux-2.6/fs/ext2/super.c
> ===================================================================
> --- linux-2.6.orig/fs/ext2/super.c	2010-02-19 00:34:37.825004031 +0100
> +++ linux-2.6/fs/ext2/super.c	2010-02-19 00:36:12.220253508 +0100
> @@ -194,6 +194,8 @@ static void destroy_inodecache(void)
>  static void ext2_clear_inode(struct inode *inode)
>  {
>  	struct ext2_block_alloc_info *rsv = EXT2_I(inode)->i_block_alloc_info;
> +
> +	vfs_dq_drop(inode);
>  	ext2_discard_reservation(inode);
>  	EXT2_I(inode)->i_block_alloc_info = NULL;
>  	if (unlikely(rsv))
> Index: linux-2.6/fs/ext3/super.c
> ===================================================================
> --- linux-2.6.orig/fs/ext3/super.c	2010-02-19 00:36:11.342272784 +0100
> +++ linux-2.6/fs/ext3/super.c	2010-02-19 00:37:51.823255463 +0100
> @@ -528,6 +528,8 @@ static void destroy_inodecache(void)
>  static void ext3_clear_inode(struct inode *inode)
>  {
>  	struct ext3_block_alloc_info *rsv = EXT3_I(inode)->i_block_alloc_info;
> +
> +	vfs_dq_drop(inode);
>  	ext3_discard_reservation(inode);
>  	EXT3_I(inode)->i_block_alloc_info = NULL;
>  	if (unlikely(rsv))
> Index: linux-2.6/fs/ext4/super.c
> ===================================================================
> --- linux-2.6.orig/fs/ext4/super.c	2010-02-19 00:36:11.349253577 +0100
> +++ linux-2.6/fs/ext4/super.c	2010-02-19 00:37:56.031005358 +0100
> @@ -761,6 +761,7 @@ static void destroy_inodecache(void)
>  
>  static void ext4_clear_inode(struct inode *inode)
>  {
> +	vfs_dq_drop(inode);
>  	ext4_discard_preallocations(inode);
>  	if (EXT4_JOURNAL(inode))
>  		jbd2_journal_release_jbd_inode(EXT4_SB(inode->i_sb)->s_journal,
> Index: linux-2.6/fs/inode.c
> ===================================================================
> --- linux-2.6.orig/fs/inode.c	2010-02-19 00:34:37.871003961 +0100
> +++ linux-2.6/fs/inode.c	2010-02-19 00:36:12.241255672 +0100
> @@ -314,7 +314,6 @@ void clear_inode(struct inode *inode)
>  	BUG_ON(!(inode->i_state & I_FREEING));
>  	BUG_ON(inode->i_state & I_CLEAR);
>  	inode_sync_wait(inode);
> -	vfs_dq_drop(inode);
>  	if (inode->i_sb->s_op->clear_inode)
>  		inode->i_sb->s_op->clear_inode(inode);
>  	if (S_ISBLK(inode->i_mode) && inode->i_bdev)
> Index: linux-2.6/fs/jfs/super.c
> ===================================================================
> --- linux-2.6.orig/fs/jfs/super.c	2010-02-19 00:34:37.880003612 +0100
> +++ linux-2.6/fs/jfs/super.c	2010-02-19 00:36:12.253005987 +0100
> @@ -131,6 +131,11 @@ static void jfs_destroy_inode(struct ino
>  	kmem_cache_free(jfs_inode_cachep, ji);
>  }
>  
> +static void jfs_clear_inode(struct inode *inode)
> +{
> +	vfs_dq_drop(inode);
> +}
> +
>  static int jfs_statfs(struct dentry *dentry, struct kstatfs *buf)
>  {
>  	struct jfs_sb_info *sbi = JFS_SBI(dentry->d_sb);
> @@ -745,6 +750,7 @@ static const struct super_operations jfs
>  	.dirty_inode	= jfs_dirty_inode,
>  	.write_inode	= jfs_write_inode,
>  	.delete_inode	= jfs_delete_inode,
> +	.clear_inode	= jfs_clear_inode,
>  	.put_super	= jfs_put_super,
>  	.sync_fs	= jfs_sync_fs,
>  	.freeze_fs	= jfs_freeze,
> Index: linux-2.6/fs/ocfs2/inode.c
> ===================================================================
> --- linux-2.6.orig/fs/ocfs2/inode.c	2010-02-19 00:36:09.946254765 +0100
> +++ linux-2.6/fs/ocfs2/inode.c	2010-02-19 00:36:12.260023517 +0100
> @@ -1087,6 +1087,8 @@ void ocfs2_clear_inode(struct inode *ino
>  	mlog_bug_on_msg(OCFS2_SB(inode->i_sb) == NULL,
>  			"Inode=%lu\n", inode->i_ino);
>  
> +	vfs_dq_drop(inode);
> +
>  	/* To preven remote deletes we hold open lock before, now it
>  	 * is time to unlock PR and EX open locks. */
>  	ocfs2_open_unlock(inode);
> Index: linux-2.6/fs/reiserfs/super.c
> ===================================================================
> --- linux-2.6.orig/fs/reiserfs/super.c	2010-02-19 00:36:11.387274530 +0100
> +++ linux-2.6/fs/reiserfs/super.c	2010-02-19 00:38:03.698255045 +0100
> @@ -578,6 +578,11 @@ out:
>  	reiserfs_write_unlock_once(inode->i_sb, lock_depth);
>  }
>  
> +static void reiserfs_clear_inode(struct inode *inode)
> +{
> +	vfs_dq_drop(inode);
> +}
> +
>  #ifdef CONFIG_QUOTA
>  static ssize_t reiserfs_quota_write(struct super_block *, int, const char *,
>  				    size_t, loff_t);
> @@ -590,6 +595,7 @@ static const struct super_operations rei
>  	.destroy_inode = reiserfs_destroy_inode,
>  	.write_inode = reiserfs_write_inode,
>  	.dirty_inode = reiserfs_dirty_inode,
> +	.clear_inode = reiserfs_clear_inode,
>  	.delete_inode = reiserfs_delete_inode,
>  	.put_super = reiserfs_put_super,
>  	.write_super = reiserfs_write_super,
> Index: linux-2.6/fs/ufs/super.c
> ===================================================================
> --- linux-2.6.orig/fs/ufs/super.c	2010-02-19 00:34:37.940003822 +0100
> +++ linux-2.6/fs/ufs/super.c	2010-02-19 00:36:12.284254834 +0100
> @@ -1432,6 +1432,11 @@ static void destroy_inodecache(void)
>  	kmem_cache_destroy(ufs_inode_cachep);
>  }
>  
> +static void ufs_clear_inode(struct inode *inode)
> +{
> +	vfs_dq_drop(inode);
> +}
> +
>  #ifdef CONFIG_QUOTA
>  static ssize_t ufs_quota_read(struct super_block *, int, char *,size_t, loff_t);
>  static ssize_t ufs_quota_write(struct super_block *, int, const char *, size_t, loff_t);
> @@ -1442,6 +1447,7 @@ static const struct super_operations ufs
>  	.destroy_inode	= ufs_destroy_inode,
>  	.write_inode	= ufs_write_inode,
>  	.delete_inode	= ufs_delete_inode,
> +	.clear_inode	= ufs_clear_inode,
>  	.put_super	= ufs_put_super,
>  	.write_super	= ufs_write_super,
>  	.sync_fs	= ufs_sync_fs,
> 
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

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

* Re: [PATCH 6/8] dquot: cleanup dquot drop routine
  2010-02-20 11:51 ` [PATCH 6/8] dquot: cleanup dquot drop routine Christoph Hellwig
@ 2010-02-25  0:08   ` Jan Kara
  0 siblings, 0 replies; 26+ messages in thread
From: Jan Kara @ 2010-02-25  0:08 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: jack, linux-fsdevel

On Sat 20-02-10 06:51:07, Christoph Hellwig wrote:
> Get rid of the drop dquot operation - it is now always called from
> the filesystem and if a filesystem really needs it's own (which none
> currently does) it can just call into it's own routine directly.
> 
> Rename the now static low-level dquot_drop helper to __dquot_drop
> and vfs_dq_drop to dquot_drop to have a consistent namespace.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
  Looks fine. Merged.

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

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

* Re: [PATCH 7/8] dquot: move dquot initialization responsibiliy into the filesystem
  2010-02-20 11:51 ` [PATCH 7/8] dquot: move dquot initialization responsibiliy into the filesystem Christoph Hellwig
@ 2010-02-25  0:29   ` Jan Kara
  2010-03-02 18:44   ` Jan Kara
  1 sibling, 0 replies; 26+ messages in thread
From: Jan Kara @ 2010-02-25  0:29 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: jack, linux-fsdevel

On Sat 20-02-10 06:51:08, Christoph Hellwig wrote:
> Currently various places in the VFS call vfs_dq_init directly.  This means
> we tie the quota code into the VFS.  Get rid of that and make the
> filesystem responsibly for the initialization.   For most metadata operations
> this is a straight forward move into the methods, but for truncate and
> open it's a bit more complicated.
> 
> For truncate we currently only call vfs_dq_init for the sys_truncate case
> because open already takes care of it for ftruncate and open(O_TRUNC) - the
> new code causes an additional vfs_dq_init for those which is harmless.
> 
> For open the initialization is moved from do_filp_open into the open method,
> which means it happens slightly earlier now, and only for regular files.
> The latter is fine because we don't need to initialize it for operations
> on special files, and we already do it as part of the namespace operations
> for directories.
> 
> Add a dquot_file_open helper that filesystems that support generic quotas
> can use to fill in ->open.
  In principle looks OK but I'm too tired now to check the details so
I'll have a next look at it on Monday...

								Honza
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> 
> 
> Index: linux-2.6/fs/ext2/inode.c
> ===================================================================
> --- linux-2.6.orig/fs/ext2/inode.c	2010-02-20 11:55:53.772255862 +0100
> +++ linux-2.6/fs/ext2/inode.c	2010-02-20 12:00:45.486253976 +0100
> @@ -58,6 +58,8 @@ static inline int ext2_inode_is_fast_sym
>   */
>  void ext2_delete_inode (struct inode * inode)
>  {
> +	if (!is_bad_inode(inode))
> +		vfs_dq_init(inode);
>  	truncate_inode_pages(&inode->i_data, 0);
>  
>  	if (is_bad_inode(inode))
> @@ -1457,6 +1459,9 @@ int ext2_setattr(struct dentry *dentry, 
>  	error = inode_change_ok(inode, iattr);
>  	if (error)
>  		return error;
> +
> +	if (iattr->ia_valid & ATTR_SIZE)
> +		vfs_dq_init(inode);
>  	if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
>  	    (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
>  		error = dquot_transfer(inode, iattr);
> Index: linux-2.6/fs/ext3/inode.c
> ===================================================================
> --- linux-2.6.orig/fs/ext3/inode.c	2010-02-20 11:55:53.781265570 +0100
> +++ linux-2.6/fs/ext3/inode.c	2010-02-20 12:00:45.488257957 +0100
> @@ -196,6 +196,9 @@ void ext3_delete_inode (struct inode * i
>  {
>  	handle_t *handle;
>  
> +	if (!is_bad_inode(inode))
> +		vfs_dq_init(inode);
> +
>  	truncate_inode_pages(&inode->i_data, 0);
>  
>  	if (is_bad_inode(inode))
> @@ -3140,6 +3143,8 @@ int ext3_setattr(struct dentry *dentry, 
>  	if (error)
>  		return error;
>  
> +	if (ia_valid & ATTR_SIZE)
> +		vfs_dq_init(inode);
>  	if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
>  		(ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
>  		handle_t *handle;
> Index: linux-2.6/fs/ext4/inode.c
> ===================================================================
> --- linux-2.6.orig/fs/ext4/inode.c	2010-02-20 11:55:53.804005688 +0100
> +++ linux-2.6/fs/ext4/inode.c	2010-02-20 12:00:45.505255373 +0100
> @@ -170,6 +170,9 @@ void ext4_delete_inode(struct inode *ino
>  	handle_t *handle;
>  	int err;
>  
> +	if (!is_bad_inode(inode))
> +		vfs_dq_init(inode);
> +
>  	if (ext4_should_order_data(inode))
>  		ext4_begin_ordered_truncate(inode, 0);
>  	truncate_inode_pages(&inode->i_data, 0);
> @@ -5249,6 +5252,8 @@ int ext4_setattr(struct dentry *dentry, 
>  	if (error)
>  		return error;
>  
> +	if (ia_valid & ATTR_SIZE)
> +		vfs_dq_init(inode);
>  	if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
>  		(ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
>  		handle_t *handle;
> Index: linux-2.6/fs/inode.c
> ===================================================================
> --- linux-2.6.orig/fs/inode.c	2010-02-20 11:58:09.796005478 +0100
> +++ linux-2.6/fs/inode.c	2010-02-20 12:00:45.538255584 +0100
> @@ -8,7 +8,6 @@
>  #include <linux/mm.h>
>  #include <linux/dcache.h>
>  #include <linux/init.h>
> -#include <linux/quotaops.h>
>  #include <linux/slab.h>
>  #include <linux/writeback.h>
>  #include <linux/module.h>
> @@ -1210,8 +1209,6 @@ void generic_delete_inode(struct inode *
>  
>  	if (op->delete_inode) {
>  		void (*delete)(struct inode *) = op->delete_inode;
> -		if (!is_bad_inode(inode))
> -			vfs_dq_init(inode);
>  		/* Filesystems implementing their own
>  		 * s_op->delete_inode are required to call
>  		 * truncate_inode_pages and clear_inode()
> Index: linux-2.6/fs/jfs/inode.c
> ===================================================================
> --- linux-2.6.orig/fs/jfs/inode.c	2010-02-20 11:59:10.775005758 +0100
> +++ linux-2.6/fs/jfs/inode.c	2010-02-20 12:00:45.545255374 +0100
> @@ -146,6 +146,9 @@ void jfs_delete_inode(struct inode *inod
>  {
>  	jfs_info("In jfs_delete_inode, inode = 0x%p", inode);
>  
> +	if (!is_bad_inode(inode))
> +		vfs_dq_init(inode);
> +
>  	if (!is_bad_inode(inode) &&
>  	    (JFS_IP(inode)->fileset == FILESYSTEM_I)) {
>  		truncate_inode_pages(&inode->i_data, 0);
> Index: linux-2.6/fs/ocfs2/inode.c
> ===================================================================
> --- linux-2.6.orig/fs/ocfs2/inode.c	2010-02-20 11:59:10.860254535 +0100
> +++ linux-2.6/fs/ocfs2/inode.c	2010-02-20 12:00:45.548255793 +0100
> @@ -971,6 +971,8 @@ void ocfs2_delete_inode(struct inode *in
>  		goto bail;
>  	}
>  
> +	vfs_dq_init(inode);
> +
>  	if (!ocfs2_inode_is_valid_to_delete(inode)) {
>  		/* It's probably not necessary to truncate_inode_pages
>  		 * here but we do it for safety anyway (it will most
> Index: linux-2.6/fs/reiserfs/inode.c
> ===================================================================
> --- linux-2.6.orig/fs/reiserfs/inode.c	2010-02-20 11:59:10.802007224 +0100
> +++ linux-2.6/fs/reiserfs/inode.c	2010-02-20 12:00:45.554256073 +0100
> @@ -34,6 +34,9 @@ void reiserfs_delete_inode(struct inode 
>  	int depth;
>  	int err;
>  
> +	if (!is_bad_inode(inode))
> +		vfs_dq_init(inode);
> +
>  	truncate_inode_pages(&inode->i_data, 0);
>  
>  	depth = reiserfs_write_lock_once(inode->i_sb);
> @@ -3073,6 +3076,8 @@ int reiserfs_setattr(struct dentry *dent
>  	ia_valid = attr->ia_valid &= ~(ATTR_KILL_SUID|ATTR_KILL_SGID);
>  
>  	depth = reiserfs_write_lock_once(inode->i_sb);
> +	if (ia_valid & ATTR_SIZE)
> +		vfs_dq_init(inode);
>  	if (attr->ia_valid & ATTR_SIZE) {
>  		/* version 2 items will be caught by the s_maxbytes check
>  		 ** done for us in vmtruncate
> Index: linux-2.6/fs/ufs/inode.c
> ===================================================================
> --- linux-2.6.orig/fs/ufs/inode.c	2010-02-20 11:40:48.574254465 +0100
> +++ linux-2.6/fs/ufs/inode.c	2010-02-20 12:00:45.560257050 +0100
> @@ -36,6 +36,7 @@
>  #include <linux/mm.h>
>  #include <linux/smp_lock.h>
>  #include <linux/buffer_head.h>
> +#include <linux/quotaops.h>
>  
>  #include "ufs_fs.h"
>  #include "ufs.h"
> @@ -908,6 +909,9 @@ void ufs_delete_inode (struct inode * in
>  {
>  	loff_t old_i_size;
>  
> +	if (!is_bad_inode(inode))
> +		vfs_dq_init(inode);
> +
>  	truncate_inode_pages(&inode->i_data, 0);
>  	if (is_bad_inode(inode))
>  		goto no_delete;
> Index: linux-2.6/fs/namei.c
> ===================================================================
> --- linux-2.6.orig/fs/namei.c	2010-02-20 11:40:48.597274509 +0100
> +++ linux-2.6/fs/namei.c	2010-02-20 12:00:45.565255863 +0100
> @@ -19,7 +19,6 @@
>  #include <linux/slab.h>
>  #include <linux/fs.h>
>  #include <linux/namei.h>
> -#include <linux/quotaops.h>
>  #include <linux/pagemap.h>
>  #include <linux/fsnotify.h>
>  #include <linux/personality.h>
> @@ -1451,7 +1450,6 @@ int vfs_create(struct inode *dir, struct
>  	error = security_inode_create(dir, dentry, mode);
>  	if (error)
>  		return error;
> -	vfs_dq_init(dir);
>  	error = dir->i_op->create(dir, dentry, mode, nd);
>  	if (!error)
>  		fsnotify_create(dir, dentry);
> @@ -1803,9 +1801,6 @@ ok:
>  		}
>  	}
>  	if (!IS_ERR(filp)) {
> -		if (acc_mode & MAY_WRITE)
> -			vfs_dq_init(nd.path.dentry->d_inode);
> -
>  		if (will_truncate) {
>  			error = handle_truncate(&nd.path);
>  			if (error) {
> @@ -1986,7 +1981,6 @@ int vfs_mknod(struct inode *dir, struct 
>  	if (error)
>  		return error;
>  
> -	vfs_dq_init(dir);
>  	error = dir->i_op->mknod(dir, dentry, mode, dev);
>  	if (!error)
>  		fsnotify_create(dir, dentry);
> @@ -2085,7 +2079,6 @@ int vfs_mkdir(struct inode *dir, struct 
>  	if (error)
>  		return error;
>  
> -	vfs_dq_init(dir);
>  	error = dir->i_op->mkdir(dir, dentry, mode);
>  	if (!error)
>  		fsnotify_mkdir(dir, dentry);
> @@ -2171,8 +2164,6 @@ int vfs_rmdir(struct inode *dir, struct 
>  	if (!dir->i_op->rmdir)
>  		return -EPERM;
>  
> -	vfs_dq_init(dir);
> -
>  	mutex_lock(&dentry->d_inode->i_mutex);
>  	dentry_unhash(dentry);
>  	if (d_mountpoint(dentry))
> @@ -2258,8 +2249,6 @@ int vfs_unlink(struct inode *dir, struct
>  	if (!dir->i_op->unlink)
>  		return -EPERM;
>  
> -	vfs_dq_init(dir);
> -
>  	mutex_lock(&dentry->d_inode->i_mutex);
>  	if (d_mountpoint(dentry))
>  		error = -EBUSY;
> @@ -2369,7 +2358,6 @@ int vfs_symlink(struct inode *dir, struc
>  	if (error)
>  		return error;
>  
> -	vfs_dq_init(dir);
>  	error = dir->i_op->symlink(dir, dentry, oldname);
>  	if (!error)
>  		fsnotify_create(dir, dentry);
> @@ -2453,7 +2441,6 @@ int vfs_link(struct dentry *old_dentry, 
>  		return error;
>  
>  	mutex_lock(&inode->i_mutex);
> -	vfs_dq_init(dir);
>  	error = dir->i_op->link(old_dentry, dir, new_dentry);
>  	mutex_unlock(&inode->i_mutex);
>  	if (!error)
> @@ -2652,9 +2639,6 @@ int vfs_rename(struct inode *old_dir, st
>  	if (!old_dir->i_op->rename)
>  		return -EPERM;
>  
> -	vfs_dq_init(old_dir);
> -	vfs_dq_init(new_dir);
> -
>  	old_name = fsnotify_oldname_init(old_dentry->d_name.name);
>  
>  	if (is_dir)
> Index: linux-2.6/fs/ext2/namei.c
> ===================================================================
> --- linux-2.6.orig/fs/ext2/namei.c	2010-02-20 11:40:48.390272694 +0100
> +++ linux-2.6/fs/ext2/namei.c	2010-02-20 12:00:45.577006037 +0100
> @@ -31,6 +31,7 @@
>   */
>  
>  #include <linux/pagemap.h>
> +#include <linux/quotaops.h>
>  #include "ext2.h"
>  #include "xattr.h"
>  #include "acl.h"
> @@ -99,24 +100,27 @@ struct dentry *ext2_get_parent(struct de
>   */
>  static int ext2_create (struct inode * dir, struct dentry * dentry, int mode, struct nameidata *nd)
>  {
> -	struct inode * inode = ext2_new_inode (dir, mode);
> -	int err = PTR_ERR(inode);
> -	if (!IS_ERR(inode)) {
> -		inode->i_op = &ext2_file_inode_operations;
> -		if (ext2_use_xip(inode->i_sb)) {
> -			inode->i_mapping->a_ops = &ext2_aops_xip;
> -			inode->i_fop = &ext2_xip_file_operations;
> -		} else if (test_opt(inode->i_sb, NOBH)) {
> -			inode->i_mapping->a_ops = &ext2_nobh_aops;
> -			inode->i_fop = &ext2_file_operations;
> -		} else {
> -			inode->i_mapping->a_ops = &ext2_aops;
> -			inode->i_fop = &ext2_file_operations;
> -		}
> -		mark_inode_dirty(inode);
> -		err = ext2_add_nondir(dentry, inode);
> +	struct inode *inode;
> +
> +	vfs_dq_init(dir);
> +
> +	inode = ext2_new_inode(dir, mode);
> +	if (IS_ERR(inode))
> +		return PTR_ERR(inode);
> +
> +	inode->i_op = &ext2_file_inode_operations;
> +	if (ext2_use_xip(inode->i_sb)) {
> +		inode->i_mapping->a_ops = &ext2_aops_xip;
> +		inode->i_fop = &ext2_xip_file_operations;
> +	} else if (test_opt(inode->i_sb, NOBH)) {
> +		inode->i_mapping->a_ops = &ext2_nobh_aops;
> +		inode->i_fop = &ext2_file_operations;
> +	} else {
> +		inode->i_mapping->a_ops = &ext2_aops;
> +		inode->i_fop = &ext2_file_operations;
>  	}
> -	return err;
> +	mark_inode_dirty(inode);
> +	return ext2_add_nondir(dentry, inode);
>  }
>  
>  static int ext2_mknod (struct inode * dir, struct dentry *dentry, int mode, dev_t rdev)
> @@ -127,6 +131,8 @@ static int ext2_mknod (struct inode * di
>  	if (!new_valid_dev(rdev))
>  		return -EINVAL;
>  
> +	vfs_dq_init(dir);
> +
>  	inode = ext2_new_inode (dir, mode);
>  	err = PTR_ERR(inode);
>  	if (!IS_ERR(inode)) {
> @@ -151,6 +157,8 @@ static int ext2_symlink (struct inode * 
>  	if (l > sb->s_blocksize)
>  		goto out;
>  
> +	vfs_dq_init(dir);
> +
>  	inode = ext2_new_inode (dir, S_IFLNK | S_IRWXUGO);
>  	err = PTR_ERR(inode);
>  	if (IS_ERR(inode))
> @@ -194,6 +202,8 @@ static int ext2_link (struct dentry * ol
>  	if (inode->i_nlink >= EXT2_LINK_MAX)
>  		return -EMLINK;
>  
> +	vfs_dq_init(dir);
> +
>  	inode->i_ctime = CURRENT_TIME_SEC;
>  	inode_inc_link_count(inode);
>  	atomic_inc(&inode->i_count);
> @@ -216,6 +226,8 @@ static int ext2_mkdir(struct inode * dir
>  	if (dir->i_nlink >= EXT2_LINK_MAX)
>  		goto out;
>  
> +	vfs_dq_init(dir);
> +
>  	inode_inc_link_count(dir);
>  
>  	inode = ext2_new_inode (dir, S_IFDIR | mode);
> @@ -262,6 +274,8 @@ static int ext2_unlink(struct inode * di
>  	struct page * page;
>  	int err = -ENOENT;
>  
> +	vfs_dq_init(dir);
> +
>  	de = ext2_find_entry (dir, &dentry->d_name, &page);
>  	if (!de)
>  		goto out;
> @@ -304,6 +318,9 @@ static int ext2_rename (struct inode * o
>  	struct ext2_dir_entry_2 * old_de;
>  	int err = -ENOENT;
>  
> +	vfs_dq_init(old_dir);
> +	vfs_dq_init(new_dir);
> +
>  	old_de = ext2_find_entry (old_dir, &old_dentry->d_name, &old_page);
>  	if (!old_de)
>  		goto out;
> Index: linux-2.6/fs/ext3/namei.c
> ===================================================================
> --- linux-2.6.orig/fs/ext3/namei.c	2010-02-20 11:40:48.419254255 +0100
> +++ linux-2.6/fs/ext3/namei.c	2010-02-20 12:00:45.584007015 +0100
> @@ -1696,6 +1696,8 @@ static int ext3_create (struct inode * d
>  	struct inode * inode;
>  	int err, retries = 0;
>  
> +	vfs_dq_init(dir);
> +
>  retry:
>  	handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
>  					EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 +
> @@ -1730,6 +1732,8 @@ static int ext3_mknod (struct inode * di
>  	if (!new_valid_dev(rdev))
>  		return -EINVAL;
>  
> +	vfs_dq_init(dir);
> +
>  retry:
>  	handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
>  					EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 +
> @@ -1766,6 +1770,8 @@ static int ext3_mkdir(struct inode * dir
>  	if (dir->i_nlink >= EXT3_LINK_MAX)
>  		return -EMLINK;
>  
> +	vfs_dq_init(dir);
> +
>  retry:
>  	handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
>  					EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 +
> @@ -2060,7 +2066,9 @@ static int ext3_rmdir (struct inode * di
>  
>  	/* Initialize quotas before so that eventual writes go in
>  	 * separate transaction */
> +	vfs_dq_init(dir);
>  	vfs_dq_init(dentry->d_inode);
> +
>  	handle = ext3_journal_start(dir, EXT3_DELETE_TRANS_BLOCKS(dir->i_sb));
>  	if (IS_ERR(handle))
>  		return PTR_ERR(handle);
> @@ -2119,7 +2127,9 @@ static int ext3_unlink(struct inode * di
>  
>  	/* Initialize quotas before so that eventual writes go
>  	 * in separate transaction */
> +	vfs_dq_init(dir);
>  	vfs_dq_init(dentry->d_inode);
> +
>  	handle = ext3_journal_start(dir, EXT3_DELETE_TRANS_BLOCKS(dir->i_sb));
>  	if (IS_ERR(handle))
>  		return PTR_ERR(handle);
> @@ -2174,6 +2184,8 @@ static int ext3_symlink (struct inode * 
>  	if (l > dir->i_sb->s_blocksize)
>  		return -ENAMETOOLONG;
>  
> +	vfs_dq_init(dir);
> +
>  retry:
>  	handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
>  					EXT3_INDEX_EXTRA_TRANS_BLOCKS + 5 +
> @@ -2228,6 +2240,9 @@ static int ext3_link (struct dentry * ol
>  
>  	if (inode->i_nlink >= EXT3_LINK_MAX)
>  		return -EMLINK;
> +
> +	vfs_dq_init(dir);
> +
>  	/*
>  	 * Return -ENOENT if we've raced with unlink and i_nlink is 0.  Doing
>  	 * otherwise has the potential to corrupt the orphan inode list.
> @@ -2278,6 +2293,9 @@ static int ext3_rename (struct inode * o
>  	struct ext3_dir_entry_2 * old_de, * new_de;
>  	int retval, flush_file = 0;
>  
> +	vfs_dq_init(old_dir);
> +	vfs_dq_init(new_dir);
> +
>  	old_bh = new_bh = dir_bh = NULL;
>  
>  	/* Initialize quotas before so that eventual writes go
> Index: linux-2.6/fs/ext4/namei.c
> ===================================================================
> --- linux-2.6.orig/fs/ext4/namei.c	2010-02-20 11:40:48.450275138 +0100
> +++ linux-2.6/fs/ext4/namei.c	2010-02-20 12:00:45.602005827 +0100
> @@ -1766,6 +1766,8 @@ static int ext4_create(struct inode *dir
>  	struct inode *inode;
>  	int err, retries = 0;
>  
> +	vfs_dq_init(dir);
> +
>  retry:
>  	handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
>  					EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
> @@ -1800,6 +1802,8 @@ static int ext4_mknod(struct inode *dir,
>  	if (!new_valid_dev(rdev))
>  		return -EINVAL;
>  
> +	vfs_dq_init(dir);
> +
>  retry:
>  	handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
>  					EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
> @@ -1837,6 +1841,8 @@ static int ext4_mkdir(struct inode *dir,
>  	if (EXT4_DIR_LINK_MAX(dir))
>  		return -EMLINK;
>  
> +	vfs_dq_init(dir);
> +
>  retry:
>  	handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
>  					EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
> @@ -2136,7 +2142,9 @@ static int ext4_rmdir(struct inode *dir,
>  
>  	/* Initialize quotas before so that eventual writes go in
>  	 * separate transaction */
> +	vfs_dq_init(dir);
>  	vfs_dq_init(dentry->d_inode);
> +
>  	handle = ext4_journal_start(dir, EXT4_DELETE_TRANS_BLOCKS(dir->i_sb));
>  	if (IS_ERR(handle))
>  		return PTR_ERR(handle);
> @@ -2195,7 +2203,9 @@ static int ext4_unlink(struct inode *dir
>  
>  	/* Initialize quotas before so that eventual writes go
>  	 * in separate transaction */
> +	vfs_dq_init(dir);
>  	vfs_dq_init(dentry->d_inode);
> +
>  	handle = ext4_journal_start(dir, EXT4_DELETE_TRANS_BLOCKS(dir->i_sb));
>  	if (IS_ERR(handle))
>  		return PTR_ERR(handle);
> @@ -2250,6 +2260,8 @@ static int ext4_symlink(struct inode *di
>  	if (l > dir->i_sb->s_blocksize)
>  		return -ENAMETOOLONG;
>  
> +	vfs_dq_init(dir);
> +
>  retry:
>  	handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
>  					EXT4_INDEX_EXTRA_TRANS_BLOCKS + 5 +
> @@ -2308,6 +2320,8 @@ static int ext4_link(struct dentry *old_
>  	if (inode->i_nlink >= EXT4_LINK_MAX)
>  		return -EMLINK;
>  
> +	vfs_dq_init(dir);
> +
>  	/*
>  	 * Return -ENOENT if we've raced with unlink and i_nlink is 0.  Doing
>  	 * otherwise has the potential to corrupt the orphan inode list.
> @@ -2358,6 +2372,9 @@ static int ext4_rename(struct inode *old
>  	struct ext4_dir_entry_2 *old_de, *new_de;
>  	int retval, force_da_alloc = 0;
>  
> +	vfs_dq_init(old_dir);
> +	vfs_dq_init(new_dir);
> +
>  	old_bh = new_bh = dir_bh = NULL;
>  
>  	/* Initialize quotas before so that eventual writes go
> Index: linux-2.6/fs/jfs/namei.c
> ===================================================================
> --- linux-2.6.orig/fs/jfs/namei.c	2010-02-20 11:53:51.140254046 +0100
> +++ linux-2.6/fs/jfs/namei.c	2010-02-20 12:00:45.617005478 +0100
> @@ -85,6 +85,8 @@ static int jfs_create(struct inode *dip,
>  
>  	jfs_info("jfs_create: dip:0x%p name:%s", dip, dentry->d_name.name);
>  
> +	vfs_dq_init(dip);
> +
>  	/*
>  	 * search parent directory for entry/freespace
>  	 * (dtSearch() returns parent directory page pinned)
> @@ -215,6 +217,8 @@ static int jfs_mkdir(struct inode *dip, 
>  
>  	jfs_info("jfs_mkdir: dip:0x%p name:%s", dip, dentry->d_name.name);
>  
> +	vfs_dq_init(dip);
> +
>  	/* link count overflow on parent directory ? */
>  	if (dip->i_nlink == JFS_LINK_MAX) {
>  		rc = -EMLINK;
> @@ -356,6 +360,7 @@ static int jfs_rmdir(struct inode *dip, 
>  	jfs_info("jfs_rmdir: dip:0x%p name:%s", dip, dentry->d_name.name);
>  
>  	/* Init inode for quota operations. */
> +	vfs_dq_init(dip);
>  	vfs_dq_init(ip);
>  
>  	/* directory must be empty to be removed */
> @@ -483,6 +488,7 @@ static int jfs_unlink(struct inode *dip,
>  	jfs_info("jfs_unlink: dip:0x%p name:%s", dip, dentry->d_name.name);
>  
>  	/* Init inode for quota operations. */
> +	vfs_dq_init(dip);
>  	vfs_dq_init(ip);
>  
>  	if ((rc = get_UCSname(&dname, dentry)))
> @@ -805,6 +811,8 @@ static int jfs_link(struct dentry *old_d
>  	if (ip->i_nlink == 0)
>  		return -ENOENT;
>  
> +	vfs_dq_init(dir);
> +
>  	tid = txBegin(ip->i_sb, 0);
>  
>  	mutex_lock_nested(&JFS_IP(dir)->commit_mutex, COMMIT_MUTEX_PARENT);
> @@ -896,6 +904,8 @@ static int jfs_symlink(struct inode *dip
>  
>  	jfs_info("jfs_symlink: dip:0x%p name:%s", dip, name);
>  
> +	vfs_dq_init(dip);
> +
>  	ssize = strlen(name) + 1;
>  
>  	/*
> @@ -1087,6 +1097,9 @@ static int jfs_rename(struct inode *old_
>  	jfs_info("jfs_rename: %s %s", old_dentry->d_name.name,
>  		 new_dentry->d_name.name);
>  
> +	vfs_dq_init(old_dir);
> +	vfs_dq_init(new_dir);
> +
>  	old_ip = old_dentry->d_inode;
>  	new_ip = new_dentry->d_inode;
>  
> @@ -1360,6 +1373,8 @@ static int jfs_mknod(struct inode *dir, 
>  
>  	jfs_info("jfs_mknod: %s", dentry->d_name.name);
>  
> +	vfs_dq_init(dir);
> +
>  	if ((rc = get_UCSname(&dname, dentry)))
>  		goto out;
>  
> Index: linux-2.6/fs/ocfs2/namei.c
> ===================================================================
> --- linux-2.6.orig/fs/ocfs2/namei.c	2010-02-20 11:48:48.651005199 +0100
> +++ linux-2.6/fs/ocfs2/namei.c	2010-02-20 12:00:45.625285195 +0100
> @@ -244,6 +244,8 @@ static int ocfs2_mknod(struct inode *dir
>  		   (unsigned long)dev, dentry->d_name.len,
>  		   dentry->d_name.name);
>  
> +	vfs_dq_init(dir);
> +
>  	/* get our super block */
>  	osb = OCFS2_SB(dir->i_sb);
>  
> @@ -633,6 +635,8 @@ static int ocfs2_link(struct dentry *old
>  	if (S_ISDIR(inode->i_mode))
>  		return -EPERM;
>  
> +	vfs_dq_init(dir);
> +
>  	err = ocfs2_inode_lock_nested(dir, &parent_fe_bh, 1, OI_LS_PARENT);
>  	if (err < 0) {
>  		if (err != -ENOENT)
> @@ -788,6 +792,8 @@ static int ocfs2_unlink(struct inode *di
>  	mlog_entry("(0x%p, 0x%p, '%.*s')\n", dir, dentry,
>  		   dentry->d_name.len, dentry->d_name.name);
>  
> +	vfs_dq_init(dir);
> +
>  	BUG_ON(dentry->d_parent->d_inode != dir);
>  
>  	mlog(0, "ino = %llu\n", (unsigned long long)OCFS2_I(inode)->ip_blkno);
> @@ -1048,6 +1054,9 @@ static int ocfs2_rename(struct inode *ol
>  		   old_dentry->d_name.len, old_dentry->d_name.name,
>  		   new_dentry->d_name.len, new_dentry->d_name.name);
>  
> +	vfs_dq_init(old_dir);
> +	vfs_dq_init(new_dir);
> +
>  	osb = OCFS2_SB(old_dir->i_sb);
>  
>  	if (new_inode) {
> @@ -1596,6 +1605,8 @@ static int ocfs2_symlink(struct inode *d
>  	mlog_entry("(0x%p, 0x%p, symname='%s' actual='%.*s')\n", dir,
>  		   dentry, symname, dentry->d_name.len, dentry->d_name.name);
>  
> +	vfs_dq_init(dir);
> +
>  	sb = dir->i_sb;
>  	osb = OCFS2_SB(sb);
>  
> Index: linux-2.6/fs/reiserfs/namei.c
> ===================================================================
> --- linux-2.6.orig/fs/reiserfs/namei.c	2010-02-20 11:59:10.814006596 +0100
> +++ linux-2.6/fs/reiserfs/namei.c	2010-02-20 12:00:45.631256001 +0100
> @@ -594,6 +594,8 @@ static int reiserfs_create(struct inode 
>  	struct reiserfs_transaction_handle th;
>  	struct reiserfs_security_handle security;
>  
> +	vfs_dq_init(dir);
> +
>  	if (!(inode = new_inode(dir->i_sb))) {
>  		return -ENOMEM;
>  	}
> @@ -666,6 +668,8 @@ static int reiserfs_mknod(struct inode *
>  	if (!new_valid_dev(rdev))
>  		return -EINVAL;
>  
> +	vfs_dq_init(dir);
> +
>  	if (!(inode = new_inode(dir->i_sb))) {
>  		return -ENOMEM;
>  	}
> @@ -739,6 +743,8 @@ static int reiserfs_mkdir(struct inode *
>  	    2 * (REISERFS_QUOTA_INIT_BLOCKS(dir->i_sb) +
>  		 REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb));
>  
> +	vfs_dq_init(dir);
> +
>  #ifdef DISPLACE_NEW_PACKING_LOCALITIES
>  	/* set flag that new packing locality created and new blocks for the content     * of that directory are not displaced yet */
>  	REISERFS_I(dir)->new_packing_locality = 1;
> @@ -842,6 +848,8 @@ static int reiserfs_rmdir(struct inode *
>  	    JOURNAL_PER_BALANCE_CNT * 2 + 2 +
>  	    4 * REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb);
>  
> +	vfs_dq_init(dir);
> +
>  	reiserfs_write_lock(dir->i_sb);
>  	retval = journal_begin(&th, dir->i_sb, jbegin_count);
>  	if (retval)
> @@ -923,6 +931,8 @@ static int reiserfs_unlink(struct inode 
>  	unsigned long savelink;
>  	int depth;
>  
> +	vfs_dq_init(dir);
> +
>  	inode = dentry->d_inode;
>  
>  	/* in this transaction we can be doing at max two balancings and update
> @@ -1024,6 +1034,8 @@ static int reiserfs_symlink(struct inode
>  	    2 * (REISERFS_QUOTA_INIT_BLOCKS(parent_dir->i_sb) +
>  		 REISERFS_QUOTA_TRANS_BLOCKS(parent_dir->i_sb));
>  
> +	vfs_dq_init(parent_dir);
> +
>  	if (!(inode = new_inode(parent_dir->i_sb))) {
>  		return -ENOMEM;
>  	}
> @@ -1111,6 +1123,8 @@ static int reiserfs_link(struct dentry *
>  	    JOURNAL_PER_BALANCE_CNT * 3 +
>  	    2 * REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb);
>  
> +	vfs_dq_init(dir);
> +
>  	reiserfs_write_lock(dir->i_sb);
>  	if (inode->i_nlink >= REISERFS_LINK_MAX) {
>  		//FIXME: sd_nlink is 32 bit for new files
> @@ -1235,6 +1249,9 @@ static int reiserfs_rename(struct inode 
>  	    JOURNAL_PER_BALANCE_CNT * 3 + 5 +
>  	    4 * REISERFS_QUOTA_TRANS_BLOCKS(old_dir->i_sb);
>  
> +	vfs_dq_init(old_dir);
> +	vfs_dq_init(new_dir);
> +
>  	old_inode = old_dentry->d_inode;
>  	new_dentry_inode = new_dentry->d_inode;
>  
> Index: linux-2.6/fs/reiserfs/xattr.c
> ===================================================================
> --- linux-2.6.orig/fs/reiserfs/xattr.c	2010-02-20 11:40:48.552254116 +0100
> +++ linux-2.6/fs/reiserfs/xattr.c	2010-02-20 12:00:45.635255512 +0100
> @@ -61,7 +61,6 @@
>  static int xattr_create(struct inode *dir, struct dentry *dentry, int mode)
>  {
>  	BUG_ON(!mutex_is_locked(&dir->i_mutex));
> -	vfs_dq_init(dir);
>  	return dir->i_op->create(dir, dentry, mode, NULL);
>  }
>  #endif
> @@ -69,7 +68,6 @@ static int xattr_create(struct inode *di
>  static int xattr_mkdir(struct inode *dir, struct dentry *dentry, int mode)
>  {
>  	BUG_ON(!mutex_is_locked(&dir->i_mutex));
> -	vfs_dq_init(dir);
>  	return dir->i_op->mkdir(dir, dentry, mode);
>  }
>  
> @@ -81,7 +79,6 @@ static int xattr_unlink(struct inode *di
>  {
>  	int error;
>  	BUG_ON(!mutex_is_locked(&dir->i_mutex));
> -	vfs_dq_init(dir);
>  
>  	reiserfs_mutex_lock_nested_safe(&dentry->d_inode->i_mutex,
>  					I_MUTEX_CHILD, dir->i_sb);
> @@ -97,7 +94,6 @@ static int xattr_rmdir(struct inode *dir
>  {
>  	int error;
>  	BUG_ON(!mutex_is_locked(&dir->i_mutex));
> -	vfs_dq_init(dir);
>  
>  	reiserfs_mutex_lock_nested_safe(&dentry->d_inode->i_mutex,
>  					I_MUTEX_CHILD, dir->i_sb);
> Index: linux-2.6/fs/ufs/namei.c
> ===================================================================
> --- linux-2.6.orig/fs/ufs/namei.c	2010-02-20 11:40:48.582254325 +0100
> +++ linux-2.6/fs/ufs/namei.c	2010-02-20 12:00:45.638255862 +0100
> @@ -30,6 +30,7 @@
>  #include <linux/time.h>
>  #include <linux/fs.h>
>  #include <linux/smp_lock.h>
> +#include <linux/quotaops.h>
>  
>  #include "ufs_fs.h"
>  #include "ufs.h"
> @@ -84,6 +85,9 @@ static int ufs_create (struct inode * di
>  	int err;
>  
>  	UFSD("BEGIN\n");
> +
> +	vfs_dq_init(dir);
> +
>  	inode = ufs_new_inode(dir, mode);
>  	err = PTR_ERR(inode);
>  
> @@ -107,6 +111,9 @@ static int ufs_mknod (struct inode * dir
>  
>  	if (!old_valid_dev(rdev))
>  		return -EINVAL;
> +
> +	vfs_dq_init(dir);
> +
>  	inode = ufs_new_inode(dir, mode);
>  	err = PTR_ERR(inode);
>  	if (!IS_ERR(inode)) {
> @@ -131,6 +138,8 @@ static int ufs_symlink (struct inode * d
>  	if (l > sb->s_blocksize)
>  		goto out_notlocked;
>  
> +	vfs_dq_init(dir);
> +
>  	lock_kernel();
>  	inode = ufs_new_inode(dir, S_IFLNK | S_IRWXUGO);
>  	err = PTR_ERR(inode);
> @@ -176,6 +185,8 @@ static int ufs_link (struct dentry * old
>  		return -EMLINK;
>  	}
>  
> +	vfs_dq_init(dir);
> +
>  	inode->i_ctime = CURRENT_TIME_SEC;
>  	inode_inc_link_count(inode);
>  	atomic_inc(&inode->i_count);
> @@ -193,6 +204,8 @@ static int ufs_mkdir(struct inode * dir,
>  	if (dir->i_nlink >= UFS_LINK_MAX)
>  		goto out;
>  
> +	vfs_dq_init(dir);
> +
>  	lock_kernel();
>  	inode_inc_link_count(dir);
>  
> @@ -237,6 +250,8 @@ static int ufs_unlink(struct inode *dir,
>  	struct page *page;
>  	int err = -ENOENT;
>  
> +	vfs_dq_init(dir);
> +
>  	de = ufs_find_entry(dir, &dentry->d_name, &page);
>  	if (!de)
>  		goto out;
> @@ -281,6 +296,9 @@ static int ufs_rename(struct inode *old_
>  	struct ufs_dir_entry *old_de;
>  	int err = -ENOENT;
>  
> +	vfs_dq_init(old_dir);
> +	vfs_dq_init(new_dir);
> +
>  	old_de = ufs_find_entry(old_dir, &old_dentry->d_name, &old_page);
>  	if (!old_de)
>  		goto out;
> Index: linux-2.6/fs/nfsd/vfs.c
> ===================================================================
> --- linux-2.6.orig/fs/nfsd/vfs.c	2010-02-20 11:40:48.611254535 +0100
> +++ linux-2.6/fs/nfsd/vfs.c	2010-02-20 12:00:45.641255652 +0100
> @@ -20,7 +20,6 @@
>  #include <linux/fcntl.h>
>  #include <linux/namei.h>
>  #include <linux/delay.h>
> -#include <linux/quotaops.h>
>  #include <linux/fsnotify.h>
>  #include <linux/posix_acl_xattr.h>
>  #include <linux/xattr.h>
> @@ -377,7 +376,6 @@ nfsd_setattr(struct svc_rqst *rqstp, str
>  			put_write_access(inode);
>  			goto out_nfserr;
>  		}
> -		vfs_dq_init(inode);
>  	}
>  
>  	/* sanitize the mode change */
> @@ -745,8 +743,6 @@ nfsd_open(struct svc_rqst *rqstp, struct
>  			flags = O_RDWR|O_LARGEFILE;
>  		else
>  			flags = O_WRONLY|O_LARGEFILE;
> -
> -		vfs_dq_init(inode);
>  	}
>  	*filp = dentry_open(dget(dentry), mntget(fhp->fh_export->ex_path.mnt),
>  			    flags, current_cred());
> Index: linux-2.6/fs/ocfs2/file.c
> ===================================================================
> --- linux-2.6.orig/fs/ocfs2/file.c	2010-02-20 11:55:53.836005270 +0100
> +++ linux-2.6/fs/ocfs2/file.c	2010-02-20 12:00:45.648255722 +0100
> @@ -107,6 +107,9 @@ static int ocfs2_file_open(struct inode 
>  	mlog_entry("(0x%p, 0x%p, '%.*s')\n", inode, file,
>  		   file->f_path.dentry->d_name.len, file->f_path.dentry->d_name.name);
>  
> +	if (file->f_mode & FMODE_WRITE)
> +		vfs_dq_init(inode);
> +
>  	spin_lock(&oi->ip_lock);
>  
>  	/* Check that the inode hasn't been wiped from disk by another
> @@ -976,6 +979,9 @@ int ocfs2_setattr(struct dentry *dentry,
>  	if (status)
>  		return status;
>  
> +	if (attr->ia_valid & ATTR_SIZE)
> +		vfs_dq_init(inode);
> +
>  	size_change = S_ISREG(inode->i_mode) && attr->ia_valid & ATTR_SIZE;
>  	if (size_change) {
>  		status = ocfs2_rw_lock(inode, 1);
> Index: linux-2.6/fs/open.c
> ===================================================================
> --- linux-2.6.orig/fs/open.c	2010-02-20 11:40:48.619003522 +0100
> +++ linux-2.6/fs/open.c	2010-02-20 12:00:45.664005758 +0100
> @@ -8,7 +8,6 @@
>  #include <linux/mm.h>
>  #include <linux/file.h>
>  #include <linux/fdtable.h>
> -#include <linux/quotaops.h>
>  #include <linux/fsnotify.h>
>  #include <linux/module.h>
>  #include <linux/slab.h>
> @@ -278,10 +277,8 @@ static long do_sys_truncate(const char _
>  	error = locks_verify_truncate(inode, NULL, length);
>  	if (!error)
>  		error = security_path_truncate(&path, length, 0);
> -	if (!error) {
> -		vfs_dq_init(inode);
> +	if (!error)
>  		error = do_truncate(path.dentry, length, 0, NULL);
> -	}
>  
>  put_write_and_out:
>  	put_write_access(inode);
> Index: linux-2.6/fs/jfs/file.c
> ===================================================================
> --- linux-2.6.orig/fs/jfs/file.c	2010-02-20 11:55:53.857256072 +0100
> +++ linux-2.6/fs/jfs/file.c	2010-02-20 12:00:45.672027269 +0100
> @@ -48,7 +48,7 @@ static int jfs_open(struct inode *inode,
>  {
>  	int rc;
>  
> -	if ((rc = generic_file_open(inode, file)))
> +	if ((rc = dquot_file_open(inode, file)))
>  		return rc;
>  
>  	/*
> @@ -98,6 +98,8 @@ int jfs_setattr(struct dentry *dentry, s
>  	if (rc)
>  		return rc;
>  
> +	if (iattr->ia_valid & ATTR_SIZE)
> +		vfs_dq_init(inode);
>  	if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
>  	    (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
>  		rc = dquot_transfer(inode, iattr);
> Index: linux-2.6/fs/ext2/file.c
> ===================================================================
> --- linux-2.6.orig/fs/ext2/file.c	2010-02-20 11:40:48.399254325 +0100
> +++ linux-2.6/fs/ext2/file.c	2010-02-20 12:00:45.675031669 +0100
> @@ -70,7 +70,7 @@ const struct file_operations ext2_file_o
>  	.compat_ioctl	= ext2_compat_ioctl,
>  #endif
>  	.mmap		= generic_file_mmap,
> -	.open		= generic_file_open,
> +	.open		= dquot_file_open,
>  	.release	= ext2_release_file,
>  	.fsync		= ext2_fsync,
>  	.splice_read	= generic_file_splice_read,
> @@ -87,7 +87,7 @@ const struct file_operations ext2_xip_fi
>  	.compat_ioctl	= ext2_compat_ioctl,
>  #endif
>  	.mmap		= xip_file_mmap,
> -	.open		= generic_file_open,
> +	.open		= dquot_file_open,
>  	.release	= ext2_release_file,
>  	.fsync		= ext2_fsync,
>  };
> Index: linux-2.6/fs/ext3/file.c
> ===================================================================
> --- linux-2.6.orig/fs/ext3/file.c	2010-02-20 11:40:48.431254674 +0100
> +++ linux-2.6/fs/ext3/file.c	2010-02-20 12:00:45.679005408 +0100
> @@ -62,7 +62,7 @@ const struct file_operations ext3_file_o
>  	.compat_ioctl	= ext3_compat_ioctl,
>  #endif
>  	.mmap		= generic_file_mmap,
> -	.open		= generic_file_open,
> +	.open		= dquot_file_open,
>  	.release	= ext3_release_file,
>  	.fsync		= ext3_sync_file,
>  	.splice_read	= generic_file_splice_read,
> Index: linux-2.6/fs/ext4/file.c
> ===================================================================
> --- linux-2.6.orig/fs/ext4/file.c	2010-02-20 11:40:48.461254604 +0100
> +++ linux-2.6/fs/ext4/file.c	2010-02-20 12:00:45.682007294 +0100
> @@ -127,7 +127,7 @@ static int ext4_file_open(struct inode *
>  			sb->s_dirt = 1;
>  		}
>  	}
> -	return generic_file_open(inode, filp);
> +	return dquot_file_open(inode, filp);
>  }
>  
>  const struct file_operations ext4_file_operations = {
> Index: linux-2.6/fs/quota/dquot.c
> ===================================================================
> --- linux-2.6.orig/fs/quota/dquot.c	2010-02-20 11:59:10.787005967 +0100
> +++ linux-2.6/fs/quota/dquot.c	2010-02-20 12:00:45.687005339 +0100
> @@ -1821,6 +1821,20 @@ const struct dquot_operations dquot_oper
>  };
>  
>  /*
> + * Generic helper for ->open on filesystems supporting disk quotas.
> + */
> +int dquot_file_open(struct inode *inode, struct file *file)
> +{
> +	int error;
> +
> +	error = generic_file_open(inode, file);
> +	if (!error && (file->f_mode & FMODE_WRITE))
> +		vfs_dq_init(inode);
> +	return error;
> +}
> +EXPORT_SYMBOL(dquot_file_open);
> +
> +/*
>   * Turn quota off on a device. type == -1 ==> quotaoff for all types (umount)
>   */
>  int vfs_quota_disable(struct super_block *sb, int type, unsigned int flags)
> Index: linux-2.6/fs/reiserfs/file.c
> ===================================================================
> --- linux-2.6.orig/fs/reiserfs/file.c	2010-02-20 11:40:48.561275487 +0100
> +++ linux-2.6/fs/reiserfs/file.c	2010-02-20 12:00:45.697024196 +0100
> @@ -289,7 +289,7 @@ const struct file_operations reiserfs_fi
>  	.compat_ioctl = reiserfs_compat_ioctl,
>  #endif
>  	.mmap = reiserfs_file_mmap,
> -	.open = generic_file_open,
> +	.open = dquot_file_open,
>  	.release = reiserfs_file_release,
>  	.fsync = reiserfs_sync_file,
>  	.aio_read = generic_file_aio_read,
> Index: linux-2.6/fs/ufs/file.c
> ===================================================================
> --- linux-2.6.orig/fs/ufs/file.c	2010-02-20 11:40:48.590259424 +0100
> +++ linux-2.6/fs/ufs/file.c	2010-02-20 12:00:45.699274231 +0100
> @@ -40,7 +40,7 @@ const struct file_operations ufs_file_op
>  	.write		= do_sync_write,
>  	.aio_write	= generic_file_aio_write,
>  	.mmap		= generic_file_mmap,
> -	.open           = generic_file_open,
> +	.open           = dquot_file_open,
>  	.fsync		= simple_fsync,
>  	.splice_read	= generic_file_splice_read,
>  };
> Index: linux-2.6/include/linux/quotaops.h
> ===================================================================
> --- linux-2.6.orig/include/linux/quotaops.h	2010-02-20 11:59:10.821253697 +0100
> +++ linux-2.6/include/linux/quotaops.h	2010-02-20 12:00:45.701253558 +0100
> @@ -23,7 +23,7 @@ void inode_add_rsv_space(struct inode *i
>  void inode_claim_rsv_space(struct inode *inode, qsize_t number);
>  void inode_sub_rsv_space(struct inode *inode, qsize_t number);
>  
> -int dquot_initialize(struct inode *inode, int type);
> +void dquot_initialize(struct inode *inode);
>  void dquot_drop(struct inode *inode);
>  struct dquot *dqget(struct super_block *sb, unsigned int id, int type);
>  void dqput(struct dquot *dquot);
> @@ -48,6 +48,8 @@ int dquot_release(struct dquot *dquot);
>  int dquot_commit_info(struct super_block *sb, int type);
>  int dquot_mark_dquot_dirty(struct dquot *dquot);
>  
> +int dquot_file_open(struct inode *inode, struct file *file);
> +
>  int vfs_quota_on(struct super_block *sb, int type, int format_id,
>   	char *path, int remount);
>  int vfs_quota_enable(struct inode *inode, int type, int format_id,
> @@ -137,15 +139,6 @@ extern const struct quotactl_ops vfs_quo
>  #define sb_dquot_ops (&dquot_operations)
>  #define sb_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 vfs_dq_init(struct inode *inode)
> -{
> -	BUG_ON(!inode->i_sb);
> -	if (sb_any_quota_active(inode->i_sb) && !IS_NOQUOTA(inode))
> -		inode->i_sb->dq_op->initialize(inode, -1);
> -}
> -
>  /* Cannot be called inside a transaction */
>  static inline int vfs_dq_off(struct super_block *sb, int remount)
>  {
> @@ -205,7 +198,7 @@ static inline int sb_any_quota_active(st
>  #define sb_dquot_ops				(NULL)
>  #define sb_quotactl_ops				(NULL)
>  
> -static inline void vfs_dq_init(struct inode *inode)
> +static inline void dquot_initialize(struct inode *inode)
>  {
>  }
>  
> @@ -342,4 +335,6 @@ static inline void dquot_release_reserva
>  	__dquot_free_space(inode, nr << inode->i_blkbits, 1);
>  }
>  
> +#define dquot_file_open		generic_file_open
> +
>  #endif /* _LINUX_QUOTAOPS_ */
> 
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

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

* Re: [PATCH 4/8] dquot: cleanup dquot transfer routine
  2010-02-24 23:14   ` Jan Kara
@ 2010-03-01  9:50     ` Christoph Hellwig
  2010-03-01 10:40       ` Jan Kara
  0 siblings, 1 reply; 26+ messages in thread
From: Christoph Hellwig @ 2010-03-01  9:50 UTC (permalink / raw)
  To: Jan Kara; +Cc: Christoph Hellwig, linux-fsdevel

On Thu, Feb 25, 2010 at 12:14:14AM +0100, Jan Kara wrote:
> On Sat 20-02-10 06:51:05, Christoph Hellwig wrote:
> > Get rid of the transfer dquot operation - it is now always called from
> > the filesystem and if a filesystem really needs it's own (which none
> > currently does) it can just call into it's own routine directly.
> > 
> > Rename the now static low-level dquot_transfer helper to __dquot_transfer
> > and vfs_dq_transfer to dquot_transfer to have a consistent namespace,
> > and make the new dquot_transfer return a normal negative errno value
> > which all callers expect.
>   Looks good. I just wonder - if you made dquot_transfer() return error
> code, shouldn't also dquot_alloc_inode, dquot_alloc_space and similar
> return error code instead of 1? It would seem more consistent.

Probably - I can do that in another pass if you haven't done it yet.


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

* Re: [PATCH 4/8] dquot: cleanup dquot transfer routine
  2010-03-01  9:50     ` Christoph Hellwig
@ 2010-03-01 10:40       ` Jan Kara
  2010-03-01 11:20         ` Dmitry Monakhov
  0 siblings, 1 reply; 26+ messages in thread
From: Jan Kara @ 2010-03-01 10:40 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Jan Kara, linux-fsdevel

On Mon 01-03-10 04:50:52, Christoph Hellwig wrote:
> On Thu, Feb 25, 2010 at 12:14:14AM +0100, Jan Kara wrote:
> > On Sat 20-02-10 06:51:05, Christoph Hellwig wrote:
> > > Get rid of the transfer dquot operation - it is now always called from
> > > the filesystem and if a filesystem really needs it's own (which none
> > > currently does) it can just call into it's own routine directly.
> > > 
> > > Rename the now static low-level dquot_transfer helper to __dquot_transfer
> > > and vfs_dq_transfer to dquot_transfer to have a consistent namespace,
> > > and make the new dquot_transfer return a normal negative errno value
> > > which all callers expect.
> >   Looks good. I just wonder - if you made dquot_transfer() return error
> > code, shouldn't also dquot_alloc_inode, dquot_alloc_space and similar
> > return error code instead of 1? It would seem more consistent.
> 
> Probably - I can do that in another pass if you haven't done it yet.
  I've already done it. See commits
3a3d2903d3e9aaba9ca154606cf2f2613839b079 and
bff3333e868578990f6fe794a7cba0c74bd433ac in my linux-fs-2.6 tree.

									Honza

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

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

* Re: [PATCH 4/8] dquot: cleanup dquot transfer routine
  2010-03-01 10:40       ` Jan Kara
@ 2010-03-01 11:20         ` Dmitry Monakhov
  2010-03-01 13:45           ` Jan Kara
  0 siblings, 1 reply; 26+ messages in thread
From: Dmitry Monakhov @ 2010-03-01 11:20 UTC (permalink / raw)
  To: Jan Kara; +Cc: Christoph Hellwig, linux-fsdevel

Jan Kara <jack@suse.cz> writes:

> On Mon 01-03-10 04:50:52, Christoph Hellwig wrote:
>> On Thu, Feb 25, 2010 at 12:14:14AM +0100, Jan Kara wrote:
>> > On Sat 20-02-10 06:51:05, Christoph Hellwig wrote:
>> > > Get rid of the transfer dquot operation - it is now always called from
>> > > the filesystem and if a filesystem really needs it's own (which none
>> > > currently does) it can just call into it's own routine directly.
>> > > 
>> > > Rename the now static low-level dquot_transfer helper to __dquot_transfer
>> > > and vfs_dq_transfer to dquot_transfer to have a consistent namespace,
>> > > and make the new dquot_transfer return a normal negative errno value
>> > > which all callers expect.
>> >   Looks good. I just wonder - if you made dquot_transfer() return error
>> > code, shouldn't also dquot_alloc_inode, dquot_alloc_space and similar
>> > return error code instead of 1? It would seem more consistent.
>> 
>> Probably - I can do that in another pass if you haven't done it yet.
>   I've already done it. See commits
> 3a3d2903d3e9aaba9ca154606cf2f2613839b079 and
> bff3333e868578990f6fe794a7cba0c74bd433ac in my linux-fs-2.6 tree.
I can't find it, in what branch this commits belong?
May be i've pulled it in wrong way, but i cant find it in 
web fron-end too. Can you please provide a web link
>
> 									Honza

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

* Re: [PATCH 4/8] dquot: cleanup dquot transfer routine
  2010-03-01 11:20         ` Dmitry Monakhov
@ 2010-03-01 13:45           ` Jan Kara
  2010-03-01 14:18             ` commiting unreviewed patches, was " Christoph Hellwig
  0 siblings, 1 reply; 26+ messages in thread
From: Jan Kara @ 2010-03-01 13:45 UTC (permalink / raw)
  To: Dmitry Monakhov; +Cc: Jan Kara, Christoph Hellwig, linux-fsdevel

On Mon 01-03-10 14:20:19, Dmitry Monakhov wrote:
> Jan Kara <jack@suse.cz> writes:
> 
> > On Mon 01-03-10 04:50:52, Christoph Hellwig wrote:
> >> On Thu, Feb 25, 2010 at 12:14:14AM +0100, Jan Kara wrote:
> >> > On Sat 20-02-10 06:51:05, Christoph Hellwig wrote:
> >> > > Get rid of the transfer dquot operation - it is now always called from
> >> > > the filesystem and if a filesystem really needs it's own (which none
> >> > > currently does) it can just call into it's own routine directly.
> >> > > 
> >> > > Rename the now static low-level dquot_transfer helper to __dquot_transfer
> >> > > and vfs_dq_transfer to dquot_transfer to have a consistent namespace,
> >> > > and make the new dquot_transfer return a normal negative errno value
> >> > > which all callers expect.
> >> >   Looks good. I just wonder - if you made dquot_transfer() return error
> >> > code, shouldn't also dquot_alloc_inode, dquot_alloc_space and similar
> >> > return error code instead of 1? It would seem more consistent.
> >> 
> >> Probably - I can do that in another pass if you haven't done it yet.
> >   I've already done it. See commits
> > 3a3d2903d3e9aaba9ca154606cf2f2613839b079 and
> > bff3333e868578990f6fe794a7cba0c74bd433ac in my linux-fs-2.6 tree.
> I can't find it, in what branch this commits belong?
> May be i've pulled it in wrong way, but i cant find it in 
> web fron-end too. Can you please provide a web link
  Hmm, probably I was too tired on Wednesday and didn't push after
committing changes. Sorry for that. Now they are pushed. The web interface
should mirror them soon...
  They are in 'for_next' branch, subject lines:
dquot: cleanup inode allocation / freeing routines
dquot: cleanup space allocation / freeing routines

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

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

* commiting unreviewed patches, was Re: [PATCH 4/8] dquot: cleanup dquot transfer routine
  2010-03-01 13:45           ` Jan Kara
@ 2010-03-01 14:18             ` Christoph Hellwig
  2010-03-02 17:43               ` Jan Kara
  0 siblings, 1 reply; 26+ messages in thread
From: Christoph Hellwig @ 2010-03-01 14:18 UTC (permalink / raw)
  To: Jan Kara; +Cc: Dmitry Monakhov, Christoph Hellwig, linux-fsdevel

>   Hmm, probably I was too tired on Wednesday and didn't push after
> committing changes. Sorry for that. Now they are pushed. The web interface
> should mirror them soon...

Btw, I'd appreciate it if you would not commit unreviewed patches to
your trees.  E.g. commit 58b308dcac935d803618f9b06909d4355dfdf5b6
introduces a fishy and unessecary call to fsync_bdev which could
just be a sync_filesystem which even requires a workaround in commit
9007983e9bf994200194727bcb87d45bb924b4a8.  


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

* Re: commiting unreviewed patches, was Re: [PATCH 4/8] dquot: cleanup dquot transfer routine
  2010-03-01 14:18             ` commiting unreviewed patches, was " Christoph Hellwig
@ 2010-03-02 17:43               ` Jan Kara
  0 siblings, 0 replies; 26+ messages in thread
From: Jan Kara @ 2010-03-02 17:43 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Jan Kara, Dmitry Monakhov, linux-fsdevel

On Mon 01-03-10 09:18:26, Christoph Hellwig wrote:
> >   Hmm, probably I was too tired on Wednesday and didn't push after
> > committing changes. Sorry for that. Now they are pushed. The web interface
> > should mirror them soon...
> 
> Btw, I'd appreciate it if you would not commit unreviewed patches to
> your trees.  E.g. commit 58b308dcac935d803618f9b06909d4355dfdf5b6
> introduces a fishy and unessecary call to fsync_bdev which could
> just be a sync_filesystem which even requires a workaround in commit
> 9007983e9bf994200194727bcb87d45bb924b4a8.  
  Fair enough. I've created new branch for_testing in my tree where I'll
put patches like this which haven't been sent for review yet.
  Regarding this particular change, I've changed fsync_bdev to
sync_filesystem, removed 9007983e9bf994200194727bcb87d45bb924b4a8, and
sent the patch for review...

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

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

* Re: [PATCH 7/8] dquot: move dquot initialization responsibiliy into the filesystem
  2010-02-20 11:51 ` [PATCH 7/8] dquot: move dquot initialization responsibiliy into the filesystem Christoph Hellwig
  2010-02-25  0:29   ` Jan Kara
@ 2010-03-02 18:44   ` Jan Kara
  2010-03-02 19:50     ` Christoph Hellwig
  1 sibling, 1 reply; 26+ messages in thread
From: Jan Kara @ 2010-03-02 18:44 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: jack, linux-fsdevel

  Hi Christoph,

On Sat 20-02-10 06:51:08, Christoph Hellwig wrote:
> Currently various places in the VFS call vfs_dq_init directly.  This means
> we tie the quota code into the VFS.  Get rid of that and make the
> filesystem responsibly for the initialization.   For most metadata operations
> this is a straight forward move into the methods, but for truncate and
> open it's a bit more complicated.
> 
> For truncate we currently only call vfs_dq_init for the sys_truncate case
> because open already takes care of it for ftruncate and open(O_TRUNC) - the
> new code causes an additional vfs_dq_init for those which is harmless.
> 
> For open the initialization is moved from do_filp_open into the open method,
> which means it happens slightly earlier now, and only for regular files.
> The latter is fine because we don't need to initialize it for operations
> on special files, and we already do it as part of the namespace operations
> for directories.
> 
> Add a dquot_file_open helper that filesystems that support generic quotas
> can use to fill in ->open.
  I've looked at the patch. I have several comments:
It seems that conversion of UDF is completely missing from the patch.
Also it seems that UFS is missing conversion of ufs_setattr to call
vfs_dq_init when ATTR_SIZE is set. Finally, ocfs2 is missing conversion
of ocfs2_open so that it calls vfs_dq_init.
  Also I have two minor suggeestions for improvement below...

> Index: linux-2.6/fs/reiserfs/inode.c
> ===================================================================
> --- linux-2.6.orig/fs/reiserfs/inode.c	2010-02-20 11:59:10.802007224 +0100
> +++ linux-2.6/fs/reiserfs/inode.c	2010-02-20 12:00:45.554256073 +0100
> @@ -3073,6 +3076,8 @@ int reiserfs_setattr(struct dentry *dent
>  	ia_valid = attr->ia_valid &= ~(ATTR_KILL_SUID|ATTR_KILL_SGID);
>  
>  	depth = reiserfs_write_lock_once(inode->i_sb);
> +	if (ia_valid & ATTR_SIZE)
> +		vfs_dq_init(inode);
>  	if (attr->ia_valid & ATTR_SIZE) {
>  		/* version 2 items will be caught by the s_maxbytes check
>  		 ** done for us in vmtruncate
  We can merge the two conditions above.

> Index: linux-2.6/fs/ocfs2/file.c
> ===================================================================
> --- linux-2.6.orig/fs/ocfs2/file.c	2010-02-20 11:55:53.836005270 +0100
> +++ linux-2.6/fs/ocfs2/file.c	2010-02-20 12:00:45.648255722 +0100
> @@ -976,6 +979,9 @@ int ocfs2_setattr(struct dentry *dentry,
>  	if (status)
>  		return status;
>  
> +	if (attr->ia_valid & ATTR_SIZE)
> +		vfs_dq_init(inode);
> +
>  	size_change = S_ISREG(inode->i_mode) && attr->ia_valid & ATTR_SIZE;
>  	if (size_change) {
>  		status = ocfs2_rw_lock(inode, 1);
  We can merge the above two conditions...

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

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

* Re: [PATCH 7/8] dquot: move dquot initialization responsibiliy into the filesystem
  2010-03-02 18:44   ` Jan Kara
@ 2010-03-02 19:50     ` Christoph Hellwig
  2010-03-03  8:16       ` Jan Kara
  0 siblings, 1 reply; 26+ messages in thread
From: Christoph Hellwig @ 2010-03-02 19:50 UTC (permalink / raw)
  To: Jan Kara; +Cc: Christoph Hellwig, linux-fsdevel

On Tue, Mar 02, 2010 at 07:44:38PM +0100, Jan Kara wrote:
>   I've looked at the patch. I have several comments:
> It seems that conversion of UDF is completely missing from the patch.

Indeed.  UDF also got left out at least from the dquot transfer patch
which should have added one to it.  Do you want me to respin those
patches to include udf?

> Also it seems that UFS is missing conversion of ufs_setattr to call
> vfs_dq_init when ATTR_SIZE is set.

Indeed.  I'm pretty sure I did these, but can't find them in my patch
anymore.  Probably got lost to some quilt interaction.

> Finally, ocfs2 is missing conversion
> of ocfs2_open so that it calls vfs_dq_init.

ocfs2 calls vfs_dq_init manually.

> > +++ linux-2.6/fs/ocfs2/file.c	2010-02-20 12:00:45.648255722 +0100
> > @@ -976,6 +979,9 @@ int ocfs2_setattr(struct dentry *dentry,
> >  	if (status)
> >  		return status;
> >  
> > +	if (attr->ia_valid & ATTR_SIZE)
> > +		vfs_dq_init(inode);
> > +
> >  	size_change = S_ISREG(inode->i_mode) && attr->ia_valid & ATTR_SIZE;
> >  	if (size_change) {
> >  		status = ocfs2_rw_lock(inode, 1);
>   We can merge the above two conditions...

Ok.


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

* Re: [PATCH 7/8] dquot: move dquot initialization responsibiliy into the filesystem
  2010-03-02 19:50     ` Christoph Hellwig
@ 2010-03-03  8:16       ` Jan Kara
  2010-03-03 13:02         ` Christoph Hellwig
  0 siblings, 1 reply; 26+ messages in thread
From: Jan Kara @ 2010-03-03  8:16 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Jan Kara, linux-fsdevel

On Tue 02-03-10 14:50:40, Christoph Hellwig wrote:
> On Tue, Mar 02, 2010 at 07:44:38PM +0100, Jan Kara wrote:
> >   I've looked at the patch. I have several comments:
> > It seems that conversion of UDF is completely missing from the patch.
> 
> Indeed.  UDF also got left out at least from the dquot transfer patch
> which should have added one to it.  Do you want me to respin those
> patches to include udf?
  Yes, please respin dquot_transfer patches and dquot_drop seems to also
have the problem so those ones as well.

> > Also it seems that UFS is missing conversion of ufs_setattr to call
> > vfs_dq_init when ATTR_SIZE is set.
> 
> Indeed.  I'm pretty sure I did these, but can't find them in my patch
> anymore.  Probably got lost to some quilt interaction.
> 
> > Finally, ocfs2 is missing conversion
> > of ocfs2_open so that it calls vfs_dq_init.
> 
> ocfs2 calls vfs_dq_init manually.
  Ah, my fault, now I see it in the patch.

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

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

* Re: [PATCH 7/8] dquot: move dquot initialization responsibiliy into the filesystem
  2010-03-03  8:16       ` Jan Kara
@ 2010-03-03 13:02         ` Christoph Hellwig
  0 siblings, 0 replies; 26+ messages in thread
From: Christoph Hellwig @ 2010-03-03 13:02 UTC (permalink / raw)
  To: Jan Kara; +Cc: Christoph Hellwig, linux-fsdevel

On Wed, Mar 03, 2010 at 09:16:03AM +0100, Jan Kara wrote:
> On Tue 02-03-10 14:50:40, Christoph Hellwig wrote:
> > On Tue, Mar 02, 2010 at 07:44:38PM +0100, Jan Kara wrote:
> > >   I've looked at the patch. I have several comments:
> > > It seems that conversion of UDF is completely missing from the patch.
> > 
> > Indeed.  UDF also got left out at least from the dquot transfer patch
> > which should have added one to it.  Do you want me to respin those
> > patches to include udf?
>   Yes, please respin dquot_transfer patches and dquot_drop seems to also
> have the problem so those ones as well.

I'll just respin the whole series, with your changes to the first two
patches included.


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

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

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-20 11:51 [PATCH 0/8] dquot interface cleanups Christoph Hellwig
2010-02-20 11:51 ` [PATCH 1/8] dquot: cleanup space allocation / freeing routines Christoph Hellwig
2010-02-24 22:09   ` Jan Kara
2010-02-20 11:51 ` [PATCH 2/8] dquot: cleanup inode " Christoph Hellwig
2010-02-24 22:39   ` Jan Kara
2010-02-20 11:51 ` [PATCH 3/8] dquot: move dquot transfer responsibiliy into the filesystem Christoph Hellwig
2010-02-24 23:06   ` Jan Kara
2010-02-20 11:51 ` [PATCH 4/8] dquot: cleanup dquot transfer routine Christoph Hellwig
2010-02-24 23:14   ` Jan Kara
2010-03-01  9:50     ` Christoph Hellwig
2010-03-01 10:40       ` Jan Kara
2010-03-01 11:20         ` Dmitry Monakhov
2010-03-01 13:45           ` Jan Kara
2010-03-01 14:18             ` commiting unreviewed patches, was " Christoph Hellwig
2010-03-02 17:43               ` Jan Kara
2010-02-20 11:51 ` [PATCH 5/8] dquot: move dquot drop responsibiliy into the filesystem Christoph Hellwig
2010-02-25  0:00   ` Jan Kara
2010-02-20 11:51 ` [PATCH 6/8] dquot: cleanup dquot drop routine Christoph Hellwig
2010-02-25  0:08   ` Jan Kara
2010-02-20 11:51 ` [PATCH 7/8] dquot: move dquot initialization responsibiliy into the filesystem Christoph Hellwig
2010-02-25  0:29   ` Jan Kara
2010-03-02 18:44   ` Jan Kara
2010-03-02 19:50     ` Christoph Hellwig
2010-03-03  8:16       ` Jan Kara
2010-03-03 13:02         ` Christoph Hellwig
2010-02-20 11:51 ` [PATCH 8/8] dquot: cleanup dquot initialize routine Christoph Hellwig

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.