Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp150058pxb; Thu, 21 Apr 2022 19:48:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxL+P4hsgJdplUPDz0TvHvXFj5OyWnV7yEMlcBTVn1fDF+H9GCyq+cpNon5EyaaKxZobXBZ X-Received: by 2002:a17:907:62a1:b0:6da:7952:d4d2 with SMTP id nd33-20020a17090762a100b006da7952d4d2mr2147582ejc.260.1650595736285; Thu, 21 Apr 2022 19:48:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650595736; cv=none; d=google.com; s=arc-20160816; b=s/7D4zL0ZYs0Nx+chLOTOeXD/wLxyEN7XFQhbr3pwj2MqfPIl5qwHF6RUJ6fLAHq8I 9yXLMWDZSOFyJiNyOzwzG7Aj82PPn4ji3uzkSIaz59k7Rhi52+isCGzMb7oSTG805DA8 czQMxYE51JDZTHn7uQdYKo/cmGfvo2QQOUkE5puiSA7qTuP0P1/nTI3nEn0cWq03k+XO 1bA3Mqd5xH1Z825IAogEV4zDkp73RitU399v9GiN3iHNcvGEk0/M0j4FNJO+++gaWPAH bNNGnWCBYZWaF5PLRYg8MuLcyeFypj4IrKa5Zhkuf/i7k8qb5PfQJCDhnDcXJ0Foy7Th 7eWw== 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:content-language:subject:user-agent:mime-version :date:message-id; bh=VkLadDtGTiS6o3nwxSAHUWZbgS0vixWqNTVKkr+reRA=; b=SArIlW1WbyEzGC8X6x2T9dBoSkwQWHIwXwuJq0yOh7GUxMTndMuvaXDWUO+sX9d7jw /gvwoYZVDHczbynlJUxyIkj6AQstu1oXmvKH2F9zpctnst93xAoT4B870vNM9zdeG8W5 sJfo2bFRl1WTRe725stGtjGD7X4Nwu2aNW1emwFcUdj4zkO1XVvjehIxCXEpa3FfD6tT ZU9gjvDqQv4r/zpoz3tM1smAUmEdLvR9AgzoDKnMBxVygQMGQ0tpk6xx5arse1nRMZkR z8tzjgzB6yDpGOxYFqvy9ZqWzczKht7z4HnluR9laUuC+RilVl8rQFZ7Qt9nykloydMV GEjA== 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 v22-20020a17090690d600b006e7f061da70si5003654ejw.696.2022.04.21.19.48.25; Thu, 21 Apr 2022 19:48:56 -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 S1443486AbiDVCrU (ORCPT + 99 others); Thu, 21 Apr 2022 22:47:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241380AbiDVCrS (ORCPT ); Thu, 21 Apr 2022 22:47:18 -0400 Received: from out30-45.freemail.mail.aliyun.com (out30-45.freemail.mail.aliyun.com [115.124.30.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C00DC4B42E; Thu, 21 Apr 2022 19:44:26 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R101e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04395;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=19;SR=0;TI=SMTPD_---0VAjn9jI_1650595459; Received: from 30.225.24.197(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0VAjn9jI_1650595459) by smtp.aliyun-inc.com(127.0.0.1); Fri, 22 Apr 2022 10:44:22 +0800 Message-ID: Date: Fri, 22 Apr 2022 10:44:19 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH v9 03/21] cachefiles: unbind cachefiles gracefully in on-demand mode Content-Language: en-US To: David Howells Cc: linux-cachefs@redhat.com, xiang@kernel.org, chao@kernel.org, linux-erofs@lists.ozlabs.org, torvalds@linux-foundation.org, gregkh@linuxfoundation.org, willy@infradead.org, linux-fsdevel@vger.kernel.org, joseph.qi@linux.alibaba.com, bo.liu@linux.alibaba.com, tao.peng@linux.alibaba.com, gerry@linux.alibaba.com, eguan@linux.alibaba.com, linux-kernel@vger.kernel.org, luodaowen.backend@bytedance.com, tianzichen@kuaishou.com, fannaihao@baidu.com, zhangjiachen.jaycee@bytedance.com References: <20220415123614.54024-4-jefflexu@linux.alibaba.com> <20220415123614.54024-1-jefflexu@linux.alibaba.com> <1444916.1650549738@warthog.procyon.org.uk> From: JeffleXu In-Reply-To: <1444916.1650549738@warthog.procyon.org.uk> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,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 4/21/22 10:02 PM, David Howells wrote: > Jeffle Xu wrote: > >> + struct kref unbind_pincount;/* refcount to do daemon unbind */ > > Please use refcount_t or atomic_t, especially as this isn't the refcount for > the structure. Okay, will be done in the next version. > >> - cachefiles_daemon_unbind(cache); >> - >> /* clean up the control file interface */ >> cache->cachefilesd = NULL; >> file->private_data = NULL; >> cachefiles_open = 0; > > Please call cachefiles_daemon_unbind() before the cleanup. Since the cachefiles_struct struct will be freed once the pincount is decreased to 0, "cache->cachefilesd = NULL;" needs to be done before decreasing the pincount. BTW, "cachefiles_open = 0;" indeed should be done only when pincount has been decreased to 0. -- Thanks, Jeffle