flex: add ffl_flags validation test
Subsystems (2)
PATCH 1/1 flex: add ffl_flags validation test
Add FFFL1 which verifies that the ffl_flags field in the LAYOUTGET response contains only bits defined in RFC 8435 Section 5.1:NO_LAYOUTCOMMIT, NO_IO_THRU_MDS, and NO_READ_IO. The three flag constants were already defined in nfs4_const.py but had no test coverage.
--- nfs4.1/server41tests/st_flex.py | 48 +++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+)
nfs4.1/server41tests/st_flex.py +48 -0
@@ -1117,3 +1117,51 @@ def testFlexLayoutReturn100(t, env): # Close file res = close_file(sess, fh, stateid=open_stateid) check(res) + +def testFlexFlags(t, env): + """Verify ffl_flags contains only valid RFC 8435 bits. + + FLAGS: flex + CODE: FFFL1 + """ + sess = env.c1.new_pnfs_client_session(env.testname(t)) + + # Create file + res = create_file(sess, env.testname(t)) + check(res) + fh = res.resarray[-1].object + open_stateid = res.resarray[-2].stateid + + # LAYOUTGET + ops = [op.putfh(fh), + op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_RW, + 0, 8192, 8192, open_stateid, 0xffff)] + res = sess.compound(ops) + check(res) + lo_stateid = res.resarray[-1].logr_stateid + + # Unpack ff_layout4 and check ffl_flags + layout = res.resarray[-1].logr_layout[-1] + p = FlexUnpacker(layout.loc_body) + opaque = p.unpack_ff_layout4() + + valid_flags = (FF_FLAGS_NO_LAYOUTCOMMIT | + FF_FLAGS_NO_IO_THRU_MDS | + FF_FLAGS_NO_READ_IO) + if opaque.ffl_flags & ~valid_flags: + t.fail("ffl_flags 0x%x has undefined bits set (valid: 0x%x)" + % (opaque.ffl_flags, valid_flags)) + + # LAYOUTRETURN + ops = [op.putfh(fh), + op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY, + layoutreturn4(LAYOUTRETURN4_FILE, + layoutreturn_file4(0, NFS4_MAXFILELEN, + lo_stateid, + empty_p.get_buffer())))] + res = sess.compound(ops) + check(res) + + # Close file + res = close_file(sess, fh, stateid=open_stateid) + check(res)
Signature · 1 line
2.54.0
Jeff Layton
maintainerQuoted 57 lines · Minxi Hou
Add FFFL1 which verifies that the
ffl_flagsfield in the LAYOUTGET response contains only bits defined in RFC 8435 Section 5.1:NO_LAYOUTCOMMIT,NO_IO_THRU_MDS, andNO_READ_IO. The three flag constants were already defined innfs4_const.pybut had no test coverage.Signed-off-by Minxi Hou <[email protected]>--- nfs4.1/server41tests/st_flex.py | 48 +++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+)nfs4.1/server41tests/st_flex.py +38
-0@@ -1117,3 +1117,51 @@ def testFlexLayoutReturn100(t, env): # Close file res = close_file(sess, fh, stateid=open_stateid) check(res) + +def testFlexFlags(t, env): + """Verify ffl_flags contains only valid RFC 8435 bits. + + FLAGS: flex + CODE: FFFL1 + """ + sess = env.c1.new_pnfs_client_session(env.testname(t)) + + # Create file + res = create_file(sess, env.testname(t)) + check(res) + fh = res.resarray[-1].object + open_stateid = res.resarray[-2].stateid + + # LAYOUTGET + ops = [op.putfh(fh), + op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_RW, + 0, 8192, 8192, open_stateid, 0xffff)] + res = sess.compound(ops) + check(res) + lo_stateid = res.resarray[-1].logr_stateid + + # Unpack ff_layout4 and check ffl_flags + layout = res.resarray[-1].logr_layout[-1] + p = FlexUnpacker(layout.loc_body) + opaque = p.unpack_ff_layout4() + + valid_flags = (FF_FLAGS_NO_LAYOUTCOMMIT | + FF_FLAGS_NO_IO_THRU_MDS | + FF_FLAGS_NO_READ_IO) + if opaque.ffl_flags & ~valid_flags: + t.fail("ffl_flags 0x%x has undefined bits set (valid: 0x%x)" + % (opaque.ffl_flags, valid_flags)) + + # LAYOUTRETURN + ops = [op.putfh(fh), + op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY,
nfs4.1/server41tests/st_flex.py def testFlexLayoutReturn100(t, env): · line 1167
Quoted 10 lines
nfs4.1/server41tests/st_flex.py +10
-0+ layoutreturn4(LAYOUTRETURN4_FILE, + layoutreturn_file4(0, NFS4_MAXFILELEN, + lo_stateid, + empty_p.get_buffer())))] + res = sess.compound(ops) + check(res) + + # Close file + res = close_file(sess, fh, stateid=open_stateid) + check(res)
Could you take a look at the pull request here and address Chuck's comments?
https://github.com/linux-nfs/pynfs/pull/13
Thanks,
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 4 lines · Jeff Layton
Could you take a look at the pull request here and address Chuck's comments?
Thanks, Jeff. I left a reply on PR #13 covering the XDR question and the review comments on st_flex.py:
https://github.com/linux-nfs/pynfs/pull/13#issuecomment-7031195467
Best regards,
Minxi Hou