Skip to contentSkip to conversation

pynfs: retry the conflicting GETATTR after CB_GETATTR on NFS4ERR_DELAY

PATCH In review Evan Champion 2 participants 3 messages Dec 5 – Dec 6

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pynfs: retry the conflicting GETATTR after CB_GETATTR on NFS4ERR_DELAY

A server may answer the second client's GETATTR in _testCbGetattr (DELEG24 and DELEG25) and in DELEG27 with NFS4ERR_DELAY while it waits for the CB_GETATTR reply from the delegation holder. RFC 8881 Section 15.2 lists NFS4ERR_DELAY as a valid error for GETATTR, and Section 15.1.1.3 says the client should wait and then send the request again. These tests currently fail in this case even though the server is behaving correctly.

NFS-Ganesha works this way. When a GETATTR conflicts with another client's write delegation, handle_deleg_getattr() in src/SAL/state_deleg.c sends a CB_GETATTR and returns NFS4ERR_DELAY. It returns NFS4_OK only after the CB_GETATTR reply has arrived. The code in release V15.13 is at

https://github.com/nfs-ganesha/nfs-ganesha/blob/V15.13/src/SAL/state_deleg.c#L1100-L1167

After the CB_GETATTR has been received, send the GETATTR again, as a client would. SESSION.compound() already retries on NFS4ERR_DELAY, so the test does not need its own loop. If no CB_GETATTR arrives, for example because the server recalls the delegation instead, the test fails with "CB_GETATTR not received" without retrying.

---
 nfs4.1/server41tests/st_delegation.py | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)
nfs4.1/server41tests/st_delegation.py +19 -7
index bfe3f6f..86d3cd2 100644
@@ -384,12 +384,18 @@ def _testCbGetattr(t, env, change=0, size=0):
 
     # create a new client session and do a GETATTR
     sess2 = env.c1.new_client_session(b"%s_2" % env.testname(t))
-    slot = sess2.compound_async([op.putfh(fh), op.getattr(1<<FATTR4_CHANGE | 1<<FATTR4_SIZE |
-                                                          1<<FATTR4_TIME_ACCESS | 1<<FATTR4_TIME_MODIFY)])
+    ops = [op.putfh(fh), op.getattr(1<<FATTR4_CHANGE | 1<<FATTR4_SIZE |
+                                    1<<FATTR4_TIME_ACCESS | 1<<FATTR4_TIME_MODIFY)]
+    slot = sess2.compound_async(ops)
 
     # wait for the CB_GETATTR
     completed = cb.wait(2)
     res = sess2.listen(slot)
+    # The server may answer NFS4ERR_DELAY while it waits for the
+    # CB_GETATTR reply. If the callback has arrived, send the GETATTR
+    # again. compound() retries by itself if it gets NFS4ERR_DELAY again.
+    if completed and res.status == NFS4ERR_DELAY:
+        res = sess2.compound(ops)
     res2 = sess1.compound([op.putfh(fh), op.delegreturn(deleg.write.stateid)])
     check(res2)
     if not completed:
@@ -586,17 +592,23 @@ def testCbGetattrAfterSyncWrite(t, env):
     cbattrs[FATTR4_SIZE] = size
 
     sess2 = env.c1.new_client_session(b"%s_2" % env.testname(t))
-    slot = sess2.compound_async([op.putfh(fh),
-                                 op.getattr(1<<FATTR4_CHANGE |
-                                            1<<FATTR4_SIZE |
-                                            1<<FATTR4_TIME_ACCESS |
-                                            1<<FATTR4_TIME_MODIFY)])
+    ops = [op.putfh(fh),
+           op.getattr(1<<FATTR4_CHANGE |
+                      1<<FATTR4_SIZE |
+                      1<<FATTR4_TIME_ACCESS |
+                      1<<FATTR4_TIME_MODIFY)]
+    slot = sess2.compound_async(ops)
 
     completed = cb.wait(2)
     if not completed:
         fail("CB_GETATTR not received")
 
     res = sess2.listen(slot)
+    # The server may answer NFS4ERR_DELAY while it waits for the
+    # CB_GETATTR reply. Send the GETATTR again. compound() retries by
+    # itself if it gets NFS4ERR_DELAY again.
+    if res.status == NFS4ERR_DELAY:
+        res = sess2.compound(ops)
     check(res)
     attrs3 = res.resarray[-1].obj_attributes
 

base-commit: c512a976d2e3962141f7990845d921ff4f8a03f4

Signature · 1 line
2.54.0 (Apple Git-157)
maintainer
#1 lore raw
Quoted 68 lines · Evan Champion

