Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6346427rwr; Mon, 24 Apr 2023 18:51:23 -0700 (PDT) X-Google-Smtp-Source: AKy350YrcVbbbmb0bIVBNcBOe3OPm+1efdlB1XMKqDwOx8/brhorJsJ2MkTDz6bey4MklHLsKvM+ X-Received: by 2002:a17:903:26c9:b0:1a2:7462:d674 with SMTP id jg9-20020a17090326c900b001a27462d674mr19412422plb.24.1682387483044; Mon, 24 Apr 2023 18:51:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682387483; cv=none; d=google.com; s=arc-20160816; b=u3PQnHLGQ4h2iy3LIEUE0z9mZtZkryggSJxdQ6YgHOAtdqE6gcSczs834nRjqyh0zY tkZMxuLllDVTz1d0NIibG4QdohfQy4z01MGhEHSHkfrLv8P4u2HkxizAw6V9mQ18DjDV krRCGt3/R7FVAb7qRpitBymOQI2NAj4dL4syl0kuO2M4JwAhDCB88ekmYNAJTi52A2e2 TfF1XZ+xba6FQ2bkginxyO3ZJD1rmpCc6XO6Vrf/4JqgDkQmSZwYe11XaTjMCfisjSAj C+7hpbCusZ+1lYtDR0jyv/7ab0b4giZq9T2i7eyJpmtWwzW/U3juPyLfd+gsM0yX+waG y3hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=lmdurcU6KIQdQ88/QQmDRrixoBaqul18ztg8rDaEvCs=; b=i12gtWDE3JWWaeLBRJ255H438oWN2zO4S+Aw+Y58Fd8pmQl9z2SujU2IVAJgCzOxWr loJDituP/qBJk8IEyngTOBvYSIFQaO9/kpTmcK7q20o1Wg2IgTyBfWHgiBt3mFpaNNYl Tlo6EpfuaaK1elAZdZW5N+KFLhwoBJh5BXu6zHfXCFWc2IXpF3J3azeCyy637XQsyC99 W1PGSRuLjpgfMrX+bBF306L6oRXCCbIZYIKrg3dPXohEyitp0EPm5lSuJj0siFNz2nuU Rhe6CuO2PwdyUWcLaCTzirOV2IN0LTn4AN98hVNUMrPPpEyQFOUHzzDiwD5a6THL54Ip hz4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=XM5IWsvk; 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=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w18-20020a170902c79200b001a6bc1e696bsi11560731pla.25.2023.04.24.18.51.08; Mon, 24 Apr 2023 18:51: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=@canonical.com header.s=20210705 header.b=XM5IWsvk; 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=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229637AbjDYBmA (ORCPT + 99 others); Mon, 24 Apr 2023 21:42:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230093AbjDYBl6 (ORCPT ); Mon, 24 Apr 2023 21:41:58 -0400 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC061AF2B for ; Mon, 24 Apr 2023 18:41:56 -0700 (PDT) Received: from mail-yb1-f197.google.com (mail-yb1-f197.google.com [209.85.219.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 932283F205 for ; Tue, 25 Apr 2023 01:41:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1682386914; bh=lmdurcU6KIQdQ88/QQmDRrixoBaqul18ztg8rDaEvCs=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=XM5IWsvkYFR7qwIMuvi0aP44uyQb0o/7enf8siqRhY5AOCVH/wpYXxJj/Kxph7kEN zantuOT06cnUFICIieG72QxzFUuFCZTaMHGkKl3FQ4h8CONrWZVQhaSx45Uxh1NPqI dKReqpXMZGgvBYh5kkFJt5cMiv3eziFd8UKYvCRcCF4aAlMEDklmfSazjRNfoRKH82 J3bxnl06ZqAX21X9Tvfxb8eqKo3AWeUWGhIgcCKIqEIVz7J/tuCBpAI9Cv2Wu58nVi xTfqrpMFXSgfPOpu+qfbqIYrL6N1ZL4V9I0nzToEF4QAZV4O8+llApmsRpw4KOhWUj ZF08fOqo5OIvw== Received: by mail-yb1-f197.google.com with SMTP id 3f1490d57ef6-b99f3aee8e0so791480276.0 for ; Mon, 24 Apr 2023 18:41:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682386913; x=1684978913; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lmdurcU6KIQdQ88/QQmDRrixoBaqul18ztg8rDaEvCs=; b=MpHFdUy9iovRwp+RClTlhCN1iPSiVkftT/u4eihPOxtxATiWJLXME5EVn52xCzd+7o 3uw+f2ZNSWdY3HNTvfxEyWxiz29XI/KanDCVtxBGrDPu5hFFUJDp8/IlHnXdEYC9IVaw qBJf1FW11qnxJsSDdIsnLL4zBa3OgEkBJYExm9sIPURHS079Ih8DMv9L6t6dxinG66cx xstmHqYte57T8uF+uAe20U0ZfHLG/lA1YDFIzGpIuLzm296yDxa6dybtt+kAxJ2Hiy02 sP4NSvwCYLJrThbCfNJ9c0TMG6WOTLOWv8AiRRbBzTCy6m5y3bn8WjQSAyz4bQIDRulV Agpw== X-Gm-Message-State: AAQBX9e1jw6sRH/3Gef6BQIFcT1RCDld2LPAc3AACiCigOCJklUWQ/dZ t44gWkwxYrTwyiGMe6WgE99xFG6pgYX38o9abRdRPzJWG7HgDebWyFdXqve2119T2N5bvUvroCr BUtPlE+UrwmjH2tZT9P6rmcdFb8SaZsvUUp+Xwvw5bPuPAfCPyWrqJOv8ng== X-Received: by 2002:a81:700c:0:b0:54b:f8b4:bc8d with SMTP id l12-20020a81700c000000b0054bf8b4bc8dmr9081708ywc.0.1682386913234; Mon, 24 Apr 2023 18:41:53 -0700 (PDT) X-Received: by 2002:a81:700c:0:b0:54b:f8b4:bc8d with SMTP id l12-20020a81700c000000b0054bf8b4bc8dmr9081693ywc.0.1682386912908; Mon, 24 Apr 2023 18:41:52 -0700 (PDT) MIME-Version: 1.0 References: <20230411030248.53356-1-chengen.du@canonical.com> In-Reply-To: From: Chengen Du Date: Tue, 25 Apr 2023 09:41:41 +0800 Message-ID: Subject: Re: [PATCH] NFS: Add mount option 'nofasc' To: trond.myklebust@hammerspace.com Cc: anna@kernel.org, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Hi, May I ask if there are any concerns or opinions regarding the introduction of the new mount option? If there is a more suitable solution, we can discuss it, and I can work on implementing it. Best regards, Chengen Du On Wed, Apr 19, 2023 at 3:18=E2=80=AFPM Daire Byrne wrote: > > Just to say, I am personally for this or some other way to opt out of > the increased ACCESS calls on select servers (e.g. ones with high > latency or with lots of multi user logins). > > I see it as similar to "actimeo" and "nocto" options in allowing users > to reduce "correctness" at their own risk if it helps with their > workloads and they deem the risk worth it. > > I am currently reverting the original patches in our kernel for our > nfs re-exporting workloads. > > Daire > > > On Tue, 11 Apr 2023 at 04:03, Chengen Du wrote= : > > > > This mount option is used to skip clearing the file access cache > > upon login. Some users or applications switch to other privileged > > users via commands such as 'su' to operate on NFS-mounted folders. > > In such cases, the privileged user's login time will be renewed, > > and NFS ACCESS operations will need to be re-sent, potentially > > leading to performance degradation. > > In some production environments where the access cache can be > > trusted due to stable group membership, this option could be > > particularly useful. > > > > Signed-off-by: Chengen Du > > --- > > fs/nfs/dir.c | 21 ++++++++++++--------- > > fs/nfs/fs_context.c | 8 ++++++++ > > fs/nfs/super.c | 1 + > > include/linux/nfs_fs_sb.h | 1 + > > 4 files changed, 22 insertions(+), 9 deletions(-) > > > > diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c > > index 6fbcbb8d6587..9a6d86e2044e 100644 > > --- a/fs/nfs/dir.c > > +++ b/fs/nfs/dir.c > > @@ -2953,12 +2953,14 @@ static struct nfs_access_entry *nfs_access_sear= ch_rbtree(struct inode *inode, co > > return NULL; > > } > > > > -static u64 nfs_access_login_time(const struct task_struct *task, > > - const struct cred *cred) > > +static inline > > +bool nfs_check_access_stale(const struct task_struct *task, > > + const struct cred *cred, > > + const struct nfs_access_entry *cache) > > { > > const struct task_struct *parent; > > const struct cred *pcred; > > - u64 ret; > > + u64 login_time; > > > > rcu_read_lock(); > > for (;;) { > > @@ -2968,15 +2970,15 @@ static u64 nfs_access_login_time(const struct t= ask_struct *task, > > break; > > task =3D parent; > > } > > - ret =3D task->start_time; > > + login_time =3D task->start_time; > > rcu_read_unlock(); > > - return ret; > > + > > + return ((s64)(login_time - cache->timestamp) > 0); > > } > > > > static int nfs_access_get_cached_locked(struct inode *inode, const str= uct cred *cred, u32 *mask, bool may_block) > > { > > struct nfs_inode *nfsi =3D NFS_I(inode); > > - u64 login_time =3D nfs_access_login_time(current, cred); > > struct nfs_access_entry *cache; > > bool retry =3D true; > > int err; > > @@ -3005,7 +3007,8 @@ static int nfs_access_get_cached_locked(struct in= ode *inode, const struct cred * > > retry =3D false; > > } > > err =3D -ENOENT; > > - if ((s64)(login_time - cache->timestamp) > 0) > > + if (!(NFS_SERVER(inode)->flags & NFS_MOUNT_NOFASC) && > > + nfs_check_access_stale(current, cred, cache)) > > goto out; > > *mask =3D cache->mask; > > list_move_tail(&cache->lru, &nfsi->access_cache_entry_lru); > > @@ -3025,7 +3028,6 @@ static int nfs_access_get_cached_rcu(struct inode= *inode, const struct cred *cre > > * but do it without locking. > > */ > > struct nfs_inode *nfsi =3D NFS_I(inode); > > - u64 login_time =3D nfs_access_login_time(current, cred); > > struct nfs_access_entry *cache; > > int err =3D -ECHILD; > > struct list_head *lh; > > @@ -3040,7 +3042,8 @@ static int nfs_access_get_cached_rcu(struct inode= *inode, const struct cred *cre > > cache =3D NULL; > > if (cache =3D=3D NULL) > > goto out; > > - if ((s64)(login_time - cache->timestamp) > 0) > > + if (!(NFS_SERVER(inode)->flags & NFS_MOUNT_NOFASC) && > > + nfs_check_access_stale(current, cred, cache)) > > goto out; > > if (nfs_check_cache_invalid(inode, NFS_INO_INVALID_ACCESS)) > > goto out; > > diff --git a/fs/nfs/fs_context.c b/fs/nfs/fs_context.c > > index 9bcd53d5c7d4..5cd9b2882c79 100644 > > --- a/fs/nfs/fs_context.c > > +++ b/fs/nfs/fs_context.c > > @@ -88,6 +88,7 @@ enum nfs_param { > > Opt_vers, > > Opt_wsize, > > Opt_write, > > + Opt_fasc, > > }; > > > > enum { > > @@ -194,6 +195,7 @@ static const struct fs_parameter_spec nfs_fs_parame= ters[] =3D { > > fsparam_string("vers", Opt_vers), > > fsparam_enum ("write", Opt_write, nfs_param_enums_writ= e), > > fsparam_u32 ("wsize", Opt_wsize), > > + fsparam_flag_no("fasc", Opt_fasc), > > {} > > }; > > > > @@ -861,6 +863,12 @@ static int nfs_fs_context_parse_param(struct fs_co= ntext *fc, > > case Opt_sloppy: > > ctx->sloppy =3D true; > > break; > > + case Opt_fasc: > > + if (result.negated) > > + ctx->flags |=3D NFS_MOUNT_NOFASC; > > + else > > + ctx->flags &=3D ~NFS_MOUNT_NOFASC; > > + break; > > } > > > > return 0; > > diff --git a/fs/nfs/super.c b/fs/nfs/super.c > > index 05ae23657527..059513d403f8 100644 > > --- a/fs/nfs/super.c > > +++ b/fs/nfs/super.c > > @@ -444,6 +444,7 @@ static void nfs_show_mount_options(struct seq_file = *m, struct nfs_server *nfss, > > { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" }, > > { NFS_MOUNT_UNSHARED, ",nosharecache", "" }, > > { NFS_MOUNT_NORESVPORT, ",noresvport", "" }, > > + { NFS_MOUNT_NOFASC, ",nofasc", "" }, > > { 0, NULL, NULL } > > }; > > const struct proc_nfs_info *nfs_infop; > > diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h > > index ea2f7e6b1b0b..a39ae1bd2217 100644 > > --- a/include/linux/nfs_fs_sb.h > > +++ b/include/linux/nfs_fs_sb.h > > @@ -153,6 +153,7 @@ struct nfs_server { > > #define NFS_MOUNT_WRITE_EAGER 0x01000000 > > #define NFS_MOUNT_WRITE_WAIT 0x02000000 > > #define NFS_MOUNT_TRUNK_DISCOVERY 0x04000000 > > +#define NFS_MOUNT_NOFASC 0x08000000 > > > > unsigned int fattr_valid; /* Valid attributes */ > > unsigned int caps; /* server capabilities = */ > > -- > > 2.37.2 > >