linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] libext2fs: fix alloc_allocate_group_table() if the flexbg_offset wraps
@ 2014-04-28 14:09 Theodore Ts'o
  2014-04-28 14:09 ` [PATCH 2/2] resize2fs: fix inode table move for the backwards move case Theodore Ts'o
  2014-04-29 11:02 ` [PATCH 1/2] libext2fs: fix alloc_allocate_group_table() if the flexbg_offset wraps Lukáš Czerner
  0 siblings, 2 replies; 4+ messages in thread
From: Theodore Ts'o @ 2014-04-28 14:09 UTC (permalink / raw)
  To: Ext4 Developers List; +Cc: Theodore Ts'o

If the previous block group's inode table ends at the very end of file
system, wrap around to the beginning of the flex_bg.

This fixes a bug was tickled by:

mke2fs.conf:
	frontload = {
		features = extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize,^resize_inode,sparse_super2
		hash_alg = half_md4
		num_backup_sb = 0
		packed_meta_blocks = 1
		inode_ratio = 4194304
		flex_bg_size = 262144
	}

mke2fs -T frontload /tmp/foo.img 2T
resize2fs -M /tmp/foo.img
resize2fs -M /tmp/foo.img

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 lib/ext2fs/alloc_tables.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/ext2fs/alloc_tables.c b/lib/ext2fs/alloc_tables.c
index fec9003..bc99943 100644
--- a/lib/ext2fs/alloc_tables.c
+++ b/lib/ext2fs/alloc_tables.c
@@ -54,8 +54,8 @@ static blk64_t flexbg_offset(ext2_filsys fs, dgrp_t group, blk64_t start_blk,
 	 * Don't do a long search if the previous block
 	 * search is still valid.
 	 */
-	if (start_blk && ext2fs_test_block_bitmap_range2(bmap, start_blk,
-							 elem_size))
+	if (start_blk && start_blk < ext2fs_blocks_count(fs->super) &&
+	    ext2fs_test_block_bitmap_range2(bmap, start_blk, elem_size))
 		return start_blk;
 
 	start_blk = ext2fs_group_first_block2(fs, flexbg_size * flexbg);
-- 
1.9.0


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

* [PATCH 2/2] resize2fs: fix inode table move for the backwards move case
  2014-04-28 14:09 [PATCH 1/2] libext2fs: fix alloc_allocate_group_table() if the flexbg_offset wraps Theodore Ts'o
@ 2014-04-28 14:09 ` Theodore Ts'o
  2014-04-29 11:02 ` [PATCH 1/2] libext2fs: fix alloc_allocate_group_table() if the flexbg_offset wraps Lukáš Czerner
  1 sibling, 0 replies; 4+ messages in thread
From: Theodore Ts'o @ 2014-04-28 14:09 UTC (permalink / raw)
  To: Ext4 Developers List; +Cc: Theodore Ts'o

In the case where the new location of the inode table is before the
old inode table, the optimization which tries to optimize zero block
moves breaks.  Fix it.

This fixes a bug that was tickled by the reproduction described in the
previous commit.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 resize/resize2fs.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/resize/resize2fs.c b/resize/resize2fs.c
index 0d968fa..c672cdb 100644
--- a/resize/resize2fs.c
+++ b/resize/resize2fs.c
@@ -1869,6 +1869,8 @@ static errcode_t move_itables(ext2_resize_t rfs)
 
 		if (!diff)
 			continue;
+		if (diff < 0)
+			diff = 0;
 
 		retval = io_channel_read_blk64(fs->io, old_blk,
 					       fs->inode_blocks_per_group,
-- 
1.9.0


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

* Re: [PATCH 1/2] libext2fs: fix alloc_allocate_group_table() if the flexbg_offset wraps
  2014-04-28 14:09 [PATCH 1/2] libext2fs: fix alloc_allocate_group_table() if the flexbg_offset wraps Theodore Ts'o
  2014-04-28 14:09 ` [PATCH 2/2] resize2fs: fix inode table move for the backwards move case Theodore Ts'o
@ 2014-04-29 11:02 ` Lukáš Czerner
  2014-04-30  2:34   ` Theodore Ts'o
  1 sibling, 1 reply; 4+ messages in thread
From: Lukáš Czerner @ 2014-04-29 11:02 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: Ext4 Developers List

On Mon, 28 Apr 2014, Theodore Ts'o wrote:

> Date: Mon, 28 Apr 2014 10:09:38 -0400
> From: Theodore Ts'o <tytso@mit.edu>
> To: Ext4 Developers List <linux-ext4@vger.kernel.org>
> Cc: Theodore Ts'o <tytso@mit.edu>
> Subject: [PATCH 1/2] libext2fs: fix alloc_allocate_group_table() if the
>     flexbg_offset wraps
> 
> If the previous block group's inode table ends at the very end of file
> system, wrap around to the beginning of the flex_bg.
> 
> This fixes a bug was tickled by:
> 
> mke2fs.conf:
> 	frontload = {
> 		features = extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize,^resize_inode,sparse_super2
> 		hash_alg = half_md4
> 		num_backup_sb = 0
> 		packed_meta_blocks = 1
> 		inode_ratio = 4194304
> 		flex_bg_size = 262144
> 	}
> 
> mke2fs -T frontload /tmp/foo.img 2T
> resize2fs -M /tmp/foo.img
> resize2fs -M /tmp/foo.img
> 
> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
> ---
>  lib/ext2fs/alloc_tables.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/ext2fs/alloc_tables.c b/lib/ext2fs/alloc_tables.c
> index fec9003..bc99943 100644
> --- a/lib/ext2fs/alloc_tables.c
> +++ b/lib/ext2fs/alloc_tables.c
> @@ -54,8 +54,8 @@ static blk64_t flexbg_offset(ext2_filsys fs, dgrp_t group, blk64_t start_blk,
>  	 * Don't do a long search if the previous block
>  	 * search is still valid.
>  	 */
> -	if (start_blk && ext2fs_test_block_bitmap_range2(bmap, start_blk,
> -							 elem_size))
> +	if (start_blk && start_blk < ext2fs_blocks_count(fs->super) &&
> +	    ext2fs_test_block_bitmap_range2(bmap, start_blk, elem_size))
>  		return start_blk;

Not sure about this, but I just wonder whether this would work with
bigalloc file system as well since it is true that we're testing
blocks in this condition but in ext2fs_test_block_bitmap_range2()
we're searching for a free cluster.

-Lukas

>  
>  	start_blk = ext2fs_group_first_block2(fs, flexbg_size * flexbg);
> 

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

* Re: [PATCH 1/2] libext2fs: fix alloc_allocate_group_table() if the flexbg_offset wraps
  2014-04-29 11:02 ` [PATCH 1/2] libext2fs: fix alloc_allocate_group_table() if the flexbg_offset wraps Lukáš Czerner
@ 2014-04-30  2:34   ` Theodore Ts'o
  0 siblings, 0 replies; 4+ messages in thread
From: Theodore Ts'o @ 2014-04-30  2:34 UTC (permalink / raw)
  To: Lukáš Czerner; +Cc: Ext4 Developers List

On Tue, Apr 29, 2014 at 01:02:07PM +0200, Lukáš Czerner wrote:
> 
> Not sure about this, but I just wonder whether this would work with
> bigalloc file system as well since it is true that we're testing
> blocks in this condition but in ext2fs_test_block_bitmap_range2()
> we're searching for a free cluster.

No, we're fine because the bitmap functions takes block numbers as
arguments, not cluster numbers.  (The bitmap functions converts block
numbers to cluster numbers, and there's a special hack for mke2fs so
we don't burn a separate cluster for each allocation bitmap block.)

					- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2014-04-30  2:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-28 14:09 [PATCH 1/2] libext2fs: fix alloc_allocate_group_table() if the flexbg_offset wraps Theodore Ts'o
2014-04-28 14:09 ` [PATCH 2/2] resize2fs: fix inode table move for the backwards move case Theodore Ts'o
2014-04-29 11:02 ` [PATCH 1/2] libext2fs: fix alloc_allocate_group_table() if the flexbg_offset wraps Lukáš Czerner
2014-04-30  2:34   ` Theodore Ts'o

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).