bdev/aio: The user now provides the names of AIO bdevs
The user now must choose the name for each AIO bdev. This provides consistency for names across restarts. Change-Id: I13ced1d02bb28c51d314512d60f739499b0c7d8d Signed-off-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
39ad6c3151
commit
6d7b6e882c
@ -62,9 +62,10 @@ Configuration file syntax:
|
|||||||
|
|
||||||
~~~
|
~~~
|
||||||
[AIO]
|
[AIO]
|
||||||
# normal file or block device
|
# AIO <file name> <bdev name>
|
||||||
AIO /dev/sdb
|
# The file name is the backing device
|
||||||
AIO /dev/sdc
|
# The bdev name can be referenced from elsewhere in the configuration file.
|
||||||
|
AIO /dev/sdb AIO0
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
This exports 2 aio block devices, named AIO0 and AIO1.
|
This exports 2 aio block devices, named AIO0 and AIO1.
|
||||||
|
@ -130,10 +130,14 @@
|
|||||||
Whitelist 00:04.1
|
Whitelist 00:04.1
|
||||||
|
|
||||||
# Users must change this section to match the /dev/sdX devices to be
|
# Users must change this section to match the /dev/sdX devices to be
|
||||||
# exported as iSCSI LUNs. The devices are accessed using Linux AIO.
|
# exported as iSCSI LUNs. The devices are accessed using Linux AIO.
|
||||||
|
# The format is:
|
||||||
|
# AIO <file name> <bdev name>
|
||||||
|
# The file name is the backing device
|
||||||
|
# The bdev name can be referenced from elsewhere in the configuration file.
|
||||||
[AIO]
|
[AIO]
|
||||||
AIO /dev/sdb
|
AIO /dev/sdb AIO0
|
||||||
AIO /dev/sdc
|
AIO /dev/sdc AIO1
|
||||||
|
|
||||||
# The Split virtual block device slices block devices into multiple smaller bdevs.
|
# The Split virtual block device slices block devices into multiple smaller bdevs.
|
||||||
[Split]
|
[Split]
|
||||||
|
@ -43,11 +43,15 @@
|
|||||||
NumberOfLuns 8
|
NumberOfLuns 8
|
||||||
LunSizeInMB 64
|
LunSizeInMB 64
|
||||||
|
|
||||||
# Users must change this section to match the /dev/sdX devices to be virtual
|
# Users must change this section to match the /dev/sdX devices to be
|
||||||
# NVMe devices. The devices are accessed using Linux AIO.
|
# exported as iSCSI LUNs. The devices are accessed using Linux AIO.
|
||||||
|
# The format is:
|
||||||
|
# AIO <file name> <bdev name>
|
||||||
|
# The file name is the backing device
|
||||||
|
# The bdev name can be referenced from elsewhere in the configuration file.
|
||||||
[AIO]
|
[AIO]
|
||||||
AIO /dev/sdb
|
AIO /dev/sdb AIO0
|
||||||
AIO /dev/sdc
|
AIO /dev/sdc AIO1
|
||||||
|
|
||||||
# Define NVMf protocol global options
|
# Define NVMf protocol global options
|
||||||
[Nvmf]
|
[Nvmf]
|
||||||
|
@ -48,8 +48,6 @@
|
|||||||
|
|
||||||
#include "spdk_internal/log.h"
|
#include "spdk_internal/log.h"
|
||||||
|
|
||||||
static int g_blockdev_count = 0;
|
|
||||||
|
|
||||||
static int blockdev_aio_initialize(void);
|
static int blockdev_aio_initialize(void);
|
||||||
static void aio_free_disk(struct file_disk *fdisk);
|
static void aio_free_disk(struct file_disk *fdisk);
|
||||||
|
|
||||||
@ -341,7 +339,7 @@ static void aio_free_disk(struct file_disk *fdisk)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct spdk_bdev *
|
struct spdk_bdev *
|
||||||
create_aio_disk(char *fname)
|
create_aio_disk(const char *name, const char *fname)
|
||||||
{
|
{
|
||||||
struct file_disk *fdisk;
|
struct file_disk *fdisk;
|
||||||
|
|
||||||
@ -360,8 +358,7 @@ create_aio_disk(char *fname)
|
|||||||
fdisk->size = spdk_fd_get_size(fdisk->fd);
|
fdisk->size = spdk_fd_get_size(fdisk->fd);
|
||||||
|
|
||||||
TAILQ_INIT(&fdisk->sync_completion_list);
|
TAILQ_INIT(&fdisk->sync_completion_list);
|
||||||
snprintf(fdisk->disk.name, SPDK_BDEV_MAX_NAME_LENGTH, "AIO%d",
|
snprintf(fdisk->disk.name, SPDK_BDEV_MAX_NAME_LENGTH, "%s", name);
|
||||||
g_blockdev_count);
|
|
||||||
snprintf(fdisk->disk.product_name, SPDK_BDEV_MAX_PRODUCT_NAME_LENGTH, "AIO disk");
|
snprintf(fdisk->disk.product_name, SPDK_BDEV_MAX_PRODUCT_NAME_LENGTH, "AIO disk");
|
||||||
|
|
||||||
fdisk->disk.need_aligned_buffer = 1;
|
fdisk->disk.need_aligned_buffer = 1;
|
||||||
@ -371,7 +368,6 @@ create_aio_disk(char *fname)
|
|||||||
fdisk->disk.ctxt = fdisk;
|
fdisk->disk.ctxt = fdisk;
|
||||||
|
|
||||||
fdisk->disk.fn_table = &aio_fn_table;
|
fdisk->disk.fn_table = &aio_fn_table;
|
||||||
g_blockdev_count++;
|
|
||||||
|
|
||||||
spdk_io_device_register(&fdisk->disk, blockdev_aio_create_cb, blockdev_aio_destroy_cb,
|
spdk_io_device_register(&fdisk->disk, blockdev_aio_create_cb, blockdev_aio_destroy_cb,
|
||||||
sizeof(struct blockdev_aio_io_channel));
|
sizeof(struct blockdev_aio_io_channel));
|
||||||
@ -386,38 +382,42 @@ error_return:
|
|||||||
|
|
||||||
static int blockdev_aio_initialize(void)
|
static int blockdev_aio_initialize(void)
|
||||||
{
|
{
|
||||||
|
size_t i;
|
||||||
|
struct spdk_conf_section *sp;
|
||||||
struct spdk_bdev *bdev;
|
struct spdk_bdev *bdev;
|
||||||
int i;
|
|
||||||
const char *val = NULL;
|
|
||||||
char *file;
|
|
||||||
struct spdk_conf_section *sp = spdk_conf_find_section(NULL, "AIO");
|
|
||||||
bool skip_missing = false;
|
|
||||||
|
|
||||||
if (sp != NULL) {
|
sp = spdk_conf_find_section(NULL, "AIO");
|
||||||
val = spdk_conf_section_get_val(sp, "SkipMissingFiles");
|
if (!sp) {
|
||||||
}
|
return 0;
|
||||||
if (val != NULL && !strcmp(val, "Yes")) {
|
|
||||||
skip_missing = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sp != NULL) {
|
i = 0;
|
||||||
for (i = 0; ; i++) {
|
while (true) {
|
||||||
val = spdk_conf_section_get_nval(sp, "AIO", i);
|
const char *file;
|
||||||
if (val == NULL)
|
const char *name;
|
||||||
break;
|
|
||||||
file = spdk_conf_section_get_nmval(sp, "AIO", i, 0);
|
|
||||||
if (file == NULL) {
|
|
||||||
SPDK_ERRLOG("AIO%d: format error\n", i);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bdev = create_aio_disk(file);
|
file = spdk_conf_section_get_nmval(sp, "AIO", i, 0);
|
||||||
|
if (!file) {
|
||||||
if (bdev == NULL && !skip_missing) {
|
break;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
name = spdk_conf_section_get_nmval(sp, "AIO", i, 1);
|
||||||
|
if (!name) {
|
||||||
|
SPDK_ERRLOG("No name provided for AIO disk with file %s\n", file);
|
||||||
|
i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
bdev = create_aio_disk(name, file);
|
||||||
|
if (!bdev) {
|
||||||
|
SPDK_ERRLOG("Unable to create AIO bdev from file %s\n", file);
|
||||||
|
i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ struct blockdev_aio_io_channel {
|
|||||||
|
|
||||||
struct file_disk {
|
struct file_disk {
|
||||||
struct spdk_bdev disk; /* this must be first element */
|
struct spdk_bdev disk; /* this must be first element */
|
||||||
char *file;
|
const char *file;
|
||||||
int fd;
|
int fd;
|
||||||
char disk_name[SPDK_BDEV_MAX_NAME_LENGTH];
|
char disk_name[SPDK_BDEV_MAX_NAME_LENGTH];
|
||||||
uint64_t size;
|
uint64_t size;
|
||||||
@ -69,6 +69,6 @@ struct file_disk {
|
|||||||
TAILQ_HEAD(, blockdev_aio_task) sync_completion_list;
|
TAILQ_HEAD(, blockdev_aio_task) sync_completion_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct spdk_bdev *create_aio_disk(char *fname);
|
struct spdk_bdev *create_aio_disk(const char *name, const char *fname);
|
||||||
|
|
||||||
#endif // SPDK_BLOCKDEV_AIO_H
|
#endif // SPDK_BLOCKDEV_AIO_H
|
||||||
|
@ -38,16 +38,19 @@
|
|||||||
#include "spdk_internal/log.h"
|
#include "spdk_internal/log.h"
|
||||||
|
|
||||||
struct rpc_construct_aio {
|
struct rpc_construct_aio {
|
||||||
|
char *name;
|
||||||
char *fname;
|
char *fname;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
free_rpc_construct_aio(struct rpc_construct_aio *req)
|
free_rpc_construct_aio(struct rpc_construct_aio *req)
|
||||||
{
|
{
|
||||||
|
free(req->name);
|
||||||
free(req->fname);
|
free(req->fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct spdk_json_object_decoder rpc_construct_aio_decoders[] = {
|
static const struct spdk_json_object_decoder rpc_construct_aio_decoders[] = {
|
||||||
|
{"name", offsetof(struct rpc_construct_aio, name), spdk_json_decode_string},
|
||||||
{"fname", offsetof(struct rpc_construct_aio, fname), spdk_json_decode_string},
|
{"fname", offsetof(struct rpc_construct_aio, fname), spdk_json_decode_string},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -67,7 +70,7 @@ spdk_rpc_construct_aio_bdev(struct spdk_jsonrpc_server_conn *conn,
|
|||||||
goto invalid;
|
goto invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
bdev = create_aio_disk(req.fname);
|
bdev = create_aio_disk(req.name, req.fname);
|
||||||
if (bdev == NULL) {
|
if (bdev == NULL) {
|
||||||
goto invalid;
|
goto invalid;
|
||||||
}
|
}
|
||||||
|
@ -165,11 +165,14 @@ p.set_defaults(func=construct_malloc_bdev)
|
|||||||
|
|
||||||
|
|
||||||
def construct_aio_bdev(args):
|
def construct_aio_bdev(args):
|
||||||
params = {'fname': args.fname}
|
params = {'name': args.name,
|
||||||
|
'fname': args.fname}
|
||||||
|
|
||||||
print_array(jsonrpc_call('construct_aio_bdev', params))
|
print_array(jsonrpc_call('construct_aio_bdev', params))
|
||||||
|
|
||||||
p = subparsers.add_parser('construct_aio_bdev', help='Add a bdev with aio backend')
|
p = subparsers.add_parser('construct_aio_bdev', help='Add a bdev with aio backend')
|
||||||
p.add_argument('fname', help='Path to device or file (ex: /dev/sda)')
|
p.add_argument('fname', help='Path to device or file (ex: /dev/sda)')
|
||||||
|
p.add_argument('name', help='Block device name')
|
||||||
p.set_defaults(func=construct_aio_bdev)
|
p.set_defaults(func=construct_aio_bdev)
|
||||||
|
|
||||||
def construct_nvme_bdev(args):
|
def construct_nvme_bdev(args):
|
||||||
|
@ -14,9 +14,4 @@
|
|||||||
Split Malloc2 8 1
|
Split Malloc2 8 1
|
||||||
|
|
||||||
[AIO]
|
[AIO]
|
||||||
# skip these blockdevs if the /dev/ramX nodes do not exist
|
AIO /dev/ram0 AIO0
|
||||||
# so that the blockdev tests can still run on systems that
|
|
||||||
# do not have /dev/ramX nodes configured
|
|
||||||
SkipMissingFiles Yes
|
|
||||||
# Linux AIO backend
|
|
||||||
AIO /dev/ram0
|
|
||||||
|
Loading…
Reference in New Issue
Block a user