scsi: fnic: use fnic_lock to guard fnic->state_flags
authorSatish Kharat <satishkh@cisco.com>
Tue, 15 Jan 2019 01:09:23 +0000 (17:09 -0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 23 Jan 2019 02:18:34 +0000 (21:18 -0500)
Need to use fnic_lock as well as host lock in that order to set state
flags.

[mkp: typos]
Signed-off-by: Satish Kharat <satishkh@cisco.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/fnic/fnic_scsi.c

index cafbcfb85bfa64e3f4440d4e0fec05c8d4d4e5a5..a49b0f36b2f883b7da263d1b5d674cb0e216e352 100644 (file)
@@ -180,20 +180,19 @@ void
 __fnic_set_state_flags(struct fnic *fnic, unsigned long st_flags,
                        unsigned long clearbits)
 {
-       struct Scsi_Host *host = fnic->lport->host;
-       int sh_locked = spin_is_locked(host->host_lock);
        unsigned long flags = 0;
+       unsigned long host_lock_flags = 0;
 
-       if (!sh_locked)
-               spin_lock_irqsave(host->host_lock, flags);
+       spin_lock_irqsave(&fnic->fnic_lock, flags);
+       spin_lock_irqsave(fnic->lport->host->host_lock, host_lock_flags);
 
        if (clearbits)
                fnic->state_flags &= ~st_flags;
        else
                fnic->state_flags |= st_flags;
 
-       if (!sh_locked)
-               spin_unlock_irqrestore(host->host_lock, flags);
+       spin_unlock_irqrestore(fnic->lport->host->host_lock, host_lock_flags);
+       spin_unlock_irqrestore(&fnic->fnic_lock, flags);
 
        return;
 }