bdev/ocf: Handle memory error properly

When there is not enough memory needed to start cache, print
relevant message and inform about possible solutions.

Fixes #1763

Signed-off-by: Rafal Stefanowski <rafal.stefanowski@intel.com>
Change-Id: I911dcb4e86ad7e3f2e2b051678736d4e88869db5
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6078
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Rafal Stefanowski 2021-01-22 05:51:33 +01:00 committed by Tomasz Zawadzki
parent 619b8e3733
commit 80b80d2482

View File

@ -1007,12 +1007,25 @@ static void
start_cache_cmpl(ocf_cache_t cache, void *priv, int error)
{
struct vbdev_ocf *vbdev = priv;
uint64_t mem_needed;
ocf_mngt_cache_unlock(cache);
if (error) {
SPDK_ERRLOG("Error %d during start cache %s, starting rollback\n",
error, vbdev->name);
if (error == -OCF_ERR_NO_MEM) {
ocf_mngt_get_ram_needed(cache, &vbdev->cfg.device, &mem_needed);
SPDK_NOTICELOG("Try to increase hugepage memory size or cache line size. "
"For your configuration:\nDevice size: %"PRIu64" bytes\n"
"Cache line size: %"PRIu64" bytes\nFree memory needed to start "
"cache: %"PRIu64" bytes\n", vbdev->cache.bdev->blockcnt *
vbdev->cache.bdev->blocklen, vbdev->cfg.cache.cache_line_size,
mem_needed);
}
vbdev_ocf_mngt_exit(vbdev, unregister_path_dirty, error);
return;
}