From patchwork Thu Oct 29 23:57:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Burkov X-Patchwork-Id: 11867909 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B023C2D0A3 for ; Thu, 29 Oct 2020 23:58:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 944992076A for ; Thu, 29 Oct 2020 23:58:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bur.io header.i=@bur.io header.b="Mu8UvkLF"; dkim=temperror (0-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="rFtStaxz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726036AbgJ2X61 (ORCPT ); Thu, 29 Oct 2020 19:58:27 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:59305 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725372AbgJ2X61 (ORCPT ); Thu, 29 Oct 2020 19:58:27 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 6381D5C00DD; Thu, 29 Oct 2020 19:58:26 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 29 Oct 2020 19:58:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bur.io; h=from :to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=fm2; bh=E42VkJKfxNqb9pRNLMWP7Aw4rQ hI7nJQushHWEDcPBE=; b=Mu8UvkLFamEsmpfx/QvU9B5ZYvsovibKAcPxtd6iHs VahmxPF6lecCJGORD3FY6D2bDU+EW1oEtWUPwJYyTL+e958h53S1b1Ec/OIr9imd 30pgFnfwp9gx2UkjkEg9bXgCya7jApZUbypU8VaO5BL/gM9ttmisc113Y45wvMIk 1UoE/AfPCMMtSkdMNH0Xp5lClW45MyPtr/8thdEP0vUD8sh9Udl1Al2vsj6yU2M0 zDslxBfSEREOKCB8zTVB7npW2J8OlRUl9W4TK7O0GW2WzhEjf+/SE/JhHbhZbZ1k 9hYfNLCP6KLNG3Luiv3qJzmM1JhcaYHHCWB4PWytgTMA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=E42VkJKfxNqb9pRNLMWP7Aw4rQhI7nJQushHWEDcPBE=; b=rFtStaxz HXJBaIuv91I3uVYapirUPdxcX63CCPOvCo7itINl+BAdGyHtStt/4wPtUuVq3FlL KlxpQDpeutdvaeuIC+oBJ7v4dUbSqJ6re0ARCetVTz8hB9/SEDEt2CaMo/rpfbFO SeVa6jVJZ3urU9fCIGDP93iLXyTDPNHH+NTe1BbWtp6YLWnYhP13LsC1fuwVANhP Zj80z30g0Q0Fkyw1xBx10ofsWqpOFmHTWyWhYW6vdjke88u/Vk1LhkfLMwYbCZ/5 a2h9WABV6mGrKBNwhj8k83WPqEdZUr5NLcsjSDSTIuHNWLxfvKiRf/SH0xcINIoF QjD/HQf2qrVwcw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrleeggdduiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtkeertd ertddtnecuhfhrohhmpeeuohhrihhsuceuuhhrkhhovhcuoegsohhrihhssegsuhhrrdhi oheqnecuggftrfgrthhtvghrnhepieeuffeuvdeiueejhfehiefgkeevudejjeejffevvd ehtddufeeihfekgeeuheelnecukfhppeduieefrdduudegrddufedvrdefnecuvehluhhs thgvrhfuihiivgepjeenucfrrghrrghmpehmrghilhhfrhhomhepsghorhhishessghurh drihho X-ME-Proxy: Received: from localhost (unknown [163.114.132.3]) by mail.messagingengine.com (Postfix) with ESMTPA id 004B33280063; Thu, 29 Oct 2020 19:58:26 -0400 (EDT) From: Boris Burkov To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v6 08/10] btrfs: warn when remount will not change the free space tree Date: Thu, 29 Oct 2020 16:57:55 -0700 Message-Id: X-Mailer: git-send-email 2.24.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org If the remount is ro->ro, rw->ro, or rw->rw, we will not create or clear the free space tree. This can be surprising, so print a warning to dmesg to make the failure more visible. It is also important to ensure that the space cache options (SPACE_CACHE, FREE_SPACE_TREE) are consistent, so ensure those are set to properly match the current on disk state (which won't be changing). Signed-off-by: Boris Burkov --- fs/btrfs/super.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 527ab305ac68..ed5c80f92f78 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -1914,6 +1914,24 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data) btrfs_resize_thread_pool(fs_info, fs_info->thread_pool_size, old_thread_pool_size); + if (btrfs_test_opt(fs_info, FREE_SPACE_TREE) != + btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE) && + ((!sb_rdonly(sb) || *flags & SB_RDONLY))) { + btrfs_warn(fs_info, + "remount supports changing free space tree only from ro to rw"); + /* + * Make sure free space cache options match the state on disk + */ + if (btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE)) { + btrfs_set_opt(fs_info->mount_opt, FREE_SPACE_TREE); + btrfs_clear_opt(fs_info->mount_opt, SPACE_CACHE); + } + if (btrfs_free_space_cache_v1_active(fs_info)) { + btrfs_clear_opt(fs_info->mount_opt, FREE_SPACE_TREE); + btrfs_set_opt(fs_info->mount_opt, SPACE_CACHE); + } + } + if ((bool)(*flags & SB_RDONLY) == sb_rdonly(sb)) goto out;