aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/quota/dquot.c54
-rw-r--r--include/linux/fs.h1
2 files changed, 32 insertions, 23 deletions
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index b1910c915c90..b80d1fe56f83 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -893,6 +893,14 @@ out:
893} 893}
894EXPORT_SYMBOL(dqget); 894EXPORT_SYMBOL(dqget);
895 895
896static inline struct dquot **i_dquot(struct inode *inode)
897{
898 /* Temporary workaround until all filesystems are converted. */
899 if (!inode->i_sb->s_op->get_dquots)
900 return inode->i_dquot;
901 return inode->i_sb->s_op->get_dquots(inode);
902}
903
896static int dqinit_needed(struct inode *inode, int type) 904static int dqinit_needed(struct inode *inode, int type)
897{ 905{
898 int cnt; 906 int cnt;
@@ -900,9 +908,9 @@ static int dqinit_needed(struct inode *inode, int type)
900 if (IS_NOQUOTA(inode)) 908 if (IS_NOQUOTA(inode))
901 return 0; 909 return 0;
902 if (type != -1) 910 if (type != -1)
903 return !inode->i_dquot[type]; 911 return !i_dquot(inode)[type];
904 for (cnt = 0; cnt < MAXQUOTAS; cnt++) 912 for (cnt = 0; cnt < MAXQUOTAS; cnt++)
905 if (!inode->i_dquot[cnt]) 913 if (!i_dquot(inode)[cnt])
906 return 1; 914 return 1;
907 return 0; 915 return 0;
908} 916}
@@ -965,9 +973,9 @@ static void add_dquot_ref(struct super_block *sb, int type)
965static void remove_inode_dquot_ref(struct inode *inode, int type, 973static void remove_inode_dquot_ref(struct inode *inode, int type,
966 struct list_head *tofree_head) 974 struct list_head *tofree_head)
967{ 975{
968 struct dquot *dquot = inode->i_dquot[type]; 976 struct dquot *dquot = i_dquot(inode)[type];
969 977
970 inode->i_dquot[type] = NULL; 978 i_dquot(inode)[type] = NULL;
971 if (!dquot) 979 if (!dquot)
972 return; 980 return;
973 981
@@ -1402,7 +1410,7 @@ static void __dquot_initialize(struct inode *inode, int type)
1402 * we check it without locking here to avoid unnecessary 1410 * we check it without locking here to avoid unnecessary
1403 * dqget()/dqput() calls. 1411 * dqget()/dqput() calls.
1404 */ 1412 */
1405 if (inode->i_dquot[cnt]) 1413 if (i_dquot(inode)[cnt])
1406 continue; 1414 continue;
1407 init_needed = 1; 1415 init_needed = 1;
1408 1416
@@ -1433,8 +1441,8 @@ static void __dquot_initialize(struct inode *inode, int type)
1433 /* We could race with quotaon or dqget() could have failed */ 1441 /* We could race with quotaon or dqget() could have failed */
1434 if (!got[cnt]) 1442 if (!got[cnt])
1435 continue; 1443 continue;
1436 if (!inode->i_dquot[cnt]) { 1444 if (!i_dquot(inode)[cnt]) {
1437 inode->i_dquot[cnt] = got[cnt]; 1445 i_dquot(inode)[cnt] = got[cnt];
1438 got[cnt] = NULL; 1446 got[cnt] = NULL;
1439 /* 1447 /*
1440 * Make quota reservation system happy if someone 1448 * Make quota reservation system happy if someone
@@ -1442,7 +1450,7 @@ static void __dquot_initialize(struct inode *inode, int type)
1442 */ 1450 */
1443 rsv = inode_get_rsv_space(inode); 1451 rsv = inode_get_rsv_space(inode);
1444 if (unlikely(rsv)) 1452 if (unlikely(rsv))
1445 dquot_resv_space(inode->i_dquot[cnt], rsv); 1453 dquot_resv_space(i_dquot(inode)[cnt], rsv);
1446 } 1454 }
1447 } 1455 }
1448out_err: 1456out_err:
@@ -1472,8 +1480,8 @@ static void __dquot_drop(struct inode *inode)
1472 1480
1473 spin_lock(&dq_data_lock); 1481 spin_lock(&dq_data_lock);
1474 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 1482 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
1475 put[cnt] = inode->i_dquot[cnt]; 1483 put[cnt] = i_dquot(inode)[cnt];
1476 inode->i_dquot[cnt] = NULL; 1484 i_dquot(inode)[cnt] = NULL;
1477 } 1485 }
1478 spin_unlock(&dq_data_lock); 1486 spin_unlock(&dq_data_lock);
1479 dqput_all(put); 1487 dqput_all(put);
@@ -1494,7 +1502,7 @@ void dquot_drop(struct inode *inode)
1494 * add quota pointers back anyway. 1502 * add quota pointers back anyway.
1495 */ 1503 */
1496 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 1504 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
1497 if (inode->i_dquot[cnt]) 1505 if (i_dquot(inode)[cnt])
1498 break; 1506 break;
1499 } 1507 }
1500 1508
@@ -1595,7 +1603,7 @@ int __dquot_alloc_space(struct inode *inode, qsize_t number, int flags)
1595{ 1603{
1596 int cnt, ret = 0, index; 1604 int cnt, ret = 0, index;
1597 struct dquot_warn warn[MAXQUOTAS]; 1605 struct dquot_warn warn[MAXQUOTAS];
1598 struct dquot **dquots = inode->i_dquot; 1606 struct dquot **dquots = i_dquot(inode);
1599 int reserve = flags & DQUOT_SPACE_RESERVE; 1607 int reserve = flags & DQUOT_SPACE_RESERVE;
1600 1608
1601 if (!dquot_active(inode)) { 1609 if (!dquot_active(inode)) {
@@ -1647,7 +1655,7 @@ int dquot_alloc_inode(struct inode *inode)
1647{ 1655{
1648 int cnt, ret = 0, index; 1656 int cnt, ret = 0, index;
1649 struct dquot_warn warn[MAXQUOTAS]; 1657 struct dquot_warn warn[MAXQUOTAS];
1650 struct dquot * const *dquots = inode->i_dquot; 1658 struct dquot * const *dquots = i_dquot(inode);
1651 1659
1652 if (!dquot_active(inode)) 1660 if (!dquot_active(inode))
1653 return 0; 1661 return 0;
@@ -1696,14 +1704,14 @@ int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
1696 spin_lock(&dq_data_lock); 1704 spin_lock(&dq_data_lock);
1697 /* Claim reserved quotas to allocated quotas */ 1705 /* Claim reserved quotas to allocated quotas */
1698 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 1706 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
1699 if (inode->i_dquot[cnt]) 1707 if (i_dquot(inode)[cnt])
1700 dquot_claim_reserved_space(inode->i_dquot[cnt], 1708 dquot_claim_reserved_space(i_dquot(inode)[cnt],
1701 number); 1709 number);
1702 } 1710 }
1703 /* Update inode bytes */ 1711 /* Update inode bytes */
1704 inode_claim_rsv_space(inode, number); 1712 inode_claim_rsv_space(inode, number);
1705 spin_unlock(&dq_data_lock); 1713 spin_unlock(&dq_data_lock);
1706 mark_all_dquot_dirty(inode->i_dquot); 1714 mark_all_dquot_dirty(i_dquot(inode));
1707 srcu_read_unlock(&dquot_srcu, index); 1715 srcu_read_unlock(&dquot_srcu, index);
1708 return 0; 1716 return 0;
1709} 1717}
@@ -1725,14 +1733,14 @@ void dquot_reclaim_space_nodirty(struct inode *inode, qsize_t number)
1725 spin_lock(&dq_data_lock); 1733 spin_lock(&dq_data_lock);
1726 /* Claim reserved quotas to allocated quotas */ 1734 /* Claim reserved quotas to allocated quotas */
1727 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 1735 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
1728 if (inode->i_dquot[cnt]) 1736 if (i_dquot(inode)[cnt])
1729 dquot_reclaim_reserved_space(inode->i_dquot[cnt], 1737 dquot_reclaim_reserved_space(i_dquot(inode)[cnt],
1730 number); 1738 number);
1731 } 1739 }
1732 /* Update inode bytes */ 1740 /* Update inode bytes */
1733 inode_reclaim_rsv_space(inode, number); 1741 inode_reclaim_rsv_space(inode, number);
1734 spin_unlock(&dq_data_lock); 1742 spin_unlock(&dq_data_lock);
1735 mark_all_dquot_dirty(inode->i_dquot); 1743 mark_all_dquot_dirty(i_dquot(inode));
1736 srcu_read_unlock(&dquot_srcu, index); 1744 srcu_read_unlock(&dquot_srcu, index);
1737 return; 1745 return;
1738} 1746}
@@ -1745,7 +1753,7 @@ void __dquot_free_space(struct inode *inode, qsize_t number, int flags)
1745{ 1753{
1746 unsigned int cnt; 1754 unsigned int cnt;
1747 struct dquot_warn warn[MAXQUOTAS]; 1755 struct dquot_warn warn[MAXQUOTAS];
1748 struct dquot **dquots = inode->i_dquot; 1756 struct dquot **dquots = i_dquot(inode);
1749 int reserve = flags & DQUOT_SPACE_RESERVE, index; 1757 int reserve = flags & DQUOT_SPACE_RESERVE, index;
1750 1758
1751 if (!dquot_active(inode)) { 1759 if (!dquot_active(inode)) {
@@ -1788,7 +1796,7 @@ void dquot_free_inode(struct inode *inode)
1788{ 1796{
1789 unsigned int cnt; 1797 unsigned int cnt;
1790 struct dquot_warn warn[MAXQUOTAS]; 1798 struct dquot_warn warn[MAXQUOTAS];
1791 struct dquot * const *dquots = inode->i_dquot; 1799 struct dquot * const *dquots = i_dquot(inode);
1792 int index; 1800 int index;
1793 1801
1794 if (!dquot_active(inode)) 1802 if (!dquot_active(inode))
@@ -1865,7 +1873,7 @@ int __dquot_transfer(struct inode *inode, struct dquot **transfer_to)
1865 if (!sb_has_quota_active(inode->i_sb, cnt)) 1873 if (!sb_has_quota_active(inode->i_sb, cnt))
1866 continue; 1874 continue;
1867 is_valid[cnt] = 1; 1875 is_valid[cnt] = 1;
1868 transfer_from[cnt] = inode->i_dquot[cnt]; 1876 transfer_from[cnt] = i_dquot(inode)[cnt];
1869 ret = check_idq(transfer_to[cnt], 1, &warn_to[cnt]); 1877 ret = check_idq(transfer_to[cnt], 1, &warn_to[cnt]);
1870 if (ret) 1878 if (ret)
1871 goto over_quota; 1879 goto over_quota;
@@ -1901,7 +1909,7 @@ int __dquot_transfer(struct inode *inode, struct dquot **transfer_to)
1901 dquot_incr_space(transfer_to[cnt], cur_space); 1909 dquot_incr_space(transfer_to[cnt], cur_space);
1902 dquot_resv_space(transfer_to[cnt], rsv_space); 1910 dquot_resv_space(transfer_to[cnt], rsv_space);
1903 1911
1904 inode->i_dquot[cnt] = transfer_to[cnt]; 1912 i_dquot(inode)[cnt] = transfer_to[cnt];
1905 } 1913 }
1906 spin_unlock(&dq_data_lock); 1914 spin_unlock(&dq_data_lock);
1907 1915
diff --git a/include/linux/fs.h b/include/linux/fs.h
index cf55a5483d40..8c093ad49522 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1591,6 +1591,7 @@ struct super_operations {
1591#ifdef CONFIG_QUOTA 1591#ifdef CONFIG_QUOTA
1592 ssize_t (*quota_read)(struct super_block *, int, char *, size_t, loff_t); 1592 ssize_t (*quota_read)(struct super_block *, int, char *, size_t, loff_t);
1593 ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t); 1593 ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t);
1594 struct dquot **(*get_dquots)(struct inode *);
1594#endif 1595#endif
1595 int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t); 1596 int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t);
1596 long (*nr_cached_objects)(struct super_block *, int); 1597 long (*nr_cached_objects)(struct super_block *, int);