diff --git a/src/metadata/metadata_io.c b/src/metadata/metadata_io.c index 0d521c7..5073fa6 100644 --- a/src/metadata/metadata_io.c +++ b/src/metadata/metadata_io.c @@ -179,10 +179,11 @@ int metadata_io_read_i_atomic(ocf_cache_t cache, ocf_queue_t queue, void *priv, static void metadata_io_req_fill(struct metadata_io_request *m_req) { ocf_cache_t cache = m_req->cache; + struct metadata_io_request_asynch *a_req = m_req->asynch; int i; for (i = 0; i < m_req->count; i++) { - m_req->on_meta_fill(cache, m_req->data, + a_req->on_meta_fill(cache, m_req->data, m_req->page + i, m_req->context); } } @@ -190,10 +191,11 @@ static void metadata_io_req_fill(struct metadata_io_request *m_req) static void metadata_io_req_drain(struct metadata_io_request *m_req) { ocf_cache_t cache = m_req->cache; + struct metadata_io_request_asynch *a_req = m_req->asynch; int i; for (i = 0; i < m_req->count; i++) { - m_req->on_meta_drain(cache, m_req->data, + a_req->on_meta_drain(cache, m_req->data, m_req->page + i, m_req->context); } } @@ -389,6 +391,8 @@ static int metadata_io_i_asynch(ocf_cache_t cache, ocf_queue_t queue, int dir, a_req->page = page; a_req->count = count; a_req->flags = flags; + a_req->on_meta_fill = io_hndl; + a_req->on_meta_drain = io_hndl; /* IO Requests initialization */ for (i = 0; i < req_count; i++) { @@ -397,8 +401,6 @@ static int metadata_io_i_asynch(ocf_cache_t cache, ocf_queue_t queue, int dir, m_req->asynch = a_req; m_req->cache = cache; m_req->context = context; - m_req->on_meta_fill = io_hndl; - m_req->on_meta_drain = io_hndl; m_req->req.io_if = &metadata_io_restart_if; m_req->req.io_queue = queue; m_req->req.cache = cache; diff --git a/src/metadata/metadata_io.h b/src/metadata/metadata_io.h index 30123c4..7109ce2 100644 --- a/src/metadata/metadata_io.h +++ b/src/metadata/metadata_io.h @@ -45,22 +45,19 @@ struct metadata_io_request_asynch; * IO request context */ struct metadata_io_request { - ocf_cache_t cache; - void *context; - uint32_t page; - uint32_t count; - ocf_metadata_io_event_t on_meta_fill; - ocf_metadata_io_event_t on_meta_drain; - ctx_data_t *data; - int error; - struct metadata_io_request_asynch *asynch; - env_atomic finished; - struct ocf_request req; struct list_head list; + ocf_cache_t cache; + void *context; + ctx_data_t *data; + struct metadata_io_request_asynch *asynch; + env_atomic finished; + uint32_t page; + uint32_t count; + int error; }; -#define METADATA_IO_REQS_LIMIT 128 +#define METADATA_IO_REQS_LIMIT 33 /* * Asynchronous IO request context @@ -68,14 +65,16 @@ struct metadata_io_request { struct metadata_io_request_asynch { struct metadata_io_request reqs[METADATA_IO_REQS_LIMIT]; void *context; - int error; env_atomic req_remaining; env_atomic req_active; env_atomic req_current; + ocf_metadata_io_event_t on_meta_fill; + ocf_metadata_io_event_t on_meta_drain; + ocf_metadata_io_end_t on_complete; uint32_t page; uint32_t count; int flags; - ocf_metadata_io_end_t on_complete; + int error; }; void metadata_io_req_complete(struct metadata_io_request *m_req);