scsi: Use not pthread_self but spdk_get_thread for LUN affinity
spdk_thread is recommended to be used in SPDK library. Change-Id: I5b75f390ddb2069e1266a3fc4f28732b281df725 Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-on: https://review.gerrithub.io/416482 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ziye Yang <optimistyzy@gmail.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
1e1e0dd70c
commit
322e50468c
@ -302,7 +302,7 @@ spdk_scsi_lun_destruct(struct spdk_scsi_lun *lun)
|
||||
int spdk_scsi_lun_allocate_io_channel(struct spdk_scsi_lun *lun)
|
||||
{
|
||||
if (lun->io_channel != NULL) {
|
||||
if (pthread_self() == lun->thread_id) {
|
||||
if (spdk_get_thread() == spdk_io_channel_get_thread(lun->io_channel)) {
|
||||
lun->ref++;
|
||||
return 0;
|
||||
}
|
||||
@ -315,19 +315,25 @@ 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) {
|
||||
lun->ref--;
|
||||
if (lun->ref == 0) {
|
||||
spdk_put_io_channel(lun->io_channel);
|
||||
lun->io_channel = NULL;
|
||||
}
|
||||
if (lun->io_channel == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (spdk_get_thread() != spdk_io_channel_get_thread(lun->io_channel)) {
|
||||
SPDK_ERRLOG("io_channel was freed by different thread\n");
|
||||
return;
|
||||
}
|
||||
|
||||
lun->ref--;
|
||||
if (lun->ref == 0) {
|
||||
spdk_put_io_channel(lun->io_channel);
|
||||
lun->io_channel = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,11 +88,6 @@ 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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user