Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1762908rwn; Fri, 9 Sep 2022 03:49:48 -0700 (PDT) X-Google-Smtp-Source: AA6agR5US5k6ruzKzqLAq4wF+Lz7/ZTGspYhNgFxpdoUt9w1na2KXVyjmgofE7HV10RLZmqSy0mc X-Received: by 2002:a17:907:6e1a:b0:741:7b1e:f7b3 with SMTP id sd26-20020a1709076e1a00b007417b1ef7b3mr9100040ejc.303.1662720588611; Fri, 09 Sep 2022 03:49:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662720588; cv=none; d=google.com; s=arc-20160816; b=zomePzPi9z6u906oOQAnkj1jV0D2MuI+NXDyReUdRkcVh6PzrrHdOEY6w/FTWD5wqK RJDScy1dMKjZzHJuf18tgHycHwiFwJpCMSA2S8dvNaAv/CWLxt2tEcRdu+qBfYgAu/UF lLKeXMqSyCmOcFZvC70vzc11ca4JxH2kpAIIjrRjbhwuRwa2QQaEnHRpj7rU7pv290ao mx4R28xDCJR3omrBgPXuUmhAXUXdYVD802D2tOvClRj8AkIHKito52pBzho6pceh2lvv 3n7IL13RUMkEIpxZl915Px+sqHlvWoB+8RKBxsm1+xOB5aUrQKR9esY3rdmdx6v/QBbM JnLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id; bh=oalXHwWI5O3ecV1htRMWkH2/wMWepM+ejYD+tgxrCmc=; b=BsZgDQXEEVMRB/aKVe0zn0f4p0ceY3DyqoIcIlpYvaTIoMEMunG/iMNEMexHAMyaVm GBuxIWiuxbA/3As313994WGTrWHV7OYcI/vLt9X2/XJrimJNoEPZnprc554ZTXRKvmEt OU1m+QuBeDVB+vVJAMJ875AyY8J+6ojAtPudbUNXDCyjTZb8g2GZSN2MKAZqG3MB5WXY 85GR57gqquS1TyC/jdmPqU4knQfziXsbNK3lk2ryVu0i9vyILLoNbC+v7BvOS2tvmjRP hsq1w/1Q35pqucpBEKjes/l/sk/qBeLyCbOOpVlxgicJMp8V8P3pV56TO3jhUEOAzoyf 8bTw== ARC-Authentication-Results: i=1; mx.google.com; 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=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bx14-20020a0564020b4e00b004484fbd4d33si197380edb.117.2022.09.09.03.49.23; Fri, 09 Sep 2022 03:49:48 -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; 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=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230515AbiIIK3c (ORCPT + 99 others); Fri, 9 Sep 2022 06:29:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230514AbiIIK2N (ORCPT ); Fri, 9 Sep 2022 06:28:13 -0400 Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com [115.124.30.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D628812F715; Fri, 9 Sep 2022 03:28:08 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R211e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0VP9.6kE_1662719284; Received: from 172.20.10.4(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0VP9.6kE_1662719284) by smtp.aliyun-inc.com; Fri, 09 Sep 2022 18:28:06 +0800 Message-ID: <8a239157-de28-44ae-edef-336092c34a15@linux.alibaba.com> Date: Fri, 9 Sep 2022 18:28:04 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 Subject: Re: [PATCH V2 4/5] erofs: remove duplicated unregister_cookie Content-Language: en-US From: JeffleXu To: Jia Zhu , 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, huyue2@coolpad.com References: <20220902105305.79687-1-zhujia.zj@bytedance.com> <20220902105305.79687-5-zhujia.zj@bytedance.com> <3f75d266-7ccd-be6d-657c-fe0633b25687@linux.alibaba.com> In-Reply-To: <3f75d266-7ccd-be6d-657c-fe0633b25687@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL 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 On 9/9/22 5:55 PM, JeffleXu wrote: > > > On 9/2/22 6:53 PM, Jia Zhu wrote: >> 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. Sorry, why can't we also set sbi->s_fscache to NULL after decrementing the refcount in shared domain mode, to avoid the refcount being decremented twice? >> >> 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); > > Generally we can't do clean ups before generic_shutdown_super(), since > generic_shutdown_super() may trigger IO, e.g. in sync_filesystem(), > though it's not the case for erofs (read-only). > > How about embedding erofs_fscache_unregister_cookie() into > erofs_fscache_unregister_fs(), and thus we can check domain_id in > erofs_fscache_unregister_fs()? > >> + } 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 = { > -- Thanks, Jingbo