Revert "scsi: remove LUN I/O channel ref counting"
This reverts commit d3828a23ec
.
GitHub issue #202 reports that this causes a crash with two or more
iSCSI connections on the same LUN.
Change-Id: I9ffb85d393eb506aac9d176299a3b3bcf021a38c
Reviewed-on: https://review.gerrithub.io/379866
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
4f1ba029b3
commit
4affd37f2b
@ -373,8 +373,12 @@ spdk_scsi_lun_delete(const char *lun_name)
|
||||
int spdk_scsi_lun_allocate_io_channel(struct spdk_scsi_lun *lun)
|
||||
{
|
||||
if (lun->io_channel != NULL) {
|
||||
assert(spdk_io_channel_get_thread(lun->io_channel) == spdk_get_thread());
|
||||
return 0;
|
||||
if (pthread_self() == lun->thread_id) {
|
||||
lun->ref++;
|
||||
return 0;
|
||||
}
|
||||
SPDK_ERRLOG("io_channel already allocated for lun %s\n", lun->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
lun->lcore = spdk_env_get_current_core();
|
||||
@ -383,14 +387,19 @@ int spdk_scsi_lun_allocate_io_channel(struct spdk_scsi_lun *lun)
|
||||
if (lun->io_channel == NULL) {
|
||||
return -1;
|
||||
}
|
||||
lun->thread_id = pthread_self();
|
||||
lun->ref = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void spdk_scsi_lun_free_io_channel(struct spdk_scsi_lun *lun)
|
||||
{
|
||||
if (lun->io_channel != NULL) {
|
||||
spdk_put_io_channel(lun->io_channel);
|
||||
lun->io_channel = NULL;
|
||||
lun->ref--;
|
||||
if (lun->ref == 0) {
|
||||
spdk_put_io_channel(lun->io_channel);
|
||||
lun->io_channel = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,6 +87,14 @@ struct spdk_scsi_lun {
|
||||
/** I/O channel for the bdev associated with this LUN. */
|
||||
struct spdk_io_channel *io_channel;
|
||||
|
||||
/** Thread ID for the thread that allocated the I/O channel for this
|
||||
* LUN. All I/O to this LUN must be performed from this thread.
|
||||
*/
|
||||
pthread_t thread_id;
|
||||
|
||||
/** The reference number for this LUN, thus we can correctly free the io_channel */
|
||||
uint32_t ref;
|
||||
|
||||
/** Name for this LUN. */
|
||||
char name[SPDK_SCSI_LUN_MAX_NAME_LENGTH];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user