diff options
-rw-r--r-- | fs/quota/dquot.c | 48 | ||||
-rw-r--r-- | include/linux/quota.h | 3 |
2 files changed, 24 insertions, 27 deletions
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 3c0a7e0dff78..e0b870f4749f 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c | |||
@@ -1181,13 +1181,13 @@ static int check_idq(struct dquot *dquot, qsize_t inodes, char *warntype) | |||
1181 | *warntype = QUOTA_NL_NOWARN; | 1181 | *warntype = QUOTA_NL_NOWARN; |
1182 | if (!sb_has_quota_limits_enabled(dquot->dq_sb, dquot->dq_type) || | 1182 | if (!sb_has_quota_limits_enabled(dquot->dq_sb, dquot->dq_type) || |
1183 | test_bit(DQ_FAKE_B, &dquot->dq_flags)) | 1183 | test_bit(DQ_FAKE_B, &dquot->dq_flags)) |
1184 | return QUOTA_OK; | 1184 | return 0; |
1185 | 1185 | ||
1186 | if (dquot->dq_dqb.dqb_ihardlimit && | 1186 | if (dquot->dq_dqb.dqb_ihardlimit && |
1187 | newinodes > dquot->dq_dqb.dqb_ihardlimit && | 1187 | newinodes > dquot->dq_dqb.dqb_ihardlimit && |
1188 | !ignore_hardlimit(dquot)) { | 1188 | !ignore_hardlimit(dquot)) { |
1189 | *warntype = QUOTA_NL_IHARDWARN; | 1189 | *warntype = QUOTA_NL_IHARDWARN; |
1190 | return NO_QUOTA; | 1190 | return -EDQUOT; |
1191 | } | 1191 | } |
1192 | 1192 | ||
1193 | if (dquot->dq_dqb.dqb_isoftlimit && | 1193 | if (dquot->dq_dqb.dqb_isoftlimit && |
@@ -1196,7 +1196,7 @@ static int check_idq(struct dquot *dquot, qsize_t inodes, char *warntype) | |||
1196 | get_seconds() >= dquot->dq_dqb.dqb_itime && | 1196 | get_seconds() >= dquot->dq_dqb.dqb_itime && |
1197 | !ignore_hardlimit(dquot)) { | 1197 | !ignore_hardlimit(dquot)) { |
1198 | *warntype = QUOTA_NL_ISOFTLONGWARN; | 1198 | *warntype = QUOTA_NL_ISOFTLONGWARN; |
1199 | return NO_QUOTA; | 1199 | return -EDQUOT; |
1200 | } | 1200 | } |
1201 | 1201 | ||
1202 | if (dquot->dq_dqb.dqb_isoftlimit && | 1202 | if (dquot->dq_dqb.dqb_isoftlimit && |
@@ -1207,7 +1207,7 @@ static int check_idq(struct dquot *dquot, qsize_t inodes, char *warntype) | |||
1207 | sb_dqopt(dquot->dq_sb)->info[dquot->dq_type].dqi_igrace; | 1207 | sb_dqopt(dquot->dq_sb)->info[dquot->dq_type].dqi_igrace; |
1208 | } | 1208 | } |
1209 | 1209 | ||
1210 | return QUOTA_OK; | 1210 | return 0; |
1211 | } | 1211 | } |
1212 | 1212 | ||
1213 | /* needs dq_data_lock */ | 1213 | /* needs dq_data_lock */ |
@@ -1219,7 +1219,7 @@ static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc, char *war | |||
1219 | *warntype = QUOTA_NL_NOWARN; | 1219 | *warntype = QUOTA_NL_NOWARN; |
1220 | if (!sb_has_quota_limits_enabled(sb, dquot->dq_type) || | 1220 | if (!sb_has_quota_limits_enabled(sb, dquot->dq_type) || |
1221 | test_bit(DQ_FAKE_B, &dquot->dq_flags)) | 1221 | test_bit(DQ_FAKE_B, &dquot->dq_flags)) |
1222 | return QUOTA_OK; | 1222 | return 0; |
1223 | 1223 | ||
1224 | tspace = dquot->dq_dqb.dqb_curspace + dquot->dq_dqb.dqb_rsvspace | 1224 | tspace = dquot->dq_dqb.dqb_curspace + dquot->dq_dqb.dqb_rsvspace |
1225 | + space; | 1225 | + space; |
@@ -1229,7 +1229,7 @@ static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc, char *war | |||
1229 | !ignore_hardlimit(dquot)) { | 1229 | !ignore_hardlimit(dquot)) { |
1230 | if (!prealloc) | 1230 | if (!prealloc) |
1231 | *warntype = QUOTA_NL_BHARDWARN; | 1231 | *warntype = QUOTA_NL_BHARDWARN; |
1232 | return NO_QUOTA; | 1232 | return -EDQUOT; |
1233 | } | 1233 | } |
1234 | 1234 | ||
1235 | if (dquot->dq_dqb.dqb_bsoftlimit && | 1235 | if (dquot->dq_dqb.dqb_bsoftlimit && |
@@ -1239,7 +1239,7 @@ static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc, char *war | |||
1239 | !ignore_hardlimit(dquot)) { | 1239 | !ignore_hardlimit(dquot)) { |
1240 | if (!prealloc) | 1240 | if (!prealloc) |
1241 | *warntype = QUOTA_NL_BSOFTLONGWARN; | 1241 | *warntype = QUOTA_NL_BSOFTLONGWARN; |
1242 | return NO_QUOTA; | 1242 | return -EDQUOT; |
1243 | } | 1243 | } |
1244 | 1244 | ||
1245 | if (dquot->dq_dqb.dqb_bsoftlimit && | 1245 | if (dquot->dq_dqb.dqb_bsoftlimit && |
@@ -1255,10 +1255,10 @@ static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc, char *war | |||
1255 | * We don't allow preallocation to exceed softlimit so exceeding will | 1255 | * We don't allow preallocation to exceed softlimit so exceeding will |
1256 | * be always printed | 1256 | * be always printed |
1257 | */ | 1257 | */ |
1258 | return NO_QUOTA; | 1258 | return -EDQUOT; |
1259 | } | 1259 | } |
1260 | 1260 | ||
1261 | return QUOTA_OK; | 1261 | return 0; |
1262 | } | 1262 | } |
1263 | 1263 | ||
1264 | static int info_idq_free(struct dquot *dquot, qsize_t inodes) | 1264 | static int info_idq_free(struct dquot *dquot, qsize_t inodes) |
@@ -1507,9 +1507,9 @@ int __dquot_alloc_space(struct inode *inode, qsize_t number, | |||
1507 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | 1507 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { |
1508 | if (!inode->i_dquot[cnt]) | 1508 | if (!inode->i_dquot[cnt]) |
1509 | continue; | 1509 | continue; |
1510 | if (check_bdq(inode->i_dquot[cnt], number, !warn, warntype+cnt) | 1510 | ret = check_bdq(inode->i_dquot[cnt], number, !warn, |
1511 | == NO_QUOTA) { | 1511 | warntype+cnt); |
1512 | ret = -EDQUOT; | 1512 | if (ret) { |
1513 | spin_unlock(&dq_data_lock); | 1513 | spin_unlock(&dq_data_lock); |
1514 | goto out_flush_warn; | 1514 | goto out_flush_warn; |
1515 | } | 1515 | } |
@@ -1541,7 +1541,7 @@ EXPORT_SYMBOL(__dquot_alloc_space); | |||
1541 | */ | 1541 | */ |
1542 | int dquot_alloc_inode(const struct inode *inode) | 1542 | int dquot_alloc_inode(const struct inode *inode) |
1543 | { | 1543 | { |
1544 | int cnt, ret = -EDQUOT; | 1544 | int cnt, ret = 0; |
1545 | char warntype[MAXQUOTAS]; | 1545 | char warntype[MAXQUOTAS]; |
1546 | 1546 | ||
1547 | /* First test before acquiring mutex - solves deadlocks when we | 1547 | /* First test before acquiring mutex - solves deadlocks when we |
@@ -1555,8 +1555,8 @@ int dquot_alloc_inode(const struct inode *inode) | |||
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 | if (check_idq(inode->i_dquot[cnt], 1, warntype+cnt) | 1558 | ret = check_idq(inode->i_dquot[cnt], 1, warntype + cnt); |
1559 | == NO_QUOTA) | 1559 | if (ret) |
1560 | goto warn_put_all; | 1560 | goto warn_put_all; |
1561 | } | 1561 | } |
1562 | 1562 | ||
@@ -1565,7 +1565,7 @@ int dquot_alloc_inode(const struct inode *inode) | |||
1565 | continue; | 1565 | continue; |
1566 | dquot_incr_inodes(inode->i_dquot[cnt], 1); | 1566 | dquot_incr_inodes(inode->i_dquot[cnt], 1); |
1567 | } | 1567 | } |
1568 | ret = 0; | 1568 | |
1569 | warn_put_all: | 1569 | warn_put_all: |
1570 | spin_unlock(&dq_data_lock); | 1570 | spin_unlock(&dq_data_lock); |
1571 | if (ret == 0) | 1571 | if (ret == 0) |
@@ -1683,14 +1683,14 @@ static int __dquot_transfer(struct inode *inode, qid_t *chid, unsigned long mask | |||
1683 | qsize_t rsv_space = 0; | 1683 | qsize_t rsv_space = 0; |
1684 | struct dquot *transfer_from[MAXQUOTAS]; | 1684 | struct dquot *transfer_from[MAXQUOTAS]; |
1685 | struct dquot *transfer_to[MAXQUOTAS]; | 1685 | struct dquot *transfer_to[MAXQUOTAS]; |
1686 | int cnt, ret = QUOTA_OK; | 1686 | int cnt, ret = 0; |
1687 | char warntype_to[MAXQUOTAS]; | 1687 | char warntype_to[MAXQUOTAS]; |
1688 | char warntype_from_inodes[MAXQUOTAS], warntype_from_space[MAXQUOTAS]; | 1688 | char warntype_from_inodes[MAXQUOTAS], warntype_from_space[MAXQUOTAS]; |
1689 | 1689 | ||
1690 | /* First test before acquiring mutex - solves deadlocks when we | 1690 | /* First test before acquiring mutex - solves deadlocks when we |
1691 | * re-enter the quota code and are already holding the mutex */ | 1691 | * re-enter the quota code and are already holding the mutex */ |
1692 | if (IS_NOQUOTA(inode)) | 1692 | if (IS_NOQUOTA(inode)) |
1693 | return QUOTA_OK; | 1693 | return 0; |
1694 | /* Initialize the arrays */ | 1694 | /* Initialize the arrays */ |
1695 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | 1695 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { |
1696 | transfer_from[cnt] = NULL; | 1696 | transfer_from[cnt] = NULL; |
@@ -1715,9 +1715,11 @@ static int __dquot_transfer(struct inode *inode, qid_t *chid, unsigned long mask | |||
1715 | if (!transfer_to[cnt]) | 1715 | if (!transfer_to[cnt]) |
1716 | continue; | 1716 | continue; |
1717 | transfer_from[cnt] = inode->i_dquot[cnt]; | 1717 | transfer_from[cnt] = inode->i_dquot[cnt]; |
1718 | if (check_idq(transfer_to[cnt], 1, warntype_to + cnt) == | 1718 | ret = check_idq(transfer_to[cnt], 1, warntype_to + cnt); |
1719 | NO_QUOTA || check_bdq(transfer_to[cnt], space, 0, | 1719 | if (ret) |
1720 | warntype_to + cnt) == NO_QUOTA) | 1720 | goto over_quota; |
1721 | ret = check_bdq(transfer_to[cnt], space, 0, warntype_to + cnt); | ||
1722 | if (ret) | ||
1721 | goto over_quota; | 1723 | goto over_quota; |
1722 | } | 1724 | } |
1723 | 1725 | ||
@@ -1771,7 +1773,6 @@ over_quota: | |||
1771 | /* Clear dquot pointers we don't want to dqput() */ | 1773 | /* Clear dquot pointers we don't want to dqput() */ |
1772 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) | 1774 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) |
1773 | transfer_from[cnt] = NULL; | 1775 | transfer_from[cnt] = NULL; |
1774 | ret = NO_QUOTA; | ||
1775 | goto warn_put_all; | 1776 | goto warn_put_all; |
1776 | } | 1777 | } |
1777 | 1778 | ||
@@ -1793,8 +1794,7 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr) | |||
1793 | } | 1794 | } |
1794 | if (sb_any_quota_active(inode->i_sb) && !IS_NOQUOTA(inode)) { | 1795 | if (sb_any_quota_active(inode->i_sb) && !IS_NOQUOTA(inode)) { |
1795 | dquot_initialize(inode); | 1796 | dquot_initialize(inode); |
1796 | if (__dquot_transfer(inode, chid, mask) == NO_QUOTA) | 1797 | return __dquot_transfer(inode, chid, mask); |
1797 | return -EDQUOT; | ||
1798 | } | 1798 | } |
1799 | return 0; | 1799 | return 0; |
1800 | } | 1800 | } |
diff --git a/include/linux/quota.h b/include/linux/quota.h index 4aa93554f0eb..b462916b2a0a 100644 --- a/include/linux/quota.h +++ b/include/linux/quota.h | |||
@@ -279,9 +279,6 @@ struct dquot { | |||
279 | struct mem_dqblk dq_dqb; /* Diskquota usage */ | 279 | struct mem_dqblk dq_dqb; /* Diskquota usage */ |
280 | }; | 280 | }; |
281 | 281 | ||
282 | #define QUOTA_OK 0 | ||
283 | #define NO_QUOTA 1 | ||
284 | |||
285 | /* Operations which must be implemented by each quota format */ | 282 | /* Operations which must be implemented by each quota format */ |
286 | struct quota_format_ops { | 283 | struct quota_format_ops { |
287 | int (*check_quota_file)(struct super_block *sb, int type); /* Detect whether file is in our format */ | 284 | int (*check_quota_file)(struct super_block *sb, int type); /* Detect whether file is in our format */ |