bdev: use simpler io_device handlers where possible

With recent update to bdev.c for its io_device_register
handle for new bdevs, several modules can now just use
their respective structures defining each bdev rather
than picking a more complicated one.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Ic8ea24c64a782e54d18b6241e36f56dbbbb5f1e7

Reviewed-on: https://review.gerrithub.io/400555
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
Jim Harris 2018-02-19 15:28:16 -07:00
parent 2db06132b0
commit 4a93f5d2ad
3 changed files with 13 additions and 13 deletions

View File

@ -274,7 +274,7 @@ bdev_aio_reset_retry_timer(void *arg)
spdk_poller_unregister(&fdisk->reset_retry_timer); spdk_poller_unregister(&fdisk->reset_retry_timer);
} }
spdk_for_each_channel(&fdisk->fd, spdk_for_each_channel(fdisk,
_bdev_aio_get_io_inflight, _bdev_aio_get_io_inflight,
fdisk, fdisk,
_bdev_aio_get_io_inflight_done); _bdev_aio_get_io_inflight_done);
@ -381,7 +381,7 @@ bdev_aio_get_io_channel(void *ctx)
{ {
struct file_disk *fdisk = ctx; struct file_disk *fdisk = ctx;
return spdk_get_io_channel(&fdisk->fd); return spdk_get_io_channel(fdisk);
} }
@ -501,11 +501,11 @@ create_aio_disk(const char *name, const char *filename, uint32_t block_size)
fdisk->disk.fn_table = &aio_fn_table; fdisk->disk.fn_table = &aio_fn_table;
spdk_io_device_register(&fdisk->fd, bdev_aio_create_cb, bdev_aio_destroy_cb, spdk_io_device_register(fdisk, bdev_aio_create_cb, bdev_aio_destroy_cb,
sizeof(struct bdev_aio_io_channel)); sizeof(struct bdev_aio_io_channel));
rc = spdk_bdev_register(&fdisk->disk); rc = spdk_bdev_register(&fdisk->disk);
if (rc) { if (rc) {
spdk_io_device_unregister(&fdisk->fd, NULL); spdk_io_device_unregister(fdisk, NULL);
goto error_return; goto error_return;
} }

View File

@ -2382,7 +2382,7 @@ spdk_bdev_part_free(struct spdk_bdev_part *part)
assert(part->base); assert(part->base);
base = part->base; base = part->base;
spdk_io_device_unregister(&part->base, NULL); spdk_io_device_unregister(part, NULL);
TAILQ_REMOVE(base->tailq, part, tailq); TAILQ_REMOVE(base->tailq, part, tailq);
free(part->bdev.name); free(part->bdev.name);
free(part); free(part);
@ -2418,7 +2418,7 @@ spdk_bdev_part_get_io_channel(void *_part)
{ {
struct spdk_bdev_part *part = _part; struct spdk_bdev_part *part = _part;
return spdk_get_io_channel(&part->base); return spdk_get_io_channel(part);
} }
static void static void
@ -2518,7 +2518,7 @@ spdk_bdev_part_submit_request(struct spdk_bdev_part_channel *ch, struct spdk_bde
static int static int
spdk_bdev_part_channel_create_cb(void *io_device, void *ctx_buf) spdk_bdev_part_channel_create_cb(void *io_device, void *ctx_buf)
{ {
struct spdk_bdev_part *part = SPDK_CONTAINEROF(io_device, struct spdk_bdev_part, base); struct spdk_bdev_part *part = (struct spdk_bdev_part *)io_device;
struct spdk_bdev_part_channel *ch = ctx_buf; struct spdk_bdev_part_channel *ch = ctx_buf;
ch->part = part; ch->part = part;
@ -2537,7 +2537,7 @@ spdk_bdev_part_channel_create_cb(void *io_device, void *ctx_buf)
static void static void
spdk_bdev_part_channel_destroy_cb(void *io_device, void *ctx_buf) spdk_bdev_part_channel_destroy_cb(void *io_device, void *ctx_buf)
{ {
struct spdk_bdev_part *part = SPDK_CONTAINEROF(io_device, struct spdk_bdev_part, base); struct spdk_bdev_part *part = (struct spdk_bdev_part *)io_device;
struct spdk_bdev_part_channel *ch = ctx_buf; struct spdk_bdev_part_channel *ch = ctx_buf;
if (part->base->ch_destroy_cb) { if (part->base->ch_destroy_cb) {
@ -2613,7 +2613,7 @@ spdk_bdev_part_construct(struct spdk_bdev_part *part, struct spdk_bdev_part_base
base->claimed = true; base->claimed = true;
} }
spdk_io_device_register(&part->base, spdk_bdev_part_channel_create_cb, spdk_io_device_register(part, spdk_bdev_part_channel_create_cb,
spdk_bdev_part_channel_destroy_cb, spdk_bdev_part_channel_destroy_cb,
base->channel_size); base->channel_size);
spdk_vbdev_register(&part->bdev, &base->bdev, 1); spdk_vbdev_register(&part->bdev, &base->bdev, 1);

View File

@ -384,7 +384,7 @@ bdev_rbd_create_cb(void *io_device, void *ctx_buf)
struct bdev_rbd_io_channel *ch = ctx_buf; struct bdev_rbd_io_channel *ch = ctx_buf;
int ret; int ret;
ch->disk = (struct bdev_rbd *)((uintptr_t)io_device - offsetof(struct bdev_rbd, info)); ch->disk = io_device;
ch->image = NULL; ch->image = NULL;
ch->io_ctx = NULL; ch->io_ctx = NULL;
ch->pfd.fd = -1; ch->pfd.fd = -1;
@ -437,7 +437,7 @@ bdev_rbd_get_io_channel(void *ctx)
{ {
struct bdev_rbd *rbd_bdev = ctx; struct bdev_rbd *rbd_bdev = ctx;
return spdk_get_io_channel(&rbd_bdev->info); return spdk_get_io_channel(rbd_bdev);
} }
static int static int
@ -519,12 +519,12 @@ spdk_bdev_rbd_create(const char *pool_name, const char *rbd_name, uint32_t block
SPDK_NOTICELOG("Add %s rbd disk to lun\n", rbd->disk.name); SPDK_NOTICELOG("Add %s rbd disk to lun\n", rbd->disk.name);
spdk_io_device_register(&rbd->info, bdev_rbd_create_cb, spdk_io_device_register(rbd, bdev_rbd_create_cb,
bdev_rbd_destroy_cb, bdev_rbd_destroy_cb,
sizeof(struct bdev_rbd_io_channel)); sizeof(struct bdev_rbd_io_channel));
ret = spdk_bdev_register(&rbd->disk); ret = spdk_bdev_register(&rbd->disk);
if (ret) { if (ret) {
spdk_io_device_unregister(&rbd->info, NULL); spdk_io_device_unregister(rbd, NULL);
bdev_rbd_free(rbd); bdev_rbd_free(rbd);
return NULL; return NULL;
} }