module/ocf: check cache name during recovery from metadata
Save cache device name in metadata section to check if names agree during auto creation on examine. This change prevents accidental creation of ocf devices. Consider example in which vbdev_split is used as cache: 1) bdev_malloc_create -b Malloc0 ... 2) bdev_malloc_create -b Malloc1 ... 3) bdev_nvme_attach_controller -b nvme ... 4) bdev_split_create nvme 2 5) bdev_ocf_create ocf0 wt nvmen1p0 Malloc0 6) bdev_ocf_create ocf1 wt nvmen1p1 Malloc1 7) *shutdown* 8) *startup* 9) bdev_nvme_attach_controller -b nvme Now ocf0 bdev gets created with cache = nvmen1 (not nvmen1p0)! This is because nvmen1 and nvmen1p0 have the same metadata. The result is rather unexpected, so we would like to verify that cache device is the one used during creation. Name is not an ideal way to verify that, but it should work for most cases. This change is related to issue #1320 Change-Id: I19ce97163090c5c5b3324eaed90b3134011bb3fb Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1544 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
parent
42fc807f47
commit
9f133b1bcc
@ -1154,16 +1154,17 @@ init_vbdev_config(struct vbdev_ocf *vbdev)
|
||||
}
|
||||
|
||||
/* Serialize bdev names in OCF UUID to interpret on future loads
|
||||
* Core UUID is pair of (core bdev name, cache bdev name)
|
||||
* Core UUID is a triple of (core name, vbdev name, cache name)
|
||||
* Cache UUID is cache bdev name */
|
||||
cfg->device.uuid.size = strlen(vbdev->cache.name) + 1;
|
||||
cfg->device.uuid.data = vbdev->cache.name;
|
||||
|
||||
snprintf(vbdev->uuid, VBDEV_OCF_MD_MAX_LEN, "%s %s",
|
||||
vbdev->core.name, vbdev->name);
|
||||
snprintf(vbdev->uuid, VBDEV_OCF_MD_MAX_LEN, "%s %s %s",
|
||||
vbdev->core.name, vbdev->name, vbdev->cache.name);
|
||||
cfg->core.uuid.size = strlen(vbdev->uuid) + 1;
|
||||
cfg->core.uuid.data = vbdev->uuid;
|
||||
vbdev->uuid[strlen(vbdev->core.name)] = 0;
|
||||
vbdev->uuid[strlen(vbdev->core.name) + 1 + strlen(vbdev->name)] = 0;
|
||||
}
|
||||
|
||||
/* Allocate vbdev structure object and add it to the global list */
|
||||
@ -1568,6 +1569,7 @@ metadata_probe_cores_construct(void *priv, int error, unsigned int num_cores)
|
||||
struct metadata_probe_ctx *ctx = priv;
|
||||
const char *vbdev_name;
|
||||
const char *core_name;
|
||||
const char *cache_name;
|
||||
unsigned int i;
|
||||
|
||||
if (error) {
|
||||
@ -1579,8 +1581,15 @@ metadata_probe_cores_construct(void *priv, int error, unsigned int num_cores)
|
||||
for (i = 0; i < num_cores; i++) {
|
||||
core_name = ocf_uuid_to_str(&ctx->core_uuids[i]);
|
||||
vbdev_name = core_name + strlen(core_name) + 1;
|
||||
cache_name = vbdev_name + strlen(vbdev_name) + 1;
|
||||
|
||||
if (strcmp(ctx->base.bdev->name, cache_name)) {
|
||||
SPDK_NOTICELOG("OCF metadata found on %s belongs to bdev named '%s'\n",
|
||||
ctx->base.bdev->name, cache_name);
|
||||
}
|
||||
|
||||
ctx->refcnt++;
|
||||
vbdev_ocf_construct(vbdev_name, NULL, ctx->base.bdev->name, core_name, true,
|
||||
vbdev_ocf_construct(vbdev_name, NULL, cache_name, core_name, true,
|
||||
metadata_probe_construct_cb, ctx);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user