nfs4.1: add some basic directory delegation tests
Subsystems (2)
Jeff Layton
maintainercover nfs4.1: add some basic directory delegation tests
Add basic support for testing both GET_DIR_DELEGATION operations and CB_NOTIFY.
---
Jeff Layton (7):
nfs4.1: add proposed NOTIFY4_GFLAG_EXTEND flag
pynfs: 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: add a test for removal from dir with dir delegation
server41tests: add a test for diretory add notifications
server41tests: add test for rename event notifications
nfs4.1/nfs4client.py | 6 + nfs4.1/server41tests/__init__.py | 1 + nfs4.1/server41tests/environment.py | 2 +- nfs4.1/server41tests/st_dir_deleg.py | 221 +++++++++++++++++++++++++++++++++++ nfs4.1/xdrdef/nfs4.x | 3 +- 5 files changed, 231 insertions(+), 2 deletions(-)
---
base-commit: 3c14d9e3ad12272ab2f6092c85bb28ab03951484
change-id: 20250930-dir-deleg-4ae7364fb398
Best regards,
Signature · 1 line
Jeff Layton <[email protected]>
Jeff Layton
maintainerPATCH 1/7 nfs4.1: add proposed NOTIFY4_GFLAG_EXTEND flag
--- 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.51.0
Jeff Layton
maintainerPATCH 2/7 pynfs: add a getfh() to the end of create_obj() compound
In reply to Jeff Layton--- 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.51.0
Jeff Layton
maintainerPATCH 3/7 server41tests: add a basic GET_DIR_DELEGATION test
In reply to Jeff Layton--- nfs4.1/nfs4client.py | 6 +++ nfs4.1/server41tests/__init__.py | 1 + nfs4.1/server41tests/st_dir_deleg.py | 77 ++++++++++++++++++++++++++++++++++++ 3 files changed, 84 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_layoutrecall(self, arg, env): log_cb.info("In CB_LAYOUTRECALL") self.prehook(arg, env)
nfs4.1/server41tests/__init__.py +1 -0
@@ -11,6 +11,7 @@ __all__ = ["st_exchange_id.py", # draft 21 "st_trunking.py", "st_open.py", "st_delegation.py", + "st_dir_deleg.py", "st_verify.py", "st_getdevicelist.py", "st_lookupp.py",
nfs4.1/server41tests/st_dir_deleg.py new file +77 -0
77 lines not on this page · raw message
Signature · 1 line
2.51.0
Jeff Layton
maintainerPATCH 4/7 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
@@ -75,3 +75,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.51.0
Jeff Layton
maintainerPATCH 5/7 server41tests: add a test for removal from dir with dir delegation
In reply to Jeff Layton...and actually request attributes in the GET_DIR_DELEGATION request.
--- nfs4.1/server41tests/st_dir_deleg.py | 53 ++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-)
nfs4.1/server41tests/st_dir_deleg.py +51 -2
@@ -43,8 +43,26 @@ def _getDirDeleg(t, env, notify_mask, cb): 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) deleg = res.resarray[-1].gddrnf_resok4.gddr_stateid
@@ -101,3 +119,34 @@ def testDirDelegDuplicate(t, env): ops = [ op.putfh(fh), op.delegreturn(deleg) ] res = sess1.compound(ops) check(res) + +def testDirDelegRemove(t, env): + """Create a dir_deleg that accepts notification of REMOVE events + + FLAGS: dirdeleg all + CODE: DIRDELEG3 + """ + c = env.c1 + cb = threading.Event() + sess1, fh, deleg = _getDirDeleg(t, env, [NOTIFY4_CHANGE_DIR_ATTRS, NOTIFY4_REMOVE_ENTRY], 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)) + 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!")
Signature · 1 line
2.51.0
Jeff Layton
maintainerPATCH 6/7 server41tests: add a test for diretory add notifications
In reply to Jeff Layton--- nfs4.1/server41tests/st_dir_deleg.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
nfs4.1/server41tests/st_dir_deleg.py +33 -0
@@ -150,3 +150,36 @@ def testDirDelegRemove(t, env): if (not completed or not cb.got_notify): fail("Didn't receive a CB_NOTIFY from the server!") + +def testDirDelegAdd(t, env): + """Create a dir_deleg that accepts notification of ADD events + + FLAGS: dirdeleg all + CODE: DIRDELEG4 + """ + 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), 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!")
Signature · 1 line
2.51.0
Jeff Layton
maintainerPATCH 7/7 server41tests: add test for rename event notifications
In reply to Jeff LaytonAdd a test of notifications for renames within the same dir.
--- nfs4.1/server41tests/st_dir_deleg.py | 38 +++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-)
nfs4.1/server41tests/st_dir_deleg.py +37 -1
@@ -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_obj, use_obj +from .environment import check, fail, create_obj, use_obj, rename_obj from xdrdef.nfs4_type import * import nfs_ops op = nfs_ops.NFS4ops()
@@ -183,3 +183,39 @@ def testDirDelegAdd(t, env): if (not completed or not cb.got_notify): fail("Didn't receive a CB_NOTIFY from the server!") + +def testDirDelegRename(t, env): + """Create a dir_deleg that accepts notification of RENAME events + + FLAGS: dirdeleg all + CODE: DIRDELEG5 + """ + c = env.c1 + cb = threading.Event() + + sess1, fh, deleg = _getDirDeleg(t, env, [NOTIFY4_RENAME_ENTRY], 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!")
Signature · 1 line
2.51.0
Quoted 20 lines · Jeff Layton
Add basic support for testing both
GET_DIR_DELEGATIONoperations andCB_NOTIFY.Signed-off-by Jeff Layton <[email protected]>---
Jeff Layton (7):
nfs4.1: add proposedNOTIFY4_GFLAG_EXTENDflag
pynfs: add agetfh()to the end ofcreate_obj()compound
server41tests: add a basicGET_DIR_DELEGATIONtest
server41tests: add a test for duplicateGET_DIR_DELEGATIONrequests
server41tests: add a test for removal from dir with dir delegation
server41tests: add a test for diretory add notifications
server41tests: add test for rename event notificationsnfs4.1/nfs4client.py | 6 + nfs4.1/server41tests/__init__.py | 1 + nfs4.1/server41tests/environment.py | 2 +- nfs4.1/server41tests/st_dir_deleg.py | 221 +++++++++++++++++++++++++++++++++++ nfs4.1/xdrdef/nfs4.x | 3 +- 5 files changed, 231 insertions(+), 2 deletions(-)
Quoted 5 lines
---
base-commit:3c14d9e3ad12272ab2f6092c85bb28ab03951484
change-id: 20250930-dir-deleg-4ae7364fb398Best regards,
But one question: should these new tests not be in the "all" group? Seems like most NFS server implementations won't support directory delegations.
Signature · 1 line
Chuck Lever
Jeff Layton
maintainerQuoted 25 lines · Chuck Lever
Quoted 24 lines · Jeff Layton
Add basic support for testing both
GET_DIR_DELEGATIONoperations andCB_NOTIFY.Signed-off-by Jeff Layton <[email protected]>---
Jeff Layton (7):
nfs4.1: add proposedNOTIFY4_GFLAG_EXTENDflag
pynfs: add agetfh()to the end ofcreate_obj()compound
server41tests: add a basicGET_DIR_DELEGATIONtest
server41tests: add a test for duplicateGET_DIR_DELEGATIONrequests
server41tests: add a test for removal from dir with dir delegation
server41tests: add a test for diretory add notifications
server41tests: add test for rename event notificationsnfs4.1/nfs4client.py | 6 + nfs4.1/server41tests/__init__.py | 1 + nfs4.1/server41tests/environment.py | 2 +- nfs4.1/server41tests/st_dir_deleg.py | 221 +++++++++++++++++++++++++++++++++++ nfs4.1/xdrdef/nfs4.x | 3 +- 5 files changed, 231 insertions(+), 2 deletions(-)---
base-commit:3c14d9e3ad12272ab2f6092c85bb28ab03951484
change-id: 20250930-dir-deleg-4ae7364fb398
Quoted 8 lines
Quoted 1 line
Best regards,
Reviewed-by Chuck Lever <[email protected]>But one question: should these new tests not be in the "all" group? Seems like most NFS server implementations won't support directory delegations.
I had meant to remove that group before posting and then forgot about it. That is a good point though...
Ideally what would best would be to try and run it, and just make it a non-fatal error if the initial GET_DIR_DELEGATION fails? Maybe just make it pass_warn() in that case?
I like that idea better than hiding this away where we forget to run it. I'll see what I can put together.
Thanks,
Signature · 1 line
Jeff Layton <[email protected]>