Ejemplo n.º 1
0
def testStateid2(t, env):
    """Check for proper sequence handling in layout stateids.

    FLAGS: block
    CODE: BLOCK2
    """
    c1 = env.c1.new_client_session(env.testname(t),
                                    flags=EXCHGID4_FLAG_USE_PNFS_MDS)
    # 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
    print open_stateid
    ops = [op.putfh(fh),
           op.layoutget(False, LAYOUT4_BLOCK_VOLUME, LAYOUTIOMODE4_RW,
                        0, 8192, 8192, open_stateid, 0xffff)]
    res = sess.compound(ops)
    check(res)
    # Get layout 2
    lo_stateid1 = res.resarray[-1].logr_stateid
    print lo_stateid1
    ops = [op.putfh(fh),
           op.layoutget(False, LAYOUT4_BLOCK_VOLUME, LAYOUTIOMODE4_RW,
                        8192, 8192, 8192, lo_stateid1, 0xffff)]
    res = sess.compound(ops)
    check(res)
    # Get layout 3 (merge of prior two)
    lo_stateid2 = res.resarray[-1].logr_stateid
    print lo_stateid2
    ops = [op.putfh(fh),
           op.layoutget(False, LAYOUT4_BLOCK_VOLUME, LAYOUTIOMODE4_RW,
                        0, 2*8192, 2*8192, lo_stateid2, 0xffff)]
    res = sess.compound(ops)
    check(res)
    lo_stateid3 = res.resarray[-1].logr_stateid
    print lo_stateid3
    # lo_stateid3.seqid = 3 # BUG - work around emc problem
    # Parse opaque to get info for commit
    # STUB not very general
    layout = res.resarray[-1].logr_layout[-1]
    p = BlockUnpacker(layout.loc_body)
    opaque = p.unpack_pnfs_block_layout4()
    p.done()
    extent = opaque.blo_extents[-1]
    extent.bex_state = PNFS_BLOCK_READWRITE_DATA
    p = BlockPacker()
    p.pack_pnfs_block_layoutupdate4(pnfs_block_layoutupdate4([extent]))
    time = newtime4(True, get_nfstime())
    ops = [op.putfh(fh),
           op.layoutcommit(extent.bex_file_offset,
                           extent.bex_length,
                           False, lo_stateid3,
                           newoffset4(True, 2 * 8192 - 1),
                           time,
                           layoutupdate4(LAYOUT4_BLOCK_VOLUME, p.get_buffer()))]
    res = sess.compound(ops)
    check(res)
Ejemplo n.º 2
0
def testSplitCommit(t, env):
    """Check for proper handling of disjoint LAYOUTCOMMIT.opaque

    FLAGS: block
    CODE: BLOCK4
    """
    sess = env.c1.new_client_session(env.testname(t),
                                     flags=EXCHGID4_FLAG_USE_PNFS_MDS)
    # 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
    print open_stateid
    ops = [
        op.putfh(fh),
        op.layoutget(False, LAYOUT4_BLOCK_VOLUME, LAYOUTIOMODE4_RW, 0,
                     2 * 8192, 2 * 8192, open_stateid, 0xffff)
    ]
    res = sess.compound(ops)
    check(res)

    lo_stateid1 = res.resarray[-1].logr_stateid
    print lo_stateid1
    # Parse opaque to get info for commit
    # STUB not very general
    layout = res.resarray[-1].logr_layout[-1]
    p = BlockUnpacker(layout.loc_body)
    opaque = p.unpack_pnfs_block_layout4()
    p.done()
    dev = opaque.blo_extents[-1].bex_vol_id
    extent1 = pnfs_block_extent4(dev, 0, 8192, 0, PNFS_BLOCK_READWRITE_DATA)
    extent2 = pnfs_block_extent4(dev, 8192, 8192, 0, PNFS_BLOCK_READWRITE_DATA)

    p = BlockPacker()
    p.pack_pnfs_block_layoutupdate4(
        pnfs_block_layoutupdate4([extent1, extent2]))
    time = newtime4(True, get_nfstime())
    ops = [
        op.putfh(fh),
        op.layoutcommit(0, 2 * 8192, False, lo_stateid1,
                        newoffset4(True, 2 * 8192 - 1), time,
                        layoutupdate4(LAYOUT4_BLOCK_VOLUME, p.get_buffer()))
    ]
    res = sess.compound(ops)
    check(res)
Ejemplo n.º 3
0
def testSplitCommit(t, env):
    """Check for proper handling of disjoint LAYOUTCOMMIT.opaque

    FLAGS: block
    CODE: BLOCK4
    """
    sess = env.c1.new_client_session(env.testname(t),
                                        flags=EXCHGID4_FLAG_USE_PNFS_MDS)
    # 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
    print open_stateid
    ops = [op.putfh(fh),
           op.layoutget(False, LAYOUT4_BLOCK_VOLUME, LAYOUTIOMODE4_RW,
                        0, 2*8192, 2*8192, open_stateid, 0xffff)]
    res = sess.compound(ops)
    check(res)

    lo_stateid1 = res.resarray[-1].logr_stateid
    print lo_stateid1
    # Parse opaque to get info for commit
    # STUB not very general
    layout = res.resarray[-1].logr_layout[-1]
    p = BlockUnpacker(layout.loc_body)
    opaque = p.unpack_pnfs_block_layout4()
    p.done()
    dev = opaque.blo_extents[-1].bex_vol_id
    extent1 = pnfs_block_extent4(dev, 0, 8192, 0, PNFS_BLOCK_READWRITE_DATA)
    extent2 = pnfs_block_extent4(dev, 8192, 8192, 0, PNFS_BLOCK_READWRITE_DATA)

    p = BlockPacker()
    p.pack_pnfs_block_layoutupdate4(pnfs_block_layoutupdate4([extent1,
                                                              extent2]))
    time = newtime4(True, get_nfstime())
    ops = [op.putfh(fh),
           op.layoutcommit(0,
                           2*8192,
                           False, lo_stateid1,
                           newoffset4(True, 2 * 8192 - 1),
                           time,
                           layoutupdate4(LAYOUT4_BLOCK_VOLUME, p.get_buffer()))]
    res = sess.compound(ops)
    check(res)
Ejemplo n.º 4
0
def testStateid2(t, env):
    """Check for proper sequence handling in layout stateids.

    FLAGS: block
    CODE: BLOCK2
    """
    c1 = env.c1.new_client_session(env.testname(t),
                                   flags=EXCHGID4_FLAG_USE_PNFS_MDS)
    # 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
    print open_stateid
    ops = [
        op.putfh(fh),
        op.layoutget(False, LAYOUT4_BLOCK_VOLUME, LAYOUTIOMODE4_RW, 0, 8192,
                     8192, open_stateid, 0xffff)
    ]
    res = sess.compound(ops)
    check(res)
    # Get layout 2
    lo_stateid1 = res.resarray[-1].logr_stateid
    print lo_stateid1
    ops = [
        op.putfh(fh),
        op.layoutget(False, LAYOUT4_BLOCK_VOLUME, LAYOUTIOMODE4_RW, 8192, 8192,
                     8192, lo_stateid1, 0xffff)
    ]
    res = sess.compound(ops)
    check(res)
    # Get layout 3 (merge of prior two)
    lo_stateid2 = res.resarray[-1].logr_stateid
    print lo_stateid2
    ops = [
        op.putfh(fh),
        op.layoutget(False, LAYOUT4_BLOCK_VOLUME, LAYOUTIOMODE4_RW, 0,
                     2 * 8192, 2 * 8192, lo_stateid2, 0xffff)
    ]
    res = sess.compound(ops)
    check(res)
    lo_stateid3 = res.resarray[-1].logr_stateid
    print lo_stateid3
    # lo_stateid3.seqid = 3 # BUG - work around emc problem
    # Parse opaque to get info for commit
    # STUB not very general
    layout = res.resarray[-1].logr_layout[-1]
    p = BlockUnpacker(layout.loc_body)
    opaque = p.unpack_pnfs_block_layout4()
    p.done()
    extent = opaque.blo_extents[-1]
    extent.bex_state = PNFS_BLOCK_READWRITE_DATA
    p = BlockPacker()
    p.pack_pnfs_block_layoutupdate4(pnfs_block_layoutupdate4([extent]))
    time = newtime4(True, get_nfstime())
    ops = [
        op.putfh(fh),
        op.layoutcommit(extent.bex_file_offset, extent.bex_length, False,
                        lo_stateid3, newoffset4(True, 2 * 8192 - 1), time,
                        layoutupdate4(LAYOUT4_BLOCK_VOLUME, p.get_buffer()))
    ]
    res = sess.compound(ops)
    check(res)
