Skip to contentSkip to conversation

NFSv4: handle ERR_GRACE on delegation recalls

PATCH In review Olga Kornievskaia 4 participants 14 messages Aug 11, 2025 – Sep 30, 2025

Subsystems (2)
lore
Share & tools
lore

Olga Kornievskaia

author reviewer
#0 lore raw

PATCH 1/1 NFSv4: handle ERR_GRACE on delegation recalls

RFC7530 states that clients should be prepared for the return of NFS4ERR_GRACE errors for non-reclaim lock and I/O requests.

---
 fs/nfs/nfs4proc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/nfs4proc.c +2 -2
index 341740fa293d..fa9b81300604 100644
@@ -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);
 }
 
Signature · 1 line
2.47.1
#1 lore raw

Any comments on or objections to this patch? It does lead to possible data corruption.

Quoted 30 lines · Olga Kornievskaia

RFC7530 states that clients should be prepared for the return of NFS4ERR_GRACE errors for non-reclaim lock and I/O requests.

---
 fs/nfs/nfs4proc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/nfs4proc.c +2 -3
index 341740fa293d..fa9b81300604 100644
@@ -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

maintainer
#2 lore raw
Quoted 3 lines · Olga Kornievskaia

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.

Quoted 31 lines
Quoted 29 lines · Olga Kornievskaia

RFC7530 states that clients should be prepared for the return of NFS4ERR_GRACE errors for non-reclaim lock and I/O requests.

---
 fs/nfs/nfs4proc.c | 4 ++--

 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/nfs4proc.c +2 -2
index 341740fa293d..fa9b81300604 100644
@@ -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);
 }

Quoted 4 lines
Quoted 4 lines

--
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?

Signature · 3 lines
Trond Myklebust
Linux NFS client maintainer, Hammerspace
[email protected], [email protected]
author reviewer
#3 lore raw
Quoted 48 lines · Trond Myklebust
Quoted 3 lines · Olga Kornievskaia

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.

Quoted 31 lines
Quoted 29 lines · Olga Kornievskaia

RFC7530 states that clients should be prepared for the return of NFS4ERR_GRACE errors for non-reclaim lock and I/O requests.

---
 fs/nfs/nfs4proc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/nfs4proc.c +2 -2
index 341740fa293d..fa9b81300604 100644
@@ -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);
}

Quoted 4 lines
Quoted 4 lines

--
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.

Quoted 2 lines

..or is the issue that this could happen before the client has a chance to reclaim the delegation after a reboot?

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.

Quoted 5 lines

--
Trond Myklebust
Linux NFS client maintainer, Hammerspace [email protected], [email protected]

maintainer
#4 lore raw
Quoted 57 lines · Olga Kornievskaia
Quoted 55 lines · Trond Myklebust
Quoted 4 lines · Olga Kornievskaia

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.

Quoted 35 lines
Quoted 33 lines · Olga Kornievskaia

RFC7530 states that clients should be prepared for the return of
NFS4ERR_GRACE errors for non-reclaim lock and I/O requests.

---
 fs/nfs/nfs4proc.c | 4 ++--

 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/nfs4proc.c +2 -2
index 341740fa293d..fa9b81300604 100644
@@ -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);
 }

Quoted 4 lines
Quoted 4 lines

--
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.

Quoted 4 lines
Quoted 3 lines

..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.

Quoted 7 lines

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.

Quoted 5 lines

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'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.

Signature · 3 lines
Trond Myklebust
Linux NFS client maintainer, Hammerspace
[email protected], [email protected]
author reviewer
#5 lore raw
Quoted 81 lines · Trond Myklebust
Quoted 57 lines · Olga Kornievskaia
Quoted 55 lines · Trond Myklebust
Quoted 4 lines · Olga Kornievskaia

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.

Quoted 35 lines
Quoted 33 lines · Olga Kornievskaia

RFC7530 states that clients should be prepared for the return of
NFS4ERR_GRACE errors for non-reclaim lock and I/O requests.

---
 fs/nfs/nfs4proc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/nfs4proc.c +2 -2
index 341740fa293d..fa9b81300604 100644
@@ -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);
}

Quoted 4 lines
Quoted 4 lines

--
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.

Quoted 4 lines
Quoted 3 lines

..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.

Quoted 7 lines

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.

Quoted 5 lines

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.):

Quoted 7 lines

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?

Quoted 6 lines

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.

Quoted 5 lines

