linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][e2fsprogs][mke2fs] fix FLEX_BG offset
@ 2008-07-03  8:21 Celine Bourde
  2008-07-03 11:55 ` Jose R. Santos
  2008-07-07 16:46 ` Theodore Tso
  0 siblings, 2 replies; 5+ messages in thread
From: Celine Bourde @ 2008-07-03  8:21 UTC (permalink / raw)
  To: linux-ext4, Jose R. Santos, cmm, Frédéric Bohé
  Cc: SOLOFO RAMANGALAHY, Jean-Pierre Dion

[-- Attachment #1: Type: text/plain, Size: 819 bytes --]

This patch resolves the offset problem of the flex_bg
option when you use mke2fs tool.

For example, if you type mkfs.ext4 -I256 -O flex_bg -G32 -E test_fs <device>
and look dumpe2fs <device> result you will see an offset problem.

Group 0: (Blocks 0-32767)
Primary superblock at 0, Group descriptors at 1-5
Reserved GDT blocks at 6-1024
Block bitmap at 1025 (+1025), Inode bitmap at 1058 (+1058)
Inode table at 1090-1601 (+1090)
0 free blocks, 8181 free inodes, 2 directories
Free blocks:
Free inodes: 12-8192

Inode bitmap must start at 1025 + 32 = 1057
In all flexbg groups, the block between the last block bitmap and the 
first inode
bitmap (metatdata) is not used, which introduced a hole.

This patch corrects it.
You have to apply it on e2fsprogs (mke2fs 1.41-WIP (17-Jun-2008)) master 
branch.

Celine Bourde.

[-- Attachment #2: flexbg_offset.patch --]
[-- Type: text/x-patch, Size: 739 bytes --]

Signed-off-by: Bourde Celine <celine.bourde@bull.net>

alloc_tables.c |    8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff -rpu a/lib/ext2fs/alloc_tables.c b/lib/ext2fs/alloc_tables.c
--- a/lib/ext2fs/alloc_tables.c	2008-07-01 16:11:49.000000000 +0200
+++ b/lib/ext2fs/alloc_tables.c	2008-07-02 16:38:22.000000000 +0200
@@ -71,9 +71,11 @@ static blk_t flexbg_offset(ext2_filsys f
 				   &first_free))
 		return first_free;
 
-	if (ext2fs_get_free_blocks(fs, first_free + offset, last_blk, size,
-				   bmap, &first_free))
-		return first_free;
+	if (offset)
+		if (ext2fs_get_free_blocks(fs, first_free + offset - 1,
+					   last_blk, size, bmap,
+					   &first_free))
+			return first_free;
 
 	return first_free;
 }

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH][e2fsprogs][mke2fs] fix FLEX_BG offset
  2008-07-03  8:21 [PATCH][e2fsprogs][mke2fs] fix FLEX_BG offset Celine Bourde
@ 2008-07-03 11:55 ` Jose R. Santos
  2008-07-07 19:42   ` Jose R. Santos
  2008-07-07 16:46 ` Theodore Tso
  1 sibling, 1 reply; 5+ messages in thread
From: Jose R. Santos @ 2008-07-03 11:55 UTC (permalink / raw)
  To: Celine Bourde
  Cc: linux-ext4, cmm, Frédéric Bohé, SOLOFO RAMANGALAHY,
	Jean-Pierre Dion

On Thu, 03 Jul 2008 10:21:02 +0200
Celine Bourde <celine.bourde@bull.net> wrote:

> This patch resolves the offset problem of the flex_bg
> option when you use mke2fs tool.
> 
> For example, if you type mkfs.ext4 -I256 -O flex_bg -G32 -E test_fs <device>
> and look dumpe2fs <device> result you will see an offset problem.
> 
> Group 0: (Blocks 0-32767)
> Primary superblock at 0, Group descriptors at 1-5
> Reserved GDT blocks at 6-1024
> Block bitmap at 1025 (+1025), Inode bitmap at 1058 (+1058)
> Inode table at 1090-1601 (+1090)
> 0 free blocks, 8181 free inodes, 2 directories
> Free blocks:
> Free inodes: 12-8192
> 
> Inode bitmap must start at 1025 + 32 = 1057
> In all flexbg groups, the block between the last block bitmap and the 
> first inode
> bitmap (metatdata) is not used, which introduced a hole.
> 
> This patch corrects it.
> You have to apply it on e2fsprogs (mke2fs 1.41-WIP (17-Jun-2008)) master 
> branch.
> 
> Celine Bourde.

Acked-by: Jose R. Santos <jrs@us.ibm.com>

-JRS

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH][e2fsprogs][mke2fs] fix FLEX_BG offset
  2008-07-03  8:21 [PATCH][e2fsprogs][mke2fs] fix FLEX_BG offset Celine Bourde
  2008-07-03 11:55 ` Jose R. Santos
@ 2008-07-07 16:46 ` Theodore Tso
  1 sibling, 0 replies; 5+ messages in thread
From: Theodore Tso @ 2008-07-07 16:46 UTC (permalink / raw)
  To: Celine Bourde
  Cc: linux-ext4, Jose R. Santos, cmm, Frédéric Bohé,
	SOLOFO RAMANGALAHY, Jean-Pierre Dion

On Thu, Jul 03, 2008 at 10:21:02AM +0200, Celine Bourde wrote:
> This patch resolves the offset problem of the flex_bg
> option when you use mke2fs tool.

Actually, I think the problem is a bigger one.  Ext2fs_get_free_blocks()
returns a error code on failure.  So the code before the conditional
you modified is totally bogus:

	/* Find the first available block */
	if (ext2fs_get_free_blocks(fs, start_blk, last_blk, 1, bmap,
				   &first_free))
		return first_free;

	if (ext2fs_get_free_blocks(fs, first_free + offset, last_blk, size,
				   bmap, &first_free))
		return first_free;

	return first_free;

I think this should be instead:

	/* Find the first available block */
	if (ext2fs_get_free_blocks(fs, start_blk, last_blk, 1, bmap,
				   &first_free) == 0)
		return first_free;

	if (ext2fs_get_free_blocks(fs, first_free + offset, last_blk, size,
				   bmap, &first_free) == 0)
		return first_free;

	/* 
	 * Oops, we weren't able to find enough space.  We return 
	 * first_free as a best try.
	 */

	return first_free;

							- Ted

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH][e2fsprogs][mke2fs] fix FLEX_BG offset
  2008-07-03 11:55 ` Jose R. Santos
@ 2008-07-07 19:42   ` Jose R. Santos
  2008-07-07 22:30     ` Theodore Tso
  0 siblings, 1 reply; 5+ messages in thread
From: Jose R. Santos @ 2008-07-07 19:42 UTC (permalink / raw)
  To: Jose R. Santos
  Cc: Celine Bourde, linux-ext4, cmm, Frédéric Bohé,
	SOLOFO RAMANGALAHY, Jean-Pierre Dion

On Thu, 3 Jul 2008 06:55:53 -0500
"Jose R. Santos" <jrs@us.ibm.com> wrote:

> On Thu, 03 Jul 2008 10:21:02 +0200
> Celine Bourde <celine.bourde@bull.net> wrote:
> 
> > This patch resolves the offset problem of the flex_bg
> > option when you use mke2fs tool.
> > 
> > For example, if you type mkfs.ext4 -I256 -O flex_bg -G32 -E test_fs <device>
> > and look dumpe2fs <device> result you will see an offset problem.
> > 
> > Group 0: (Blocks 0-32767)
> > Primary superblock at 0, Group descriptors at 1-5
> > Reserved GDT blocks at 6-1024
> > Block bitmap at 1025 (+1025), Inode bitmap at 1058 (+1058)
> > Inode table at 1090-1601 (+1090)
> > 0 free blocks, 8181 free inodes, 2 directories
> > Free blocks:
> > Free inodes: 12-8192
> > 
> > Inode bitmap must start at 1025 + 32 = 1057
> > In all flexbg groups, the block between the last block bitmap and the 
> > first inode
> > bitmap (metatdata) is not used, which introduced a hole.
> > 
> > This patch corrects it.
> > You have to apply it on e2fsprogs (mke2fs 1.41-WIP (17-Jun-2008)) master 
> > branch.
> > 
> > Celine Bourde.
> 
> Acked-by: Jose R. Santos <jrs@us.ibm.com>

Looks like I jumped the gun to fast acknowledging this patch.  The
current patch doesn't run the second ext2fs_get_free_blocks() when
doing a search for block bitmap space.

Here is an updated patch.

commit a58058e85240c7834cd863efa35b21688e104047
Author: Jose R. Santos <jrs@us.ibm.com>
Date:   Mon Jul 7 14:36:08 2008 -0500

    Fix FLEX_BG offset
    
    The offset for both inode bitmaps and inode tables is overshot by one
    block causing a hole between the group of bitmaps and inode tables.

    Signed-off-by: Jose R. Santos <jrs@us.ibm.com>

diff --git a/lib/ext2fs/alloc_tables.c b/lib/ext2fs/alloc_tables.c
index d87585b..7f6ac77 100644
--- a/lib/ext2fs/alloc_tables.c
+++ b/lib/ext2fs/alloc_tables.c
@@ -46,6 +46,8 @@ static blk_t flexbg_offset(ext2_filsys fs, dgrp_t group, blk_t start_blk,
 	if (size > fs->super->s_blocks_per_group / 8)
 		size = fs->super->s_blocks_per_group / 8;
 
+	if (offset)
+		offset -= 1;
 	/*
 	 * Dont do a long search if the previous block
 	 * search is still valid.




-JRS

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH][e2fsprogs][mke2fs] fix FLEX_BG offset
  2008-07-07 19:42   ` Jose R. Santos
@ 2008-07-07 22:30     ` Theodore Tso
  0 siblings, 0 replies; 5+ messages in thread
From: Theodore Tso @ 2008-07-07 22:30 UTC (permalink / raw)
  To: Jose R. Santos
  Cc: Celine Bourde, linux-ext4, cmm, Frédéric Bohé,
	SOLOFO RAMANGALAHY, Jean-Pierre Dion

Thanks, applied.  (And ignore my earlier e-mail; I was confused about
what the code was trying to do.)

						- Ted

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-07-07 22:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-03  8:21 [PATCH][e2fsprogs][mke2fs] fix FLEX_BG offset Celine Bourde
2008-07-03 11:55 ` Jose R. Santos
2008-07-07 19:42   ` Jose R. Santos
2008-07-07 22:30     ` Theodore Tso
2008-07-07 16:46 ` Theodore Tso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).