public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@zip.com.au>
To: "Stephen C. Tweedie" <sct@redhat.com>,
	"ext3-users@redhat.com" <ext3-users@redhat.com>,
	lkml <linux-kernel@vger.kernel.org>
Subject: [patch] fix ext3 i_blocks accounting
Date: Tue, 02 Apr 2002 13:22:08 -0800	[thread overview]
Message-ID: <3CAA2100.C493214@zip.com.au> (raw)

This fixes the "i_blocks went wrong when the disk filled up"
problem.

In ext3_new_block() we increment i_blocks early, so the
quota operation can be performed outside lock_super().
But if the block allocation ends up failing, we forget to
undo the allocation.  

This is not a serious bug, and probably does not warrant
an upgrade for production machines.  Its effects are:

1) errors are generated from e2fsck and

2) users could appear to be over quota when they really aren't.

The patch undoes the accounting operation if the allocation
ends up failing.


--- 2.4.19-pre5/fs/ext3/balloc.c~ext3-i_blocks	Tue Apr  2 13:12:34 2002
+++ 2.4.19-pre5-akpm/fs/ext3/balloc.c	Tue Apr  2 13:15:03 2002
@@ -542,6 +542,7 @@ int ext3_new_block (handle_t *handle, st
 	int i, j, k, tmp, alloctmp;
 	int bitmap_nr;
 	int fatal = 0, err;
+	int performed_allocation = 0;
 	struct super_block * sb;
 	struct ext3_group_desc * gdp;
 	struct ext3_super_block * es;
@@ -644,8 +645,7 @@ int ext3_new_block (handle_t *handle, st
 	}
 
 	/* No space left on the device */
-	unlock_super (sb);
-	return 0;
+	goto out;
 
 search_back:
 	/* 
@@ -694,6 +694,7 @@ got_block:
 	J_ASSERT_BH(bh, !ext3_test_bit(j, bh->b_data));
 	BUFFER_TRACE(bh, "setting bitmap bit");
 	ext3_set_bit(j, bh->b_data);
+	performed_allocation = 1;
 
 #ifdef CONFIG_JBD_DEBUG
 	{
@@ -815,6 +816,11 @@ out:
 		ext3_std_error(sb, fatal);
 	}
 	unlock_super (sb);
+	/*
+	 * Undo the block allocation
+	 */
+	if (!performed_allocation)
+		DQUOT_FREE_BLOCK(inode, 1);
 	return 0;
 	
 }

-

                 reply	other threads:[~2002-04-02 21:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3CAA2100.C493214@zip.com.au \
    --to=akpm@zip.com.au \
    --cc=ext3-users@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sct@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox