public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: Calum Mackay <calum.mackay@oracle.com>
Cc: linux-nfs@vger.kernel.org, Jeff Layton <jlayton@kernel.org>
Subject: [PATCH pynfs v2 7/7] st_deleg: test delegated timestamps in CB_GETATTR
Date: Mon, 14 Oct 2024 16:50:27 -0400	[thread overview]
Message-ID: <20241014-cb_getattr-v2-7-3782e0d7c598@kernel.org> (raw)
In-Reply-To: <20241014-cb_getattr-v2-0-3782e0d7c598@kernel.org>

First, query the server to get the SUPPORTED_ATTRS and OPEN_ARGUMENTS,
and determine whether delegated timestamps are supported. If they are,
request them, and test whether they are as expected.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 nfs4.1/server41tests/st_delegation.py | 42 +++++++++++++++++++++++++++++------
 1 file changed, 35 insertions(+), 7 deletions(-)

diff --git a/nfs4.1/server41tests/st_delegation.py b/nfs4.1/server41tests/st_delegation.py
index 2aa73ba7acd0bd857a4fd5206b8857f980176d73..fc374e693cb4b9a9adaaf5ff15a64a02573113b0 100644
--- a/nfs4.1/server41tests/st_delegation.py
+++ b/nfs4.1/server41tests/st_delegation.py
@@ -301,22 +301,44 @@ def _testCbGetattr(t, env, change=0, size=0):
     sess1 = env.c1.new_client_session(b"%s_1" % env.testname(t))
     sess1.client.cb_post_hook(OP_CB_GETATTR, getattr_post_hook)
 
-    fh, deleg = __create_file_with_deleg(sess1, env.testname(t),
-                                                OPEN4_SHARE_ACCESS_READ  |
-                                                OPEN4_SHARE_ACCESS_WRITE |
-                                                OPEN4_SHARE_ACCESS_WANT_WRITE_DELEG)
+    res = sess1.compound([op.putrootfh(),
+                          op.getattr(nfs4lib.list2bitmap([FATTR4_SUPPORTED_ATTRS,
+                                                          FATTR4_OPEN_ARGUMENTS]))])
+    check(res)
+    caps = res.resarray[-1].obj_attributes
+
+    openmask = (OPEN4_SHARE_ACCESS_READ  |
+                OPEN4_SHARE_ACCESS_WRITE |
+                OPEN4_SHARE_ACCESS_WANT_WRITE_DELEG)
+
+    if caps[FATTR4_SUPPORTED_ATTRS] & FATTR4_OPEN_ARGUMENTS:
+        if caps[FATTR4_OPEN_ARGUMENTS].oa_share_access_want & OPEN_ARGS_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS:
+            openmask |= 1<<OPEN_ARGS_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS
+
+    fh, deleg = __create_file_with_deleg(sess1, env.testname(t), openmask)
     print("__create_file_with_deleg: ", fh, deleg)
-    attrs1 = do_getattrdict(sess1, fh, [FATTR4_CHANGE, FATTR4_SIZE])
-    cbattrs = dict(attrs1)
+    attrs1 = do_getattrdict(sess1, fh, [FATTR4_CHANGE, FATTR4_SIZE,
+                                        FATTR4_TIME_ACCESS, FATTR4_TIME_MODIFY])
+
+    cbattrs[FATTR4_CHANGE] = attrs1[FATTR4_CHANGE]
+    cbattrs[FATTR4_SIZE] = attrs1[FATTR4_SIZE]
 
     if change != 0:
         cbattrs[FATTR4_CHANGE] += 1
         if size > 0:
             cbattrs[FATTR4_SIZE] = size
 
+    if openmask & 1<<OPEN_ARGS_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS:
+        cbattrs[FATTR4_TIME_DELEG_ACCESS] = attrs1[FATTR4_TIME_ACCESS]
+        cbattrs[FATTR4_TIME_DELEG_MODIFY] = attrs1[FATTR4_TIME_MODIFY]
+        if change != 0:
+            cbattrs[FATTR4_TIME_DELEG_ACCESS].seconds += 1
+            cbattrs[FATTR4_TIME_DELEG_MODIFY].seconds += 1
+
     # create a new client session and do a GETATTR
     sess2 = env.c1.new_client_session(b"%s_2" % env.testname(t))
-    slot = sess2.compound_async([op.putfh(fh), op.getattr(1<<FATTR4_CHANGE | 1<<FATTR4_SIZE)])
+    slot = sess2.compound_async([op.putfh(fh), op.getattr(1<<FATTR4_CHANGE | 1<<FATTR4_SIZE |
+                                                          1<<FATTR4_TIME_ACCESS | 1<<FATTR4_TIME_MODIFY)])
 
     # wait for the CB_GETATTR
     completed = cb.wait(2)
@@ -343,6 +365,9 @@ def testCbGetattrNoChange(t, env):
         fail("Bad size: %u != %u" % (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])
 
 def testCbGetattrWithChange(t, env):
     """Test CB_GETATTR with simulated changes to file
@@ -359,3 +384,6 @@ def testCbGetattrWithChange(t, env):
         fail("Bad size: %u != 5" % 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])

-- 
2.47.0


  parent reply	other threads:[~2024-10-14 20:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-14 20:50 [PATCH pynfs v2 0/7] pynfs: add CB_GETATTR tests and tests for delegated timestamps Jeff Layton
2024-10-14 20:50 ` [PATCH pynfs v2 1/7] WRT18: have it also check the ctime between writes Jeff Layton
2024-10-14 20:50 ` [PATCH pynfs v2 2/7] DELEG2: fix write delegation test to open the file RW Jeff Layton
2024-10-14 20:50 ` [PATCH pynfs v2 3/7] pynfs: update maintainer info Jeff Layton
2024-10-14 20:50 ` [PATCH pynfs v2 4/7] nfs4.1: add two CB_GETATTR tests Jeff Layton
2024-10-14 20:50 ` [PATCH pynfs v2 5/7] nfs4.1: default to minorversion 2 Jeff Layton
2024-10-15 13:43   ` Chuck Lever III
2024-10-15 14:23     ` Jeff Layton
2024-10-15 19:20       ` Chuck Lever III
2024-10-14 20:50 ` [PATCH pynfs v2 6/7] nfs4.1: add support for the "delstid" draft Jeff Layton
2024-10-14 20:50 ` Jeff Layton [this message]
2024-10-14 21:24 ` [PATCH pynfs v2 0/7] pynfs: add CB_GETATTR tests and tests for delegated timestamps Calum Mackay
2024-10-22 21:56 ` 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=20241014-cb_getattr-v2-7-3782e0d7c598@kernel.org \
    --to=jlayton@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