--
Trond Myklebust
Linux NFS client maintainer, Hammerspace [email protected], [email protected]

#6 lore raw
Quoted 103 lines · Olga Kornievskaia
Quoted 81 lines · Trond Myklebust
Quoted 57 lines · Olga Kornievskaia
Quoted 55 lines · Trond Myklebust
Quoted 4 lines · Olga Kornievskaia

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.

Quoted 35 lines
Quoted 33 lines · Olga Kornievskaia

RFC7530 states that clients should be prepared for the return of
NFS4ERR_GRACE errors for non-reclaim lock and I/O requests.

---
 fs/nfs/nfs4proc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/nfs4proc.c +2 -2
index 341740fa293d..fa9b81300604 100644
@@ -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);
}

Quoted 4 lines
Quoted 4 lines

--
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.

Quoted 4 lines
Quoted 3 lines

..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.

Quoted 7 lines

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.

Quoted 5 lines

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.):

Quoted 7 lines

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?

Quoted 6 lines

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.

Quoted 3 lines

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?

Quoted 7 lines
Quoted 6 lines

--
Trond Myklebust
Linux NFS client maintainer, Hammerspace [email protected], [email protected]

#7 lore raw
Quoted 104 lines · Olga Kornievskaia
Quoted 103 lines · Olga Kornievskaia
Quoted 81 lines · Trond Myklebust
Quoted 57 lines · Olga Kornievskaia
Quoted 55 lines · Trond Myklebust
Quoted 4 lines · Olga Kornievskaia

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.

Quoted 35 lines
Quoted 33 lines · Olga Kornievskaia

RFC7530 states that clients should be prepared for the return of
NFS4ERR_GRACE errors for non-reclaim lock and I/O requests.

---
 fs/nfs/nfs4proc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/nfs4proc.c +2 -2
index 341740fa293d..fa9b81300604 100644
@@ -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);
}

Quoted 4 lines
Quoted 4 lines

--
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.

Quoted 4 lines
Quoted 3 lines

..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.

Quoted 7 lines

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.

Quoted 5 lines

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.):

Quoted 7 lines

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?

Quoted 6 lines

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.

Quoted 5 lines
Quoted 3 lines

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?

Signature · 1 line
Chuck Lever
#8 lore raw
Quoted 112 lines · Chuck Lever
Quoted 104 lines · Olga Kornievskaia
Quoted 103 lines · Olga Kornievskaia
Quoted 81 lines · Trond Myklebust
Quoted 57 lines · Olga Kornievskaia
Quoted 55 lines · Trond Myklebust
Quoted 4 lines · Olga Kornievskaia

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.

Quoted 35 lines
Quoted 33 lines · Olga Kornievskaia

RFC7530 states that clients should be prepared for the return of
NFS4ERR_GRACE errors for non-reclaim lock and I/O requests.

---
 fs/nfs/nfs4proc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/nfs4proc.c +2 -2
index 341740fa293d..fa9b81300604 100644
@@ -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);
}

Quoted 4 lines
Quoted 4 lines

--
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.

Quoted 4 lines
Quoted 3 lines

..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.

Quoted 7 lines

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.

Quoted 5 lines

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.):

Quoted 7 lines

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?

Quoted 6 lines

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.

Quoted 5 lines
Quoted 3 lines

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?

Quoted 8 lines

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?

NFSD did not allow for the creation of a new lock.

NFSD got a v3 lock request which triggered a delegation recall (while in grace). nfsd v3 call (with the patch a082e4b4d08a "nfsd:
nfserr_jukebox in nlm_fopen should lead to a retry" no longer fails the request) drops the reply forcing the client to retry. Please recall that I was advocating for an additional fix where the server goes a step further and returns nlm_lck_denied_grace_period but it was not accepted. But that wouldn't have helped the current problem.

Because the delegation is triggered, the client sends a reclaim lock (but the client already sent a reclaim_complete, as it reclaimed the open and gotten a delegation) so this is a "new" lock and the server returns ERR_GRACE. Client does not handle this error and instead acts like it got the lock and thus silent corruption.

The proposed patch is to handle ERR_GRACE error while reclaiming delegation state.

Quoted 4 lines

--
Chuck Lever

#9 lore raw
Quoted 133 lines · Olga Kornievskaia
Quoted 112 lines · Chuck Lever
Quoted 104 lines · Olga Kornievskaia
Quoted 103 lines · Olga Kornievskaia
Quoted 81 lines · Trond Myklebust
Quoted 57 lines · Olga Kornievskaia
Quoted 55 lines · Trond Myklebust
Quoted 4 lines · Olga Kornievskaia

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.

Quoted 35 lines
Quoted 33 lines · Olga Kornievskaia

RFC7530 states that clients should be prepared for the return of
NFS4ERR_GRACE errors for non-reclaim lock and I/O requests.

---
 fs/nfs/nfs4proc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/nfs4proc.c +2 -2
index 341740fa293d..fa9b81300604 100644
@@ -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);
}

