Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6126265rwn; Mon, 12 Sep 2022 22:09:31 -0700 (PDT) X-Google-Smtp-Source: AA6agR5nXPx7dgbREPdSbMvSQx3OQNy4nxXZoHJhj6V1cwK2V7BDezybrIRqmuWTZt9dTP08VvnI X-Received: by 2002:a05:6402:270d:b0:452:4285:87b7 with SMTP id y13-20020a056402270d00b00452428587b7mr2337157edd.135.1663045771195; Mon, 12 Sep 2022 22:09:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663045771; cv=none; d=google.com; s=arc-20160816; b=Si/T0/Mhny4EnMx1yHB9MjgUTjhnLBGcJzsKPUL2b7DjALJXNjuvmHApoc5fc/2vCO yJt7LvGbPsl6/acsizaz4ufBuI3O0cnSD4Nv1NawFEb2Nxx8i5ZTSLSke+XC7SvB5FV/ y7Ei3IBQFZ0cVEucCRH2uUnxuI4ACiyo+QgD03692nM4PauR5cha06QmPISk4uL34smu Q4c7UXdau9yBEvlexP1AS0MJsXBE7GY3qL0AFDYfdUb49ZDMk2OsaXEQ9gEQnF7dcyXm s6mXzXfAeX1vcwsKk4XBYIz2uczzzh8VVpcp5iNsgYpeaJgEQWvwbyB+g8cKL4G79MZO 75Qg== 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:from :references:cc:to:subject:user-agent:mime-version:date:message-id :dkim-signature; bh=b7Bt/6YykyrjMchIDnbFXbVoXcDSV6FDpCyHEofA/qI=; b=Gx09B0fEU5dX1kLGOLTsPe3Q9Vd6MXyXETNKrRhKKrLY/GFesEE5rPbVXQihmJ9uFN YzPThLMObkiAbhckIsBybNztHaXhCcPwVqmiMRhjBbNUMJJahO8F8VOUbYW2Mxr8Y9Ne iCNdOW1SwtdyrseL/jL9Zg10RPrGsxg3x2He2M6DhUB2lmQ9YYpfiLjUcLOqKpnI12zb n8pJKesoUwSt6BWn/H3NTt3MnqgZ2EZGVOf+pJekQIWaBaBdLWWoxGOFwCBWBaDYxUxT oV90/DNr3EepbJANzhUYn13QfcK2lxnSbvmGPop0+bZfscrW6ZBBHs1jAVtiRv3T6FD+ jN5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=tDZt8AcW; 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 h26-20020a170906111a00b0073d9c412570si7948478eja.785.2022.09.12.22.09.05; Mon, 12 Sep 2022 22:09:31 -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=tDZt8AcW; 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 S229881AbiIMEiX (ORCPT + 99 others); Tue, 13 Sep 2022 00:38:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230319AbiIMEhs (ORCPT ); Tue, 13 Sep 2022 00:37:48 -0400 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E3376143 for ; Mon, 12 Sep 2022 21:37:47 -0700 (PDT) Received: by mail-pf1-x430.google.com with SMTP id b75so5365756pfb.7 for ; Mon, 12 Sep 2022 21:37:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date; bh=b7Bt/6YykyrjMchIDnbFXbVoXcDSV6FDpCyHEofA/qI=; b=tDZt8AcWokd/xVHEI5fGydFkbJEPKf/viuCMk7B4IQI4/2/VcQwYi1aOxJUi3CE+SO lDX6xyUveu3H03QWTLGMIEuSIA9Qc9KdB7APrKrxHt8Jpry8IEvY4nMf2AmX457HS95L K9NNtnlsucaFPOaNgmPoXoDZACoBQ6HRRoYeE/MivzjAdB/JpSnsmlC+uROYaKaBLp3a ugjk6/qyB9SLQCaQ7HIFafa01ei7997gJBzIkILPvCvIShXZiD7jWbeISymZzRn7yhdu vYfc0Mh+ip3peQVLfCqR6xKLjUP11unFz7AAHtMiCT9Ir+52CQ1HRoLQI+uvxcWNlGKT 7hCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date; bh=b7Bt/6YykyrjMchIDnbFXbVoXcDSV6FDpCyHEofA/qI=; b=xZWH/3+df6hoBTOILNK21b5ntFRmgVoktkqQ4/IjQ6ycb08mPMuDQ3kRGjCAiKqyN6 Fxr3J+Jr3K6/CVXXrKVCx5UUVZOnDPxm0ql2Cybjx3v4d1R7Y7jwjQEccFy+5Ju6b03N k9Q3Pdjt6sh990umenMuS+/0pR0qD0YdZVqKOaegyqHaGbsZ8CnsbGjt9J+ycOO/ZZt8 +T6cHntrScvQOBdcnmdXE2pdyBMQYTTZI/EyTj2jaKQn2L6zhihuJY3XcSPiUrdd7/dU xIENWtvRfRYH+OooPKSTgbRN7g+ViyOwQXkG8Ss2Jy21KwJE5uuoAFMq/ILC1/wq43z9 igjQ== X-Gm-Message-State: ACgBeo1honE/kz36qMmOq8n/vJGGLUa71z8VJOG+GUuXj9PBSVz3Hws8 Z8Zp8a/nbn2+KQ+hv1nsLINJ2Q== X-Received: by 2002:aa7:9e12:0:b0:53e:27d8:b71b with SMTP id y18-20020aa79e12000000b0053e27d8b71bmr31213065pfq.46.1663043866649; Mon, 12 Sep 2022 21:37:46 -0700 (PDT) Received: from [10.76.37.214] ([114.251.196.103]) by smtp.gmail.com with ESMTPSA id t3-20020a17090a6a0300b002002fb120d7sm6198682pjj.8.2022.09.12.21.37.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Sep 2022 21:37:46 -0700 (PDT) Message-ID: <8c17fa4d-96a3-36e7-38db-17673c4bf552@bytedance.com> Date: Tue, 13 Sep 2022 12:37:43 +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: [External] Re: [PATCH V2 4/5] erofs: remove duplicated unregister_cookie To: JeffleXu , 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> From: Jia Zhu In-Reply-To: <3f75d266-7ccd-be6d-657c-fe0633b25687@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,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 在 2022/9/9 17:55, JeffleXu 写道: > > > 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. >> >> 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()? > Thanks. >> + } 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 = { >