]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob
3abea8eee1858a81046df84accdb066ee9a7e269
[thirdparty/kernel/stable-queue.git] /
1 From db196935d9562abec4510f48d887bc1f1e054fcf Mon Sep 17 00:00:00 2001
2 From: Hiral Shah <hishah@cisco.com>
3 Date: Tue, 14 Jul 2015 07:08:57 -0700
4 Subject: fnic: Use the local variable instead of I/O flag to acquire io_req_lock in fnic_queuecommand() to avoid deadloack
5
6 From: Hiral Shah <hishah@cisco.com>
7
8 commit db196935d9562abec4510f48d887bc1f1e054fcf upstream.
9
10 We added changes in fnic driver patch 1.6.0.16 to acquire
11 io_req_lock in fnic_queuecommand() before issuing I/O so that io completion
12 is serialized. But when releasing the lock we check for the I/O flag and
13 this could be modified if IO abort occurs before I/O completion. In this case
14 we wont release the lock and causes deadlock in some scenerios. Using the
15 local variable to check the IO lock status will resolve the problem.
16
17 Fixes: 41df7b02db82cf6c14f094757bac3830d10a827f
18 Signed-off-by: Hiral Shah <hishah@cisco.com>
19 Signed-off-by: Sesidhar Baddela <sebaddel@cisco.com>
20 Signed-off-by: Anil Chintalapati <achintal@cisco.com>
21 Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
22 Signed-off-by: James Bottomley <JBottomley@Odin.com>
23 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
24
25 ---
26 drivers/scsi/fnic/fnic.h | 2 +-
27 drivers/scsi/fnic/fnic_scsi.c | 4 +++-
28 2 files changed, 4 insertions(+), 2 deletions(-)
29
30 --- a/drivers/scsi/fnic/fnic.h
31 +++ b/drivers/scsi/fnic/fnic.h
32 @@ -39,7 +39,7 @@
33
34 #define DRV_NAME "fnic"
35 #define DRV_DESCRIPTION "Cisco FCoE HBA Driver"
36 -#define DRV_VERSION "1.6.0.17"
37 +#define DRV_VERSION "1.6.0.17a"
38 #define PFX DRV_NAME ": "
39 #define DFX DRV_NAME "%d: "
40
41 --- a/drivers/scsi/fnic/fnic_scsi.c
42 +++ b/drivers/scsi/fnic/fnic_scsi.c
43 @@ -425,6 +425,7 @@ static int fnic_queuecommand_lck(struct
44 unsigned long ptr;
45 struct fc_rport_priv *rdata;
46 spinlock_t *io_lock = NULL;
47 + int io_lock_acquired = 0;
48
49 if (unlikely(fnic_chk_state_flags_locked(fnic, FNIC_FLAGS_IO_BLOCKED)))
50 return SCSI_MLQUEUE_HOST_BUSY;
51 @@ -518,6 +519,7 @@ static int fnic_queuecommand_lck(struct
52 spin_lock_irqsave(io_lock, flags);
53
54 /* initialize rest of io_req */
55 + io_lock_acquired = 1;
56 io_req->port_id = rport->port_id;
57 io_req->start_time = jiffies;
58 CMD_STATE(sc) = FNIC_IOREQ_CMD_PENDING;
59 @@ -571,7 +573,7 @@ out:
60 (((u64)CMD_FLAGS(sc) >> 32) | CMD_STATE(sc)));
61
62 /* if only we issued IO, will we have the io lock */
63 - if (CMD_FLAGS(sc) & FNIC_IO_INITIALIZED)
64 + if (io_lock_acquired)
65 spin_unlock_irqrestore(io_lock, flags);
66
67 atomic_dec(&fnic->in_flight);