Merge new_io and configure - update tests
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
@@ -11,9 +11,10 @@ from ctypes import (
|
||||
c_int,
|
||||
c_uint8,
|
||||
c_uint16,
|
||||
c_uint32,
|
||||
c_uint64,
|
||||
c_char_p,
|
||||
c_bool,
|
||||
c_uint32,
|
||||
cast,
|
||||
byref,
|
||||
create_string_buffer,
|
||||
@@ -22,6 +23,7 @@ from datetime import timedelta
|
||||
|
||||
from .data import Data
|
||||
from .io import Io, IoDir
|
||||
from .queue import Queue
|
||||
from .shared import Uuid, OcfCompletion, OcfError, SeqCutOffPolicy
|
||||
from .stats.core import CoreStats
|
||||
from .stats.shared import UsageStats, RequestsStats, BlocksStats, ErrorsStats
|
||||
@@ -92,17 +94,25 @@ class Core:
|
||||
def get_handle(self):
|
||||
return self.handle
|
||||
|
||||
def new_io(self):
|
||||
def new_io(
|
||||
self, queue: Queue, addr: int, length: int, direction: IoDir,
|
||||
io_class: int, flags: int
|
||||
):
|
||||
if not self.cache:
|
||||
raise Exception("Core isn't attached to any cache")
|
||||
|
||||
io = OcfLib.getInstance().ocf_core_new_io_wrapper(self.handle)
|
||||
io = OcfLib.getInstance().ocf_core_new_io_wrapper(
|
||||
self.handle, queue.handle, addr, length, direction, io_class, flags)
|
||||
return Io.from_pointer(io)
|
||||
|
||||
def new_core_io(self):
|
||||
def new_core_io(
|
||||
self, queue: Queue, addr: int, length: int, direction: IoDir,
|
||||
io_class: int, flags: int
|
||||
):
|
||||
lib = OcfLib.getInstance()
|
||||
core = lib.ocf_core_get_volume(self.handle)
|
||||
io = lib.ocf_volume_new_io(core)
|
||||
volume = lib.ocf_core_get_volume(self.handle)
|
||||
io = lib.ocf_volume_new_io(
|
||||
volume, queue.handle, addr, length, direction, io_class, flags)
|
||||
return Io.from_pointer(io)
|
||||
|
||||
def get_stats(self):
|
||||
@@ -166,10 +176,9 @@ class Core:
|
||||
|
||||
position = 0
|
||||
while position < read_buffer_all.size:
|
||||
io = self.new_io()
|
||||
io.configure(position, cache_line_size, IoDir.READ, 0, 0)
|
||||
io = self.new_io(self.cache.get_default_queue(), position,
|
||||
cache_line_size, IoDir.READ, 0, 0)
|
||||
io.set_data(read_buffer)
|
||||
io.set_queue(self.cache.get_default_queue())
|
||||
|
||||
cmpl = OcfCompletion([("err", c_int)])
|
||||
io.callback = cmpl.callback
|
||||
@@ -187,7 +196,15 @@ class Core:
|
||||
|
||||
lib = OcfLib.getInstance()
|
||||
lib.ocf_core_get_volume.restype = c_void_p
|
||||
lib.ocf_volume_new_io.argtypes = [c_void_p]
|
||||
lib.ocf_volume_new_io.argtypes = [
|
||||
c_void_p,
|
||||
c_void_p,
|
||||
c_uint64,
|
||||
c_uint32,
|
||||
c_uint32,
|
||||
c_uint32,
|
||||
c_uint64,
|
||||
]
|
||||
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
|
||||
@@ -197,3 +214,13 @@ lib.ocf_stats_collect_core.argtypes = [c_void_p, c_void_p, c_void_p, c_void_p, c
|
||||
lib.ocf_stats_collect_core.restype = c_int
|
||||
lib.ocf_core_get_stats.argtypes = [c_void_p, c_void_p]
|
||||
lib.ocf_core_get_stats.restype = c_int
|
||||
lib.ocf_core_new_io_wrapper.argtypes = [
|
||||
c_void_p,
|
||||
c_void_p,
|
||||
c_uint64,
|
||||
c_uint32,
|
||||
c_uint32,
|
||||
c_uint32,
|
||||
c_uint64,
|
||||
]
|
||||
lib.ocf_core_new_io_wrapper.restype = c_void_p
|
||||
|
@@ -18,7 +18,6 @@ from enum import IntEnum
|
||||
|
||||
from ..ocf import OcfLib
|
||||
from .data import Data
|
||||
from .queue import Queue
|
||||
|
||||
|
||||
class IoDir(IntEnum):
|
||||
@@ -99,20 +98,10 @@ class Io(Structure):
|
||||
def submit(self):
|
||||
return OcfLib.getInstance().ocf_core_submit_io_wrapper(byref(self))
|
||||
|
||||
def configure(
|
||||
self, addr: int, length: int, direction: IoDir, io_class: int, flags: int
|
||||
):
|
||||
OcfLib.getInstance().ocf_io_configure_wrapper(
|
||||
byref(self), addr, length, direction, io_class, flags
|
||||
)
|
||||
|
||||
def set_data(self, data: Data, offset: int = 0):
|
||||
self.data = data
|
||||
OcfLib.getInstance().ocf_io_set_data(byref(self), data, offset)
|
||||
|
||||
def set_queue(self, queue: Queue):
|
||||
OcfLib.getInstance().ocf_io_set_queue_wrapper(byref(self), queue.handle)
|
||||
|
||||
|
||||
IoOps.SET_DATA = CFUNCTYPE(c_int, POINTER(Io), c_void_p, c_uint32)
|
||||
IoOps.GET_DATA = CFUNCTYPE(c_void_p, POINTER(Io))
|
||||
@@ -120,22 +109,10 @@ IoOps.GET_DATA = CFUNCTYPE(c_void_p, POINTER(Io))
|
||||
IoOps._fields_ = [("_set_data", IoOps.SET_DATA), ("_get_data", IoOps.GET_DATA)]
|
||||
|
||||
lib = OcfLib.getInstance()
|
||||
lib.ocf_core_new_io_wrapper.restype = POINTER(Io)
|
||||
lib.ocf_io_set_cmpl_wrapper.argtypes = [POINTER(Io), c_void_p, c_void_p, Io.END]
|
||||
lib.ocf_io_configure_wrapper.argtypes = [
|
||||
POINTER(Io),
|
||||
c_uint64,
|
||||
c_uint32,
|
||||
c_uint32,
|
||||
c_uint32,
|
||||
c_uint64,
|
||||
]
|
||||
lib.ocf_io_set_queue_wrapper.argtypes = [POINTER(Io), c_uint32]
|
||||
|
||||
lib.ocf_core_new_io_wrapper.argtypes = [c_void_p]
|
||||
lib.ocf_core_new_io_wrapper.restype = c_void_p
|
||||
|
||||
lib.ocf_io_set_data.argtypes = [POINTER(Io), c_void_p, c_uint32]
|
||||
lib.ocf_io_set_data.restype = c_int
|
||||
|
||||
lib.ocf_io_set_queue_wrapper.argtypes = [POINTER(Io), c_void_p]
|
||||
|
@@ -6,15 +6,11 @@
|
||||
#include "ocf/ocf_io.h"
|
||||
#include "ocf/ocf_core.h"
|
||||
|
||||
struct ocf_io *ocf_core_new_io_wrapper(ocf_core_t core)
|
||||
struct ocf_io *ocf_core_new_io_wrapper(ocf_core_t core, ocf_queue_t queue,
|
||||
uint64_t addr, uint32_t bytes, uint32_t dir,
|
||||
uint32_t io_class, uint64_t flags)
|
||||
{
|
||||
return ocf_core_new_io(core);
|
||||
}
|
||||
|
||||
void ocf_io_configure_wrapper(struct ocf_io *io, uint64_t addr,
|
||||
uint32_t bytes, uint32_t dir, uint32_t class, uint64_t flags)
|
||||
{
|
||||
ocf_io_configure(io, addr, bytes, dir, class, flags);
|
||||
return ocf_core_new_io(core, queue, addr, bytes, dir, io_class, flags);
|
||||
}
|
||||
|
||||
void ocf_io_set_cmpl_wrapper(struct ocf_io *io, void *context,
|
||||
@@ -33,11 +29,6 @@ void ocf_io_set_handle_wrapper(struct ocf_io *io, ocf_handle_io_t fn)
|
||||
ocf_io_set_handle(io, fn);
|
||||
}
|
||||
|
||||
void ocf_io_set_queue_wrapper(struct ocf_io *io, ocf_queue_t queue)
|
||||
{
|
||||
ocf_io_set_queue(io, queue);
|
||||
}
|
||||
|
||||
void ocf_core_submit_io_wrapper(struct ocf_io *io)
|
||||
{
|
||||
ocf_core_submit_io(io);
|
||||
|
Reference in New Issue
Block a user