pyocf: make open/close explicit

Signed-off-by: Jan Musial <jan.musial@intel.com>
This commit is contained in:
Jan Musial
2022-06-20 14:59:40 +02:00
parent abc726d7f8
commit a0c6995189
23 changed files with 168 additions and 109 deletions

View File

@@ -191,7 +191,7 @@ def prepare_cache_and_core(core_size: Size, cache_size: Size = Size.from_MiB(50)
core = Core.using_device(core_device)
cache.add_core(core)
vol = CoreVolume(core, open=True)
vol = CoreVolume(core)
queue = cache.get_default_queue()
return vol, queue
@@ -200,6 +200,7 @@ def prepare_cache_and_core(core_size: Size, cache_size: Size = Size.from_MiB(50)
def io_operation(
vol: Volume, queue: Queue, data: Data, io_direction: int, offset: int = 0, io_class: int = 0,
):
vol.open()
io = vol.new_io(queue, offset, data.size, io_direction, io_class, 0)
io.set_data(data)
@@ -207,4 +208,5 @@ def io_operation(
io.callback = completion.callback
io.submit()
completion.wait()
vol.close()
return completion

View File

@@ -82,10 +82,11 @@ def test_secure_erase_simple_io_read_misses(cache_mode):
core_device = RamVolume(S.from_MiB(50))
core = Core.using_device(core_device)
cache.add_core(core)
vol = CoreVolume(core, open=True)
vol = CoreVolume(core)
queue = cache.get_default_queue()
write_data = DataCopyTracer(S.from_sector(1))
vol.open()
io = vol.new_io(queue, S.from_sector(1).B, write_data.size, IoDir.WRITE, 0, 0,)
io.set_data(write_data)
@@ -117,6 +118,7 @@ def test_secure_erase_simple_io_read_misses(cache_mode):
io.submit()
cmpl.wait()
vol.close()
stats = cache.get_stats()
ctx.exit()
@@ -156,10 +158,12 @@ def test_secure_erase_simple_io_cleaning():
core_device = RamVolume(S.from_MiB(100))
core = Core.using_device(core_device)
cache.add_core(core)
vol = CoreVolume(core, open=True)
vol = CoreVolume(core)
queue = cache.get_default_queue()
read_data = Data(S.from_sector(1).B)
vol.open()
io = vol.new_io(queue, S.from_sector(1).B, read_data.size, IoDir.WRITE, 0, 0)
io.set_data(read_data)
@@ -177,6 +181,7 @@ def test_secure_erase_simple_io_cleaning():
io.submit()
cmpl.wait()
vol.close()
stats = cache.get_stats()
ctx.exit()