diff options
author | Christoph Hellwig <hch@infradead.org> | 2010-03-03 09:05:01 -0500 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2010-03-04 18:20:28 -0500 |
commit | 63936ddaa16b9486e2d426ed7b09f559a5c60f87 (patch) | |
tree | 4cb1c4581799e10c26dd71d1a7d420de3c2cfd05 /fs/quota/dquot.c | |
parent | 5dd4056db84387975140ff2568eaa0406f07985e (diff) |
dquot: cleanup inode allocation / freeing routines
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>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/quota/dquot.c')
-rw-r--r-- | fs/quota/dquot.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index baf202c012cc..ed131318b849 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c | |||
@@ -1531,15 +1531,15 @@ EXPORT_SYMBOL(__dquot_alloc_space); | |||
1531 | /* | 1531 | /* |
1532 | * This operation can block, but only after everything is updated | 1532 | * This operation can block, but only after everything is updated |
1533 | */ | 1533 | */ |
1534 | int dquot_alloc_inode(const struct inode *inode, qsize_t number) | 1534 | int dquot_alloc_inode(const struct inode *inode) |
1535 | { | 1535 | { |
1536 | int cnt, ret = NO_QUOTA; | 1536 | int cnt, ret = -EDQUOT; |
1537 | char warntype[MAXQUOTAS]; | 1537 | char warntype[MAXQUOTAS]; |
1538 | 1538 | ||
1539 | /* First test before acquiring mutex - solves deadlocks when we | 1539 | /* First test before acquiring mutex - solves deadlocks when we |
1540 | * re-enter the quota code and are already holding the mutex */ | 1540 | * re-enter the quota code and are already holding the mutex */ |
1541 | if (IS_NOQUOTA(inode)) | 1541 | if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode)) |
1542 | return QUOTA_OK; | 1542 | return 0; |
1543 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) | 1543 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) |
1544 | warntype[cnt] = QUOTA_NL_NOWARN; | 1544 | warntype[cnt] = QUOTA_NL_NOWARN; |
1545 | down_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | 1545 | down_read(&sb_dqopt(inode->i_sb)->dqptr_sem); |
@@ -1547,7 +1547,7 @@ int dquot_alloc_inode(const struct inode *inode, qsize_t number) | |||
1547 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | 1547 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { |
1548 | if (!inode->i_dquot[cnt]) | 1548 | if (!inode->i_dquot[cnt]) |
1549 | continue; | 1549 | continue; |
1550 | if (check_idq(inode->i_dquot[cnt], number, warntype+cnt) | 1550 | if (check_idq(inode->i_dquot[cnt], 1, warntype+cnt) |
1551 | == NO_QUOTA) | 1551 | == NO_QUOTA) |
1552 | goto warn_put_all; | 1552 | goto warn_put_all; |
1553 | } | 1553 | } |
@@ -1555,12 +1555,12 @@ int dquot_alloc_inode(const struct inode *inode, qsize_t number) | |||
1555 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | 1555 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { |
1556 | if (!inode->i_dquot[cnt]) | 1556 | if (!inode->i_dquot[cnt]) |
1557 | continue; | 1557 | continue; |
1558 | dquot_incr_inodes(inode->i_dquot[cnt], number); | 1558 | dquot_incr_inodes(inode->i_dquot[cnt], 1); |
1559 | } | 1559 | } |
1560 | ret = QUOTA_OK; | 1560 | ret = 0; |
1561 | warn_put_all: | 1561 | warn_put_all: |
1562 | spin_unlock(&dq_data_lock); | 1562 | spin_unlock(&dq_data_lock); |
1563 | if (ret == QUOTA_OK) | 1563 | if (ret == 0) |
1564 | mark_all_dquot_dirty(inode->i_dquot); | 1564 | mark_all_dquot_dirty(inode->i_dquot); |
1565 | flush_warnings(inode->i_dquot, warntype); | 1565 | flush_warnings(inode->i_dquot, warntype); |
1566 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | 1566 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); |
@@ -1638,29 +1638,28 @@ EXPORT_SYMBOL(__dquot_free_space); | |||
1638 | /* | 1638 | /* |
1639 | * This operation can block, but only after everything is updated | 1639 | * This operation can block, but only after everything is updated |
1640 | */ | 1640 | */ |
1641 | int dquot_free_inode(const struct inode *inode, qsize_t number) | 1641 | void dquot_free_inode(const struct inode *inode) |
1642 | { | 1642 | { |
1643 | unsigned int cnt; | 1643 | unsigned int cnt; |
1644 | char warntype[MAXQUOTAS]; | 1644 | char warntype[MAXQUOTAS]; |
1645 | 1645 | ||
1646 | /* First test before acquiring mutex - solves deadlocks when we | 1646 | /* First test before acquiring mutex - solves deadlocks when we |
1647 | * re-enter the quota code and are already holding the mutex */ | 1647 | * re-enter the quota code and are already holding the mutex */ |
1648 | if (IS_NOQUOTA(inode)) | 1648 | if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode)) |
1649 | return QUOTA_OK; | 1649 | return; |
1650 | 1650 | ||
1651 | down_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | 1651 | down_read(&sb_dqopt(inode->i_sb)->dqptr_sem); |
1652 | spin_lock(&dq_data_lock); | 1652 | spin_lock(&dq_data_lock); |
1653 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | 1653 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { |
1654 | if (!inode->i_dquot[cnt]) | 1654 | if (!inode->i_dquot[cnt]) |
1655 | continue; | 1655 | continue; |
1656 | warntype[cnt] = info_idq_free(inode->i_dquot[cnt], number); | 1656 | warntype[cnt] = info_idq_free(inode->i_dquot[cnt], 1); |
1657 | dquot_decr_inodes(inode->i_dquot[cnt], number); | 1657 | dquot_decr_inodes(inode->i_dquot[cnt], 1); |
1658 | } | 1658 | } |
1659 | spin_unlock(&dq_data_lock); | 1659 | spin_unlock(&dq_data_lock); |
1660 | mark_all_dquot_dirty(inode->i_dquot); | 1660 | mark_all_dquot_dirty(inode->i_dquot); |
1661 | flush_warnings(inode->i_dquot, warntype); | 1661 | flush_warnings(inode->i_dquot, warntype); |
1662 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | 1662 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); |
1663 | return QUOTA_OK; | ||
1664 | } | 1663 | } |
1665 | EXPORT_SYMBOL(dquot_free_inode); | 1664 | EXPORT_SYMBOL(dquot_free_inode); |
1666 | 1665 | ||
@@ -1815,8 +1814,6 @@ EXPORT_SYMBOL(dquot_commit_info); | |||
1815 | const struct dquot_operations dquot_operations = { | 1814 | const struct dquot_operations dquot_operations = { |
1816 | .initialize = dquot_initialize, | 1815 | .initialize = dquot_initialize, |
1817 | .drop = dquot_drop, | 1816 | .drop = dquot_drop, |
1818 | .alloc_inode = dquot_alloc_inode, | ||
1819 | .free_inode = dquot_free_inode, | ||
1820 | .transfer = dquot_transfer, | 1817 | .transfer = dquot_transfer, |
1821 | .write_dquot = dquot_commit, | 1818 | .write_dquot = dquot_commit, |
1822 | .acquire_dquot = dquot_acquire, | 1819 | .acquire_dquot = dquot_acquire, |