quota: clean up quota active checks
PATCH 1/1 quota: clean up quota active checks
The various quota operations check for any quota beeing active on a superblock, and the inode not having the noquota flag.
Merge these two checks into a dquot_active check and move that into dquot.c as that's the only place where it's needed.
fs/quota/dquot.c +16 -7
@@ -1304,6 +1304,15 @@ static int info_bdq_free(struct dquot *dreturn QUOTA_NL_NOWARN ; } +static int dquot_active (const struct inode *inode) +{ +struct super_block *sb = inode->i_sb; + +if (!IS_NOQUOTA (inode)) +return 0 ; +return sb_any_quota_loaded (sb) & ~sb_any_quota_suspended (sb); +} +/* * Initialize quota pointers in inode *
@@ -1323,7 +1332,7 @@ static void __dquot_initialize(struct in/* First test before acquiring mutex - solves deadlocks when we * re-enter the quota code and are already holding the mutex */ -if (!sb_any_quota_active (inode->i_sb) ||IS_NOQUOTA (inode)) +if (!dquot_active (inode))return ;/* First get references to structures we might need. */
@@ -1507,7 +1516,7 @@ int __dquot_alloc_space(struct inode *in* First test before acquiring mutex - solves deadlocks when we * re-enter the quota code and are already holding the mutex */ -if (!sb_any_quota_active (inode->i_sb) ||IS_NOQUOTA (inode)) { +if (!dquot_active (inode)) {inode_incr_space (inode, number, reserve); goto out; }
@@ -1559,7 +1568,7 @@ int dquot_alloc_inode(const struct inode/* First test before acquiring mutex - solves deadlocks when we * re-enter the quota code and are already holding the mutex */ -if (!sb_any_quota_active (inode->i_sb) ||IS_NOQUOTA (inode)) +if (!dquot_active (inode))return 0 ;for (cnt =0 ; cnt <MAXQUOTAS ; cnt++) warntype[cnt] =QUOTA_NL_NOWARN ;
@@ -1596,7 +1605,7 @@ int dquot_claim_space_nodirty(struct ino {int cnt; -if (!sb_any_quota_active (inode->i_sb) ||IS_NOQUOTA (inode)) { +if (!dquot_active (inode)) {inode_claim_rsv_space (inode, number);return 0 ; }
@@ -1629,7 +1638,7 @@ void __dquot_free_space(struct inode *in/* First test before acquiring mutex - solves deadlocks when we * re-enter the quota code and are already holding the mutex */ -if (!sb_any_quota_active (inode->i_sb) ||IS_NOQUOTA (inode)) { +if (!dquot_active (inode)) {inode_decr_space (inode, number, reserve);return ; }
@@ -1667,7 +1676,7 @@ void dquot_free_inode(const struct inode/* First test before acquiring mutex - solves deadlocks when we * re-enter the quota code and are already holding the mutex */ -if (!sb_any_quota_active (inode->i_sb) ||IS_NOQUOTA (inode)) +if (!dquot_active (inode))return ;down_read (&sb_dqopt (inode->i_sb)->dqptr_sem);
@@ -1790,7 +1799,7 @@ int dquot_transfer(struct inode *inode,struct super_block *sb = inode->i_sb;int ret; -if (!sb_any_quota_active (sb) ||IS_NOQUOTA (inode)) +if (!dquot_active (inode))return 0 ;if (iattr->ia_valid &ATTR_UID && iattr->ia_uid != inode->i_uid)
include/linux/quotaops.h +0 -10
@@ -145,11 +145,6 @@ static inline bool sb_has_quota_active(s !sb_has_quota_suspended (sb, type); } -static inline unsigned sb_any_quota_active (struct super_block *sb) -{ -return sb_any_quota_loaded (sb) & ~sb_any_quota_suspended (sb); -} -/* * Operations supported for diskquotas. */
@@ -193,11 +188,6 @@ static inline int sb_has_quota_active(st {return 0 ; } - -static inline int sb_any_quota_active (struct super_block *sb) -{ -return 0 ; -}static inline void dquot_initialize (struct inode *inode) {
Jan Kara
reviewerQuoted 6 lines · Christoph Hellwig
The various quota operations check for any quota beeing active on a superblock, and the inode not having the noquota flag.
Merge these two checks into a
dquot_activecheck and move that intodquot.cas that's the only place where it's needed.
Thanks. Merged.
Honza
Quoted 114 lines
Signed-off-by Christoph Hellwig <[email protected]>Index:
linux-2.6/fs/quota/dquot.c
===================================================================fs/quota/dquot.c +16
-7@@ -1304,6 +1304,15 @@ static int info_bdq_free(struct dquot *dreturn QUOTA_NL_NOWARN ; } +static int dquot_active (const struct inode *inode) +{ +struct super_block *sb = inode->i_sb; + +if (!IS_NOQUOTA (inode)) +return 0 ; +return sb_any_quota_loaded (sb) & ~sb_any_quota_suspended (sb); +} +/* * Initialize quota pointers in inode * @@ -1323,7 +1332,7 @@ static void __dquot_initialize(struct in/* First test before acquiring mutex - solves deadlocks when we * re-enter the quota code and are already holding the mutex */ -if (!sb_any_quota_active (inode->i_sb) ||IS_NOQUOTA (inode)) +if (!dquot_active (inode))return ;/* First get references to structures we might need. */ @@ -1507,7 +1516,7 @@ int __dquot_alloc_space(struct inode *in* First test before acquiring mutex - solves deadlocks when we * re-enter the quota code and are already holding the mutex */ -if (!sb_any_quota_active (inode->i_sb) ||IS_NOQUOTA (inode)) { +if (!dquot_active (inode)) {inode_incr_space (inode, number, reserve); goto out; }@@ -1559,7 +1568,7 @@ int dquot_alloc_inode(const struct inode/* First test before acquiring mutex - solves deadlocks when we * re-enter the quota code and are already holding the mutex */ -if (!sb_any_quota_active (inode->i_sb) ||IS_NOQUOTA (inode)) +if (!dquot_active (inode))return 0 ;for (cnt =0 ; cnt <MAXQUOTAS ; cnt++) warntype[cnt] =QUOTA_NL_NOWARN ;@@ -1596,7 +1605,7 @@ int dquot_claim_space_nodirty(struct ino {int cnt; -if (!sb_any_quota_active (inode->i_sb) ||IS_NOQUOTA (inode)) { +if (!dquot_active (inode)) {inode_claim_rsv_space (inode, number);return 0 ; }@@ -1629,7 +1638,7 @@ void __dquot_free_space(struct inode *in/* First test before acquiring mutex - solves deadlocks when we * re-enter the quota code and are already holding the mutex */ -if (!sb_any_quota_active (inode->i_sb) ||IS_NOQUOTA (inode)) { +if (!dquot_active (inode)) {inode_decr_space (inode, number, reserve);return ; }@@ -1667,7 +1676,7 @@ void dquot_free_inode(const struct inode/* First test before acquiring mutex - solves deadlocks when we * re-enter the quota code and are already holding the mutex */ -if (!sb_any_quota_active (inode->i_sb) ||IS_NOQUOTA (inode)) +if (!dquot_active (inode))return ;down_read (&sb_dqopt (inode->i_sb)->dqptr_sem);@@ -1790,7 +1799,7 @@ int dquot_transfer(struct inode *inode,struct super_block *sb = inode->i_sb;int ret; -if (!sb_any_quota_active (sb) ||IS_NOQUOTA (inode)) +if (!dquot_active (inode))return 0 ;if (iattr->ia_valid &ATTR_UID && iattr->ia_uid != inode->i_uid)Index:
linux-2.6/include/linux/quotaops.h
===================================================================include/linux/quotaops.h +0
-10@@ -145,11 +145,6 @@ static inline bool sb_has_quota_active(s !sb_has_quota_suspended (sb, type); } -static inline unsigned sb_any_quota_active (struct super_block *sb) -{ -return sb_any_quota_loaded (sb) & ~sb_any_quota_suspended (sb); -} -/* * Operations supported for diskquotas. */ @@ -193,11 +188,6 @@ static inline int sb_has_quota_active(st {return 0 ; } - -static inline int sb_any_quota_active (struct super_block *sb) -{ -return 0 ; -}static inline void dquot_initialize (struct inode *inode) {
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Jan Kara
reviewerQuoted 8 lines · Jan Kara
Quoted 6 lines · Christoph Hellwig
The various quota operations check for any quota beeing active on a superblock, and the inode not having the noquota flag.
Merge these two checks into a
dquot_activecheck and move that intodquot.cas that's the only place where it's needed.Thanks. Merged.
Except that IS_NOQUOTA check was reversed so no quota was actually
ever accounted... Grumble... Fixed that.
Honza
Quoted 117 lines
Quoted 114 lines
Signed-off-by Christoph Hellwig <[email protected]>Index:
linux-2.6/fs/quota/dquot.c
===================================================================fs/quota/dquot.c +16
-7@@ -1304,6 +1304,15 @@ static int info_bdq_free(struct dquot *dreturn QUOTA_NL_NOWARN ; } +static int dquot_active (const struct inode *inode) +{ +struct super_block *sb = inode->i_sb; + +if (!IS_NOQUOTA (inode)) +return 0 ; +return sb_any_quota_loaded (sb) & ~sb_any_quota_suspended (sb); +} +/* * Initialize quota pointers in inode * @@ -1323,7 +1332,7 @@ static void __dquot_initialize(struct in/* First test before acquiring mutex - solves deadlocks when we * re-enter the quota code and are already holding the mutex */ -if (!sb_any_quota_active (inode->i_sb) ||IS_NOQUOTA (inode)) +if (!dquot_active (inode))return ;/* First get references to structures we might need. */ @@ -1507,7 +1516,7 @@ int __dquot_alloc_space(struct inode *in* First test before acquiring mutex - solves deadlocks when we * re-enter the quota code and are already holding the mutex */ -if (!sb_any_quota_active (inode->i_sb) ||IS_NOQUOTA (inode)) { +if (!dquot_active (inode)) {inode_incr_space (inode, number, reserve); goto out; }@@ -1559,7 +1568,7 @@ int dquot_alloc_inode(const struct inode/* First test before acquiring mutex - solves deadlocks when we * re-enter the quota code and are already holding the mutex */ -if (!sb_any_quota_active (inode->i_sb) ||IS_NOQUOTA (inode)) +if (!dquot_active (inode))return 0 ;for (cnt =0 ; cnt <MAXQUOTAS ; cnt++) warntype[cnt] =QUOTA_NL_NOWARN ;@@ -1596,7 +1605,7 @@ int dquot_claim_space_nodirty(struct ino {int cnt; -if (!sb_any_quota_active (inode->i_sb) ||IS_NOQUOTA (inode)) { +if (!dquot_active (inode)) {inode_claim_rsv_space (inode, number);return 0 ; }@@ -1629,7 +1638,7 @@ void __dquot_free_space(struct inode *in/* First test before acquiring mutex - solves deadlocks when we * re-enter the quota code and are already holding the mutex */ -if (!sb_any_quota_active (inode->i_sb) ||IS_NOQUOTA (inode)) { +if (!dquot_active (inode)) {inode_decr_space (inode, number, reserve);return ; }@@ -1667,7 +1676,7 @@ void dquot_free_inode(const struct inode/* First test before acquiring mutex - solves deadlocks when we * re-enter the quota code and are already holding the mutex */ -if (!sb_any_quota_active (inode->i_sb) ||IS_NOQUOTA (inode)) +if (!dquot_active (inode))return ;down_read (&sb_dqopt (inode->i_sb)->dqptr_sem);@@ -1790,7 +1799,7 @@ int dquot_transfer(struct inode *inode,struct super_block *sb = inode->i_sb;int ret; -if (!sb_any_quota_active (sb) ||IS_NOQUOTA (inode)) +if (!dquot_active (inode))return 0 ;if (iattr->ia_valid &ATTR_UID && iattr->ia_uid != inode->i_uid)Index:
linux-2.6/include/linux/quotaops.h
===================================================================include/linux/quotaops.h +0
-10@@ -145,11 +145,6 @@ static inline bool sb_has_quota_active(s !sb_has_quota_suspended (sb, type); } -static inline unsigned sb_any_quota_active (struct super_block *sb) -{ -return sb_any_quota_loaded (sb) & ~sb_any_quota_suspended (sb); -} -/* * Operations supported for diskquotas. */ @@ -193,11 +188,6 @@ static inline int sb_has_quota_active(st {return 0 ; } - -static inline int sb_any_quota_active (struct super_block *sb) -{ -return 0 ; -}static inline void dquot_initialize (struct inode *inode) {Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR