Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp2399662rdb; Tue, 14 Nov 2023 22:24:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IEOoL2T1t0rC0XXTLYSeSXhFVUx7l/b9k9kqxk8Nd6BYd1lrxWbbh+vkKRIyWtN7A4IzceF X-Received: by 2002:a05:6808:1388:b0:3ad:fdfb:d384 with SMTP id c8-20020a056808138800b003adfdfbd384mr15339618oiw.53.1700029481584; Tue, 14 Nov 2023 22:24:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700029481; cv=none; d=google.com; s=arc-20160816; b=RQ8y+1L1ZpOMFpqive+5k4eyn1JMrg2MfXOlslaB6mIc2CVz+2Jm0EztCkUw+jswA5 RbXrq7Nt007HLQOMnsqF9DNeA/sS4eDrCLKXg8pbRRZufIYlShRnKlLzMVPNKkhSB8Wn 4r6p5rufUCCx21FRRE7dB8zButnqMxT5KE/HfMADgoYhd350KRS4zDDAuqPi1afnmuqb sNLbTvuptyVAu6vuW9FFpCveAHQeuCrwcD2k6D7NXODPdp8ZB6OCCD4SOhkzjarP2I8w xZRadL/nxPqpHvlf1vKHZQpq6GrueR99zNtRlHxNtkBQgmc6HXjgF9sFlLFeL8gItShH U5AQ== 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 :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id; bh=Jd6UVFdne7P3Uhgz4bSrFh+HVlcn7yGwiIdbdrAFevI=; fh=FxWsNBCSW53v7/RhBGdXkm2rmdwqLl1nFDUWFCysBYM=; b=TGmB/CLxnogw69jZlaLdBWlO2qUiw0ZM0KfTpDhs9/HhpKhqh5ZTXIRE3Z/iuEDPeF gU2XpfjbdTvKWcQHPG+fYt0uug+u8CNOOteDxFUaAWzalp5IVPEPZ+jJ5tEGo7okPkz1 DrJYtF+9fpfS2UTPPB+F68zQkpfXNjFwEwpwBH1YQfCpJi8jha1UcQfxDElVVEPUURrN noaVjSR/nKObc19NXkMNDSCQWkcV927TEClRGx/csF2Py3K1wbmrtNOTf8TwDebbWBAl ndaFgjDHNE4/p2t7pbV0tUw9CsDWqWiPe05iJ729nJTAU8NDgglL5JsnLT2Oc+AKxENc ND4Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id bg10-20020a056a02010a00b00563ee04bbafsi9501191pgb.837.2023.11.14.22.24.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 22:24:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 81CC680BB223; Tue, 14 Nov 2023 22:24:38 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234557AbjKOGYZ (ORCPT + 99 others); Wed, 15 Nov 2023 01:24:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229551AbjKOGYY (ORCPT ); Wed, 15 Nov 2023 01:24:24 -0500 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 EFF5E91; Tue, 14 Nov 2023 22:24:20 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R881e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046049;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=4;SR=0;TI=SMTPD_---0VwRo1MD_1700029457; Received: from 30.221.145.208(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0VwRo1MD_1700029457) by smtp.aliyun-inc.com; Wed, 15 Nov 2023 14:24:18 +0800 Message-ID: <3b032e02-59a6-d25e-34a7-93481326f334@linux.alibaba.com> Date: Wed, 15 Nov 2023 14:24:13 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH] fuse: make delete_stale configurable From: Jingbo Xu To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: zyfjeff@linux.alibaba.com, linux-kernel@vger.kernel.org References: <20231023115341.60127-1-jefflexu@linux.alibaba.com> Content-Language: en-US In-Reply-To: <20231023115341.60127-1-jefflexu@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.5 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 14 Nov 2023 22:24:38 -0800 (PST) Hi, On 10/23/23 7:53 PM, Jingbo Xu wrote: > From: Yifei Zhang > > Fuse tends to cache dentries in LRU list for performance, which makes > the fuse server always keep a reference to the opened fd. If the file > is deleted by a third party process (neither fuse server nor fuse > client), the fuse server will always keep a reference to the deleted > file, in which case the deleted file cannot be released. > > Fix this by making the delete_stale feature configurable. Fuse servers > can enable this if a file may be unlinked not through fuse server nor > client. Actually virtiofs enables this by default. Make this > configurable for other fuse filesystems. Is there any comment? Without this patch, when files are unlinked by third-party processes, the fuse daemon will keep reference to the fd of those files, and the disk space of those files also can not be released. The above issue doesn't exist if the fuse client tries to access the unlinked file later, as it will trigger a new FUSE_LOOKUP and get -ENOENT returned, and thus making the dentry finally get invalidated. However it depends on the explicit access from the fuse client. As long as the path is not accessed, the unused dentry will be cached there, while the fd descriptor and the disk space of the unlinked file also can not be released. Thanks, Jingbo > > Signed-off-by: Yifei Zhang > Signed-off-by: Jingbo Xu > --- > fs/fuse/inode.c | 5 ++++- > include/uapi/linux/fuse.h | 2 ++ > 2 files changed, 6 insertions(+), 1 deletion(-) > > diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c > index 2e4eb7cf26fb..635bf0b11147 100644 > --- a/fs/fuse/inode.c > +++ b/fs/fuse/inode.c > @@ -1234,6 +1234,8 @@ static void process_init_reply(struct fuse_mount *fm, struct fuse_args *args, > fc->create_supp_group = 1; > if (flags & FUSE_DIRECT_IO_RELAX) > fc->direct_io_relax = 1; > + if (flags & FUSE_DELETE_STALE) > + fc->delete_stale = 1; > } else { > ra_pages = fc->max_read / PAGE_SIZE; > fc->no_lock = 1; > @@ -1280,7 +1282,8 @@ void fuse_send_init(struct fuse_mount *fm) > FUSE_NO_OPENDIR_SUPPORT | FUSE_EXPLICIT_INVAL_DATA | > FUSE_HANDLE_KILLPRIV_V2 | FUSE_SETXATTR_EXT | FUSE_INIT_EXT | > FUSE_SECURITY_CTX | FUSE_CREATE_SUPP_GROUP | > - FUSE_HAS_EXPIRE_ONLY | FUSE_DIRECT_IO_RELAX; > + FUSE_HAS_EXPIRE_ONLY | FUSE_DIRECT_IO_RELAX | > + FUSE_DELETE_STALE; > #ifdef CONFIG_FUSE_DAX > if (fm->fc->dax) > flags |= FUSE_MAP_ALIGNMENT; > diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h > index db92a7202b34..8d0926d21d2e 100644 > --- a/include/uapi/linux/fuse.h > +++ b/include/uapi/linux/fuse.h > @@ -411,6 +411,7 @@ struct fuse_file_lock { > * FUSE_HAS_EXPIRE_ONLY: kernel supports expiry-only entry invalidation > * FUSE_DIRECT_IO_RELAX: relax restrictions in FOPEN_DIRECT_IO mode, for now > * allow shared mmap > + * FUSE_DELETE_STALE: delete dentry if timeout is zero > */ > #define FUSE_ASYNC_READ (1 << 0) > #define FUSE_POSIX_LOCKS (1 << 1) > @@ -450,6 +451,7 @@ struct fuse_file_lock { > #define FUSE_CREATE_SUPP_GROUP (1ULL << 34) > #define FUSE_HAS_EXPIRE_ONLY (1ULL << 35) > #define FUSE_DIRECT_IO_RELAX (1ULL << 36) > +#define FUSE_DELETE_STALE (1ULL << 37) > > /** > * CUSE INIT request/reply flags -- Thanks, Jingbo