Re: [nfsv4] RFC: Is Open/Claim_Delegate_Prev done before/after Reclaim_complete?

Rick Macklem <rick.macklem@gmail.com> Sun, 07 April 2024 00:48 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 24148C14F61C for <nfsv4@ietfa.amsl.com>; Sat, 6 Apr 2024 17:48:35 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.098
X-Spam-Level:
X-Spam-Status: No, score=-2.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_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 REnVNMMdDkxD for <nfsv4@ietfa.amsl.com>; Sat, 6 Apr 2024 17:48:34 -0700 (PDT)
Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) (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 3D29BC14F5EC for <nfsv4@ietf.org>; Sat, 6 Apr 2024 17:48:34 -0700 (PDT)
Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-53fa455cd94so2747114a12.2 for <nfsv4@ietf.org>; Sat, 06 Apr 2024 17:48:34 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712450913; x=1713055713; 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=V0aBHVoVmOOi1fJJFjqkDUZz5XfY4ju2pNCXjkphGvI=; b=ghX5b2PIJV+nF8m4obsKeWdKJcXjvTY0uBIg0d2G4qOfnH19JDcnUiOURw3DK9N66t 5+eefQIdUyZAzp5W4ck0SYrkhe8V8EA4I2gQ4IFOMSFKKpttMhd2jgE7yPpsifc8WDeb 0wOxK4w5mmxHFuYkqF7bta4gG2hxM+Wu+REdZ0eDD2z5VDsScM11Qx5kv935fHOincF1 ul+eMOGlGxJo0m41YKOzaIzC7fUNk8stE8kpF4tWQcsv7oErkGlt1MpWSditDxrQn5kv 90IsJZCzwUbyrZ3ckd5tk7ZOaf7R2Q4dUiRFrFQySoci4a9IJek0RfFGYGb756EKJERJ 6DTA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712450913; x=1713055713; 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=V0aBHVoVmOOi1fJJFjqkDUZz5XfY4ju2pNCXjkphGvI=; b=FxM2oHj7QCtHKaEyWygIF5G6HhpwPau6TEHziFKWWBS7s1obzz2/aw/1uYL4NUVUAY /YZXwqR6Xba/18M7j7uM/5stCxS1sh5Ov7cXieoKFRasl/P47tZW4dBf2zIdcLfZaqqP nq2YV1p7xrrbAJRu1j2Ih8RR3rohRp9rgSrqxfNrMUaNdSZSO9WjIteCSmMFAjEK8GV4 xvqn02Pab4qWQLfImu5Ku+ISIVWrYX25HYphW+eQVeW72urgeqHn7YA+jwaW4swkLAu4 KtFMIMyTjBhFicQM1PsnV/X+UUBs1eYfrfet1jMbHLvkiI3p1S9b3DfaR5HYs9tbX69u 8+Eg==
X-Gm-Message-State: AOJu0YxsoFqWg2Bv4aaxdiVePI8Utr84AICjBxuTttHFjYllyDBaKh2b +oxpbikkRVRPHJOOmApPVovuxN2kzb88/M9n71EEkXD3HkoMny/Spdjm6q68HO/upn522VcPVP8 xrAjfBjXcplm+PMaL2PN4j0SVyqposK4=
X-Google-Smtp-Source: AGHT+IG9zA4kXWC87NCRhxpfk0OqJWB6gs9w55XpSJElTjKSSetcqiCMV95dv4Poe1P1qIqbNBchf8xuZTZG9ZY5B+s=
X-Received: by 2002:a05:6a20:dd84:b0:1a7:5951:edac with SMTP id kw4-20020a056a20dd8400b001a75951edacmr417153pzb.26.1712450913365; Sat, 06 Apr 2024 17:48:33 -0700 (PDT)
MIME-Version: 1.0
References: <CAM5tNy4y36AEyD5SeOZ2F1t8AYhu8-ZKPyNvCd-dmydFg1kJtA@mail.gmail.com> <19e3502ca1859608975bd17dc18e6774bf0bfab3.camel@hammerspace.com> <CAM5tNy41j0BLi0ixu=VA_rT14GxL7ZKKwbSyb1UAgf-xAE8m+g@mail.gmail.com> <0d1c12d3e85a5feb165c13b44b0f25111224166f.camel@hammerspace.com>
In-Reply-To: <0d1c12d3e85a5feb165c13b44b0f25111224166f.camel@hammerspace.com>
From: Rick Macklem <rick.macklem@gmail.com>
Date: Sat, 06 Apr 2024 17:48:23 -0700
Message-ID: <CAM5tNy7i3SyY0mLbd+vsmO-jpkZ6Bdr8hz3w5T-PhR8GdbMpnA@mail.gmail.com>
To: Trond Myklebust <trondmy@hammerspace.com>
Cc: "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/YP7gzJ_iaWW1LEjBfBDXRHHWNxg>
Subject: Re: [nfsv4] RFC: Is Open/Claim_Delegate_Prev done before/after Reclaim_complete?
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: Sun, 07 Apr 2024 00:48:35 -0000

On Fri, Apr 5, 2024 at 8:02 PM Trond Myklebust <trondmy@hammerspace.com> wrote:
>
> On Fri, 2024-04-05 at 16:13 -0700, Rick Macklem wrote:
> > On Thu, Apr 4, 2024 at 9:18 PM Trond Myklebust
> > <trondmy@hammerspace.com> wrote:
> > >
> > > On Thu, 2024-04-04 at 16:23 -0700, Rick Macklem wrote:
> > > > Hi,
> > > >
> > > > I am in the process of implementing Open/Claim_Delegate_Prev and
> > > > have
> > > > run
> > > > into a question I cannot seem to answer from reading RFC8881.
> > > >
> > > > There is this snippet:
> > > >    enum open_claim_type4 {
> > > >            /*
> > > >             * Not a reclaim.
> > > >             */
> > > >            CLAIM_NULL              = 0,
> > > >
> > > >            CLAIM_PREVIOUS          = 1,
> > > >            CLAIM_DELEGATE_CUR      = 2,
> > > >            CLAIM_DELEGATE_PREV     = 3,
> > > >
> > > >            /*
> > > >             * Not a reclaim.
> > > >             *
> > > >             * Like CLAIM_NULL, but object identified
> > > >             * by the current filehandle.
> > > >             */
> > > >            CLAIM_FH                = 4, /* new to v4.1 */
> > > > The comments in the above seem to "hint" that CLAIM_DELEGATE_PREV
> > > > is
> > > > a
> > > > reclaim type operation.
> > > > If that is the case, I'd assume it/should be performed by the
> > > > client
> > > > before it does a
> > > > Reclaim_Complete?
> > > >
> > > > Then there is this snippet:
> > > >    For OPEN requests that reach the server during the grace
> > > > period,
> > > > the
> > > >    server returns an error of NFS4ERR_GRACE.  The following claim
> > > > types
> > > >    are exceptions:
> > > >
> > > >    *  OPEN requests specifying the claim type CLAIM_PREVIOUS are
> > > > devoted
> > > >       to reclaiming opens after a server restart and are
> > > > typically
> > > > only
> > > >       valid during the grace period.
> > > >
> > > >    *  OPEN requests specifying the claim types CLAIM_DELEGATE_CUR
> > > > and
> > > >       CLAIM_DELEG_CUR_FH are valid both during and after the
> > > > grace
> > > >       period.  Since the granting of the delegation that they are
> > > >       subordinate to assures that there is no conflict with locks
> > > > to
> > > > be
> > > >       reclaimed by other clients, the server need not return
> > > >       NFS4ERR_GRACE when these are received during the grace
> > > > period.
> > > > This clearly states that CLAIM_DELEGATE_PREV cannot be performed
> > > > during the server's grace period.
> > > >
> > > > The above two statements are not necessarily contradictory but it
> > > > does seem
> > > > that, if the server is in its grace period, the Reclaim_Complete
> > > > needs to be
> > > > done before any Open/Claim_Delegate_Prev, since Reclaim_Complete
> > > > tells
> > > > the server when to end its grace period.
> > > > Note that, usually, a client would not be rebooting when a server
> > > > is
> > > > in its
> > > > grace period, but that could happen.
> > > >
> > > > Bottom line...
> > > > Should a client perform Open/Claim_Delegate_Prev before or after
> > > > Reclaim_Complete?
> > > > And, if the answer is "after", how does the server know when a
> > > > client
> > > > is done recovering opens/delegations via
> > > > Open/Claim_Delegate_Prev?
> > > >
> > > > Thanks for any help with this, rick
> > >
> > > CLAIM_DELEGATE_PREV has now survived at least 24 years as part of a
> > > "standard" and has yet to be properly described. I can find
> > > references
> > > to it in RFC3010 and all NFSv4 descriptions since then, but I have
> > > yet
> > > to meet anybody who can claim to have implemented it in a product.
> > >
> > > IMO, it is time to drop it, and start afresh with something that
> > > has
> > > actually been road tested before someone started putting pen to
> > > paper.
> > Well, I am going to respond to David's post in some more detail, but
> > I will
> > note here that, with the exception of whether to do it before or
> > after
> > Reclaim_complete,
> > I have not found serious issues with it. (Btw, the FreeBSD server has
> > had a "dormant"
> > implementation for about 20years, although I am just now trying to
> > use it by the
> > FreeBSD client. I was wondering if I would find any other server
> > implementation at
> > the Bakeathon in a couple of weeks.)
>
> I see. So how do you plan to deal with the case where the server denies
> the request for a delegation? Will your client just toss away the dirty
> data?
Lets assume the client had a write delegation and dirty data for the file
in a non-volatile cache in the client before it crashed/rebooted.

The more I think about it, the more I think you are correct, at least
by default.
Why?
Because when a client crashes/reboots and there is dirty data in the
RAM cache it gets
tossed, so tossing dirty data in the non-volatile cache when it cannot safely
write it back to the server would be consistent with what happens now.

For the case where the server is in grace, the client can use
Open/Claim_previous
and then, if the reply indicates an immediate recall of the
delegation, it can write the dirty data
back to the server before doing a Delegreturn.

For the case where the server is not in grace and the Open/Claim_delegate_prev
fails, I think there is another way that the client can safely write
the dirty data back.
- If the client keeps track of the server's value of the change
attribute for the file
  in non-volatile storage.
  - The client can try an
Open/Claim_null/Open_share_access_write/Open_share_deny_write
     followed by a Getattr of change in the same compound.
     - if this succeeds and the change attribute is the same as the
stored one, then I think the client can
       safely write the dirty data back to the server using the open_stateid
       - then close the open_stateid

An option other than tossing the data would be to flag it and let a
sysadmin/user decide if
merging it back to the server's file makes sense. Ugly but doable when
the dirty data is in
client non-volatile storage.

rick

>
> --
> Trond Myklebust
> Linux NFS client maintainer, Hammerspace
> trond.myklebust@hammerspace.com
>
>