Re: [nfsv4] RFC: New DelegReturn_NoFH operation for NFSv4.2?

Rick Macklem <rick.macklem@gmail.com> Thu, 18 April 2024 00:37 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 14B73C14F6ED for <nfsv4@ietfa.amsl.com>; Wed, 17 Apr 2024 17:37:20 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -7.098
X-Spam-Level:
X-Spam-Status: No, score=-7.098 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_HI=-5, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] 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 7vHFMnUgMueT for <nfsv4@ietfa.amsl.com>; Wed, 17 Apr 2024 17:37:19 -0700 (PDT)
Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 835B6C14F5F2 for <nfsv4@ietf.org>; Wed, 17 Apr 2024 17:37:19 -0700 (PDT)
Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-5ce07cf1e5dso171875a12.2 for <nfsv4@ietf.org>; Wed, 17 Apr 2024 17:37:19 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713400639; x=1714005439; 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=r0kgmabzQ6i6mdUG1kZoHcpliuWFsn6siAWI+jm9W88=; b=nKPL6x/4P0/Z6ZwP9QrCgGkFIjW/imhM/n03b6pGN6eUrBqzjJIRmp9hEvR8I+UEyd WOGpA351JVvXRkFRocRQW4CANn9r4syA6DH4d5j2kUBbaTTb58An9gaEO9lp9AIbdlnD FeHOJ7npTlaGe0nOFuxpcWWf5WHw1Jo1Q5Bq2ss05w8qG6on6vouCWUlxj7t85PKlEXc GnhH03ZJBEM06Ot8SuX2q5UuNxv4H7xkM+NIH35/TBV0jivC7aLE4mLJ5jmzF8XZHssJ 5zdmIOWP2zMn5gocasrV+NWSUhzJEcHSg2vFwsnF25zskmbBJTWQRGmaGuhNTzeS12EW ukBw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713400639; x=1714005439; 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=r0kgmabzQ6i6mdUG1kZoHcpliuWFsn6siAWI+jm9W88=; b=sXepeF50oyLS8Rf1W/Ku2dnY7dYCETv4GU0PTl6K+kwQJTV6bcRMyxfueiXWF1IN4t w37RjWo8gozPy4rSEtGuQb3io4BkmxhfGxIGU/Fm2XQFSo/bmob9EJHc2XDpwtnh6CP4 EIMJpJ1cQUiAXv6UAIH1qllSw6zNsFPnSeVTJhnoM1XqRkhduabty6WmLhpu8HL5z9+y K43wHuB7hpaWx4Q/cgTHdUGJTzYxoGxz7/stVttRR94Gmv/tE5NC/DphPayVk/sWGXVV q03lndw8slQfrb+8k/mpkdnY4MysfB1haeONgoTlyElMxIZezIjml2K24Hfu95VuHS2w jHAw==
X-Forwarded-Encrypted: i=1; AJvYcCVaUKUaDcBPRkEa3R1z7mkTMpAI7La4Xs3N6YTLBmt9MwDG/60a4Z4om4jOn0cRK5c02Np/is8Pd8BvekESmw==
X-Gm-Message-State: AOJu0Yz1wR4wE5eemM6VNGKov99NIP7fSWbDqhN28HypsRFehtaxzyDd x80RIXoIFMMv5RDa8EWY+D0Maz0oiMEG3zbgu2XvAdUmdR1q5ghhkaGivVL1I5tnVoF0e+plFg5 mg4VJSEAzN26c1Lki1cOlxHVXaq0u
X-Google-Smtp-Source: AGHT+IGGrWK0M6K5EREgpaaLQUXVzLllbZJL93JchWLHkpgEdV/5OG5tr3Nseln2UB14jOWofhX8PM4XmyQlKboDo+4=
X-Received: by 2002:a17:90b:68e:b0:2a5:5334:e223 with SMTP id m14-20020a17090b068e00b002a55334e223mr1020201pjz.24.1713400638701; Wed, 17 Apr 2024 17:37:18 -0700 (PDT)
MIME-Version: 1.0
References: <CAM5tNy407R30WQqCuzFE+feRz42wkaAAGOwiHwqFoWZSpwfT0A@mail.gmail.com> <9D17BB42-54A9-46DB-8E4F-3FF852EEAC90@hammerspace.com> <CADaq8jePTg8WVFe2FmrwgUjyc7H9v=Ln7g2FT9G5DJtkpVSF3Q@mail.gmail.com> <CAM5tNy6-ADHC1z9HJME0r5o-hDeG9OucE_SWftDrqE4JnMrhAg@mail.gmail.com> <adc3fb5ed3674078c64399b19891c63b7a1185e4.camel@hammerspace.com> <CAM5tNy77PNiH6aTWTOyhrofe2cFTg+ga8sFzGbi0EHSfrXz79w@mail.gmail.com> <CADaq8jdifYwzZDkrYnaZwV-_bYs=3z8HxfM7mtUAoPy29uvAig@mail.gmail.com> <d4b197a4dcad15d30b4aec25adbd5bb08485f121.camel@hammerspace.com>
In-Reply-To: <d4b197a4dcad15d30b4aec25adbd5bb08485f121.camel@hammerspace.com>
From: Rick Macklem <rick.macklem@gmail.com>
Date: Wed, 17 Apr 2024 17:37:07 -0700
Message-ID: <CAM5tNy7cDpMd+zms1r6PjtVvZQ7LWyyrFmL6Pn_x1FkJYfPckA@mail.gmail.com>
To: Trond Myklebust <trondmy@hammerspace.com>
Cc: "davenoveck@gmail.com" <davenoveck@gmail.com>, "nfsv4@ietf.org" <nfsv4@ietf.org>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Archived-At: <https://mailarchive.ietf.org/arch/msg/nfsv4/J7eMvr9PCFO8e1nBL_DR4InHpSQ>
Subject: Re: [nfsv4] RFC: New DelegReturn_NoFH operation for NFSv4.2?
X-BeenThere: nfsv4@ietf.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: NFSv4 Working Group <nfsv4.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/nfsv4>, <mailto:nfsv4-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/nfsv4/>
List-Post: <mailto:nfsv4@ietf.org>
List-Help: <mailto:nfsv4-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/nfsv4>, <mailto:nfsv4-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 18 Apr 2024 00:37:20 -0000

