Commit 746a54be authored by Jim Harris's avatar Jim Harris
Browse files

bdev: create new get_channel/put_channel function pointers



Also implement these functions for all of the bdev drivers in
the tree.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: Idea97743d601150044b1fe2d9d76e922d46d3ee1
parent eb605a82
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -146,6 +146,9 @@ struct spdk_bdev_fn_table {

	/** Check if the block device supports a specific I/O type. */
	bool (*io_type_supported)(struct spdk_bdev *bdev, enum spdk_bdev_io_type);

	/** Get an I/O channel for the specific bdev for the calling thread. */
	struct spdk_io_channel *(*get_io_channel)(struct spdk_bdev *bdev, uint32_t priority);
};

/** Blockdev I/O completion status */
@@ -308,5 +311,5 @@ void spdk_bdev_do_work(void *ctx);
int spdk_bdev_free_io(struct spdk_bdev_io *bdev_io);
int spdk_bdev_reset(struct spdk_bdev *bdev, enum spdk_bdev_reset_type,
		    spdk_bdev_io_completion_cb cb, void *cb_arg);

struct spdk_io_channel *spdk_bdev_get_io_channel(struct spdk_bdev *bdev, uint32_t priority);
#endif /* SPDK_BDEV_H_ */
+34 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@
#include "spdk/conf.h"
#include "spdk/fd.h"
#include "spdk/log.h"
#include "spdk/io_channel.h"

static int g_blockdev_count = 0;

@@ -314,11 +315,42 @@ blockdev_aio_io_type_supported(struct spdk_bdev *bdev, enum spdk_bdev_io_type io
	}
}

static int
blockdev_aio_create_cb(void *io_device, uint32_t priority, void *ctx_buf)
{
	struct blockdev_aio_io_channel *ch = ctx_buf;

	if (blockdev_aio_initialize_io_channel(ch) != 0) {
		return -1;
	}

	spdk_poller_register(&ch->poller, blockdev_aio_poll, ch,
			     spdk_app_get_current_core(), NULL, 0);
	return 0;
}

static void
blockdev_aio_destroy_cb(void *io_device, void *ctx_buf)
{
	struct blockdev_aio_io_channel *io_channel = ctx_buf;

	io_destroy(io_channel->io_ctx);
	free(io_channel->events);
	spdk_poller_unregister(&io_channel->poller, NULL);
}

static struct spdk_io_channel *
blockdev_aio_get_io_channel(struct spdk_bdev *bdev, uint32_t priority)
{
	return spdk_get_io_channel(bdev, priority);
}

static const struct spdk_bdev_fn_table aio_fn_table = {
	.destruct		= blockdev_aio_destruct,
	.check_io		= blockdev_aio_check_io,
	.submit_request		= blockdev_aio_submit_request,
	.io_type_supported	= blockdev_aio_io_type_supported,
	.get_io_channel		= blockdev_aio_get_io_channel,
};

static void aio_free_disk(struct file_disk *fdisk)
@@ -367,6 +399,8 @@ create_aio_disk(char *fname)

	g_blockdev_count++;

	spdk_io_device_register(&fdisk->disk, blockdev_aio_create_cb, blockdev_aio_destroy_cb,
				sizeof(struct blockdev_aio_io_channel));
	spdk_bdev_register(&fdisk->disk);
	return fdisk;

+1 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ struct blockdev_aio_io_channel {
	io_context_t		io_ctx;
	long			queue_depth;
	struct io_event		*events;
	struct spdk_poller	*poller;
};

struct file_disk {
+6 −0
Original line number Diff line number Diff line
@@ -535,6 +535,12 @@ spdk_bdev_io_type_supported(struct spdk_bdev *bdev, enum spdk_bdev_io_type io_ty
	return bdev->fn_table->io_type_supported(bdev, io_type);
}

struct spdk_io_channel *
spdk_bdev_get_io_channel(struct spdk_bdev *bdev, uint32_t priority)
{
	return bdev->fn_table->get_io_channel(bdev, priority);
}

struct spdk_bdev_io *
spdk_bdev_read(struct spdk_bdev *bdev,
	       void *buf, uint64_t offset, uint64_t nbytes,
+8 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@
#include "spdk/endian.h"
#include "spdk/log.h"
#include "spdk/copy_engine.h"
#include "spdk/io_channel.h"

#include "bdev_module.h"

@@ -266,11 +267,18 @@ blockdev_malloc_io_type_supported(struct spdk_bdev *bdev, enum spdk_bdev_io_type
	}
}

static struct spdk_io_channel *
blockdev_malloc_get_io_channel(struct spdk_bdev *bdev, uint32_t priority)
{
	return spdk_copy_engine_get_io_channel(priority);
}

static const struct spdk_bdev_fn_table malloc_fn_table = {
	.destruct		= blockdev_malloc_destruct,
	.check_io		= blockdev_malloc_check_io,
	.submit_request		= blockdev_malloc_submit_request,
	.io_type_supported	= blockdev_malloc_io_type_supported,
	.get_io_channel		= blockdev_malloc_get_io_channel,
};

struct malloc_disk *create_malloc_disk(uint64_t num_blocks, uint32_t block_size)
Loading