Пример #1
0
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, 0xffffffffffffffff, 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)
Пример #2
0
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,
                     0xffffffffffffffff, 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)
Пример #3
0
def testFlexGetDevInfo(t, env):
    """Get the device info

    FLAGS: flex
    CODE: FFGDI1
    """
    sess = env.c1.new_pnfs_client_session(env.testname(t))
    # Create the file
    res = create_file(sess, env.testname(t))
    check(res)
    # Get layout 1
    fh = res.resarray[-1].object
    open_stateid = res.resarray[-2].stateid
    lo_stateid = open_stateid

    ops = [
        op.putfh(fh),
        op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_RW, 0,
                     NFS4_MAXFILELEN, 8192, lo_stateid, 0xffff)
    ]
    res = sess.compound(ops)
    check(res)
    lo_stateid = res.resarray[-1].logr_stateid
    check_seqid(lo_stateid, 1)

    layout = res.resarray[-1].logr_layout[-1]
    p = FlexUnpacker(layout.loc_body)
    opaque = p.unpack_ff_layout4()
    p.done()

    # Assume one mirror/storage device
    ds = opaque.ffl_mirrors[-1].ffm_data_servers[-1]

    deviceid = ds.ffds_deviceid

    ops = [
        op.putfh(fh),
        op.getdeviceinfo(deviceid, LAYOUT4_FLEX_FILES, 0xffffffff, 0)
    ]
    res = sess.compound(ops)
    check(res)

    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)
Пример #4
0
def get_layout_cred(logr):
    """
    :summary: Returns credentials contained in LAYOUTGET reply
    :param logr: LAYOUTGET reply result
    :return: List with uid and gid
    """
    locb = logr.logr_layout[0].lo_content.loc_body
    p = FlexUnpacker(locb)
    layout = p.unpack_ff_layout4()
    p.done()
    uid = layout.ffl_mirrors[0].ffm_data_servers[0].ffds_user
    gid = layout.ffl_mirrors[0].ffm_data_servers[0].ffds_group
    return [uid, gid]
Пример #5
0
def layoutget_return(sess, fh, open_stateid, allowed_errors=NFS4_OK,
                     layout_iomode=LAYOUTIOMODE4_RW, layout_error=None,
                     layout_error_op=OP_WRITE):
    """
    Perform LAYOUTGET and LAYOUTRETURN
    """

    # Get layout
    ops = [op.putfh(fh),
           op.layoutget(False, LAYOUT4_FLEX_FILES, layout_iomode,
                        0, NFS4_MAXFILELEN, 4196, open_stateid, 0xffff)]
    res = sess.compound(ops)
    check(res, allowed_errors)
    if res.status != NFS4_OK:
        return [res] # We can't return the layout without a stateid!
    layout_stateid = res.resarray[-1].logr_stateid

    # Return layout
    if not layout_error:  # Return regular layout
        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())))]
    else:  # Return layout with error
        # Get device id
        locb = res.resarray[-1].logr_layout[0].lo_content.loc_body
        p = FlexUnpacker(locb)
        layout = p.unpack_ff_layout4()
        p.done()

        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_MAXFILELEN, layout_stateid, [deverr])
        fflr = ff_layoutreturn4([ffioerr], [])

        p = FlexPacker()
        p.pack_ff_layoutreturn4(fflr)

        ops = [op.putfh(fh),
               op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY,
                               layoutreturn4(LAYOUTRETURN4_FILE,
                                             layoutreturn_file4(0, NFS4_MAXFILELEN,
                                                                layout_stateid,
                                                                p.get_buffer())))]

    res2 = sess.compound(ops)
    check(res2)
    return [res, res2]
Пример #6
0
def testFlexGetDevInfo(t, env):
    """Get the device info

    FLAGS: flex
    CODE: FFGDI1
    """
    sess = env.c1.new_pnfs_client_session(env.testname(t))
    # Create the file
    res = create_file(sess, env.testname(t))
    check(res)
    # Get layout 1
    fh = res.resarray[-1].object
    open_stateid = res.resarray[-2].stateid
    lo_stateid = open_stateid

    ops = [op.putfh(fh),
           op.layoutget(False, LAYOUT4_FLEX_FILES,
                        LAYOUTIOMODE4_RW,
                        0, 0xffffffffffffffff, 8192, lo_stateid, 0xffff)]
    res = sess.compound(ops)
    check(res)
    lo_stateid = res.resarray[-1].logr_stateid
    check_seqid(lo_stateid, 1)

    layout = res.resarray[-1].logr_layout[-1]
    p = FlexUnpacker(layout.loc_body)
    opaque = p.unpack_ff_layout4()
    p.done()

    # Assume one mirror/storage device
    ds = opaque.ffl_mirrors[-1].ffm_data_servers[-1]

    deviceid = ds.ffds_deviceid

    ops = [op.putfh(fh),
           op.getdeviceinfo(deviceid, LAYOUT4_FLEX_FILES, 0xffffffff, 0)]
    res = sess.compound(ops)
    check(res)

    ops = [op.putfh(fh),
           op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY,
                           layoutreturn4(LAYOUTRETURN4_FILE,
                                         layoutreturn_file4(0, 0xffffffffffffffff, lo_stateid, "")))]
    res = sess.compound(ops)
    check(res)
    res = close_file(sess, fh, stateid=open_stateid)
    check(res)
Пример #7
0
def _LayoutStats(t, env, stats):
    '''Loop over the provided layoutstats, sending them on in time
    '''
    sess = env.c1.new_pnfs_client_session(env.testname(t))

    # Create the file
    res = create_file(sess, env.testname(t))
    check(res)
    fh = res.resarray[-1].object
    open_stateid = res.resarray[-2].stateid
    lo_stateid = open_stateid

    ops = [op.putfh(fh),
           op.layoutget(False, LAYOUT4_FLEX_FILES,
                        LAYOUTIOMODE4_RW,
                        0, 0xffffffffffffffff, 8192, lo_stateid, 0xffff)]
    res = sess.compound(ops)
    check(res)
    lo_stateid = res.resarray[-1].logr_stateid
    check_seqid(lo_stateid, 1)

    layout = res.resarray[-1].logr_layout[-1]
    p = FlexUnpacker(layout.loc_body)
    opaque = p.unpack_ff_layout4()
    p.done()

    stats_hint = opaque.ffl_stats_collect_hint

    # Assume one mirror/storage device
    ds = opaque.ffl_mirrors[-1].ffm_data_servers[-1]

    deviceid = ds.ffds_deviceid

    ops = [op.putfh(fh),
           op.getdeviceinfo(deviceid, LAYOUT4_FLEX_FILES, 0xffffffff, 0)]
    res = sess.compound(ops)
    check(res)

    gda = res.resarray[-1].gdir_device_addr

    p = FlexUnpacker(gda.da_addr_body)
    da = p.unpack_ff_device_addr4()
    p.done()

    rd_io = io_info4()
    wr_io = io_info4()

    rd_lat = ff_io_latency4()
    wr_lat = ff_io_latency4()

    for s in stats:
        dur = get_nfstime(s[1])

        # Did not capture these in the gathered traces
        offset = 0
        file_length = 0xffffffffffffffff
        rd_io.ii_count = 0
        rd_io.ii_bytes = 0
        wr_io.ii_count = 0
        wr_io.ii_bytes = 0

        rd_lat.ffil_ops_requested = s[5]
        rd_lat.ffil_bytes_requested = s[4]
        rd_lat.ffil_ops_completed = s[6]
        rd_lat.ffil_bytes_completed = s[2]
        rd_lat.ffil_bytes_not_delivered = s[3]
        rd_lat.ffil_total_busy_time = get_nfstime(s[7])
        rd_lat.ffil_aggregate_completion_time = get_nfstime(s[8])
        wr_lat.ffil_ops_requested = s[12]
        wr_lat.ffil_bytes_requested = s[11]
        wr_lat.ffil_ops_completed = s[13]
        wr_lat.ffil_bytes_completed = s[9]
        wr_lat.ffil_bytes_not_delivered = s[10]
        wr_lat.ffil_total_busy_time = get_nfstime(s[14])
        wr_lat.ffil_aggregate_completion_time = get_nfstime(s[15])

        sleeper = s[0]
        env.sleep(sleeper)
        fflu = ff_layoutupdate4(da.ffda_netaddrs[-1], ds.ffds_fh_vers[-1],
                                rd_lat, wr_lat, dur, True)
        p = FlexPacker()
        p.pack_ff_layoutupdate4(fflu)
        lu4 = layoutupdate4(LAYOUT4_FLEX_FILES, p.get_buffer())

        ops = [op.putfh(fh),
               op.layoutstats(offset, file_length, lo_stateid, rd_io, wr_io, deviceid, lu4)]
        res = sess.compound(ops)
        check(res)

    ops = [op.putfh(fh),
           op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY,
                           layoutreturn4(LAYOUTRETURN4_FILE,
                                         layoutreturn_file4(0, 0xffffffffffffffff, lo_stateid, "")))]
    res = sess.compound(ops)
    check(res)
    res = close_file(sess, fh, stateid=open_stateid)
    check(res)