Quoted 4 lines
Quoted 4 lines

--
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.

Quoted 4 lines
Quoted 3 lines

..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.

Quoted 7 lines

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.

Quoted 5 lines

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.):

Quoted 7 lines

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?

Quoted 6 lines

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.

Quoted 5 lines
Quoted 3 lines

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?

Quoted 8 lines

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?

NFSD did not allow for the creation of a new lock.

NFSD got a v3 lock request which triggered a delegation recall (while in grace). nfsd v3 call (with the patch a082e4b4d08a "nfsd:
nfserr_jukebox in nlm_fopen should lead to a retry" no longer fails the request) drops the reply forcing the client to retry. Please recall that I was advocating for an additional fix where the server goes a step further and returns nlm_lck_denied_grace_period but it was not accepted. But that wouldn't have helped the current problem.

Quoted 9 lines

Because the delegation is triggered, the client sends a reclaim lock (but the client already sent a reclaim_complete, as it reclaimed the open and gotten a delegation) so this is a "new" lock and the server returns ERR_GRACE. Client does not handle this error and instead acts like it got the lock and thus silent corruption.

The proposed patch is to handle ERR_GRACE error while reclaiming delegation state.

To clarify there are 2 clients: v3 client (making a new lock request) and v4 client that holds a delegation (and a local lock).

Quoted 6 lines
Quoted 6 lines

--
Chuck Lever

#10 lore raw
Quoted 140 lines · Olga Kornievskaia
Quoted 139 lines · Olga Kornievskaia
Quoted 112 lines · Chuck Lever
Quoted 104 lines · Olga Kornievskaia
Quoted 103 lines · Olga Kornievskaia
Quoted 81 lines · Trond Myklebust
Quoted 57 lines · Olga Kornievskaia
Quoted 55 lines · Trond Myklebust
Quoted 4 lines · Olga Kornievskaia

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.

Quoted 35 lines
Quoted 33 lines · Olga Kornievskaia

RFC7530 states that clients should be prepared for the return of
NFS4ERR_GRACE errors for non-reclaim lock and I/O requests.

---
 fs/nfs/nfs4proc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/nfs4proc.c +2 -2
index 341740fa293d..fa9b81300604 100644
@@ -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);
}

Quoted 4 lines
Quoted 4 lines

--
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.

Quoted 4 lines
Quoted 3 lines

..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.

Quoted 7 lines

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.

Quoted 5 lines

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.):

Quoted 7 lines

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?

Quoted 6 lines

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.

Quoted 5 lines
Quoted 3 lines

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?

Quoted 8 lines

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?

NFSD did not allow for the creation of a new lock.

NFSD got a v3 lock request which triggered a delegation recall (while in grace). nfsd v3 call (with the patch a082e4b4d08a "nfsd:
nfserr_jukebox in nlm_fopen should lead to a retry" no longer fails the request) drops the reply forcing the client to retry. Please recall that I was advocating for an additional fix where the server goes a step further and returns nlm_lck_denied_grace_period but it was not accepted. But that wouldn't have helped the current problem.

Because the delegation is triggered, the client sends a reclaim lock (but the client already sent a reclaim_complete, as it reclaimed the open and gotten a delegation) so this is a "new" lock and the server returns ERR_GRACE. Client does not handle this error and instead acts like it got the lock and thus silent corruption.

Quoted 6 lines
Quoted 3 lines

The proposed patch is to handle ERR_GRACE error while reclaiming delegation state.

To clarify there are 2 clients: v3 client (making a new lock request) and v4 client that holds a delegation (and a local lock).

I'm still confused about the procession of events. Namely, whether a delegation recall was done while the server was still in grace.

Could you provide a ladder diagram showing the interactions, in steps?

Signature · 1 line
Chuck Lever
#11 lore raw
Quoted 146 lines · Chuck Lever
Quoted 144 lines · Olga Kornievskaia
Quoted 142 lines · Olga Kornievskaia
Quoted 112 lines · Chuck Lever
Quoted 104 lines · Olga Kornievskaia
Quoted 103 lines · Olga Kornievskaia
Quoted 81 lines · Trond Myklebust
Quoted 57 lines · Olga Kornievskaia
Quoted 55 lines · Trond Myklebust
Quoted 4 lines · Olga Kornievskaia

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.

Quoted 35 lines
Quoted 33 lines · Olga Kornievskaia

RFC7530 states that clients should be prepared for the return of
NFS4ERR_GRACE errors for non-reclaim lock and I/O requests.

---
 fs/nfs/nfs4proc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/nfs4proc.c +2 -2
index 341740fa293d..fa9b81300604 100644
@@ -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);
}

