aboutsummaryrefslogtreecommitdiffstats
path: root/fs/quota/dquot.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2010-06-04 04:56:29 -0400
committerJan Kara <jack@suse.cz>2010-07-21 10:01:47 -0400
commit189eef59e70e3e56edf726864629f310d114eefb (patch)
treeeff40faa6d8f4b103f10709892c1b47c8be6ae4e /fs/quota/dquot.c
parentade7ce31c22e961dfbe1a6d57fd362c90c187cbd (diff)
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. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/quota/dquot.c')
-rw-r--r--fs/quota/dquot.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 2857fd67ff33..2eebf72d07c8 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -1315,6 +1315,15 @@ static int info_bdq_free(struct dquot *dquot, qsize_t space)
1315 return QUOTA_NL_NOWARN; 1315 return QUOTA_NL_NOWARN;
1316} 1316}
1317 1317
1318static int dquot_active(const struct inode *inode)
1319{
1320 struct super_block *sb = inode->i_sb;
1321
1322 if (IS_NOQUOTA(inode))
1323 return 0;
1324 return sb_any_quota_loaded(sb) & ~sb_any_quota_suspended(sb);
1325}
1326
1318/* 1327/*
1319 * Initialize quota pointers in inode 1328 * Initialize quota pointers in inode
1320 * 1329 *
@@ -1334,7 +1343,7 @@ static void __dquot_initialize(struct inode *inode, int type)
1334 1343
1335 /* First test before acquiring mutex - solves deadlocks when we 1344 /* First test before acquiring mutex - solves deadlocks when we
1336 * re-enter the quota code and are already holding the mutex */ 1345 * re-enter the quota code and are already holding the mutex */
1337 if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode)) 1346 if (!dquot_active(inode))
1338 return; 1347 return;
1339 1348
1340 /* First get references to structures we might need. */ 1349 /* First get references to structures we might need. */
@@ -1518,7 +1527,7 @@ int __dquot_alloc_space(struct inode *inode, qsize_t number, int flags)
1518 * First test before acquiring mutex - solves deadlocks when we 1527 * First test before acquiring mutex - solves deadlocks when we
1519 * re-enter the quota code and are already holding the mutex 1528 * re-enter the quota code and are already holding the mutex
1520 */ 1529 */
1521 if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode)) { 1530 if (!dquot_active(inode)) {
1522 inode_incr_space(inode, number, reserve); 1531 inode_incr_space(inode, number, reserve);
1523 goto out; 1532 goto out;
1524 } 1533 }
@@ -1570,7 +1579,7 @@ int dquot_alloc_inode(const struct inode *inode)
1570 1579
1571 /* First test before acquiring mutex - solves deadlocks when we 1580 /* First test before acquiring mutex - solves deadlocks when we
1572 * re-enter the quota code and are already holding the mutex */ 1581 * re-enter the quota code and are already holding the mutex */
1573 if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode)) 1582 if (!dquot_active(inode))
1574 return 0; 1583 return 0;
1575 for (cnt = 0; cnt < MAXQUOTAS; cnt++) 1584 for (cnt = 0; cnt < MAXQUOTAS; cnt++)
1576 warntype[cnt] = QUOTA_NL_NOWARN; 1585 warntype[cnt] = QUOTA_NL_NOWARN;
@@ -1607,7 +1616,7 @@ int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
1607{ 1616{
1608 int cnt; 1617 int cnt;
1609 1618
1610 if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode)) { 1619 if (!dquot_active(inode)) {
1611 inode_claim_rsv_space(inode, number); 1620 inode_claim_rsv_space(inode, number);
1612 return 0; 1621 return 0;
1613 } 1622 }
@@ -1640,7 +1649,7 @@ void __dquot_free_space(struct inode *inode, qsize_t number, int flags)
1640 1649
1641 /* First test before acquiring mutex - solves deadlocks when we 1650 /* First test before acquiring mutex - solves deadlocks when we
1642 * re-enter the quota code and are already holding the mutex */ 1651 * re-enter the quota code and are already holding the mutex */
1643 if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode)) { 1652 if (!dquot_active(inode)) {
1644 inode_decr_space(inode, number, reserve); 1653 inode_decr_space(inode, number, reserve);
1645 return; 1654 return;
1646 } 1655 }
@@ -1678,7 +1687,7 @@ void dquot_free_inode(const struct inode *inode)
1678 1687
1679 /* First test before acquiring mutex - solves deadlocks when we 1688 /* First test before acquiring mutex - solves deadlocks when we
1680 * re-enter the quota code and are already holding the mutex */ 1689 * re-enter the quota code and are already holding the mutex */
1681 if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode)) 1690 if (!dquot_active(inode))
1682 return; 1691 return;
1683 1692
1684 down_read(&sb_dqopt(inode->i_sb)->dqptr_sem); 1693 down_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
@@ -1801,7 +1810,7 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr)
1801 struct super_block *sb = inode->i_sb; 1810 struct super_block *sb = inode->i_sb;
1802 int ret; 1811 int ret;
1803 1812
1804 if (!sb_any_quota_active(sb) || IS_NOQUOTA(inode)) 1813 if (!dquot_active(inode))
1805 return 0; 1814 return 0;
1806 1815
1807 if (iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) 1816 if (iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid)