2008-01-26 11:38:54

by Aneesh Kumar K.V

[permalink] [raw]
Subject: Patch for 2.6.25 queue

This diff contain mballoc fixes and update for ext3-4 migrate patch.

Testing:
ext3 to ext4 migration.

I will be putting the patch queue for abat test now.

-aneesh

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index ebcd25e..99d16f5 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -62,7 +62,7 @@ static ext4_fsblk_t ext_pblock(struct ext4_extent *ex)
* idx_pblock:
* combine low and high parts of a leaf physical block number into ext4_fsblk_t
*/
-static ext4_fsblk_t idx_pblock(struct ext4_extent_idx *ix)
+ext4_fsblk_t idx_pblock(struct ext4_extent_idx *ix)
{
ext4_fsblk_t block;

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index a60672c..9de0cdf 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2723,7 +2723,7 @@ int ext4_mb_release(struct super_block *sb)
#endif
ext4_lock_group(sb, i);
ext4_mb_cleanup_pa(grinfo);
- ext4_lock_group(sb, i);
+ ext4_unlock_group(sb, i);
kfree(grinfo);
}
num_meta_group_infos = (sbi->s_groups_count +
@@ -4452,7 +4452,6 @@ do_more:
overflow = bit + count - EXT4_BLOCKS_PER_GROUP(sb);
count -= overflow;
}
- put_bh(bitmap_bh);
bitmap_bh = read_block_bitmap(sb, block_group);
if (!bitmap_bh)
goto error_return;
diff --git a/fs/ext4/migrate.c b/fs/ext4/migrate.c
index 70a4d9c..3ebc233 100644
--- a/fs/ext4/migrate.c
+++ b/fs/ext4/migrate.c
@@ -342,16 +342,6 @@ err_out:
return retval;
}

-/* Will go away */
-static ext4_fsblk_t idx_pblock(struct ext4_extent_idx *ix)
-{
- ext4_fsblk_t block;
-
- block = le32_to_cpu(ix->ei_leaf_lo);
- block |= ((ext4_fsblk_t) le16_to_cpu(ix->ei_leaf_hi) << 31) << 1;
- return block;
-}
-
static int free_ext_idx(handle_t *handle, struct inode *inode,
struct ext4_extent_idx *ix)
{
@@ -366,9 +356,7 @@ static int free_ext_idx(handle_t *handle, struct inode *inode,
return -EIO;

eh = (struct ext4_extent_header *)bh->b_data;
- if (eh->eh_depth == 0)
- ext4_free_blocks(handle, inode, block, 1, 1);
- else {
+ if (eh->eh_depth != 0) {
ix = EXT_FIRST_INDEX(eh);
for (i = 0; i < le16_to_cpu(eh->eh_entries); i++, ix++) {
retval = free_ext_idx(handle, inode, ix);
@@ -377,6 +365,7 @@ static int free_ext_idx(handle_t *handle, struct inode *inode,
}
}
put_bh(bh);
+ ext4_free_blocks(handle, inode, block, 1, 1);
return retval;
}

diff --git a/include/linux/ext4_fs_extents.h b/include/linux/ext4_fs_extents.h
index f536b2f..697da4b 100644
--- a/include/linux/ext4_fs_extents.h
+++ b/include/linux/ext4_fs_extents.h
@@ -212,6 +212,7 @@ static inline int ext4_ext_get_actual_len(struct ext4_extent *ext)
(le16_to_cpu(ext->ee_len) - EXT_INIT_MAX_LEN));
}

+extern ext4_fsblk_t idx_pblock(struct ext4_extent_idx *);
extern void ext4_ext_store_pblock(struct ext4_extent *, ext4_fsblk_t);
extern int ext4_extent_tree_init(handle_t *, struct inode *);
extern int ext4_ext_calc_credits_for_insert(struct inode *, struct ext4_ext_path *);


2008-01-26 17:03:38

by Theodore Ts'o

[permalink] [raw]
Subject: Re: Patch for 2.6.25 queue

On Sat, Jan 26, 2008 at 05:08:49PM +0530, Aneesh Kumar K.V wrote:
> This diff contain mballoc fixes and update for ext3-4 migrate patch.

I will fold these patches into the patch queue in the proper places
(and adjust other patches as necessary).

> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index a60672c..9de0cdf 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -4452,7 +4452,6 @@ do_more:
> overflow = bit + count - EXT4_BLOCKS_PER_GROUP(sb);
> count -= overflow;
> }
> - put_bh(bitmap_bh);
> bitmap_bh = read_block_bitmap(sb, block_group);
> if (!bitmap_bh)
> goto error_return;

This patch hunk causes a failure due to a botched brelse->put_bh
conversion, but removing it isn't the right fix. It was there to
avoid a buffer leak on a goto. So the right fix is to remove the
put_bh() above, but to add one here, circa line 4542 of mballoc.c:

if (overflow && !err) {
block += count;
count = overflow;
+ put_bh(bitmap_bh);
goto do_more;
}

And once we do that, we can drop the initialization of bitmap_bh to
NULL, circa line 4408:

int metadata, unsigned long *freed)
{
- struct buffer_head *bitmap_bh = NULL;
+ struct buffer_head *bitmap_bh;
struct super_block *sb = inode->i_sb;
struct ext4_allocation_context ac;


- Ted

2008-01-26 17:14:59

by Theodore Ts'o

[permalink] [raw]
Subject: Re: Patch for 2.6.25 queue

On Sat, Jan 26, 2008 at 12:03:31PM -0500, Theodore Tso wrote:
> This patch hunk causes a failure due to a botched brelse->put_bh
> conversion, but removing it isn't the right fix.

Err, sorry, the above should read, "This patch hunk FIXES a failure"...

and if it wasn't clear, I was responsible for the initial botched
conversion. :-)

- Ted