[nfsv4] Re: question around CB_GETATTR handling

Rick Macklem <rick.macklem@gmail.com> Wed, 04 September 2024 21:16 UTC

Return-Path: <rick.macklem@gmail.com>
X-Original-To: nfsv4@ietfa.amsl.com
Delivered-To: nfsv4@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 2671DC1D5C45 for <nfsv4@ietfa.amsl.com>; Wed, 4 Sep 2024 14:16:06 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.108
X-Spam-Level:
X-Spam-Status: No, score=-2.108 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id c0zrjvntVTGS for <nfsv4@ietfa.amsl.com>; Wed, 4 Sep 2024 14:16:04 -0700 (PDT)
Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id C1100C1D5305 for <nfsv4@ietf.org>; Wed, 4 Sep 2024 14:16:04 -0700 (PDT)
Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-2053f6b8201so823245ad.2 for <nfsv4@ietf.org>; Wed, 04 Sep 2024 14:16:04 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725484564; x=1726089364; darn=ietf.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=QCw4uFzRlusWfUixuJT68CeY9CUQsizWELe5sdt43eE=; b=hJnQBbifwA9OJEVsVmCv5jgUCazU6Hgn3kKk4tB3MFYLdxbBhxZfEeDasdz3PnmayY PCqYZ4wTgU0WYpIvDYaf2yLcuponsCmGLO8mvQWWj7i6EmfNJaLrCf62r8te656WJbbr 8VfiLbhko/yf/mktEUph7rlDGwC6wXBOlP+u1UKennb6p8j6pknyiXuq2ufFqzQWI7aQ O2+Lz3Y2WGQR1yFlnWXDTkrpVHyPbnchoGpef2pK6GdpV0RC8h+DG6EoTiG5rcvGyR9K 5nV763hcr3uxLD9qOwEHlm3sU+fyFxgDjgc+56xcOsD9MaZa58d0xEGjFqEaTGZf0vnY QkWg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725484564; x=1726089364; 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=QCw4uFzRlusWfUixuJT68CeY9CUQsizWELe5sdt43eE=; b=WBbXk7QlXKw3IoYagCLPpONF919bzjBPD4VJSEdKpb2bHj3aajs0IN2j9T50P1CbSs ITujffR7efliR0/BOlUXq/jsV+3Im1bhDciG4EP9VVAwdJCJBxrwnDYilqY2KA+Vj+G9 FyRbKhbex+DVeRxf61njQTdpVswXWC2XjZFW90HzKcHH3o2JWf4mMDA79L7OpC1SDFgq LMc7U6aCVR8/Mo6N19UiF78SKdWPU/MS16IVKTvo1WowBfS23s/z02UdldIPc43qy0aE FZ/lQHc81TaNNXLCP5LVA1s3NZZGvcmUxLmrn20AXGj7AgBJCiuOHWOWAAhYNHTWxNGa 4miQ==
X-Forwarded-Encrypted: i=1; AJvYcCWtTcB7GmieEW5OZg6b2e02cPzRHKiKH9kcQAMoCK5E1fgeYbegIteu6psP2tzbLPfqSPH8hA==@ietf.org
X-Gm-Message-State: AOJu0Yy7g2OjyRHvk6p7vnWcX37mVEWXt8JxtKUw9C15MYSGz2ncEF3b YMWKP4uMCwKGU6L+yAJth0lnm4dTpmTOY5kQKZu7tjzsI6/wOOJh8ynCJ7amP91GbyD7AFHN3A1 QbjWRy8fWZUyXAYeM40oRFVLk6Q==
X-Google-Smtp-Source: AGHT+IFmNcjWjRT2UfIX9k0gwT8FJIZH/Wc086Sr/n3WhyptWiSK4qi82/69v0uUnbJnF7DAU+QldUyDkKkYOCahnOA=
X-Received: by 2002:a17:903:2a8f:b0:205:79c:56f5 with SMTP id d9443c01a7336-20546600327mr156862455ad.27.1725484563601; Wed, 04 Sep 2024 14:16:03 -0700 (PDT)
MIME-Version: 1.0
References: <6e6e3d11d0d48c88cc4cefc28b66d9cfb5874723.camel@poochiereds.net> <e584a74b46853af247212e8dc9bee1949c676cea.camel@hammerspace.com> <28b4c2851c73b518023f2e78be53874c64b1cff3.camel@poochiereds.net> <2074c10c3de50525f30089fd1634c421b3eddca6.camel@hammerspace.com> <880007b35526b41f41ce1263cd96813e7e5faf92.camel@poochiereds.net> <CAM5tNy5GJm+BXNiLJUZ8aS5kT5S0uLwUiBBF1MKQQ-0gGmTwQQ@mail.gmail.com>
In-Reply-To: <CAM5tNy5GJm+BXNiLJUZ8aS5kT5S0uLwUiBBF1MKQQ-0gGmTwQQ@mail.gmail.com>
From: Rick Macklem <rick.macklem@gmail.com>
Date: Wed, 04 Sep 2024 14:15:52 -0700
Message-ID: <CAM5tNy6aZM8RkuvycuNLaNhP6fB4O1TuGx3SvjW2Hd6ZE1Yhuw@mail.gmail.com>
To: Jeff Layton <jlayton@poochiereds.net>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Message-ID-Hash: XGZFOQ5U5Z5DBFWKEKXBOX5R4TQ6ZIJL
X-Message-ID-Hash: XGZFOQ5U5Z5DBFWKEKXBOX5R4TQ6ZIJL
X-MailFrom: rick.macklem@gmail.com
X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-nfsv4.ietf.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header
CC: Trond Myklebust <trondmy@hammerspace.com>, "nfsv4@ietf.org" <nfsv4@ietf.org>
X-Mailman-Version: 3.3.9rc4
Precedence: list
Subject: [nfsv4] Re: question around CB_GETATTR handling
List-Id: NFSv4 Working Group <nfsv4.ietf.org>
Archived-At: <https://mailarchive.ietf.org/arch/msg/nfsv4/sSvLAE0DezR7OJZgnti-mrbyd4k>
List-Archive: <https://mailarchive.ietf.org/arch/browse/nfsv4>
List-Help: <mailto:nfsv4-request@ietf.org?subject=help>
List-Owner: <mailto:nfsv4-owner@ietf.org>
List-Post: <mailto:nfsv4@ietf.org>
List-Subscribe: <mailto:nfsv4-join@ietf.org>
List-Unsubscribe: <mailto:nfsv4-leave@ietf.org>

