Skip to content

Commit db19693

Browse files
Hiral ShahJames Bottomley
authored andcommitted
fnic: Use the local variable instead of I/O flag to acquire io_req_lock in fnic_queuecommand() to avoid deadloack
We added changes in fnic driver patch 1.6.0.16 to acquire io_req_lock in fnic_queuecommand() before issuing I/O so that io completion is serialized. But when releasing the lock we check for the I/O flag and this could be modified if IO abort occurs before I/O completion. In this case we wont release the lock and causes deadlock in some scenerios. Using the local variable to check the IO lock status will resolve the problem. Fixes: 41df7b0 Signed-off-by: Hiral Shah <[email protected]> Signed-off-by: Sesidhar Baddela <[email protected]> Signed-off-by: Anil Chintalapati <[email protected]> Reviewed-by: Martin K. Petersen <[email protected]> Cc: [email protected] Signed-off-by: James Bottomley <[email protected]>
1 parent 4f258a4 commit db19693

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

drivers/scsi/fnic/fnic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
#define DRV_NAME "fnic"
4141
#define DRV_DESCRIPTION "Cisco FCoE HBA Driver"
42-
#define DRV_VERSION "1.6.0.17"
42+
#define DRV_VERSION "1.6.0.17a"
4343
#define PFX DRV_NAME ": "
4444
#define DFX DRV_NAME "%d: "
4545

drivers/scsi/fnic/fnic_scsi.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, void (*done)(struct scsi_
425425
unsigned long ptr;
426426
struct fc_rport_priv *rdata;
427427
spinlock_t *io_lock = NULL;
428+
int io_lock_acquired = 0;
428429

429430
if (unlikely(fnic_chk_state_flags_locked(fnic, FNIC_FLAGS_IO_BLOCKED)))
430431
return SCSI_MLQUEUE_HOST_BUSY;
@@ -518,6 +519,7 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, void (*done)(struct scsi_
518519
spin_lock_irqsave(io_lock, flags);
519520

520521
/* initialize rest of io_req */
522+
io_lock_acquired = 1;
521523
io_req->port_id = rport->port_id;
522524
io_req->start_time = jiffies;
523525
CMD_STATE(sc) = FNIC_IOREQ_CMD_PENDING;
@@ -571,7 +573,7 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, void (*done)(struct scsi_
571573
(((u64)CMD_FLAGS(sc) >> 32) | CMD_STATE(sc)));
572574

573575
/* if only we issued IO, will we have the io lock */
574-
if (CMD_FLAGS(sc) & FNIC_IO_INITIALIZED)
576+
if (io_lock_acquired)
575577
spin_unlock_irqrestore(io_lock, flags);
576578

577579
atomic_dec(&fnic->in_flight);

0 commit comments

Comments
 (0)