Commit 9d73eed8 authored by Ben Walker's avatar Ben Walker Committed by Daniel Verkamp
Browse files

bdev: Consistently pass user context to fn_table calls



Some calls were passing bdev->ctxt, some calls just
bdev. In most of our implementations those are the
same pointer, but they aren't necessarily.

Change-Id: If2d19f9eef059aded10a917ffb270c1dc4a8dc41
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 4f9f191c
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -129,16 +129,16 @@ struct spdk_bdev_module_if {
 */
struct spdk_bdev_fn_table {
	/** Destroy the backend block device object */
	int (*destruct)(struct spdk_bdev *bdev);
	int (*destruct)(void *ctx);

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

	/** Check if the block device supports a specific I/O type. */
	bool (*io_type_supported)(struct spdk_bdev *bdev, enum spdk_bdev_io_type);
	bool (*io_type_supported)(void *ctx, 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);
	struct spdk_io_channel *(*get_io_channel)(void *ctx, uint32_t priority);

	/**
	 * Output driver-specific configuration to a JSON stream. Optional - may be NULL.
@@ -147,7 +147,7 @@ struct spdk_bdev_fn_table {
	 * driver should write a name (based on the driver name) followed by a JSON value
	 * (most likely another nested object).
	 */
	int (*dump_config_json)(struct spdk_bdev *bdev, struct spdk_json_write_ctx *w);
	int (*dump_config_json)(void *ctx, struct spdk_json_write_ctx *w);
};

void spdk_bdev_register(struct spdk_bdev *bdev);
+7 −5
Original line number Diff line number Diff line
@@ -160,9 +160,9 @@ blockdev_aio_flush(struct file_disk *fdisk, struct blockdev_aio_task *aio_task,
}

static int
blockdev_aio_destruct(struct spdk_bdev *bdev)
blockdev_aio_destruct(void *ctx)
{
	struct file_disk *fdisk = (struct file_disk *)bdev;
	struct file_disk *fdisk = ctx;
	int rc = 0;

	rc = blockdev_aio_close(fdisk);
@@ -281,7 +281,7 @@ static void blockdev_aio_submit_request(struct spdk_bdev_io *bdev_io)
}

static bool
blockdev_aio_io_type_supported(struct spdk_bdev *bdev, enum spdk_bdev_io_type io_type)
blockdev_aio_io_type_supported(void *ctx, enum spdk_bdev_io_type io_type)
{
	switch (io_type) {
	case SPDK_BDEV_IO_TYPE_READ:
@@ -320,9 +320,11 @@ blockdev_aio_destroy_cb(void *io_device, void *ctx_buf)
}

static struct spdk_io_channel *
blockdev_aio_get_io_channel(struct spdk_bdev *bdev, uint32_t priority)
blockdev_aio_get_io_channel(void *ctx, uint32_t priority)
{
	return spdk_get_io_channel(bdev, priority, false, NULL);
	struct file_disk *fdisk = ctx;

	return spdk_get_io_channel(&fdisk->disk, priority, false, NULL);
}

static const struct spdk_bdev_fn_table aio_fn_table = {
+1 −1
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ struct blockdev_aio_io_channel {
};

struct file_disk {
	struct spdk_bdev	disk;	/* this must be first element */
	struct spdk_bdev	disk;
	const char		*file;
	int			fd;
	char			disk_name[SPDK_BDEV_MAX_NAME_LENGTH];
+3 −3
Original line number Diff line number Diff line
@@ -498,14 +498,14 @@ spdk_bdev_get_child_io(struct spdk_bdev_io *parent,
bool
spdk_bdev_io_type_supported(struct spdk_bdev *bdev, enum spdk_bdev_io_type io_type)
{
	return bdev->fn_table->io_type_supported(bdev, io_type);
	return bdev->fn_table->io_type_supported(bdev->ctxt, io_type);
}

int
spdk_bdev_dump_config_json(struct spdk_bdev *bdev, struct spdk_json_write_ctx *w)
{
	if (bdev->fn_table->dump_config_json) {
		return bdev->fn_table->dump_config_json(bdev, w);
		return bdev->fn_table->dump_config_json(bdev->ctxt, w);
	}

	return 0;
@@ -514,7 +514,7 @@ spdk_bdev_dump_config_json(struct spdk_bdev *bdev, struct spdk_json_write_ctx *w
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);
	return bdev->fn_table->get_io_channel(bdev->ctxt, priority);
}

static int
+5 −5
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@
#define MALLOC_MAX_UNMAP_BDESC	1

struct malloc_disk {
	struct spdk_bdev	disk;	/* this must be the first element */
	struct spdk_bdev	disk;
	void 			*malloc_buf;
	struct malloc_disk	*next;
};
@@ -126,9 +126,9 @@ blockdev_malloc_delete_from_list(struct malloc_disk *malloc_disk)
}

static int
blockdev_malloc_destruct(struct spdk_bdev *bdev)
blockdev_malloc_destruct(void *ctx)
{
	struct malloc_disk *malloc_disk = (struct malloc_disk *)bdev;
	struct malloc_disk *malloc_disk = ctx;
	blockdev_malloc_delete_from_list(malloc_disk);
	spdk_free(malloc_disk->malloc_buf);
	spdk_free(malloc_disk);
@@ -336,7 +336,7 @@ static void blockdev_malloc_submit_request(struct spdk_bdev_io *bdev_io)
}

static bool
blockdev_malloc_io_type_supported(struct spdk_bdev *bdev, enum spdk_bdev_io_type io_type)
blockdev_malloc_io_type_supported(void *ctx, enum spdk_bdev_io_type io_type)
{
	switch (io_type) {
	case SPDK_BDEV_IO_TYPE_READ:
@@ -352,7 +352,7 @@ 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)
blockdev_malloc_get_io_channel(void *ctx, uint32_t priority)
{
	return spdk_copy_engine_get_io_channel(priority);
}
Loading