linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: Find the group descriptors on a 1k-block bigalloc,meta_bg filesystem
@ 2013-12-20  0:15 Darrick J. Wong
  2014-03-11  7:02 ` Darrick J. Wong
  2014-05-12 14:07 ` Theodore Ts'o
  0 siblings, 2 replies; 4+ messages in thread
From: Darrick J. Wong @ 2013-12-20  0:15 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: linux-ext4

On a filesystem with a 1k block size, the group descriptors live in
block 2, not block 1.  If the filesystem has bigalloc,meta_bg set,
however, the calculation of the group descriptor table location does
not take this into account and returns the wrong block number.  Fix
the calculation to return the correct value for this case.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/ext4/super.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 7f52a54..d968c64 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -2420,6 +2420,16 @@ static ext4_fsblk_t descriptor_loc(struct super_block *sb,
 	if (ext4_bg_has_super(sb, bg))
 		has_super = 1;
 
+	/*
+	 * If we have a meta_bg fs with 1k blocks, group 0's GDT is at
+	 * block 2, not 1.  If s_first_data_block == 0 (bigalloc is enabled
+	 * on modern mke2fs or blksize > 1k on older mke2fs) then we must
+	 * compensate.
+	 */
+	if (sb->s_blocksize == 1024 && nr == 0 &&
+	    le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block) == 0)
+		has_super++;
+
 	return (has_super + ext4_group_first_block_no(sb, bg));
 }
 

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

* Re: [PATCH] ext4: Find the group descriptors on a 1k-block bigalloc,meta_bg filesystem
  2013-12-20  0:15 [PATCH] ext4: Find the group descriptors on a 1k-block bigalloc,meta_bg filesystem Darrick J. Wong
@ 2014-03-11  7:02 ` Darrick J. Wong
  2014-05-12 14:07 ` Theodore Ts'o
  1 sibling, 0 replies; 4+ messages in thread
From: Darrick J. Wong @ 2014-03-11  7:02 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: linux-ext4

On Thu, Dec 19, 2013 at 04:15:42PM -0800, Darrick J. Wong wrote:
> On a filesystem with a 1k block size, the group descriptors live in
> block 2, not block 1.  If the filesystem has bigalloc,meta_bg set,
> however, the calculation of the group descriptor table location does
> not take this into account and returns the wrong block number.  Fix
> the calculation to return the correct value for this case.

Hey Ted,

Any comments on this one?

--D
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  fs/ext4/super.c |   10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index 7f52a54..d968c64 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -2420,6 +2420,16 @@ static ext4_fsblk_t descriptor_loc(struct super_block *sb,
>  	if (ext4_bg_has_super(sb, bg))
>  		has_super = 1;
>  
> +	/*
> +	 * If we have a meta_bg fs with 1k blocks, group 0's GDT is at
> +	 * block 2, not 1.  If s_first_data_block == 0 (bigalloc is enabled
> +	 * on modern mke2fs or blksize > 1k on older mke2fs) then we must
> +	 * compensate.
> +	 */
> +	if (sb->s_blocksize == 1024 && nr == 0 &&
> +	    le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block) == 0)
> +		has_super++;
> +
>  	return (has_super + ext4_group_first_block_no(sb, bg));
>  }
>  
> --
> 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

* [PATCH] ext4: Find the group descriptors on a 1k-block bigalloc,meta_bg filesystem
@ 2014-04-23  3:30 Darrick J. Wong
  0 siblings, 0 replies; 4+ messages in thread
From: Darrick J. Wong @ 2014-04-23  3:30 UTC (permalink / raw)
  To: tytso, darrick.wong; +Cc: linux-ext4

On a filesystem with a 1k block size, the group descriptors live in
block 2, not block 1.  If the filesystem has bigalloc,meta_bg set,
however, the calculation of the group descriptor table location does
not take this into account and returns the wrong block number.  Fix
the calculation to return the correct value for this case.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/ext4/super.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index f3c6670..ef78d13 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -2404,6 +2404,16 @@ static ext4_fsblk_t descriptor_loc(struct super_block *sb,
 	if (ext4_bg_has_super(sb, bg))
 		has_super = 1;
 
+	/*
+	 * If we have a meta_bg fs with 1k blocks, group 0's GDT is at
+	 * block 2, not 1.  If s_first_data_block == 0 (bigalloc is enabled
+	 * on modern mke2fs or blksize > 1k on older mke2fs) then we must
+	 * compensate.
+	 */
+	if (sb->s_blocksize == 1024 && nr == 0 &&
+	    le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block) == 0)
+		has_super++;
+
 	return (has_super + ext4_group_first_block_no(sb, bg));
 }
 

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

* Re: [PATCH] ext4: Find the group descriptors on a 1k-block bigalloc,meta_bg filesystem
  2013-12-20  0:15 [PATCH] ext4: Find the group descriptors on a 1k-block bigalloc,meta_bg filesystem Darrick J. Wong
  2014-03-11  7:02 ` Darrick J. Wong
@ 2014-05-12 14:07 ` Theodore Ts'o
  1 sibling, 0 replies; 4+ messages in thread
From: Theodore Ts'o @ 2014-05-12 14:07 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-ext4

On Thu, Dec 19, 2013 at 04:15:42PM -0800, Darrick J. Wong wrote:
> On a filesystem with a 1k block size, the group descriptors live in
> block 2, not block 1.  If the filesystem has bigalloc,meta_bg set,
> however, the calculation of the group descriptor table location does
> not take this into account and returns the wrong block number.  Fix
> the calculation to return the correct value for this case.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Thanks, applied.

					- Ted

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

end of thread, other threads:[~2014-05-12 14:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-20  0:15 [PATCH] ext4: Find the group descriptors on a 1k-block bigalloc,meta_bg filesystem Darrick J. Wong
2014-03-11  7:02 ` Darrick J. Wong
2014-05-12 14:07 ` Theodore Ts'o
  -- strict thread matches above, loose matches on Subject: below --
2014-04-23  3:30 Darrick J. Wong

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