From 4a93f5d2ad8f7131c8eee6ca6b8b526280eab707 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Mon, 19 Feb 2018 15:28:16 -0700 Subject: [PATCH] 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 Change-Id: Ic8ea24c64a782e54d18b6241e36f56dbbbb5f1e7 Reviewed-on: https://review.gerrithub.io/400555 Reviewed-by: Daniel Verkamp Tested-by: SPDK Automated Test System Reviewed-by: Changpeng Liu --- lib/bdev/aio/bdev_aio.c | 8 ++++---- lib/bdev/bdev.c | 10 +++++----- lib/bdev/rbd/bdev_rbd.c | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/bdev/aio/bdev_aio.c b/lib/bdev/aio/bdev_aio.c index 11c8f34ae..3554d9e17 100644 --- a/lib/bdev/aio/bdev_aio.c +++ b/lib/bdev/aio/bdev_aio.c @@ -274,7 +274,7 @@ bdev_aio_reset_retry_timer(void *arg) spdk_poller_unregister(&fdisk->reset_retry_timer); } - spdk_for_each_channel(&fdisk->fd, + spdk_for_each_channel(fdisk, _bdev_aio_get_io_inflight, fdisk, _bdev_aio_get_io_inflight_done); @@ -381,7 +381,7 @@ bdev_aio_get_io_channel(void *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; - 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)); rc = spdk_bdev_register(&fdisk->disk); if (rc) { - spdk_io_device_unregister(&fdisk->fd, NULL); + spdk_io_device_unregister(fdisk, NULL); goto error_return; } diff --git a/lib/bdev/bdev.c b/lib/bdev/bdev.c index c41296d00..b6309b9ae 100644 --- a/lib/bdev/bdev.c +++ b/lib/bdev/bdev.c @@ -2382,7 +2382,7 @@ spdk_bdev_part_free(struct spdk_bdev_part *part) assert(part->base); base = part->base; - spdk_io_device_unregister(&part->base, NULL); + spdk_io_device_unregister(part, NULL); TAILQ_REMOVE(base->tailq, part, tailq); free(part->bdev.name); free(part); @@ -2418,7 +2418,7 @@ spdk_bdev_part_get_io_channel(void *_part) { struct spdk_bdev_part *part = _part; - return spdk_get_io_channel(&part->base); + return spdk_get_io_channel(part); } static void @@ -2518,7 +2518,7 @@ spdk_bdev_part_submit_request(struct spdk_bdev_part_channel *ch, struct spdk_bde static int 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; ch->part = part; @@ -2537,7 +2537,7 @@ spdk_bdev_part_channel_create_cb(void *io_device, void *ctx_buf) static void 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; 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; } - 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, base->channel_size); spdk_vbdev_register(&part->bdev, &base->bdev, 1); diff --git a/lib/bdev/rbd/bdev_rbd.c b/lib/bdev/rbd/bdev_rbd.c index ec872b2b5..1329afeee 100644 --- a/lib/bdev/rbd/bdev_rbd.c +++ b/lib/bdev/rbd/bdev_rbd.c @@ -384,7 +384,7 @@ bdev_rbd_create_cb(void *io_device, void *ctx_buf) struct bdev_rbd_io_channel *ch = ctx_buf; int ret; - ch->disk = (struct bdev_rbd *)((uintptr_t)io_device - offsetof(struct bdev_rbd, info)); + ch->disk = io_device; ch->image = NULL; ch->io_ctx = NULL; ch->pfd.fd = -1; @@ -437,7 +437,7 @@ bdev_rbd_get_io_channel(void *ctx) { struct bdev_rbd *rbd_bdev = ctx; - return spdk_get_io_channel(&rbd_bdev->info); + return spdk_get_io_channel(rbd_bdev); } 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_io_device_register(&rbd->info, bdev_rbd_create_cb, + spdk_io_device_register(rbd, bdev_rbd_create_cb, bdev_rbd_destroy_cb, sizeof(struct bdev_rbd_io_channel)); ret = spdk_bdev_register(&rbd->disk); if (ret) { - spdk_io_device_unregister(&rbd->info, NULL); + spdk_io_device_unregister(rbd, NULL); bdev_rbd_free(rbd); return NULL; }