quota: check time limit when back out space/inode change
PATCH 1/1 quota: check time limit when back out space/inode change
When we fail from allocating inode/space, we back out the change we already did. In a special case which has exceeded soft limit by the change, we should also check time limit and reset it properly.
Signed-off-by Chengguang Xu <[email protected]>
--- fs/quota/dquot.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
fs/quota/dquot.c +6 -8
@@ -1681,13 +1681,11 @@ int __dquot_alloc_space(struct inode *inode, qsize_t number, int flags)if (!dquots[cnt])continue ;spin_lock (&dquots[cnt]->dq_dqb_lock); -if (reserve) { - dquots[cnt]->dq_dqb.dqb_rsvspace -= - number; - }else { - dquots[cnt]->dq_dqb.dqb_curspace -= - number; - } +if (reserve) +dquot_free_reserved_space (dquots[cnt], + number); +else +dquot_decr_space (dquots[cnt], number);spin_unlock (&dquots[cnt]->dq_dqb_lock); }spin_unlock (&inode->i_lock);
@@ -1738,7 +1736,7 @@ int dquot_alloc_inode(struct inode *inode)continue ;/* Back out changes we already did */ spin_lock (&dquots[cnt]->dq_dqb_lock); - dquots[cnt]->dq_dqb.dqb_curinodes--; +dquot_decr_inodes (dquots[cnt],1 );spin_unlock (&dquots[cnt]->dq_dqb_lock); } goto warn_put_all;
--
2.20.1
Quoted 6 lines · Chengguang Xu
When we fail from allocating inode/space, we back out the change we already did. In a special case which has exceeded soft limit by the change, we should also check time limit and reset it properly.
Signed-off-by Chengguang Xu <[email protected]>
Good catch. Thanks for fixing this. I've added the patch to my tree.
Honza
Quoted 40 lines
--- fs/quota/dquot.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)fs/quota/dquot.c +6
-9@@ -1681,13 +1681,11 @@ int __dquot_alloc_space(struct inode *inode, qsize_t number, int flags)if (!dquots[cnt])continue ;spin_lock (&dquots[cnt]->dq_dqb_lock); -if (reserve) { - dquots[cnt]->dq_dqb.dqb_rsvspace -= - number; - }else { - dquots[cnt]->dq_dqb.dqb_curspace -= - number; - } +if (reserve) +dquot_free_reserved_space (dquots[cnt], + number); +else +dquot_decr_space (dquots[cnt], number);spin_unlock (&dquots[cnt]->dq_dqb_lock); }spin_unlock (&inode->i_lock);@@ -1738,7 +1736,7 @@ int dquot_alloc_inode(struct inode *inode)continue ;/* Back out changes we already did */ spin_lock (&dquots[cnt]->dq_dqb_lock); - dquots[cnt]->dq_dqb.dqb_curinodes--; +dquot_decr_inodes (dquots[cnt],1 );spin_unlock (&dquots[cnt]->dq_dqb_lock); } goto warn_put_all; --2.20.1
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR