nfs4.1: add some directory delegation testcases
Subsystems (2)
Jeff Layton
maintainerv2 cover nfs4.1: add some directory delegation testcases
This patchset adds some new testcases for directory delegations.
DIRDELEG1-7 should pass on current mainline kernels, with recall-only support. The rest require CB_NOTIFY support. If the server doesn't offer notifications, then the tests pass_warn (so there should be no failures in those cases):
https://lore.kernel.org/linux-nfs/[email protected]/
---
Changes in v2:
- Added more tests for CB_NOTIFY behavior
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Jeff Layton (25):
nfs4.1: add proposed NOTIFY4_GFLAG_EXTEND flag
nfs4.1: add a getfh() to the end of create_obj() compound
server41tests: add a basic GET_DIR_DELEGATION test
server41tests: add a test for duplicate GET_DIR_DELEGATION requests
server41tests: pass_warn() when server doesn't support dir delegations
server41tests: test remove triggers dir delegation recall
server41tests: test rename triggers dir delegation recall
server41tests: test mkdir triggers dir delegation recall
server41tests: test link triggers dir delegation recall
server41tests: test no notifications without GFLAG_EXTEND
server41tests: test unrequested notification type triggers recall
server41tests: add a test for removal from dir with dir delegation
server41tests: add a test for directory add notifications
server41tests: add test for RENAME event notifications
server41tests: verify child attributes in ADD notification
server41tests: test CHANGE_DIR_ATTRS notification
server41tests: test mkdir triggers ADD notification
server41tests: test DELEGRETURN stops notifications
server41tests: verify filehandle in ADD notification
server41tests: test cross-directory rename REMOVE notification
server41tests: test cross-directory rename ADD notification on target
server41tests: test link triggers ADD notification
server41tests: test same-client changes don't trigger notifications
server41tests: test cross-directory rename-over nad_old_entry
server41tests: test within-directory rename-over nad_old_entry
nfs4.1/nfs4client.py | 6 + nfs4.1/server41tests/__init__.py | 1 + nfs4.1/server41tests/environment.py | 2 +- nfs4.1/server41tests/st_dir_deleg.py | 1066 ++++++++++++++++++++++++++++++++++ nfs4.1/xdrdef/nfs4.x | 3 +- 5 files changed, 1076 insertions(+), 2 deletions(-)
---
base-commit: cd4701827a8261fedbfb4c6e39029fb9671321a6
change-id: 20260331-dir-deleg-a1b3475f8385
Best regards,
Signature · 1 line
Jeff Layton <[email protected]>
Jeff Layton
maintainerPATCH v2 1/25 nfs4.1: add proposed NOTIFY4_GFLAG_EXTEND flag
This flag has been proposed as part of RFC8881bis. This flag is used to negotiate extensions to the original directory delegations originally specified in RFC8881.
In practice, the Linux nfs server requires that the client support this flag if it's requesting anything other than a recall-only delegation.
--- nfs4.1/xdrdef/nfs4.x | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
nfs4.1/xdrdef/nfs4.x +2 -1
@@ -3611,7 +3611,8 @@ enum notify_type4 { NOTIFY4_REMOVE_ENTRY = 2, NOTIFY4_ADD_ENTRY = 3, NOTIFY4_RENAME_ENTRY = 4, - NOTIFY4_CHANGE_COOKIE_VERIFIER = 5 + NOTIFY4_CHANGE_COOKIE_VERIFIER = 5, + NOTIFY4_GFLAG_EXTEND = 6 /* proposed in rfc8881bis */ }; /* Changed entry information. */
Signature · 1 line
2.53.0
Jeff Layton
maintainerPATCH v2 2/25 nfs4.1: add a getfh() to the end of create_obj() compound
In reply to Jeff LaytonA later patch will use the create_obj() function to create files, but some of the tests require us to know the filehandle of the created object. Add a GETFH operation to the end of the create_obj() compound.
--- nfs4.1/server41tests/environment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
nfs4.1/server41tests/environment.py +1 -1
@@ -474,7 +474,7 @@ def create_obj(sess, path, kind=NF4DIR, attrs={FATTR4_MODE:0o755}): # Ensure using createtype4 if not hasattr(kind, "type"): kind = createtype4(kind) - ops = use_obj(path[:-1]) + [op.create(kind, path[-1], attrs)] + ops = use_obj(path[:-1]) + [op.create(kind, path[-1], attrs), op.getfh()] return sess.compound(ops) def open_create_file(sess, owner, path=None, attrs={FATTR4_MODE: 0o644},
Signature · 1 line
2.53.0
Jeff Layton
maintainerPATCH v2 3/25 server41tests: add a basic GET_DIR_DELEGATION test
In reply to Jeff LaytonTest basic dir delegation handout, recall and return
--- nfs4.1/nfs4client.py | 6 +++ nfs4.1/server41tests/__init__.py | 1 + nfs4.1/server41tests/st_dir_deleg.py | 102 +++++++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+)
nfs4.1/nfs4client.py +6 -0
@@ -283,6 +283,12 @@ class NFS4Client(rpc.Client, rpc.Server): res = self.posthook(arg, env, res=NFS4_OK) return encode_status(res) + def op_cb_notify(self, arg, env): + log_cb.info("In CB_NOTIFY") + self.prehook(arg, env) + res = self.posthook(arg, env, res=NFS4_OK) + return encode_status(res) + def op_cb_notify_lock(self, arg, env): log_cb.info("In CB_NOTIFY_LOCK") self.prehook(arg, env)
nfs4.1/server41tests/__init__.py +1 -0
@@ -28,4 +28,5 @@ __all__ = ["st_exchange_id.py", # draft 21 "st_xattr.py", "st_courtesy.py", "st_callback.py", + "st_dir_deleg.py", ]
nfs4.1/server41tests/st_dir_deleg.py new file +102 -0
102 lines not on this page · raw message
Signature · 1 line
2.53.0
Jeff Layton
maintainerPATCH v2 4/25 server41tests: add a test for duplicate GET_DIR_DELEGATION requests
In reply to Jeff Layton--- nfs4.1/server41tests/st_dir_deleg.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
nfs4.1/server41tests/st_dir_deleg.py +26 -0
@@ -100,3 +100,29 @@ def testDirDelegSimple(t, env): ops = [ op.putfh(fh), op.delegreturn(deleg) ] res = sess1.compound(ops) check(res) + +def testDirDelegDuplicate(t, env): + """Test that server returns GDD4_UNAVAIL on duplicate GDD4 request + + FLAGS: dirdeleg all + CODE: DIRDELEG2 + """ + c = env.c1 + recall = threading.Event() + sess1, fh, deleg = _getDirDeleg(t, env, [], recall) + + # get a dir deleg with no notifications + ops = [ op.putfh(fh), op.get_dir_delegation(False, + nfs4lib.list2bitmap([]), + zerotime, zerotime, + nfs4lib.list2bitmap([]), + nfs4lib.list2bitmap([]))] + res = sess1.compound(ops) + check(res) + nfstatus = res.resarray[-1].gddr_res_non_fatal4.gddrnf_status + if (nfstatus != GDD4_UNAVAIL): + fail("Server replied to duplicate request with %d" % nfstatus) + + ops = [ op.putfh(fh), op.delegreturn(deleg) ] + res = sess1.compound(ops) + check(res)
Signature · 1 line
2.53.0
Jeff Layton
maintainerPATCH v2 5/25 server41tests: pass_warn() when server doesn't support dir delegations
In reply to Jeff LaytonInstead of just failing the test when GET_DIR_DELEGATION isn't supported or the server doesn't hand out a directory delegation, have it pass with a warning instead. This should make it safe to keep the directory delegation tests in the "all" group.
Also, when receiving a directory delegation, vet that it got the requested notifications. Just pass_warn() if it didn't.
--- nfs4.1/server41tests/st_dir_deleg.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
nfs4.1/server41tests/st_dir_deleg.py +18 -3
@@ -65,14 +65,29 @@ def _getDirDeleg(t, env, notify_mask, cb): check(res) fh = res.resarray[-1].object - ops = [ op.putfh(fh), op.get_dir_delegation(False, - nfs4lib.list2bitmap(notify_mask), + mask_bm = nfs4lib.list2bitmap(notify_mask) + ops = [ op.putfh(fh), op.get_dir_delegation(False, nfs4lib.list2bitmap(notify_mask), zerotime, zerotime, nfs4lib.list2bitmap([]), nfs4lib.list2bitmap([]))] res = sess1.compound(ops) - check(res) + check(res, [NFS4_OK, NFS4ERR_NOTSUPP]) + if (res.status == NFS4ERR_NOTSUPP): + t.pass_warn("Server doesn't support GET_DIR_DELEGATION") + + nf = res.resarray[-1].gddr_res_non_fatal4 + if nf.gddrnf_status == GDD4_UNAVAIL: + t.pass_warn("Server reported that delegation on new dir was unavailable.") + elif nf.gddrnf_status != GDD4_OK: + t.fail("Server returned unknown non-fatal status code.") + deleg = res.resarray[-1].gddrnf_resok4.gddr_stateid + if NOTIFY4_GFLAG_EXTEND in notify_mask and \ + nf.gddrnf_resok4.gddr_notification != mask_bm: + ops = [ op.putfh(fh), op.delegreturn(deleg) ] + res = sess1.compound(ops) + t.pass_warn("Server didn't offer the necessary directory notifications for this test") + return (sess1, fh, deleg) def testDirDelegSimple(t, env):
Signature · 1 line
2.53.0
Jeff Layton
maintainerPATCH v2 6/25 server41tests: test remove triggers dir delegation recall
In reply to Jeff LaytonGet a dir delegation with no notification mask, create a file, then remove it from a second client. Verify that the server issues a CB_RECALL.
--- nfs4.1/server41tests/st_dir_deleg.py | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-)
nfs4.1/server41tests/st_dir_deleg.py +35 -1
@@ -3,7 +3,7 @@ from .st_open import open_claim4 from xdrdef.nfs4_const import * from xdrdef.nfs4_pack import NFS4Unpacker -from .environment import check, fail, create_obj, use_obj +from .environment import check, fail, create_obj, use_obj, close_file, rename_obj from xdrdef.nfs4_type import * import nfs_ops op = nfs_ops.NFS4ops()
@@ -141,3 +141,37 @@ def testDirDelegDuplicate(t, env): ops = [ op.putfh(fh), op.delegreturn(deleg) ] res = sess1.compound(ops) check(res) + +def testDirDelegRemoveRecall(t, env): + """Verify remove triggers dir delegation recall + + FLAGS: dirdeleg all + CODE: DIRDELEG3 + """ + c = env.c1 + recall = threading.Event() + sess1, fh, deleg = _getDirDeleg(t, env, [], recall) + + # Create a file from sess1 + claim = open_claim4(CLAIM_NULL, env.testname(t)) + owner = open_owner4(0, b"owner") + how = openflag4(OPEN4_CREATE, createhow4(GUARDED4, {FATTR4_SIZE:0})) + open_op = [ op.putfh(fh), op.open(0, + OPEN4_SHARE_ACCESS_WRITE | OPEN4_SHARE_ACCESS_WANT_NO_DELEG, + OPEN4_SHARE_DENY_NONE, owner, how, claim), op.getfh() ] + res = sess1.compound(open_op) + check(res) + open_stateid = res.resarray[-2].stateid + file_fh = res.resarray[-1].object + close_file(sess1, file_fh, stateid=open_stateid) + + # Remove the file from sess2 -- should trigger recall + sess2 = c.new_client_session(b"%s_2" % env.testname(t)) + remove_op = [ op.putfh(fh), op.remove(env.testname(t)) ] + slot = sess2.compound_async(remove_op) + completed = recall.wait(2) + env.sleep(.1) + + ops = [ op.putfh(fh), op.delegreturn(deleg) ] + res = sess1.compound(ops) + check(res)
Signature · 1 line
2.53.0
Jeff Layton
maintainerPATCH v2 7/25 server41tests: test rename triggers dir delegation recall
In reply to Jeff LaytonGet a dir delegation with no notification mask, create a file, then rename it from a second client. Verify that the server issues a CB_RECALL.
--- nfs4.1/server41tests/st_dir_deleg.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
nfs4.1/server41tests/st_dir_deleg.py +33 -0
@@ -175,3 +175,36 @@ def testDirDelegRemoveRecall(t, env): ops = [ op.putfh(fh), op.delegreturn(deleg) ] res = sess1.compound(ops) check(res) + +def testDirDelegRenameRecall(t, env): + """Verify rename triggers dir delegation recall + + FLAGS: dirdeleg all + CODE: DIRDELEG4 + """ + c = env.c1 + recall = threading.Event() + sess1, fh, deleg = _getDirDeleg(t, env, [], recall) + + # Create a file from sess1 + claim = open_claim4(CLAIM_NULL, env.testname(t)) + owner = open_owner4(0, b"owner") + how = openflag4(OPEN4_CREATE, createhow4(GUARDED4, {FATTR4_SIZE:0})) + open_op = [ op.putfh(fh), op.open(0, + OPEN4_SHARE_ACCESS_WRITE | OPEN4_SHARE_ACCESS_WANT_NO_DELEG, + OPEN4_SHARE_DENY_NONE, owner, how, claim) ] + res = sess1.compound(open_op) + check(res) + + # Rename the file from sess2 -- should trigger recall + sess2 = c.new_client_session(b"%s_2" % env.testname(t)) + rename_op = [ op.putfh(fh), op.savefh(), + op.putfh(fh), + op.rename(env.testname(t), b"%s_2" % env.testname(t)) ] + slot = sess2.compound_async(rename_op) + completed = recall.wait(2) + env.sleep(.1) + + ops = [ op.putfh(fh), op.delegreturn(deleg) ] + res = sess1.compound(ops) + check(res)
Signature · 1 line
2.53.0
Re: [PATCH pynfs v2 07/25] server41tests: test rename triggers dir delegation recall
Quoted 27 lines · Jeff Layton
Get a dir delegation with no notification mask, create a file, then rename it from a second client. Verify that the server issues a
CB_RECALL.Signed-off-by Jeff Layton <[email protected]>--- nfs4.1/server41tests/st_dir_deleg.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)nfs4.1/server41tests/st_dir_deleg.py +10
-0@@ -175,3 +175,36 @@ def testDirDelegRemoveRecall(t, env): ops = [ op.putfh(fh), op.delegreturn(deleg) ] res = sess1.compound(ops) check(res) + +def testDirDelegRenameRecall(t, env): + """Verify rename triggers dir delegation recall + + FLAGS: dirdeleg all + CODE: DIRDELEG4 + """ + c = env.c1 + recall = threading.Event() + sess1, fh, deleg = _getDirDeleg(t, env, [], recall)
nfs4.1/server41tests/st_dir_deleg.py def testDirDelegRemoveRecall(t, env): · line 197
Quoted 10 lines
nfs4.1/server41tests/st_dir_deleg.py +10
-0+ + # Create a file from sess1 + claim = open_claim4(CLAIM_NULL, env.testname(t)) + owner = open_owner4(0, b"owner") + how = openflag4(OPEN4_CREATE, createhow4(GUARDED4, {FATTR4_SIZE:0})) + open_op = [ op.putfh(fh), op.open(0, + OPEN4_SHARE_ACCESS_WRITE | OPEN4_SHARE_ACCESS_WANT_NO_DELEG, + OPEN4_SHARE_DENY_NONE, owner, how, claim) ] + res = sess1.compound(open_op) + check(res)
You probably want to close this file at the end of the test so you're not leaving state behind on the server.
-Scott
Quoted 18 lines
nfs4.1/server41tests/st_dir_deleg.py +13
-0+ + # Rename the file from sess2 -- should trigger recall + sess2 = c.new_client_session(b"%s_2" % env.testname(t)) + rename_op = [ op.putfh(fh), op.savefh(), + op.putfh(fh), + op.rename(env.testname(t), b"%s_2" % env.testname(t)) ] + slot = sess2.compound_async(rename_op) + completed = recall.wait(2) + env.sleep(.1) + + ops = [ op.putfh(fh), op.delegreturn(deleg) ] + res = sess1.compound(ops) + check(res)Signature · 2 lines
-- 2.53.0
Jeff Layton
maintainerRe: [PATCH pynfs v2 07/25] server41tests: test rename triggers dir delegation recall
Quoted 34 lines · Scott Mayhew
Quoted 32 lines · Jeff Layton
Get a dir delegation with no notification mask, create a file, then rename it from a second client. Verify that the server issues a
CB_RECALL.Signed-off-by Jeff Layton <[email protected]>--- nfs4.1/server41tests/st_dir_deleg.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)nfs4.1/server41tests/st_dir_deleg.py +15
-0@@ -175,3 +175,36 @@ def testDirDelegRemoveRecall(t, env): ops = [ op.putfh(fh), op.delegreturn(deleg) ] res = sess1.compound(ops) check(res) + +def testDirDelegRenameRecall(t, env): + """Verify rename triggers dir delegation recall + + FLAGS: dirdeleg all + CODE: DIRDELEG4 + """ + c = env.c1 + recall = threading.Event() + sess1, fh, deleg = _getDirDeleg(t, env, [], recall) + + # Create a file from sess1 + claim = open_claim4(CLAIM_NULL, env.testname(t)) + owner = open_owner4(0, b"owner") + how = openflag4(OPEN4_CREATE, createhow4(GUARDED4, {FATTR4_SIZE:0}))
Quoted 9 lines
nfs4.1/server41tests/st_dir_deleg.py def testDirDelegRemoveRecall(t, env): · line 197
Quoted 5 lines
nfs4.1/server41tests/st_dir_deleg.py +5
-0+ open_op = [ op.putfh(fh), op.open(0, + OPEN4_SHARE_ACCESS_WRITE | OPEN4_SHARE_ACCESS_WANT_NO_DELEG, + OPEN4_SHARE_DENY_NONE, owner, how, claim) ] + res = sess1.compound(open_op) + check(res)You probably want to close this file at the end of the test so you're not leaving state behind on the server.
Definitely. I'll make a pass through all of the tests and make sure that there is no leftover state. I'll plan to send a v3.
Thanks for the review!
Quoted 1 line
Signature · 1 line
Jeff Layton <[email protected]>
Jeff Layton
maintainerPATCH v2 8/25 server41tests: test mkdir triggers dir delegation recall
In reply to Jeff LaytonGet a dir delegation with no notification mask, then create a subdirectory from a second client. Verify that the server issues a CB_RECALL.
--- nfs4.1/server41tests/st_dir_deleg.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
nfs4.1/server41tests/st_dir_deleg.py +23 -0
@@ -208,3 +208,26 @@ def testDirDelegRenameRecall(t, env): ops = [ op.putfh(fh), op.delegreturn(deleg) ] res = sess1.compound(ops) check(res) + +def testDirDelegMkdirRecall(t, env): + """Verify mkdir triggers dir delegation recall + + FLAGS: dirdeleg all + CODE: DIRDELEG5 + """ + c = env.c1 + recall = threading.Event() + sess1, fh, deleg = _getDirDeleg(t, env, [], recall) + + # Create a subdirectory from sess2 -- should trigger recall + sess2 = c.new_client_session(b"%s_2" % env.testname(t)) + create_op = [ op.putfh(fh), + op.create(createtype4(NF4DIR), env.testname(t), + {FATTR4_MODE: 0o755}) ] + slot = sess2.compound_async(create_op) + completed = recall.wait(2) + env.sleep(.1) + + ops = [ op.putfh(fh), op.delegreturn(deleg) ] + res = sess1.compound(ops) + check(res)
Signature · 1 line
2.53.0
Jeff Layton
maintainerPATCH v2 9/25 server41tests: test link triggers dir delegation recall
In reply to Jeff LaytonGet a dir delegation with no notification mask, create a file, then hard-link it to a new name from a second client. Verify that the server issues a CB_RECALL.
--- nfs4.1/server41tests/st_dir_deleg.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
nfs4.1/server41tests/st_dir_deleg.py +36 -0
@@ -231,3 +231,39 @@ def testDirDelegMkdirRecall(t, env): ops = [ op.putfh(fh), op.delegreturn(deleg) ] res = sess1.compound(ops) check(res) + +def testDirDelegLinkRecall(t, env): + """Verify link triggers dir delegation recall + + FLAGS: dirdeleg all + CODE: DIRDELEG6 + """ + c = env.c1 + recall = threading.Event() + sess1, fh, deleg = _getDirDeleg(t, env, [], recall) + + # Create a file from sess1 + claim = open_claim4(CLAIM_NULL, env.testname(t)) + owner = open_owner4(0, b"owner") + how = openflag4(OPEN4_CREATE, createhow4(GUARDED4, {FATTR4_SIZE:0})) + open_op = [ op.putfh(fh), op.open(0, + OPEN4_SHARE_ACCESS_WRITE | OPEN4_SHARE_ACCESS_WANT_NO_DELEG, + OPEN4_SHARE_DENY_NONE, owner, how, claim), op.getfh() ] + res = sess1.compound(open_op) + check(res) + open_stateid = res.resarray[-2].stateid + file_fh = res.resarray[-1].object + close_file(sess1, file_fh, stateid=open_stateid) + + # Link the file to a new name from sess2 -- should trigger recall + sess2 = c.new_client_session(b"%s_2" % env.testname(t)) + link_op = [ op.putfh(file_fh), op.savefh(), + op.putfh(fh), + op.link(b"%s_link" % env.testname(t)) ] + slot = sess2.compound_async(link_op) + completed = recall.wait(2) + env.sleep(.1) + + ops = [ op.putfh(fh), op.delegreturn(deleg) ] + res = sess1.compound(ops) + check(res)
Signature · 1 line
2.53.0
Jeff Layton
maintainerPATCH v2 10/25 server41tests: test no notifications without GFLAG_EXTEND
In reply to Jeff LaytonRequest a dir delegation with NOTIFY4_ADD_ENTRY but without NOTIFY4_GFLAG_EXTEND. Verify the server issues a CB_RECALL instead of CB_NOTIFY when a file is created.
--- nfs4.1/server41tests/st_dir_deleg.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
nfs4.1/server41tests/st_dir_deleg.py +30 -0
@@ -267,3 +267,33 @@ def testDirDelegLinkRecall(t, env): ops = [ op.putfh(fh), op.delegreturn(deleg) ] res = sess1.compound(ops) check(res) + +def testDirDelegNoGflag(t, env): + """Verify recall instead of notification without NOTIFY4_GFLAG_EXTEND + + FLAGS: dirdeleg all + CODE: DIRDELEG7 + """ + c = env.c1 + cb = threading.Event() + sess1, fh, deleg = _getDirDeleg(t, env, [NOTIFY4_ADD_ENTRY], cb) + + sess2 = c.new_client_session(b"%s_2" % env.testname(t)) + claim = open_claim4(CLAIM_NULL, env.testname(t)) + owner = open_owner4(0, b"owner") + how = openflag4(OPEN4_CREATE, createhow4(GUARDED4, {FATTR4_SIZE:0})) + open_op = [ op.putfh(fh), op.open(0, + OPEN4_SHARE_ACCESS_WRITE | OPEN4_SHARE_ACCESS_WANT_NO_DELEG, + OPEN4_SHARE_DENY_NONE, owner, how, claim) ] + slot = sess2.compound_async(open_op) + completed = cb.wait(2) + env.sleep(.1) + + ops = [ op.putfh(fh), op.delegreturn(deleg) ] + res = sess1.compound(ops) + check(res) + + if cb.got_notify: + fail("Got CB_NOTIFY without GFLAG_EXTEND") + if not cb.got_recall: + fail("Expected CB_RECALL without GFLAG_EXTEND, but didn't get one")
Signature · 1 line
2.53.0
Jeff Layton
maintainerPATCH v2 11/25 server41tests: test unrequested notification type triggers recall
In reply to Jeff LaytonRequest a dir delegation with only REMOVE notifications. Trigger an ADD event from a second client. Verify the server issues a CB_RECALL instead of CB_NOTIFY since ADD was not requested.
--- nfs4.1/server41tests/st_dir_deleg.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
nfs4.1/server41tests/st_dir_deleg.py +32 -0
@@ -297,3 +297,35 @@ def testDirDelegNoGflag(t, env): fail("Got CB_NOTIFY without GFLAG_EXTEND") if not cb.got_recall: fail("Expected CB_RECALL without GFLAG_EXTEND, but didn't get one") + +def testDirDelegFiltering(t, env): + """Verify unrequested notification type triggers recall + + FLAGS: dirdeleg all + CODE: DIRDELEG8 + """ + c = env.c1 + cb = threading.Event() + # Only request REMOVE notifications + sess1, fh, deleg = _getDirDeleg(t, env, + [NOTIFY4_REMOVE_ENTRY, + NOTIFY4_GFLAG_EXTEND], cb) + + # Trigger an ADD event (not requested) from a second client + sess2 = c.new_client_session(b"%s_2" % env.testname(t)) + claim = open_claim4(CLAIM_NULL, env.testname(t)) + owner = open_owner4(0, b"owner") + how = openflag4(OPEN4_CREATE, createhow4(GUARDED4, {FATTR4_SIZE:0})) + open_op = [ op.putfh(fh), op.open(0, + OPEN4_SHARE_ACCESS_WRITE | OPEN4_SHARE_ACCESS_WANT_NO_DELEG, + OPEN4_SHARE_DENY_NONE, owner, how, claim) ] + slot = sess2.compound_async(open_op) + completed = cb.wait(2) + env.sleep(.1) + + ops = [ op.putfh(fh), op.delegreturn(deleg) ] + res = sess1.compound(ops) + check(res) + + if not cb.got_recall: + fail("Expected CB_RECALL for unrequested notification type")
Signature · 1 line
2.53.0
Jeff Layton
maintainerPATCH v2 12/25 server41tests: add a test for removal from dir with dir delegation
In reply to Jeff LaytonRequest a dir delegation with REMOVE_ENTRY notifications. Create a file, then remove it from a second client. Verify the server sends a CB_NOTIFY with the correct REMOVE event.
Also add full child and directory attribute bitmaps to the GET_DIR_DELEGATION request for all CB_NOTIFY tests.
--- nfs4.1/server41tests/st_dir_deleg.py | 65 ++++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 2 deletions(-)
nfs4.1/server41tests/st_dir_deleg.py +63 -2
@@ -68,8 +68,26 @@ def _getDirDeleg(t, env, notify_mask, cb): mask_bm = nfs4lib.list2bitmap(notify_mask) ops = [ op.putfh(fh), op.get_dir_delegation(False, nfs4lib.list2bitmap(notify_mask), zerotime, zerotime, - nfs4lib.list2bitmap([]), - nfs4lib.list2bitmap([]))] + nfs4lib.list2bitmap([FATTR4_TYPE, + FATTR4_CHANGE, + FATTR4_SIZE, + FATTR4_FILEID, + FATTR4_FILEHANDLE, + FATTR4_MODE, + FATTR4_NUMLINKS, + FATTR4_RAWDEV, + FATTR4_SPACE_USED, + FATTR4_TIME_ACCESS, + FATTR4_TIME_METADATA, + FATTR4_TIME_MODIFY, + FATTR4_TIME_CREATE]), + nfs4lib.list2bitmap([FATTR4_CHANGE, + FATTR4_SIZE, + FATTR4_NUMLINKS, + FATTR4_SPACE_USED, + FATTR4_TIME_ACCESS, + FATTR4_TIME_METADATA, + FATTR4_TIME_MODIFY]))] res = sess1.compound(ops) check(res, [NFS4_OK, NFS4ERR_NOTSUPP]) if (res.status == NFS4ERR_NOTSUPP):
@@ -329,3 +347,46 @@ def testDirDelegFiltering(t, env): if not cb.got_recall: fail("Expected CB_RECALL for unrequested notification type") + +def testDirDelegRemove(t, env): + """Create a dir_deleg that accepts notification of REMOVE events + + FLAGS: dirdeleg all + CODE: DIRDELEG9 + """ + c = env.c1 + cb = threading.Event() + sess1, fh, deleg = _getDirDeleg(t, env, + [NOTIFY4_CHANGE_DIR_ATTRS, + NOTIFY4_REMOVE_ENTRY, + NOTIFY4_GFLAG_EXTEND], cb) + + claim = open_claim4(CLAIM_NULL, env.testname(t)) + owner = open_owner4(0, b"owner") + how = openflag4(OPEN4_CREATE, createhow4(GUARDED4, {FATTR4_SIZE:0})) + open_op = [ op.putfh(fh), op.open(0, + OPEN4_SHARE_ACCESS_WRITE | OPEN4_SHARE_ACCESS_WANT_NO_DELEG, + OPEN4_SHARE_DENY_NONE, owner, how, claim), op.getfh() ] + res = sess1.compound(open_op) + check(res) + open_stateid = res.resarray[-2].stateid + file_fh = res.resarray[-1].object + close_file(sess1, file_fh, stateid=open_stateid) + + sess2 = c.new_client_session(b"%s_2" % env.testname(t)) + remove_op = [ op.putfh(fh), op.remove(env.testname(t)) ] + res = sess2.compound(remove_op) + check(res) + + completed = cb.wait(5) + ops = [ op.putfh(fh), op.delegreturn(deleg) ] + res = sess1.compound(ops) + + if (not completed or not cb.got_notify): + fail("Didn't receive a CB_NOTIFY from the server!") + + evt_type, evt = decode_notify_event(cb.changes[0]) + if evt_type != NOTIFY4_REMOVE_ENTRY: + fail("Expected REMOVE notification, got %d" % evt_type) + if evt.nrm_old_entry.ne_file != env.testname(t): + fail("Wrong entry name in REMOVE notification")
Signature · 1 line
2.53.0
Jeff Layton
maintainerPATCH v2 13/25 server41tests: add a test for directory add notifications
In reply to Jeff LaytonRequest a dir delegation with ADD_ENTRY notifications. Create a file from a second client. Verify the server sends a CB_NOTIFY with the correct ADD event.
--- nfs4.1/server41tests/st_dir_deleg.py | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
nfs4.1/server41tests/st_dir_deleg.py +41 -0
@@ -390,3 +390,44 @@ def testDirDelegRemove(t, env): fail("Expected REMOVE notification, got %d" % evt_type) if evt.nrm_old_entry.ne_file != env.testname(t): fail("Wrong entry name in REMOVE notification") + +def testDirDelegAdd(t, env): + """Create a dir_deleg that accepts notification of ADD events + + FLAGS: dirdeleg all + CODE: DIRDELEG10 + """ + c = env.c1 + cb = threading.Event() + sess1, fh, deleg = _getDirDeleg(t, env, + [NOTIFY4_ADD_ENTRY, + NOTIFY4_GFLAG_EXTEND], cb) + + sess2 = c.new_client_session(b"%s_2" % env.testname(t)) + claim = open_claim4(CLAIM_NULL, env.testname(t)) + owner = open_owner4(0, b"owner") + how = openflag4(OPEN4_CREATE, createhow4(GUARDED4, {FATTR4_SIZE:0})) + open_op = [ op.putfh(fh), op.open(0, + OPEN4_SHARE_ACCESS_WRITE | OPEN4_SHARE_ACCESS_WANT_NO_DELEG, + OPEN4_SHARE_DENY_NONE, owner, how, claim), op.getfh() ] + res = sess2.compound(open_op) + check(res) + + completed = cb.wait(2) + + delegreturn_op = [ op.putfh(fh), op.delegreturn(deleg) ] + res = sess1.compound(delegreturn_op) + check(res) + + remove_op = [ op.putfh(fh), op.remove(env.testname(t)) ] + res = sess2.compound(remove_op) + check(res) + + if (not completed or not cb.got_notify): + fail("Didn't receive a CB_NOTIFY from the server!") + + evt_type, evt = decode_notify_event(cb.changes[0]) + if evt_type != NOTIFY4_ADD_ENTRY: + fail("Expected ADD notification, got %d" % evt_type) + if evt.nad_new_entry.ne_file != env.testname(t): + fail("Wrong entry name in ADD notification")
Signature · 1 line
2.53.0
Jeff Layton
maintainerPATCH v2 14/25 server41tests: add test for RENAME event notifications
In reply to Jeff LaytonRequest a dir delegation with RENAME_ENTRY notifications. Create a file, then rename it from a second client. Verify the server sends a CB_NOTIFY with the correct RENAME event.
--- nfs4.1/server41tests/st_dir_deleg.py | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)
nfs4.1/server41tests/st_dir_deleg.py +44 -0
@@ -431,3 +431,47 @@ def testDirDelegAdd(t, env): fail("Expected ADD notification, got %d" % evt_type) if evt.nad_new_entry.ne_file != env.testname(t): fail("Wrong entry name in ADD notification") + +def testDirDelegRename(t, env): + """Create a dir_deleg that accepts notification of RENAME events + + FLAGS: dirdeleg all + CODE: DIRDELEG11 + """ + c = env.c1 + cb = threading.Event() + + sess1, fh, deleg = _getDirDeleg(t, env, + [NOTIFY4_RENAME_ENTRY, + NOTIFY4_GFLAG_EXTEND], cb) + + claim = open_claim4(CLAIM_NULL, env.testname(t)) + owner = open_owner4(0, b"owner") + how = openflag4(OPEN4_CREATE, createhow4(GUARDED4, {FATTR4_SIZE:0})) + open_op = [ op.putfh(fh), op.open(0, + OPEN4_SHARE_ACCESS_WRITE | OPEN4_SHARE_ACCESS_WANT_NO_DELEG, + OPEN4_SHARE_DENY_NONE, owner, how, claim) ] + res = sess1.compound(open_op) + check(res) + + sess2 = c.new_client_session(b"%s_2" % env.testname(t)) + topdir = c.homedir + [t.code.encode('utf8')] + oldpath = topdir + [env.testname(t)] + newpath = topdir + [b"%s_2" % env.testname(t)] + res = rename_obj(sess2, oldpath, newpath) + check(res) + + completed = cb.wait(2) + + delegreturn_op = [ op.putfh(fh), op.delegreturn(deleg) ] + res = sess1.compound(delegreturn_op) + check(res) + + if (not completed or not cb.got_notify): + fail("Didn't receive a CB_NOTIFY from the server!") + + evt_type, evt = decode_notify_event(cb.changes[0]) + if evt_type != NOTIFY4_RENAME_ENTRY: + fail("Expected RENAME notification, got %d" % evt_type) + if evt.nrn_old_entry.nrm_old_entry.ne_file != env.testname(t): + fail("Wrong old entry name in RENAME notification")
Signature · 1 line
2.53.0
Jeff Layton
maintainerPATCH v2 15/25 server41tests: verify child attributes in ADD notification
In reply to Jeff LaytonRequest a dir delegation with ADD_ENTRY notifications. Create a file from a second client. Verify the ADD notification includes child attributes with a correct size.
--- nfs4.1/server41tests/st_dir_deleg.py | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)
nfs4.1/server41tests/st_dir_deleg.py +47 -0
@@ -475,3 +475,50 @@ def testDirDelegRename(t, env): fail("Expected RENAME notification, got %d" % evt_type) if evt.nrn_old_entry.nrm_old_entry.ne_file != env.testname(t): fail("Wrong old entry name in RENAME notification") + +def testDirDelegChildAttrs(t, env): + """Verify child attributes are present in ADD notification + + FLAGS: dirdeleg all + CODE: DIRDELEG12 + """ + c = env.c1 + cb = threading.Event() + sess1, fh, deleg = _getDirDeleg(t, env, + [NOTIFY4_ADD_ENTRY, + NOTIFY4_GFLAG_EXTEND], cb) + + sess2 = c.new_client_session(b"%s_2" % env.testname(t)) + claim = open_claim4(CLAIM_NULL, env.testname(t)) + owner = open_owner4(0, b"owner") + how = openflag4(OPEN4_CREATE, createhow4(GUARDED4, {FATTR4_SIZE:0})) + open_op = [ op.putfh(fh), op.open(0, + OPEN4_SHARE_ACCESS_WRITE | OPEN4_SHARE_ACCESS_WANT_NO_DELEG, + OPEN4_SHARE_DENY_NONE, owner, how, claim), op.getfh() ] + res = sess2.compound(open_op) + check(res) + + completed = cb.wait(2) + + delegreturn_op = [ op.putfh(fh), op.delegreturn(deleg) ] + res = sess1.compound(delegreturn_op) + check(res) + + remove_op = [ op.putfh(fh), op.remove(env.testname(t)) ] + res = sess2.compound(remove_op) + check(res) + + if (not completed or not cb.got_notify): + fail("Didn't receive a CB_NOTIFY from the server!") + + evt_type, evt = decode_notify_event(cb.changes[0]) + if evt_type != NOTIFY4_ADD_ENTRY: + fail("Expected ADD notification, got %d" % evt_type) + + attrs = evt.nad_new_entry.ne_attrs + if not any(attrs.attrmask): + fail("No child attributes in ADD notification") + attrs.attrmask = bitmap4_to_int(attrs.attrmask) + attr_dict = nfs4lib.fattr2dict(attrs) + if FATTR4_SIZE in attr_dict and attr_dict[FATTR4_SIZE] != 0: + fail("Expected size 0 for new file, got %d" % attr_dict[FATTR4_SIZE])
Signature · 1 line
2.53.0
Jeff Layton
maintainerPATCH v2 16/25 server41tests: test CHANGE_DIR_ATTRS notification
In reply to Jeff LaytonRequest a dir delegation with CHANGE_DIR_ATTRS and ADD_ENTRY notifications. Create a file from a second client. Verify the server sends a CHANGE_DIR_ATTRS notification with directory attributes.
--- nfs4.1/server41tests/st_dir_deleg.py | 50 ++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+)
nfs4.1/server41tests/st_dir_deleg.py +50 -0
@@ -522,3 +522,53 @@ def testDirDelegChildAttrs(t, env): attr_dict = nfs4lib.fattr2dict(attrs) if FATTR4_SIZE in attr_dict and attr_dict[FATTR4_SIZE] != 0: fail("Expected size 0 for new file, got %d" % attr_dict[FATTR4_SIZE]) + +def testDirDelegDirAttrs(t, env): + """Verify CHANGE_DIR_ATTRS notification on directory change + + FLAGS: dirdeleg all + CODE: DIRDELEG13 + """ + c = env.c1 + cb = threading.Event() + sess1, fh, deleg = _getDirDeleg(t, env, + [NOTIFY4_CHANGE_DIR_ATTRS, + NOTIFY4_ADD_ENTRY, + NOTIFY4_GFLAG_EXTEND], cb) + + sess2 = c.new_client_session(b"%s_2" % env.testname(t)) + claim = open_claim4(CLAIM_NULL, env.testname(t)) + owner = open_owner4(0, b"owner") + how = openflag4(OPEN4_CREATE, createhow4(GUARDED4, {FATTR4_SIZE:0})) + open_op = [ op.putfh(fh), op.open(0, + OPEN4_SHARE_ACCESS_WRITE | OPEN4_SHARE_ACCESS_WANT_NO_DELEG, + OPEN4_SHARE_DENY_NONE, owner, how, claim), op.getfh() ] + res = sess2.compound(open_op) + check(res) + + completed = cb.wait(2) + + delegreturn_op = [ op.putfh(fh), op.delegreturn(deleg) ] + res = sess1.compound(delegreturn_op) + check(res) + + remove_op = [ op.putfh(fh), op.remove(env.testname(t)) ] + res = sess2.compound(remove_op) + check(res) + + if (not completed or not cb.got_notify): + fail("Didn't receive a CB_NOTIFY from the server!") + + # Look for a CHANGE_DIR_ATTRS event among the changes + found_dir_attrs = False + for change in cb.changes: + evt_type, evt = decode_notify_event(change) + if evt_type == NOTIFY4_CHANGE_DIR_ATTRS: + found_dir_attrs = True + attrs = evt.na_changed_entry.ne_attrs + if not any(attrs.attrmask): + fail("No directory attributes in CHANGE_DIR_ATTRS notification") + break + + if not found_dir_attrs: + fail("No CHANGE_DIR_ATTRS notification found")
Signature · 1 line
2.53.0
Jeff Layton
maintainerPATCH v2 17/25 server41tests: test mkdir triggers ADD notification
In reply to Jeff LaytonRequest a dir delegation with ADD_ENTRY notifications. Create a subdirectory from a second client. Verify the server sends a CB_NOTIFY with the correct ADD event.
--- nfs4.1/server41tests/st_dir_deleg.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
nfs4.1/server41tests/st_dir_deleg.py +33 -0
@@ -572,3 +572,36 @@ def testDirDelegDirAttrs(t, env): if not found_dir_attrs: fail("No CHANGE_DIR_ATTRS notification found") + +def testDirDelegMkdir(t, env): + """Verify mkdir triggers ADD notification + + FLAGS: dirdeleg all + CODE: DIRDELEG14 + """ + c = env.c1 + cb = threading.Event() + sess1, fh, deleg = _getDirDeleg(t, env, + [NOTIFY4_ADD_ENTRY, + NOTIFY4_GFLAG_EXTEND], cb) + + sess2 = c.new_client_session(b"%s_2" % env.testname(t)) + topdir = c.homedir + [t.code.encode('utf8')] + subdir = topdir + [env.testname(t)] + res = create_obj(sess2, subdir) + check(res) + + completed = cb.wait(2) + + delegreturn_op = [ op.putfh(fh), op.delegreturn(deleg) ] + res = sess1.compound(delegreturn_op) + check(res) + + if (not completed or not cb.got_notify): + fail("Didn't receive a CB_NOTIFY from the server!") + + evt_type, evt = decode_notify_event(cb.changes[0]) + if evt_type != NOTIFY4_ADD_ENTRY: + fail("Expected ADD notification, got %d" % evt_type) + if evt.nad_new_entry.ne_file != env.testname(t): + fail("Wrong directory name in ADD notification")
Signature · 1 line
2.53.0
Jeff Layton
maintainerPATCH v2 18/25 server41tests: test DELEGRETURN stops notifications
In reply to Jeff LaytonGet a dir delegation with ADD_ENTRY notifications, immediately return it with DELEGRETURN, then create a file from a second client. Verify no callbacks are received after the delegation was returned.
--- nfs4.1/server41tests/st_dir_deleg.py | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
nfs4.1/server41tests/st_dir_deleg.py +38 -0
@@ -605,3 +605,41 @@ def testDirDelegMkdir(t, env): fail("Expected ADD notification, got %d" % evt_type) if evt.nad_new_entry.ne_file != env.testname(t): fail("Wrong directory name in ADD notification") + +def testDirDelegReturnStopsNotify(t, env): + """Verify DELEGRETURN stops notifications + + FLAGS: dirdeleg all + CODE: DIRDELEG15 + """ + c = env.c1 + cb = threading.Event() + sess1, fh, deleg = _getDirDeleg(t, env, + [NOTIFY4_ADD_ENTRY, + NOTIFY4_GFLAG_EXTEND], cb) + + # Immediately return the delegation + ops = [ op.putfh(fh), op.delegreturn(deleg) ] + res = sess1.compound(ops) + check(res) + + # Now create a file from a second client + sess2 = c.new_client_session(b"%s_2" % env.testname(t)) + claim = open_claim4(CLAIM_NULL, env.testname(t)) + owner = open_owner4(0, b"owner") + how = openflag4(OPEN4_CREATE, createhow4(GUARDED4, {FATTR4_SIZE:0})) + open_op = [ op.putfh(fh), op.open(0, + OPEN4_SHARE_ACCESS_WRITE | OPEN4_SHARE_ACCESS_WANT_NO_DELEG, + OPEN4_SHARE_DENY_NONE, owner, how, claim) ] + res = sess2.compound(open_op) + check(res) + + # Wait briefly -- should NOT get any callback + completed = cb.wait(2) + + remove_op = [ op.putfh(fh), op.remove(env.testname(t)) ] + res = sess2.compound(remove_op) + check(res) + + if cb.got_notify or cb.got_recall: + fail("Received callback after DELEGRETURN")
Signature · 1 line
2.53.0
Jeff Layton
maintainerPATCH v2 19/25 server41tests: verify filehandle in ADD notification
In reply to Jeff LaytonRequest a dir delegation with ADD_ENTRY notifications. Create a file from a second client, recording its filehandle via GETFH. Verify the ADD notification includes a filehandle attribute that matches.
--- nfs4.1/server41tests/st_dir_deleg.py | 48 ++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+)
nfs4.1/server41tests/st_dir_deleg.py +48 -0
@@ -643,3 +643,51 @@ def testDirDelegReturnStopsNotify(t, env): if cb.got_notify or cb.got_recall: fail("Received callback after DELEGRETURN") + +def testDirDelegFilehandle(t, env): + """Verify filehandle in ADD notification matches GETFH result + + FLAGS: dirdeleg all + CODE: DIRDELEG16 + """ + c = env.c1 + cb = threading.Event() + sess1, fh, deleg = _getDirDeleg(t, env, + [NOTIFY4_ADD_ENTRY, + NOTIFY4_GFLAG_EXTEND], cb) + + sess2 = c.new_client_session(b"%s_2" % env.testname(t)) + claim = open_claim4(CLAIM_NULL, env.testname(t)) + owner = open_owner4(0, b"owner") + how = openflag4(OPEN4_CREATE, createhow4(GUARDED4, {FATTR4_SIZE:0})) + open_op = [ op.putfh(fh), op.open(0, + OPEN4_SHARE_ACCESS_WRITE | OPEN4_SHARE_ACCESS_WANT_NO_DELEG, + OPEN4_SHARE_DENY_NONE, owner, how, claim), op.getfh() ] + res = sess2.compound(open_op) + check(res) + file_fh = res.resarray[-1].object + + completed = cb.wait(2) + + delegreturn_op = [ op.putfh(fh), op.delegreturn(deleg) ] + res = sess1.compound(delegreturn_op) + check(res) + + remove_op = [ op.putfh(fh), op.remove(env.testname(t)) ] + res = sess2.compound(remove_op) + check(res) + + if (not completed or not cb.got_notify): + fail("Didn't receive a CB_NOTIFY from the server!") + + evt_type, evt = decode_notify_event(cb.changes[0]) + if evt_type != NOTIFY4_ADD_ENTRY: + fail("Expected ADD notification, got %d" % evt_type) + + attrs = evt.nad_new_entry.ne_attrs + attrs.attrmask = bitmap4_to_int(attrs.attrmask) + attr_dict = nfs4lib.fattr2dict(attrs) + if FATTR4_FILEHANDLE not in attr_dict: + fail("No filehandle in ADD notification attributes") + if attr_dict[FATTR4_FILEHANDLE] != file_fh: + fail("Filehandle in notification doesn't match GETFH result")
Signature · 1 line
2.53.0
Jeff Layton
maintainerPATCH v2 20/25 server41tests: test cross-directory rename REMOVE notification
In reply to Jeff LaytonVerify that a cross-directory rename generates a NOTIFY4_REMOVE_ENTRY notification on the source directory's delegation, rather than a NOTIFY4_RENAME_ENTRY (which is only for within-directory renames).
--- nfs4.1/server41tests/st_dir_deleg.py | 57 ++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+)
nfs4.1/server41tests/st_dir_deleg.py +57 -0
@@ -691,3 +691,60 @@ def testDirDelegFilehandle(t, env): fail("No filehandle in ADD notification attributes") if attr_dict[FATTR4_FILEHANDLE] != file_fh: fail("Filehandle in notification doesn't match GETFH result") + +def testDirDelegCrossRename(t, env): + """Verify cross-directory rename generates REMOVE notification on source + + Per RFC 8881bis Section 27.4.6, a rename across directories sends + a REMOVE notification to the source directory and an ADD notification + to the target directory, rather than a RENAME notification. + + FLAGS: dirdeleg all + CODE: DIRDELEG17 + """ + c = env.c1 + cb = threading.Event() + sess1, fh, deleg = _getDirDeleg(t, env, + [NOTIFY4_REMOVE_ENTRY, + NOTIFY4_GFLAG_EXTEND], cb) + + # Create a file in the delegated directory + claim = open_claim4(CLAIM_NULL, env.testname(t)) + owner = open_owner4(0, b"owner") + how = openflag4(OPEN4_CREATE, createhow4(GUARDED4, {FATTR4_SIZE:0})) + open_op = [ op.putfh(fh), op.open(0, + OPEN4_SHARE_ACCESS_WRITE | OPEN4_SHARE_ACCESS_WANT_NO_DELEG, + OPEN4_SHARE_DENY_NONE, owner, how, claim), op.getfh() ] + res = sess1.compound(open_op) + check(res) + open_stateid = res.resarray[-2].stateid + file_fh = res.resarray[-1].object + close_file(sess1, file_fh, stateid=open_stateid) + + # Create a target directory (sibling of the delegated directory) + topdir = c.homedir + [t.code.encode('utf8')] + targetdir = c.homedir + [b"%s_target" % t.code.encode('utf8')] + res = create_obj(sess1, targetdir) + check(res) + + # Rename the file from the delegated dir to the target dir from sess2 + sess2 = c.new_client_session(b"%s_2" % env.testname(t)) + oldpath = topdir + [env.testname(t)] + newpath = targetdir + [env.testname(t)] + res = rename_obj(sess2, oldpath, newpath) + check(res) + + completed = cb.wait(2) + + delegreturn_op = [ op.putfh(fh), op.delegreturn(deleg) ] + res = sess1.compound(delegreturn_op) + check(res) + + if (not completed or not cb.got_notify): + fail("Didn't receive a CB_NOTIFY from the server!") + + evt_type, evt = decode_notify_event(cb.changes[0]) + if evt_type != NOTIFY4_REMOVE_ENTRY: + fail("Expected REMOVE notification for cross-dir rename, got %d" % evt_type) + if evt.nrm_old_entry.ne_file != env.testname(t): + fail("Wrong entry name in REMOVE notification")
Signature · 1 line
2.53.0
Jeff Layton
maintainerPATCH v2 21/25 server41tests: test cross-directory rename ADD notification on target
In reply to Jeff LaytonVerify that a cross-directory rename generates a NOTIFY4_ADD_ENTRY notification on the target directory's delegation.
--- nfs4.1/server41tests/st_dir_deleg.py | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+)
nfs4.1/server41tests/st_dir_deleg.py +60 -0
@@ -748,3 +748,63 @@ def testDirDelegCrossRename(t, env): fail("Expected REMOVE notification for cross-dir rename, got %d" % evt_type) if evt.nrm_old_entry.ne_file != env.testname(t): fail("Wrong entry name in REMOVE notification") + +def testDirDelegCrossRenameTarget(t, env): + """Verify cross-directory rename generates ADD notification on target + + Per RFC 8881bis Section 27.4.6, a rename across directories sends + a REMOVE notification to the source directory and an ADD notification + to the target directory. + + FLAGS: dirdeleg all + CODE: DIRDELEG18 + """ + c = env.c1 + cb = threading.Event() + + # Create a source directory (not delegated) and a file in it + srcdir = c.homedir + [b"%s_src" % t.code.encode('utf8')] + sess1 = c.new_client_session(b"%s_1" % env.testname(t)) + res = create_obj(sess1, srcdir) + check(res) + + claim = open_claim4(CLAIM_NULL, env.testname(t)) + owner = open_owner4(0, b"owner") + how = openflag4(OPEN4_CREATE, createhow4(GUARDED4, {FATTR4_SIZE:0})) + src_fh = res.resarray[-1].object + open_op = [ op.putfh(src_fh), op.open(0, + OPEN4_SHARE_ACCESS_WRITE | OPEN4_SHARE_ACCESS_WANT_NO_DELEG, + OPEN4_SHARE_DENY_NONE, owner, how, claim), op.getfh() ] + res = sess1.compound(open_op) + check(res) + open_stateid = res.resarray[-2].stateid + file_fh = res.resarray[-1].object + close_file(sess1, file_fh, stateid=open_stateid) + + # Get a dir delegation on the target directory + sess1, fh, deleg = _getDirDeleg(t, env, + [NOTIFY4_ADD_ENTRY, + NOTIFY4_GFLAG_EXTEND], cb) + + # Rename the file into the delegated target directory from sess2 + sess2 = c.new_client_session(b"%s_2" % env.testname(t)) + topdir = c.homedir + [t.code.encode('utf8')] + oldpath = srcdir + [env.testname(t)] + newpath = topdir + [env.testname(t)] + res = rename_obj(sess2, oldpath, newpath) + check(res) + + completed = cb.wait(2) + + delegreturn_op = [ op.putfh(fh), op.delegreturn(deleg) ] + res = sess1.compound(delegreturn_op) + check(res) + + if (not completed or not cb.got_notify): + fail("Didn't receive a CB_NOTIFY from the server!") + + evt_type, evt = decode_notify_event(cb.changes[0]) + if evt_type != NOTIFY4_ADD_ENTRY: + fail("Expected ADD notification for cross-dir rename target, got %d" % evt_type) + if evt.nad_new_entry.ne_file != env.testname(t): + fail("Wrong entry name in ADD notification")
Signature · 1 line
2.53.0
Jeff Layton
maintainerPATCH v2 22/25 server41tests: test link triggers ADD notification
In reply to Jeff LaytonVerify that creating a hard link triggers a NOTIFY4_ADD_ENTRY notification on the directory's delegation.
--- nfs4.1/server41tests/st_dir_deleg.py | 56 ++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+)
nfs4.1/server41tests/st_dir_deleg.py +56 -0
@@ -808,3 +808,59 @@ def testDirDelegCrossRenameTarget(t, env): fail("Expected ADD notification for cross-dir rename target, got %d" % evt_type) if evt.nad_new_entry.ne_file != env.testname(t): fail("Wrong entry name in ADD notification") + +def testDirDelegLinkNotify(t, env): + """Verify hard link triggers ADD notification + + Per RFC 8881bis Section 27.4.4, the server sends an ADD notification + when a hard link is being created to an existing file. + + FLAGS: dirdeleg all + CODE: DIRDELEG19 + """ + c = env.c1 + cb = threading.Event() + sess1, fh, deleg = _getDirDeleg(t, env, + [NOTIFY4_ADD_ENTRY, + NOTIFY4_GFLAG_EXTEND], cb) + + # Create a file in the delegated directory from sess1 + claim = open_claim4(CLAIM_NULL, env.testname(t)) + owner = open_owner4(0, b"owner") + how = openflag4(OPEN4_CREATE, createhow4(GUARDED4, {FATTR4_SIZE:0})) + open_op = [ op.putfh(fh), op.open(0, + OPEN4_SHARE_ACCESS_WRITE | OPEN4_SHARE_ACCESS_WANT_NO_DELEG, + OPEN4_SHARE_DENY_NONE, owner, how, claim), op.getfh() ] + res = sess1.compound(open_op) + check(res) + open_stateid = res.resarray[-2].stateid + file_fh = res.resarray[-1].object + close_file(sess1, file_fh, stateid=open_stateid) + + # Clear the notification state from the create + cb.clear() + cb.got_notify = False + + # Link the file to a new name from sess2 + link_name = b"%s_link" % env.testname(t) + sess2 = c.new_client_session(b"%s_2" % env.testname(t)) + link_op = [ op.putfh(file_fh), op.savefh(), + op.putfh(fh), + op.link(link_name) ] + res = sess2.compound(link_op) + check(res) + + completed = cb.wait(2) + + delegreturn_op = [ op.putfh(fh), op.delegreturn(deleg) ] + res = sess1.compound(delegreturn_op) + check(res) + + if (not completed or not cb.got_notify): + fail("Didn't receive a CB_NOTIFY from the server!") + + evt_type, evt = decode_notify_event(cb.changes[0]) + if evt_type != NOTIFY4_ADD_ENTRY: + fail("Expected ADD notification for link, got %d" % evt_type) + if evt.nad_new_entry.ne_file != link_name: + fail("Wrong entry name in ADD notification")
Signature · 1 line
2.53.0
Jeff Layton
maintainerPATCH v2 23/25 server41tests: test same-client changes don't trigger notifications
In reply to Jeff LaytonVerify that changes made by the delegation-holding session itself do not trigger CB_NOTIFY or CB_RECALL callbacks.
--- nfs4.1/server41tests/st_dir_deleg.py | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
nfs4.1/server41tests/st_dir_deleg.py +37 -0
@@ -864,3 +864,40 @@ def testDirDelegLinkNotify(t, env): fail("Expected ADD notification for link, got %d" % evt_type) if evt.nad_new_entry.ne_file != link_name: fail("Wrong entry name in ADD notification") + +def testDirDelegSameClientNoNotify(t, env): + """Verify delegation holder's own changes don't trigger notifications + + Per RFC 8881bis Section 16.2.11.2, order-unaware clients should not + receive notifications for changes they made themselves. + + FLAGS: dirdeleg all + CODE: DIRDELEG20 + """ + c = env.c1 + cb = threading.Event() + sess1, fh, deleg = _getDirDeleg(t, env, + [NOTIFY4_ADD_ENTRY, + NOTIFY4_GFLAG_EXTEND], cb) + + # Create a file from the delegation-holding session itself + claim = open_claim4(CLAIM_NULL, env.testname(t)) + owner = open_owner4(0, b"owner") + how = openflag4(OPEN4_CREATE, createhow4(GUARDED4, {FATTR4_SIZE:0})) + open_op = [ op.putfh(fh), op.open(0, + OPEN4_SHARE_ACCESS_WRITE | OPEN4_SHARE_ACCESS_WANT_NO_DELEG, + OPEN4_SHARE_DENY_NONE, owner, how, claim) ] + res = sess1.compound(open_op) + check(res) + + # Wait briefly -- should NOT get any callback + completed = cb.wait(2) + + ops = [ op.putfh(fh), op.delegreturn(deleg) ] + res = sess1.compound(ops) + check(res) + + if cb.got_notify: + fail("Got CB_NOTIFY for delegation holder's own change") + if cb.got_recall: + fail("Got CB_RECALL for delegation holder's own change")
Signature · 1 line
2.53.0
Jeff Layton
maintainerPATCH v2 24/25 server41tests: test cross-directory rename-over nad_old_entry
In reply to Jeff LaytonTest that when a cross-directory rename overwrites an existing file in a delegated directory, the server reports the overwritten entry via nad_old_entry in the NOTIFY4_ADD_ENTRY notification rather than generating a separate NOTIFY4_REMOVE_ENTRY notification.
Per RFC 8881 Section 18.26.4, when the removal is done atomically with the rename, a separate NOTIFY4_REMOVE_ENTRY notification will not be generated. Instead, the deletion of the file will be reported as part of the NOTIFY4_ADD_ENTRY notification via nad_old_entry.
Also fix _getDirDeleg to initialize cb.changes as a list and use extend() to accumulate notifications, so tests that receive multiple CB_NOTIFY callbacks can see all notifications.
--- nfs4.1/server41tests/st_dir_deleg.py | 100 ++++++++++++++++++++++++++++++++++- 1 file changed, 99 insertions(+), 1 deletion(-)
nfs4.1/server41tests/st_dir_deleg.py +99 -1
@@ -44,7 +44,7 @@ def _getDirDeleg(t, env, notify_mask, cb): def notify_pre_hook(arg, env): cb.stateid = arg.cna_stateid cb.fh = arg.cna_fh - cb.changes = arg.cna_changes + cb.changes.extend(arg.cna_changes) cb.got_notify = True env.notify = cb.set # This is called after compound sent to queue def notify_post_hook(arg, env, res):
@@ -52,6 +52,7 @@ def _getDirDeleg(t, env, notify_mask, cb): cb.got_recall = False cb.got_notify = False + cb.changes = [] c = env.c1 sess1 = c.new_client_session(b"%s_1" % env.testname(t))
@@ -901,3 +902,100 @@ def testDirDelegSameClientNoNotify(t, env): fail("Got CB_NOTIFY for delegation holder's own change") if cb.got_recall: fail("Got CB_RECALL for delegation holder's own change") + +def testDirDelegCrossRenameOver(t, env): + """Verify cross-directory rename-over reports overwritten entry in nad_old_entry + + Per RFC 8881 Section 18.26.4, when a cross-directory rename + overwrites an existing file in the target directory, a + NOTIFY4_ADD_ENTRY is generated. When the removal is done + atomically with the rename, a separate NOTIFY4_REMOVE_ENTRY + notification will not be generated. Instead, the deletion of the + file will be reported as part of the NOTIFY4_ADD_ENTRY notification + via nad_old_entry. + + FLAGS: dirdeleg all + CODE: DIRDELEG21 + """ + c = env.c1 + cb = threading.Event() + + # Get a dir delegation on the target directory + sess1, fh, deleg = _getDirDeleg(t, env, + [NOTIFY4_ADD_ENTRY, + NOTIFY4_REMOVE_ENTRY, + NOTIFY4_GFLAG_EXTEND], cb) + + topdir = c.homedir + [t.code.encode('utf8')] + + # Create a file in the delegated directory (will be renamed over) + victim_name = b"%s_victim" % env.testname(t) + claim = open_claim4(CLAIM_NULL, victim_name) + owner = open_owner4(0, b"owner") + how = openflag4(OPEN4_CREATE, createhow4(GUARDED4, {FATTR4_SIZE:0})) + open_op = [ op.putfh(fh), op.open(0, + OPEN4_SHARE_ACCESS_WRITE | OPEN4_SHARE_ACCESS_WANT_NO_DELEG, + OPEN4_SHARE_DENY_NONE, owner, how, claim), op.getfh() ] + res = sess1.compound(open_op) + check(res) + open_stateid = res.resarray[-2].stateid + file_fh = res.resarray[-1].object + close_file(sess1, file_fh, stateid=open_stateid) + + # Create a source directory and a file in it + srcdir = c.homedir + [b"%s_src" % t.code.encode('utf8')] + res = create_obj(sess1, srcdir) + check(res) + src_fh = res.resarray[-1].object + + src_name = env.testname(t) + claim2 = open_claim4(CLAIM_NULL, src_name) + owner2 = open_owner4(0, b"owner2") + how2 = openflag4(OPEN4_CREATE, createhow4(GUARDED4, {FATTR4_SIZE:0})) + open_op = [ op.putfh(src_fh), op.open(0, + OPEN4_SHARE_ACCESS_WRITE | OPEN4_SHARE_ACCESS_WANT_NO_DELEG, + OPEN4_SHARE_DENY_NONE, owner2, how2, claim2), op.getfh() ] + res = sess1.compound(open_op) + check(res) + open_stateid2 = res.resarray[-2].stateid + file_fh2 = res.resarray[-1].object + close_file(sess1, file_fh2, stateid=open_stateid2) + + # Clear notification state from creates above + cb.clear() + cb.got_notify = False + + # Rename the source file over the victim in the delegated dir from sess2 + sess2 = c.new_client_session(b"%s_2" % env.testname(t)) + oldpath = srcdir + [src_name] + newpath = topdir + [victim_name] + res = rename_obj(sess2, oldpath, newpath) + check(res) + + completed = cb.wait(2) + if completed: + cb.clear() + cb.wait(1) + + delegreturn_op = [ op.putfh(fh), op.delegreturn(deleg) ] + res = sess1.compound(delegreturn_op) + check(res) + + if (not completed or not cb.got_notify): + fail("Didn't receive a CB_NOTIFY from the server!") + + # Look for ADD notification with nad_old_entry for the overwritten file + got_add = False + for change in cb.changes: + evt_type, evt = decode_notify_event(change) + if evt_type == NOTIFY4_ADD_ENTRY: + got_add = True + if evt.nad_new_entry.ne_file != victim_name: + fail("Wrong entry name in ADD notification") + if len(evt.nad_old_entry) != 1: + fail("Expected nad_old_entry to contain the overwritten entry") + if evt.nad_old_entry[0].nrm_old_entry.ne_file != victim_name: + fail("Wrong overwritten entry name in nad_old_entry") + + if not got_add: + fail("Missing ADD notification for cross-dir rename-over")
Signature · 1 line
2.53.0
Jeff Layton
maintainerPATCH v2 25/25 server41tests: test within-directory rename-over nad_old_entry
In reply to Jeff LaytonTest that when a within-directory rename overwrites an existing entry, the server populates nrn_new_entry.nad_old_entry in the NOTIFY4_RENAME_ENTRY notification with the overwritten entry's info.
--- nfs4.1/server41tests/st_dir_deleg.py | 65 ++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+)
nfs4.1/server41tests/st_dir_deleg.py +65 -0
@@ -999,3 +999,68 @@ def testDirDelegCrossRenameOver(t, env): if not got_add: fail("Missing ADD notification for cross-dir rename-over") + +def testDirDelegRenameOver(t, env): + """Verify within-directory rename-over populates nad_old_entry + + Per RFC 8881bis Section 27.4.6, when a within-directory rename + overwrites an existing entry, the overwritten entry's info is + reported in nrn_new_entry.nad_old_entry. + + FLAGS: dirdeleg all + CODE: DIRDELEG22 + """ + c = env.c1 + cb = threading.Event() + sess1, fh, deleg = _getDirDeleg(t, env, + [NOTIFY4_RENAME_ENTRY, + NOTIFY4_GFLAG_EXTEND], cb) + + # Create two files in the delegated directory from sess1 + src_name = env.testname(t) + victim_name = b"%s_victim" % env.testname(t) + owner = open_owner4(0, b"owner") + how = openflag4(OPEN4_CREATE, createhow4(GUARDED4, {FATTR4_SIZE:0})) + + for name in [src_name, victim_name]: + claim = open_claim4(CLAIM_NULL, name) + open_op = [ op.putfh(fh), op.open(0, + OPEN4_SHARE_ACCESS_WRITE | OPEN4_SHARE_ACCESS_WANT_NO_DELEG, + OPEN4_SHARE_DENY_NONE, owner, how, claim), op.getfh() ] + res = sess1.compound(open_op) + check(res) + open_stateid = res.resarray[-2].stateid + file_fh = res.resarray[-1].object + close_file(sess1, file_fh, stateid=open_stateid) + + # Rename src over victim from sess2 + sess2 = c.new_client_session(b"%s_2" % env.testname(t)) + rename_op = [ op.putfh(fh), op.savefh(), + op.putfh(fh), + op.rename(src_name, victim_name) ] + res = sess2.compound(rename_op) + check(res) + + completed = cb.wait(2) + if completed: + cb.clear() + cb.wait(1) + + delegreturn_op = [ op.putfh(fh), op.delegreturn(deleg) ] + res = sess1.compound(delegreturn_op) + check(res) + + if (not completed or not cb.got_notify): + fail("Didn't receive a CB_NOTIFY from the server!") + + evt_type, evt = decode_notify_event(cb.changes[0]) + if evt_type != NOTIFY4_RENAME_ENTRY: + fail("Expected RENAME notification, got %d" % evt_type) + if evt.nrn_old_entry.nrm_old_entry.ne_file != src_name: + fail("Wrong old entry name in RENAME notification") + if evt.nrn_new_entry.nad_new_entry.ne_file != victim_name: + fail("Wrong new entry name in RENAME notification") + if len(evt.nrn_new_entry.nad_old_entry) != 1: + fail("Expected nad_old_entry to contain the overwritten entry") + if evt.nrn_new_entry.nad_old_entry[0].nrm_old_entry.ne_file != victim_name: + fail("Wrong overwritten entry name in nad_old_entry")
Signature · 1 line
2.53.0