Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6248382iob; Tue, 10 May 2022 13:56:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUfmFScbmqO7/EZ6qME1mPqH0U5WMxg1bKkHqQQcnQEdatCM6pGbqMhRijwLL9md9Pe5j2 X-Received: by 2002:a17:907:3f29:b0:6f4:cb04:a6f5 with SMTP id hq41-20020a1709073f2900b006f4cb04a6f5mr21457698ejc.115.1652216186589; Tue, 10 May 2022 13:56:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652216186; cv=none; d=google.com; s=arc-20160816; b=qS4TjPHQoAl9xKUHIIj0m1zMWMzmVtEx6gdfeuhet3FuhtAUlk5CELcJvt6sSZBRwb bXA3Xe11Lv00P9GZTFhA5wpxrXlgdhqbS+92rqfzf/FtUoLg9kfOhS/JnKaeq9kf/8B5 NHjL+erbxHdEDA4GJbuAmdJIt/cQ0K8NI/MmYYU0b3i7x1dUSIOs9jzMvv+OxES2L2E/ n+335EJKIHSyM7G4FBAnt6D1T0MP1qSPMhBx57uK89MoDUTAvWQ03ArblrsB9/+SdL/r bp4obKgff2KxvSFq8QwOV8QCK6zR/AlqCtszHxzMP72r6LBCQ9N9ECGC1H/MJ776t6oc TFog== 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=Gcb3UJtw/GTSKD/OWx133DCck4pPHWQgGznWzXf+qvg=; b=cAofz9Flc2+EtTQUjq7IF/e8G2E2VNUYzxT3905yZA0S8GaUpDqe6cSXfWYabIxTxj QvahisjjLEYAsiDY4la/odbGY5EJlqWgSUo9jhuq9TaFGz4MauLbMKdLOoEyIA73o8+d 3alAwWPlcmz5M7bRFzXf01SPszC/DCuKHqRvEtZgF399T/Vwdog+SQ12oMcTYn8pzgHn daVqnBQaG1OFvXpkHl1AyjHYw8uuydExGLvIj2LvA9GvVV1ytEY8UmMt9NYePY+B6oEc sc4iokhtxVlGlu3Qog+e8ISIhph4BIy4SJL5kM+I5lfBX/WJIBpoSVf2pJ5w536Lg+Zy cy2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=j75TrZCS; 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 rl24-20020a170907217800b006f3a070d863si279477ejb.710.2022.05.10.13.56.03; Tue, 10 May 2022 13:56:26 -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=j75TrZCS; 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 S244614AbiEJOJE (ORCPT + 99 others); Tue, 10 May 2022 10:09:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244872AbiEJNrE (ORCPT ); Tue, 10 May 2022 09:47:04 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BE681B090B; Tue, 10 May 2022 06:32:19 -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 sin.source.kernel.org (Postfix) with ESMTPS id E5012CE1EF0; Tue, 10 May 2022 13:32:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3322C385C6; Tue, 10 May 2022 13:32:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652189536; bh=qwSQxW4053RPG9LwGxHuLd7tkBgQhDyBH+bD/XchwME=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j75TrZCSP9UI0QUb08CaX/lPx7fqh+AALvRVuuvNnmYSwqRt7Z8ZQuq4noQ0nthQS uv/jTwRKJ6dSCN8Lzot7yh0J1IAxoQiwbXcldpP/trJzdhPyA89FKVucniGlCA+s+U 4vmbx22pe7nliWADDIjHknBrPVsUgbGCCPMH519I= 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.15 080/135] btrfs: force v2 space cache usage for subpage mount Date: Tue, 10 May 2022 15:07:42 +0200 Message-Id: <20220510130742.705596847@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220510130740.392653815@linuxfoundation.org> References: <20220510130740.392653815@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 @@ -3415,6 +3415,17 @@ int __cold open_ctree(struct super_block } if (sectorsize != PAGE_SIZE) { + /* + * 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);