Skip to content

Commit

Permalink
engine_rd: Ignore backfill buffer allocation errors
Browse files Browse the repository at this point in the history
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
  • Loading branch information
mmichal10 committed Sep 18, 2024
1 parent 268a919 commit 1a0ba08
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
19 changes: 13 additions & 6 deletions src/engine/engine_bf.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ static void _ocf_backfill_complete(struct ocf_request *req, int error)
backfill_queue_dec_unblock(req->cache);

/* We must free the pages we have allocated */
ctx_data_secure_erase(cache->owner, req->data);
ctx_data_munlock(cache->owner, req->data);
ctx_data_free(cache->owner, req->data);
req->data = NULL;
if (likely(req->data)) {
ctx_data_secure_erase(cache->owner, req->data);
ctx_data_munlock(cache->owner, req->data);
ctx_data_free(cache->owner, req->data);
req->data = NULL;
}

if (req->error) {
ocf_engine_invalidate(req);
Expand All @@ -79,13 +81,18 @@ static int _ocf_backfill_do(struct ocf_request *req)
{
unsigned int reqs_to_issue;

req->data = req->cp_data;
if (unlikely(req->data == NULL)) {
env_atomic_set(&req->req_remaining, 1);
_ocf_backfill_complete(req, -OCF_ERR_NO_MEM);
return 0;
}

reqs_to_issue = ocf_engine_io_count(req);

/* There will be #reqs_to_issue completions */
env_atomic_set(&req->req_remaining, reqs_to_issue);

req->data = req->cp_data;

ocf_submit_cache_reqs(req->cache, req, OCF_WRITE, 0, req->byte_length,
reqs_to_issue, _ocf_backfill_complete);

Expand Down
20 changes: 12 additions & 8 deletions src/engine/engine_rd.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,25 @@ static inline void _ocf_read_generic_submit_miss(struct ocf_request *req)

req->cp_data = ctx_data_alloc(cache->owner,
BYTES_TO_PAGES(req->byte_length));
if (!req->cp_data)
if (!req->cp_data) {
/* If buffer allocation for backfill fails, ignore the error */
ocf_cache_log(cache, log_warn, "Backfill buffer allocation "
"error (size %u)\n",
req->byte_length);
goto err_alloc;
}

ret = ctx_data_mlock(cache->owner, req->cp_data);
if (ret)
goto err_alloc;
if (ret) {
ocf_cache_log(cache, log_warn, "Backfill error\n");
ctx_data_free(cache->owner, req->cp_data);
req->cp_data = NULL;
}

err_alloc:
/* Submit read request to core device. */
ocf_submit_volume_req(&req->core->volume, req,
_ocf_read_generic_miss_complete);

return;

err_alloc:
_ocf_read_generic_miss_complete(req, -OCF_ERR_NO_MEM);
}

static int _ocf_read_generic_do(struct ocf_request *req)
Expand Down

0 comments on commit 1a0ba08

Please sign in to comment.