Пример #8
0
def testFlexLayoutStatsSmall(t, env):
    """Open 20 "small" files and simulate LAYOUTSTATS for them
    1) OPEN, LAYOUTGET
    2) GETDEVINFO
    3) LAYOUTRETURN, CLOSE

    FLAGS: flex layoutstats
    CODE: FFLS1
    """
    lats = [93089, 107683, 112340, 113195, 130412, 138390, 140427, 158824, 193078, 201879, 391634, 404757, 2201181, 2232614, 2280089, 2296343, 2341763, 2392984, 3064546, 3070314]
    durs = [3387666, 3439506, 3737081, 4448315, 4380523, 4419273, 4419746, 5903420, 5932432, 5932938, 7573082, 11085497, 11125274, 11126513, 13720303, 15990926, 16020425, 16020948, 20181628, 20213871]

    if len(lats) != len(durs):
        fail("Lats and durs not same")

    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 +
               [op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_RW,
                            0, 0xffffffffffffffff, 4196, current_stateid, 0xffff)])
        check(res, NFS4_OK)
        lo_stateid = res.resarray[-1].logr_stateid
        fh = res.resarray[-2].object
        open_stateid = res.resarray[-3].stateid

        check_seqid(lo_stateid, 1)

        layout = res.resarray[-1].logr_layout[-1]
        p = FlexUnpacker(layout.loc_body)
        opaque = p.unpack_ff_layout4()
        p.done()

        # Assume one mirror/storage device
        ds = opaque.ffl_mirrors[-1].ffm_data_servers[-1]

        stats_hint = opaque.ffl_stats_collect_hint

        deviceid = ds.ffds_deviceid

        ops = [op.putfh(fh),
               op.getdeviceinfo(deviceid, LAYOUT4_FLEX_FILES, 0xffffffff, 0)]
        res = sess.compound(ops)
        check(res)

        gda = res.resarray[-1].gdir_device_addr

        p = FlexUnpacker(gda.da_addr_body)
        da = p.unpack_ff_device_addr4()
        p.done()

        rd_io = io_info4(0, 0)
        wr_io = io_info4(1, 16384)

        rd_lat = ff_io_latency4(0, 0, 0, 0, 0, nfstime4(0, 0), nfstime4(0, 0))
        wr_lat = ff_io_latency4(1, 16384, 1, 16384, 0, nfstime4(0, lats[i]), nfstime4(0, lats[i]))

        offset = 0
        file_length = 16384

        dur = durs[i]
        fflu = ff_layoutupdate4(da.ffda_netaddrs[-1], ds.ffds_fh_vers[-1],
                                rd_lat, wr_lat, nfstime4(0, dur), True)

        ffio = ff_iostats4(offset, file_length, lo_stateid, rd_io, wr_io, deviceid, fflu)
        fflr = ff_layoutreturn4([], [ffio])

        p = FlexPacker()
        p.pack_ff_layoutreturn4(fflr)

        ops = [op.putfh(fh),
               op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY,
                               layoutreturn4(LAYOUTRETURN4_FILE,
                                             layoutreturn_file4(0, 0xffffffffffffffff, lo_stateid, p.get_buffer()))),
               op.close(0, open_stateid)]
        res = sess.compound(ops)
        check(res)
