Skip to content

Commit 1c4e395

Browse files
committed
Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Pull SCSI fixes from James Bottomley: "Nine changes, eight to drivers (qla2xxx, hpsa, lpfc, alua, ch, 53c710[x2], target) and one core change that tries to close a race between sysfs delete and module removal" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: scsi: lpfc: remove left-over BUILD_NVME defines scsi: core: try to get module before removing device scsi: hpsa: add missing hunks in reset-patch scsi: target: core: Do not overwrite CDB byte 1 scsi: ch: Make it possible to open a ch device multiple times again scsi: fix kconfig dependency warning related to 53C700_LE_ON_BE scsi: sni_53c710: fix compilation error scsi: scsi_dh_alua: handle RTPG sense code correctly during state transitions scsi: qla2xxx: fix a potential NULL pointer dereference
2 parents b4b61b2 + 1052b41 commit 1c4e395

File tree

10 files changed

+36
-36
lines changed

10 files changed

+36
-36
lines changed

drivers/scsi/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ config SCSI_SNI_53C710
898898

899899
config 53C700_LE_ON_BE
900900
bool
901-
depends on SCSI_LASI700
901+
depends on SCSI_LASI700 || SCSI_SNI_53C710
902902
default y
903903

904904
config SCSI_STEX

drivers/scsi/ch.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,6 @@ ch_release(struct inode *inode, struct file *file)
579579
scsi_changer *ch = file->private_data;
580580

581581
scsi_device_put(ch->device);
582-
ch->device = NULL;
583582
file->private_data = NULL;
584583
kref_put(&ch->ref, ch_destroy);
585584
return 0;

drivers/scsi/device_handler/scsi_dh_alua.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,7 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)
512512
unsigned int tpg_desc_tbl_off;
513513
unsigned char orig_transition_tmo;
514514
unsigned long flags;
515+
bool transitioning_sense = false;
515516

516517
if (!pg->expiry) {
517518
unsigned long transition_tmo = ALUA_FAILOVER_TIMEOUT * HZ;
@@ -572,13 +573,19 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)
572573
goto retry;
573574
}
574575
/*
575-
* Retry on ALUA state transition or if any
576-
* UNIT ATTENTION occurred.
576+
* If the array returns with 'ALUA state transition'
577+
* sense code here it cannot return RTPG data during
578+
* transition. So set the state to 'transitioning' directly.
577579
*/
578580
if (sense_hdr.sense_key == NOT_READY &&
579-
sense_hdr.asc == 0x04 && sense_hdr.ascq == 0x0a)
580-
err = SCSI_DH_RETRY;
581-
else if (sense_hdr.sense_key == UNIT_ATTENTION)
581+
sense_hdr.asc == 0x04 && sense_hdr.ascq == 0x0a) {
582+
transitioning_sense = true;
583+
goto skip_rtpg;
584+
}
585+
/*
586+
* Retry on any other UNIT ATTENTION occurred.
587+
*/
588+
if (sense_hdr.sense_key == UNIT_ATTENTION)
582589
err = SCSI_DH_RETRY;
583590
if (err == SCSI_DH_RETRY &&
584591
pg->expiry != 0 && time_before(jiffies, pg->expiry)) {
@@ -666,7 +673,11 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)
666673
off = 8 + (desc[7] * 4);
667674
}
668675

676+
skip_rtpg:
669677
spin_lock_irqsave(&pg->lock, flags);
678+
if (transitioning_sense)
679+
pg->state = SCSI_ACCESS_STATE_TRANSITIONING;
680+
670681
sdev_printk(KERN_INFO, sdev,
671682
"%s: port group %02x state %c %s supports %c%c%c%c%c%c%c\n",
672683
ALUA_DH_NAME, pg->group_id, print_alua_state(pg->state),

drivers/scsi/hpsa.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5477,6 +5477,8 @@ static int hpsa_ciss_submit(struct ctlr_info *h,
54775477
return SCSI_MLQUEUE_HOST_BUSY;
54785478
}
54795479

5480+
c->device = dev;
5481+
54805482
enqueue_cmd_and_start_io(h, c);
54815483
/* the cmd'll come back via intr handler in complete_scsi_command() */
54825484
return 0;
@@ -5548,13 +5550,15 @@ static int hpsa_ioaccel_submit(struct ctlr_info *h,
55485550
hpsa_cmd_init(h, c->cmdindex, c);
55495551
c->cmd_type = CMD_SCSI;
55505552
c->scsi_cmd = cmd;
5553+
c->device = dev;
55515554
rc = hpsa_scsi_ioaccel_raid_map(h, c);
55525555
if (rc < 0) /* scsi_dma_map failed. */
55535556
rc = SCSI_MLQUEUE_HOST_BUSY;
55545557
} else if (dev->hba_ioaccel_enabled) {
55555558
hpsa_cmd_init(h, c->cmdindex, c);
55565559
c->cmd_type = CMD_SCSI;
55575560
c->scsi_cmd = cmd;
5561+
c->device = dev;
55585562
rc = hpsa_scsi_ioaccel_direct_map(h, c);
55595563
if (rc < 0) /* scsi_dma_map failed. */
55605564
rc = SCSI_MLQUEUE_HOST_BUSY;

drivers/scsi/lpfc/lpfc_init.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9055,15 +9055,13 @@ lpfc_sli4_queue_create(struct lpfc_hba *phba)
90559055
}
90569056
}
90579057

