All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: calum.mackay@oracle.com
Cc: bfields@fieldses.org, ffilzlnx@mindspring.com,
	linux-nfs@vger.kernel.org, Dai Ngo <dai.ngo@oracle.com>
Subject: [pynfs PATCH v2 1/5] nfs4.0: add a retry loop on NFS4ERR_DELAY to compound function
Date: Mon, 13 Mar 2023 07:23:57 -0400	[thread overview]
Message-ID: <20230313112401.20488-2-jlayton@kernel.org> (raw)
In-Reply-To: <20230313112401.20488-1-jlayton@kernel.org>

The latest knfsd server is "courteous" in that it will not revoke a
lease held by an expired client until there is competing access for it.
When there is competing access, it can now return NFS4ERR_DELAY until
the old client is expired. I've seen this happen when running pynfs in
a loop against a server with only 4g of memory.

The v4.0 compound handler doesn't retry automatically on NFS4ERR_DELAY
like the v4.1 version does. Add support for it using the same timeouts
as the v4.1 compound handler.

Cc: Dai Ngo <dai.ngo@oracle.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 nfs4.0/nfs4lib.py | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/nfs4.0/nfs4lib.py b/nfs4.0/nfs4lib.py
index 9b074f02b91f..eddcd862bc2f 100644
--- a/nfs4.0/nfs4lib.py
+++ b/nfs4.0/nfs4lib.py
@@ -338,12 +338,21 @@ class NFS4Client(rpc.RPCClient):
         un_p = self.nfs4unpacker
         p.reset()
         p.pack_COMPOUND4args(compoundargs)
-        res = self.call(NFSPROC4_COMPOUND, p.get_buffer())
-        un_p.reset(res)
-        res = un_p.unpack_COMPOUND4res()
-        if SHOW_TRAFFIC:
-            print(res)
-        un_p.done()
+        res = None
+
+        # NFS servers can return NFS4ERR_DELAY at any time for any reason.
+        # Just delay a second and retry the call again in that event. If
+        # it fails after 10 retries then just give up.
+        for i in range(1, 10):
+            res = self.call(NFSPROC4_COMPOUND, p.get_buffer())
+            un_p.reset(res)
+            res = un_p.unpack_COMPOUND4res()
+            if SHOW_TRAFFIC:
+                print(res)
+            un_p.done()
+            if res.status != NFS4ERR_DELAY:
+                break
+            time.sleep(1)
 
         # Do some error checking
 
-- 
2.39.2


  reply	other threads:[~2023-03-13 11:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-13 11:23 [pynfs PATCH v2 0/5] An assortment of pynfs patches Jeff Layton
2023-03-13 11:23 ` Jeff Layton [this message]
2023-03-13 11:23 ` [pynfs PATCH v2 2/5] examples: add a new example localhost_helper.sh script Jeff Layton
2023-03-13 11:23 ` [pynfs PATCH v2 3/5] nfs4.0/testserver.py: don't return an error when tests fail Jeff Layton
2023-03-13 11:24 ` [pynfs PATCH v2 4/5] testserver.py: add a new (special) "everything" flag Jeff Layton
2023-03-13 11:24 ` [pynfs PATCH v2 5/5] LOCK24: fix the lock_seqid in second lock request Jeff Layton
2023-03-13 18:51   ` Frank Filz
2023-03-13 21:23     ` Jeff Layton
2023-04-13 18:35     ` Calum Mackay
2023-04-14 14:41       ` Frank Filz
2023-04-14 17:24         ` Calum Mackay
2023-03-28 13:23   ` Petr Vorel
2023-03-13 16:39 ` [pynfs PATCH v2 0/5] An assortment of pynfs patches Calum Mackay

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230313112401.20488-2-jlayton@kernel.org \
    --to=jlayton@kernel.org \
    --cc=bfields@fieldses.org \
    --cc=calum.mackay@oracle.com \
    --cc=dai.ngo@oracle.com \
    --cc=ffilzlnx@mindspring.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.