lib/scsi: Close block device on the thread which opened it
All connections to a single LUN run on a single thread but this thread may not be the same as the one which opened the backed bdev. So hold pointer to the thread which opened the backed bdev to struct spdk_scsi_lun and use it when calling spdk_bdev_close(). All resource of LUN are accessed on a single thread after getting I/O channel, and so lock is not still necessary. Fixes issue #1024. Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: Ifc1e238d333afcde0cdf9e9b4af3b56ef65a4f7d Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/473002 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: yidong0635 <dongx.yi@intel.com>
This commit is contained in:
parent
9889ab2dc8
commit
7cef60b657
@ -233,19 +233,33 @@ spdk_scsi_lun_execute_tasks(struct spdk_scsi_lun *lun)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_scsi_lun_remove(void *arg)
|
||||
{
|
||||
struct spdk_scsi_lun *lun = (struct spdk_scsi_lun *)arg;
|
||||
|
||||
spdk_bdev_close(lun->bdev_desc);
|
||||
spdk_scsi_dev_delete_lun(lun->dev, lun);
|
||||
free(lun);
|
||||
}
|
||||
|
||||
static void
|
||||
scsi_lun_remove(struct spdk_scsi_lun *lun)
|
||||
{
|
||||
struct spdk_scsi_pr_registrant *reg, *tmp;
|
||||
struct spdk_thread *thread;
|
||||
|
||||
TAILQ_FOREACH_SAFE(reg, &lun->reg_head, link, tmp) {
|
||||
TAILQ_REMOVE(&lun->reg_head, reg, link);
|
||||
free(reg);
|
||||
}
|
||||
spdk_bdev_close(lun->bdev_desc);
|
||||
|
||||
spdk_scsi_dev_delete_lun(lun->dev, lun);
|
||||
free(lun);
|
||||
thread = spdk_get_thread();
|
||||
if (thread != lun->thread) {
|
||||
spdk_thread_send_msg(lun->thread, _scsi_lun_remove, lun);
|
||||
} else {
|
||||
_scsi_lun_remove(lun);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
@ -375,6 +389,8 @@ spdk_scsi_lun_construct(struct spdk_bdev *bdev,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
lun->thread = spdk_get_thread();
|
||||
|
||||
TAILQ_INIT(&lun->tasks);
|
||||
TAILQ_INIT(&lun->pending_tasks);
|
||||
TAILQ_INIT(&lun->mgmt_tasks);
|
||||
|
@ -117,6 +117,9 @@ struct spdk_scsi_lun {
|
||||
/** Descriptor for opened block device. */
|
||||
struct spdk_bdev_desc *bdev_desc;
|
||||
|
||||
/** The thread which opens this LUN. */
|
||||
struct spdk_thread *thread;
|
||||
|
||||
/** I/O channel for the bdev associated with this LUN. */
|
||||
struct spdk_io_channel *io_channel;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user