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

cleanup req->error setting #762

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 src/engine/engine_bf.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ static void _ocf_backfill_complete(struct ocf_request *req, int error)
struct ocf_cache *cache = req->cache;

if (error) {
req->error = error;
env_atomic_cmpxchg(&req->error, 0, error);
ocf_core_stats_cache_error_update(req->core, OCF_WRITE);
}

if (req->error)
if (env_atomic_read(&req->error))
inc_fallback_pt_error_counter(req->cache);

/* Handle callback-caller race to let only one of the two complete the
Expand All @@ -64,7 +64,7 @@ static void _ocf_backfill_complete(struct ocf_request *req, int error)
ctx_data_free(cache->owner, req->data);
req->data = NULL;

if (req->error) {
if (env_atomic_read(&req->error)) {
ocf_engine_invalidate(req);
} else {
ocf_req_unlock(ocf_cache_line_concurrency(cache), req);
Expand Down
9 changes: 5 additions & 4 deletions src/engine/engine_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,8 @@ static void _ocf_engine_clean_end(void *private_data, int error)

if (error) {
OCF_DEBUG_RQ(req, "Cleaning ERROR");
req->error |= error;
env_atomic_cmpxchg(&req->error, 0, error);


/* End request and do not processing */
ocf_req_unlock(ocf_cache_line_concurrency(req->cache),
Expand Down Expand Up @@ -648,7 +649,7 @@ void ocf_engine_push_req_front_cb(struct ocf_request *req,
ocf_engine_cb engine_cb,
bool allow_sync)
{
req->error = 0; /* Please explain why!!! */
env_atomic_cmpxchg(&req->error, 0, 0);/* Please explain why!!! */
req->engine_handler = engine_cb;
ocf_engine_push_req_front(req, allow_sync);
}
Expand Down Expand Up @@ -687,10 +688,10 @@ static int _ocf_engine_refresh(struct ocf_request *req)
req->engine_handler(req);
} else {
ENV_WARN(true, "Inconsistent request");
req->error = -OCF_ERR_INVAL;
env_atomic_cmpxchg(&req->error, 0, -OCF_ERR_INVAL);

/* Complete request */
req->complete(req, req->error);
req->complete(req, env_atomic_read(&req->error));

/* Release WRITE lock of request */
ocf_req_unlock(ocf_cache_line_concurrency(req->cache), req);
Expand Down
6 changes: 3 additions & 3 deletions src/engine/engine_d2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@

static void _ocf_d2c_completion(struct ocf_request *req, int error)
{
req->error = error;
env_atomic_cmpxchg(&req->error, 0, error);

OCF_DEBUG_RQ(req, "Completion");

if (req->error) {
if (env_atomic_read(&req->error)) {
req->info.core_error = 1;
ocf_core_stats_core_error_update(req->core, req->rw);
}

/* Complete request */
req->complete(req, req->error);
req->complete(req, env_atomic_read(&req->error));

/* Release OCF request */
ocf_req_put(req);
Expand Down
8 changes: 4 additions & 4 deletions src/engine/engine_discard.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static void _ocf_discard_finish_step(struct ocf_request *req)
static void _ocf_discard_step_complete(struct ocf_request *req, int error)
{
if (error)
req->error |= error;
env_atomic_cmpxchg(&req->error, 0, error);

if (env_atomic_dec_return(&req->req_remaining))
return;
Expand All @@ -126,9 +126,9 @@ static void _ocf_discard_step_complete(struct ocf_request *req, int error)
/* Release WRITE lock of request */
ocf_req_unlock_wr(ocf_cache_line_concurrency(req->cache), req);

if (req->error) {
if (env_atomic_read(&req->error)) {
ocf_metadata_error(req->cache);
_ocf_discard_complete_req(req, req->error);
_ocf_discard_complete_req(req, env_atomic_read(&req->error));
return;
}

Expand Down Expand Up @@ -230,7 +230,7 @@ static int _ocf_discard_step(struct ocf_request *req)
}
} else {
OCF_DEBUG_RQ(req, "LOCK ERROR %d", lock);
req->error |= lock;
env_atomic_cmpxchg(&req->error, 0, lock);
_ocf_discard_finish_step(req);
}

Expand Down
6 changes: 3 additions & 3 deletions src/engine/engine_fast.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
static void _ocf_read_fast_complete(struct ocf_request *req, int error)
{
if (error) {
req->error |= error;
env_atomic_cmpxchg(&req->error, 0, error);
ocf_core_stats_cache_error_update(req->core, OCF_READ);
}

Expand All @@ -42,15 +42,15 @@ static void _ocf_read_fast_complete(struct ocf_request *req, int error)

OCF_DEBUG_RQ(req, "HIT completion");

if (req->error) {
if (env_atomic_read(&req->error)) {
OCF_DEBUG_RQ(req, "ERROR");

ocf_engine_push_req_front_pt(req);
} else {
ocf_req_unlock(ocf_cache_line_concurrency(req->cache), req);

/* Complete request */
req->complete(req, req->error);
req->complete(req, env_atomic_read(&req->error));

/* Free the request at the last point of the completion path */
ocf_req_put(req);
Expand Down
4 changes: 2 additions & 2 deletions src/engine/engine_inv.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
static void _ocf_invalidate_req(struct ocf_request *req, int error)
{
if (error) {
req->error = error;
env_atomic_cmpxchg(&req->error, 0, error);
ocf_core_stats_cache_error_update(req->core, OCF_WRITE);
}

Expand All @@ -28,7 +28,7 @@ static void _ocf_invalidate_req(struct ocf_request *req, int error)

OCF_DEBUG_RQ(req, "Completion");

if (req->error)
if (env_atomic_read(&req->error))
ocf_engine_error(req, true, "Failed to flush metadata to cache");

ocf_req_unlock_wr(ocf_cache_line_concurrency(req->cache), req);
Expand Down
6 changes: 3 additions & 3 deletions src/engine/engine_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@
static void _ocf_engine_ops_complete(struct ocf_request *req, int error)
{
if (error)
req->error |= error;
env_atomic_cmpxchg(&req->error, 0, error);

if (env_atomic_dec_return(&req->req_remaining))
return;

OCF_DEBUG_RQ(req, "Completion");

if (req->error) {
if (env_atomic_read(&req->error)) {
/* An error occured */
ocf_engine_error(req, false, "Core operation failure");
}

/* Complete requests - both to cache and to core*/
req->complete(req, req->error);
req->complete(req, env_atomic_read(&req->error));

/* Release OCF request */
ocf_req_put(req);
Expand Down
6 changes: 3 additions & 3 deletions src/engine/engine_pt.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@
static void _ocf_read_pt_complete(struct ocf_request *req, int error)
{
if (error)
req->error |= error;
env_atomic_cmpxchg(&req->error, 0, error);

if (env_atomic_dec_return(&req->req_remaining))
return;

OCF_DEBUG_RQ(req, "Completion");

if (req->error) {
if (env_atomic_read(&req->error)) {
req->info.core_error = 1;
ocf_core_stats_core_error_update(req->core, OCF_READ);
}

/* Complete request */
req->complete(req, req->error);
req->complete(req, env_atomic_read(&req->error));

ocf_req_unlock_rd(ocf_cache_line_concurrency(req->cache), req);

Expand Down
14 changes: 7 additions & 7 deletions src/engine/engine_rd.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static void _ocf_read_generic_hit_complete(struct ocf_request *req, int error)
req->cache);

if (error) {
req->error |= error;
env_atomic_cmpxchg(&req->error, 0, error);
ocf_core_stats_cache_error_update(req->core, OCF_READ);
inc_fallback_pt_error_counter(req->cache);
}
Expand All @@ -40,13 +40,13 @@ static void _ocf_read_generic_hit_complete(struct ocf_request *req, int error)
if (env_atomic_dec_return(&req->req_remaining) == 0) {
OCF_DEBUG_RQ(req, "HIT completion");

if (req->error) {
if (env_atomic_read(&req->error)) {
ocf_engine_push_req_front_pt(req);
} else {
ocf_req_unlock(c, req);

/* Complete request */
req->complete(req, req->error);
req->complete(req, env_atomic_read(&req->error));

/* Free the request at the last point
* of the completion path
Expand All @@ -61,7 +61,7 @@ static void _ocf_read_generic_miss_complete(struct ocf_request *req, int error)
struct ocf_cache *cache = req->cache;

if (error)
req->error = error;
env_atomic_cmpxchg(&req->error, 0, error);

/* Handle callback-caller race to let only one of the two complete the
* request. Also, complete original request only if this is the last
Expand All @@ -70,12 +70,12 @@ static void _ocf_read_generic_miss_complete(struct ocf_request *req, int error)
if (env_atomic_dec_return(&req->req_remaining) == 0) {
OCF_DEBUG_RQ(req, "MISS completion");

if (req->error) {
if (env_atomic_read(&req->error)) {
/*
* --- Do not submit this request to write-back-thread.
* Stop it here ---
*/
req->complete(req, req->error);
req->complete(req, env_atomic_read(&req->error));

req->info.core_error = 1;
ocf_core_stats_core_error_update(req->core, OCF_READ);
Expand All @@ -96,7 +96,7 @@ static void _ocf_read_generic_miss_complete(struct ocf_request *req, int error)
req->byte_length);

/* Complete request */
req->complete(req, req->error);
req->complete(req, env_atomic_read(&req->error));

ocf_engine_backfill(req);
}
Expand Down
12 changes: 6 additions & 6 deletions src/engine/engine_wb.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@ static void _ocf_write_wb_update_bits(struct ocf_request *req)
static void _ocf_write_wb_io_flush_metadata(struct ocf_request *req, int error)
{
if (error)
req->error = error;
env_atomic_cmpxchg(&req->error, 0, error);

if (env_atomic_dec_return(&req->req_remaining))
return;

if (req->error)
if (env_atomic_read(&req->error))
ocf_engine_error(req, true, "Failed to write data to cache");

ocf_req_unlock_wr(ocf_cache_line_concurrency(req->cache), req);

req->complete(req, req->error);
req->complete(req, env_atomic_read(&req->error));

ocf_req_put(req);
}
Expand Down Expand Up @@ -87,18 +87,18 @@ static void _ocf_write_wb_complete(struct ocf_request *req, int error)
{
if (error) {
ocf_core_stats_cache_error_update(req->core, OCF_WRITE);
req->error |= error;
env_atomic_cmpxchg(&req->error, 0, error);
}

if (env_atomic_dec_return(&req->req_remaining))
return;

OCF_DEBUG_RQ(req, "Completion");

if (req->error) {
if (env_atomic_read(&req->error)) {
ocf_engine_error(req, true, "Failed to write data to cache");

req->complete(req, req->error);
req->complete(req, env_atomic_read(&req->error));

ocf_engine_invalidate(req);
} else {
Expand Down
16 changes: 8 additions & 8 deletions src/engine/engine_wi.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ int _ocf_write_wi_next_pass(struct ocf_request *req)
ocf_req_unlock_wr(ocf_cache_line_concurrency(req->cache), req);

if (req->wi_second_pass) {
req->complete(req, req->error);
req->complete(req, env_atomic_read(&req->error));
ocf_req_put(req);

return 0;
Expand All @@ -47,25 +47,25 @@ static void _ocf_write_wi_io_flush_metadata(struct ocf_request *req, int error)
{
if (error) {
ocf_core_stats_cache_error_update(req->core, OCF_WRITE);
req->error |= error;
env_atomic_cmpxchg(&req->error, 0, error);
}

if (env_atomic_dec_return(&req->req_remaining))
return;

if (!req->error && !req->wi_second_pass && ocf_engine_is_miss(req)) {
if (!env_atomic_read(&req->error) && !req->wi_second_pass && ocf_engine_is_miss(req)) {
/* need another pass */
ocf_engine_push_req_front_cb(req, _ocf_write_wi_next_pass,
true);
return;
}

if (req->error)
if (env_atomic_read(&req->error))
ocf_engine_error(req, true, "Failed to write data to cache");

ocf_req_unlock_wr(ocf_cache_line_concurrency(req->cache), req);

req->complete(req, req->error);
req->complete(req, env_atomic_read(&req->error));

ocf_req_put(req);
}
Expand Down Expand Up @@ -105,7 +105,7 @@ static int ocf_write_wi_update_and_flush_metadata(struct ocf_request *req)
static void _ocf_write_wi_core_complete(struct ocf_request *req, int error)
{
if (error) {
req->error = error;
env_atomic_cmpxchg(&req->error, 0, error);
req->info.core_error = 1;
ocf_core_stats_core_error_update(req->core, OCF_WRITE);
}
Expand All @@ -115,10 +115,10 @@ static void _ocf_write_wi_core_complete(struct ocf_request *req, int error)

OCF_DEBUG_RQ(req, "Completion");

if (req->error) {
if (env_atomic_read(&req->error)) {
ocf_req_unlock_wr(ocf_cache_line_concurrency(req->cache), req);

req->complete(req, req->error);
req->complete(req, env_atomic_read(&req->error));

ocf_req_put(req);
} else {
Expand Down
Loading