Exemple #1
0
def test_zns_ioworker(nvme0, nvme0n1, qpair, buf, zone_size, num_of_zones):
    slba = zone_size*int(random.randrange(num_of_zones))
    logging.info("Test zslba: 0x%x" % slba)
    zone = Zone(qpair, nvme0n1, slba)
    zone.reset()    

    nvme0n1.ioworker(io_size=8, lba_random=False, read_percentage=0, \
            region_start=slba, region_end=slba+zone.capacity).start().close()

    assert zone.state == 'Full'
    test_zns_management_receive(nvme0, nvme0n1, qpair, buf, zone_size, num_of_zones)
Exemple #2
0
def test_zns_write_a_closed_zone(nvme0, nvme0n1, qpair, zone, buf, zone_size, num_of_zones):
    slba = zone_size*int(random.randrange(num_of_zones))
    logging.info("Test zslba: 0x%x" % slba)
    zone = Zone(qpair, nvme0n1, slba)
    zone.reset()

    zone.write(qpair, buf, 0, 16).waitdone()
    zone.close()

    with pytest.warns(UserWarning, match="ERROR status: 01/bc"):
        zone.write(qpair, buf, 0x0, 8).waitdone()
    test_zns_management_receive(nvme0, nvme0n1, qpair, buf, zone_size, num_of_zones)
Exemple #3
0
def test_zns_transition_next_zone(nvme0, nvme0n1, qpair, buf, zone_size, num_of_zones, repeat):
    zone_index = int(random.randrange(num_of_zones))
    if zone_index == num_of_zones - 1:        
        next_index = zone_index
        zone_index = zone_index - 1
    else:
        next_index = (zone_index + 1) % num_of_zones
    slba = zone_size * zone_index
    next_slba = next_index*zone_size
    logging.info("Fill Zone 0x%x, zslba: 0x%x" % (zone_index, slba))
    logging.info("Next Zone 0x%x, zslba: 0x%x" % (next_index, next_slba))
    zone = Zone(qpair, nvme0n1, slba)
    zone.reset()
    next_zone = Zone(qpair, nvme0n1, next_slba)
    next_zone.reset()
    
    if (zone.capacity < zone_size):
        nvme0n1.ioworker(io_size=8, lba_random=False, read_percentage=0, \
                region_start=slba, region_end=slba+zone.capacity).start().close()
        nvme0n1.ioworker(io_size=8, lba_random=False, read_percentage=0, \
                region_start=next_slba, region_end=next_slba+128).start().close()
    else:
        nvme0n1.ioworker(io_size=8, lba_random=False, read_percentage=0, \
                region_start=slba, region_end=slba+zone.capacity+128).start().close()

    assert zone.state == 'Full'
    assert next_zone.state == 'Implicitly Opened'
    test_zns_management_receive(nvme0, nvme0n1, qpair, buf, zone_size, num_of_zones)
Exemple #4
0
def test_zns_write_full_zone(nvme0, nvme0n1, qpair, slba=0):
    buf = Buffer(96*1024)
    z0 = Zone(qpair, nvme0n1, slba)
    #with pytest.warns(UserWarning, match="ERROR status: 01/"):
    z0.write(qpair, buf, 0, 16).waitdone()

    z0.reset()
    z0.finish()
    assert z0.state == 'Full'
Exemple #5
0
def zone(nvme0, nvme0n1, qpair, buf, num_of_zones, zone_size):
    slba = zone_size*int(random.randrange(num_of_zones))
    logging.debug("slba:0x%x" % slba )
    ret = Zone(qpair, nvme0n1, slba)
    ret.reset()
    ret.open()
    assert ret.state == 'Explicitly Opened'
    assert ret.wpointer == ret.slba
    return ret
Exemple #6
0
def test_zns_write_implicitly_open(nvme0, nvme0n1, qpair, slba, repeat):
    buf = Buffer(96*1024)
    z0 = Zone(qpair, nvme0n1, slba)
    #assert z0.state == 'Full'
    
    z0.reset()
    assert z0.state == 'Empty'
    assert z0.wpointer == slba

    z0.write(qpair, buf, 0, 16).waitdone()
    time.sleep(1)
    logging.info("Write pointer:0x%x" % z0.wpointer)
    assert z0.state == 'Implicitly Opened'
    assert z0.wpointer == slba+16

    z0.close()
    #logging.info(z0)
    assert z0.state == 'Closed'
    assert z0.wpointer == slba+0x10
    
    z0.finish()
    logging.info(z0)
    assert z0.state == 'Full'
    assert z0.wpointer == slba+0x10
Exemple #7
0
def test_zns_management_receive(nvme0, nvme0n1, qpair, buf, zone_size, num_of_zones):
    logging.info("number of zones: %d" % num_of_zones)
    logging.info("zone size: 0x%x" % zone_size)

    for i in range(num_of_zones):
        base = 64
        nvme0n1.zns_mgmt_receive(qpair, buf, slba=i*zone_size).waitdone()
        zone_type = buf.data(base)
        assert zone_type == 2

        zone = Zone(qpair, nvme0n1, i*zone_size)
        assert zone.capacity <= zone_size
        #assert buf.data(base+1)>>4 == 14
        assert buf.data(base+15, base+8) == zone.capacity
        logging.info(zone)
