bdev/null: Add data protection type configuration file parameter

Configuration file allows to configure only type of protection
information. Protection information is always located in the last 8
bytes of metadata.

Signed-off-by: Evgeniy Kochetov <evgeniik@mellanox.com>
Signed-off-by: Sasha Kotchubievsky <sashakot@mellanox.com>
Signed-off-by: Alexey Marchuk <alexeymar@mellanox.com>
Change-Id: Ib8e151b833f88201e23d3c637231e1f64c96f879
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/464782
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Evgeniy Kochetov 2019-08-01 11:24:46 +00:00 committed by Jim Harris
parent 20aeec560b
commit b9d5e78852

View File

@ -387,7 +387,7 @@ bdev_null_initialize(void)
struct spdk_conf_section *sp = spdk_conf_find_section(NULL, "Null");
uint64_t size_in_mb, num_blocks;
int block_size, i, rc = 0;
int md_size;
int md_size, dif_type;
struct spdk_bdev *bdev;
const char *name, *val;
struct spdk_null_bdev_opts opts = {};
@ -460,6 +460,17 @@ bdev_null_initialize(void)
continue;
}
}
val = spdk_conf_section_get_nmval(sp, "Dev", i, 4);
if (val == NULL) {
dif_type = SPDK_DIF_DISABLE;
} else {
dif_type = (int)spdk_strtol(val, 10);
if (dif_type < SPDK_DIF_DISABLE || dif_type > SPDK_DIF_TYPE3) {
SPDK_ERRLOG("Null entry %d: Invalid data protection type %s\n", i, val);
continue;
}
}
num_blocks = size_in_mb * (1024 * 1024) / block_size;
opts.name = name;
@ -467,6 +478,8 @@ bdev_null_initialize(void)
opts.block_size = block_size;
opts.md_size = md_size;
opts.md_interleave = true;
opts.dif_type = dif_type;
opts.dif_is_head_of_md = false;
rc = create_null_bdev(&bdev, &opts);
if (rc) {
SPDK_ERRLOG("Could not create null bdev\n");
@ -504,8 +517,9 @@ bdev_null_get_spdk_running_config(FILE *fp)
TAILQ_FOREACH(bdev, &g_null_bdev_head, tailq) {
null_bdev_size = bdev->bdev.blocklen * bdev->bdev.blockcnt;
null_bdev_size /= (1024 * 1024);
fprintf(fp, " Dev %s %" PRIu64 " %d %d\n",
bdev->bdev.name, null_bdev_size, bdev->bdev.blocklen, bdev->bdev.md_len);
fprintf(fp, " Dev %s %" PRIu64 " %d %d %d\n",
bdev->bdev.name, null_bdev_size, bdev->bdev.blocklen, bdev->bdev.md_len,
bdev->bdev.dif_type);
}
}