From patchwork Wed Nov 18 23:06:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Burkov X-Patchwork-Id: 11916093 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,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 CA169C63697 for ; Wed, 18 Nov 2020 23:06:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4860822255 for ; Wed, 18 Nov 2020 23:06:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bur.io header.i=@bur.io header.b="VfYiNDCU"; dkim=temperror (0-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="BYR28fFx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726889AbgKRXGa (ORCPT ); Wed, 18 Nov 2020 18:06:30 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:56617 "EHLO wout2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726588AbgKRXGa (ORCPT ); Wed, 18 Nov 2020 18:06:30 -0500 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id E4DCCD37; Wed, 18 Nov 2020 18:06:46 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 18 Nov 2020 18:06:47 -0500 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=eJZSpcjXxOpl9/AEy4OvQwVU6w DDaas8FavaIrwBnbc=; b=VfYiNDCULjFsZ7NU0tZcmQAcqI72BJycbWqfOWHUhD R3riA/dWC3EYIDm6QsqUU8c40UnXIdmKXEP+Gnsuc879w/LUCZhJEryFVBOJJLzm da/x5/nbDUR0B3TAP/kDwDBzfj1HOiUypTAFne8Ti35TLjrmYqQjRyhbNQPnE9Wb 3R4aBVvjRKA4l6ZoEJlBYOOtXomxqopmx1qzxnoOY5vcwx0RoJ/hCTvT1E65jQg8 dii35lzclXrbAH7TuBENolGTQcBTKXW8rLXf56wu13nkdZuvCHy9M74yg1E1h0U6 7JJL1ECc14GAGormjVkQjVZHFRbowxdEKpNxJ8idMDJw== 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=eJZSpcjXxOpl9/AEy4OvQwVU6wDDaas8FavaIrwBnbc=; b=BYR28fFx QAYLzZ1h9QxGSKCOYRKMZhRrQn6H+RM7l/T4wvXjW01viUYDUy/7ggeDLG//ESS0 ERTbpdTx+3xTPfHekSsIaKmk1mnXzD2ju2etFjxsYPOOKRc7uhoxuh0rzSKOs9OF ree4/H79YdQN4HsOnKFLiqG7HH6FuAQ1uLirSDkxKwskZ7r/hgScRNjZ0f1qTZ84 2cdHhqp+KJ7r1LBYPXHMMOx5kgSufFW0XLcHKrYEAsi39SqAYMF5TDo5fMelp402 D6JfKlc8ki4oMFJ0ag0Fegf5jTsMsDQDayee55kXEJFI4rY2b1Bi55xQypMsj5DD aztt1uBxV5oWBA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudefiedgtdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepuehorhhishcuuehurhhkohhvuceosghorhhishessghurhdr ihhoqeenucggtffrrghtthgvrhhnpeeiueffuedvieeujefhheeigfekvedujeejjeffve dvhedtudefiefhkeegueehleenucfkphepudeifedruddugedrudefvddrfeenucevlhhu shhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegsohhrihhssegsuh hrrdhioh X-ME-Proxy: Received: from localhost (unknown [163.114.132.3]) by mail.messagingengine.com (Postfix) with ESMTPA id 1A8ED3280060; Wed, 18 Nov 2020 18:06:46 -0500 (EST) From: Boris Burkov To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v7 02/12] btrfs: cleanup all orphan inodes on ro->rw remount Date: Wed, 18 Nov 2020 15:06:17 -0800 Message-Id: <623aef2cdca5e4444a1575f09555d24a827130d7.1605736355.git.boris@bur.io> 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 When we mount a rw file system, we clean the orphan inodes in the filesystem trees, and also on the tree_root and fs_root. However, when we remount a ro file system rw, we only clean the former. Move the calls to btrfs_orphan_cleanup() on tree_root and fs_root to the shared rw mount routine to effectively add them on ro->rw remount. Signed-off-by: Boris Burkov --- fs/btrfs/disk-io.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 3e0de4986dbc..2cf81a4e9393 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -2896,6 +2896,14 @@ int btrfs_mount_rw(struct btrfs_fs_info *fs_info) if (ret) goto out; + down_read(&fs_info->cleanup_work_sem); + if ((ret = btrfs_orphan_cleanup(fs_info->fs_root)) || + (ret = btrfs_orphan_cleanup(fs_info->tree_root))) { + up_read(&fs_info->cleanup_work_sem); + goto out; + } + up_read(&fs_info->cleanup_work_sem); + mutex_lock(&fs_info->cleaner_mutex); ret = btrfs_recover_relocation(fs_info->tree_root); mutex_unlock(&fs_info->cleaner_mutex); @@ -3380,15 +3388,6 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device } } - down_read(&fs_info->cleanup_work_sem); - if ((ret = btrfs_orphan_cleanup(fs_info->fs_root)) || - (ret = btrfs_orphan_cleanup(fs_info->tree_root))) { - up_read(&fs_info->cleanup_work_sem); - close_ctree(fs_info); - return ret; - } - up_read(&fs_info->cleanup_work_sem); - ret = btrfs_mount_rw(fs_info); if (ret) { close_ctree(fs_info);