Пример #9
0
def testFlexLayoutTestAccess(t, env):
    """Get both a LAYOUTIOMODE4_RW and LAYOUTIOMODE4_READ segment
    making sure that they have the same gid, but a different uid.

    FLAGS: flex
    CODE: FFLA1
    """
    sess = env.c1.new_pnfs_client_session(env.testname(t))
    # Create the file
    res = create_file(sess, env.testname(t))
    check(res)
    # Get layout 1
    fh = res.resarray[-1].object
    open_stateid = res.resarray[-2].stateid

    ops = [op.putfh(fh),
           op.layoutget(False, LAYOUT4_FLEX_FILES,
                        LAYOUTIOMODE4_RW,
                        0, 0xffffffffffffffff, 8192, open_stateid, 0xffff)]
    res = sess.compound(ops)
    check(res)
    lo_stateid = res.resarray[-1].logr_stateid
    check_seqid(lo_stateid, 1)

    layout = res.resarray[-1].logr_layout[-1]
    p = FlexUnpacker(layout.loc_body)
    opaque = p.unpack_ff_layout4()
    p.done()

    # Assume one mirror/storage device
    ds = opaque.ffl_mirrors[-1].ffm_data_servers[-1]

    uid_rw = ds.ffds_user
    gid_rw = ds.ffds_group

    ops = [op.putfh(fh),
           op.layoutget(False, LAYOUT4_FLEX_FILES,
                        LAYOUTIOMODE4_READ,
                        0, 0xffffffffffffffff, 8192, lo_stateid, 0xffff)]
    res = sess.compound(ops)
    check(res)
    lo_stateid = res.resarray[-1].logr_stateid
    check_seqid(lo_stateid, 2)

    layout = res.resarray[-1].logr_layout[-1]
    p = FlexUnpacker(layout.loc_body)
    opaque = p.unpack_ff_layout4()
    p.done()

    # Assume one mirror/storage device
    ds = opaque.ffl_mirrors[-1].ffm_data_servers[-1]

    uid_rd = ds.ffds_user
    gid_rd = ds.ffds_group

    if uid_rw == uid_rd:
        fail("Expected uid_rd != %i, got %i" % (uid_rd, uid_rw))

    if gid_rw != gid_rd:
        fail("Expected gid_rd == %i, got %i" % (gid_rd, gid_rw))

    res = close_file(sess, fh, stateid=open_stateid)
    check(res)
