Skip to contentSkip to conversation

nfs4lib.py: enhance open_file to work with courteous server

PATCH In review Dai Ngo 2 participants 6 messages Jun 15, 2022 – Jul 11, 2022

Subsystems (2)
lore
Share & tools
lore

Dai Ngo

author reviewer
#0 lore raw

PATCH 1/2 nfs4lib.py: enhance open_file to work with courteous server

Enhance open_file to handle NFS4ERR_DELAY returned by the server in case of share/access/delegation conflict.

---
 nfs4.0/nfs4lib.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
nfs4.0/nfs4lib.py +6 -1
index 934def3b7333..e0299e8d6676 100644
@@ -677,7 +677,12 @@ class NFS4Client(rpc.RPCClient):
                           claim_type=claim_type, deleg_type=deleg_type,
                           deleg_cur_info=deleg_cur_info)]
         ops += [op4.getfh()]
-        res = self.compound(ops)
+        while 1:
+            res = self.compound(ops)
+            if res.status == NFS4ERR_DELAY:
+                time.sleep(2)
+            else:
+                break
         self.advance_seqid(owner, res)
         if set_recall and (res.status != NFS4_OK or \
            res.resarray[-2].switch.switch.delegation == OPEN_DELEGATE_NONE):
Signature · 1 line
2.27.0
author reviewer
#1 lore raw

PATCH 2/2 environment.py: enhance open_create_file to work with courteous server

Enhance open_create_file to handle NFS4ERR_DELAY returned by the server in case of share/access/delegation conflict.

---
 nfs4.1/server41tests/environment.py | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
nfs4.1/server41tests/environment.py +10 -5
index 0b7c976d8582..fb834b28841b 100644
@@ -483,11 +483,16 @@ def open_create_file(sess, owner, path=None, attrs={FATTR4_MODE: 0o644},
                      deleg_type=None,
                      open_create=OPEN4_NOCREATE,
                      seqid=0, clientid=0):
-    open_op = open_create_file_op(sess, owner, path, attrs, access, deny, mode,
-                            verifier, claim_type, want_deleg, deleg_type,
-                            open_create, seqid, clientid)
-
-    return sess.compound(open_op)
+    while 1:
+        open_op = open_create_file_op(sess, owner, path, attrs, access, deny, mode,
+                       verifier, claim_type, want_deleg, deleg_type,
+                       open_create, seqid, clientid)
+        res = sess.compound(open_op)
+        if res.status == NFS4ERR_DELAY:
+            time.sleep(2)
+        else:
+            break
+    return res
 
 def open_create_file_op(sess, owner, path=None, attrs={FATTR4_MODE: 0o644},
                      access=OPEN4_SHARE_ACCESS_BOTH,
Signature · 1 line
2.27.0
#2 lore raw
In reply to Dai Ngo

THere are tests that want to explicitly test for DELAY returns. (Grep for ERR_DELAY. Look at the delegation tests especially.) Does this work for them? I assumed we'd want an optional parameter that allowed to caller to circument the DELAY handling.

--b.

Quoted 28 lines · Dai Ngo

Enhance open_file to handle NFS4ERR_DELAY returned by the server in case of share/access/delegation conflict.

---
 nfs4.0/nfs4lib.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
nfs4.0/nfs4lib.py +6 -1
index 934def3b7333..e0299e8d6676 100644
@@ -677,7 +677,12 @@ class NFS4Client(rpc.RPCClient):
                           claim_type=claim_type, deleg_type=deleg_type,
                           deleg_cur_info=deleg_cur_info)]
         ops += [op4.getfh()]
-        res = self.compound(ops)
+        while 1:
+            res = self.compound(ops)
+            if res.status == NFS4ERR_DELAY:
+                time.sleep(2)
+            else:
+                break
         self.advance_seqid(owner, res)
         if set_recall and (res.status != NFS4_OK or \
            res.resarray[-2].switch.switch.delegation == OPEN_DELEGATE_NONE):
Signature · 1 line
2.27.0
author reviewer
#3 lore raw
Quoted 3 lines · J. Bruce Fields

THere are tests that want to explicitly test for DELAY returns. (Grep for ERR_DELAY. Look at the delegation tests especially.) Does this work for them?

Those tests expect NFS4_OK but also handle NFS4ERR_DELAY themselves if the OPEN causes recall. With this patch, the NFS4ERR_DELAY is handled internally by open_file so the ERR_DELAY never get to those tests. All tests passed with this patch.

-Dai

Quoted 34 lines

I assumed we'd want an optional parameter that allowed
to caller to circument the DELAY handling.

