bdev/ocf: Fix devices block size mismatch

OCF creates vbdev with block size equal in size with a core device.
We need to ensure that cache's bdev block size is not bigger than
core's bdev block size, so there are no IO errors due to IO length
smaller than cache device's block size.
The reason why this is implemented late in the cache start and not
as soon as we want to construct OCF vbdev is that cache or core
device can be added later after OCF vbdev creation and only then
we are certain to have both devices to compare.

Fixes #2088

Signed-off-by: Rafal Stefanowski <rafal.stefanowski@intel.com>
Change-Id: I536c783ca71b52f212217c597b7997f2d2e89491
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9229
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Jim Harris <james.r.harris@intel.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-08-16 02:32:51 +02:00 committed by Tomasz Zawadzki
parent 15b7d3bacc
commit 074a63d507

View File

@ -203,7 +203,9 @@ unregister_finish(struct vbdev_ocf *vbdev)
ocf_mngt_cache_put(vbdev->ocf_cache);
}
vbdev_ocf_cache_ctx_put(vbdev->cache_ctx);
if (vbdev->cache_ctx) {
vbdev_ocf_cache_ctx_put(vbdev->cache_ctx);
}
vbdev_ocf_mngt_continue(vbdev, 0);
}
@ -1066,6 +1068,8 @@ static void
start_cache(struct vbdev_ocf *vbdev)
{
ocf_cache_t existing;
uint32_t cache_block_size = vbdev->cache.bdev->blocklen;
uint32_t core_block_size = vbdev->core.bdev->blocklen;
int rc;
if (is_ocf_cache_running(vbdev)) {
@ -1073,6 +1077,13 @@ start_cache(struct vbdev_ocf *vbdev)
return;
}
if (cache_block_size > core_block_size) {
SPDK_ERRLOG("Cache bdev block size (%d) is bigger then core bdev block size (%d)\n",
cache_block_size, core_block_size);
vbdev_ocf_mngt_exit(vbdev, unregister_path_dirty, -EINVAL);
return;
}
existing = get_other_cache_instance(vbdev);
if (existing) {
SPDK_NOTICELOG("OCF bdev %s connects to existing cache device %s\n",