Ejemplo n.º 5
0
def testLayoutCommit(t, env):
    """
    Do some commits

    FLAGS: layoutcommit all
    CODE: LAYOUTCOMMIT1
    """
    # Make sure E_ID returns MDS capabilities
    c1 = env.c1.new_client(env.testname(t), flags=EXCHGID4_FLAG_USE_PNFS_MDS)
    if not c1.flags & EXCHGID4_FLAG_USE_PNFS_MDS:
        fail("Server can not be used as pnfs metadata server")
    sess = c1.create_session()
    # Test that fs handles block layouts
    ops = use_obj(env.opts.path) + [
        op.getattr(1 << FATTR4_FS_LAYOUT_TYPE | 1 << FATTR4_LAYOUT_BLKSIZE)
    ]
    res = sess.compound(ops)
    check(res)
    attrdict = res.resarray[-1].obj_attributes
    if FATTR4_FS_LAYOUT_TYPE not in attrdict:
        fail("fs_layout_type not available")
    if LAYOUT4_BLOCK_VOLUME not in attrdict[FATTR4_FS_LAYOUT_TYPE]:
        fail("layout_type does not contain BLOCK")
    blocksize = attrdict[FATTR4_LAYOUT_BLKSIZE]
    # 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_BLOCK_VOLUME, LAYOUTIOMODE4_RW, 0,
                     4 * blocksize, 4 * blocksize, open_stateid, 0xffff)
    ]
    res = sess.compound(ops)
    check(res)
    layout_stateid = res.resarray[-1].logr_stateid
    # Parse opaque
    for layout in res.resarray[-1].logr_layout:
        if layout.loc_type != LAYOUT4_BLOCK_VOLUME:
            fail("Did not get Block layout")
        p = BlockUnpacker(layout.loc_body)
        opaque = p.unpack_pnfs_block_layout4()
        p.done()
        print opaque
    final_extent = opaque.blo_extents[-1]
    print final_extent
    if final_extent.bex_state != PNFS_BLOCK_INVALID_DATA:
        fail("Expected INVALID_DATA in extent")
    # LAYOUTCOMMIT
    final_extent.bex_state = PNFS_BLOCK_READWRITE_DATA
    p = BlockPacker()
    p.pack_pnfs_block_layoutupdate4(pnfs_block_layoutupdate4([final_extent]))
    notime = newtime4(False)
    ops = [
        op.putfh(fh),
        op.layoutcommit(final_extent.bex_file_offset, final_extent.bex_length,
                        False, layout_stateid,
                        newoffset4(True, 4 * blocksize - 1), notime,
                        layoutupdate4(LAYOUT4_BLOCK_VOLUME, p.get_buffer()))
    ]
    res = sess.compound(ops)
    check(res)
    print res