A server may answer the second client's GETATTR in _testCbGetattr (DELEG24 and DELEG25) and in DELEG27 with NFS4ERR_DELAY while it waits for the CB_GETATTR reply from the delegation holder. RFC 8881 Section 15.2 lists NFS4ERR_DELAY as a valid error for GETATTR, and Section 15.1.1.3 says the client should wait and then send the request again. These tests currently fail in this case even though the server is behaving correctly.

NFS-Ganesha works this way. When a GETATTR conflicts with another client's write delegation, handle_deleg_getattr() in src/SAL/state_deleg.c sends a CB_GETATTR and returns NFS4ERR_DELAY. It returns NFS4_OK only after the CB_GETATTR reply has arrived. The code in release V15.13 is at

https://github.com/nfs-ganesha/nfs-ganesha/blob/V15.13/src/SAL/state_deleg.c#L1100-L1167

After the CB_GETATTR has been received, send the GETATTR again, as a client would. SESSION.compound() already retries on NFS4ERR_DELAY, so the test does not need its own loop. If no CB_GETATTR arrives, for example because the server recalls the delegation instead, the test fails with "CB_GETATTR not received" without retrying.

---
 nfs4.1/server41tests/st_delegation.py | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)
nfs4.1/server41tests/st_delegation.py +14 -7
index bfe3f6f..86d3cd2 100644
@@ -384,12 +384,18 @@ def _testCbGetattr(t, env, change=0, size=0):
 
     # create a new client session and do a GETATTR
     sess2 = env.c1.new_client_session(b"%s_2" % env.testname(t))
-    slot = sess2.compound_async([op.putfh(fh), op.getattr(1<<FATTR4_CHANGE | 1<<FATTR4_SIZE |
-                                                          1<<FATTR4_TIME_ACCESS | 1<<FATTR4_TIME_MODIFY)])
+    ops = [op.putfh(fh), op.getattr(1<<FATTR4_CHANGE | 1<<FATTR4_SIZE |
+                                    1<<FATTR4_TIME_ACCESS | 1<<FATTR4_TIME_MODIFY)]
+    slot = sess2.compound_async(ops)
 
     # wait for the CB_GETATTR
     completed = cb.wait(2)
     res = sess2.listen(slot)
+    # The server may answer NFS4ERR_DELAY while it waits for the
+    # CB_GETATTR reply. If the callback has arrived, send the GETATTR
+    # again. compound() retries by itself if it gets NFS4ERR_DELAY again.
+    if completed and res.status == NFS4ERR_DELAY:
+        res = sess2.compound(ops)
     res2 = sess1.compound([op.putfh(fh), op.delegreturn(deleg.write.stateid)])
     check(res2)
     if not completed:
@@ -586,17 +592,23 @@ def testCbGetattrAfterSyncWrite(t, env):
     cbattrs[FATTR4_SIZE] = size
 
     sess2 = env.c1.new_client_session(b"%s_2" % env.testname(t))
-    slot = sess2.compound_async([op.putfh(fh),
-                                 op.getattr(1<<FATTR4_CHANGE |
-                                            1<<FATTR4_SIZE |
-                                            1<<FATTR4_TIME_ACCESS |
-                                            1<<FATTR4_TIME_MODIFY)])
+    ops = [op.putfh(fh),
+           op.getattr(1<<FATTR4_CHANGE |
+                      1<<FATTR4_SIZE |
+                      1<<FATTR4_TIME_ACCESS |
+                      1<<FATTR4_TIME_MODIFY)]
+    slot = sess2.compound_async(ops)
 

nfs4.1/server41tests/st_delegation.py def testCbGetattrAfterSyncWrite(t, env): · line 611

Quoted 10 lines
nfs4.1/server41tests/st_delegation.py +5 -0
     completed = cb.wait(2)
     if not completed:
         fail("CB_GETATTR not received")
 
     res = sess2.listen(slot)
+    # The server may answer NFS4ERR_DELAY while it waits for the
+    # CB_GETATTR reply. Send the GETATTR again. compound() retries by
+    # itself if it gets NFS4ERR_DELAY again.
+    if res.status == NFS4ERR_DELAY:
+        res = sess2.compound(ops)

Should this if and the one above be a bounded loop? There is no guarantee that the server won't return NFS4ERR_DELAY more than once.

Quoted 5 lines
nfs4.1/server41tests/st_delegation.py +0 -0
     check(res)
     attrs3 = res.resarray[-1].obj_attributes
 

base-commit: c512a976d2e3962141f7990845d921ff4f8a03f4

Signature · 1 line
Jeff Layton <[email protected]>
#2 lore raw

Hi Jeff,

There are no unbounded loops. compound() retries up to max_retries times (default 10) with delay_time (default 1s) between tries; see nfs4.1/nfs4client.py:562. compound_async() has no retry logic.

Best wishes,

Evan

