Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10796613imu; Thu, 6 Dec 2018 06:59:03 -0800 (PST) X-Google-Smtp-Source: AFSGD/VnumbWTcHAaUCbiBOE7E+KovIt/0YjY7CD65fj+YK8WEQ4NI3LMZfYGr8/Cp8MVTB4ogwA X-Received: by 2002:a63:94:: with SMTP id 142mr23926695pga.74.1544108343437; Thu, 06 Dec 2018 06:59:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544108343; cv=none; d=google.com; s=arc-20160816; b=R+qGLXnfE9xyGpohnI1BgNLQYCbfk7PGpI3VSAv11ZxNEo9gWorqOpt7+jO8n6lY+p 5euWVyTwcf2GNvm6t9lVJs93JuRjmcBnPx7cywPZ3/T8tuhkLC171U+T7Kcw8SZ4d2os 3CQzLNy1ogsGSKaSmhMUXsU3t0bkCtr+7nPH7rwKUaLWUJicYZ6bY8PBpSZF+SQ6a/8G RSMs3GVzm6XTgRRgeDXE/l23E5qQtEmACBNjLRg8nE5wRRHfIVxdtFYJUEoO+WrwWYjL AWgl4+8NRC9OmIjaawLxeH2VjQfzCau/FnmoQlzavJ9mQXxqhQmCMEJAWhV2cG0w5Rx/ Z16A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wAS+k/isAWuisgEN+rn5cvdET3jEoTsRsCRtmS1+lJs=; b=ENQUUTf6FTqruezmi5/Z5epIj0mzcQpdVrH1mkTKk73slkkp4GQWo2whXudazZcSN2 ZO4KlYEJ6zceJNpQV9cze+aOL+bmzoKpVTFUHuceV/hqjFS7xyrdsSkhqJv4E38pyIla 9wqOlsU96+I4Iz9JGGkJTaBQYKKVDHkYHLltb00WbWXzF4miwwJ0Jrwug2y3RL/BtNqj BlGdxTvXzPyozlCLE1L40PGAVmdKpG47k1y8FGjX+t6o5WNU4oRZyhD6m+B9h/hZ1Tgt oGE3oySMyY0W+AdX9C8RIu+0daL4MX8eHoWTjIR7RxfzcLFYAYVV00tYTrC44UatoP1v E0oQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=In+yPXFG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u3si431467plb.99.2018.12.06.06.58.48; Thu, 06 Dec 2018 06:59:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=In+yPXFG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726427AbeLFO5D (ORCPT + 99 others); Thu, 6 Dec 2018 09:57:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:47448 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729726AbeLFOnC (ORCPT ); Thu, 6 Dec 2018 09:43:02 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 50ECF2082B; Thu, 6 Dec 2018 14:43:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544107381; bh=MzA5iKNYccFloCOq7qddigWTtPNYL/7nsoJRAD+Fn+c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=In+yPXFGhoxGg32uC+dTUyJ7XJP1bSaV9mTJhQmlGjapQ/euCfwJVgzm0P0stucbD dXOeRCyJxvhVWyasPeH108l3qZWhyELDWo+1ItycybNSnXY+OUKt7gtPH6plrHlo2i 0TWhpkyxC5cuB8RlnMudTjyrcyJ9h4+A6EXJKCBI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wang Yugui , Qu Wenruo , David Sterba Subject: [PATCH 4.14 40/55] btrfs: tree-checker: Dont check max block group size as current max chunk size limit is unreliable Date: Thu, 6 Dec 2018 15:39:14 +0100 Message-Id: <20181206143003.870816990@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206143001.749982936@linuxfoundation.org> References: <20181206143001.749982936@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Qu Wenruo commit 10950929e994c5ecee149ff0873388d3c98f12b5 upstream. [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] This has been reported several times as the 4.19 kernel is now being used. The filesystem refuses to mount, but is otherwise ok and booting 4.18 is a workaround. 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 Signed-off-by: Qu Wenruo Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/tree-checker.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) --- a/fs/btrfs/tree-checker.c +++ b/fs/btrfs/tree-checker.c @@ -348,13 +348,11 @@ static int check_block_group_item(struct /* * 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; }