Quoted 4 lines
Quoted 4 lines

--
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.

Quoted 4 lines
Quoted 3 lines

..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.

Quoted 7 lines

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.

Quoted 5 lines

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.):

Quoted 7 lines

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?

Quoted 6 lines

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.

Quoted 5 lines
Quoted 3 lines

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?

Quoted 8 lines

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?

NFSD did not allow for the creation of a new lock.

NFSD got a v3 lock request which triggered a delegation recall (while in grace). nfsd v3 call (with the patch a082e4b4d08a "nfsd:
nfserr_jukebox in nlm_fopen should lead to a retry" no longer fails the request) drops the reply forcing the client to retry. Please recall that I was advocating for an additional fix where the server goes a step further and returns nlm_lck_denied_grace_period but it was not accepted. But that wouldn't have helped the current problem.

Because the delegation is triggered, the client sends a reclaim lock (but the client already sent a reclaim_complete, as it reclaimed the open and gotten a delegation) so this is a "new" lock and the server returns ERR_GRACE. Client does not handle this error and instead acts like it got the lock and thus silent corruption.

The proposed patch is to handle ERR_GRACE error while reclaiming delegation state.

Quoted 5 lines
Quoted 2 lines

To clarify there are 2 clients: v3 client (making a new lock request) and v4 client that holds a delegation (and a local lock).

I'm still confused about the procession of events. Namely, whether a delegation recall was done while the server was still in grace.

Yes. Delegation recall is done while the server is in grace.

Quoted 1 line

Could you provide a ladder diagram showing the interactions, in steps?

I'm not sure I can do a ladder diagram but let me try to lay out steps.

1. v4 client sends open (foo) and gets a delegation.
2. v4 client locally locks the file.
3. server reboots. grace starts.
4. v4 client sends reclaim open for "foo" and gets a delegation in reply.
5. v4 client sends reclaim_complete
6. v3 client sends NLM lock for "foo".
as a result of step 6 there are 2 actions happen on the server
(a) server sends cb_recall to v4 client
(b) drops NLM lock request for v3 client (so that that the v3 client retries)
7. v4 client sends (non-reclaim) lock request to the server . Server replies ERR_GRACE.
--> this is where the client doesn't retry but assumes it got the lock.
8. client sends delegreturn.

... if we let this play out. the v3 client which keeps resending NLM lock request will get the lock once the nfsd is out of grace.

Quoted 4 lines

--
Chuck Lever

#12 lore raw
Quoted 150 lines · Olga Kornievskaia
Quoted 149 lines · Chuck Lever
Quoted 146 lines · Olga Kornievskaia
Quoted 133 lines · Olga Kornievskaia
Quoted 112 lines · Chuck Lever
Quoted 104 lines · Olga Kornievskaia
Quoted 103 lines · Olga Kornievskaia
Quoted 81 lines · Trond Myklebust
Quoted 57 lines · Olga Kornievskaia
Quoted 55 lines · Trond Myklebust
Quoted 4 lines · Olga Kornievskaia

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.

Quoted 35 lines
Quoted 33 lines · Olga Kornievskaia

RFC7530 states that clients should be prepared for the return of
NFS4ERR_GRACE errors for non-reclaim lock and I/O requests.

---
 fs/nfs/nfs4proc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/nfs4proc.c +2 -2
index 341740fa293d..fa9b81300604 100644
@@ -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);
}

Quoted 4 lines
Quoted 4 lines

--
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.

Quoted 4 lines
Quoted 3 lines

..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.

Quoted 7 lines

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.

Quoted 5 lines

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.):