Пример #10
0
def _LayoutStats(t, env, stats):
    '''Loop over the provided layoutstats, sending them on in time
    '''
    sess = env.c1.new_pnfs_client_session(env.testname(t))

    # Create the file
    res = create_file(sess, env.testname(t))
    check(res)
    fh = res.resarray[-1].object
    open_stateid = res.resarray[-2].stateid
    lo_stateid = open_stateid

    ops = [
        op.putfh(fh),
        op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_RW, 0,
                     0xffffffffffffffff, 8192, lo_stateid, 0xffff)
    ]
    res = sess.compound(ops)
    check(res)
    lo_stateid = res.resarray[-1].logr_stateid
    check_seqid(lo_stateid, 1)

    layout = res.resarray[-1].logr_layout[-1]
    p = FlexUnpacker(layout.loc_body)
    opaque = p.unpack_ff_layout4()
    p.done()

    stats_hint = opaque.ffl_stats_collect_hint

    # Assume one mirror/storage device
    ds = opaque.ffl_mirrors[-1].ffm_data_servers[-1]

    deviceid = ds.ffds_deviceid

    ops = [
        op.putfh(fh),
        op.getdeviceinfo(deviceid, LAYOUT4_FLEX_FILES, 0xffffffff, 0)
    ]
    res = sess.compound(ops)
    check(res)

    gda = res.resarray[-1].gdir_device_addr

    p = FlexUnpacker(gda.da_addr_body)
    da = p.unpack_ff_device_addr4()
    p.done()

    rd_io = io_info4()
    wr_io = io_info4()

    rd_lat = ff_io_latency4()
    wr_lat = ff_io_latency4()

    for s in stats:
        dur = get_nfstime(s[1])

        # Did not capture these in the gathered traces
        offset = 0
        file_length = 0xffffffffffffffff
        rd_io.ii_count = 0
        rd_io.ii_bytes = 0
        wr_io.ii_count = 0
        wr_io.ii_bytes = 0

        rd_lat.ffil_ops_requested = s[5]
        rd_lat.ffil_bytes_requested = s[4]
        rd_lat.ffil_ops_completed = s[6]
        rd_lat.ffil_bytes_completed = s[2]
        rd_lat.ffil_bytes_not_delivered = s[3]
        rd_lat.ffil_total_busy_time = get_nfstime(s[7])
        rd_lat.ffil_aggregate_completion_time = get_nfstime(s[8])
        wr_lat.ffil_ops_requested = s[12]
        wr_lat.ffil_bytes_requested = s[11]
        wr_lat.ffil_ops_completed = s[13]
        wr_lat.ffil_bytes_completed = s[9]
        wr_lat.ffil_bytes_not_delivered = s[10]
        wr_lat.ffil_total_busy_time = get_nfstime(s[14])
        wr_lat.ffil_aggregate_completion_time = get_nfstime(s[15])

        sleeper = s[0]
        env.sleep(sleeper)
        fflu = ff_layoutupdate4(da.ffda_netaddrs[-1], ds.ffds_fh_vers[-1],
                                rd_lat, wr_lat, dur, True)
        p = FlexPacker()
        p.pack_ff_layoutupdate4(fflu)
        lu4 = layoutupdate4(LAYOUT4_FLEX_FILES, p.get_buffer())

        ops = [
            op.putfh(fh),
            op.layoutstats(offset, file_length, lo_stateid, rd_io, wr_io,
                           deviceid, lu4)
        ]
        res = sess.compound(ops)
        check(res)

    ops = [
        op.putfh(fh),
        op.layoutreturn(
            False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY,
            layoutreturn4(
                LAYOUTRETURN4_FILE,
                layoutreturn_file4(0, 0xffffffffffffffff, lo_stateid, "")))
    ]
    res = sess.compound(ops)
    check(res)
    res = close_file(sess, fh, stateid=open_stateid)
    check(res)
