Commit 80b80d24 authored by Rafal Stefanowski's avatar Rafal Stefanowski Committed by Tomasz Zawadzki
Browse files

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: default avatarRafal 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: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 619b8e37
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -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;
	}