Commit 8e2e0a79 authored by Chao Yu's avatar Chao Yu Committed by Jan Kara

quota: fix to propagate error of mark_dquot_dirty() to caller

in order to let caller be aware of failure of mark_dquot_dirty().
Signed-off-by: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
Message-Id: <20240412094942.2131243-1-chao@kernel.org>
parent 4f8cf60a
...@@ -410,7 +410,7 @@ static inline int mark_all_dquot_dirty(struct dquot __rcu * const *dquots) ...@@ -410,7 +410,7 @@ static inline int mark_all_dquot_dirty(struct dquot __rcu * const *dquots)
if (dquot) if (dquot)
/* Even in case of error we have to continue */ /* Even in case of error we have to continue */
ret = mark_dquot_dirty(dquot); ret = mark_dquot_dirty(dquot);
if (!err) if (!err && ret < 0)
err = ret; err = ret;
} }
return err; return err;
...@@ -1737,7 +1737,7 @@ int __dquot_alloc_space(struct inode *inode, qsize_t number, int flags) ...@@ -1737,7 +1737,7 @@ int __dquot_alloc_space(struct inode *inode, qsize_t number, int flags)
if (reserve) if (reserve)
goto out_flush_warn; goto out_flush_warn;
mark_all_dquot_dirty(dquots); ret = mark_all_dquot_dirty(dquots);
out_flush_warn: out_flush_warn:
srcu_read_unlock(&dquot_srcu, index); srcu_read_unlock(&dquot_srcu, index);
flush_warnings(warn); flush_warnings(warn);
...@@ -1786,7 +1786,7 @@ int dquot_alloc_inode(struct inode *inode) ...@@ -1786,7 +1786,7 @@ int dquot_alloc_inode(struct inode *inode)
warn_put_all: warn_put_all:
spin_unlock(&inode->i_lock); spin_unlock(&inode->i_lock);
if (ret == 0) if (ret == 0)
mark_all_dquot_dirty(dquots); ret = mark_all_dquot_dirty(dquots);
srcu_read_unlock(&dquot_srcu, index); srcu_read_unlock(&dquot_srcu, index);
flush_warnings(warn); flush_warnings(warn);
return ret; return ret;
...@@ -1990,7 +1990,7 @@ int __dquot_transfer(struct inode *inode, struct dquot **transfer_to) ...@@ -1990,7 +1990,7 @@ int __dquot_transfer(struct inode *inode, struct dquot **transfer_to)
qsize_t inode_usage = 1; qsize_t inode_usage = 1;
struct dquot __rcu **dquots; struct dquot __rcu **dquots;
struct dquot *transfer_from[MAXQUOTAS] = {}; struct dquot *transfer_from[MAXQUOTAS] = {};
int cnt, index, ret = 0; int cnt, index, ret = 0, err;
char is_valid[MAXQUOTAS] = {}; char is_valid[MAXQUOTAS] = {};
struct dquot_warn warn_to[MAXQUOTAS]; struct dquot_warn warn_to[MAXQUOTAS];
struct dquot_warn warn_from_inodes[MAXQUOTAS]; struct dquot_warn warn_from_inodes[MAXQUOTAS];
...@@ -2087,8 +2087,12 @@ int __dquot_transfer(struct inode *inode, struct dquot **transfer_to) ...@@ -2087,8 +2087,12 @@ int __dquot_transfer(struct inode *inode, struct dquot **transfer_to)
* mark_all_dquot_dirty(). * mark_all_dquot_dirty().
*/ */
index = srcu_read_lock(&dquot_srcu); index = srcu_read_lock(&dquot_srcu);
mark_all_dquot_dirty((struct dquot __rcu **)transfer_from); err = mark_all_dquot_dirty((struct dquot __rcu **)transfer_from);
mark_all_dquot_dirty((struct dquot __rcu **)transfer_to); if (err < 0)
ret = err;
err = mark_all_dquot_dirty((struct dquot __rcu **)transfer_to);
if (err < 0)
ret = err;
srcu_read_unlock(&dquot_srcu, index); srcu_read_unlock(&dquot_srcu, index);
flush_warnings(warn_to); flush_warnings(warn_to);
...@@ -2098,7 +2102,7 @@ int __dquot_transfer(struct inode *inode, struct dquot **transfer_to) ...@@ -2098,7 +2102,7 @@ int __dquot_transfer(struct inode *inode, struct dquot **transfer_to)
for (cnt = 0; cnt < MAXQUOTAS; cnt++) for (cnt = 0; cnt < MAXQUOTAS; cnt++)
if (is_valid[cnt]) if (is_valid[cnt])
transfer_to[cnt] = transfer_from[cnt]; transfer_to[cnt] = transfer_from[cnt];
return 0; return ret;
over_quota: over_quota:
/* Back out changes we already did */ /* Back out changes we already did */
for (cnt--; cnt >= 0; cnt--) { for (cnt--; cnt >= 0; cnt--) {
...@@ -2726,6 +2730,7 @@ static int do_set_dqblk(struct dquot *dquot, struct qc_dqblk *di) ...@@ -2726,6 +2730,7 @@ static int do_set_dqblk(struct dquot *dquot, struct qc_dqblk *di)
struct mem_dqblk *dm = &dquot->dq_dqb; struct mem_dqblk *dm = &dquot->dq_dqb;
int check_blim = 0, check_ilim = 0; int check_blim = 0, check_ilim = 0;
struct mem_dqinfo *dqi = &sb_dqopt(dquot->dq_sb)->info[dquot->dq_id.type]; struct mem_dqinfo *dqi = &sb_dqopt(dquot->dq_sb)->info[dquot->dq_id.type];
int ret;
if (di->d_fieldmask & ~VFS_QC_MASK) if (di->d_fieldmask & ~VFS_QC_MASK)
return -EINVAL; return -EINVAL;
...@@ -2807,8 +2812,9 @@ static int do_set_dqblk(struct dquot *dquot, struct qc_dqblk *di) ...@@ -2807,8 +2812,9 @@ static int do_set_dqblk(struct dquot *dquot, struct qc_dqblk *di)
else else
set_bit(DQ_FAKE_B, &dquot->dq_flags); set_bit(DQ_FAKE_B, &dquot->dq_flags);
spin_unlock(&dquot->dq_dqb_lock); spin_unlock(&dquot->dq_dqb_lock);
mark_dquot_dirty(dquot); ret = mark_dquot_dirty(dquot);
if (ret < 0)
return ret;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment