diff options
author | Dmitry Monakhov <dmonakhov@openvz.org> | 2009-12-14 07:21:15 -0500 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2009-12-23 07:33:55 -0500 |
commit | dc52dd3a3a800e70b3440ea4424f8c87ab043e42 (patch) | |
tree | 1a4a0ba723065b8308db6597fe19cd0f73d5713a /fs/quota | |
parent | a9e7f4472075fb6937c545af3f6329e9946bbe66 (diff) |
quota: Move duplicated code to separate functions
- for(..) { mark_dquot_dirty(); } -> mark_all_dquot_dirty()
- for(..) { dput(); } -> dqput_all()
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/quota')
-rw-r--r-- | fs/quota/dquot.c | 77 |
1 files changed, 38 insertions, 39 deletions
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 1cb8fa84300f..dea86abdf2e7 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c | |||
@@ -323,6 +323,30 @@ int dquot_mark_dquot_dirty(struct dquot *dquot) | |||
323 | } | 323 | } |
324 | EXPORT_SYMBOL(dquot_mark_dquot_dirty); | 324 | EXPORT_SYMBOL(dquot_mark_dquot_dirty); |
325 | 325 | ||
326 | /* Dirtify all the dquots - this can block when journalling */ | ||
327 | static inline int mark_all_dquot_dirty(struct dquot * const *dquot) | ||
328 | { | ||
329 | int ret, err, cnt; | ||
330 | |||
331 | ret = err = 0; | ||
332 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | ||
333 | if (dquot[cnt]) | ||
334 | /* Even in case of error we have to continue */ | ||
335 | ret = mark_dquot_dirty(dquot[cnt]); | ||
336 | if (!err) | ||
337 | err = ret; | ||
338 | } | ||
339 | return err; | ||
340 | } | ||
341 | |||
342 | static inline void dqput_all(struct dquot **dquot) | ||
343 | { | ||
344 | unsigned int cnt; | ||
345 | |||
346 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) | ||
347 | dqput(dquot[cnt]); | ||
348 | } | ||
349 | |||
326 | /* This function needs dq_list_lock */ | 350 | /* This function needs dq_list_lock */ |
327 | static inline int clear_dquot_dirty(struct dquot *dquot) | 351 | static inline int clear_dquot_dirty(struct dquot *dquot) |
328 | { | 352 | { |
@@ -1268,8 +1292,7 @@ int dquot_initialize(struct inode *inode, int type) | |||
1268 | out_err: | 1292 | out_err: |
1269 | up_write(&sb_dqopt(sb)->dqptr_sem); | 1293 | up_write(&sb_dqopt(sb)->dqptr_sem); |
1270 | /* Drop unused references */ | 1294 | /* Drop unused references */ |
1271 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) | 1295 | dqput_all(got); |
1272 | dqput(got[cnt]); | ||
1273 | return ret; | 1296 | return ret; |
1274 | } | 1297 | } |
1275 | EXPORT_SYMBOL(dquot_initialize); | 1298 | EXPORT_SYMBOL(dquot_initialize); |
@@ -1288,9 +1311,7 @@ int dquot_drop(struct inode *inode) | |||
1288 | inode->i_dquot[cnt] = NULL; | 1311 | inode->i_dquot[cnt] = NULL; |
1289 | } | 1312 | } |
1290 | up_write(&sb_dqopt(inode->i_sb)->dqptr_sem); | 1313 | up_write(&sb_dqopt(inode->i_sb)->dqptr_sem); |
1291 | 1314 | dqput_all(put); | |
1292 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) | ||
1293 | dqput(put[cnt]); | ||
1294 | return 0; | 1315 | return 0; |
1295 | } | 1316 | } |
1296 | EXPORT_SYMBOL(dquot_drop); | 1317 | EXPORT_SYMBOL(dquot_drop); |
@@ -1439,10 +1460,7 @@ int __dquot_alloc_space(struct inode *inode, qsize_t number, | |||
1439 | 1460 | ||
1440 | if (reserve) | 1461 | if (reserve) |
1441 | goto out_flush_warn; | 1462 | goto out_flush_warn; |
1442 | /* Dirtify all the dquots - this can block when journalling */ | 1463 | mark_all_dquot_dirty(inode->i_dquot); |
1443 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) | ||
1444 | if (inode->i_dquot[cnt]) | ||
1445 | mark_dquot_dirty(inode->i_dquot[cnt]); | ||
1446 | out_flush_warn: | 1464 | out_flush_warn: |
1447 | flush_warnings(inode->i_dquot, warntype); | 1465 | flush_warnings(inode->i_dquot, warntype); |
1448 | out_unlock: | 1466 | out_unlock: |
@@ -1500,10 +1518,7 @@ int dquot_alloc_inode(const struct inode *inode, qsize_t number) | |||
1500 | warn_put_all: | 1518 | warn_put_all: |
1501 | spin_unlock(&dq_data_lock); | 1519 | spin_unlock(&dq_data_lock); |
1502 | if (ret == QUOTA_OK) | 1520 | if (ret == QUOTA_OK) |
1503 | /* Dirtify all the dquots - this can block when journalling */ | 1521 | mark_all_dquot_dirty(inode->i_dquot); |
1504 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) | ||
1505 | if (inode->i_dquot[cnt]) | ||
1506 | mark_dquot_dirty(inode->i_dquot[cnt]); | ||
1507 | flush_warnings(inode->i_dquot, warntype); | 1522 | flush_warnings(inode->i_dquot, warntype); |
1508 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | 1523 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); |
1509 | return ret; | 1524 | return ret; |
@@ -1537,10 +1552,7 @@ int dquot_claim_space(struct inode *inode, qsize_t number) | |||
1537 | /* Update inode bytes */ | 1552 | /* Update inode bytes */ |
1538 | inode_claim_rsv_space(inode, number); | 1553 | inode_claim_rsv_space(inode, number); |
1539 | spin_unlock(&dq_data_lock); | 1554 | spin_unlock(&dq_data_lock); |
1540 | /* Dirtify all the dquots - this can block when journalling */ | 1555 | mark_all_dquot_dirty(inode->i_dquot); |
1541 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) | ||
1542 | if (inode->i_dquot[cnt]) | ||
1543 | mark_dquot_dirty(inode->i_dquot[cnt]); | ||
1544 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | 1556 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); |
1545 | out: | 1557 | out: |
1546 | return ret; | 1558 | return ret; |
@@ -1584,10 +1596,7 @@ out_sub: | |||
1584 | 1596 | ||
1585 | if (reserve) | 1597 | if (reserve) |
1586 | goto out_unlock; | 1598 | goto out_unlock; |
1587 | /* Dirtify all the dquots - this can block when journalling */ | 1599 | mark_all_dquot_dirty(inode->i_dquot); |
1588 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) | ||
1589 | if (inode->i_dquot[cnt]) | ||
1590 | mark_dquot_dirty(inode->i_dquot[cnt]); | ||
1591 | out_unlock: | 1600 | out_unlock: |
1592 | flush_warnings(inode->i_dquot, warntype); | 1601 | flush_warnings(inode->i_dquot, warntype); |
1593 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | 1602 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); |
@@ -1637,10 +1646,7 @@ int dquot_free_inode(const struct inode *inode, qsize_t number) | |||
1637 | dquot_decr_inodes(inode->i_dquot[cnt], number); | 1646 | dquot_decr_inodes(inode->i_dquot[cnt], number); |
1638 | } | 1647 | } |
1639 | spin_unlock(&dq_data_lock); | 1648 | spin_unlock(&dq_data_lock); |
1640 | /* Dirtify all the dquots - this can block when journalling */ | 1649 | mark_all_dquot_dirty(inode->i_dquot); |
1641 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) | ||
1642 | if (inode->i_dquot[cnt]) | ||
1643 | mark_dquot_dirty(inode->i_dquot[cnt]); | ||
1644 | flush_warnings(inode->i_dquot, warntype); | 1650 | flush_warnings(inode->i_dquot, warntype); |
1645 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); | 1651 | up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); |
1646 | return QUOTA_OK; | 1652 | return QUOTA_OK; |
@@ -1734,25 +1740,18 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr) | |||
1734 | spin_unlock(&dq_data_lock); | 1740 | spin_unlock(&dq_data_lock); |
1735 | up_write(&sb_dqopt(inode->i_sb)->dqptr_sem); | 1741 | up_write(&sb_dqopt(inode->i_sb)->dqptr_sem); |
1736 | 1742 | ||
1737 | /* Dirtify all the dquots - this can block when journalling */ | 1743 | mark_all_dquot_dirty(transfer_from); |
1738 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | 1744 | mark_all_dquot_dirty(transfer_to); |
1739 | if (transfer_from[cnt]) | 1745 | /* The reference we got is transferred to the inode */ |
1740 | mark_dquot_dirty(transfer_from[cnt]); | 1746 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) |
1741 | if (transfer_to[cnt]) { | 1747 | transfer_to[cnt] = NULL; |
1742 | mark_dquot_dirty(transfer_to[cnt]); | ||
1743 | /* The reference we got is transferred to the inode */ | ||
1744 | transfer_to[cnt] = NULL; | ||
1745 | } | ||
1746 | } | ||
1747 | warn_put_all: | 1748 | warn_put_all: |
1748 | flush_warnings(transfer_to, warntype_to); | 1749 | flush_warnings(transfer_to, warntype_to); |
1749 | flush_warnings(transfer_from, warntype_from_inodes); | 1750 | flush_warnings(transfer_from, warntype_from_inodes); |
1750 | flush_warnings(transfer_from, warntype_from_space); | 1751 | flush_warnings(transfer_from, warntype_from_space); |
1751 | put_all: | 1752 | put_all: |
1752 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | 1753 | dqput_all(transfer_from); |
1753 | dqput(transfer_from[cnt]); | 1754 | dqput_all(transfer_to); |
1754 | dqput(transfer_to[cnt]); | ||
1755 | } | ||
1756 | return ret; | 1755 | return ret; |
1757 | over_quota: | 1756 | over_quota: |
1758 | spin_unlock(&dq_data_lock); | 1757 | spin_unlock(&dq_data_lock); |