Linux-BTRFS Archive on lore.kernel.org
 help / Atom feed
* [PATCH] btrfs: tree-checker: Don't check max block group size as current max chunk size limit is unreliable
@ 2018-11-23  1:06 Qu Wenruo
  2018-12-04 10:15 ` Qu Wenruo
  0 siblings, 1 reply; 5+ messages in thread
From: Qu Wenruo @ 2018-11-23  1:06 UTC (permalink / raw)
  To: linux-btrfs; +Cc: stable

[BUG]
A completely valid btrfs will refuse to mount, with error message like:
  BTRFS critical (device sdb2): corrupt leaf: root=2 block=239681536 slot=172 \
    bg_start=12018974720 bg_len=10888413184, invalid block group size, \
    have 10888413184 expect (0, 10737418240]

Btrfs check returns no error, and all kernels used on this fs is later
than 2011, which should all have the 10G size limit commit.

[CAUSE]
For a 12 devices btrfs, we could allocate a chunk larger than 10G due to
stripe stripe bump up.

__btrfs_alloc_chunk()
|- max_stripe_size = 1G
|- max_chunk_size = 10G
|- data_stripe = 11
|- if (1G * 11 > 10G) {
       stripe_size = 976128930;
       stripe_size = round_up(976128930, SZ_16M) = 989855744

However the final stripe_size (989855744) * 11 = 10888413184, which is
still larger than 10G.

[FIX]
For the comprehensive check, we need to do the full check at chunk
read time, and rely on bg <-> chunk mapping to do the check.

We could just skip the length check for now.

Fixes: fce466eab7ac ("btrfs: tree-checker: Verify block_group_item")
Cc: stable@vger.kernel.org # v4.19+
Reported-by: Wang Yugui <wangyugui@e16-tech.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 fs/btrfs/tree-checker.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c
index cab0b1f1f741..d8bd5340fbbc 100644
--- a/fs/btrfs/tree-checker.c
+++ b/fs/btrfs/tree-checker.c
@@ -389,13 +389,11 @@ static int check_block_group_item(struct btrfs_fs_info *fs_info,
 
 	/*
 	 * Here we don't really care about alignment since extent allocator can
-	 * handle it.  We care more about the size, as if one block group is
-	 * larger than maximum size, it's must be some obvious corruption.
+	 * handle it.  We care more about the size.
 	 */
-	if (key->offset > BTRFS_MAX_DATA_CHUNK_SIZE || key->offset == 0) {
+	if (key->offset == 0) {
 		block_group_err(fs_info, leaf, slot,
-			"invalid block group size, have %llu expect (0, %llu]",
-				key->offset, BTRFS_MAX_DATA_CHUNK_SIZE);
+				"invalid block group size 0");
 		return -EUCLEAN;
 	}
 
-- 
2.19.1


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

* Re: [PATCH] btrfs: tree-checker: Don't check max block group size as current max chunk size limit is unreliable
  2018-11-23  1:06 [PATCH] btrfs: tree-checker: Don't check max block group size as current max chunk size limit is unreliable Qu Wenruo
@ 2018-12-04 10:15 ` Qu Wenruo
  2018-12-04 13:38   ` David Sterba
  2018-12-04 13:52   ` David Sterba
  0 siblings, 2 replies; 5+ messages in thread
From: Qu Wenruo @ 2018-12-04 10:15 UTC (permalink / raw)
  To: Qu Wenruo, linux-btrfs, David Sterba; +Cc: stable

