diff options
Diffstat (limited to 'fs/quota')
-rw-r--r-- | fs/quota/dquot.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index fbad622841f9..9a702e193538 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c | |||
@@ -1094,6 +1094,14 @@ static void dquot_claim_reserved_space(struct dquot *dquot, qsize_t number) | |||
1094 | dquot->dq_dqb.dqb_rsvspace -= number; | 1094 | dquot->dq_dqb.dqb_rsvspace -= number; |
1095 | } | 1095 | } |
1096 | 1096 | ||
1097 | static void dquot_reclaim_reserved_space(struct dquot *dquot, qsize_t number) | ||
1098 | { | ||
1099 | if (WARN_ON_ONCE(dquot->dq_dqb.dqb_curspace < number)) | ||
1100 | number = dquot->dq_dqb.dqb_curspace; | ||
1101 | dquot->dq_dqb.dqb_rsvspace += number; | ||
1102 | dquot->dq_dqb.dqb_curspace -= number; | ||
1103 | } | ||
1104 | |||
1097 | static inline | 1105 | static inline |
1098 | void dquot_free_reserved_space(struct dquot *dquot, qsize_t number) | 1106 | void dquot_free_reserved_space(struct dquot *dquot, qsize_t number) |
1099 | { | 1107 | { |
@@ -1528,6 +1536,15 @@ void inode_claim_rsv_space(struct inode *inode, qsize_t number) | |||
1528 | } | 1536 | } |
1529 | EXPORT_SYMBOL(inode_claim_rsv_space); | 1537 | EXPORT_SYMBOL(inode_claim_rsv_space); |
1530 | 1538 | ||
1539 | void inode_reclaim_rsv_space(struct inode *inode, qsize_t number) | ||
1540 | { | ||
1541 | spin_lock(&inode->i_lock); | ||
1542 | *inode_reserved_space(inode) += number; | ||
1543 | __inode_sub_bytes(inode, number); | ||
1544 | spin_unlock(&inode->i_lock); | ||
1545 | } | ||
1546 | EXPORT_SYMBOL(inode_reclaim_rsv_space); | ||
1547 | |||
1531 | void inode_sub_rsv_space(struct inode *inode, qsize_t number) | 1548 | void inode_sub_rsv_space(struct inode *inode, qsize_t number) |
1532 | { | 1549 | { |
1533 | spin_lock(&inode->i_lock); | 1550 | spin_lock(&inode->i_lock); |
@@ -1702,6 +1719,35 @@ int dquot_claim_space_nodirty(struct inode *inode, qsize_t number) | |||
1702 | EXPORT_SYMBOL(dquot_claim_space_nodirty); | 1719 | EXPORT_SYMBOL(dquot_claim_space_nodirty); |
1703 | 1720 | ||
1704 | /* | 1721 | /* |
1722 | * Convert allocated space back to in-memory reserved quotas | ||
1723 | */ | ||
1724 | void dquot_reclaim_space_nodirty(struct inode *inode, qsize_t number) | ||
1725 | { | ||
1726 | int cnt; | ||
1727 | |||
1728 | if (!dquot_active(inode)) { | ||
1729 | inode_reclaim_rsv_space(inode, number); | ||
1730 | return; | ||
1731 | } | ||
1732 | |||
1733 | down_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | ||
1734 | spin_lock(&dq_data_lock); | ||
1735 | /* Claim reserved quotas to allocated quotas */ | ||
1736 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | ||
1737 | if (inode->i_dquot[cnt]) | ||
1738 | dquot_reclaim_reserved_space(inode->i_dquot[cnt], | ||
1739 | number); | ||
1740 | } | ||
1741 | /* Update inode bytes */ | ||
1742 | inode_reclaim_rsv_space(inode, number); | ||
1743 | spin_unlock(&dq_data_lock); | ||
1744 | mark_all_dquot_dirty(inode->i_dquot); | ||
1745 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | ||
1746 | return; | ||
1747 | } | ||
1748 | EXPORT_SYMBOL(dquot_reclaim_space_nodirty); | ||
1749 | |||
1750 | /* | ||
1705 | * This operation can block, but only after everything is updated | 1751 | * This operation can block, but only after everything is updated |
1706 | */ | 1752 | */ |
1707 | void __dquot_free_space(struct inode *inode, qsize_t number, int flags) | 1753 | void __dquot_free_space(struct inode *inode, qsize_t number, int flags) |