Skip to contentSkip to conversation

quota: Fix possible infinite loop in quota code

PATCH In review Jan Kara 2 participants 4 messages Jul 9, 2008 – Jul 10, 2008 VFS

lore
Share & tools
lore

Jan Kara

author reviewer
#0 lore raw

PATCH 1/1 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.

---
 fs/dquot.c |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)
fs/dquot.c +15 -1
index 5ac77da..ad88cf6 100644
@@ -562,6 +562,8 @@ static struct shrinker dqcache_shrinker = {
  */
 static void dqput(struct dquot *dquot)
 {
+	int ret;
+
 	if (!dquot)
 		return;
 #ifdef __DQUOT_PARANOIA
@@ -594,7 +596,19 @@ we_slept:
 	if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags) && dquot_dirty(dquot)) {
 		spin_unlock(&dq_list_lock);
 		/* 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;
 	}
 	/* Clear flag in case dquot was inactive (something bad happened) */
Signature · 1 line
1.5.2.4
#1 lore raw
Quoted 5 lines · On Wed, 9 Jul 2008 19:30:41 +0200 Jan Kara <[email protected]> wrote:

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.

What do you consider the priority is here? Needed in 2.6.26? Backport to 2.6.25.x? Merge into 2.6.27 with a backport to 2.6.26.x and 2.6.25.x?

Lots of options ;)

author reviewer
#2 lore raw
Quoted 8 lines · Andrew Morton
Quoted 5 lines · On Wed, 9 Jul 2008 19:30:41 +0200 Jan Kara <[email protected]> wrote:

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.

Quoted 4 lines

What do you consider the priority is here? Needed in 2.6.26? Backport to 2.6.25.x? Merge into 2.6.27 with a backport to 2.6.26.x and 2.6.25.x?

Lots of options ;)

Since nobody has really seen it in the wild, I don't think it's urgent.
The bug has been there for 5 years or so without notice... I'd just let it be included in 2.6.26.x maybe 2.6.25.x and push into 2.6.27.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#3 lore raw
Quoted 9 lines · On Thu, 10 Jul 2008 11:05:53 +0200 Jan Kara <[email protected]> wrote:
Quoted 8 lines · Andrew Morton
Quoted 5 lines · On Wed, 9 Jul 2008 19:30:41 +0200 Jan Kara <[email protected]> wrote:

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.

Quoted 8 lines
Quoted 4 lines

What do you consider the priority is here? Needed in 2.6.26? Backport to 2.6.25.x? Merge into 2.6.27 with a backport to 2.6.26.x and 2.6.25.x?

Lots of options ;)

Since nobody has really seen it in the wild, I don't think it's urgent.
The bug has been there for 5 years or so without notice... I'd just let it be included in 2.6.26.x maybe 2.6.25.x and push into 2.6.27.

So noted, thanks.