From: Chuck Lever <cel@kernel.org>
To: Calum Mackay <calum.mackay@oracle.com>
Cc: <linux-nfs@vger.kernel.org>
Subject: [PATCH v1 1/8] pynfs: add test for OPEN(CLAIM_FH) with WANT_READ_DELEG
Date: Thu, 8 Oct 2026 11:47:22 -0400 [thread overview]
Message-ID: <20261008154729.77787-2-cel@kernel.org> (raw)
In-Reply-To: <20261008154729.77787-1-cel@kernel.org>
The delegation tests request a delegation only through CLAIM_NULL,
and OPEN7 pairs CLAIM_FH with WANT_NO_DELEG. No test covers a client
that already holds a filehandle and asks for a delegation with
OPEN(CLAIM_FH). On a server that does not implement WANT_DELEGATION,
that OPEN is the only way to ask.
Add DELEG27. It creates a file, closes it, then sends OPEN(CLAIM_FH)
with WANT_READ_DELEG and expects a read delegation. A failure reports
the delegation type and ond_why that the server returned instead.
Signed-off-by: Chuck Lever <cel@kernel.org>
---
nfs4.1/server41tests/st_delegation.py | 61 +++++++++++++++++++++++++++
1 file changed, 61 insertions(+)
diff --git a/nfs4.1/server41tests/st_delegation.py b/nfs4.1/server41tests/st_delegation.py
index 6ae89d223c7f..c35ce8f5ec3b 100644
--- a/nfs4.1/server41tests/st_delegation.py
+++ b/nfs4.1/server41tests/st_delegation.py
@@ -625,3 +625,64 @@ def testCbGetattrAfterSyncWrite(t, env):
if compareTimes(attrs2[FATTR4_TIME_MODIFY], attrs4[FATTR4_TIME_MODIFY]) != 0:
fail(f"mtime after write ({attrs2[FATTR4_TIME_MODIFY]}) != "
f"mtime from delegreturn ({attrs4[FATTR4_TIME_MODIFY]})")
+
+def _open_claim_fh(sess, fh, owner, access):
+ """OPEN by filehandle. No GETFH follows, so OPEN is the last result."""
+ open_op = op.open(0, access, OPEN4_SHARE_DENY_NONE, open_owner4(0, owner),
+ openflag4(OPEN4_NOCREATE), open_claim4(CLAIM_FH))
+ return sess.compound([op.putfh(fh), open_op])
+
+def _open_claim_fh_retry(sess, fh, owner, access):
+ """Send OPEN(CLAIM_FH) again if the first reply carries no delegation
+
+ The first OPEN after CREATE_SESSION can race the server's backchannel
+ probe.
+ """
+ res = _open_claim_fh(sess, fh, owner, access)
+ check(res)
+ if not _got_deleg(res.resarray[-1].delegation):
+ res = _open_claim_fh(sess, fh, owner, access)
+ check(res)
+ return res
+
+def _delegreturn(sess, fh, deleg):
+ """Return the delegation, if OPEN granted one"""
+ if _got_deleg(deleg):
+ res = sess.compound([op.putfh(fh), op.delegreturn(deleg.stateid)])
+ check(res)
+
+def _deleg_desc(deleg):
+ desc = "%s" % open_delegation_type4.get(deleg.delegation_type,
+ deleg.delegation_type)
+ if deleg.delegation_type == OPEN_DELEGATE_NONE_EXT:
+ desc += ", ond_why %s" % why_no_delegation4.get(deleg.ond_why,
+ deleg.ond_why)
+ return desc
+
+def testClaimFHReadDeleg(t, env):
+ """OPEN(CLAIM_FH) with WANT_READ_DELEG on a file with no open state
+
+ FLAGS: open deleg all
+ CODE: DELEG28
+ """
+ name = env.testname(t)
+ sess1 = env.c1.new_client_session(b"%s_1" % name)
+ res = create_file(sess1, name, access=OPEN4_SHARE_ACCESS_BOTH |
+ OPEN4_SHARE_ACCESS_WANT_NO_DELEG)
+ check(res)
+ fh = res.resarray[-1].object
+ res = close_file(sess1, fh, stateid=res.resarray[-2].stateid)
+ check(res)
+
+ res = _open_claim_fh_retry(sess1, fh, name, OPEN4_SHARE_ACCESS_READ |
+ OPEN4_SHARE_ACCESS_WANT_READ_DELEG)
+ stateid = res.resarray[-1].stateid
+ deleg = res.resarray[-1].delegation
+ if deleg.delegation_type != OPEN_DELEGATE_READ:
+ _delegreturn(sess1, fh, deleg)
+ fail("Expected a read delegation, got %s" % _deleg_desc(deleg))
+
+ res = sess1.compound([op.putfh(fh), op.delegreturn(deleg.read.stateid)])
+ check(res)
+ res = close_file(sess1, fh, stateid=stateid)
+ check(res)
--
2.55.0
next prev parent reply other threads:[~2026-10-08 15:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-08 15:47 [PATCH v1 0/8] Test the WANT_*_DELEG OPEN flags Chuck Lever
2026-10-08 15:47 ` Chuck Lever [this message]
2026-10-09 7:58 ` Substituting WANT_DELEGATION with OPEN(CLAIM_FH)? Re: [PATCH v1 1/8] pynfs: add test for OPEN(CLAIM_FH) with WANT_READ_DELEG Lionel Cons
2026-10-08 15:47 ` [PATCH v1 2/8] pynfs: add test for OPEN(CLAIM_FH) delegation request on an open file Chuck Lever
2026-10-08 15:47 ` [PATCH v1 3/8] pynfs: add test for a delegation request after a recall Chuck Lever
2026-10-08 15:47 ` [PATCH v1 4/8] pynfs: add tests for SETATTR by a delegation holder Chuck Lever
2026-10-08 15:47 ` [PATCH v1 5/8] pynfs: add test for WANT_OPEN_XOR_DELEGATION through CLAIM_FH Chuck Lever
2026-10-08 15:47 ` [PATCH v1 6/8] pynfs: add test for a CLAIM_FH delegation that outlives its open Chuck Lever
2026-10-08 15:47 ` [PATCH v1 7/8] pynfs: add tests for delegation upgrade and downgrade wants Chuck Lever
2026-10-08 15:47 ` [PATCH v1 8/8] pynfs: add test for OPEN with WANT_CANCEL Chuck Lever
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=20261008154729.77787-2-cel@kernel.org \
--to=cel@kernel.org \
--cc=calum.mackay@oracle.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox