Skip to contentSkip to conversation

Python3 patches for st_flex.py

PATCH In review Tom Haynes 3 participants 10 messages Dec 19, 2020 – Dec 21, 2020

Subsystems (2)
lore
Share & tools
lore

Tom Haynes

author
#0 lore raw

cover Python3 patches for st_flex.py

From: Tom Haynes <[email protected]>

Hey Bruce,

This applies on top of the previous patch set.

This passes on my RHEL 8.2 client running python3 against a Hammerspace server.

Thanks,
Tom

fwiw - In some of the error paths, the system would complain that the exception StandardError was not defined.

I found this:
https://portingguide.readthedocs.io/en/latest/exceptions.html#the-removed-standarderror

Tom Haynes (7):
CB_LAYOUTRECALL: Make string a byte array
st_flex: Use NFS4_MAXFILELEN in layout calls
st_flex: Provide an empty ff_layoutreturn4 by default for LAYOUTRETURN
st_flex: Use range instead of xrange for python3
st_flex: Test is now redundant
st_flex: Return the layout before closing the file
st_flex: testFlexLayoutStatsSmall needed loving to pass python3

 nfs4.1/nfs4client.py            |   2 +-
 nfs4.1/server41tests/st_flex.py | 124 +++++++++++++++++---------------
 2 files changed, 68 insertions(+), 58 deletions(-)
Signature · 1 line
2.26.2
author
#1 lore raw

PATCH 1/7 CB_LAYOUTRECALL: Make string a byte array

From: Tom Haynes <[email protected]>

---
 nfs4.1/nfs4client.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
nfs4.1/nfs4client.py +1 -1
index f06d9c5..df573d6 100644
@@ -296,7 +296,7 @@ class NFS4Client(rpc.Client, rpc.Server):
                       layoutreturn4(LAYOUTRETURN4_FILE,
                                     layoutreturn_file4(rclayout.lor_offset,
                                                        rclayout.lor_length, \
-                                                       rclayout.lor_stateid, "")))]
+                                                       rclayout.lor_stateid, b"")))]
             env.session.compound(ops)
         elif lo_recalltype not in [LAYOUTRECALL4_FSID, LAYOUTRECALL4_ALL]:
             res = NFS4ERR_NOTSUPP
Signature · 1 line
2.26.2
author
#2 lore raw

PATCH 2/7 st_flex: Use NFS4_MAXFILELEN in layout calls

In reply to Tom Haynes

From: Tom Haynes <[email protected]>

---
 nfs4.1/server41tests/st_flex.py | 50 ++++++++++++++++-----------------
 1 file changed, 25 insertions(+), 25 deletions(-)
nfs4.1/server41tests/st_flex.py +25 -25
index d70b216..8150054 100644
@@ -5,7 +5,7 @@ import nfs_ops
 op = nfs_ops.NFS4ops()
 from .environment import check, fail, create_file, close_file, open_create_file_op
 from xdrdef.nfs4_pack import NFS4Packer as FlexPacker, \
-	NFS4Unpacker as FlexUnpacker
+    NFS4Unpacker as FlexUnpacker
 from nfs4lib import FancyNFS4Packer, get_nfstime
 
 current_stateid = stateid4(1, '\0' * 12)
@@ -69,11 +69,11 @@ def testFlexGetLayout(t, env):
     open_stateid = res.resarray[-2].stateid
     ops = [op.putfh(fh),
            op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_READ,
-                        0, 0xffffffffffffffff, 4196, open_stateid, 0xffff)]
+                        0, NFS4_MAXFILELEN, 4196, open_stateid, 0xffff)]
     res = sess.compound(ops)
     check(res)
     # Parse opaque
-    for layout in  res.resarray[-1].logr_layout:
+    for layout in res.resarray[-1].logr_layout:
         if layout.loc_type == LAYOUT4_FLEX_FILES:
             p = FlexUnpacker(layout.loc_body)
             opaque = p.unpack_ff_layout4()
@@ -98,7 +98,7 @@ def testFlexLayoutReturnFile(t, env):
     open_stateid = res.resarray[-2].stateid
     ops = [op.putfh(fh),
            op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_READ,
-                        0, 0xffffffffffffffff, 4196, open_stateid, 0xffff)]
+                        0, NFS4_MAXFILELEN, 4196, open_stateid, 0xffff)]
     res = sess.compound(ops)
     check(res)
     # Return layout
@@ -106,7 +106,7 @@ def testFlexLayoutReturnFile(t, env):
     ops = [op.putfh(fh),
            op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY,
                            layoutreturn4(LAYOUTRETURN4_FILE,
-                                         layoutreturn_file4(0, 0xffffffffffffffff, layout_stateid, "")))]
+                                         layoutreturn_file4(0, NFS4_MAXFILELEN, layout_stateid, "")))]
     res = sess.compound(ops)
     check(res)
     res = close_file(sess, fh, stateid=open_stateid)
@@ -132,7 +132,7 @@ def testFlexLayoutOldSeqid(t, env):
     ops = [op.putfh(fh),
            op.layoutget(False, LAYOUT4_FLEX_FILES,
                         LAYOUTIOMODE4_RW,
-                        0, 0xffffffffffffffff, 8192, open_stateid, 0xffff)]
+                        0, NFS4_MAXFILELEN, 8192, open_stateid, 0xffff)]
     res = sess.compound(ops)
     check(res)
     lo_stateid = res.resarray[-1].logr_stateid
@@ -144,7 +144,7 @@ def testFlexLayoutOldSeqid(t, env):
     ops = [op.putfh(fh),
            op.layoutget(False, LAYOUT4_FLEX_FILES,
                         LAYOUTIOMODE4_RW,
-                        0, 0xffffffffffffffff, 8192, lo_stateid, 0xffff)]
+                        0, NFS4_MAXFILELEN, 8192, lo_stateid, 0xffff)]
     res = sess.compound(ops)
     check(res)
     lo_stateid2 = res.resarray[-1].logr_stateid
@@ -156,7 +156,7 @@ def testFlexLayoutOldSeqid(t, env):
     ops = [op.putfh(fh),
            op.layoutget(False, LAYOUT4_FLEX_FILES,
                         LAYOUTIOMODE4_RW,
-                        0, 0xffffffffffffffff, 8192, lo_stateid, 0xffff)]
+                        0, NFS4_MAXFILELEN, 8192, lo_stateid, 0xffff)]
     res = sess.compound(ops)
     check(res)
     lo_stateid3 = res.resarray[-1].logr_stateid
@@ -167,7 +167,7 @@ def testFlexLayoutOldSeqid(t, env):
     ops = [op.putfh(fh),
            op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY,
                            layoutreturn4(LAYOUTRETURN4_FILE,
-                                         layoutreturn_file4(0, 0xffffffffffffffff, lo_stateid, "")))]
+                                         layoutreturn_file4(0, NFS4_MAXFILELEN, lo_stateid, "")))]
     res = sess.compound(ops)
     check(res, NFS4ERR_OLD_STATEID, "LAYOUTRETURN with an old stateid")
     res = close_file(sess, fh, stateid=open_stateid)
@@ -192,8 +192,8 @@ def testFlexLayoutStress(t, env):
     for i in range(1000):
         ops = [op.putfh(fh),
                op.layoutget(False, LAYOUT4_FLEX_FILES,
-                            LAYOUTIOMODE4_READ if i%2  else LAYOUTIOMODE4_RW,
-                            0, 0xffffffffffffffff, 8192, lo_stateid, 0xffff)]
+                            LAYOUTIOMODE4_READ if i%2 else LAYOUTIOMODE4_RW,
+                            0, NFS4_MAXFILELEN, 8192, lo_stateid, 0xffff)]
         res = sess.compound(ops)
         check(res)
         lo_stateid = res.resarray[-1].logr_stateid
@@ -203,7 +203,7 @@ def testFlexLayoutStress(t, env):
     ops = [op.putfh(fh),
            op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY,
                            layoutreturn4(LAYOUTRETURN4_FILE,
-                                         layoutreturn_file4(0, 0xffffffffffffffff, lo_stateid, "")))]
+                                         layoutreturn_file4(0, NFS4_MAXFILELEN, lo_stateid, "")))]
     res = sess.compound(ops)
     check(res)
     res = close_file(sess, fh, stateid=open_stateid)
@@ -227,7 +227,7 @@ def testFlexGetDevInfo(t, env):
     ops = [op.putfh(fh),
            op.layoutget(False, LAYOUT4_FLEX_FILES,
                         LAYOUTIOMODE4_RW,
-                        0, 0xffffffffffffffff, 8192, lo_stateid, 0xffff)]
+                        0, NFS4_MAXFILELEN, 8192, lo_stateid, 0xffff)]
     res = sess.compound(ops)
     check(res)
     lo_stateid = res.resarray[-1].logr_stateid
@@ -251,7 +251,7 @@ def testFlexGetDevInfo(t, env):
     ops = [op.putfh(fh),
            op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY,
                            layoutreturn4(LAYOUTRETURN4_FILE,
-                                         layoutreturn_file4(0, 0xffffffffffffffff, lo_stateid, "")))]
+                                         layoutreturn_file4(0, NFS4_MAXFILELEN, lo_stateid, "")))]
     res = sess.compound(ops)
     check(res)
     res = close_file(sess, fh, stateid=open_stateid)
@@ -275,7 +275,7 @@ def testFlexLayoutTestAccess(t, env):
     ops = [op.putfh(fh),
            op.layoutget(False, LAYOUT4_FLEX_FILES,
                         LAYOUTIOMODE4_RW,
-                        0, 0xffffffffffffffff, 8192, open_stateid, 0xffff)]
+                        0, NFS4_MAXFILELEN, 8192, open_stateid, 0xffff)]
     res = sess.compound(ops)
     check(res)
     lo_stateid = res.resarray[-1].logr_stateid
@@ -295,7 +295,7 @@ def testFlexLayoutTestAccess(t, env):
     ops = [op.putfh(fh),
            op.layoutget(False, LAYOUT4_FLEX_FILES,
                         LAYOUTIOMODE4_READ,
-                        0, 0xffffffffffffffff, 8192, lo_stateid, 0xffff)]
+                        0, NFS4_MAXFILELEN, 8192, lo_stateid, 0xffff)]
     res = sess.compound(ops)
     check(res)
     lo_stateid = res.resarray[-1].logr_stateid
@@ -342,7 +342,7 @@ def testFlexLayoutStatsSmall(t, env):
         open_op = open_create_file_op(sess, env.testname(t) + str(i), open_create=OPEN4_CREATE)
         res = sess.compound( open_op +
                [op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_RW,
-                            0, 0xffffffffffffffff, 4196, current_stateid, 0xffff)])
+                            0, NFS4_MAXFILELEN, 4196, current_stateid, 0xffff)])
         check(res, NFS4_OK)
         lo_stateid = res.resarray[-1].logr_stateid
         fh = res.resarray[-2].object
@@ -395,7 +395,7 @@ def testFlexLayoutStatsSmall(t, env):
         ops = [op.putfh(fh),
                op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY,
                                layoutreturn4(LAYOUTRETURN4_FILE,
-                                             layoutreturn_file4(0, 0xffffffffffffffff, lo_stateid, p.get_buffer()))),
+                                             layoutreturn_file4(0, NFS4_MAXFILELEN, lo_stateid, p.get_buffer()))),
                op.close(0, open_stateid)]
         res = sess.compound(ops)
         check(res)
@@ -415,7 +415,7 @@ def _LayoutStats(t, env, stats):
     ops = [op.putfh(fh),
            op.layoutget(False, LAYOUT4_FLEX_FILES,
                         LAYOUTIOMODE4_RW,
-                        0, 0xffffffffffffffff, 8192, lo_stateid, 0xffff)]
+                        0, NFS4_MAXFILELEN, 8192, lo_stateid, 0xffff)]
     res = sess.compound(ops)
     check(res)
     lo_stateid = res.resarray[-1].logr_stateid
@@ -455,7 +455,7 @@ def _LayoutStats(t, env, stats):
 
         # Did not capture these in the gathered traces
         offset = 0
-        file_length = 0xffffffffffffffff
+        file_length = NFS4_MAXFILELEN
         rd_io.ii_count = 0
         rd_io.ii_bytes = 0
         wr_io.ii_count = 0
@@ -492,7 +492,7 @@ def _LayoutStats(t, env, stats):
     ops = [op.putfh(fh),
            op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY,
                            layoutreturn4(LAYOUTRETURN4_FILE,
-                                         layoutreturn_file4(0, 0xffffffffffffffff, lo_stateid, "")))]
+                                         layoutreturn_file4(0, NFS4_MAXFILELEN, lo_stateid, "")))]
     res = sess.compound(ops)
     check(res)
     res = close_file(sess, fh, stateid=open_stateid)
@@ -602,7 +602,7 @@ def layoutget_return(sess, fh, open_stateid, allowed_errors=NFS4_OK,
     # Get layout
     ops = [op.putfh(fh),
            op.layoutget(False, LAYOUT4_FLEX_FILES, layout_iomode,
-                        0, NFS4_UINT64_MAX, 4196, open_stateid, 0xffff)]
+                        0, NFS4_MAXFILELEN, 4196, open_stateid, 0xffff)]
     res = sess.compound(ops)
     check(res, allowed_errors)
     if nfsstat4[res.status] is not 'NFS4_OK':
@@ -614,7 +614,7 @@ def layoutget_return(sess, fh, open_stateid, allowed_errors=NFS4_OK,
         ops = [op.putfh(fh),
                op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY,
                                layoutreturn4(LAYOUTRETURN4_FILE,
-                                             layoutreturn_file4(0, NFS4_UINT64_MAX,
+                                             layoutreturn_file4(0, NFS4_MAXFILELEN,
                                                                 layout_stateid, "")))]
     else:  # Return layout with error
         # Get device id
@@ -625,7 +625,7 @@ def layoutget_return(sess, fh, open_stateid, allowed_errors=NFS4_OK,
 
         deviceid = layout.ffl_mirrors[0].ffm_data_servers[0].ffds_deviceid
         deverr = device_error4(deviceid, layout_error, layout_error_op)
-        ffioerr = ff_ioerr4(0, NFS4_UINT64_MAX, layout_stateid, [deverr])
+        ffioerr = ff_ioerr4(0, NFS4_MAXFILELEN, layout_stateid, [deverr])
         fflr = ff_layoutreturn4([ffioerr], [])
 
         p = FlexPacker()
@@ -634,7 +634,7 @@ def layoutget_return(sess, fh, open_stateid, allowed_errors=NFS4_OK,
         ops = [op.putfh(fh),
                op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY,
                                layoutreturn4(LAYOUTRETURN4_FILE,
-                                             layoutreturn_file4(0, NFS4_UINT64_MAX,
+                                             layoutreturn_file4(0, NFS4_MAXFILELEN,
                                                                 layout_stateid,
                                                                 p.get_buffer())))]
 
Signature · 1 line
2.26.2
author
#3 lore raw

PATCH 3/7 st_flex: Provide an empty ff_layoutreturn4 by default for LAYOUTRETURN

In reply to Tom Haynes

From: Tom Haynes <[email protected]>

---
 nfs4.1/server41tests/st_flex.py | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)
nfs4.1/server41tests/st_flex.py +19 -7
index 8150054..7036271 100644
@@ -10,6 +10,11 @@ from nfs4lib import FancyNFS4Packer, get_nfstime
 
 current_stateid = stateid4(1, '\0' * 12)
 
+empty_fflr = ff_layoutreturn4([], [])
+
+empty_p = FlexPacker()
+empty_p.pack_ff_layoutreturn4(empty_fflr)
+
 def check_seqid(stateid, seqid):
     if stateid.seqid != seqid:
         fail("Expected stateid.seqid==%i, got %i" % (seqid, stateid.seqid))
@@ -103,10 +108,12 @@ def testFlexLayoutReturnFile(t, env):
     check(res)
     # Return layout
     layout_stateid = res.resarray[-1].logr_stateid
+
     ops = [op.putfh(fh),
            op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY,
                            layoutreturn4(LAYOUTRETURN4_FILE,
-                                         layoutreturn_file4(0, NFS4_MAXFILELEN, layout_stateid, "")))]
+                                         layoutreturn_file4(0, NFS4_MAXFILELEN,
+                                                            layout_stateid, empty_p.get_buffer())))]
     res = sess.compound(ops)
     check(res)
     res = close_file(sess, fh, stateid=open_stateid)
@@ -167,7 +174,8 @@ def testFlexLayoutOldSeqid(t, env):
     ops = [op.putfh(fh),
            op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY,
                            layoutreturn4(LAYOUTRETURN4_FILE,
-                                         layoutreturn_file4(0, NFS4_MAXFILELEN, lo_stateid, "")))]
+                                         layoutreturn_file4(0, NFS4_MAXFILELEN,
+                                                            lo_stateid, empty_p.get_buffer())))]
     res = sess.compound(ops)
     check(res, NFS4ERR_OLD_STATEID, "LAYOUTRETURN with an old stateid")
     res = close_file(sess, fh, stateid=open_stateid)
@@ -203,7 +211,8 @@ def testFlexLayoutStress(t, env):
     ops = [op.putfh(fh),
            op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY,
                            layoutreturn4(LAYOUTRETURN4_FILE,
-                                         layoutreturn_file4(0, NFS4_MAXFILELEN, lo_stateid, "")))]
+                                         layoutreturn_file4(0, NFS4_MAXFILELEN,
+                                                            lo_stateid, empty_p.get_buffer())))]
     res = sess.compound(ops)
     check(res)
     res = close_file(sess, fh, stateid=open_stateid)
@@ -251,7 +260,8 @@ def testFlexGetDevInfo(t, env):
     ops = [op.putfh(fh),
            op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY,
                            layoutreturn4(LAYOUTRETURN4_FILE,
-                                         layoutreturn_file4(0, NFS4_MAXFILELEN, lo_stateid, "")))]
+                                         layoutreturn_file4(0, NFS4_MAXFILELEN,
+                                                            lo_stateid, empty_p.get_buffer())))]
     res = sess.compound(ops)
     check(res)
     res = close_file(sess, fh, stateid=open_stateid)
@@ -395,7 +405,8 @@ def testFlexLayoutStatsSmall(t, env):
         ops = [op.putfh(fh),
                op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY,
                                layoutreturn4(LAYOUTRETURN4_FILE,
-                                             layoutreturn_file4(0, NFS4_MAXFILELEN, lo_stateid, p.get_buffer()))),
+                                             layoutreturn_file4(0, NFS4_MAXFILELEN,
+                                                                lo_stateid, p.get_buffer()))),
                op.close(0, open_stateid)]
         res = sess.compound(ops)
         check(res)
@@ -492,7 +503,8 @@ def _LayoutStats(t, env, stats):
     ops = [op.putfh(fh),
            op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY,
                            layoutreturn4(LAYOUTRETURN4_FILE,
-                                         layoutreturn_file4(0, NFS4_MAXFILELEN, lo_stateid, "")))]
+                                         layoutreturn_file4(0, NFS4_MAXFILELEN,
+                                                            lo_stateid, empty_p.get_buffer())))]
     res = sess.compound(ops)
     check(res)
     res = close_file(sess, fh, stateid=open_stateid)
@@ -615,7 +627,7 @@ def layoutget_return(sess, fh, open_stateid, allowed_errors=NFS4_OK,
                op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY,
                                layoutreturn4(LAYOUTRETURN4_FILE,
                                              layoutreturn_file4(0, NFS4_MAXFILELEN,
-                                                                layout_stateid, "")))]
+                                                                layout_stateid, empty_p.get_buffer())))]
     else:  # Return layout with error
         # Get device id
         locb = res.resarray[-1].logr_layout[0].lo_content.loc_body
Signature · 1 line
2.26.2
author
#4 lore raw

PATCH 4/7 st_flex: Use range instead of xrange for python3

In reply to Tom Haynes

From: Tom Haynes <[email protected]>

---
 nfs4.1/server41tests/st_flex.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
nfs4.1/server41tests/st_flex.py +1 -1
index 7036271..80f5a85 100644
@@ -1106,7 +1106,7 @@ def testFlexLayoutReturn100(t, env):
     fh = res.resarray[-1].object
     open_stateid = res.resarray[-2].stateid
 
-    for i in xrange(count):
+    for i in range(count):
         layout_error = None if i % layout_error_ratio else NFS4ERR_ACCESS
         layoutget_return(sess, fh, open_stateid, layout_error=layout_error)
 
Signature · 1 line
2.26.2
author
#5 lore raw

PATCH 5/7 st_flex: Test is now redundant

In reply to Tom Haynes

From: Tom Haynes <[email protected]>

---
 nfs4.1/server41tests/st_flex.py | 28 ----------------------------
 1 file changed, 28 deletions(-)
nfs4.1/server41tests/st_flex.py +0 -28
index 80f5a85..3aae441 100644
@@ -59,39 +59,11 @@ def testStateid1(t, env):
     res = close_file(sess, fh, stateid=open_stateid)
     check(res)
 
-def testFlexGetLayout(t, env):
-    """Verify layout handling
-
-    FLAGS: flex
-    CODE: FFGLO1
-    """
-    sess = env.c1.new_pnfs_client_session(env.testname(t))
-    # Create the file
-    res = create_file(sess, env.testname(t))
-    check(res)
-    # Get layout
-    fh = res.resarray[-1].object
-    open_stateid = res.resarray[-2].stateid
-    ops = [op.putfh(fh),
-           op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_READ,
-                        0, NFS4_MAXFILELEN, 4196, open_stateid, 0xffff)]
-    res = sess.compound(ops)
-    check(res)
-    # Parse opaque
-    for layout in res.resarray[-1].logr_layout:
-        if layout.loc_type == LAYOUT4_FLEX_FILES:
-            p = FlexUnpacker(layout.loc_body)
-            opaque = p.unpack_ff_layout4()
-            p.done()
-    res = close_file(sess, fh, stateid=open_stateid)
-    check(res)
-
 def testFlexLayoutReturnFile(t, env):
     """
     Return a file's layout
 
     FLAGS: flex
-    DEPEND: FFGLO1
     CODE: FFLOR1
     """
     sess = env.c1.new_pnfs_client_session(env.testname(t))
Signature · 1 line
2.26.2
author
#6 lore raw

PATCH 6/7 st_flex: Return the layout before closing the file

In reply to Tom Haynes

From: Tom Haynes <[email protected]>

---
 nfs4.1/server41tests/st_flex.py | 40 +++++++++++++++++++++++++++------
 1 file changed, 33 insertions(+), 7 deletions(-)
nfs4.1/server41tests/st_flex.py +33 -7
index 3aae441..2b1820c 100644
@@ -56,6 +56,15 @@ def testStateid1(t, env):
         # the server increments by one the value of the "seqid" in each
         # subsequent LAYOUTGET and LAYOUTRETURN response,
         check_seqid(lo_stateid, i + 2)
+
+    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)
+
     res = close_file(sess, fh, stateid=open_stateid)
     check(res)
 
@@ -79,13 +88,13 @@ def testFlexLayoutReturnFile(t, env):
     res = sess.compound(ops)
     check(res)
     # Return layout
-    layout_stateid = res.resarray[-1].logr_stateid
+    lo_stateid = res.resarray[-1].logr_stateid
 
     ops = [op.putfh(fh),
            op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY,
                            layoutreturn4(LAYOUTRETURN4_FILE,
                                          layoutreturn_file4(0, NFS4_MAXFILELEN,
-                                                            layout_stateid, empty_p.get_buffer())))]
+                                                            lo_stateid, empty_p.get_buffer())))]
     res = sess.compound(ops)
     check(res)
     res = close_file(sess, fh, stateid=open_stateid)
@@ -150,6 +159,15 @@ def testFlexLayoutOldSeqid(t, env):
                                                             lo_stateid, empty_p.get_buffer())))]
     res = sess.compound(ops)
     check(res, NFS4ERR_OLD_STATEID, "LAYOUTRETURN with an old stateid")
+
+    ops = [op.putfh(fh),
+           op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY,
+                           layoutreturn4(LAYOUTRETURN4_FILE,
+                                         layoutreturn_file4(0, NFS4_MAXFILELEN,
+                                                            lo_stateid3, empty_p.get_buffer())))]
+    res = sess.compound(ops)
+    check(res)
+
     res = close_file(sess, fh, stateid=open_stateid)
     check(res)
 
@@ -260,8 +278,8 @@ def testFlexLayoutTestAccess(t, env):
                         0, NFS4_MAXFILELEN, 8192, open_stateid, 0xffff)]
     res = sess.compound(ops)
     check(res)
-    lo_stateid = res.resarray[-1].logr_stateid
-    check_seqid(lo_stateid, 1)
+    lo_stateid1 = res.resarray[-1].logr_stateid
+    check_seqid(lo_stateid1, 1)
 
     layout = res.resarray[-1].logr_layout[-1]
     p = FlexUnpacker(layout.loc_body)
@@ -277,11 +295,11 @@ def testFlexLayoutTestAccess(t, env):
     ops = [op.putfh(fh),
            op.layoutget(False, LAYOUT4_FLEX_FILES,
                         LAYOUTIOMODE4_READ,
-                        0, NFS4_MAXFILELEN, 8192, lo_stateid, 0xffff)]
+                        0, NFS4_MAXFILELEN, 8192, lo_stateid1, 0xffff)]
     res = sess.compound(ops)
     check(res)
-    lo_stateid = res.resarray[-1].logr_stateid
-    check_seqid(lo_stateid, 2)
+    lo_stateid2 = res.resarray[-1].logr_stateid
+    check_seqid(lo_stateid2, 2)
 
     layout = res.resarray[-1].logr_layout[-1]
     p = FlexUnpacker(layout.loc_body)
@@ -300,6 +318,14 @@ def testFlexLayoutTestAccess(t, env):
     if gid_rw != gid_rd:
         fail("Expected gid_rd == %s, got %s" % (gid_rd, gid_rw))
 
+    ops = [op.putfh(fh),
+           op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY,
+                           layoutreturn4(LAYOUTRETURN4_FILE,
+                                         layoutreturn_file4(0, NFS4_MAXFILELEN,
+                                                            lo_stateid2, empty_p.get_buffer())))]
+    res = sess.compound(ops)
+    check(res)
+
     res = close_file(sess, fh, stateid=open_stateid)
     check(res)
 
Signature · 1 line
2.26.2
author
#8 lore raw

PATCH 7/7 st_flex: testFlexLayoutStatsSmall needed loving to pass python3

In reply to Tom Haynes

From: Tom Haynes <[email protected]>

---
 nfs4.1/server41tests/st_flex.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
nfs4.1/server41tests/st_flex.py +3 -3
index 2b1820c..169db69 100644
@@ -8,7 +8,7 @@ from xdrdef.nfs4_pack import NFS4Packer as FlexPacker, \
     NFS4Unpacker as FlexUnpacker
 from nfs4lib import FancyNFS4Packer, get_nfstime
 
-current_stateid = stateid4(1, '\0' * 12)
+current_stateid = stateid4(1, b'\0' * 12)
 
 empty_fflr = ff_layoutreturn4([], [])
 
@@ -347,8 +347,8 @@ def testFlexLayoutStatsSmall(t, env):
     sess = env.c1.new_pnfs_client_session(env.testname(t))
 
     for i in range(len(lats)):
-        open_op = open_create_file_op(sess, env.testname(t) + str(i), open_create=OPEN4_CREATE)
-        res = sess.compound( open_op +
+        open_op = open_create_file_op(sess, b'%s_%i' % (env.testname(t), i), open_create=OPEN4_CREATE)
+        res = sess.compound(open_op +
                [op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_RW,
                             0, NFS4_MAXFILELEN, 4196, current_stateid, 0xffff)])
         check(res, NFS4_OK)
Signature · 1 line
2.26.2
#7 lore raw

Re: [pynfs python3 6/7] st_flex: Return the layout before closing the file

In reply to Tom Haynes

Hi Tom,

works for me as well with fedora33 and dcache server.

Thanks,
Tigran.

----- Original Message -----

Quoted 113 lines

From: "Tom Haynes" <[email protected]>
To: "bfields" <[email protected]>
Cc: "linux-nfs" <[email protected]>
Sent: Saturday, 19 December, 2020 19:29:47
Subject: [pynfs python3 6/7] st_flex: Return the layout before closing the file

From: Tom Haynes <[email protected]>

---
nfs4.1/server41tests/st_flex.py | 40 +++++++++++++++++++++++++++------

1 file changed, 33 insertions(+), 7 deletions(-)
nfs4.1/server41tests/st_flex.py +6 -0
index 3aae441..2b1820c 100644
@@ -56,6 +56,15 @@ def testStateid1(t, env):
        # the server increments by one the value of the "seqid" in each
        # subsequent LAYOUTGET and LAYOUTRETURN response,
        check_seqid(lo_stateid, i + 2)
+
+    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())))]

nfs4.1/server41tests/st_flex.py +4 -2
+    res = sess.compound(ops)
+    check(res)
+
    res = close_file(sess, fh, stateid=open_stateid)
    check(res)
@@ -79,13 +88,13 @@ def testFlexLayoutReturnFile(t, env):
    res = sess.compound(ops)
    check(res)
    # Return layout
-    layout_stateid = res.resarray[-1].logr_stateid
+    lo_stateid = res.resarray[-1].logr_stateid
 
    ops = [op.putfh(fh),
           op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY,
                           layoutreturn4(LAYOUTRETURN4_FILE,
                                         layoutreturn_file4(0, NFS4_MAXFILELEN,
-                                                            layout_stateid,

empty_p.get_buffer())))]
+ lo_stateid,
empty_p.get_buffer())))]
res = sess.compound(ops)
check(res)
res = close_file(sess, fh, stateid=open_stateid)

nfs4.1/server41tests/st_flex.py +6 -0
@@ -150,6 +159,15 @@ def testFlexLayoutOldSeqid(t, env):
                                                            lo_stateid, empty_p.get_buffer())))]
    res = sess.compound(ops)
    check(res, NFS4ERR_OLD_STATEID, "LAYOUTRETURN with an old stateid")
+
+    ops = [op.putfh(fh),
+           op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY,
+                           layoutreturn4(LAYOUTRETURN4_FILE,
+                                         layoutreturn_file4(0, NFS4_MAXFILELEN,
+                                                            lo_stateid3,

empty_p.get_buffer())))]

nfs4.1/server41tests/st_flex.py +13 -5
+    res = sess.compound(ops)
+    check(res)
+
    res = close_file(sess, fh, stateid=open_stateid)
    check(res)
@@ -260,8 +278,8 @@ def testFlexLayoutTestAccess(t, env):
                        0, NFS4_MAXFILELEN, 8192, open_stateid, 0xffff)]
    res = sess.compound(ops)
    check(res)
-    lo_stateid = res.resarray[-1].logr_stateid
-    check_seqid(lo_stateid, 1)
+    lo_stateid1 = res.resarray[-1].logr_stateid
+    check_seqid(lo_stateid1, 1)
 
    layout = res.resarray[-1].logr_layout[-1]
    p = FlexUnpacker(layout.loc_body)
@@ -277,11 +295,11 @@ def testFlexLayoutTestAccess(t, env):
    ops = [op.putfh(fh),
           op.layoutget(False, LAYOUT4_FLEX_FILES,
                        LAYOUTIOMODE4_READ,
-                        0, NFS4_MAXFILELEN, 8192, lo_stateid, 0xffff)]
+                        0, NFS4_MAXFILELEN, 8192, lo_stateid1, 0xffff)]
    res = sess.compound(ops)
    check(res)
-    lo_stateid = res.resarray[-1].logr_stateid
-    check_seqid(lo_stateid, 2)
+    lo_stateid2 = res.resarray[-1].logr_stateid
+    check_seqid(lo_stateid2, 2)
 
    layout = res.resarray[-1].logr_layout[-1]
    p = FlexUnpacker(layout.loc_body)
@@ -300,6 +318,14 @@ def testFlexLayoutTestAccess(t, env):
    if gid_rw != gid_rd:
        fail("Expected gid_rd == %s, got %s" % (gid_rd, gid_rw))
 
+    ops = [op.putfh(fh),
+           op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY,
+                           layoutreturn4(LAYOUTRETURN4_FILE,
+                                         layoutreturn_file4(0, NFS4_MAXFILELEN,
+                                                            lo_stateid2,

empty_p.get_buffer())))]

nfs4.1/server41tests/st_flex.py +3 -1
+    res = sess.compound(ops)
+    check(res)
+
    res = close_file(sess, fh, stateid=open_stateid)
    check(res)
 
--

2.26.2

#9 lore raw
In reply to Tom Haynes
Quoted 8 lines · Tom Haynes

From: Tom Haynes <[email protected]>

Hey Bruce,

This applies on top of the previous patch set.

This passes on my RHEL 8.2 client running python3 against a Hammerspace server.

Thanks, and thanks to Tigran for testing; applied.--b.

Quoted 25 lines

Thanks,
Tom

fwiw - In some of the error paths, the system would complain that the exception StandardError was not defined.

I found this:
https://portingguide.readthedocs.io/en/latest/exceptions.html#the-removed-standarderror

Tom Haynes (7):
CB_LAYOUTRECALL: Make string a byte array
st_flex: Use NFS4_MAXFILELEN in layout calls
st_flex: Provide an empty ff_layoutreturn4 by default for LAYOUTRETURN
st_flex: Use range instead of xrange for python3
st_flex: Test is now redundant
st_flex: Return the layout before closing the file
st_flex: testFlexLayoutStatsSmall needed loving to pass python3

 nfs4.1/nfs4client.py            |   2 +-
 nfs4.1/server41tests/st_flex.py | 124 +++++++++++++++++---------------
 2 files changed, 68 insertions(+), 58 deletions(-)
Signature · 1 line
2.26.2