From: Chris Mason <mason@suse.com>
To: linux-kernel@vger.kernel.org, akpm@osdl.org
Subject: [PATCH] ext2 -ENOSPC bug
Date: Tue, 02 Mar 2004 14:51:07 -0500 [thread overview]
Message-ID: <1078257067.3932.53.camel@watt.suse.com> (raw)
Hello everyone,
find_group_other looks buggy for ext2 and ext3 in 2.6, it can cause
-ENOSPC errors when the fs has plenty of free room.
To hit the bug, you need a filesystem where:
parent_group has no free blocks (but might have free inodes)
Every other group has with free inodes has no free blocks.
That gets you down to the final linear search in find_group_other. The
linear search has two bugs:
group = parent_group + 1; means we start searching at parent_group + 2
because the loop increments group before using it.
for(i = 2 ; i < ngroups ; i++) means we don't search through all the
groups.
The end result is that parent_group and parent_group + 1 are not checked
for free inodes in the final linear search. ext3 has the same problem,
my patch below fixes both but is largely untested.
I've got an image available that shows the bug if people are interested.
-chris
Index: linux.t/fs/ext2/ialloc.c
===================================================================
--- linux.t.orig/fs/ext2/ialloc.c 2004-02-05 16:56:28.000000000 -0500
+++ linux.t/fs/ext2/ialloc.c 2004-03-02 14:23:20.284235337 -0500
@@ -431,8 +431,8 @@
* That failed: try linear search for a free inode, even if that group
* has no free blocks.
*/
- group = parent_group + 1;
- for (i = 2; i < ngroups; i++) {
+ group = parent_group;
+ for (i = 0; i < ngroups; i++) {
if (++group >= ngroups)
group = 0;
desc = ext2_get_group_desc (sb, group, &bh);
Index: linux.t/fs/ext3/ialloc.c
===================================================================
--- linux.t.orig/fs/ext3/ialloc.c 2004-02-05 16:56:28.000000000 -0500
+++ linux.t/fs/ext3/ialloc.c 2004-03-02 14:45:52.910477449 -0500
@@ -398,8 +398,8 @@
* That failed: try linear search for a free inode, even if that group
* has no free blocks.
*/
- group = parent_group + 1;
- for (i = 2; i < ngroups; i++) {
+ group = parent_group;
+ for (i = 0; i < ngroups; i++) {
if (++group >= ngroups)
group = 0;
desc = ext3_get_group_desc (sb, group, &bh);
reply other threads:[~2004-03-02 19:48 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=1078257067.3932.53.camel@watt.suse.com \
--to=mason@suse.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®