Commit b48d3805 authored by Jan Kara's avatar Jan Kara Committed by Linus Torvalds

quota: fix possible infinite loop in quota code

When quota structure is going to be dropped and it is dirty, quota code tries
to write it.  If the write fails for some reason (e.  g.  transaction cannot
be started because the journal is aborted), we try writing again and again and
again...  Fix the problem by clearing the dirty bit even if the write failed.

(akpm: for 2.6.27, 2.6.26.x and 2.6.25.x)
Signed-off-by: default avatarJan Kara <jack@suse.cz>
Reviewed-by: default avatardingdinghua <dingdinghua85@gmail.com>
Cc: <stable@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 41003cde
...@@ -562,6 +562,8 @@ static struct shrinker dqcache_shrinker = { ...@@ -562,6 +562,8 @@ static struct shrinker dqcache_shrinker = {
*/ */
static void dqput(struct dquot *dquot) static void dqput(struct dquot *dquot)
{ {
int ret;
if (!dquot) if (!dquot)
return; return;
#ifdef __DQUOT_PARANOIA #ifdef __DQUOT_PARANOIA
...@@ -594,7 +596,19 @@ static void dqput(struct dquot *dquot) ...@@ -594,7 +596,19 @@ static void dqput(struct dquot *dquot)
if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags) && dquot_dirty(dquot)) { if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags) && dquot_dirty(dquot)) {
spin_unlock(&dq_list_lock); spin_unlock(&dq_list_lock);
/* Commit dquot before releasing */ /* Commit dquot before releasing */
dquot->dq_sb->dq_op->write_dquot(dquot); ret = dquot->dq_sb->dq_op->write_dquot(dquot);
if (ret < 0) {
printk(KERN_ERR "VFS: cannot write quota structure on "
"device %s (error %d). Quota may get out of "
"sync!\n", dquot->dq_sb->s_id, ret);
/*
* We clear dirty bit anyway, so that we avoid
* infinite loop here
*/
spin_lock(&dq_list_lock);
clear_dquot_dirty(dquot);
spin_unlock(&dq_list_lock);
}
goto we_slept; goto we_slept;
} }
/* Clear flag in case dquot was inactive (something bad happened) */ /* Clear flag in case dquot was inactive (something bad happened) */
......
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