Ejemplo n.º 6
0
def testLayoutCommit(t, env):
    """
    Do some commits

    FLAGS: pnfs
    CODE: LAYOUTCOMMIT1
    """
    # Make sure E_ID returns MDS capabilities
    c1 = env.c1.new_client(env.testname(t), flags=EXCHGID4_FLAG_USE_PNFS_MDS)
    if not c1.flags & EXCHGID4_FLAG_USE_PNFS_MDS:
        fail("Server can not be used as pnfs metadata server")
    sess = c1.create_session()
    # Test that fs handles block layouts
    ops = use_obj(env.opts.path) + [op.getattr(1<<FATTR4_FS_LAYOUT_TYPE |
                                               1<<FATTR4_LAYOUT_BLKSIZE)]
    res = sess.compound(ops)
    check(res)
    attrdict = res.resarray[-1].obj_attributes
    if FATTR4_FS_LAYOUT_TYPE not in attrdict:
        fail("fs_layout_type not available")
    if LAYOUT4_BLOCK_VOLUME not in attrdict[FATTR4_FS_LAYOUT_TYPE]:
        fail("layout_type does not contain BLOCK")
    blocksize = attrdict[FATTR4_LAYOUT_BLKSIZE]
    # 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_BLOCK_VOLUME, LAYOUTIOMODE4_RW,
                        0, 4*blocksize, 4*blocksize, open_stateid, 0xffff)]
    res = sess.compound(ops)
    check(res)
    layout_stateid = res.resarray[-1].logr_stateid
    # Parse opaque
    for layout in  res.resarray[-1].logr_layout:
        if layout.loc_type != LAYOUT4_BLOCK_VOLUME:
            fail("Did not get Block layout")
        p = BlockUnpacker(layout.loc_body)
        opaque = p.unpack_pnfs_block_layout4()
        p.done()
        print opaque
    final_extent = opaque.blo_extents[-1]
    print final_extent
    if final_extent.bex_state != PNFS_BLOCK_INVALID_DATA:
        fail("Expected INVALID_DATA in extent")
    # LAYOUTCOMMIT
    final_extent.bex_state = PNFS_BLOCK_READWRITE_DATA
    p = BlockPacker()
    p.pack_pnfs_block_layoutupdate4(pnfs_block_layoutupdate4([final_extent]))
    notime = newtime4(False)
    ops = [op.putfh(fh),
           op.layoutcommit(final_extent.bex_file_offset,
                           final_extent.bex_length,
                           False, layout_stateid,
                           newoffset4(True, 4 * blocksize - 1),
                           notime,
                           layoutupdate4(LAYOUT4_BLOCK_VOLUME, p.get_buffer()))]
    res = sess.compound(ops)
    check(res)
    print res
Ejemplo n.º 7
0
def testEmptyCommit(t, env):
    """Check for proper handling of empty LAYOUTCOMMIT.

    FLAGS: block
    CODE: BLOCK3
    """
    c1 = env.c1.new_client(env.testname(t), flags=EXCHGID4_FLAG_USE_PNFS_MDS)
    sess = c1.create_session()
    # 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
    print open_stateid
    ops = [
        op.putfh(fh),
        op.layoutget(False, LAYOUT4_BLOCK_VOLUME, LAYOUTIOMODE4_RW, 0, 8192,
                     8192, open_stateid, 0xffff)
    ]
    res = sess.compound(ops)
    check(res)
    # Get layout 2
    lo_stateid1 = res.resarray[-1].logr_stateid
    print lo_stateid1
    ops = [
        op.putfh(fh),
        op.layoutget(False, LAYOUT4_BLOCK_VOLUME, LAYOUTIOMODE4_RW, 8192, 8192,
                     8192, lo_stateid1, 0xffff)
    ]
    res = sess.compound(ops)
    check(res)
    lo_stateid2 = res.resarray[-1].logr_stateid
    print lo_stateid2
    # Parse opaque to get info for commit
    # STUB not very general
    layout = res.resarray[-1].logr_layout[-1]
    p = BlockUnpacker(layout.loc_body)
    opaque = p.unpack_pnfs_block_layout4()
    p.done()
    extent = opaque.blo_extents[-1]
    extent.bex_state = PNFS_BLOCK_READWRITE_DATA
    p = BlockPacker()
    p.pack_pnfs_block_layoutupdate4(pnfs_block_layoutupdate4([extent]))
    time = newtime4(True, get_nfstime())
    ops = [
        op.putfh(fh),
        op.layoutcommit(extent.bex_file_offset, extent.bex_length, False,
                        lo_stateid2, newoffset4(True, 2 * 8192 - 1), time,
                        layoutupdate4(LAYOUT4_BLOCK_VOLUME, p.get_buffer()))
    ]
    res = sess.compound(ops)
    check(res)
    # Send another LAYOUTCOMMIT, with an empty opaque
    time = newtime4(True, get_nfstime())
    ops = [
        op.putfh(fh),
        op.layoutcommit(extent.bex_file_offset, extent.bex_length, False,
                        lo_stateid2, newoffset4(True, 2 * 8192 - 1), time,
                        layoutupdate4(LAYOUT4_BLOCK_VOLUME, ""))
    ]
    res = sess.compound(ops)
    check(res)