Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1802367rwe; Fri, 2 Sep 2022 04:13:00 -0700 (PDT) X-Google-Smtp-Source: AA6agR5jEGZ5OBWY4X545/UDuna0awNiIrjPjir6bG0JnKX3mTgPVPeEAMtvDAkjfsfRyMzAgzRH X-Received: by 2002:a17:907:1ca9:b0:741:4f9a:5984 with SMTP id nb41-20020a1709071ca900b007414f9a5984mr19782903ejc.86.1662117180396; Fri, 02 Sep 2022 04:13:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662117180; cv=none; d=google.com; s=arc-20160816; b=pVK9VX6jOLxYlMbs7kLXuP6EULLmF8wbsC1VZS7SsLJ2wUoJHc184hPHzZ7mTvfbg8 Tnwz5I3d8JpoqicHGnJMN6HSt1Ok7UjBJOJ0QSCArOnUlSZRnPK2Waj7ebQudFLJidUn SlLgK0kkCh6dAFpWVhR8UmtzRP+PnlgkHDZBF3aRR57Mt7ZQBhP6hIVEeZSCobdesSJB L+2J3jg6tdPtcgQoKw80CvE+t81JRBpEH7HvIHQldF42L3FqIh9kwwNM8EbeDtETKUuv 54XUxu4REJtuoPP6Wx8GPsRaQHUL7Uq9oOtPhT4xrFI1XsLeQ+0cZKKE55f5/tbbBqnH 3fww== 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=AuN/fB7WFgyGdRo1r9YkRNBbxG011D/UvehVb1XsFR8=; b=edNA1FBf2aKi2jyuqJMGL6snX5ajOdED5/FqgQXNGWJ+ZBBzYAvOjIy9Orw6a1gbnJ 8xK6wJhn0XgI/TF/oEYnFl9/Mh8LNFWKBj+F9uS8bw7pR7vA3NF4wTJlNhOUv9bB4V6O 4UKbQlgTX5QQdq3t0Cwsa3S8ffdbnmp9aUT9Zm8VlHzvk3KWm1+buD/ay3IC1CUBTMvH MDzcOxrQnmMrTW8NAdZ8LrV5Zu0ZAPeTblYRqrj7+uOO+R5P5ZHD+KhYYg/X6scMSGv2 1+SdSeI+uAM4z7fzI0teGoUwJSYPyO90jPZxslfkLxsDSsvtX1zCq/jw5RJ9Wdk6SZ+V jQ8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=kbfzT2ZC; 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 gt9-20020a1709072d8900b0073d8cfa8070si272565ejc.271.2022.09.02.04.12.30; Fri, 02 Sep 2022 04:13:00 -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=kbfzT2ZC; 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 S233539AbiIBKyr (ORCPT + 99 others); Fri, 2 Sep 2022 06:54:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235974AbiIBKyk (ORCPT ); Fri, 2 Sep 2022 06:54:40 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E057C993B for ; Fri, 2 Sep 2022 03:54:27 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id z9-20020a17090a468900b001ffff693b27so378941pjf.2 for ; Fri, 02 Sep 2022 03:54:27 -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=AuN/fB7WFgyGdRo1r9YkRNBbxG011D/UvehVb1XsFR8=; b=kbfzT2ZCnk1BzCZUOZaSAPZHcn9bDeZoIcCQhUlUv1pniGRGW5nNiT5GTdes8JMaV3 Y95kFlCTrSr2u/ho8LKBpM7nw0xPrCdk5y+RnYRy4rVkIvtbQBJe18GV3ATAHVdkwr6g jSlOLST7OCNNH/NBnvg2ORdfU6UIClzGfrTGx0ck4MdCrOdafFpH5+xU1lxMWQDU5H5b OZgJCmeJ4kGZJg7H4rvp49s+pALBQsNpqQWYlWdSYYyp6YhHMq6twrHzRoJROmbqq3KU iKyDIr8yonTBNEgRk4efSFsvao3qAC2QRKQTyK1/UMwBaOQJAAYjeuDvjBaLxNRXe0mX eJ5w== 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=AuN/fB7WFgyGdRo1r9YkRNBbxG011D/UvehVb1XsFR8=; b=uzruEBFzCQ2xRZCSIgcTeqH7TDsR4ZRG3i2zh5HFopVmieWiTRD+rCa+5VU2Lm3Tok Uv18HP5GgK3GG1Sziwgu5lnh9o1bbCbw7mwpJtsUCGwf64MNsaULt6M+zDwDpNKSINtw h6kHxAOor+y2JkFBEFJepxK4lVZGZsyw/Umv522HD5/gbrxa1OHQa+eFXdhFbIq1qyev SBDit0DiYyunY5HgpHHnjBHENLf55zMNMK61uOH/Jt5aNDpmS+xzUMru3Y6QSqwHZbXu eCu3Lx8zWdwxiRpZTgIWkq3wqPB6b+OT2Qz+PKBU82rRXtErppsBVi0NU/H2zQ/Ctv29 /xQA== X-Gm-Message-State: ACgBeo201vvF8vK848tHJ/kbinzIoL3ExRlnqsyyyuhH2cr05OJjD68I PYxYjVpXfY65O98jbEctSUGX4w== X-Received: by 2002:a17:90b:4aca:b0:1fe:686:fbf3 with SMTP id mh10-20020a17090b4aca00b001fe0686fbf3mr4194388pjb.174.1662116066994; Fri, 02 Sep 2022 03:54:26 -0700 (PDT) Received: from C02G705SMD6V.bytedance.net ([61.120.150.76]) by smtp.gmail.com with ESMTPSA id e4-20020a63d944000000b0041b29fd0626sm1128681pgj.88.2022.09.02.03.54.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 03:54:26 -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 V2 4/5] erofs: remove duplicated unregister_cookie Date: Fri, 2 Sep 2022 18:53:04 +0800 Message-Id: <20220902105305.79687-5-zhujia.zj@bytedance.com> X-Mailer: git-send-email 2.32.1 (Apple Git-133) In-Reply-To: <20220902105305.79687-1-zhujia.zj@bytedance.com> References: <20220902105305.79687-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 69de1731f454..667a78f0ee70 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -919,19 +919,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); @@ -951,7 +952,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