[-- Attachment #1.1: Type: text/plain, Size: 2519 bytes --]

Gentle ping.

Please put this patch into current release as the new block group size
limit check introduced in v4.19 is causing at least 2 reports in mail list.

Thanks,
Qu

On 2018/11/23 上午9:06, Qu Wenruo wrote:
> [BUG]
> A completely valid btrfs will refuse to mount, with error message like:
>   BTRFS critical (device sdb2): corrupt leaf: root=2 block=239681536 slot=172 \
>     bg_start=12018974720 bg_len=10888413184, invalid block group size, \
>     have 10888413184 expect (0, 10737418240]
> 
> Btrfs check returns no error, and all kernels used on this fs is later
> than 2011, which should all have the 10G size limit commit.
> 
> [CAUSE]
> For a 12 devices btrfs, we could allocate a chunk larger than 10G due to
> stripe stripe bump up.
> 
> __btrfs_alloc_chunk()
> |- max_stripe_size = 1G
> |- max_chunk_size = 10G
> |- data_stripe = 11
> |- if (1G * 11 > 10G) {
>        stripe_size = 976128930;
>        stripe_size = round_up(976128930, SZ_16M) = 989855744
> 
> However the final stripe_size (989855744) * 11 = 10888413184, which is
> still larger than 10G.
> 
> [FIX]
> For the comprehensive check, we need to do the full check at chunk
> read time, and rely on bg <-> chunk mapping to do the check.
> 
> We could just skip the length check for now.
> 
> Fixes: fce466eab7ac ("btrfs: tree-checker: Verify block_group_item")
> Cc: stable@vger.kernel.org # v4.19+
> Reported-by: Wang Yugui <wangyugui@e16-tech.com>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
>  fs/btrfs/tree-checker.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c
> index cab0b1f1f741..d8bd5340fbbc 100644
> --- a/fs/btrfs/tree-checker.c
> +++ b/fs/btrfs/tree-checker.c
> @@ -389,13 +389,11 @@ static int check_block_group_item(struct btrfs_fs_info *fs_info,
>  
>  	/*
>  	 * Here we don't really care about alignment since extent allocator can
> -	 * handle it.  We care more about the size, as if one block group is
> -	 * larger than maximum size, it's must be some obvious corruption.
> +	 * handle it.  We care more about the size.
>  	 */
> -	if (key->offset > BTRFS_MAX_DATA_CHUNK_SIZE || key->offset == 0) {
> +	if (key->offset == 0) {
>  		block_group_err(fs_info, leaf, slot,
> -			"invalid block group size, have %llu expect (0, %llu]",
> -				key->offset, BTRFS_MAX_DATA_CHUNK_SIZE);
> +				"invalid block group size 0");
>  		return -EUCLEAN;
>  	}
>  
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH] btrfs: tree-checker: Don't check max block group size as current max chunk size limit is unreliable
  2018-12-04 10:15 ` Qu Wenruo
@ 2018-12-04 13:38   ` David Sterba
  2018-12-04 13:52   ` David Sterba
  1 sibling, 0 replies; 5+ messages in thread
From: David Sterba @ 2018-12-04 13:38 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: Qu Wenruo, linux-btrfs, David Sterba, stable

On Tue, Dec 04, 2018 at 06:15:13PM +0800, Qu Wenruo wrote:
> Gentle ping.
> 
> Please put this patch into current release as the new block group size
> limit check introduced in v4.19 is causing at least 2 reports in mail list.

I see, on the way to 4.20-rc with stable tags. Thanks.

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

* Re: [PATCH] btrfs: tree-checker: Don't check max block group size as current max chunk size limit is unreliable
  2018-12-04 10:15 ` Qu Wenruo
  2018-12-04 13:38   ` David Sterba
@ 2018-12-04 13:52   ` David Sterba
  2018-12-04 14:10     ` Qu Wenruo
  1 sibling, 1 reply; 5+ messages in thread
From: David Sterba @ 2018-12-04 13:52 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: Qu Wenruo, linux-btrfs, David Sterba, stable

On Tue, Dec 04, 2018 at 06:15:13PM +0800, Qu Wenruo wrote:
> Gentle ping.
> 
> Please put this patch into current release as the new block group size
> limit check introduced in v4.19 is causing at least 2 reports in mail list.

BTW, if there's an urgent fix or patch that should be considered for
current devel cycle, please note that in the subject like

  [PATCH for 4.20-rc] btrfs: ...

to make it more visible.

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

* Re: [PATCH] btrfs: tree-checker: Don't check max block group size as current max chunk size limit is unreliable
  2018-12-04 13:52   ` David Sterba
@ 2018-12-04 14:10     ` Qu Wenruo
  0 siblings, 0 replies; 5+ messages in thread
From: Qu Wenruo @ 2018-12-04 14:10 UTC (permalink / raw)
  To: dsterba, Qu Wenruo, linux-btrfs, stable

[-- Attachment #1.1: Type: text/plain, Size: 582 bytes --]



On 2018/12/4 下午9:52, David Sterba wrote:
> On Tue, Dec 04, 2018 at 06:15:13PM +0800, Qu Wenruo wrote:
>> Gentle ping.
>>
>> Please put this patch into current release as the new block group size
>> limit check introduced in v4.19 is causing at least 2 reports in mail list.
> 
> BTW, if there's an urgent fix or patch that should be considered for
> current devel cycle, please note that in the subject like
> 
>   [PATCH for 4.20-rc] btrfs: ...
> 
> to make it more visible.
> 

Great thanks for this hint!

Just forgot we have such tag.

Thanks,
Qu


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-23  1:06 [PATCH] btrfs: tree-checker: Don't check max block group size as current max chunk size limit is unreliable Qu Wenruo
2018-12-04 10:15 ` Qu Wenruo
2018-12-04 13:38   ` David Sterba
2018-12-04 13:52   ` David Sterba
2018-12-04 14:10     ` Qu Wenruo

Linux-BTRFS Archive on lore.kernel.org

Archives are clonable: git clone --mirror https://lore.kernel.org/linux-btrfs/0 linux-btrfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-btrfs linux-btrfs/ https://lore.kernel.org/linux-btrfs \
		linux-btrfs@vger.kernel.org linux-btrfs@archiver.kernel.org
	public-inbox-index linux-btrfs


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-btrfs


AGPL code for this site: git clone https://public-inbox.org/ public-inbox