diff mbox series

[v3] NFSv4: Fix dropped lock for racing OPEN and delegation return

Message ID 93929ecf62e79670f1e3a1878757fc9fa443aa7c.1688210094.git.bcodding@redhat.com (mailing list archive)
State New, archived
Headers show
Series [v3] NFSv4: Fix dropped lock for racing OPEN and delegation return | expand

Commit Message

Benjamin Coddington July 1, 2023, 11:15 a.m. UTC
Commmit f5ea16137a3f ("NFSv4: Retry LOCK on OLD_STATEID during delegation
return") attempted to solve this problem by using nfs4's generic async error
handling, but introduced a regression where v4.0 lock recovery would hang.
The additional complexity introduced by overloading that error handling is
not necessary for this case.  This patch expects that commit to be
reverted.

The problem as originally explained in the above commit is:

    There's a small window where a LOCK sent during a delegation return can
    race with another OPEN on client, but the open stateid has not yet been
    updated.  In this case, the client doesn't handle the OLD_STATEID error
    from the server and will lose this lock, emitting:
    "NFS: nfs4_handle_delegation_recall_error: unhandled error -10024".

Fix this by using the old_stateid refresh helpers if the server replies
with OLD_STATEID.

Suggested-by: Trond Myklebust <trondmy@hammerspace.com>
Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
---
 fs/nfs/nfs4proc.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Olga Kornievskaia Oct. 4, 2023, 6:53 p.m. UTC | #1
Hi Trond/Ben,

Did this ever go to stable? I don't know if I missed a mail from Greg
that it was picked up or it never got picked up because it wasn't
marked for stable?

Thank you.

On Sat, Jul 1, 2023 at 8:13 AM Benjamin Coddington <bcodding@redhat.com> wrote:
>
> Commmit f5ea16137a3f ("NFSv4: Retry LOCK on OLD_STATEID during delegation
> return") attempted to solve this problem by using nfs4's generic async error
> handling, but introduced a regression where v4.0 lock recovery would hang.
> The additional complexity introduced by overloading that error handling is
> not necessary for this case.  This patch expects that commit to be
> reverted.
>
> The problem as originally explained in the above commit is:
>
>     There's a small window where a LOCK sent during a delegation return can
>     race with another OPEN on client, but the open stateid has not yet been
>     updated.  In this case, the client doesn't handle the OLD_STATEID error
>     from the server and will lose this lock, emitting:
>     "NFS: nfs4_handle_delegation_recall_error: unhandled error -10024".
>
> Fix this by using the old_stateid refresh helpers if the server replies
> with OLD_STATEID.
>
> Suggested-by: Trond Myklebust <trondmy@hammerspace.com>
> Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
> ---
>  fs/nfs/nfs4proc.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
> index 6bb14f6cfbc0..f350f41e1967 100644
> --- a/fs/nfs/nfs4proc.c
> +++ b/fs/nfs/nfs4proc.c
> @@ -7180,8 +7180,15 @@ static void nfs4_lock_done(struct rpc_task *task, void *calldata)
>                 } else if (!nfs4_update_lock_stateid(lsp, &data->res.stateid))
>                         goto out_restart;
>                 break;
> -       case -NFS4ERR_BAD_STATEID:
>         case -NFS4ERR_OLD_STATEID:
> +               if (data->arg.new_lock_owner != 0 &&
> +                       nfs4_refresh_open_old_stateid(&data->arg.open_stateid,
> +                                       lsp->ls_state))
> +                       goto out_restart;
> +               else if (nfs4_refresh_lock_old_stateid(&data->arg.lock_stateid, lsp))
> +                       goto out_restart;
> +               fallthrough;
> +       case -NFS4ERR_BAD_STATEID:
>         case -NFS4ERR_STALE_STATEID:
>         case -NFS4ERR_EXPIRED:
>                 if (data->arg.new_lock_owner != 0) {
> --
> 2.40.1
>
Olga Kornievskaia Oct. 4, 2023, 6:54 p.m. UTC | #2
Sorry, I didn't mean this patch. I meant the revert patch.

On Wed, Oct 4, 2023 at 2:53 PM Olga Kornievskaia <aglo@umich.edu> wrote:
>
> Hi Trond/Ben,
>
> Did this ever go to stable? I don't know if I missed a mail from Greg
> that it was picked up or it never got picked up because it wasn't
> marked for stable?
>
> Thank you.
>
> On Sat, Jul 1, 2023 at 8:13 AM Benjamin Coddington <bcodding@redhat.com> wrote:
> >
> > Commmit f5ea16137a3f ("NFSv4: Retry LOCK on OLD_STATEID during delegation
> > return") attempted to solve this problem by using nfs4's generic async error
> > handling, but introduced a regression where v4.0 lock recovery would hang.
> > The additional complexity introduced by overloading that error handling is
> > not necessary for this case.  This patch expects that commit to be
> > reverted.
> >
> > The problem as originally explained in the above commit is:
> >
> >     There's a small window where a LOCK sent during a delegation return can
> >     race with another OPEN on client, but the open stateid has not yet been
> >     updated.  In this case, the client doesn't handle the OLD_STATEID error
> >     from the server and will lose this lock, emitting:
> >     "NFS: nfs4_handle_delegation_recall_error: unhandled error -10024".
> >
> > Fix this by using the old_stateid refresh helpers if the server replies
> > with OLD_STATEID.
> >
> > Suggested-by: Trond Myklebust <trondmy@hammerspace.com>
> > Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
> > ---
> >  fs/nfs/nfs4proc.c | 9 ++++++++-
> >  1 file changed, 8 insertions(+), 1 deletion(-)
> >
> > diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
> > index 6bb14f6cfbc0..f350f41e1967 100644
> > --- a/fs/nfs/nfs4proc.c
> > +++ b/fs/nfs/nfs4proc.c
> > @@ -7180,8 +7180,15 @@ static void nfs4_lock_done(struct rpc_task *task, void *calldata)
> >                 } else if (!nfs4_update_lock_stateid(lsp, &data->res.stateid))
> >                         goto out_restart;
> >                 break;
> > -       case -NFS4ERR_BAD_STATEID:
> >         case -NFS4ERR_OLD_STATEID:
> > +               if (data->arg.new_lock_owner != 0 &&
> > +                       nfs4_refresh_open_old_stateid(&data->arg.open_stateid,
> > +                                       lsp->ls_state))
> > +                       goto out_restart;
> > +               else if (nfs4_refresh_lock_old_stateid(&data->arg.lock_stateid, lsp))
> > +                       goto out_restart;
> > +               fallthrough;
> > +       case -NFS4ERR_BAD_STATEID:
> >         case -NFS4ERR_STALE_STATEID:
> >         case -NFS4ERR_EXPIRED:
> >                 if (data->arg.new_lock_owner != 0) {
> > --
> > 2.40.1
> >
Anna Schumaker Oct. 5, 2023, 6:16 p.m. UTC | #3
Hi Olga,

On Wed, Oct 4, 2023 at 2:55 PM Olga Kornievskaia <aglo@umich.edu> wrote:
>
> Sorry, I didn't mean this patch. I meant the revert patch.
>
> On Wed, Oct 4, 2023 at 2:53 PM Olga Kornievskaia <aglo@umich.edu> wrote:
> >
> > Hi Trond/Ben,
> >
> > Did this ever go to stable? I don't know if I missed a mail from Greg
> > that it was picked up or it never got picked up because it wasn't
> > marked for stable?

Looks like the revert went into 6.5 as commit 5b4a82a0724a. It's not
marked for stable, so it probably wasn't picked up.

Anna

> >
> > Thank you.
> >
> > On Sat, Jul 1, 2023 at 8:13 AM Benjamin Coddington <bcodding@redhat.com> wrote:
> > >
> > > Commmit f5ea16137a3f ("NFSv4: Retry LOCK on OLD_STATEID during delegation
> > > return") attempted to solve this problem by using nfs4's generic async error
> > > handling, but introduced a regression where v4.0 lock recovery would hang.
> > > The additional complexity introduced by overloading that error handling is
> > > not necessary for this case.  This patch expects that commit to be
> > > reverted.
> > >
> > > The problem as originally explained in the above commit is:
> > >
> > >     There's a small window where a LOCK sent during a delegation return can
> > >     race with another OPEN on client, but the open stateid has not yet been
> > >     updated.  In this case, the client doesn't handle the OLD_STATEID error
> > >     from the server and will lose this lock, emitting:
> > >     "NFS: nfs4_handle_delegation_recall_error: unhandled error -10024".
> > >
> > > Fix this by using the old_stateid refresh helpers if the server replies
> > > with OLD_STATEID.
> > >
> > > Suggested-by: Trond Myklebust <trondmy@hammerspace.com>
> > > Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
> > > ---
> > >  fs/nfs/nfs4proc.c | 9 ++++++++-
> > >  1 file changed, 8 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
> > > index 6bb14f6cfbc0..f350f41e1967 100644
> > > --- a/fs/nfs/nfs4proc.c
> > > +++ b/fs/nfs/nfs4proc.c
> > > @@ -7180,8 +7180,15 @@ static void nfs4_lock_done(struct rpc_task *task, void *calldata)
> > >                 } else if (!nfs4_update_lock_stateid(lsp, &data->res.stateid))
> > >                         goto out_restart;
> > >                 break;
> > > -       case -NFS4ERR_BAD_STATEID:
> > >         case -NFS4ERR_OLD_STATEID:
> > > +               if (data->arg.new_lock_owner != 0 &&
> > > +                       nfs4_refresh_open_old_stateid(&data->arg.open_stateid,
> > > +                                       lsp->ls_state))
> > > +                       goto out_restart;
> > > +               else if (nfs4_refresh_lock_old_stateid(&data->arg.lock_stateid, lsp))
> > > +                       goto out_restart;
> > > +               fallthrough;
> > > +       case -NFS4ERR_BAD_STATEID:
> > >         case -NFS4ERR_STALE_STATEID:
> > >         case -NFS4ERR_EXPIRED:
> > >                 if (data->arg.new_lock_owner != 0) {
> > > --
> > > 2.40.1
> > >
Benjamin Coddington Oct. 9, 2023, 3:58 p.m. UTC | #4
On 5 Oct 2023, at 14:16, Anna Schumaker wrote:

> Hi Olga,
>
> On Wed, Oct 4, 2023 at 2:55 PM Olga Kornievskaia <aglo@umich.edu> wrote:
>>
>> Sorry, I didn't mean this patch. I meant the revert patch.
>>
>> On Wed, Oct 4, 2023 at 2:53 PM Olga Kornievskaia <aglo@umich.edu> wrote:
>>>
>>> Hi Trond/Ben,
>>>
>>> Did this ever go to stable? I don't know if I missed a mail from Greg
>>> that it was picked up or it never got picked up because it wasn't
>>> marked for stable?
>
> Looks like the revert went into 6.5 as commit 5b4a82a0724a. It's not
> marked for stable, so it probably wasn't picked up.

Gah, thanks for taking this on and fixing it.

Ben
diff mbox series

Patch

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 6bb14f6cfbc0..f350f41e1967 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -7180,8 +7180,15 @@  static void nfs4_lock_done(struct rpc_task *task, void *calldata)
 		} else if (!nfs4_update_lock_stateid(lsp, &data->res.stateid))
 			goto out_restart;
 		break;
-	case -NFS4ERR_BAD_STATEID:
 	case -NFS4ERR_OLD_STATEID:
+		if (data->arg.new_lock_owner != 0 &&
+			nfs4_refresh_open_old_stateid(&data->arg.open_stateid,
+					lsp->ls_state))
+			goto out_restart;
+		else if (nfs4_refresh_lock_old_stateid(&data->arg.lock_stateid, lsp))
+			goto out_restart;
+		fallthrough;
+	case -NFS4ERR_BAD_STATEID:
 	case -NFS4ERR_STALE_STATEID:
 	case -NFS4ERR_EXPIRED:
 		if (data->arg.new_lock_owner != 0) {