From 3e5cfa4124733c1af581436671090bd37f814c9b Mon Sep 17 00:00:00 2001 From: Vitaliy Mysak Date: Wed, 22 May 2019 21:22:34 +0000 Subject: [PATCH] ocf: serialize base bdev names in OCF UUID Use OCF per-volume UUID field to serialize bdev names. This is going to be used during cache load to find out which bdevs we want to attach. Note that there is in fact "user_metadata" buffor that is also stored in cache metadata, but we cannot use it because its size is limited to 64 bytes. UUID in OCF terms is not standarized and is meant to be used to store custom immutable data. This change preparation for persistent metadata support. Functionality is not changed. (everything works the same way) Signed-off-by: Vitaliy Mysak Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/455414 (master) (cherry picked from commit 4003ebf73cdb8ef26b91b8e9b980c41baae6e667) Change-Id: Ia9204fae29106f5b816d93a6771425a223d6c028 Signed-off-by: Tomasz Zawadzki Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457268 Tested-by: SPDK CI Jenkins Reviewed-by: Darek Stojaczyk Reviewed-by: Ben Walker --- lib/bdev/ocf/vbdev_ocf.c | 11 +++++++++-- lib/bdev/ocf/vbdev_ocf.h | 5 +++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/bdev/ocf/vbdev_ocf.c b/lib/bdev/ocf/vbdev_ocf.c index 943d49f9f8..b055b4f472 100644 --- a/lib/bdev/ocf/vbdev_ocf.c +++ b/lib/bdev/ocf/vbdev_ocf.c @@ -1068,10 +1068,17 @@ init_vbdev_config(struct vbdev_ocf *vbdev) vbdev->cfg.core.try_add = true; } + /* Serialize bdev names in OCF UUID to interpret on future loads + * Core UUID is pair of (core bdev name, cache bdev name) + * Cache UUID is cache bdev name */ cfg->device.uuid.size = strlen(vbdev->cache.name) + 1; cfg->device.uuid.data = vbdev->cache.name; - cfg->core.uuid.size = strlen(vbdev->core.name) + 1; - cfg->core.uuid.data = vbdev->core.name; + + snprintf(vbdev->uuid, VBDEV_OCF_MD_MAX_LEN, "%s %s", + vbdev->core.name, vbdev->name); + cfg->core.uuid.size = strlen(vbdev->uuid) + 1; + cfg->core.uuid.data = vbdev->uuid; + vbdev->uuid[strlen(vbdev->core.name)] = 0; } /* Allocate vbdev structure object and add it to the global list */ diff --git a/lib/bdev/ocf/vbdev_ocf.h b/lib/bdev/ocf/vbdev_ocf.h index 16ab26e925..0b952bd5a6 100644 --- a/lib/bdev/ocf/vbdev_ocf.h +++ b/lib/bdev/ocf/vbdev_ocf.h @@ -39,6 +39,8 @@ #include "spdk/bdev.h" #include "spdk/bdev_module.h" +#define VBDEV_OCF_MD_MAX_LEN 4096 + struct vbdev_ocf; /* Context for OCF queue poller @@ -169,6 +171,9 @@ struct vbdev_ocf { /* Exposed SPDK bdev. Registered in bdev layer */ struct spdk_bdev exp_bdev; + /* OCF uuid for core device of this vbdev */ + char uuid[VBDEV_OCF_MD_MAX_LEN]; + /* Link to global list of this type structures */ TAILQ_ENTRY(vbdev_ocf) tailq; };