From: Scott Mayhew <smayhew@redhat.com>
To: calum.mackay@oracle.com
Cc: linux-nfs@vger.kernel.org, Jeff Layton <jlayton@kernel.org>
Subject: [PATCH v2 4/5] pynfs: fix erroneous test in DELEG24 and DELEG25
Date: Fri, 3 Apr 2026 20:30:49 -0400 [thread overview]
Message-ID: <20260404003050.1560149-5-smayhew@redhat.com> (raw)
In-Reply-To: <20260404003050.1560149-1-smayhew@redhat.com>
fattr4_time_deleg_modify is valid in CB_GETATTR and SETATTR. attrs2
contains the attributes from a GETATTR reply, and will never contain the
fattr4_time_deleg_modify attribute. Instead, we want to compare
fattr4_time_modify from attrs1 and attrs2.
Fixing that revealed a secondary issue. In pynfs, these attributes are
nfstime4 objects, so:
1. We need to be careful about how we initialize the timestamps in
cbattrs. Otherwise we wind up indadvertently modifying the values in
attrs1 and causing the DELEG25 test to fail.
2. We need compare the instance attributes (seconds, nseconds) rather
than the object references (environment.py already has a
compareTimes() function for this).
Finally, since I'm in there anyway I decided to convert the messages
from legacy printf-style formatting to f-strings.
Cc: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Scott Mayhew <smayhew@redhat.com>
---
nfs4.1/server41tests/st_delegation.py | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/nfs4.1/server41tests/st_delegation.py b/nfs4.1/server41tests/st_delegation.py
index 754b56c..bbf6925 100644
--- a/nfs4.1/server41tests/st_delegation.py
+++ b/nfs4.1/server41tests/st_delegation.py
@@ -2,7 +2,7 @@ from .st_create_session import create_session
from .st_open import open_claim4
from xdrdef.nfs4_const import *
-from .environment import check, fail, create_file, open_file, close_file, do_getattrdict, close_file, write_file, read_file
+from .environment import check, fail, create_file, open_file, close_file, do_getattrdict, close_file, write_file, read_file, compareTimes
from xdrdef.nfs4_type import *
import nfs_ops
op = nfs_ops.NFS4ops()
@@ -366,8 +366,10 @@ def _testCbGetattr(t, env, change=0, size=0):
cbattrs[FATTR4_SIZE] = size
if delegtype == OPEN_DELEGATE_WRITE_ATTRS_DELEG:
- cbattrs[FATTR4_TIME_DELEG_ACCESS] = attrs1[FATTR4_TIME_ACCESS]
- cbattrs[FATTR4_TIME_DELEG_MODIFY] = attrs1[FATTR4_TIME_MODIFY]
+ cbattrs[FATTR4_TIME_DELEG_ACCESS] = nfstime4(attrs1[FATTR4_TIME_ACCESS].seconds,
+ attrs1[FATTR4_TIME_ACCESS].nseconds)
+ cbattrs[FATTR4_TIME_DELEG_MODIFY] = nfstime4(attrs1[FATTR4_TIME_MODIFY].seconds,
+ attrs1[FATTR4_TIME_MODIFY].nseconds)
if change != 0:
cbattrs[FATTR4_TIME_DELEG_ACCESS].seconds += 1
cbattrs[FATTR4_TIME_DELEG_MODIFY].seconds += 1
@@ -400,12 +402,11 @@ def testCbGetattrNoChange(t, env):
"""
attrs1, attrs2 = _testCbGetattr(t, env)
if attrs1[FATTR4_SIZE] != attrs2[FATTR4_SIZE]:
- fail("Bad size: %u != %u" % (attrs1[FATTR4_SIZE], attrs2[FATTR4_SIZE]))
+ fail(f"Bad size: {attrs1[FATTR4_SIZE]} != {attrs2[FATTR4_SIZE]}")
if attrs1[FATTR4_CHANGE] != attrs2[FATTR4_CHANGE]:
- fail("Bad change attribute: %u != %u" % (attrs1[FATTR4_CHANGE], attrs2[FATTR4_CHANGE]))
- if FATTR4_TIME_DELEG_MODIFY in attrs2:
- if attrs1[FATTR4_TIME_MODIFY] != attrs2[FATTR4_TIME_DELEG_MODIFY]:
- fail("Bad modify time: ", attrs1[FATTR4_TIME_MODIFY], " != ", attrs2[FATTR4_TIME_DELEG_MODIFY])
+ fail(f"Bad change attribute: {attrs1[FATTR4_CHANGE]} != {attrs2[FATTR4_CHANGE]}")
+ if compareTimes(attrs1[FATTR4_TIME_MODIFY], attrs2[FATTR4_TIME_MODIFY]) != 0:
+ fail(f"Bad modify time: {attrs1[FATTR4_TIME_MODIFY]} != {attrs2[FATTR4_TIME_MODIFY]}")
def testCbGetattrWithChange(t, env):
"""Test CB_GETATTR with simulated changes to file
@@ -419,12 +420,11 @@ def testCbGetattrWithChange(t, env):
"""
attrs1, attrs2 = _testCbGetattr(t, env, change=1, size=5)
if attrs2[FATTR4_SIZE] != 5:
- fail("Bad size: %u != 5" % attrs2[FATTR4_SIZE])
+ fail(f"Bad size: {attrs2[FATTR4_SIZE]} != 5")
if attrs1[FATTR4_CHANGE] == attrs2[FATTR4_CHANGE]:
- fail("Bad change attribute: %u == %u" % (attrs1[FATTR4_CHANGE], attrs2[FATTR4_CHANGE]))
- if FATTR4_TIME_DELEG_MODIFY in attrs2:
- if attrs1[FATTR4_TIME_MODIFY] == attrs2[FATTR4_TIME_DELEG_MODIFY]:
- fail("Bad modify time: ", attrs1[FATTR4_TIME_MODIFY], " == ", attrs2[FATTR4_TIME_DELEG_MODIFY])
+ fail(f"Bad change attribute: {attrs1[FATTR4_CHANGE]} == {attrs2[FATTR4_CHANGE]}")
+ if compareTimes(attrs1[FATTR4_TIME_MODIFY], attrs2[FATTR4_TIME_MODIFY]) == 0:
+ fail(f"Bad modify time: {attrs1[FATTR4_TIME_MODIFY]} == {attrs2[FATTR4_TIME_MODIFY]}")
def testDelegReadAfterClose(t, env):
"""Test read with delegation stateid after close
--
2.53.0
next prev parent reply other threads:[~2026-04-04 0:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-04 0:30 [PATCH v2 0/5] pynfs: a handful of fixes and a new CB_GETATTR test Scott Mayhew
2026-04-04 0:30 ` [PATCH v2 1/5] pynfs: ensure tests clean up after themselves Scott Mayhew
2026-04-04 0:30 ` [PATCH v2 2/5] pynfs: fix the check for delegated attribute support Scott Mayhew
2026-04-04 0:30 ` [PATCH v2 3/5] pynfs: _testCbGetattr() should check the delegation that was received Scott Mayhew
2026-04-04 0:30 ` Scott Mayhew [this message]
2026-04-04 0:30 ` [PATCH v2] pynfs: add delegation test for CB_GETATTR after sync WRITE Scott Mayhew
2026-04-04 0:55 ` Scott Mayhew
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=20260404003050.1560149-5-smayhew@redhat.com \
--to=smayhew@redhat.com \
--cc=calum.mackay@oracle.com \
--cc=jlayton@kernel.org \
--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