Commit 0babf8ce authored by Jim Harris's avatar Jim Harris
Browse files

bdev, copy: move all I/O paths to use I/O channels



bdev and copy modules no longer have check_io functions
now - all polling is done via pollers registered when
I/O channels are created.

Other default resources are also removed - for example,
a qpair is no longer allocated and assigned per bdev
exposed by the nvme driver - the qpairs are only allocated
via I/O channels.  Similar principle also applies to the
aio driver.

ioat channels are no longer allocated and assigned to
lcores - they are dynamically allocated and assigned
to I/O channels when needed.  If no ioat channel is
available for an I/O channel, the copy engine framework
will revert to using memcpy/memset instead.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I99435a75fe792a2b91ab08f25962dfd407d6402f
parent fa29c709
Loading
Loading
Loading
Loading
+8 −22
Original line number Diff line number Diff line
@@ -98,15 +98,6 @@ struct spdk_bdev {
	/** generation value used by block device reset */
	uint32_t gencnt;

	/** Whether the poller is registered with the reactor */
	bool is_running;

	/** Which lcore the poller is running on */
	uint32_t lcore;

	/** Poller to submit IO and check completion */
	struct spdk_poller *poller;

	/** True if another blockdev or a LUN is using this device */
	bool claimed;

@@ -134,13 +125,6 @@ struct spdk_bdev_fn_table {
	/** Destroy the backend block device object */
	int (*destruct)(struct spdk_bdev *bdev);

	/**
	 * Poll the backend for I/O waiting to be completed.
	 *
	 * Optional; if the bdev does not have any periodic work to do, this pointer can be NULL.
	 */
	int (*check_io)(struct spdk_bdev *bdev);

	/** Process the IO. */
	void (*submit_request)(struct spdk_bdev_io *);

@@ -193,6 +177,9 @@ struct spdk_bdev_io {
	/** The block device that this I/O belongs to. */
	struct spdk_bdev *bdev;

	/** The I/O channel to submit this I/O on. */
	struct spdk_io_channel *ch;

	/** Enumerated value representing the I/O type. */
	enum spdk_bdev_io_type type;

@@ -289,25 +276,24 @@ struct spdk_bdev *spdk_bdev_next(struct spdk_bdev *prev);

bool spdk_bdev_io_type_supported(struct spdk_bdev *bdev, enum spdk_bdev_io_type io_type);

struct spdk_bdev_io *spdk_bdev_read(struct spdk_bdev *bdev,
struct spdk_bdev_io *spdk_bdev_read(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
				    void *buf, uint64_t offset, uint64_t nbytes,
				    spdk_bdev_io_completion_cb cb, void *cb_arg);
struct spdk_bdev_io *spdk_bdev_write(struct spdk_bdev *bdev,
struct spdk_bdev_io *spdk_bdev_write(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
				     void *buf, uint64_t offset, uint64_t nbytes,
				     spdk_bdev_io_completion_cb cb, void *cb_arg);
struct spdk_bdev_io *spdk_bdev_writev(struct spdk_bdev *bdev,
struct spdk_bdev_io *spdk_bdev_writev(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
				      struct iovec *iov, int iovcnt,
				      uint64_t offset, uint64_t len,
				      spdk_bdev_io_completion_cb cb, void *cb_arg);
struct spdk_bdev_io *spdk_bdev_unmap(struct spdk_bdev *bdev,
struct spdk_bdev_io *spdk_bdev_unmap(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
				     struct spdk_scsi_unmap_bdesc *unmap_d,
				     uint16_t bdesc_count,
				     spdk_bdev_io_completion_cb cb, void *cb_arg);
struct spdk_bdev_io *spdk_bdev_flush(struct spdk_bdev *bdev,
struct spdk_bdev_io *spdk_bdev_flush(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
				     uint64_t offset, uint64_t length,
				     spdk_bdev_io_completion_cb cb, void *cb_arg);
int spdk_bdev_io_submit(struct spdk_bdev_io *bdev_io);
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);
+8 −8
Original line number Diff line number Diff line
@@ -45,17 +45,18 @@

typedef void (*copy_completion_cb)(void *ref, int status);

struct spdk_io_channel;

struct copy_task {
	copy_completion_cb	cb;
	uint8_t			offload_ctx[0];
};

struct spdk_copy_engine {
	int64_t	(*copy)(void *cb_arg, void *dst, void *src,
	int64_t	(*copy)(void *cb_arg, struct spdk_io_channel *ch, void *dst, void *src,
			uint64_t nbytes, copy_completion_cb cb);
	int64_t	(*fill)(void *cb_arg, void *dst, uint8_t fill,
	int64_t	(*fill)(void *cb_arg, struct spdk_io_channel *ch, void *dst, uint8_t fill,
			uint64_t nbytes, copy_completion_cb cb);
	void	(*check_io)(void);
	struct spdk_io_channel *(*get_io_channel)(uint32_t priority);
};

@@ -86,11 +87,10 @@ struct spdk_copy_module_if {

void spdk_copy_engine_register(struct spdk_copy_engine *copy_engine);
struct spdk_io_channel *spdk_copy_engine_get_io_channel(uint32_t priority);
int64_t spdk_copy_submit(struct copy_task *copy_req, void *dst, void *src,
			 uint64_t nbytes, copy_completion_cb cb);
int64_t spdk_copy_submit_fill(struct copy_task *copy_req, void *dst, uint8_t fill,
			      uint64_t nbytes, copy_completion_cb cb);
int spdk_copy_check_io(void);
int64_t spdk_copy_submit(struct copy_task *copy_req, struct spdk_io_channel *ch, void *dst,
			 void *src, uint64_t nbytes, copy_completion_cb cb);
int64_t spdk_copy_submit_fill(struct copy_task *copy_req, struct spdk_io_channel *ch, void *dst,
			      uint8_t fill, uint64_t nbytes, copy_completion_cb cb);
int spdk_copy_module_get_max_ctx_size(void);
void spdk_copy_module_list_add(struct spdk_copy_module_if *copy_module);

+1 −0
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@ struct spdk_scsi_task {
	uint8_t				function; /* task mgmt function */
	uint8_t				response; /* task mgmt response */
	struct spdk_scsi_lun		*lun;
	struct spdk_io_channel		*ch;
	struct spdk_scsi_port		*target_port;
	struct spdk_scsi_port		*initiator_port;
	spdk_event_t			cb_event;
+10 −23
Original line number Diff line number Diff line
@@ -82,8 +82,6 @@ blockdev_aio_close(struct file_disk *disk)
{
	int rc;

	io_destroy(disk->ch.io_ctx);

	if (disk->fd == -1) {
		return 0;
	}
@@ -100,10 +98,11 @@ blockdev_aio_close(struct file_disk *disk)
}

static int64_t
blockdev_aio_read(struct file_disk *fdisk, struct blockdev_aio_task *aio_task,
		  void *buf, uint64_t nbytes, off_t offset)
blockdev_aio_read(struct file_disk *fdisk, struct spdk_io_channel *ch,
		  struct blockdev_aio_task *aio_task, void *buf, uint64_t nbytes, off_t offset)
{
	struct iocb *iocb = &aio_task->iocb;
	struct blockdev_aio_io_channel *aio_ch = spdk_io_channel_get_ctx(ch);
	int rc;

	iocb->aio_fildes = fdisk->fd;
@@ -118,7 +117,7 @@ blockdev_aio_read(struct file_disk *fdisk, struct blockdev_aio_task *aio_task,
	SPDK_TRACELOG(SPDK_TRACE_AIO, "read from %p of size %lu to off: %#lx\n",
		      buf, nbytes, offset);

	rc = io_submit(fdisk->ch.io_ctx, 1, &iocb);
	rc = io_submit(aio_ch->io_ctx, 1, &iocb);
	if (rc < 0) {
		SPDK_ERRLOG("%s: io_submit returned %d\n", __func__, rc);
		return -1;
@@ -128,10 +127,12 @@ blockdev_aio_read(struct file_disk *fdisk, struct blockdev_aio_task *aio_task,
}

static int64_t
blockdev_aio_writev(struct file_disk *fdisk, struct blockdev_aio_task *aio_task,
blockdev_aio_writev(struct file_disk *fdisk, struct spdk_io_channel *ch,
		    struct blockdev_aio_task *aio_task,
		    struct iovec *iov, int iovcnt, size_t len, off_t offset)
{
	struct iocb *iocb = &aio_task->iocb;
	struct blockdev_aio_io_channel *aio_ch = spdk_io_channel_get_ctx(ch);
	int rc;

	iocb->aio_fildes = fdisk->fd;
@@ -146,7 +147,7 @@ blockdev_aio_writev(struct file_disk *fdisk, struct blockdev_aio_task *aio_task,
	SPDK_TRACELOG(SPDK_TRACE_AIO, "write %d iovs size %lu from off: %#lx\n",
		      iovcnt, len, offset);

	rc = io_submit(fdisk->ch.io_ctx, 1, &iocb);
	rc = io_submit(aio_ch->io_ctx, 1, &iocb);
	if (rc < 0) {
		SPDK_ERRLOG("%s: io_submit returned %d\n", __func__, rc);
		return -1;
@@ -232,15 +233,6 @@ blockdev_aio_poll(void *arg)
	}
}

static int
blockdev_aio_check_io(struct spdk_bdev *bdev)
{
	struct file_disk *fdisk = (struct file_disk *)bdev;

	blockdev_aio_poll(&fdisk->ch);
	return 0;
}

static int
blockdev_aio_reset(struct file_disk *fdisk, struct blockdev_aio_task *aio_task)
{
@@ -254,6 +246,7 @@ static void blockdev_aio_get_rbuf_cb(struct spdk_bdev_io *bdev_io)
	int ret = 0;

	ret = blockdev_aio_read((struct file_disk *)bdev_io->ctx,
				bdev_io->ch,
				(struct blockdev_aio_task *)bdev_io->driver_ctx,
				bdev_io->u.read.buf,
				bdev_io->u.read.nbytes,
@@ -273,6 +266,7 @@ static int _blockdev_aio_submit_request(struct spdk_bdev_io *bdev_io)

	case SPDK_BDEV_IO_TYPE_WRITE:
		return blockdev_aio_writev((struct file_disk *)bdev_io->ctx,
					   bdev_io->ch,
					   (struct blockdev_aio_task *)bdev_io->driver_ctx,
					   bdev_io->u.write.iovs,
					   bdev_io->u.write.iovcnt,
@@ -347,7 +341,6 @@ blockdev_aio_get_io_channel(struct spdk_bdev *bdev, uint32_t 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,
@@ -357,8 +350,6 @@ static void aio_free_disk(struct file_disk *fdisk)
{
	if (fdisk == NULL)
		return;
	if (fdisk->ch.events != NULL)
		free(fdisk->ch.events);
	free(fdisk);
}

@@ -393,10 +384,6 @@ create_aio_disk(char *fname)
	fdisk->disk.ctxt = fdisk;

	fdisk->disk.fn_table = &aio_fn_table;
	if (blockdev_aio_initialize_io_channel(&fdisk->ch) != 0) {
		goto error_return;
	}

	g_blockdev_count++;

	spdk_io_device_register(&fdisk->disk, blockdev_aio_create_cb, blockdev_aio_destroy_cb,
+0 −2
Original line number Diff line number Diff line
@@ -62,8 +62,6 @@ struct file_disk {
	char			disk_name[SPDK_BDEV_MAX_NAME_LENGTH];
	uint64_t		size;

	struct blockdev_aio_io_channel	ch;

	/**
	 * For storing I/O that were completed synchronously, and will be
	 *   completed during next check_io call.
Loading