Introduce ocf_forward_get_data()
Skip the ocf_io abstraction and get the data directly from the request. Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com> Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
This commit is contained in:
parent
54f75ba492
commit
6aa141c247
@ -91,9 +91,8 @@ static void volume_submit_discard(struct ocf_io *io)
|
||||
void volume_forward_io(ocf_volume_t volume, ocf_forward_token_t token,
|
||||
int dir, uint64_t addr, uint64_t bytes, uint64_t offset)
|
||||
{
|
||||
struct ocf_io *io = ocf_forward_get_io(token);
|
||||
struct myvolume *myvolume = ocf_volume_get_priv(volume);
|
||||
struct volume_data *data = ocf_io_get_data(io);
|
||||
struct volume_data *data = ocf_forward_get_data(token);
|
||||
|
||||
if (dir == OCF_WRITE) {
|
||||
memcpy(myvolume->mem + addr,
|
||||
|
@ -243,6 +243,13 @@ ocf_volume_t ocf_io_get_volume(struct ocf_io *io);
|
||||
*/
|
||||
struct ocf_io *ocf_forward_get_io(ocf_forward_token_t token);
|
||||
|
||||
/**
|
||||
* @brief Get the data to be submitted
|
||||
*
|
||||
* @param[in] token Forward token
|
||||
*/
|
||||
ctx_data_t *ocf_forward_get_data(ocf_forward_token_t token);
|
||||
|
||||
/**
|
||||
* @brief Forward io to another subvolume
|
||||
*
|
||||
|
@ -559,6 +559,13 @@ struct ocf_io *ocf_forward_get_io(ocf_forward_token_t token)
|
||||
return &req->ioi.io;
|
||||
}
|
||||
|
||||
ctx_data_t *ocf_forward_get_data(ocf_forward_token_t token)
|
||||
{
|
||||
struct ocf_request *req = (struct ocf_request *)(token & ~1);
|
||||
|
||||
return req->data;
|
||||
}
|
||||
|
||||
static inline void _ocf_forward_get(ocf_forward_token_t token)
|
||||
{
|
||||
struct ocf_request *req = (struct ocf_request *)(token & ~1);
|
||||
|
@ -519,14 +519,12 @@ class RamVolume(Volume):
|
||||
|
||||
def do_forward_io(self, token, rw, addr, nbytes, offset):
|
||||
try:
|
||||
io = Io.get_by_forward_token(token)
|
||||
|
||||
if rw == IoDir.WRITE:
|
||||
src_ptr = cast(OcfLib.getInstance().ocf_io_get_data(io), c_void_p)
|
||||
src_ptr = cast(OcfLib.getInstance().ocf_forward_get_data(token), c_void_p)
|
||||
src = Data.get_instance(src_ptr.value).handle.value + offset
|
||||
dst = self.data_ptr + addr
|
||||
elif rw == IoDir.READ:
|
||||
dst_ptr = cast(OcfLib.getInstance().ocf_io_get_data(io), c_void_p)
|
||||
dst_ptr = cast(OcfLib.getInstance().ocf_forward_get_data(token), c_void_p)
|
||||
dst = Data.get_instance(dst_ptr.value).handle.value + offset
|
||||
src = self.data_ptr + addr
|
||||
|
||||
@ -818,6 +816,8 @@ lib.ocf_io_get_volume.argtypes = [c_void_p]
|
||||
lib.ocf_io_get_volume.restype = c_void_p
|
||||
lib.ocf_io_get_data.argtypes = [c_void_p]
|
||||
lib.ocf_io_get_data.restype = c_void_p
|
||||
lib.ocf_forward_get_data.argtypes = [c_uint64]
|
||||
lib.ocf_forward_get_data.restype = c_void_p
|
||||
lib.ocf_volume_new_io.argtypes = [
|
||||
c_void_p,
|
||||
c_void_p,
|
||||
|
@ -24,7 +24,7 @@ class OcfInternalVolume(Volume):
|
||||
queue = self.parent.get_default_queue() # TODO multiple queues?
|
||||
return self.new_io(queue, addr, _bytes, _dir, _class, _flags)
|
||||
|
||||
def _alloc_io(self, io, rw=None, addr=None, nbytes=None, offset=0):
|
||||
def _alloc_io(self, io, cdata=None, rw=None, addr=None, nbytes=None, offset=0):
|
||||
exp_obj_io = self.__alloc_io(
|
||||
addr or io.contents._addr,
|
||||
nbytes or io.contents._bytes,
|
||||
@ -33,6 +33,7 @@ class OcfInternalVolume(Volume):
|
||||
io.contents._flags,
|
||||
)
|
||||
|
||||
if not cdata:
|
||||
cdata = OcfLib.getInstance().ocf_io_get_data(io)
|
||||
OcfLib.getInstance().ocf_io_set_data(byref(exp_obj_io), cdata, offset)
|
||||
|
||||
@ -65,7 +66,8 @@ class OcfInternalVolume(Volume):
|
||||
|
||||
def do_forward_io(self, token, rw, addr, nbytes, offset):
|
||||
orig_io = Io.get_by_forward_token(token)
|
||||
io = self._alloc_io(orig_io, rw, addr, nbytes, offset)
|
||||
cdata = OcfLib.getInstance().ocf_forward_get_data(token)
|
||||
io = self._alloc_io(orig_io, cdata, rw, addr, nbytes, offset)
|
||||
|
||||
def cb(error):
|
||||
nonlocal io
|
||||
@ -78,12 +80,14 @@ class OcfInternalVolume(Volume):
|
||||
|
||||
def do_forward_flush(self, token):
|
||||
orig_io = Io.get_by_forward_token(token)
|
||||
io = self._alloc_io(orig_io)
|
||||
cdata = OcfLib.getInstance().ocf_forward_get_data(token)
|
||||
io = self._alloc_io(orig_io, cdata)
|
||||
io.submit_flush()
|
||||
|
||||
def do_forward_discard(self, token, addr, nbytes):
|
||||
orig_io = Io.get_by_forward_token(token)
|
||||
io = self._alloc_io(orig_io, addr=addr, nbytes=nbytes)
|
||||
cdata = OcfLib.getInstance().ocf_forward_get_data(token)
|
||||
io = self._alloc_io(orig_io, cdata, addr=addr, nbytes=nbytes)
|
||||
io.submit_discard()
|
||||
|
||||
def _read(self, offset=0, size=0):
|
||||
@ -160,3 +164,5 @@ lib.ocf_volume_get_length.argtypes = [c_void_p]
|
||||
lib.ocf_volume_get_length.restype = c_uint64
|
||||
lib.ocf_io_get_data.argtypes = [POINTER(Io)]
|
||||
lib.ocf_io_get_data.restype = c_void_p
|
||||
lib.ocf_forward_get_data.argtypes = [c_uint64]
|
||||
lib.ocf_forward_get_data.restype = c_void_p
|
||||
|
Loading…
Reference in New Issue
Block a user