Quoted 7 lines

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?

Quoted 6 lines

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.

Quoted 5 lines
Quoted 3 lines

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?

Quoted 8 lines

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?

NFSD did not allow for the creation of a new lock.

NFSD got a v3 lock request which triggered a delegation recall (while in grace). nfsd v3 call (with the patch a082e4b4d08a "nfsd:
nfserr_jukebox in nlm_fopen should lead to a retry" no longer fails the request) drops the reply forcing the client to retry. Please recall that I was advocating for an additional fix where the server goes a step further and returns nlm_lck_denied_grace_period but it was not accepted. But that wouldn't have helped the current problem.

Quoted 9 lines

Because the delegation is triggered, the client sends a reclaim lock (but the client already sent a reclaim_complete, as it reclaimed the open and gotten a delegation) so this is a "new" lock and the server returns ERR_GRACE. Client does not handle this error and instead acts like it got the lock and thus silent corruption.

The proposed patch is to handle ERR_GRACE error while reclaiming delegation state.

To clarify there are 2 clients: v3 client (making a new lock request) and v4 client that holds a delegation (and a local lock).

Quoted 8 lines
Quoted 2 lines

I'm still confused about the procession of events. Namely, whether a delegation recall was done while the server was still in grace.

Yes. Delegation recall is done while the server is in grace.

Quoted 1 line

Could you provide a ladder diagram showing the interactions, in steps?

I'm not sure I can do a ladder diagram but let me try to lay out steps.

Thanks, this works.

Quoted 8 lines

1. v4 client sends open (foo) and gets a delegation.
2. v4 client locally locks the file.
3. server reboots. grace starts.
4. v4 client sends reclaim open for "foo" and gets a delegation in reply.
5. v4 client sends reclaim_complete
6. v3 client sends NLM lock for "foo".
as a result of step 6 there are 2 actions happen on the server
(a) server sends cb_recall to v4 client

It's arguable whether the server should prepare to allow the acquisition of a new lock during its grace period. It might be overall friendlier behavior if the server did not recall the delegation until grace is complete for all clients, since it's not supposed to allow new non- reclaim locks.

I guess it doesn't rise to the category of bug, though.

Quoted 5 lines

(b) drops NLM lock request for v3 client (so that that the v3 client retries)
7. v4 client sends (non-reclaim) lock request to the server . Server replies ERR_GRACE.
--> this is where the client doesn't retry but assumes it got the lock.
8. client sends delegreturn.

That seems like an overt client bug to me. The client should not return its delegation until the LOCK request has succeeded.

Quoted 2 lines

... if we let this play out. the v3 client which keeps resending NLM lock request will get the lock once the nfsd is out of grace.

Thank you for clarifying.

Signature · 1 line
Chuck Lever
#13 lore raw
In reply to Olga Kornievskaia
Quoted 105 lines · Olga Kornievskaia
Quoted 103 lines · Olga Kornievskaia
Quoted 81 lines · Trond Myklebust
Quoted 57 lines · Olga Kornievskaia
Quoted 55 lines · Trond Myklebust
Quoted 4 lines · Olga Kornievskaia

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.

Quoted 35 lines
Quoted 33 lines · Olga Kornievskaia

RFC7530 states that clients should be prepared for the return of
NFS4ERR_GRACE errors for non-reclaim lock and I/O requests.

---
 fs/nfs/nfs4proc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/nfs4proc.c +2 -2
index 341740fa293d..fa9b81300604 100644
@@ -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);
}

Quoted 4 lines
Quoted 4 lines

--
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.

Quoted 4 lines
Quoted 3 lines

..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.

Quoted 7 lines

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.

Quoted 5 lines

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.):

Quoted 7 lines

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?

Quoted 6 lines

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.

Quoted 5 lines
Quoted 3 lines

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?

Trond, you mentioned "we also need to handle all the other possible errors under a reboot scenario".

I could be wrong but I think ERR_GRACE is the only (critical) unhandled error that's left. _nfs4_do_setlk() via (nfs4_handle_setlk_error) handles (some) state errors and stale clientid errors. I think session errors are handled by the nfs41_sequence_process(). So we are left with ERR_GRACE? Isn't ERR_GRACE and ERR_DELAY the only 2 errors that get handled by nfs4_lock_expired and thus we should do the same in reboot recovery case too?

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

--
Trond Myklebust
Linux NFS client maintainer, Hammerspace [email protected], [email protected]