Make request structure more compressed

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
Robert Baldyga 2019-05-29 14:38:08 +02:00
parent 75fb6c7940
commit f240f81641
14 changed files with 67 additions and 66 deletions

View File

@ -795,9 +795,9 @@ static void _req_on_lock(void *ctx, uint32_t ctx_id,
if (env_atomic_dec_return(&req->lock_remaining) == 0) {
/* All cache line locked, resume request */
OCF_DEBUG_RQ(req, "Resume");
OCF_CHECK_NULL(req->resume);
ENV_BUG_ON(!req->io_if->resume);
env_atomic_dec(&c->waiting);
req->resume(req);
req->io_if->resume(req);
}
}
@ -806,7 +806,7 @@ static void _req_on_lock(void *ctx, uint32_t ctx_id,
*/
int ocf_req_trylock_rd(struct ocf_request *req)
{
OCF_CHECK_NULL(req->resume);
ENV_BUG_ON(!req->io_if->resume);
return _ocf_req_lock_rd_common(req, req, _req_on_lock);
}
@ -928,7 +928,7 @@ static int _ocf_req_lock_wr_common(struct ocf_request *req, void *context,
*/
int ocf_req_trylock_wr(struct ocf_request *req)
{
OCF_CHECK_NULL(req->resume);
ENV_BUG_ON(!req->io_if->resume);
return _ocf_req_lock_wr_common(req, req, _req_on_lock);
}

View File

@ -53,14 +53,14 @@ size_t ocf_cache_concurrency_size_of(struct ocf_cache *cache);
/**
* @brief Lock OCF request for WRITE access (Lock all cache lines in map info)
*
* @note req->resume callback has to be set
* @note io_if->resume callback has to be set
*
* @param req - OCF request
*
* @retval OCF_LOCK_ACQUIRED - OCF request has been locked and can be processed
*
* @retval OCF_LOCK_NOT_ACQUIRED - OCF request lock not acquired, request was
* added into waiting list. When lock will be acquired req->resume be called
* added into waiting list. When lock will be acquired io_if->resume be called
*/
int ocf_req_trylock_wr(struct ocf_request *req);
@ -75,21 +75,21 @@ int ocf_req_trylock_wr(struct ocf_request *req);
* @retval OCF_LOCK_ACQUIRED - OCF request has been locked and can be processed
*
* @retval OCF_LOCK_NOT_ACQUIRED - OCF request lock not acquired, request was
* added into waiting list. When lock will be acquired req->resume be called
* added into waiting list. When lock will be acquired io_if->resume be called
*/
int ocf_req_retrylock_wr(struct ocf_request *req);
/**
* @brief Lock OCF request for READ access (Lock all cache lines in map info)
*
* @note req->resume callback has to be set
* @note io_if->resume callback has to be set
*
* @param req - OCF request
*
* @retval OCF_LOCK_ACQUIRED - OCF request has been locked and can be processed
*
* @retval OCF_LOCK_NOT_ACQUIRED - OCF request lock not acquired, request was
* added into waiting list. When lock will be acquired req->resume be called
* added into waiting list. When lock will be acquired io_if->resume be called
*/
int ocf_req_trylock_rd(struct ocf_request *req);

View File

@ -36,6 +36,8 @@ struct ocf_io_if {
int (*write)(struct ocf_request *req);
void (*resume)(struct ocf_request *req);
const char *name;
};

View File

@ -574,7 +574,6 @@ static int _ocf_engine_refresh(struct ocf_request *req)
/* Refresh successful, can process with original IO interface */
req->io_if = req->priv;
req->resume = NULL;
req->priv = NULL;
if (req->rw == OCF_READ)
@ -601,14 +600,13 @@ static int _ocf_engine_refresh(struct ocf_request *req)
}
static const struct ocf_io_if _io_if_refresh = {
.read = _ocf_engine_refresh,
.write = _ocf_engine_refresh,
.read = _ocf_engine_refresh,
.write = _ocf_engine_refresh,
};
void ocf_engine_on_resume(struct ocf_request *req)
{
ENV_BUG_ON(req->priv);
ENV_BUG_ON(ocf_engine_on_resume != req->resume);
OCF_CHECK_NULL(req->io_if);
/* Exchange IO interface */

View File

@ -22,25 +22,30 @@ static int _ocf_discard_step_do(struct ocf_request *req);
static int _ocf_discard_step(struct ocf_request *req);
static int _ocf_discard_flush_cache(struct ocf_request *req);
static int _ocf_discard_core(struct ocf_request *req);
static void _ocf_discard_on_resume(struct ocf_request *req);
static const struct ocf_io_if _io_if_discard_step = {
.read = _ocf_discard_step,
.write = _ocf_discard_step
.write = _ocf_discard_step,
.resume = _ocf_discard_on_resume,
};
static const struct ocf_io_if _io_if_discard_step_resume = {
.read = _ocf_discard_step_do,
.write = _ocf_discard_step_do
.write = _ocf_discard_step_do,
.resume = _ocf_discard_on_resume,
};
static const struct ocf_io_if _io_if_discard_flush_cache = {
.read = _ocf_discard_flush_cache,
.write = _ocf_discard_flush_cache,
.resume = _ocf_discard_on_resume,
};
static const struct ocf_io_if _io_if_discard_core = {
.read = _ocf_discard_core,
.write = _ocf_discard_core
.write = _ocf_discard_core,
.resume = _ocf_discard_on_resume,
};
static void _ocf_discard_complete_req(struct ocf_request *req, int error)
@ -263,9 +268,6 @@ int ocf_discard(struct ocf_request *req)
/* Get OCF request - increase reference counter */
ocf_req_get(req);
/* Set resume call backs */
req->resume = _ocf_discard_on_resume;
_ocf_discard_step(req);
/* Put OCF request - decrease reference counter */

View File

@ -102,8 +102,9 @@ static int _ocf_read_fast_do(struct ocf_request *req)
}
static const struct ocf_io_if _io_if_read_fast_resume = {
.read = _ocf_read_fast_do,
.write = _ocf_read_fast_do,
.read = _ocf_read_fast_do,
.write = _ocf_read_fast_do,
.resume = ocf_engine_on_resume,
};
int ocf_read_fast(struct ocf_request *req)
@ -115,8 +116,7 @@ int ocf_read_fast(struct ocf_request *req)
/* Get OCF request - increase reference counter */
ocf_req_get(req);
/* Set resume call backs */
req->resume = ocf_engine_on_resume;
/* Set resume io_if */
req->io_if = &_io_if_read_fast_resume;
/*- Metadata RD access -----------------------------------------------*/
@ -172,8 +172,9 @@ int ocf_read_fast(struct ocf_request *req)
*/
static const struct ocf_io_if _io_if_write_fast_resume = {
.read = ocf_write_wb_do,
.write = ocf_write_wb_do,
.read = ocf_write_wb_do,
.write = ocf_write_wb_do,
.resume = ocf_engine_on_resume,
};
int ocf_write_fast(struct ocf_request *req)
@ -185,8 +186,7 @@ int ocf_write_fast(struct ocf_request *req)
/* Get OCF request - increase reference counter */
ocf_req_get(req);
/* Set resume call backs */
req->resume = ocf_engine_on_resume;
/* Set resume io_if */
req->io_if = &_io_if_write_fast_resume;
/*- Metadata RD access -----------------------------------------------*/

View File

@ -99,6 +99,7 @@ int ocf_read_pt_do(struct ocf_request *req)
static const struct ocf_io_if _io_if_pt_resume = {
.read = ocf_read_pt_do,
.write = ocf_read_pt_do,
.resume = ocf_engine_on_resume,
};
int ocf_read_pt(struct ocf_request *req)
@ -114,8 +115,7 @@ int ocf_read_pt(struct ocf_request *req)
/* Get OCF request - increase reference counter */
ocf_req_get(req);
/* Set resume call backs */
req->resume = ocf_engine_on_resume;
/* Set resume io_if */
req->io_if = &_io_if_pt_resume;
OCF_METADATA_LOCK_RD(); /*- Metadata RD access -----------------------*/

View File

@ -206,8 +206,9 @@ static int _ocf_read_generic_do(struct ocf_request *req)
}
static const struct ocf_io_if _io_if_read_generic_resume = {
.read = _ocf_read_generic_do,
.write = _ocf_read_generic_do,
.read = _ocf_read_generic_do,
.write = _ocf_read_generic_do,
.resume = ocf_engine_on_resume,
};
int ocf_read_generic(struct ocf_request *req)
@ -228,7 +229,6 @@ int ocf_read_generic(struct ocf_request *req)
ocf_req_get(req);
/* Set resume call backs */
req->resume = ocf_engine_on_resume;
req->io_if = &_io_if_read_generic_resume;
/*- Metadata RD access -----------------------------------------------*/

View File

@ -19,8 +19,9 @@
#include "engine_debug.h"
static const struct ocf_io_if _io_if_wb_resume = {
.read = ocf_write_wb_do,
.write = ocf_write_wb_do,
.read = ocf_write_wb_do,
.write = ocf_write_wb_do,
.resume = ocf_engine_on_resume,
};
static void _ocf_write_wb_update_bits(struct ocf_request *req)
@ -176,8 +177,7 @@ int ocf_write_wb(struct ocf_request *req)
/* Not sure if we need this. */
ocf_req_get(req);
/* Set resume call backs */
req->resume = ocf_engine_on_resume;
/* Set resume io_if */
req->io_if = &_io_if_wb_resume;
/* TODO: Handle fits into dirty */

View File

@ -130,6 +130,7 @@ static void _ocf_write_wi_on_resume(struct ocf_request *req)
static const struct ocf_io_if _io_if_wi_resume = {
.read = _ocf_write_wi_do,
.write = _ocf_write_wi_do,
.resume = _ocf_write_wi_on_resume,
};
int ocf_write_wi(struct ocf_request *req)
@ -144,8 +145,7 @@ int ocf_write_wi(struct ocf_request *req)
/* Get OCF request - increase reference counter */
ocf_req_get(req);
/* Set resume call backs */
req->resume = _ocf_write_wi_on_resume;
/* Set resume io_if */
req->io_if = &_io_if_wi_resume;
OCF_METADATA_LOCK_RD(); /*- Metadata READ access, No eviction --------*/