On Wed, Apr 17, 2024 at 4:56 PM Trond Myklebust <trondmy@hammerspace.com> wrote:
>
> On Wed, 2024-04-17 at 07:46 -0400, David Noveck wrote:
>
>
>
> On Tue, Apr 16, 2024, 5:40 PM Rick Macklem <rick.macklem@gmail.com> wrote:
>
> On Tue, Apr 16, 2024 at 7:44 AM Trond Myklebust <trondmy@hammerspace.com> wrote:
> >
> > On Tue, 2024-04-16 at 07:06 -0700, Rick Macklem wrote:
> > > On Tue, Apr 16, 2024 at 5:21 AM David Noveck <davenoveck@gmail.com>
> > > wrote:
> > > >
> > > >
> > > >
> > > > On Mon, Apr 15, 2024, 8:06 PM Trond Myklebust
> > > > <trondmy@hammerspace.com> wrote:
> > > > >
> > > > >
> > > > >
> > > > > On Apr 15, 2024, at 18:31, Rick Macklem <rick.macklem@gmail.com>
> > > > > wrote:
> > > > >
> > > > > Hi,
> > > > >
> > > > > I am wondering if others have found this a pita and are
> > > > > interested in
> > > > > a new operation for NFSv4.2 to get around it.
> > > > >
> > > > > Right now DelegReturn requires a CFH and delegation stateid.
> > > > > I do not know why the CFH is needed, since it seems that the
> > > > > delegation stateid should be sufficient?
> > > > >
> > > > > This new operation would be the same as DelegReturn except that
> > > > > it would not require a CFH argument.
> > > > >
> > > > > Why am I interested in this?
> > > > > - Lets assume a NFSv4.2 server that supports persistent FHs and
> > > > >  multiple hard links (as most extant servers do).
> > > > > - A client mounted to this server is removing a file for which it
> > > > > holds
> > > > >  a write delegation and a bunch of dirty data.
> > > > > Right now, the client must:
> > > > > - Write the dirty data back to the server.
> > > > > - DelegReturn
> > > > > - Remove
> > > > > because the client has no way of knowing if the file will be
> > > > > deleted
> > > > > by the Remove (or alternately is just removing one of several
> > > > > hard links).
> > > > >
> > > > >
> > > > > If a client is holding a delegation, it will presumably have done
> > > > > a GETATTR at some point while holding that delegation so should
> > > > > know how many links remain. While it is true that the unlink
> > > > > might invalidate the filehandle, that’s not a situation you are
> > > > > able to fix with the new operation.
> > > > >
> > > > > With a DelegReturn_NoFH, the client could:
> > > > > - Do a compound RPC with
> > > > >  Remove
> > > > >  PutFH of file
> > > > > - if the above returns NFS_OK, the file still exists and the
> > > > > client
> > > > >  can continue to use the delegation, writing the dirty data back
> > > > >  to the server sometime later (or maybe never, if the file gets
> > > > >   deleted by a subsequent Remove).
> > > > > or
> > > > > - If the above returns NFS4ERR_STALE for the PutFH, the file
> > > > >  has been deleted. It can throw the dirty data away and
> > > > >  DelegReturn_NoFH the delegation.
> > > > >
> > > > > A similar situation exists for Rename where the destination
> > > > > already exists.
> > > > >
> > > > > I find this scenario happens frequently during software builds.
> > > > >
> > > > > So, what do others think  w.r.t. this new operation? rick
> > > > >
> > > > >
> > > > > Why would you need to do a DELEGRETURN if the PUTFH returns
> > > > > NFS4ERR_STALE?
> > > >
> > > >
> > > > To make sure the client and server agree on the state of things.
> > > >
> > > > > If the server isn’t willing to just invalidate the delegation on
> > > > > the final unlink of the file,
> > > >
> > > > I'm not sure about "unwilling",  but I am uncomfortable with
> > > > unilateral stare changes like this, even if the spec indicated that
> > > > needed to be done, which is harder to effect than an extension such
> > > > as Rick is proposing
> > > >
> > > >  > then it can and should recall the delegation (and any pNFS
> > > > layouts that might be outstanding).
> > > >
> > > > If it did recall it/them, then there is no way to return them
> > > > without something like Rick's proposed extension.
> > > I assumed Trond meant "recall during the REMOVE" while the FH is
> > > still valid.
>
>
> I didn't get that.  Apparently, I was mistaken.
>
> >
> > Yes. This is a clarification of how the server can deal with the
> > problem (if it thinks this is a problem) within the confines of the
> > existing spec
>
>
> That depends on what the problem is.  Your proposal does address the problem of recalling a delegation when it is incapable of being returned.  It doesn't, at least alone, solve Rick's problem  which is that he wants to be able to know, at the time of recall, whether he can throw away pending writes, as opposed to flushing them to the server.
>
>
> Please re-read what I said above (repeated here):
>
> > > > > If a client is holding a delegation, it will presumably have done
> > > > > a GETATTR at some point while holding that delegation so should
> > > > > know how many links remain. While it is true that the unlink
> > > > > might invalidate the filehandle, that’s not a situation you are
> > > > > able to fix with the new operation.
I did not get this. Now I see that in LINK (sec. 18.9.3) it says that
delegations must
be CB_RECALL'd (I never noticed that and assumed that a LINK could
be done by another client when a delegation is held. My Bad;-)

