Skip to content

Commit

Permalink
Debug request tracing
Browse files Browse the repository at this point in the history
Signed-off-by: Michal Mielewczyk <[email protected]>
  • Loading branch information
mmichal10 committed Oct 16, 2024
1 parent 1ab882a commit 136e50d
Show file tree
Hide file tree
Showing 14 changed files with 65 additions and 1 deletion.
25 changes: 25 additions & 0 deletions src/engine/cache_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ enum ocf_io_if_type {
OCF_IO_FAST_IF,
OCF_IO_FLUSH_IF,
OCF_IO_DISCARD_IF,
OCF_IO_REFRESH_IF,
OCF_IO_INVALIDATE_IF,
OCF_IO_RD_IF,
OCF_IO_PRIV_MAX_IF,
};

Expand Down Expand Up @@ -108,6 +111,18 @@ static const struct ocf_io_if IO_IFS[OCF_IO_PRIV_MAX_IF] = {
},
.name = "Discard",
},
[OCF_IO_REFRESH_IF] = {
.cbs = { },
.name = "Refresh",
},
[OCF_IO_INVALIDATE_IF] = {
.cbs = { },
.name = "Invalidate",
},
[OCF_IO_RD_IF] = {
.cbs = { },
.name = "Read generic",
},
};

static const struct ocf_io_if *cache_mode_io_if_map[ocf_req_cache_mode_max] = {
Expand All @@ -118,8 +133,18 @@ static const struct ocf_io_if *cache_mode_io_if_map[ocf_req_cache_mode_max] = {
[ocf_req_cache_mode_wo] = &IO_IFS[OCF_IO_WO_IF],
[ocf_req_cache_mode_pt] = &IO_IFS[OCF_IO_PT_IF],
[ocf_req_cache_mode_fast] = &IO_IFS[OCF_IO_FAST_IF],
[ocf_req_refresh] = &IO_IFS[OCF_IO_REFRESH_IF],
[ocf_req_cache_mode_discard] = &IO_IFS[OCF_IO_DISCARD_IF],
[ocf_req_cache_mode_invalidate] = &IO_IFS[OCF_IO_INVALIDATE_IF],
[ocf_req_cache_mode_rd] = &IO_IFS[OCF_IO_RD_IF],
};

void ocf_debug_request_trace(struct ocf_request *req,
ocf_req_cache_mode_t engine)
{
req->engine_trace[req->engine_trace_counter++] = engine;
}

const char *ocf_get_io_iface_name(ocf_req_cache_mode_t cache_mode)
{
if (cache_mode == ocf_req_cache_mode_max)
Expand Down
3 changes: 3 additions & 0 deletions src/engine/cache_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,7 @@ void ocf_engine_hndl_flush_req(struct ocf_request *req);

void ocf_engine_hndl_discard_req(struct ocf_request *req);

void ocf_debug_request_trace(struct ocf_request *req,
ocf_req_cache_mode_t engine);

#endif
2 changes: 2 additions & 0 deletions src/engine/engine_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,8 @@ static int _ocf_engine_refresh(struct ocf_request *req)
{
int result;

ocf_debug_request_trace(req, ocf_req_refresh);

/* Check under metadata RD lock */
ocf_hb_req_prot_lock_rd(req);

Expand Down
2 changes: 2 additions & 0 deletions src/engine/engine_discard.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ int ocf_engine_discard(struct ocf_request *req)
/* Get OCF request - increase reference counter */
ocf_req_get(req);

ocf_debug_request_trace(req, ocf_req_cache_mode_discard);

_ocf_discard_step(req);

/* Put OCF request - decrease reference counter */
Expand Down
4 changes: 4 additions & 0 deletions src/engine/engine_fast.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ int ocf_read_fast(struct ocf_request *req)
/* Get OCF request - increase reference counter */
ocf_req_get(req);

ocf_debug_request_trace(req, ocf_req_cache_mode_fast);

/* Set resume handler */
req->engine_handler = _ocf_read_fast_do;

Expand Down Expand Up @@ -165,6 +167,8 @@ int ocf_write_fast(struct ocf_request *req)
/* Get OCF request - increase reference counter */
ocf_req_get(req);

ocf_debug_request_trace(req, ocf_req_cache_mode_fast);

/* Set resume handler */
req->engine_handler = ocf_write_wb_do;

Expand Down
2 changes: 2 additions & 0 deletions src/engine/engine_inv.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ static int _ocf_invalidate_do(struct ocf_request *req)
ocf_purge_map_info(req);
ocf_hb_req_prot_unlock_wr(req);

ocf_debug_request_trace(req, ocf_req_cache_mode_invalidate);

if (ocf_volume_is_atomic(&cache->device->volume) &&
req->info.flush_metadata) {
/* Metadata flush IO */
Expand Down
5 changes: 5 additions & 0 deletions src/engine/engine_pt.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ int ocf_read_pt_do(struct ocf_request *req)
/* Get OCF request - increase reference counter */
ocf_req_get(req);

ocf_debug_request_trace(req, ocf_req_cache_mode_pt);

if (req->info.dirty_any) {
ocf_hb_req_prot_lock_rd(req);
/* Need to clean, start it */
Expand Down Expand Up @@ -101,6 +103,9 @@ int ocf_read_pt(struct ocf_request *req)
/* Get OCF request - increase reference counter */
ocf_req_get(req);


ocf_debug_request_trace(req, ocf_req_cache_mode_pt);

/* Set resume handler */
req->engine_handler = ocf_read_pt_do;

Expand Down
2 changes: 2 additions & 0 deletions src/engine/engine_rd.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ int ocf_read_generic(struct ocf_request *req)
int lock = OCF_LOCK_NOT_ACQUIRED;
struct ocf_cache *cache = req->cache;

ocf_debug_request_trace(req, ocf_req_cache_mode_rd);


if (env_atomic_read(&cache->pending_read_misses_list_blocked)) {
/* There are conditions to bypass IO */
Expand Down
2 changes: 2 additions & 0 deletions src/engine/engine_wa.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ int ocf_write_wa(struct ocf_request *req)
/* Get OCF request - increase reference counter */
ocf_req_get(req);

ocf_debug_request_trace(req, ocf_req_cache_mode_wa);

ocf_req_hash(req);

ocf_hb_req_prot_lock_rd(req); /*- Metadata RD access -----------------------*/
Expand Down
4 changes: 3 additions & 1 deletion src/engine/engine_wb.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ int ocf_write_wb_do(struct ocf_request *req)
/* Get OCF request - increase reference counter */
ocf_req_get(req);

ocf_debug_request_trace(req, ocf_req_cache_mode_wb);
/* Submit IO */
_ocf_write_wb_submit(req);

Expand All @@ -149,10 +150,11 @@ int ocf_write_wb(struct ocf_request *req)
{
int lock = OCF_LOCK_NOT_ACQUIRED;


/* Not sure if we need this. */
ocf_req_get(req);

ocf_debug_request_trace(req, ocf_req_cache_mode_wb);

/* Set resume handler */
req->engine_handler = ocf_write_wb_do;
req->engine_cbs = &_wb_engine_callbacks;
Expand Down
2 changes: 2 additions & 0 deletions src/engine/engine_wi.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ int ocf_write_wi(struct ocf_request *req)
/* Get OCF request - increase reference counter */
ocf_req_get(req);

ocf_debug_request_trace(req, ocf_req_cache_mode_wi);

/* Set resume handler */
req->engine_handler = req->wi_second_pass ?
ocf_write_wi_update_and_flush_metadata :
Expand Down
2 changes: 2 additions & 0 deletions src/engine/engine_wo.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ int ocf_read_wo(struct ocf_request *req)
/* Get OCF request - increase reference counter */
ocf_req_get(req);

ocf_debug_request_trace(req, ocf_req_cache_mode_wo);

/* Set resume call backs */
req->engine_handler = ocf_read_wo_do;

Expand Down
2 changes: 2 additions & 0 deletions src/engine/engine_wt.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ int ocf_write_wt(struct ocf_request *req)
/* Get OCF request - increase reference counter */
ocf_req_get(req);

ocf_debug_request_trace(req, ocf_req_cache_mode_wt);

/* Set resume handler */
req->engine_handler = _ocf_write_wt_do;
req->engine_cbs = &_wt_engine_callbacks;
Expand Down
9 changes: 9 additions & 0 deletions src/ocf_request.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ typedef enum {
/*!< Direct to Core - pass through to core without
touching cacheline metadata */

ocf_req_refresh,
ocf_req_cache_mode_discard,
ocf_req_cache_mode_invalidate,
ocf_req_cache_mode_rd,
/*!< Just for debug purposes */

ocf_req_cache_mode_max,
} ocf_req_cache_mode_t;

Expand Down Expand Up @@ -320,6 +326,9 @@ struct ocf_request {
uint32_t alock_rw;
/*!< Read/Write mode for alock*/

uint32_t engine_trace[128];
uint8_t engine_trace_counter;

uint8_t *alock_status;
/*!< Mapping for locked/unlocked alock entries */

Expand Down

0 comments on commit 136e50d

Please sign in to comment.