aboutsummaryrefslogtreecommitdiffstats
path: root/fs/dquot.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/dquot.c')
-rw-r--r--fs/dquot.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/fs/dquot.c b/fs/dquot.c
index 41b9dbd68b0e..24eef582d2a0 100644
--- a/fs/dquot.c
+++ b/fs/dquot.c
@@ -1709,10 +1709,19 @@ int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *d
1709} 1709}
1710 1710
1711/* Generic routine for setting common part of quota structure */ 1711/* Generic routine for setting common part of quota structure */
1712static void do_set_dqblk(struct dquot *dquot, struct if_dqblk *di) 1712static int do_set_dqblk(struct dquot *dquot, struct if_dqblk *di)
1713{ 1713{
1714 struct mem_dqblk *dm = &dquot->dq_dqb; 1714 struct mem_dqblk *dm = &dquot->dq_dqb;
1715 int check_blim = 0, check_ilim = 0; 1715 int check_blim = 0, check_ilim = 0;
1716 struct mem_dqinfo *dqi = &sb_dqopt(dquot->dq_sb)->info[dquot->dq_type];
1717
1718 if ((di->dqb_valid & QIF_BLIMITS &&
1719 (di->dqb_bhardlimit > dqi->dqi_maxblimit ||
1720 di->dqb_bsoftlimit > dqi->dqi_maxblimit)) ||
1721 (di->dqb_valid & QIF_ILIMITS &&
1722 (di->dqb_ihardlimit > dqi->dqi_maxilimit ||
1723 di->dqb_isoftlimit > dqi->dqi_maxilimit)))
1724 return -ERANGE;
1716 1725
1717 spin_lock(&dq_data_lock); 1726 spin_lock(&dq_data_lock);
1718 if (di->dqb_valid & QIF_SPACE) { 1727 if (di->dqb_valid & QIF_SPACE) {
@@ -1744,7 +1753,7 @@ static void do_set_dqblk(struct dquot *dquot, struct if_dqblk *di)
1744 clear_bit(DQ_BLKS_B, &dquot->dq_flags); 1753 clear_bit(DQ_BLKS_B, &dquot->dq_flags);
1745 } 1754 }
1746 else if (!(di->dqb_valid & QIF_BTIME)) /* Set grace only if user hasn't provided his own... */ 1755 else if (!(di->dqb_valid & QIF_BTIME)) /* Set grace only if user hasn't provided his own... */
1747 dm->dqb_btime = get_seconds() + sb_dqopt(dquot->dq_sb)->info[dquot->dq_type].dqi_bgrace; 1756 dm->dqb_btime = get_seconds() + dqi->dqi_bgrace;
1748 } 1757 }
1749 if (check_ilim) { 1758 if (check_ilim) {
1750 if (!dm->dqb_isoftlimit || dm->dqb_curinodes < dm->dqb_isoftlimit) { 1759 if (!dm->dqb_isoftlimit || dm->dqb_curinodes < dm->dqb_isoftlimit) {
@@ -1752,7 +1761,7 @@ static void do_set_dqblk(struct dquot *dquot, struct if_dqblk *di)
1752 clear_bit(DQ_INODES_B, &dquot->dq_flags); 1761 clear_bit(DQ_INODES_B, &dquot->dq_flags);
1753 } 1762 }
1754 else if (!(di->dqb_valid & QIF_ITIME)) /* Set grace only if user hasn't provided his own... */ 1763 else if (!(di->dqb_valid & QIF_ITIME)) /* Set grace only if user hasn't provided his own... */
1755 dm->dqb_itime = get_seconds() + sb_dqopt(dquot->dq_sb)->info[dquot->dq_type].dqi_igrace; 1764 dm->dqb_itime = get_seconds() + dqi->dqi_igrace;
1756 } 1765 }
1757 if (dm->dqb_bhardlimit || dm->dqb_bsoftlimit || dm->dqb_ihardlimit || dm->dqb_isoftlimit) 1766 if (dm->dqb_bhardlimit || dm->dqb_bsoftlimit || dm->dqb_ihardlimit || dm->dqb_isoftlimit)
1758 clear_bit(DQ_FAKE_B, &dquot->dq_flags); 1767 clear_bit(DQ_FAKE_B, &dquot->dq_flags);
@@ -1760,21 +1769,24 @@ static void do_set_dqblk(struct dquot *dquot, struct if_dqblk *di)
1760 set_bit(DQ_FAKE_B, &dquot->dq_flags); 1769 set_bit(DQ_FAKE_B, &dquot->dq_flags);
1761 spin_unlock(&dq_data_lock); 1770 spin_unlock(&dq_data_lock);
1762 mark_dquot_dirty(dquot); 1771 mark_dquot_dirty(dquot);
1772
1773 return 0;
1763} 1774}
1764 1775
1765int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di) 1776int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di)
1766{ 1777{
1767 struct dquot *dquot; 1778 struct dquot *dquot;
1779 int rc;
1768 1780
1769 mutex_lock(&sb_dqopt(sb)->dqonoff_mutex); 1781 mutex_lock(&sb_dqopt(sb)->dqonoff_mutex);
1770 if (!(dquot = dqget(sb, id, type))) { 1782 if (!(dquot = dqget(sb, id, type))) {
1771 mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex); 1783 mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
1772 return -ESRCH; 1784 return -ESRCH;
1773 } 1785 }
1774 do_set_dqblk(dquot, di); 1786 rc = do_set_dqblk(dquot, di);
1775 dqput(dquot); 1787 dqput(dquot);
1776 mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex); 1788 mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
1777 return 0; 1789 return rc;
1778} 1790}
1779 1791
1780/* Generic routine for getting common part of quota file information */ 1792/* Generic routine for getting common part of quota file information */