So, yes, the client that holds a delegation can track numlinks for the
file. I didn't realize that was the case.

>
>
> The point is that there are 2 problems here, and they are orthogonal to one another.
>
> One problem is the question of "is this the last link?", which the above addresses. Well.... Except that Rick cannot know for certain that the REMOVE will actually succeed. Until he has tried the operation, he can only hope...
>
> The second problem is the question of "is the filehandle now stale, and how do I return my delegation?", which the above does not address. For reasons best known to themselves, the authors of RFC3010, and subsequent NFSv4 specs decided that it is OK to have filehandles that are derived from an object pathname (e.g. RFC8881 section 4.2.1 and section 10.3.4), so presumably the REMOVE could end up invalidating the filehandle despite the file having several links remaining. It seems to me that such a server does need to either recall the delegation, or be prepared to administratively revoke it on invalidation of that filehandle.

Isn't this covered by a persistent filehandle, which is what I specified
in the original post (and have assumed throughout) and. maybe, support
for numlinks? (It might be possible to construct a persistent FH using an
object pathname, but only if multiple hard links are not supported, I think?)

(To be honest, the FreeBSD NFSv4.1/4.2 client will be broken for non-persistent
file handles and I have yet to hear reports of problems or done any work to fix
it. It has never been clear to me what a client does when a volatile file handle
becomes NFS4ERR_FHEXPIRED?)

So, now that I know numlinks will not be changed by other clients
while a delegation
is held, I think that numlinks == 1 before a REMOVE will determine if
the file will
be deleted and I think that resolves this.
(Assuming persistent file handles.)

rick

> The gentler approach would be to recall...
>
> --
>
> Trond Myklebust
> Linux NFS client maintainer, Hammerspace
> trond.myklebust@hammerspace.com
>
>