Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1491960rwe; Thu, 1 Sep 2022 21:05:59 -0700 (PDT) X-Google-Smtp-Source: AA6agR5rpLijcW88LDIaZ22YLZxlw8im3NoGWLBhBgHLa5e0icYZbGzLBBpu3puzHbHJMDoxm+ZH X-Received: by 2002:a17:90a:4801:b0:1fa:98ec:fa2 with SMTP id a1-20020a17090a480100b001fa98ec0fa2mr2606084pjh.41.1662091559031; Thu, 01 Sep 2022 21:05:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662091559; cv=none; d=google.com; s=arc-20160816; b=EN5ioDjnSSoADGjoyuCTfCA6l2uE3q3Tz4ldb7xYjzgZL5fBH6J3pmtwC8/rYuIoly X64x5qvIpDGBlpjEMmRz5zFlVqm15OYle47VbGyCPeul4EsWtQkD76YuzTY2ErPI7d8L pugcMluK2ToJ10vACHQ3JKlc9x44fv1pKDaNKfaH01y52+gpf0zPXNCnUPI+UzDK6lOZ DxWZJwZSqTs5OPtU98R/TisVbZNBLKRajzD2kVPa07UTo/I3HWkIHgyF2Lfp3lIPVeHB W82x2AKdc7pSRYk0U0JZFpOpC6sO6PHlwb8OQ+YgdUt7cHXnTgVEjiru5m7aqAtxj9dr WQCA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=29yigyMnPFGfDuD40Y83IOfvtDsC8VAK42q+yJUeUxw=; b=opYEW3t3hMeImW3/NvUwoxVhvPigkc/L6IZ7K1BpPIB0nl/bU0Lwy576GAFvaczaNC 3am9xBaP4GWxYubyh9iQbQNfGPwc4jV1ME/JfAEAzD4IrUHuazXNQ+ERO5jJ8ef1OIeh D0UNdIB+rkSfBvUryblwqrdFRtxBBsKuxjX0Ei7QdeyIEVaXxGWruKa2JUTRx76xpxcL SE3QcN4kK7wLl8W5mDYlYagfN7odYJwMUF+ntVvTsQ6BW4FyAayiu6EZrAMJ6iuCYI/M Tb778kXmsKJA5vlmcKYCUFapjV3SPvukRFxRCF3URYu5tMVaNgf2gQkbf9eNxQQeTJWA gE8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=wdHIrpiS; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r16-20020a635150000000b0042b0f80d8desi861735pgl.36.2022.09.01.21.05.39; Thu, 01 Sep 2022 21:05:59 -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=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=wdHIrpiS; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235403AbiIBDtM (ORCPT + 99 others); Thu, 1 Sep 2022 23:49:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235357AbiIBDsm (ORCPT ); Thu, 1 Sep 2022 23:48:42 -0400 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90D01B4E9E for ; Thu, 1 Sep 2022 20:48:24 -0700 (PDT) Received: by mail-pg1-x52f.google.com with SMTP id 73so899469pga.1 for ; Thu, 01 Sep 2022 20:48:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=29yigyMnPFGfDuD40Y83IOfvtDsC8VAK42q+yJUeUxw=; b=wdHIrpiSaBhjfQbqOd+Abr+Z7iAWnqTitm0NuSsGbPvaDveHA3TOCmzxpCEaxURIvn c4v4b8cLleHbAaCx7Pp/bxts1GEAxe61h0wmVCp0UPzqOM/w+wQyPhrW0zLkYq9qOBhf Yok1Z6ryVNgeKydsYzrzE2f1+QcKwwUjY0epN8bEV51Gn2fpLpHQ5fimRpaiotKtRmmS FaM2mEHm+hrTaNF9ek8tH40G1HIcPI1MV66GhzrFLYX1/3JVfh0AvFmLGjG/Nj71ugoc m4u9opqkr/kAkUKl65Ljw2aEOhQShGIYtP46EA3cAzRgwQx/ME02xiOMWu6+NuZVKe1l UEYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=29yigyMnPFGfDuD40Y83IOfvtDsC8VAK42q+yJUeUxw=; b=nlUXfueV+MBoTm5l93SBRJLqy6jxbvbqpRQgh2PKztPS3iuuFWclAatSwE0tguoMQ0 71WGyEmw6p7IvUSrvM6fc9GEgjDCBw223wjdFAu5itIfes/AzaxirNsdhAvgLr7HxCQW kyyXVQVaTCXLfuBLdDewON28cugIuluBp2QnCnPuRtvaBVQkqAb4uqXFxdHP6wrz2aam gvax2t2wRaH0SQozq8WLiV/bDHFmA/VARqladyUKBFSUxpJfU8kKhjQ0n9JQ/foSHF+z RcbfA5ydsljTgexQ1BYFbAlOLI9LpPAtFa2aEkrd4qwIMLdfOZBFu/2KfuwYBsPSIzF6 8N9g== X-Gm-Message-State: ACgBeo36CCItXrTHcIDl7N7tj0PgUmkt9u+PQR/wAiZd7rVWYjOOA3kd gQ67HlghOibbuzTs1/L2IBryTA5owCdr1g== X-Received: by 2002:a05:6a00:e8f:b0:536:c98e:8307 with SMTP id bo15-20020a056a000e8f00b00536c98e8307mr34362687pfb.73.1662090504153; Thu, 01 Sep 2022 20:48:24 -0700 (PDT) Received: from C02G705SMD6V.bytedance.net ([61.120.150.76]) by smtp.gmail.com with ESMTPSA id w8-20020a170902e88800b0016c4546fbf9sm376152plg.128.2022.09.01.20.48.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 20:48:23 -0700 (PDT) From: Jia Zhu To: linux-erofs@lists.ozlabs.org, xiang@kernel.org, chao@kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, yinxin.x@bytedance.com, jefflexu@linux.alibaba.com, huyue2@coolpad.com, Jia Zhu Subject: [PATCH V1 4/5] erofs: remove duplicated unregister_cookie Date: Fri, 2 Sep 2022 11:47:47 +0800 Message-Id: <20220902034748.60868-5-zhujia.zj@bytedance.com> X-Mailer: git-send-email 2.32.1 (Apple Git-133) In-Reply-To: <20220902034748.60868-1-zhujia.zj@bytedance.com> References: <20220902034748.60868-1-zhujia.zj@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 In erofs umount scenario, erofs_fscache_unregister_cookie() is called twice in kill_sb() and put_super(). It works for original semantics, cause 'ctx' will be set to NULL in put_super() and will not be unregister again in kill_sb(). However, in shared domain scenario, we use refcount to maintain the lifecycle of cookie. Unregister the cookie twice will cause it to be released early. For the above reasons, this patch removes duplicate unregister_cookie and move fscache_unregister_* before shotdown_super() to prevent busy inode(ctx->inode) when umount. Signed-off-by: Jia Zhu --- fs/erofs/super.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/erofs/super.c b/fs/erofs/super.c index a3ff87e45f2c..05dc83b25da3 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -920,19 +920,20 @@ static void erofs_kill_sb(struct super_block *sb) kill_litter_super(sb); return; } - if (erofs_is_fscache_mode(sb)) - generic_shutdown_super(sb); - else - kill_block_super(sb); - sbi = EROFS_SB(sb); if (!sbi) return; + if (erofs_is_fscache_mode(sb)) { + erofs_fscache_unregister_cookie(&sbi->s_fscache); + erofs_fscache_unregister_fs(sb); + generic_shutdown_super(sb); + } else { + kill_block_super(sb); + } + erofs_free_dev_context(sbi->devs); fs_put_dax(sbi->dax_dev, NULL); - erofs_fscache_unregister_cookie(&sbi->s_fscache); - erofs_fscache_unregister_fs(sb); kfree(sbi->opt.fsid); kfree(sbi->opt.domain_id); kfree(sbi); @@ -952,7 +953,6 @@ static void erofs_put_super(struct super_block *sb) iput(sbi->managed_cache); sbi->managed_cache = NULL; #endif - erofs_fscache_unregister_cookie(&sbi->s_fscache); } struct file_system_type erofs_fs_type = { -- 2.20.1