[PATCH pynfs v3 21/26] server41tests: test cross-directory rename ADD notification on target
Jeff Layton <[email protected]>
| Newsgroups | gmane.linux.nfs |
|---|---|
| Message-ID | <[email protected]> |
Verify that a cross-directory rename generates a NOTIFY4_ADD_ENTRY notification on the target directory's delegation. Signed-off-by: Jeff Layton <[email protected]> --- nfs4.1/server41tests/st_dir_deleg.py | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/nfs4.1/server41tests/st_dir_deleg.py b/nfs4.1/server41tests/st_dir_deleg.py index 0751cf1ec47e..43e9ce4cb4d2 100644 --- a/nfs4.1/server41tests/st_dir_deleg.py +++ b/nfs4.1/server41tests/st_dir_deleg.py @@ -795,3 +795,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") -- 2.54.0