Quoted 93 lines · Jeff Layton
Quoted 68 lines · Evan Champion

A server may answer the second client's GETATTR in _testCbGetattr (DELEG24 and DELEG25) and in DELEG27 with NFS4ERR_DELAY while it waits for the CB_GETATTR reply from the delegation holder. RFC 8881 Section 15.2 lists NFS4ERR_DELAY as a valid error for GETATTR, and Section 15.1.1.3 says the client should wait and then send the request again. These tests currently fail in this case even though the server is behaving correctly.

NFS-Ganesha works this way. When a GETATTR conflicts with another client's write delegation, handle_deleg_getattr() in src/SAL/state_deleg.c sends a CB_GETATTR and returns NFS4ERR_DELAY. It returns NFS4_OK only after the CB_GETATTR reply has arrived. The code in release V15.13 is at

https://github.com/nfs-ganesha/nfs-ganesha/blob/V15.13/src/SAL/state_deleg.c#L1100-L1167

After the CB_GETATTR has been received, send the GETATTR again, as a client would. SESSION.compound() already retries on NFS4ERR_DELAY, so the test does not need its own loop. If no CB_GETATTR arrives, for example because the server recalls the delegation instead, the test fails with "CB_GETATTR not received" without retrying.

---
nfs4.1/server41tests/st_delegation.py | 26 +++++++++++++++++++-------

1 file changed, 19 insertions(+), 7 deletions(-)
nfs4.1/server41tests/st_delegation.py +14 -7
index bfe3f6f..86d3cd2 100644
@@ -384,12 +384,18 @@ def _testCbGetattr(t, env, change=0, size=0):
 
    # create a new client session and do a GETATTR
    sess2 = env.c1.new_client_session(b"%s_2" % env.testname(t))
-    slot = sess2.compound_async([op.putfh(fh), op.getattr(1<<FATTR4_CHANGE | 1<<FATTR4_SIZE |
-                                                          1<<FATTR4_TIME_ACCESS | 1<<FATTR4_TIME_MODIFY)])
+    ops = [op.putfh(fh), op.getattr(1<<FATTR4_CHANGE | 1<<FATTR4_SIZE |
+                                    1<<FATTR4_TIME_ACCESS | 1<<FATTR4_TIME_MODIFY)]
+    slot = sess2.compound_async(ops)
 
    # wait for the CB_GETATTR
    completed = cb.wait(2)
    res = sess2.listen(slot)
+    # The server may answer NFS4ERR_DELAY while it waits for the
+    # CB_GETATTR reply. If the callback has arrived, send the GETATTR
+    # again. compound() retries by itself if it gets NFS4ERR_DELAY again.
+    if completed and res.status == NFS4ERR_DELAY:
+        res = sess2.compound(ops)
    res2 = sess1.compound([op.putfh(fh), op.delegreturn(deleg.write.stateid)])
    check(res2)
    if not completed:
@@ -586,17 +592,23 @@ def testCbGetattrAfterSyncWrite(t, env):
    cbattrs[FATTR4_SIZE] = size
 
    sess2 = env.c1.new_client_session(b"%s_2" % env.testname(t))
-    slot = sess2.compound_async([op.putfh(fh),
-                                 op.getattr(1<<FATTR4_CHANGE |
-                                            1<<FATTR4_SIZE |
-                                            1<<FATTR4_TIME_ACCESS |
-                                            1<<FATTR4_TIME_MODIFY)])
+    ops = [op.putfh(fh),
+           op.getattr(1<<FATTR4_CHANGE |
+                      1<<FATTR4_SIZE |
+                      1<<FATTR4_TIME_ACCESS |
+                      1<<FATTR4_TIME_MODIFY)]
+    slot = sess2.compound_async(ops)
 

nfs4.1/server41tests/st_delegation.py def testCbGetattrAfterSyncWrite(t, env): · line 611

Quoted 10 lines
nfs4.1/server41tests/st_delegation.py +5 -0
    completed = cb.wait(2)
    if not completed:
        fail("CB_GETATTR not received")
 
    res = sess2.listen(slot)
+    # The server may answer NFS4ERR_DELAY while it waits for the
+    # CB_GETATTR reply. Send the GETATTR again. compound() retries by
+    # itself if it gets NFS4ERR_DELAY again.
+    if res.status == NFS4ERR_DELAY:
+        res = sess2.compound(ops)

Should this if and the one above be a bounded loop? There is no guarantee that the server won't return NFS4ERR_DELAY more than once.

Quoted 5 lines
nfs4.1/server41tests/st_delegation.py +0 -0
    check(res)
    attrs3 = res.resarray[-1].obj_attributes
 

base-commit: c512a976d2e3962141f7990845d921ff4f8a03f4

Signature · 1 line
Jeff Layton <[email protected]>