Commit 6d7b6e88 authored by Ben Walker's avatar Ben Walker
Browse files

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: default avatarBen Walker <benjamin.walker@intel.com>
parent 39ad6c31
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -62,9 +62,10 @@ Configuration file syntax:

~~~
[AIO]
  # normal file or block device
  AIO /dev/sdb
  AIO /dev/sdc
  # 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 /dev/sdb AIO0
~~~

This exports 2 aio block devices, named AIO0 and AIO1.
+7 −3
Original line number Diff line number Diff line
@@ -131,9 +131,13 @@

# Users must change this section to match the /dev/sdX devices to be
# 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 /dev/sdb
  AIO /dev/sdc
  AIO /dev/sdb AIO0
  AIO /dev/sdc AIO1

# The Split virtual block device slices block devices into multiple smaller bdevs.
[Split]
+8 −4
Original line number Diff line number Diff line
@@ -43,11 +43,15 @@
  NumberOfLuns 8
  LunSizeInMB 64

# Users must change this section to match the /dev/sdX devices to be virtual
# NVMe devices. The devices are accessed using Linux AIO.
# Users must change this section to match the /dev/sdX devices to be
# 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 /dev/sdb
  AIO /dev/sdc
  AIO /dev/sdb AIO0
  AIO /dev/sdc AIO1

# Define NVMf protocol global options
[Nvmf]
+33 −33
Original line number Diff line number Diff line
@@ -48,8 +48,6 @@

#include "spdk_internal/log.h"

static int g_blockdev_count = 0;

static int blockdev_aio_initialize(void);
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 *
create_aio_disk(char *fname)
create_aio_disk(const char *name, const char *fname)
{
	struct file_disk *fdisk;

@@ -360,8 +358,7 @@ create_aio_disk(char *fname)
	fdisk->size = spdk_fd_get_size(fdisk->fd);

	TAILQ_INIT(&fdisk->sync_completion_list);
	snprintf(fdisk->disk.name, SPDK_BDEV_MAX_NAME_LENGTH, "AIO%d",
		 g_blockdev_count);
	snprintf(fdisk->disk.name, SPDK_BDEV_MAX_NAME_LENGTH, "%s", name);
	snprintf(fdisk->disk.product_name, SPDK_BDEV_MAX_PRODUCT_NAME_LENGTH, "AIO disk");

	fdisk->disk.need_aligned_buffer = 1;
@@ -371,7 +368,6 @@ create_aio_disk(char *fname)
	fdisk->disk.ctxt = fdisk;

	fdisk->disk.fn_table = &aio_fn_table;
	g_blockdev_count++;

	spdk_io_device_register(&fdisk->disk, blockdev_aio_create_cb, blockdev_aio_destroy_cb,
				sizeof(struct blockdev_aio_io_channel));
@@ -386,38 +382,42 @@ error_return:

static int blockdev_aio_initialize(void)
{
	size_t i;
	struct spdk_conf_section *sp;
	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) {
		val = spdk_conf_section_get_val(sp, "SkipMissingFiles");
	}
	if (val != NULL && !strcmp(val, "Yes")) {
		skip_missing = true;
	sp = spdk_conf_find_section(NULL, "AIO");
	if (!sp) {
		return 0;
	}

	if (sp != NULL) {
		for (i = 0; ; i++) {
			val = spdk_conf_section_get_nval(sp, "AIO", i);
			if (val == NULL)
				break;
	i = 0;
	while (true) {
		const char *file;
		const char *name;

		file = spdk_conf_section_get_nmval(sp, "AIO", i, 0);
			if (file == NULL) {
				SPDK_ERRLOG("AIO%d: format error\n", i);
				return -1;
		if (!file) {
			break;
		}

			bdev = create_aio_disk(file);

			if (bdev == NULL && !skip_missing) {
				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;
}

+2 −2
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ struct blockdev_aio_io_channel {

struct file_disk {
	struct spdk_bdev	disk;	/* this must be first element */
	char			*file;
	const char		*file;
	int			fd;
	char			disk_name[SPDK_BDEV_MAX_NAME_LENGTH];
	uint64_t		size;
@@ -69,6 +69,6 @@ struct file_disk {
	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
Loading