From 13e69db5c08b98d89bf24c0ad5d6345b1103e12b Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Tue, 30 Oct 2018 11:43:22 -0700 Subject: [PATCH] bdev/iscsi: attach poller to lun instead of channel There is no guarantee that the first io_channel created for a LUN will be the last one destroyed. So we need to attach the poller to the LUN, not the io_channel. While here, and related to this patch, remove the assert() that the last channel destroyed must be on the LUN's master thread. This assertion simply isn't true. Signed-off-by: Jim Harris Change-Id: I3e0dfddde2de70caec479bf1b6703f01c9d7b3a2 Reviewed-on: https://review.gerrithub.io/431375 Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Shuhei Matsumoto Reviewed-by: Liang Yan Chandler-Test-Pool: SPDK Automated Test System --- lib/bdev/iscsi/bdev_iscsi.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/lib/bdev/iscsi/bdev_iscsi.c b/lib/bdev/iscsi/bdev_iscsi.c index 528337f55..ae67a3f53 100644 --- a/lib/bdev/iscsi/bdev_iscsi.c +++ b/lib/bdev/iscsi/bdev_iscsi.c @@ -85,10 +85,10 @@ struct bdev_iscsi_lun { struct spdk_poller *no_master_ch_poller; struct spdk_thread *no_master_ch_poller_td; bool unmap_supported; + struct spdk_poller *poller; }; struct bdev_iscsi_io_channel { - struct spdk_poller *poller; struct bdev_iscsi_lun *lun; }; @@ -356,8 +356,9 @@ bdev_iscsi_reset(struct spdk_bdev_io *bdev_io) } static int -bdev_iscsi_poll_lun(struct bdev_iscsi_lun *lun) +bdev_iscsi_poll_lun(void *_lun) { + struct bdev_iscsi_lun *lun = _lun; struct pollfd pfd = {}; pfd.fd = iscsi_get_fd(lun->context); @@ -396,14 +397,6 @@ bdev_iscsi_no_master_ch_poll(void *arg) return rc; } -static int -bdev_iscsi_poll(void *arg) -{ - struct bdev_iscsi_io_channel *ch = arg; - - return bdev_iscsi_poll_lun(ch->lun); -} - static void bdev_iscsi_get_buf_cb(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io) { bdev_iscsi_readv((struct bdev_iscsi_lun *)bdev_io->bdev->ctxt, @@ -501,7 +494,7 @@ bdev_iscsi_create_cb(void *io_device, void *ctx_buf) assert(lun->master_td == NULL); lun->master_ch = ch; lun->master_td = spdk_get_thread(); - ch->poller = spdk_poller_register(bdev_iscsi_poll, ch, 0); + lun->poller = spdk_poller_register(bdev_iscsi_poll_lun, lun, 0); ch->lun = lun; } lun->ch_count++; @@ -513,7 +506,6 @@ bdev_iscsi_create_cb(void *io_device, void *ctx_buf) static void bdev_iscsi_destroy_cb(void *io_device, void *ctx_buf) { - struct bdev_iscsi_io_channel *io_channel = ctx_buf; struct bdev_iscsi_lun *lun = io_device; pthread_mutex_lock(&lun->mutex); @@ -521,11 +513,10 @@ bdev_iscsi_destroy_cb(void *io_device, void *ctx_buf) if (lun->ch_count == 0) { assert(lun->master_ch != NULL); assert(lun->master_td != NULL); - assert(lun->master_td == spdk_get_thread()); lun->master_ch = NULL; lun->master_td = NULL; - spdk_poller_unregister(&io_channel->poller); + spdk_poller_unregister(&lun->poller); } pthread_mutex_unlock(&lun->mutex); }