Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Io forward pt2 #831

Merged
merged 24 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
cd544e8
Introduce ocf_forward_write_zeros()
robertbaldyga Oct 13, 2023
17144e5
composite: Add forward_write_zeros support
robertbaldyga Oct 13, 2023
5859e43
Introduce ocf_forward_metadata()
robertbaldyga Oct 13, 2023
07abdf5
composite: Add forward_metadata support
robertbaldyga Oct 13, 2023
54f75ba
Introduce ocf_req_forward_volume_*()
robertbaldyga Oct 13, 2023
6aa141c
Introduce ocf_forward_get_data()
robertbaldyga Oct 12, 2023
2d303e8
Replace ocf_forward_get_io() with more specific ops
robertbaldyga Oct 13, 2023
1f26ceb
composite: Add forward_io_simple support
robertbaldyga Oct 16, 2023
1c2d5bb
Introduce forward_io_simple
robertbaldyga Oct 16, 2023
8347868
Replace submit with forward in mngt
robertbaldyga Oct 12, 2023
322ae26
Replace submit with forward in cleaner
robertbaldyga Oct 12, 2023
29ca8fb
Replace submit with forward in standby
robertbaldyga Oct 13, 2023
af3b379
Replace submit with forward in metadata_io
robertbaldyga Oct 13, 2023
9404716
Replace submit with forward in metadata_raw_atomic
robertbaldyga Oct 13, 2023
39d566c
Replace submit with forward in ocf_metadata_read_sb()
robertbaldyga Oct 13, 2023
7fb6b62
Drop support for submit_* ops in backend volumes
robertbaldyga Oct 13, 2023
c5741df
Bind ocf_io to ocf_request
robertbaldyga Oct 13, 2023
be0ad8f
pyocf: Update tests after the API changes
robertbaldyga Oct 13, 2023
ff5c20b
Redirect ocf_volume_submit_* operations to forward
robertbaldyga Oct 13, 2023
f72b922
Remove struct ocf_io
mmichal10 Jul 26, 2024
6392cce
example: simple: Update after removing struct ocf_io
robertbaldyga Dec 21, 2023
9b7f476
pyocf: Update after removing struct ocf_io
robertbaldyga Dec 21, 2023
d8d7504
tests: pyocf: Remove legacy submit_* ops implementation from volumes
robertbaldyga Dec 21, 2023
3fbb757
Consolidate ocf_request_io and ocf_request - io properties
robertbaldyga Aug 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions example/simple/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ int initialize_core(ocf_cache_t cache, ocf_core_t *core)
/*
* Callback function called when write completes.
*/
void complete_write(struct ocf_io *io, int error)
void complete_write(ocf_io_t io, void *priv1, void *priv2, int error)
{
struct volume_data *data = ocf_io_get_data(io);

Expand All @@ -253,7 +253,7 @@ void complete_write(struct ocf_io *io, int error)
/*
* Callback function called when read completes.
*/
void complete_read(struct ocf_io *io, int error)
void complete_read(ocf_io_t io, void *priv1, void *priv2, int error)
{
struct volume_data *data = ocf_io_get_data(io);

Expand All @@ -274,7 +274,7 @@ int submit_io(ocf_core_t core, struct volume_data *data,
ocf_cache_t cache = ocf_core_get_cache(core);
ocf_volume_t core_vol = ocf_core_get_front_volume(core);
struct cache_priv *cache_priv = ocf_cache_get_priv(cache);
struct ocf_io *io;
ocf_io_t io;

/* Allocate new io */
io = ocf_volume_new_io(core_vol, cache_priv->io_queue, addr, len, dir, 0, 0);
Expand Down
80 changes: 1 addition & 79 deletions example/simple/src/volume.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,57 +43,11 @@ static void volume_close(ocf_volume_t volume)
free(myvolume->mem);
}

/*
* In submit_io() function we simulate read or write to backend storage device
* by doing memcpy() to or from previously allocated memory buffer.
*/
static void volume_submit_io(struct ocf_io *io)
{
struct myvolume_io *myvolume_io = ocf_io_get_priv(io);
struct volume_data *data;
struct myvolume *myvolume;
uint32_t offset = myvolume_io->offset;

data = ocf_io_get_data(io);
myvolume = ocf_volume_get_priv(ocf_io_get_volume(io));

if (io->dir == OCF_WRITE) {
memcpy(myvolume->mem + io->addr,
data->ptr + offset, io->bytes);
} else {
memcpy(data->ptr + offset,
myvolume->mem + io->addr, io->bytes);
}

printf("VOL: (name: %s), IO: (dir: %s, addr: %ld, bytes: %d)\n",
myvolume->name, io->dir == OCF_READ ? "read" : "write",
io->addr, io->bytes);

io->end(io, 0);
}

/*
* We don't need to implement submit_flush(). Just complete io with success.
*/
static void volume_submit_flush(struct ocf_io *io)
{
io->end(io, 0);
}

/*
* We don't need to implement submit_discard(). Just complete io with success.
*/
static void volume_submit_discard(struct ocf_io *io)
{
io->end(io, 0);
}

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,
Expand Down Expand Up @@ -139,58 +93,26 @@ static uint64_t volume_get_length(ocf_volume_t volume)
return VOL_SIZE;
}

/*
* In set_data() we just assing data and offset to io.
*/
static int myvolume_io_set_data(struct ocf_io *io, ctx_data_t *data,
uint32_t offset)
{
struct myvolume_io *myvolume_io = ocf_io_get_priv(io);

myvolume_io->data = data;
myvolume_io->offset = offset;

return 0;
}

/*
* In get_data() return data stored in io.
*/
static ctx_data_t *myvolume_io_get_data(struct ocf_io *io)
{
struct myvolume_io *myvolume_io = ocf_io_get_priv(io);

return myvolume_io->data;
}

/*
* This structure contains volume properties. It describes volume
* type, which can be later instantiated as backend storage for cache
* or core.
*/
const struct ocf_volume_properties volume_properties = {
.name = "Example volume",
.io_priv_size = sizeof(struct myvolume_io),
.volume_priv_size = sizeof(struct myvolume),
.caps = {
.atomic_writes = 0,
},
.ops = {
.open = volume_open,
.close = volume_close,
.submit_io = volume_submit_io,
.submit_flush = volume_submit_flush,
.submit_discard = volume_submit_discard,
.forward_io = volume_forward_io,
.forward_flush = volume_forward_flush,
.forward_discard = volume_forward_discard,
.get_max_io_size = volume_get_max_io_size,
.get_length = volume_get_length,
},
.io_ops = {
.set_data = myvolume_io_set_data,
.get_data = myvolume_io_get_data,
},
};

/*
Expand Down
6 changes: 1 addition & 5 deletions example/simple/src/volume.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright(c) 2019-2021 Intel Corporation
* Copyright(c) 2024 Huawei Technologies
* SPDX-License-Identifier: BSD-3-Clause
*/

Expand All @@ -11,11 +12,6 @@
#include "ctx.h"
#include "data.h"

struct myvolume_io {
struct volume_data *data;
uint32_t offset;
};

struct myvolume {
uint8_t *mem;
const char *name;
Expand Down
7 changes: 4 additions & 3 deletions inc/ocf_core.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright(c) 2012-2022 Intel Corporation
* Copyright(c) 2024 Huawei Technologies
* SPDX-License-Identifier: BSD-3-Clause
*/

Expand Down Expand Up @@ -151,7 +152,7 @@ ocf_core_state_t ocf_core_get_state(ocf_core_t core);
*
* @param[in] io IO to be submitted
*/
static inline void ocf_core_submit_io(struct ocf_io *io)
static inline void ocf_core_submit_io(ocf_io_t io)
{
ocf_volume_submit_io(io);
}
Expand All @@ -161,7 +162,7 @@ static inline void ocf_core_submit_io(struct ocf_io *io)
*
* @param[in] io IO to be submitted
*/
static inline void ocf_core_submit_flush(struct ocf_io *io)
static inline void ocf_core_submit_flush(ocf_io_t io)
{
ocf_volume_submit_flush(io);
}
Expand All @@ -171,7 +172,7 @@ static inline void ocf_core_submit_flush(struct ocf_io *io)
*
* @param[in] io IO to be submitted
*/
static inline void ocf_core_submit_discard(struct ocf_io *io)
static inline void ocf_core_submit_discard(ocf_io_t io)
{
ocf_volume_submit_discard(io);
}
Expand Down
Loading