bdev/null: Add metadata support for Null bdev
'md_interleave' option is added to spdk_null_bdev_opts along with 'md_size', but only interleaved metadata is supported at the moment. 'md_interleave' option must be initialiazed with 'true', otherwise -ENOTSUP will be returned from Null bdev constructor. 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: Ibee745741d0125534e06aa6a35767d9dff795951 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/464777 Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
703a5473f7
commit
f12094267b
@ -39,6 +39,10 @@ A new RPC `bdev_compress_get_orphans` has been added to list compress bdevs
|
||||
that were not loaded due to a missing pm metadata file. In this state they
|
||||
can only be deleted.
|
||||
|
||||
### null bdev
|
||||
|
||||
Metadata support has been added to Null bdev module.
|
||||
|
||||
## v19.07:
|
||||
|
||||
### ftl
|
||||
|
@ -175,6 +175,7 @@ int
|
||||
create_null_bdev(struct spdk_bdev **bdev, const struct spdk_null_bdev_opts *opts)
|
||||
{
|
||||
struct null_bdev *null_disk;
|
||||
uint32_t data_block_size;
|
||||
int rc;
|
||||
|
||||
if (!opts) {
|
||||
@ -182,8 +183,22 @@ create_null_bdev(struct spdk_bdev **bdev, const struct spdk_null_bdev_opts *opts
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (opts->block_size % 512 != 0) {
|
||||
SPDK_ERRLOG("Block size %u is not a multiple of 512.\n", opts->block_size);
|
||||
if (opts->md_interleave) {
|
||||
if (opts->block_size < opts->md_size) {
|
||||
SPDK_ERRLOG("Interleaved metadata size can not be greater than block size.\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
data_block_size = opts->block_size - opts->md_size;
|
||||
} else {
|
||||
if (opts->md_size != 0) {
|
||||
SPDK_ERRLOG("Metadata in separate buffer is not supported\n");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
data_block_size = opts->block_size;
|
||||
}
|
||||
|
||||
if (data_block_size % 512 != 0) {
|
||||
SPDK_ERRLOG("Data block size %u is not a multiple of 512.\n", opts->block_size);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@ -208,6 +223,8 @@ create_null_bdev(struct spdk_bdev **bdev, const struct spdk_null_bdev_opts *opts
|
||||
null_disk->bdev.write_cache = 0;
|
||||
null_disk->bdev.blocklen = opts->block_size;
|
||||
null_disk->bdev.blockcnt = opts->num_blocks;
|
||||
null_disk->bdev.md_len = opts->md_size;
|
||||
null_disk->bdev.md_interleave = opts->md_interleave;
|
||||
if (opts->uuid) {
|
||||
null_disk->bdev.uuid = *opts->uuid;
|
||||
} else {
|
||||
|
@ -46,6 +46,8 @@ struct spdk_null_bdev_opts {
|
||||
const struct spdk_uuid *uuid;
|
||||
uint64_t num_blocks;
|
||||
uint32_t block_size;
|
||||
uint32_t md_size;
|
||||
bool md_interleave;
|
||||
};
|
||||
|
||||
int create_null_bdev(struct spdk_bdev **bdev, const struct spdk_null_bdev_opts *opts);
|
||||
|
Loading…
x
Reference in New Issue
Block a user