Commit 3415ce12 authored by Ben Walker's avatar Ben Walker Committed by Jim Harris
Browse files

bdev: Pass correct channel to bdev modules



Change-Id: I38911e70303f66f479c1495d4dbe02b2205cab8a
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 6d3a4cd2
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -168,7 +168,6 @@ enum spdk_bdev_reset_type {
typedef void (*spdk_bdev_io_completion_cb)(struct spdk_bdev_io *bdev_io,
		enum spdk_bdev_io_status status,
		void *cb_arg);
typedef void (*spdk_bdev_io_get_rbuf_cb)(struct spdk_bdev_io *bdev_io);

struct spdk_bdev *spdk_bdev_get_by_name(const char *bdev_name);
void spdk_bdev_unregister(struct spdk_bdev *bdev);
+5 −3
Original line number Diff line number Diff line
@@ -127,7 +127,7 @@ struct spdk_bdev_fn_table {
	int (*destruct)(void *ctx);

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

	/** Check if the block device supports a specific I/O type. */
	bool (*io_type_supported)(void *ctx, enum spdk_bdev_io_type);
@@ -145,6 +145,8 @@ struct spdk_bdev_fn_table {
	int (*dump_config_json)(void *ctx, struct spdk_json_write_ctx *w);
};

typedef void (*spdk_bdev_io_get_rbuf_cb)(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io);

struct spdk_bdev_io {
	/** Pointer to scratch area reserved for use by the driver consuming this spdk_bdev_io. */
	void *ctx;
@@ -152,8 +154,8 @@ 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;
	/** The bdev I/O channel that this was submitted on. */
	struct spdk_bdev_channel *ch;

	/** Generation value for each I/O. */
	uint32_t gencnt;
+6 −6
Original line number Diff line number Diff line
@@ -224,10 +224,10 @@ blockdev_aio_reset(struct file_disk *fdisk, struct blockdev_aio_task *aio_task)
	spdk_bdev_io_complete(spdk_bdev_io_from_ctx(aio_task), SPDK_BDEV_IO_STATUS_SUCCESS);
}

static void blockdev_aio_get_rbuf_cb(struct spdk_bdev_io *bdev_io)
static void blockdev_aio_get_rbuf_cb(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
{
	blockdev_aio_readv((struct file_disk *)bdev_io->ctx,
			   bdev_io->ch,
			   ch,
			   (struct blockdev_aio_task *)bdev_io->driver_ctx,
			   bdev_io->u.read.iovs,
			   bdev_io->u.read.iovcnt,
@@ -235,7 +235,7 @@ static void blockdev_aio_get_rbuf_cb(struct spdk_bdev_io *bdev_io)
			   bdev_io->u.read.offset);
}

static int _blockdev_aio_submit_request(struct spdk_bdev_io *bdev_io)
static int _blockdev_aio_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
{
	switch (bdev_io->type) {
	case SPDK_BDEV_IO_TYPE_READ:
@@ -244,7 +244,7 @@ static int _blockdev_aio_submit_request(struct spdk_bdev_io *bdev_io)

	case SPDK_BDEV_IO_TYPE_WRITE:
		blockdev_aio_writev((struct file_disk *)bdev_io->ctx,
				    bdev_io->ch,
				    ch,
				    (struct blockdev_aio_task *)bdev_io->driver_ctx,
				    bdev_io->u.write.iovs,
				    bdev_io->u.write.iovcnt,
@@ -267,9 +267,9 @@ static int _blockdev_aio_submit_request(struct spdk_bdev_io *bdev_io)
	}
}

static void blockdev_aio_submit_request(struct spdk_bdev_io *bdev_io)
static void blockdev_aio_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
{
	if (_blockdev_aio_submit_request(bdev_io) < 0) {
	if (_blockdev_aio_submit_request(ch, bdev_io) < 0) {
		spdk_bdev_io_complete(bdev_io, SPDK_BDEV_IO_STATUS_FAILED);
	}
}
+16 −9
Original line number Diff line number Diff line
@@ -126,7 +126,7 @@ spdk_bdev_io_set_rbuf(struct spdk_bdev_io *bdev_io, void *buf)
	bdev_io->u.read.iovs[0].iov_base = (void *)((unsigned long)((char *)buf + 512) & ~511UL);
	bdev_io->u.read.iovs[0].iov_len = bdev_io->u.read.len;
	bdev_io->u.read.put_rbuf = true;
	bdev_io->get_rbuf_cb(bdev_io);
	bdev_io->get_rbuf_cb(bdev_io->ch->channel, bdev_io);
}

static void
@@ -419,12 +419,19 @@ spdk_bdev_cleanup_pending_rbuf_io(struct spdk_bdev *bdev)
static void
__submit_request(struct spdk_bdev *bdev, struct spdk_bdev_io *bdev_io)
{
	struct spdk_io_channel *ch;

	assert(bdev_io->status == SPDK_BDEV_IO_STATUS_PENDING);

	if (bdev_io->type == SPDK_BDEV_IO_TYPE_RESET) {
		spdk_bdev_cleanup_pending_rbuf_io(bdev);
		ch = NULL;
	} else {
		ch = bdev_io->ch->channel;
	}

	bdev_io->in_submit_request = true;
	bdev->fn_table->submit_request(bdev_io);
	bdev->fn_table->submit_request(ch, bdev_io);
	bdev_io->in_submit_request = false;
}

@@ -586,7 +593,7 @@ spdk_bdev_read(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
		return NULL;
	}

	bdev_io->ch = channel->channel;
	bdev_io->ch = channel;
	bdev_io->type = SPDK_BDEV_IO_TYPE_READ;
	bdev_io->u.read.iov.iov_base = buf;
	bdev_io->u.read.iov.iov_len = nbytes;
@@ -627,7 +634,7 @@ spdk_bdev_readv(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
		return NULL;
	}

	bdev_io->ch = channel->channel;
	bdev_io->ch = channel;
	bdev_io->type = SPDK_BDEV_IO_TYPE_READ;
	bdev_io->u.read.iovs = iov;
	bdev_io->u.read.iovcnt = iovcnt;
@@ -665,7 +672,7 @@ spdk_bdev_write(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
		return NULL;
	}

	bdev_io->ch = channel->channel;
	bdev_io->ch = channel;
	bdev_io->type = SPDK_BDEV_IO_TYPE_WRITE;
	bdev_io->u.write.iov.iov_base = buf;
	bdev_io->u.write.iov.iov_len = nbytes;
@@ -705,7 +712,7 @@ spdk_bdev_writev(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
		return NULL;
	}

	bdev_io->ch = channel->channel;
	bdev_io->ch = channel;
	bdev_io->type = SPDK_BDEV_IO_TYPE_WRITE;
	bdev_io->u.write.iovs = iov;
	bdev_io->u.write.iovcnt = iovcnt;
@@ -750,7 +757,7 @@ spdk_bdev_unmap(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
		return NULL;
	}

	bdev_io->ch = channel->channel;
	bdev_io->ch = channel;
	bdev_io->type = SPDK_BDEV_IO_TYPE_UNMAP;
	bdev_io->u.unmap.unmap_bdesc = unmap_d;
	bdev_io->u.unmap.bdesc_count = bdesc_count;
@@ -781,7 +788,7 @@ spdk_bdev_flush(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
		return NULL;
	}

	bdev_io->ch = channel->channel;
	bdev_io->ch = channel;
	bdev_io->type = SPDK_BDEV_IO_TYPE_FLUSH;
	bdev_io->u.flush.offset = offset;
	bdev_io->u.flush.length = length;
@@ -1098,7 +1105,7 @@ spdk_bdev_io_get_rbuf(struct spdk_bdev_io *bdev_io, spdk_bdev_io_get_rbuf_cb cb)
		bdev_io->get_rbuf_cb = cb;
		_spdk_bdev_io_get_rbuf(bdev_io);
	} else {
		cb(bdev_io);
		cb(bdev_io->ch->channel, bdev_io);
	}
}

+6 −6
Original line number Diff line number Diff line
@@ -270,7 +270,7 @@ blockdev_malloc_reset(struct malloc_disk *mdisk, struct malloc_task *task)
	return 0;
}

static int _blockdev_malloc_submit_request(struct spdk_bdev_io *bdev_io)
static int _blockdev_malloc_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
{
	switch (bdev_io->type) {
	case SPDK_BDEV_IO_TYPE_READ:
@@ -287,7 +287,7 @@ static int _blockdev_malloc_submit_request(struct spdk_bdev_io *bdev_io)
		}

		blockdev_malloc_readv((struct malloc_disk *)bdev_io->ctx,
				      bdev_io->ch,
				      ch,
				      (struct malloc_task *)bdev_io->driver_ctx,
				      bdev_io->u.read.iovs,
				      bdev_io->u.read.iovcnt,
@@ -297,7 +297,7 @@ static int _blockdev_malloc_submit_request(struct spdk_bdev_io *bdev_io)

	case SPDK_BDEV_IO_TYPE_WRITE:
		blockdev_malloc_writev((struct malloc_disk *)bdev_io->ctx,
				       bdev_io->ch,
				       ch,
				       (struct malloc_task *)bdev_io->driver_ctx,
				       bdev_io->u.write.iovs,
				       bdev_io->u.write.iovcnt,
@@ -317,7 +317,7 @@ static int _blockdev_malloc_submit_request(struct spdk_bdev_io *bdev_io)

	case SPDK_BDEV_IO_TYPE_UNMAP:
		return blockdev_malloc_unmap((struct malloc_disk *)bdev_io->ctx,
					     bdev_io->ch,
					     ch,
					     (struct malloc_task *)bdev_io->driver_ctx,
					     bdev_io->u.unmap.unmap_bdesc,
					     bdev_io->u.unmap.bdesc_count);
@@ -327,9 +327,9 @@ static int _blockdev_malloc_submit_request(struct spdk_bdev_io *bdev_io)
	return 0;
}

static void blockdev_malloc_submit_request(struct spdk_bdev_io *bdev_io)
static void blockdev_malloc_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
{
	if (_blockdev_malloc_submit_request(bdev_io) < 0) {
	if (_blockdev_malloc_submit_request(ch, bdev_io) < 0) {
		spdk_bdev_io_complete(bdev_io, SPDK_BDEV_IO_STATUS_FAILED);
	}
}
Loading