9058-
#if defined(BUILD_NVME)
90599058
/* Clear NVME stats */
90609059
if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) {
90619060
for (idx = 0; idx < phba->cfg_hdw_queue; idx++) {
90629061
memset(&phba->sli4_hba.hdwq[idx].nvme_cstat, 0,
90639062
sizeof(phba->sli4_hba.hdwq[idx].nvme_cstat));
90649063
}
90659064
}
9066-
#endif
90679065

90689066
/* Clear SCSI stats */
90699067
if (phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) {

drivers/scsi/lpfc/lpfc_scsi.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,15 +528,13 @@ lpfc_sli4_io_xri_aborted(struct lpfc_hba *phba,
528528
list_del_init(&psb->list);
529529
psb->exch_busy = 0;
530530
psb->status = IOSTAT_SUCCESS;
531-
#ifdef BUILD_NVME
532531
if (psb->cur_iocbq.iocb_flag == LPFC_IO_NVME) {
533532
qp->abts_nvme_io_bufs--;
534533
spin_unlock(&qp->abts_io_buf_list_lock);
535534
spin_unlock_irqrestore(&phba->hbalock, iflag);
536535
lpfc_sli4_nvme_xri_aborted(phba, axri, psb);
537536
return;
538537
}
539-
#endif
540538
qp->abts_scsi_io_bufs--;
541539
spin_unlock(&qp->abts_io_buf_list_lock);
542540

drivers/scsi/qla2xxx/qla_os.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3224,6 +3224,10 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
32243224
req->req_q_in, req->req_q_out, rsp->rsp_q_in, rsp->rsp_q_out);
32253225

32263226
ha->wq = alloc_workqueue("qla2xxx_wq", 0, 0);
3227+
if (unlikely(!ha->wq)) {
3228+
ret = -ENOMEM;
3229+
goto probe_failed;
3230+
}
32273231

32283232
if (ha->isp_ops->initialize_adapter(base_vha)) {
32293233
ql_log(ql_log_fatal, base_vha, 0x00d6,

drivers/scsi/scsi_sysfs.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,14 @@ sdev_store_delete(struct device *dev, struct device_attribute *attr,
730730
const char *buf, size_t count)
731731
{
732732
struct kernfs_node *kn;
733+
struct scsi_device *sdev = to_scsi_device(dev);
734+
735+
/*
736+
* We need to try to get module, avoiding the module been removed
737+
* during delete.
738+
*/
739+
if (scsi_device_get(sdev))
740+
return -ENODEV;
733741

734742
kn = sysfs_break_active_protection(&dev->kobj, &attr->attr);
735743
WARN_ON_ONCE(!kn);
@@ -744,9 +752,10 @@ sdev_store_delete(struct device *dev, struct device_attribute *attr,
744752
* state into SDEV_DEL.
745753
*/
746754
device_remove_file(dev, attr);
747-
scsi_remove_device(to_scsi_device(dev));
755+
scsi_remove_device(sdev);
748756
if (kn)
749757
sysfs_unbreak_active_protection(kn);
758+
scsi_device_put(sdev);
750759
return count;
751760
};
752761
static DEVICE_ATTR(delete, S_IWUSR, NULL, sdev_store_delete);

drivers/scsi/sni_53c710.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,8 @@ static int snirm710_probe(struct platform_device *dev)
6666

6767
base = res->start;
6868
hostdata = kzalloc(sizeof(*hostdata), GFP_KERNEL);
69-
if (!hostdata) {
70-
dev_printk(KERN_ERR, dev, "Failed to allocate host data\n");
69+
if (!hostdata)
7170
return -ENOMEM;
72-
}
7371

7472
hostdata->dev = &dev->dev;
7573
dma_set_mask(&dev->dev, DMA_BIT_MASK(32));

drivers/target/target_core_device.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,27 +1074,6 @@ passthrough_parse_cdb(struct se_cmd *cmd,
10741074
struct se_device *dev = cmd->se_dev;
10751075
unsigned int size;
10761076

1077-
/*
1078-
* Clear a lun set in the cdb if the initiator talking to use spoke
1079-
* and old standards version, as we can't assume the underlying device
1080-
* won't choke up on it.
1081-
*/
1082-
switch (cdb[0]) {
1083-
case READ_10: /* SBC - RDProtect */
1084-
case READ_12: /* SBC - RDProtect */
1085-
case READ_16: /* SBC - RDProtect */
1086-
case SEND_DIAGNOSTIC: /* SPC - SELF-TEST Code */
1087-
case VERIFY: /* SBC - VRProtect */
1088-
case VERIFY_16: /* SBC - VRProtect */
1089-
case WRITE_VERIFY: /* SBC - VRProtect */
1090-
case WRITE_VERIFY_12: /* SBC - VRProtect */
1091-
case MAINTENANCE_IN: /* SPC - Parameter Data Format for SA RTPG */
1092-
break;
1093-
default:
1094-
cdb[1] &= 0x1f; /* clear logical unit number */
1095-
break;
1096-
}
1097-
10981077
/*
10991078
* For REPORT LUNS we always need to emulate the response, for everything
11001079
* else, pass it up.

0 commit comments

Comments
 (0)