On Wed, Sep 4, 2024 at 2:05 PM Rick Macklem <rick.macklem@gmail.com> wrote:
>
> On Wed, Sep 4, 2024 at 1:09 PM Jeff Layton <jlayton@poochiereds.net> wrote:
> >
> > On Wed, 2024-09-04 at 19:47 +0000, Trond Myklebust wrote:
> > > On Wed, 2024-09-04 at 15:33 -0400, Jeff Layton wrote:
> > > > On Wed, 2024-09-04 at 19:21 +0000, Trond Myklebust wrote:
> > > > > On Wed, 2024-09-04 at 12:23 -0400, Jeff Layton wrote:
> > > > > > RFC 8881, section 10.4.3 has this pseudo code to describe how to
> > > > > > handle
> > > > > > the size and change attr:
> > > > > >
> > > > > > ------------------8<-------------------
> > > > > >     if (!modified) {
> > > > > >         do CB_GETATTR for change and size;
> > > > > >
> > > > > >         if (cc != sc)
> > > > > >             modified = TRUE;
> > > > > >     } else {
> > > > > >         do CB_GETATTR for size;
> > > > > >     }
> > > > > >
> > > > > >     if (modified) {
> > > > > >         sc = sc + 1;
> > > > > >         time_modify = time_metadata = current_time;
> > > > > >         update sc, time_modify, time_metadata into file's
> > > > > > metadata;
> > > > > >     }
> > > > > > ------------------8<-------------------
> > > > > >
> > > > > >
> > > > > > The line that shows sc = sc + 1 seems to indicate that we need to
> > > > > > increment "sc" on every CB_GETATTR, even if nothing changed since
> > > > > > the
> > > > > > last time.
> > > > > >
> > > > > > Is that correct or should we only increment it if it wasn't
> > > > > > incremented
> > > > > > before? The latter would make more sense, given that it doesn't
> > > > > > query
> > > > > > for change if the file is already considered to be modified.
> > > > >
> > > > > I believe RFC5661 says
> > > > >
> > > > >    For simplicity of implementation, the client MAY for each
> > > > > CB_GETATTR
> > > > >    return the same value d.  This is true even if, between
> > > > > successive
> > > > >    CB_GETATTR operations, the client again modifies the file's data
> > > > > or
> > > > >    metadata in its cache.  The client can return the same value
> > > > > because
> > > > >    the only requirement is that the client be able to indicate to
> > > > > the
> > > > >    server that the client holds modified data.  Therefore, the
> > > > > value of
> > > > >    d may always be c + 1.
> > > > >
> > > > > Which is how the Linux client tries to implement it.
> > > > >
> > > >
> > > > Right, 8881 is similar.
> > >
> > > Yeah, but nobody has coded to that.
> > >
> > > >
> > > > In this case though, I'm asking about the server-side implementation.
> > > > That has its own algorithm (illustrated above in the pseudocode), and
> > > > it seems to indicate that once the server detects that the client has
> > > > made a single modification to the file, that it needs to increment
> > > > "sc"
> > > > on every subsequent CB_GETATTR.
> > > >
> > > > That makes no sense on its face, so I suspect this is a mistake in
> > > > the
> > > > pseudocode above. Or am I wrong and this is actually necessary?
> > > > --
> > >
> > > Oh... No, as far as the server is concerned, I think it is indeed
> > > supposed to increment the change attribute and timestamps on every
> > > reply. That is reinforced here:
> > >
> > >    As discussed earlier in this section, the client MAY return the same
> > >    cc value on subsequent CB_GETATTR calls, even if the file was
> > >    modified in the client's cache yet again between successive
> > >    CB_GETATTR calls.  Therefore, the server must assume that the file
> > >    has been modified yet again, and MUST take care to ensure that the
> > >    new nsc it constructs and returns is greater than the previous nsc it
> > >    returned.
> > >
> > > The spec also says that "committing the constructed attribute values to
> > > stable storage is OPTIONAL". That seems misleading or possibly just
> > > incorrect. The fact that the client declares that it is caching data
> > > doesn't necessarily mean that it will actually manage to write that
> > > data back.
> I think the server does have the option of not saving the change attribute
> on stable storage and then, after a server reboot, if the client does a
> OPEN/CLAIM_PREVIOUS for the delegation, the server can require
> an immediate recall of the delegation. (By setting recall == true in the
> open_read_delegation4/open_write_delegation4.)
>
> At least I think that works?
Hmm. I now think it takes more than the above. I think it does need to
commit nsc to stable storage, just as it would for changes done via
write(s) to the server, as an updated change.
(It is the sc value it can forget on a reboot, if
it does the immediate recall for CLAIM_REVIOUS for a write delegation.)

Does this sound correct to others? rick

>
> >
> > Huh, ok.
> >
> > So imagine that the client gets a write deleg and makes a single small
> > change to the file, but then holds on to the write deleg for a long
> > time. Other clients are issuing CB_GETATTRs against the server.
> > Eventually the delegation is returned.
> >
> > Could you end up in a change attr reuse situation due to all of this
> > faux change attr incrementing by the server?
> Since change is 64bits, I think this will take a very very long time?
>
> rick
>
> > --
> > Jeff Layton <jlayton@poochiereds.net>
> >
> > _______________________________________________
> > nfsv4 mailing list -- nfsv4@ietf.org
> > To unsubscribe send an email to nfsv4-leave@ietf.org