Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6250440iob; Tue, 10 May 2022 14:00:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyi4gwj1XtbIHVXGpbSiXAIDTIB5xcG8Wa4pWMAQqp8fTsnEyKfwLeqf60zH107w4nwSKt0 X-Received: by 2002:a63:89c7:0:b0:3da:ee16:c84 with SMTP id v190-20020a6389c7000000b003daee160c84mr3692364pgd.320.1652216409220; Tue, 10 May 2022 14:00:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652216409; cv=none; d=google.com; s=arc-20160816; b=TdSB41/Jd4ywABWEPuyD5j7FCfAUGYv4Nualw6iArtjpNrxAMx139ncGP5hqYSMTq0 WSKGnYqyojlEmTBLDiVoyeYwxctM0gHNapArID7PxMv6v+ChU7++WRMaO9dOhhol/W3P 9Eo0ujDcUEckmxdc+Vgvd0D89LeLtwrsYMHR5UZ4iZzSD7mIjKFdhjEBpYqPz/bQVfnG KG/2bteLqwjR9nko7le/sPjCTs/MB9DtuZO2s7lTPSfl05zZIgMx9e+dIEiPKciodaXK i+NcfKplfNF9dAH4fCVXcTD4UtLrXKOw0VDiJ1ZxfwW9TO99LFTRxiqC6HKXTlC8bOo3 tmZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nOaO/s0xPq96q5halqG0fuXKiw4zXwkGuMjnYr6NKSM=; b=yYodsOahiUAX1y0DrcPLvDlE2uXcMY2m2oEkPInzLXzjEHgIZqMmhGYSXZf23Qs5KT 7d1QERUlErZXABZ5h1yVnyCinHAgWdehWl35QktQABknefEmNTgjR1t1UYDXO+T3zUpR hXQAiNupEstJDfIzNlIIR9VTJTNihEYD56DsHU8Rkd8SMH0i534Q4Gr4hTTOOjH759QG fXdMzTUTmdpUFlYV3gouy5WCDq1osW/FTH4TKLWLC6qCgZ76j2gvaFwnKqQfBbHGZ2rF x67+fXRzjeHZBdJn+ebpG7FEpIm/d2OS2ySYqR5l87rr6DDgs5OpuwH1CfPL9tSxARi/ 5WNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cTTVYKZ8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 30-20020a63145e000000b003a94e627cc2si349574pgu.360.2022.05.10.13.59.49; Tue, 10 May 2022 14:00:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cTTVYKZ8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245754AbiEJOQH (ORCPT + 99 others); Tue, 10 May 2022 10:16:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343517AbiEJNsL (ORCPT ); Tue, 10 May 2022 09:48:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6BF32AED8D; Tue, 10 May 2022 06:36:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AB70E618C1; Tue, 10 May 2022 13:36:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0806C385C2; Tue, 10 May 2022 13:36:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652189790; bh=ICoUCWveMjVxL0JXl/i8DtIZOEvJ3uy+U5E1ZTjNeo4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cTTVYKZ8lHuGqO2EBTh/OgDTbPLjDY/7r/JVwNZt1X4Qm818us/odsweZ2EngjAzZ z3LmWHXJIj0l/OalpiMFmF6uKRYz7KW5WwVkLFp4/I73yVHdVKJCieJXtqSZWWICmT EdGj4aGodP2FMLsKtJvjrzCdDQw1Soc5LdLKkg1I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Matt Corallo , Josef Bacik , Qu Wenruo , David Sterba Subject: [PATCH 5.17 029/140] btrfs: force v2 space cache usage for subpage mount Date: Tue, 10 May 2022 15:06:59 +0200 Message-Id: <20220510130742.446962329@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220510130741.600270947@linuxfoundation.org> References: <20220510130741.600270947@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Qu Wenruo commit 9f73f1aef98b2fa7252c0a89be64840271ce8ea0 upstream. [BUG] For a 4K sector sized btrfs with v1 cache enabled and only mounted on systems with 4K page size, if it's mounted on subpage (64K page size) systems, it can cause the following warning on v1 space cache: BTRFS error (device dm-1): csum mismatch on free space cache BTRFS warning (device dm-1): failed to load free space cache for block group 84082688, rebuilding it now Although not a big deal, as kernel can rebuild it without problem, such warning will bother end users, especially if they want to switch the same btrfs seamlessly between different page sized systems. [CAUSE] V1 free space cache is still using fixed PAGE_SIZE for various bitmap, like BITS_PER_BITMAP. Such hard-coded PAGE_SIZE usage will cause various mismatch, from v1 cache size to checksum. Thus kernel will always reject v1 cache with a different PAGE_SIZE with csum mismatch. [FIX] Although we should fix v1 cache, it's already going to be marked deprecated soon. And we have v2 cache based on metadata (which is already fully subpage compatible), and it has almost everything superior than v1 cache. So just force subpage mount to use v2 cache on mount. Reported-by: Matt Corallo CC: stable@vger.kernel.org # 5.15+ Link: https://lore.kernel.org/linux-btrfs/61aa27d1-30fc-c1a9-f0f4-9df544395ec3@bluematt.me/ Reviewed-by: Josef Bacik Signed-off-by: Qu Wenruo Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/disk-io.c | 11 +++++++++++ 1 file changed, 11 insertions(+) --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -3569,6 +3569,17 @@ int __cold open_ctree(struct super_block if (sectorsize < PAGE_SIZE) { struct btrfs_subpage_info *subpage_info; + /* + * V1 space cache has some hardcoded PAGE_SIZE usage, and is + * going to be deprecated. + * + * Force to use v2 cache for subpage case. + */ + btrfs_clear_opt(fs_info->mount_opt, SPACE_CACHE); + btrfs_set_and_info(fs_info, FREE_SPACE_TREE, + "forcing free space tree for sector size %u with page size %lu", + sectorsize, PAGE_SIZE); + btrfs_warn(fs_info, "read-write for sector size %u with page size %lu is experimental", sectorsize, PAGE_SIZE);