View File

@ -156,8 +156,9 @@ static int _ocf_write_wt_do(struct ocf_request *req)
}
static const struct ocf_io_if _io_if_wt_resume = {
.read = _ocf_write_wt_do,
.write = _ocf_write_wt_do,
.read = _ocf_write_wt_do,
.write = _ocf_write_wt_do,
.resume = ocf_engine_on_resume,
};
int ocf_write_wt(struct ocf_request *req)
@ -171,8 +172,7 @@ int ocf_write_wt(struct ocf_request *req)
/* Get OCF request - increase reference counter */
ocf_req_get(req);
/* Set resume call backs */
req->resume = ocf_engine_on_resume;
/* Set resume io_if */
req->io_if = &_io_if_wt_resume;
OCF_METADATA_LOCK_RD(); /*- Metadata READ access, No eviction --------*/

View File

@ -129,6 +129,7 @@ static int _ocf_zero_do(struct ocf_request *req)
static const struct ocf_io_if _io_if_ocf_zero_do = {
.read = _ocf_zero_do,
.write = _ocf_zero_do,
.resume = ocf_engine_on_resume,
};
/**
@ -147,7 +148,6 @@ void ocf_engine_zero_line(struct ocf_request *req)
ENV_BUG_ON(!ocf_engine_is_mapped(req));
req->resume = ocf_engine_on_resume;
req->io_if = &_io_if_ocf_zero_do;
/* Some cache line are mapped, lock request for WRITE access */

View File

@ -131,12 +131,6 @@ struct ocf_request {
const struct ocf_io_if *io_if;
/*!< IO interface */
void (*resume)(struct ocf_request *req);
/*!< OCF request resume callback */
ocf_part_id_t part_id;
/*!< Targeted partition of requests */
void *priv;
/*!< Filed for private data, context */
@ -167,27 +161,33 @@ struct ocf_request {
uint32_t alloc_core_line_count;
/*! Core line count for which request was initially allocated */
ocf_queue_t io_queue;
/*!< I/O queue handle for which request should be submitted */
int error;
/*!< This filed indicates an error for OCF request */
int rw;
ocf_part_id_t part_id;
/*!< Targeted partition of requests */
uint8_t rw : 1;
/*!< Indicator of IO direction - Read/Write */
uint8_t d2c : 1;
/**!< request affects metadata cachelines (is not direct-to-core) */
uint8_t dirty : 1;
/**!< indicates that request produces dirty data */
uint8_t master_io_req_type : 2;
/*!< Core device request context type */
ocf_queue_t io_queue;
/*!< I/O queue handle for which request should be submitted */
struct list_head list;
/*!< List item for OCF IO thread workers */
struct ocf_req_info info;
/*!< Detailed request info */
uint8_t d2c;
/**!< request affects metadata cachelines (is not direct-to-core) */
uint8_t master_io_req_type;
/*!< Core device request context type */
void (*complete)(struct ocf_request *ocf_req, int error);
/*!< Request completion funstion */

View File

@ -703,23 +703,22 @@ static int _ocf_cleaner_fire_cache(struct ocf_request *req)
return 0;
}
static const struct ocf_io_if _io_if_fire_cache = {
.read = _ocf_cleaner_fire_cache,
.write = _ocf_cleaner_fire_cache,
};
static void _ocf_cleaner_on_resume(struct ocf_request *req)
{
OCF_DEBUG_TRACE(req->cache);
ocf_engine_push_req_front(req, true);
}
static const struct ocf_io_if _io_if_fire_cache = {
.read = _ocf_cleaner_fire_cache,
.write = _ocf_cleaner_fire_cache,
.resume = _ocf_cleaner_on_resume,
};
static int _ocf_cleaner_fire(struct ocf_request *req)
{
int result;
/* Set resume call backs */
req->resume = _ocf_cleaner_on_resume;
req->io_if = &_io_if_fire_cache;
/* Handle cache lines locks */