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 <james.r.harris@intel.com> Change-Id: I3e0dfddde2de70caec479bf1b6703f01c9d7b3a2 Reviewed-on: https://review.gerrithub.io/431375 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Liang Yan <liang.z.yan@intel.com> Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
parent
81c0e62feb
commit
13e69db5c0
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user