From e0c762387c4e6c186ffa704d025b9205d6f05d72 Mon Sep 17 00:00:00 2001 From: Adam Rutkowski Date: Mon, 7 Mar 2022 15:50:56 +0100 Subject: [PATCH] pyocf: implement get_(front_)volume() in Cache and Core This common interface is later going to be used for generic code implementing cache/core exported object I/O. Signed-off-by: Adam Rutkowski --- tests/functional/pyocf/types/cache.py | 12 +++++++++++- tests/functional/pyocf/types/core.py | 9 ++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/tests/functional/pyocf/types/cache.py b/tests/functional/pyocf/types/cache.py index f27978a..1c18f15 100644 --- a/tests/functional/pyocf/types/cache.py +++ b/tests/functional/pyocf/types/cache.py @@ -35,12 +35,12 @@ from ..utils import Size, struct_to_dict from .core import Core from .queue import Queue from .stats.cache import CacheInfo +from .io import IoDir from .ioclass import IoClassesInfo, IoClassInfo from .stats.shared import UsageStats, RequestsStats, BlocksStats, ErrorsStats from .ctx import OcfCtx from .volume import RamVolume - class Backfill(Structure): _fields_ = [("_max_queue_size", c_uint32), ("_queue_unblock_size", c_uint32)] @@ -655,6 +655,12 @@ class Cache: self.cores.remove(core) + def get_front_volume(self): + return Volume.get_instance(lib.ocf_cache_get_front_volume(self.cache_handle)) + + def get_volume(self): + return Volume.get_instance(lib.ocf_cache_get_volume(self.cache_handle)) + def get_stats(self): cache_info = CacheInfo() usage = UsageStats() @@ -803,6 +809,10 @@ lib.ocf_mngt_cache_remove_core.argtypes = [c_void_p, c_void_p, c_void_p] lib.ocf_mngt_cache_add_core.argtypes = [c_void_p, c_void_p, c_void_p, c_void_p] lib.ocf_cache_get_name.argtypes = [c_void_p] lib.ocf_cache_get_name.restype = c_char_p +lib.ocf_cache_get_front_volume.argtypes = [c_void_p] +lib.ocf_cache_get_front_volume.restype = c_void_p +lib.ocf_cache_get_volume.argtypes = [c_void_p] +lib.ocf_cache_get_volume.restype = c_void_p lib.ocf_mngt_cache_cleaning_set_policy.argtypes = [ c_void_p, c_uint32, diff --git a/tests/functional/pyocf/types/core.py b/tests/functional/pyocf/types/core.py index 33d076e..f980e6c 100644 --- a/tests/functional/pyocf/types/core.py +++ b/tests/functional/pyocf/types/core.py @@ -114,6 +114,12 @@ class Core: return Io.from_pointer(io) + def get_front_volume(self): + return Volume.get_instance(lib.ocf_core_get_front_volume(self.handle)) + + def get_volume(self): + return Volume.get_instance(lib.ocf_core_get_volume(self.handle)) + def new_core_io( self, queue: Queue, addr: int, length: int, direction: IoDir, io_class: int, flags: int @@ -227,7 +233,6 @@ class Core: lib = OcfLib.getInstance() lib.ocf_core_get_uuid_wrapper.restype = POINTER(Uuid) lib.ocf_core_get_uuid_wrapper.argtypes = [c_void_p] -lib.ocf_core_get_volume.restype = c_void_p lib.ocf_volume_new_io.argtypes = [ c_void_p, c_void_p, @@ -240,6 +245,8 @@ lib.ocf_volume_new_io.argtypes = [ lib.ocf_volume_new_io.restype = c_void_p lib.ocf_core_get_volume.argtypes = [c_void_p] lib.ocf_core_get_volume.restype = c_void_p +lib.ocf_core_get_front_volume.argtypes = [c_void_p] +lib.ocf_core_get_front_volume.restype = c_void_p lib.ocf_mngt_core_set_seq_cutoff_policy.argtypes = [c_void_p, c_uint32] lib.ocf_mngt_core_set_seq_cutoff_policy.restype = c_int lib.ocf_mngt_core_set_seq_cutoff_threshold.argtypes = [c_void_p, c_uint32]