Exemple #8
0
def test_zns_fill_a_zone(nvme0, nvme0n1, qpair, buf, zone_size, num_of_zones):
    slba = zone_size*int(random.randrange(num_of_zones))
    logging.info("Test zslba: 0x%x" % slba)
    zone = Zone(qpair, nvme0n1, slba)
    zone.reset()

    #for lba in range(slba, slba+zone_size, 8):
    #    nvme0n1.write(qpair, buf, lba, 8).waitdone()
    for lba in range(0, zone.capacity, 16):
        zone.write(qpair, buf, lba, 16).waitdone()

    assert zone.state == 'Full'
    test_zns_management_receive(nvme0, nvme0n1, qpair, buf, zone_size, num_of_zones)
Exemple #9
0
def test_max_open_zone(nvme0, nvme0n1, qpair, buf, zone_size, num_of_zones, zslba_list):
    nvme0.identify(buf, nsid=1, cns=5, csi=2).waitdone()
    mor = buf.data(11, 8)
    logging.info("Maximum Open Resources (MAR): 0x%x" % mor)

    if (mor == 0xffffffff):
        pytest.skip("No Max open zone limit")
    else:
        assert mor < num_of_zones

        for zone_index, slba in enumerate(zslba_list):
            z0 = Zone(qpair, nvme0n1, slba)
            z0.reset()
            if zone_index <= mor:
                z0.open()
                logging.info("open zone: %d" % zone_index)
            else:
                logging.info("Try to open extra zone: %d" % zone_index)
                with pytest.warns(UserWarning, match="ERROR status: 01/be"):
                    z0.open()

                break
        test_zns_management_receive(nvme0, nvme0n1, qpair, buf, zone_size, num_of_zones)
Exemple #10
0
def test_zone_append(nvme0, nvme0n1, qpair, buf, zone_size, num_of_zones):
    alba = 0

    def z_append_cb(cpl):
        nonlocal alba
        alba = (cpl[1] << 32) | cpl[0]

    zone_index = int(random.randrange(num_of_zones))
    slba = zone_size * zone_index
    zone = Zone(qpair, nvme0n1, slba)
    logging.info("Append Zone 0x%x, zslba: 0x%x, wp:0x%x" % (zone_index, slba, zone.wpointer))

    current_wp = zone.wpointer
    zone.append(qpair, buf, lba_count=9, cb=z_append_cb).waitdone()
    logging.info("Append Zone 0x%x, zslba: 0x%x, wp:0x%x" % (zone_index, slba, zone.wpointer))
    assert alba == current_wp

    current_wp = zone.wpointer
    zone.append(qpair, buf, lba_count=9, cb=z_append_cb).waitdone()
    logging.info("Append Zone 0x%x, zslba: 0x%x, wp:0x%x" % (zone_index, slba, zone.wpointer))
    assert alba == current_wp
    # zone append not from the zslba,Invalid Field in Command 00/02
    with pytest.warns(UserWarning, match="ERROR status: 00/02"):
        zone.append(qpair, buf, slba+10).waitdone()
Exemple #11
0
def test_zns_show_zone(nvme0, nvme0n1, qpair, slba=0):
    z0 = Zone(qpair, nvme0n1, slba)
    logging.info(z0)
Exemple #12
0
def test_zns_state_machine_all(nvme0, nvme0n1, qpair, buf, zslba_list):
    for slba in zslba_list:
        z0 = Zone(qpair, nvme0n1, slba)
        logging.info("zslba:0x%x" % slba)

        z0.reset()
        assert z0.state == 'Empty'
        
        z0.open()
        assert z0.state == 'Explicitly Opened'
        
        z0.close()
        assert z0.state == 'Closed'

        z0.open()
        assert z0.state == 'Explicitly Opened'
        
        z0.close()
        assert z0.state == 'Closed'

        z0.finish()
        assert z0.state == 'Full'
        
        z0.reset()
        assert z0.state == 'Empty'

        z0.open()
        assert z0.state == 'Explicitly Opened'
        
        z0.reset()
        assert z0.state == 'Empty'

        z0.open()
        assert z0.state == 'Explicitly Opened'
        
        z0.close()
        assert z0.state == 'Closed'

        z0.reset()
        assert z0.state == 'Empty'
        
        z0.finish()
        assert z0.state == 'Full'

        z0.reset()
Exemple #13
0
def test_zns_state_machine(nvme0, nvme0n1, qpair, buf, slba):
    z0 = Zone(qpair, nvme0n1, slba)

    z0.reset()
    assert z0.state == 'Empty'
    
    z0.open()
    assert z0.state == 'Explicitly Opened'
    
    z0.close()
    assert z0.state == 'Closed'

    z0.open()
    assert z0.state == 'Explicitly Opened'
    
    z0.close()
    assert z0.state == 'Closed'

    z0.finish()
    assert z0.state == 'Full'
    
    z0.reset()
    assert z0.state == 'Empty'

    z0.open()
    assert z0.state == 'Explicitly Opened'
    
    z0.reset()
    assert z0.state == 'Empty'

    z0.open()
    assert z0.state == 'Explicitly Opened'
    
    z0.close()
    assert z0.state == 'Closed'
    
    z0.finish()
    assert z0.state == 'Full'

    z0.reset()
    assert z0.state == 'Empty'
Exemple #14
0
def test_zns_management_send(nvme0, nvme0n1, qpair):
    z0 = Zone(qpair, nvme0n1, 0)
    z0.action(2)
    assert z0.state == 'Full'
Exemple #15
0
def get_zone_gap(nvme0n1, qpair, zone_size, slba):
    zone = Zone(qpair, nvme0n1, slba)
    ret = zone_size - zone.capacity
    logging.debug("zone size:0x%x, zcap:0x%x" %(zone_size, zone.capacity))
    return ret