]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
quota: clean up quota active checks
authorChristoph Hellwig <hch@lst.de>
Fri, 4 Jun 2010 08:56:29 +0000 (10:56 +0200)
committerJan Kara <jack@suse.cz>
Wed, 21 Jul 2010 14:01:47 +0000 (16:01 +0200)
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.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
fs/quota/dquot.c
include/linux/quotaops.h

index 2857fd67ff33fe0a84da6e98c488d9bc6a643706..2eebf72d07c876b270517d966459e9efbf23be67 100644 (file)
@@ -1315,6 +1315,15 @@ static int info_bdq_free(struct dquot *dquot, qsize_t space)
        return 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
  *
@@ -1334,7 +1343,7 @@ static void __dquot_initialize(struct inode *inode, int type)
 
        /* 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. */
@@ -1518,7 +1527,7 @@ int __dquot_alloc_space(struct inode *inode, qsize_t number, int flags)
         * 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;
        }
@@ -1570,7 +1579,7 @@ int dquot_alloc_inode(const struct inode *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;
@@ -1607,7 +1616,7 @@ int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
 {
        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;
        }
@@ -1640,7 +1649,7 @@ void __dquot_free_space(struct inode *inode, qsize_t number, int flags)
 
        /* 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;
        }
@@ -1678,7 +1687,7 @@ void dquot_free_inode(const struct inode *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);
@@ -1801,7 +1810,7 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr)
        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 aa36793b48bd11b80b4b33765c7b7d074a899e7f..126193c1a5cef111c5602d1b455d8c4e1c7e55b5 100644 (file)
@@ -145,11 +145,6 @@ static inline bool sb_has_quota_active(struct super_block *sb, int type)
               !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.
  */
@@ -194,11 +189,6 @@ static inline int sb_has_quota_active(struct super_block *sb, int type)
        return 0;
 }
 
-static inline int sb_any_quota_active(struct super_block *sb)
-{
-       return 0;
-}
-
 static inline void dquot_initialize(struct inode *inode)
 {
 }