From patchwork Fri Sep 23 00:24:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 9347231 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 36B36607EE for ; Fri, 23 Sep 2016 00:24:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2CF6F2AD1F for ; Fri, 23 Sep 2016 00:24:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 21E992AD22; Fri, 23 Sep 2016 00:24:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B82852AD1F for ; Fri, 23 Sep 2016 00:24:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965201AbcIWAYf (ORCPT ); Thu, 22 Sep 2016 20:24:35 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:34302 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964947AbcIWAYc (ORCPT ); Thu, 22 Sep 2016 20:24:32 -0400 Received: by mail-pa0-f46.google.com with SMTP id wk8so34098370pab.1 for ; Thu, 22 Sep 2016 17:24:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=fFAJYw1llgEsSrzn4DbtKnvH+AvtRnzIs6va3X9XSGs=; b=jdNRmDUZDP4HTHF3eb8zuU3JLcb/NqAlgGh2sqQdTJ95466bpuX0jCUZkNxViWKlDc 0HoLIhl5DD+20xEEuHy2Lm5pf1tzMSeop3BsTXFsaNokSlY9VdquyNk7dfEsvcQ5zH5L 5srsz5XnqVy0V2lgTzuDnTlmNV/Zngn+MvyI3RpPP3+dpNPycrgkg67pNLvgxSP1kbUP KsVNoferFdlYyJcAhcevRmhvNRs2EgIJ3FFcZmH5zNMd3RhoPp2MahRE58hcydUo40cM rAh7XhZTk5myHPvJ/df86yyhUZ3ZHv5AakqRBj+ZDWY+QtDhj6JZqeR2mQFot2gwsnBk elig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=fFAJYw1llgEsSrzn4DbtKnvH+AvtRnzIs6va3X9XSGs=; b=dLUJY7skqbxQEbo05pD+hv5kwzA2ycO7g5etr0M0lcZ94QYBAsIHw5cLeBzriUS1hm TZ7bBDbQ0YgzPKZdoTd18CuJsJ7flYci0cAfPx41eMB5Z1GhZLeOJZzERG4t9E5iiZ+1 XqEsxcvl6n4ozSEX66acTA9I0NFgj1MzSTtjnWHyD37FN9X5xx3bBJrvn75zUv/H87SU Yl1M2vmuOH5OX29LX2gqyRHkLlVGlwDbfgVBUJIf3XBLx7+SayRMMxDSIy5vBHDGwHxl P+sPrzTnFsoW+9ZZ5OMnCE+3kvoD9wJ9tw9NVZKxQViVHrdMt257bzdrkIBtbR+pkrZu jpGA== X-Gm-Message-State: AE9vXwM3bsWKxudtyRJRKautFcaMP7kImZiL4jtPcRXRMRfOoj+969n7hOA3pRznx9EUIzmz X-Received: by 10.66.249.233 with SMTP id yx9mr7860371pac.165.1474590271822; Thu, 22 Sep 2016 17:24:31 -0700 (PDT) Received: from vader.thefacebook.com ([2620:10d:c090:200::6:58ae]) by smtp.gmail.com with ESMTPSA id i8sm6586299paw.25.2016.09.22.17.24.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Sep 2016 17:24:31 -0700 (PDT) From: Omar Sandoval To: linux-btrfs@vger.kernel.org Cc: kernel-team@fb.com, Chandan Rajendra , Anatoly Pugachev Subject: [PATCH v2 2/6] Btrfs: fix mount -o clear_cache,space_cache=v2 Date: Thu, 22 Sep 2016 17:24:21 -0700 Message-Id: <016aef0e9b3421cc2d2cce0914a746a14eb7af45.1474580472.git.osandov@fb.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <218563982dbe4387c60909eeb0add6914a20f813.1474580472.git.osandov@fb.com> References: <218563982dbe4387c60909eeb0add6914a20f813.1474580472.git.osandov@fb.com> In-Reply-To: References: Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Omar Sandoval We moved the code for creating the free space tree the first time that it's enabled, but didn't move the clearing code along with it. This breaks my (undocumented) intention that `mount -o clear_cache,space_cache=v2` would clear the free space tree and then recreate it. Fixes: 511711af91f2 ("btrfs: don't run delayed references while we are creating the free space tree") Cc: stable@vger.kernel.org # 4.5+ Signed-off-by: Omar Sandoval Tested-by: Holger Hoffstätte --- fs/btrfs/disk-io.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 54bc8c7..c0bfc6c 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -3129,6 +3129,18 @@ retry_root_backup: if (sb->s_flags & MS_RDONLY) return 0; + if (btrfs_test_opt(fs_info, CLEAR_CACHE) && + btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE)) { + btrfs_info(fs_info, "clearing free space tree"); + ret = btrfs_clear_free_space_tree(fs_info); + if (ret) { + btrfs_warn(fs_info, + "failed to clear free space tree: %d", ret); + close_ctree(tree_root); + return ret; + } + } + if (btrfs_test_opt(tree_root->fs_info, FREE_SPACE_TREE) && !btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE)) { btrfs_info(fs_info, "creating free space tree"); @@ -3166,18 +3178,6 @@ retry_root_backup: btrfs_qgroup_rescan_resume(fs_info); - if (btrfs_test_opt(tree_root->fs_info, CLEAR_CACHE) && - btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE)) { - btrfs_info(fs_info, "clearing free space tree"); - ret = btrfs_clear_free_space_tree(fs_info); - if (ret) { - btrfs_warn(fs_info, - "failed to clear free space tree: %d", ret); - close_ctree(tree_root); - return ret; - } - } - if (!fs_info->uuid_root) { btrfs_info(fs_info, "creating UUID tree"); ret = btrfs_create_uuid_tree(fs_info);