Пример #11
0
def testFlexLayoutStatsSmall(t, env):
    """Open 20 "small" files and simulate LAYOUTSTATS for them
    1) OPEN, LAYOUTGET
    2) GETDEVINFO
    3) LAYOUTRETURN, CLOSE

    FLAGS: flex layoutstats
    CODE: FFLS1
    """
    lats = [
        93089, 107683, 112340, 113195, 130412, 138390, 140427, 158824, 193078,
        201879, 391634, 404757, 2201181, 2232614, 2280089, 2296343, 2341763,
        2392984, 3064546, 3070314
    ]
    durs = [
        3387666, 3439506, 3737081, 4448315, 4380523, 4419273, 4419746, 5903420,
        5932432, 5932938, 7573082, 11085497, 11125274, 11126513, 13720303,
        15990926, 16020425, 16020948, 20181628, 20213871
    ]

    if len(lats) != len(durs):
        fail("Lats and durs not same")

    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 + [
            op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_RW, 0,
                         0xffffffffffffffff, 4196, current_stateid, 0xffff)
        ])
        check(res, NFS4_OK)
        lo_stateid = res.resarray[-1].logr_stateid
        fh = res.resarray[-2].object
        open_stateid = res.resarray[-3].stateid

        check_seqid(lo_stateid, 1)

        layout = res.resarray[-1].logr_layout[-1]
        p = FlexUnpacker(layout.loc_body)
        opaque = p.unpack_ff_layout4()
        p.done()

        # Assume one mirror/storage device
        ds = opaque.ffl_mirrors[-1].ffm_data_servers[-1]

        stats_hint = opaque.ffl_stats_collect_hint

        deviceid = ds.ffds_deviceid

        ops = [
            op.putfh(fh),
            op.getdeviceinfo(deviceid, LAYOUT4_FLEX_FILES, 0xffffffff, 0)
        ]
        res = sess.compound(ops)
        check(res)

        gda = res.resarray[-1].gdir_device_addr

        p = FlexUnpacker(gda.da_addr_body)
        da = p.unpack_ff_device_addr4()
        p.done()

        rd_io = io_info4(0, 0)
        wr_io = io_info4(1, 16384)

        rd_lat = ff_io_latency4(0, 0, 0, 0, 0, nfstime4(0, 0), nfstime4(0, 0))
        wr_lat = ff_io_latency4(1, 16384, 1, 16384, 0, nfstime4(0, lats[i]),
                                nfstime4(0, lats[i]))

        offset = 0
        file_length = 16384

        dur = durs[i]
        fflu = ff_layoutupdate4(da.ffda_netaddrs[-1], ds.ffds_fh_vers[-1],
                                rd_lat, wr_lat, nfstime4(0, dur), True)

        ffio = ff_iostats4(offset, file_length, lo_stateid, rd_io, wr_io,
                           deviceid, fflu)
        fflr = ff_layoutreturn4([], [ffio])

        p = FlexPacker()
        p.pack_ff_layoutreturn4(fflr)

        ops = [
            op.putfh(fh),
            op.layoutreturn(
                False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY,
                layoutreturn4(
                    LAYOUTRETURN4_FILE,
                    layoutreturn_file4(0, 0xffffffffffffffff, lo_stateid,
                                       p.get_buffer()))),
            op.close(0, open_stateid)
        ]
        res = sess.compound(ops)
        check(res)
Пример #12
0
def testFlexLayoutTestAccess(t, env):
    """Get both a LAYOUTIOMODE4_RW and LAYOUTIOMODE4_READ segment
    making sure that they have the same gid, but a different uid.

    FLAGS: flex
    CODE: FFLA1
    """
    sess = env.c1.new_pnfs_client_session(env.testname(t))
    # Create the file
    res = create_file(sess, env.testname(t))
    check(res)
    # Get layout 1
    fh = res.resarray[-1].object
    open_stateid = res.resarray[-2].stateid

    ops = [
        op.putfh(fh),
        op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_RW, 0,
                     0xffffffffffffffff, 8192, open_stateid, 0xffff)
    ]
    res = sess.compound(ops)
    check(res)
    lo_stateid = res.resarray[-1].logr_stateid
    check_seqid(lo_stateid, 1)

    layout = res.resarray[-1].logr_layout[-1]
    p = FlexUnpacker(layout.loc_body)
    opaque = p.unpack_ff_layout4()
    p.done()

    # Assume one mirror/storage device
    ds = opaque.ffl_mirrors[-1].ffm_data_servers[-1]

    uid_rw = ds.ffds_user
    gid_rw = ds.ffds_group

    ops = [
        op.putfh(fh),
        op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_READ, 0,
                     0xffffffffffffffff, 8192, lo_stateid, 0xffff)
    ]
    res = sess.compound(ops)
    check(res)
    lo_stateid = res.resarray[-1].logr_stateid
    check_seqid(lo_stateid, 2)

    layout = res.resarray[-1].logr_layout[-1]
    p = FlexUnpacker(layout.loc_body)
    opaque = p.unpack_ff_layout4()
    p.done()

    # Assume one mirror/storage device
    ds = opaque.ffl_mirrors[-1].ffm_data_servers[-1]

    uid_rd = ds.ffds_user
    gid_rd = ds.ffds_group

    if uid_rw == uid_rd:
        fail("Expected uid_rd != %i, got %i" % (uid_rd, uid_rw))

    if gid_rw != gid_rd:
        fail("Expected gid_rd == %i, got %i" % (gid_rd, gid_rw))

    res = close_file(sess, fh, stateid=open_stateid)
    check(res)