From: Chuck Lever <chuck.lever@oracle.com>
To: Olga Kornievskaia <aglo@umich.edu>,
Olga Kornievskaia <okorniev@redhat.com>
Cc: Trond Myklebust <trondmy@kernel.org>,
anna.schumaker@oracle.com, linux-nfs@vger.kernel.org
Subject: Re: [PATCH 1/1] NFSv4: handle ERR_GRACE on delegation recalls
Date: Tue, 30 Sep 2025 10:01:47 -0400 [thread overview]
Message-ID: <f6ba4e9d-98df-46f2-b2fa-8ac832b8ce11@oracle.com> (raw)
In-Reply-To: <CAN-5tyEY17k5SZ6hj2QsgW_006c-0ywS5H5vPvadj80bC0X=7w@mail.gmail.com>
On 9/29/25 1:49 PM, Olga Kornievskaia wrote:
> On Fri, Sep 12, 2025 at 12:04 PM Olga Kornievskaia <okorniev@redhat.com> wrote:
>>
>> On Fri, Sep 12, 2025 at 11:11 AM Trond Myklebust <trondmy@kernel.org> wrote:
>>>
>>> On Fri, 2025-09-12 at 10:41 -0400, Olga Kornievskaia wrote:
>>>> On Fri, Sep 12, 2025 at 10:29 AM Trond Myklebust <trondmy@kernel.org>
>>>> wrote:
>>>>>
>>>>> On Fri, 2025-09-12 at 10:21 -0400, Olga Kornievskaia wrote:
>>>>>> Any comments on or objections to this patch? It does lead to
>>>>>> possible
>>>>>> data corruption.
>>>>>>
>>>>>
>>>>> Sorry, I think was travelling when you originally sent this patch.
>>>>>
>>>>>> On Mon, Aug 11, 2025 at 2:25 PM Olga Kornievskaia
>>>>>> <okorniev@redhat.com> wrote:
>>>>>>>
>>>>>>> RFC7530 states that clients should be prepared for the return
>>>>>>> of
>>>>>>> NFS4ERR_GRACE errors for non-reclaim lock and I/O requests.
>>>>>>>
>>>>>>> Signed-off-by: Olga Kornievskaia <okorniev@redhat.com>
>>>>>>> ---
>>>>>>> fs/nfs/nfs4proc.c | 4 ++--
>>>>>>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>>>>>>
>>>>>>> diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
>>>>>>> index 341740fa293d..fa9b81300604 100644
>>>>>>> --- a/fs/nfs/nfs4proc.c
>>>>>>> +++ b/fs/nfs/nfs4proc.c
>>>>>>> @@ -7867,10 +7867,10 @@ int nfs4_lock_delegation_recall(struct
>>>>>>> file_lock *fl, struct nfs4_state *state,
>>>>>>> return err;
>>>>>>> do {
>>>>>>> err = _nfs4_do_setlk(state, F_SETLK, fl,
>>>>>>> NFS_LOCK_NEW);
>>>>>>> - if (err != -NFS4ERR_DELAY)
>>>>>>> + if (err != -NFS4ERR_DELAY && err != -
>>>>>>> NFS4ERR_GRACE)
>>>>>>> break;
>>>>>>> ssleep(1);
>>>>>>> - } while (err == -NFS4ERR_DELAY);
>>>>>>> + } while (err == -NFS4ERR_DELAY || err == -
>>>>>>> NFSERR_GRACE);
>>>>>>> return nfs4_handle_delegation_recall_error(server,
>>>>>>> state,
>>>>>>> stateid, fl, err);
>>>>>>> }
>>>>>>>
>>>>>>> --
>>>>>>> 2.47.1
>>>>>>>
>>>>>>>
>>>>>
>>>>> Should the server be sending NFS4ERR_GRACE in this case, though?
>>>>> The
>>>>> client already holds a delegation, so it is clear that other
>>>>> clients
>>>>> cannot reclaim any locks that would conflict.
>>>>>
>>>>> ..or is the issue that this could happen before the client has a
>>>>> chance
>>>>> to reclaim the delegation after a reboot?
>>>>
>>> To answer my own question here: in that case the server would return
>>> NFS4ERR_BAD_STATEID, and not NFS4ERR_GRACE.
>>>
>>>> The scenario was, v4 client had an open file and a lock and upon
>>>> server reboot (during grace) sends the reclaim open, to which the
>>>> server replies with a delegation. How a v3 client comes in and
>>>> requests the same lock. The linux server at this point sends a
>>>> delegation recall to v4 client, the client sends its local lock
>>>> request and gets ERR_GRACE.
>>>>
>>>> And the spec explicitly notes as I mention in the commit comment that
>>>> the client is supposed to handle ERR_GRACE for non-reclaim locks.
>>>> Thus
>>>> this patch.
>>>>
>>>
>>> Sure, however the same spec also says (Section 9.6.2.):
>>>
>>> If the server can reliably determine that granting a non-reclaim
>>> request will not conflict with reclamation of locks by other clients,
>>> the NFS4ERR_GRACE error does not have to be returned and the
>>> non-reclaim client request can be serviced.
>>>
>>> The server can definitely reliably determine that is the case here,
>>> since it already granted the delegation to the client.
>>
>> I'll take your word for it as I'm not that versed in the server code.
>> But it's an optimization and hard to argue that a server must do it
>> and thus the client really should handle the case that actually
>> happens in practice now?
>>
>>> I'm not saying that the client shouldn't also handle NFS4ERR_GRACE, but
>>> I am stating that the server shouldn't really be putting us in this
>>> situation in the first place.
>>> I'm also saying that if we're going to handle NFS4ERR_GRACE, then we
>>> also need to handle all the other possible errors under a reboot
>>> scenario.
>>
>> I don't see how the "if" and "then" are combined. I think if there are
>> other errors we don't handle in reclaim then we should but I don't see
>> it's conditional on handling ERR_GRACE error.
>
> What's the path forward here?
I saw something earlier in the thread that caught my eye.
It looked like you said that, while NFSD is in grace, it allowed a
client to acquire an NLM lock and that triggered the delegation recall.
It seems to me that, because it was in grace, NFSD should not have
allowed the creation of a new lock; it should have returned nlm_grace.
Did I read that incorrectly?
--
Chuck Lever
next prev parent reply other threads:[~2025-09-30 14:02 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-11 18:18 [PATCH 1/1] NFSv4: handle ERR_GRACE on delegation recalls Olga Kornievskaia
2025-09-12 14:21 ` Olga Kornievskaia
2025-09-12 14:29 ` Trond Myklebust
2025-09-12 14:41 ` Olga Kornievskaia
2025-09-12 15:11 ` Trond Myklebust
2025-09-12 16:04 ` Olga Kornievskaia
2025-09-29 17:49 ` Olga Kornievskaia
2025-09-30 14:01 ` Chuck Lever [this message]
2025-09-30 14:29 ` Olga Kornievskaia
2025-09-30 14:32 ` Olga Kornievskaia
2025-09-30 14:37 ` Chuck Lever
2025-09-30 14:56 ` Olga Kornievskaia
2025-09-30 15:19 ` Chuck Lever
2025-09-30 17:00 ` Olga Kornievskaia
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f6ba4e9d-98df-46f2-b2fa-8ac832b8ce11@oracle.com \
--to=chuck.lever@oracle.com \
--cc=aglo@umich.edu \
--cc=anna.schumaker@oracle.com \
--cc=linux-nfs@vger.kernel.org \
--cc=okorniev@redhat.com \
--cc=trondmy@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.