bdev/ocf: Update OCF to 22.6.1
This OCF update is mainly focused on: - New volume API - New cache attach config instead of old cache device config - UUID moved to different struct - Persistent metadata is not supported due to metadata flapping (see 689c44c76ba87f80a9538c17220bb9ca6bffdda0 in OCF) Signed-off-by: Amir Haroush <amir.haroush@huawei.com> Signed-off-by: Shai Fultheim <shai.fultheim@huawei.com> Change-Id: Ic3bc0f1b58550dc3b03b0afc9bcb43b2b9b988c6 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17066 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Robert Baldyga
This commit is contained in:
parent
8e8c360b53
commit
3797564736
@ -115,6 +115,15 @@ is_ocf_cache_running(struct vbdev_ocf *vbdev)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
is_ocf_cache_initializing(struct vbdev_ocf *vbdev)
|
||||||
|
{
|
||||||
|
if (vbdev->cache.attached && vbdev->ocf_cache) {
|
||||||
|
return ocf_cache_is_initializing(vbdev->ocf_cache);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* Get existing OCF cache instance
|
/* Get existing OCF cache instance
|
||||||
* that is started by other vbdev */
|
* that is started by other vbdev */
|
||||||
static ocf_cache_t
|
static ocf_cache_t
|
||||||
@ -129,7 +138,7 @@ get_other_cache_instance(struct vbdev_ocf *vbdev)
|
|||||||
if (strcmp(cmp->cache.name, vbdev->cache.name)) {
|
if (strcmp(cmp->cache.name, vbdev->cache.name)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (is_ocf_cache_running(cmp)) {
|
if (is_ocf_cache_running(cmp) || is_ocf_cache_initializing(cmp)) {
|
||||||
return cmp->ocf_cache;
|
return cmp->ocf_cache;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -604,7 +613,8 @@ io_handle(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
|
|||||||
flags = OCF_WRITE_FLUSH;
|
flags = OCF_WRITE_FLUSH;
|
||||||
}
|
}
|
||||||
|
|
||||||
io = ocf_core_new_io(vbdev->ocf_core, qctx->queue, offset, len, dir, 0, flags);
|
io = ocf_volume_new_io(ocf_core_get_front_volume(vbdev->ocf_core), qctx->queue, offset, len, dir, 0,
|
||||||
|
flags);
|
||||||
if (!io) {
|
if (!io) {
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
goto fail;
|
goto fail;
|
||||||
@ -994,7 +1004,7 @@ start_cache_cmpl(ocf_cache_t cache, void *priv, int error)
|
|||||||
error, vbdev->name);
|
error, vbdev->name);
|
||||||
|
|
||||||
if (error == -OCF_ERR_NO_MEM) {
|
if (error == -OCF_ERR_NO_MEM) {
|
||||||
ocf_mngt_get_ram_needed(cache, &vbdev->cfg.device, &mem_needed);
|
ocf_mngt_get_ram_needed(cache, &vbdev->cfg.attach.device, &mem_needed);
|
||||||
|
|
||||||
SPDK_NOTICELOG("Try to increase hugepage memory size or cache line size. "
|
SPDK_NOTICELOG("Try to increase hugepage memory size or cache line size. "
|
||||||
"For your configuration:\nDevice size: %"PRIu64" bytes\n"
|
"For your configuration:\nDevice size: %"PRIu64" bytes\n"
|
||||||
@ -1095,9 +1105,9 @@ start_cache(struct vbdev_ocf *vbdev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (vbdev->cfg.loadq) {
|
if (vbdev->cfg.loadq) {
|
||||||
ocf_mngt_cache_load(vbdev->ocf_cache, &vbdev->cfg.device, start_cache_cmpl, vbdev);
|
ocf_mngt_cache_load(vbdev->ocf_cache, &vbdev->cfg.attach, start_cache_cmpl, vbdev);
|
||||||
} else {
|
} else {
|
||||||
ocf_mngt_cache_attach(vbdev->ocf_cache, &vbdev->cfg.device, start_cache_cmpl, vbdev);
|
ocf_mngt_cache_attach(vbdev->ocf_cache, &vbdev->cfg.attach, start_cache_cmpl, vbdev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1129,27 +1139,30 @@ register_vbdev(struct vbdev_ocf *vbdev, vbdev_ocf_mngt_callback cb, void *cb_arg
|
|||||||
|
|
||||||
/* Init OCF configuration options
|
/* Init OCF configuration options
|
||||||
* for core and cache devices */
|
* for core and cache devices */
|
||||||
static void
|
static int
|
||||||
init_vbdev_config(struct vbdev_ocf *vbdev)
|
init_vbdev_config(struct vbdev_ocf *vbdev)
|
||||||
{
|
{
|
||||||
struct vbdev_ocf_config *cfg = &vbdev->cfg;
|
struct vbdev_ocf_config *cfg = &vbdev->cfg;
|
||||||
|
struct ocf_volume_uuid uuid;
|
||||||
|
ocf_volume_type_t type;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
|
||||||
/* Initialize OCF defaults first */
|
/* Initialize OCF defaults first */
|
||||||
ocf_mngt_cache_device_config_set_default(&cfg->device);
|
ocf_mngt_cache_attach_config_set_default(&cfg->attach);
|
||||||
ocf_mngt_cache_config_set_default(&cfg->cache);
|
ocf_mngt_cache_config_set_default(&cfg->cache);
|
||||||
ocf_mngt_core_config_set_default(&cfg->core);
|
ocf_mngt_core_config_set_default(&cfg->core);
|
||||||
|
|
||||||
snprintf(cfg->cache.name, sizeof(cfg->cache.name), "%s", vbdev->name);
|
snprintf(cfg->cache.name, sizeof(cfg->cache.name), "%s", vbdev->name);
|
||||||
snprintf(cfg->core.name, sizeof(cfg->core.name), "%s", vbdev->core.name);
|
snprintf(cfg->core.name, sizeof(cfg->core.name), "%s", vbdev->core.name);
|
||||||
|
|
||||||
cfg->device.open_cores = false;
|
cfg->attach.open_cores = false;
|
||||||
cfg->device.perform_test = false;
|
cfg->attach.device.perform_test = false;
|
||||||
cfg->device.discard_on_start = false;
|
cfg->attach.discard_on_start = false;
|
||||||
|
|
||||||
vbdev->cfg.cache.locked = true;
|
vbdev->cfg.cache.locked = true;
|
||||||
|
|
||||||
cfg->core.volume_type = SPDK_OBJECT;
|
cfg->core.volume_type = SPDK_OBJECT;
|
||||||
cfg->device.volume_type = SPDK_OBJECT;
|
|
||||||
|
|
||||||
if (vbdev->cfg.loadq) {
|
if (vbdev->cfg.loadq) {
|
||||||
/* When doing cache_load(), we need to set try_add to true,
|
/* When doing cache_load(), we need to set try_add to true,
|
||||||
@ -1159,14 +1172,24 @@ init_vbdev_config(struct vbdev_ocf *vbdev)
|
|||||||
} else {
|
} else {
|
||||||
/* When cache is initialized as new, set force flag to true,
|
/* When cache is initialized as new, set force flag to true,
|
||||||
* to ignore warnings about existing metadata */
|
* to ignore warnings about existing metadata */
|
||||||
cfg->device.force = true;
|
cfg->attach.force = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Serialize bdev names in OCF UUID to interpret on future loads
|
/* Serialize bdev names in OCF UUID to interpret on future loads
|
||||||
* Core UUID is a triple of (core name, vbdev name, cache name)
|
* Core UUID is a triple of (core name, vbdev name, cache name)
|
||||||
* Cache UUID is cache bdev name */
|
* Cache UUID is cache bdev name */
|
||||||
cfg->device.uuid.size = strlen(vbdev->cache.name) + 1;
|
type = ocf_ctx_get_volume_type(vbdev_ocf_ctx, SPDK_OBJECT);
|
||||||
cfg->device.uuid.data = vbdev->cache.name;
|
if (!type) {
|
||||||
|
SPDK_ERRLOG("Fail to get volume type\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
uuid.size = strlen(vbdev->cache.name) + 1;
|
||||||
|
uuid.data = vbdev->cache.name;
|
||||||
|
ret = ocf_volume_create(&cfg->attach.device.volume, type, &uuid);
|
||||||
|
if (ret) {
|
||||||
|
SPDK_ERRLOG("Fail to create volume\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
snprintf(vbdev->uuid, VBDEV_OCF_MD_MAX_LEN, "%s %s %s",
|
snprintf(vbdev->uuid, VBDEV_OCF_MD_MAX_LEN, "%s %s %s",
|
||||||
vbdev->core.name, vbdev->name, vbdev->cache.name);
|
vbdev->core.name, vbdev->name, vbdev->cache.name);
|
||||||
@ -1174,6 +1197,8 @@ init_vbdev_config(struct vbdev_ocf *vbdev)
|
|||||||
cfg->core.uuid.data = vbdev->uuid;
|
cfg->core.uuid.data = vbdev->uuid;
|
||||||
vbdev->uuid[strlen(vbdev->core.name)] = 0;
|
vbdev->uuid[strlen(vbdev->core.name)] = 0;
|
||||||
vbdev->uuid[strlen(vbdev->core.name) + 1 + strlen(vbdev->name)] = 0;
|
vbdev->uuid[strlen(vbdev->core.name) + 1 + strlen(vbdev->name)] = 0;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate vbdev structure object and add it to the global list */
|
/* Allocate vbdev structure object and add it to the global list */
|
||||||
@ -1219,7 +1244,12 @@ init_vbdev(const char *vbdev_name,
|
|||||||
vbdev->core.is_cache = false;
|
vbdev->core.is_cache = false;
|
||||||
vbdev->cfg.loadq = loadq;
|
vbdev->cfg.loadq = loadq;
|
||||||
|
|
||||||
init_vbdev_config(vbdev);
|
rc = init_vbdev_config(vbdev);
|
||||||
|
if (rc) {
|
||||||
|
SPDK_ERRLOG("Fail to init vbdev config\n");
|
||||||
|
goto error_free;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (cache_mode_name) {
|
if (cache_mode_name) {
|
||||||
vbdev->cfg.cache.cache_mode
|
vbdev->cfg.cache.cache_mode
|
||||||
@ -1243,7 +1273,7 @@ init_vbdev(const char *vbdev_name,
|
|||||||
rc = -EINVAL;
|
rc = -EINVAL;
|
||||||
goto error_free;
|
goto error_free;
|
||||||
}
|
}
|
||||||
vbdev->cfg.device.cache_line_size = set_cache_line_size;
|
vbdev->cfg.attach.cache_line_size = set_cache_line_size;
|
||||||
vbdev->cfg.cache.cache_line_size = set_cache_line_size;
|
vbdev->cfg.cache.cache_line_size = set_cache_line_size;
|
||||||
|
|
||||||
TAILQ_INSERT_TAIL(&g_ocf_vbdev_head, vbdev, tailq);
|
TAILQ_INSERT_TAIL(&g_ocf_vbdev_head, vbdev, tailq);
|
||||||
@ -1625,85 +1655,6 @@ examine_ctx_put(struct metadata_probe_ctx *ctx)
|
|||||||
free(ctx);
|
free(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
metadata_probe_construct_cb(int rc, struct vbdev_ocf *vbdev, void *vctx)
|
|
||||||
{
|
|
||||||
struct metadata_probe_ctx *ctx = vctx;
|
|
||||||
|
|
||||||
examine_ctx_put(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This is second callback for ocf_metadata_probe_cores()
|
|
||||||
* Here we create vbdev configurations based on UUIDs */
|
|
||||||
static void
|
|
||||||
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) {
|
|
||||||
ctx->result = error;
|
|
||||||
examine_ctx_put(ctx);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
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, 0, cache_name, core_name, true,
|
|
||||||
metadata_probe_construct_cb, ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
examine_ctx_put(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This callback is called after OCF reads cores UUIDs from cache metadata
|
|
||||||
* Here we allocate memory for those UUIDs and call ocf_metadata_probe_cores() again */
|
|
||||||
static void
|
|
||||||
metadata_probe_cores_get_num(void *priv, int error, unsigned int num_cores)
|
|
||||||
{
|
|
||||||
struct metadata_probe_ctx *ctx = priv;
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
if (error) {
|
|
||||||
ctx->result = error;
|
|
||||||
examine_ctx_put(ctx);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx->uuid_count = num_cores;
|
|
||||||
ctx->core_uuids = calloc(num_cores, sizeof(struct ocf_volume_uuid));
|
|
||||||
if (!ctx->core_uuids) {
|
|
||||||
ctx->result = -ENOMEM;
|
|
||||||
examine_ctx_put(ctx);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < ctx->uuid_count; i++) {
|
|
||||||
ctx->core_uuids[i].size = OCF_VOLUME_UUID_MAX_SIZE;
|
|
||||||
ctx->core_uuids[i].data = malloc(OCF_VOLUME_UUID_MAX_SIZE);
|
|
||||||
if (!ctx->core_uuids[i].data) {
|
|
||||||
ctx->result = -ENOMEM;
|
|
||||||
examine_ctx_put(ctx);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ocf_metadata_probe_cores(vbdev_ocf_ctx, ctx->volume, ctx->core_uuids, ctx->uuid_count,
|
|
||||||
metadata_probe_cores_construct, ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
metadata_probe_cb(void *priv, int rc,
|
metadata_probe_cb(void *priv, int rc,
|
||||||
struct ocf_metadata_probe_status *status)
|
struct ocf_metadata_probe_status *status)
|
||||||
@ -1715,12 +1666,9 @@ metadata_probe_cb(void *priv, int rc,
|
|||||||
if (rc != -OCF_ERR_NO_METADATA) {
|
if (rc != -OCF_ERR_NO_METADATA) {
|
||||||
ctx->result = rc;
|
ctx->result = rc;
|
||||||
}
|
}
|
||||||
examine_ctx_put(ctx);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ocf_metadata_probe_cores(vbdev_ocf_ctx, ctx->volume, NULL, 0,
|
examine_ctx_put(ctx);
|
||||||
metadata_probe_cores_get_num, ctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This is called after vbdev_ocf_examine
|
/* This is called after vbdev_ocf_examine
|
||||||
|
@ -57,7 +57,7 @@ struct vbdev_ocf_config {
|
|||||||
struct ocf_mngt_cache_config cache;
|
struct ocf_mngt_cache_config cache;
|
||||||
|
|
||||||
/* Cache device config */
|
/* Cache device config */
|
||||||
struct ocf_mngt_cache_device_config device;
|
struct ocf_mngt_cache_attach_config attach;
|
||||||
|
|
||||||
/* Core initial config */
|
/* Core initial config */
|
||||||
struct ocf_mngt_core_config core;
|
struct ocf_mngt_core_config core;
|
||||||
|
2
ocf
2
ocf
@ -1 +1 @@
|
|||||||
Subproject commit 4477cb55a0bcd313a5ebcfdf877ca76a31695df7
|
Subproject commit d1d6d7cb5f55b616d2aa5123f84ce4ece10fdb0b
|
@ -1,101 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
# SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
# Copyright (C) 2019 Intel Corporation
|
|
||||||
# All rights reserved.
|
|
||||||
#
|
|
||||||
curdir=$(dirname $(readlink -f "${BASH_SOURCE[0]}"))
|
|
||||||
rootdir=$(readlink -f $curdir/../../..)
|
|
||||||
source $rootdir/test/ocf/common.sh
|
|
||||||
|
|
||||||
source $rootdir/scripts/common.sh
|
|
||||||
source $rootdir/test/common/autotest_common.sh
|
|
||||||
|
|
||||||
rpc_py=$rootdir/scripts/rpc.py
|
|
||||||
|
|
||||||
$rootdir/scripts/setup.sh
|
|
||||||
|
|
||||||
mapfile -t config < <("$rootdir/scripts/gen_nvme.sh")
|
|
||||||
# Drop anything from last closing ] so we can inject our own config pieces ...
|
|
||||||
config=("${config[@]::${#config[@]}-2}")
|
|
||||||
# ... and now convert entire array to a single string item
|
|
||||||
config=("${config[*]}")
|
|
||||||
|
|
||||||
config+=(
|
|
||||||
"$(
|
|
||||||
cat <<- JSON
|
|
||||||
{
|
|
||||||
"method": "bdev_split_create",
|
|
||||||
"params": {
|
|
||||||
"base_bdev": "Nvme0n1",
|
|
||||||
"split_count": 7,
|
|
||||||
"split_size_mb": 128
|
|
||||||
}
|
|
||||||
}
|
|
||||||
JSON
|
|
||||||
)"
|
|
||||||
)
|
|
||||||
|
|
||||||
config+=(
|
|
||||||
"$(
|
|
||||||
cat <<- JSON
|
|
||||||
{
|
|
||||||
"method": "bdev_wait_for_examine"
|
|
||||||
}
|
|
||||||
JSON
|
|
||||||
)"
|
|
||||||
)
|
|
||||||
|
|
||||||
# First ']}' closes our config and bdev subsystem blocks
|
|
||||||
jq . <<- CONFIG > "$curdir/config"
|
|
||||||
{"subsystems":[
|
|
||||||
$(
|
|
||||||
IFS=","
|
|
||||||
printf '%s\n' "${config[*]}"
|
|
||||||
)
|
|
||||||
]}]}
|
|
||||||
CONFIG
|
|
||||||
|
|
||||||
# Clear nvme device which we will use in test
|
|
||||||
clear_nvme
|
|
||||||
|
|
||||||
"$SPDK_BIN_DIR/iscsi_tgt" --json "$curdir/config" &
|
|
||||||
spdk_pid=$!
|
|
||||||
|
|
||||||
waitforlisten $spdk_pid
|
|
||||||
|
|
||||||
# Create ocf on persistent storage
|
|
||||||
|
|
||||||
$rpc_py bdev_ocf_create ocfWT wt Nvme0n1p0 Nvme0n1p1
|
|
||||||
$rpc_py bdev_ocf_create ocfPT pt Nvme0n1p2 Nvme0n1p3
|
|
||||||
$rpc_py bdev_ocf_create ocfWB0 wb Nvme0n1p4 Nvme0n1p5
|
|
||||||
$rpc_py bdev_ocf_create ocfWB1 wb Nvme0n1p4 Nvme0n1p6
|
|
||||||
|
|
||||||
# Sorting bdevs because we dont guarantee that they are going to be
|
|
||||||
# in the same order after shutdown
|
|
||||||
($rpc_py bdev_ocf_get_bdevs | jq '(.. | arrays) |= sort') > ./ocf_bdevs
|
|
||||||
|
|
||||||
trap - SIGINT SIGTERM EXIT
|
|
||||||
|
|
||||||
killprocess $spdk_pid
|
|
||||||
|
|
||||||
# Check for ocf persistency after restart
|
|
||||||
"$SPDK_BIN_DIR/iscsi_tgt" --json "$curdir/config" &
|
|
||||||
spdk_pid=$!
|
|
||||||
|
|
||||||
trap 'killprocess $spdk_pid; rm -f $curdir/config ocf_bdevs ocf_bdevs_verify; exit 1' SIGINT SIGTERM EXIT
|
|
||||||
|
|
||||||
waitforlisten $spdk_pid
|
|
||||||
sleep 5
|
|
||||||
|
|
||||||
# OCF should be loaded now as well
|
|
||||||
|
|
||||||
($rpc_py bdev_ocf_get_bdevs | jq '(.. | arrays) |= sort') > ./ocf_bdevs_verify
|
|
||||||
|
|
||||||
diff ocf_bdevs ocf_bdevs_verify
|
|
||||||
|
|
||||||
trap - SIGINT SIGTERM EXIT
|
|
||||||
|
|
||||||
killprocess $spdk_pid
|
|
||||||
rm -f $curdir/config ocf_bdevs ocf_bdevs_verify
|
|
||||||
|
|
||||||
clear_nvme $bdf
|
|
@ -14,6 +14,5 @@ run_test "ocf_stats" "$testdir/integrity/stats.sh"
|
|||||||
run_test "ocf_flush" "$testdir/integrity/flush.sh"
|
run_test "ocf_flush" "$testdir/integrity/flush.sh"
|
||||||
run_test "ocf_create_destruct" "$testdir/management/create-destruct.sh"
|
run_test "ocf_create_destruct" "$testdir/management/create-destruct.sh"
|
||||||
run_test "ocf_multicore" "$testdir/management/multicore.sh"
|
run_test "ocf_multicore" "$testdir/management/multicore.sh"
|
||||||
run_test "ocf_persistent_metadata" "$testdir/management/persistent-metadata.sh"
|
|
||||||
run_test "ocf_remove" "$testdir/management/remove.sh"
|
run_test "ocf_remove" "$testdir/management/remove.sh"
|
||||||
run_test "ocf_configuration_change" "$testdir/management/configuration-change.sh"
|
run_test "ocf_configuration_change" "$testdir/management/configuration-change.sh"
|
||||||
|
Loading…
Reference in New Issue
Block a user