diff mbox series

[RFC,v2] nfs4.0 enhance open_confirm to work with courteous server.

Message ID 20211211025245.53863-1-dai.ngo@oracle.com (mailing list archive)
State New, archived
Headers show
Series [RFC,v2] nfs4.0 enhance open_confirm to work with courteous server. | expand

Commit Message

Dai Ngo Dec. 11, 2021, 2:52 a.m. UTC
Linux NFSv4 courteous server resolves share reservation conflicts
with courtesy clients asynchronously and returning NFS4ERR_DELAY
to the client.

v2:
stop test after timed out on NFS4ERR_DELAY

Signed-off-by: Dai Ngo <dai.ngo@oracle.com>
---
 nfs4.0/nfs4lib.py | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/nfs4.0/nfs4lib.py b/nfs4.0/nfs4lib.py
index 934def3b7333..1feb103e20d9 100644
--- a/nfs4.0/nfs4lib.py
+++ b/nfs4.0/nfs4lib.py
@@ -723,8 +723,19 @@  class NFS4Client(rpc.RPCClient):
     def open_confirm(self, owner, path=None,
                      access=OPEN4_SHARE_ACCESS_READ,
                      deny=OPEN4_SHARE_DENY_WRITE):
-        res = self.open_file(owner, path, access, deny)
-        check_result(res, "Opening file %s" % _getname(owner, path))
+        while 1:
+            res = self.open_file(owner, path, access, deny)
+            cnt = 0
+            try:
+                 check_result(res, "Opening file %s" % _getname(owner, path))
+                 break
+            except BadCompoundRes:
+                if res.status != NFS4ERR_DELAY: raise
+                cnt += 1
+                if cnt <= 5:
+                    time.sleep(2)
+                else:
+                    raise UnexpectedCompoundRes("OPEN timed out on NFS4ERR_DELAY")
         return self.confirm(owner, res)
 
 ##     def xxxopen_claim_prev(self, owner, fh, seqid=None,