--b.

Quoted 28 lines · Dai Ngo

Enhance open_file to handle NFS4ERR_DELAY returned by the server in case of share/access/delegation conflict.

---
  nfs4.0/nfs4lib.py | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
nfs4.0/nfs4lib.py +6 -1
index 934def3b7333..e0299e8d6676 100644
@@ -677,7 +677,12 @@ class NFS4Client(rpc.RPCClient):
                            claim_type=claim_type, deleg_type=deleg_type,
                            deleg_cur_info=deleg_cur_info)]
          ops += [op4.getfh()]
-        res = self.compound(ops)
+        while 1:
+            res = self.compound(ops)
+            if res.status == NFS4ERR_DELAY:
+                time.sleep(2)
+            else:
+                break
          self.advance_seqid(owner, res)
          if set_recall and (res.status != NFS4_OK or \
             res.resarray[-2].switch.switch.delegation == OPEN_DELEGATE_NONE):
Signature · 1 line
2.27.0
#4 lore raw

Applying, thanks, sorry for the delay.--b.

Quoted 47 lines · On Wed, Jun 15, 2022 at 12:48:17PM -0700, [email protected] wrote:
Quoted 3 lines · J. Bruce Fields

THere are tests that want to explicitly test for DELAY returns. (Grep for ERR_DELAY. Look at the delegation tests especially.) Does this work for them?

Those tests expect NFS4_OK but also handle NFS4ERR_DELAY themselves if the OPEN causes recall. With this patch, the NFS4ERR_DELAY is handled internally by open_file so the ERR_DELAY never get to those tests. All tests passed with this patch.

-Dai

Quoted 34 lines

I assumed we'd want an optional parameter that allowed
to caller to circument the DELAY handling.

--b.

Quoted 28 lines · Dai Ngo

Enhance open_file to handle NFS4ERR_DELAY returned by the server in case of share/access/delegation conflict.

---
 nfs4.0/nfs4lib.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
nfs4.0/nfs4lib.py +6 -1
index 934def3b7333..e0299e8d6676 100644
@@ -677,7 +677,12 @@ class NFS4Client(rpc.RPCClient):
                           claim_type=claim_type, deleg_type=deleg_type,
                           deleg_cur_info=deleg_cur_info)]
         ops += [op4.getfh()]
-        res = self.compound(ops)
+        while 1:
+            res = self.compound(ops)
+            if res.status == NFS4ERR_DELAY:
+                time.sleep(2)
+            else:
+                break
         self.advance_seqid(owner, res)
         if set_recall and (res.status != NFS4_OK or \
            res.resarray[-2].switch.switch.delegation == OPEN_DELEGATE_NONE):
Signature · 1 line
2.27.0
author reviewer
#5 lore raw
Quoted 1 line · J. Bruce Fields

Applying, thanks, sorry for the delay.--b.

thank you Bruce!

-Dai

Quoted 47 lines · On Wed, Jun 15, 2022 at 12:48:17PM -0700, [email protected] wrote:
Quoted 45 lines · J. Bruce Fields
Quoted 3 lines

THere are tests that want to explicitly test for DELAY returns. (Grep for ERR_DELAY. Look at the delegation tests especially.) Does this work for them?

Those tests expect NFS4_OK but also handle NFS4ERR_DELAY themselves if the OPEN causes recall. With this patch, the NFS4ERR_DELAY is handled internally by open_file so the ERR_DELAY never get to those tests. All tests passed with this patch.

-Dai

Quoted 34 lines

I assumed we'd want an optional parameter that allowed
to caller to circument the DELAY handling.

--b.

Quoted 28 lines · Dai Ngo

Enhance open_file to handle NFS4ERR_DELAY returned by the server in case of share/access/delegation conflict.

---
  nfs4.0/nfs4lib.py | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
nfs4.0/nfs4lib.py +6 -1
index 934def3b7333..e0299e8d6676 100644
@@ -677,7 +677,12 @@ class NFS4Client(rpc.RPCClient):
                            claim_type=claim_type, deleg_type=deleg_type,
                            deleg_cur_info=deleg_cur_info)]
          ops += [op4.getfh()]
-        res = self.compound(ops)
+        while 1:
+            res = self.compound(ops)
+            if res.status == NFS4ERR_DELAY:
+                time.sleep(2)
+            else:
+                break
          self.advance_seqid(owner, res)
          if set_recall and (res.status != NFS4_OK or \
             res.resarray[-2].switch.switch.delegation == OPEN_DELEGATE_NONE):
Signature · 1 line
2.27.0