Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3641806iog; Mon, 27 Jun 2022 22:41:23 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tbSW9nBDAm2aoJ2kTZSFSHnvJgKpgn8RxZxqoNtjkbLXeMj9beGv3xrlZOX6fl3Ea0+v61 X-Received: by 2002:a05:6402:3808:b0:435:5a6c:9dd9 with SMTP id es8-20020a056402380800b004355a6c9dd9mr21167168edb.368.1656394883628; Mon, 27 Jun 2022 22:41:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656394883; cv=none; d=google.com; s=arc-20160816; b=y97lfLXKmM2K6U3M374gUV6iC/MaLOUjMaoUh86Hbj/B0WpZshJ8HN/dAa4YPJNKAH gF/NQ+M40umt5gCa5ySwnAtBoHcfs7p9qIqD9O+EUARhH5PM85n6221btjw9iiKgBnkN T8QBlmk6Rl118ETty8515QTZsOitDtZrTdsNEE0tltaH6ptrARZS3de7uDYrJUupU+ZK e1r8h+mxkz2r04zfZ/rV27SrTOhor0GSG+luYC4cnmBypDu+AOTbU4UhI4AfG0vNj4Zk PbEe9IkWNGDxm6kvvI8Qwp1Y0XCOdmD3P3Cq2KFoKDpG5rV9D/LhCcxXWb7AZxZfLg7a nEGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=oG6UmMCeULY14p5Tnuuf681QLknd/2jzZKexPfhwXHo=; b=DpHO3Tch/RbIN8Eryz6TtreCZHw3bwxH9RE77k7wpCtP6abJj+xAiTxfnBd68Pge3Y k6uWnDAAi5EeGSH8fUMTsZzfRLhVuOCYlDOgwBArVONzB/32Z798sI0WO5ISOYgSsqqr vmktrYIUlkq7TXSf1CCeSCeuQldnqCHSWGozg4pH4UVocvq8bSTjwVWAm0aYL4lBFA5Y MnnysO+NbULBcpS3xlysFn7CzLIXjNxnFoRDZeVWmGneOLS0rObPqw+xiVt6HLls1Qk3 u/FURFYJUl6TiX+UR7ERT92BlPyOmef+5lz8hKECXUHIs2yWp6FM8qAcJnofag1cMQXZ tHNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=1W2RaMrq; 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 dt13-20020a170907728d00b00726be208896si189667ejc.973.2022.06.27.22.40.57; Mon, 27 Jun 2022 22:41:23 -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=1W2RaMrq; 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 S244815AbiF1FQV (ORCPT + 99 others); Tue, 28 Jun 2022 01:16:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244838AbiF1FPr (ORCPT ); Tue, 28 Jun 2022 01:15:47 -0400 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 073BB275CD for ; Mon, 27 Jun 2022 22:14:34 -0700 (PDT) Received: by mail-il1-x131.google.com with SMTP id 9so7454595ill.5 for ; Mon, 27 Jun 2022 22:14:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=oG6UmMCeULY14p5Tnuuf681QLknd/2jzZKexPfhwXHo=; b=1W2RaMrqcsbZfT9D9Kb4GB4UobqcaC7M7RaswpgReAuuCtk4JgzRIGdgBJ4g1WM4Fn qru0MTS6IP2RQf6esYtsp9yaH1DLApJzzcfo58uEVpegkBj6EeVjj4f721h2sClNDsqX pSzqRCOetnm4dXRflO8aNfBiBAmAaauNAQcnHDm4efmAMANpumeTKYK3ZpiHfY6BBtkd DIwwQQ+JPDhlOv+KRBVtB4Nus1SC4UydB0PX88t1SSrRfsNJDNHu24zVD758Z0lv/L0n VNvXuyupIqFLISQdJWMUTYPCE4aYf9DdyLUstPm4Pan7PCN7SKQLi3ot7dpsmoluote8 AZqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=oG6UmMCeULY14p5Tnuuf681QLknd/2jzZKexPfhwXHo=; b=eVX5BlXMCcx7jpKg+K9oDdOu8AB0lzfXgjRmN7Wm9qli/CcoosvZm+SV1oWj51qRL+ PLao+49H3gHJD00CWJwWoMs4tr9nrhdXzwT4RXezJ4AAkh+vxFfi3pZTrEVDnVKJD8Kz 2yFbAtxSOVuy9ATk3N8V8MvpFSPd0cVH4bAg5QuReXKqlc9P0a1U8QWhiPXWKsumvIdl XxyPgHpm7Qzsc36YGRGTa4J9na+j1yLJeln+JqSZV0FjFG2s7s0iNoEYFO33y3IqBjer cvwsi0bA4KporORArlL41CcsfsdhdgOTe7EzcreiiB/hYj4WeH4t3H4fYkyMBoywvt4M D45g== X-Gm-Message-State: AJIora9m/JE3M8GpxUbsh/rmkbveOkvuqxZ3GEvJ32BZGVOc7kaC+SL9 6TJIAgmGPg1hJWIBMolY0Y/Ye/Vq8bgfvM9SAPAOLg== X-Received: by 2002:a05:6e02:1a66:b0:2da:a3c6:d8f1 with SMTP id w6-20020a056e021a6600b002daa3c6d8f1mr2783376ilv.180.1656393272553; Mon, 27 Jun 2022 22:14:32 -0700 (PDT) MIME-Version: 1.0 References: <20220608104202.19461-1-zhangjiachen.jaycee@bytedance.com> In-Reply-To: From: Jiachen Zhang Date: Tue, 28 Jun 2022 13:14:21 +0800 Message-ID: Subject: Re: Re: [PATCH] fuse: add FOPEN_INVAL_ATTR To: Vivek Goyal Cc: Miklos Szeredi , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" 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=unavailable 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 Mon, Jun 27, 2022 at 11:06 PM Vivek Goyal wrote: > > On Wed, Jun 08, 2022 at 06:42:02PM +0800, Jiachen Zhang wrote: > > So that the fuse daemon can ask kernel to invalidate the attr cache on file > > open. > > Will be great if there was a proper context around this. Without any > explanation, how one is supposed to understand how this is useful. > > By going through other email threads, looks like, with writeback > cache enabled, you want to invalidate attr cache and data cache > when file is opened next time. Right? Hi Vivek, Yes, exactly. This patch is supposed to be a supplement to the writeback_cache consistency enhancement patch [1]. Sorry for the lack of explanation. I think I will send this and the enhancement patch as a patchset later after there is more comments and discussions. > > IOW, when file is closed, its changes will be flushed out. And when > file is reopened, server somehow is supposed to determine if file > has changed (on server by another client) and based on that determine > whether to invalidate attr and data cache on next open? Yes, to achieve this so-called close-to-open consistency, this patch gives a knod to FUSE server handler to invalidate attributes cache on file open. > > Even without that, on next open, it probably makes sense to being > invalidate attr cache. We have notion to invalidate data cache. So > it will be kind of odd that we can invalidate data but not attrs > on next open. Am I understanding it right? Yes, Exactly. It could also be used for immediate attr invalidation in write-through mode. [1] https://lore.kernel.org/linux-fsdevel/20220624055825.29183-1-zhangjiachen.jaycee@bytedance.com/ Thanks, Jiachen > > Thanks > Vivek > > > > > Signed-off-by: Jiachen Zhang > > --- > > fs/fuse/file.c | 4 ++++ > > include/uapi/linux/fuse.h | 2 ++ > > 2 files changed, 6 insertions(+) > > > > diff --git a/fs/fuse/file.c b/fs/fuse/file.c > > index fdcec3aa7830..9609d13ec351 100644 > > --- a/fs/fuse/file.c > > +++ b/fs/fuse/file.c > > @@ -213,6 +213,10 @@ void fuse_finish_open(struct inode *inode, struct file *file) > > file_update_time(file); > > fuse_invalidate_attr_mask(inode, FUSE_STATX_MODSIZE); > > } > > + > > + if (ff->open_flags & FOPEN_INVAL_ATTR) > > + fuse_invalidate_attr(inode); > > + > > if ((file->f_mode & FMODE_WRITE) && fc->writeback_cache) > > fuse_link_write_file(file); > > } > > diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h > > index d6ccee961891..0b0b7d308ddb 100644 > > --- a/include/uapi/linux/fuse.h > > +++ b/include/uapi/linux/fuse.h > > @@ -301,6 +301,7 @@ struct fuse_file_lock { > > * FOPEN_CACHE_DIR: allow caching this directory > > * FOPEN_STREAM: the file is stream-like (no file position at all) > > * FOPEN_NOFLUSH: don't flush data cache on close (unless FUSE_WRITEBACK_CACHE) > > + * FOPEN_INVAL_ATTR: invalidate the attr cache on open > > */ > > #define FOPEN_DIRECT_IO (1 << 0) > > #define FOPEN_KEEP_CACHE (1 << 1) > > @@ -308,6 +309,7 @@ struct fuse_file_lock { > > #define FOPEN_CACHE_DIR (1 << 3) > > #define FOPEN_STREAM (1 << 4) > > #define FOPEN_NOFLUSH (1 << 5) > > +#define FOPEN_INVAL_ATTR (1 << 6) > > > > /** > > * INIT request/reply flags > > -- > > 2.20.1 > > >