Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Dmitry Monakhov and committed by
Jan Kara
dc52dd3a a9e7f447

+38 -39
+38 -39
fs/quota/dquot.c
··· 323 323 } 324 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 350 /* This function needs dq_list_lock */ 327 351 static inline int clear_dquot_dirty(struct dquot *dquot) 328 352 { ··· 1292 1268 out_err: 1293 1269 up_write(&sb_dqopt(sb)->dqptr_sem); 1294 1270 /* Drop unused references */ 1295 - for (cnt = 0; cnt < MAXQUOTAS; cnt++) 1296 - dqput(got[cnt]); 1271 + dqput_all(got); 1297 1272 return ret; 1298 1273 } 1299 1274 EXPORT_SYMBOL(dquot_initialize); ··· 1311 1288 inode->i_dquot[cnt] = NULL; 1312 1289 } 1313 1290 up_write(&sb_dqopt(inode->i_sb)->dqptr_sem); 1314 - 1315 - for (cnt = 0; cnt < MAXQUOTAS; cnt++) 1316 - dqput(put[cnt]); 1291 + dqput_all(put); 1317 1292 return 0; 1318 1293 } 1319 1294 EXPORT_SYMBOL(dquot_drop); ··· 1460 1439 1461 1440 if (reserve) 1462 1441 goto out_flush_warn; 1463 - /* Dirtify all the dquots - this can block when journalling */ 1464 - for (cnt = 0; cnt < MAXQUOTAS; cnt++) 1465 - if (inode->i_dquot[cnt]) 1466 - mark_dquot_dirty(inode->i_dquot[cnt]); 1442 + mark_all_dquot_dirty(inode->i_dquot); 1467 1443 out_flush_warn: 1468 1444 flush_warnings(inode->i_dquot, warntype); 1469 1445 out_unlock: ··· 1518 1500 warn_put_all: 1519 1501 spin_unlock(&dq_data_lock); 1520 1502 if (ret == QUOTA_OK) 1521 - /* Dirtify all the dquots - this can block when journalling */ 1522 - for (cnt = 0; cnt < MAXQUOTAS; cnt++) 1523 - if (inode->i_dquot[cnt]) 1524 - mark_dquot_dirty(inode->i_dquot[cnt]); 1503 + mark_all_dquot_dirty(inode->i_dquot); 1525 1504 flush_warnings(inode->i_dquot, warntype); 1526 1505 up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); 1527 1506 return ret; ··· 1552 1537 /* Update inode bytes */ 1553 1538 inode_claim_rsv_space(inode, number); 1554 1539 spin_unlock(&dq_data_lock); 1555 - /* Dirtify all the dquots - this can block when journalling */ 1556 - for (cnt = 0; cnt < MAXQUOTAS; cnt++) 1557 - if (inode->i_dquot[cnt]) 1558 - mark_dquot_dirty(inode->i_dquot[cnt]); 1540 + mark_all_dquot_dirty(inode->i_dquot); 1559 1541 up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); 1560 1542 out: 1561 1543 return ret; ··· 1596 1584 1597 1585 if (reserve) 1598 1586 goto out_unlock; 1599 - /* Dirtify all the dquots - this can block when journalling */ 1600 - for (cnt = 0; cnt < MAXQUOTAS; cnt++) 1601 - if (inode->i_dquot[cnt]) 1602 - mark_dquot_dirty(inode->i_dquot[cnt]); 1587 + mark_all_dquot_dirty(inode->i_dquot); 1603 1588 out_unlock: 1604 1589 flush_warnings(inode->i_dquot, warntype); 1605 1590 up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); ··· 1646 1637 dquot_decr_inodes(inode->i_dquot[cnt], number); 1647 1638 } 1648 1639 spin_unlock(&dq_data_lock); 1649 - /* Dirtify all the dquots - this can block when journalling */ 1650 - for (cnt = 0; cnt < MAXQUOTAS; cnt++) 1651 - if (inode->i_dquot[cnt]) 1652 - mark_dquot_dirty(inode->i_dquot[cnt]); 1640 + mark_all_dquot_dirty(inode->i_dquot); 1653 1641 flush_warnings(inode->i_dquot, warntype); 1654 1642 up_read(&sb_dqopt(inode->i_sb)->dqptr_sem); 1655 1643 return QUOTA_OK; ··· 1740 1734 spin_unlock(&dq_data_lock); 1741 1735 up_write(&sb_dqopt(inode->i_sb)->dqptr_sem); 1742 1736 1743 - /* Dirtify all the dquots - this can block when journalling */ 1744 - for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 1745 - if (transfer_from[cnt]) 1746 - mark_dquot_dirty(transfer_from[cnt]); 1747 - if (transfer_to[cnt]) { 1748 - mark_dquot_dirty(transfer_to[cnt]); 1749 - /* The reference we got is transferred to the inode */ 1750 - transfer_to[cnt] = NULL; 1751 - } 1752 - } 1737 + mark_all_dquot_dirty(transfer_from); 1738 + mark_all_dquot_dirty(transfer_to); 1739 + /* The reference we got is transferred to the inode */ 1740 + for (cnt = 0; cnt < MAXQUOTAS; cnt++) 1741 + transfer_to[cnt] = NULL; 1753 1742 warn_put_all: 1754 1743 flush_warnings(transfer_to, warntype_to); 1755 1744 flush_warnings(transfer_from, warntype_from_inodes); 1756 1745 flush_warnings(transfer_from, warntype_from_space); 1757 1746 put_all: 1758 - for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 1759 - dqput(transfer_from[cnt]); 1760 - dqput(transfer_to[cnt]); 1761 - } 1747 + dqput_all(transfer_from); 1748 + dqput_all(transfer_to); 1762 1749 return ret; 1763 1750 over_quota: 1764 1751 spin_unlock(&dq_data_lock);