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
Unified · Split
| @@ -898,7 +898,7 @@ config SCSI_SNI_53C710 · 897 unmodified lines | ||
| 898 | 898 | |
| 899 | 899 | config 53C700_LE_ON_BE |
| 900 | 900 | bool |
| 901 | − depends on SCSI_LASI700 | |
| 901 | + depends on SCSI_LASI700 || SCSI_SNI_53C710 | |
| 902 | 902 | default y |
| 903 | 903 | |
| 904 | 904 | config SCSI_STEX |
| @@ -579,7 +579,6 @@ ch_release(struct inode *inode, struct file *file) · 578 unmodified lines | ||
| 579 | 579 | scsi_changer *ch = file->private_data; |
| 580 | 580 | |
| 581 | 581 | scsi_device_put(ch->device); |
| 582 | − ch->device = NULL; | |
| 583 | 582 | file->private_data = NULL; |
| 584 | 583 | kref_put(&ch->ref, ch_destroy); |
| 585 | 584 | return 0; |
| @@ -512,6 +512,7 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg) · 511 unmodified lines | ||
| 512 | 512 | unsigned int tpg_desc_tbl_off; |
| 513 | 513 | unsigned char orig_transition_tmo; |
| 514 | 514 | unsigned long flags; |
| 515 | + bool transitioning_sense = false; | |
| 515 | 516 | |
| 516 | 517 | if (!pg->expiry) { |
| 517 | 518 | 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) · 54 unmodified lines | ||
| 572 | 573 | goto retry; |
| 573 | 574 | } |
| 574 | 575 | /* |
| 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. | |
| 577 | 579 | */ |
| 578 | 580 | 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) | |
| 582 | 589 | err = SCSI_DH_RETRY; |
| 583 | 590 | if (err == SCSI_DH_RETRY && |
| 584 | 591 | 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) · 81 unmodified lines | ||
| 666 | 673 | off = 8 + (desc[7] * 4); |
| 667 | 674 | } |
| 668 | 675 | |
| 676 | + skip_rtpg: | |
| 669 | 677 | spin_lock_irqsave(&pg->lock, flags); |
| 678 | + if (transitioning_sense) | |
| 679 | + pg->state = SCSI_ACCESS_STATE_TRANSITIONING; | |
| 680 | + | |
| 670 | 681 | sdev_printk(KERN_INFO, sdev, |
| 671 | 682 | "%s: port group %02x state %c %s supports %c%c%c%c%c%c%c\n", |
| 672 | 683 | ALUA_DH_NAME, pg->group_id, print_alua_state(pg->state), |
| @@ -5477,6 +5477,8 @@ static int hpsa_ciss_submit(struct ctlr_info *h, · 5476 unmodified lines | ||
| 5477 | 5477 | return SCSI_MLQUEUE_HOST_BUSY; |
| 5478 | 5478 | } |
| 5479 | 5479 | |
| 5480 | + c->device = dev; | |
| 5481 | + | |
| 5480 | 5482 | enqueue_cmd_and_start_io(h, c); |
| 5481 | 5483 | /* the cmd'll come back via intr handler in complete_scsi_command() */ |
| 5482 | 5484 | return 0; |
| @@ -5548,6 +5550,7 @@ static int hpsa_ioaccel_submit(struct ctlr_info *h, · 65 unmodified lines | ||
| 5548 | 5550 | hpsa_cmd_init(h, c->cmdindex, c); |
| 5549 | 5551 | c->cmd_type = CMD_SCSI; |
| 5550 | 5552 | c->scsi_cmd = cmd; |
| 5553 | + c->device = dev; | |
| 5551 | 5554 | rc = hpsa_scsi_ioaccel_raid_map(h, c); |
| 5552 | 5555 | if (rc < 0) /* scsi_dma_map failed. */ |
| 5553 | 5556 | rc = SCSI_MLQUEUE_HOST_BUSY; |
| @@ -5555,6 +5558,7 @@ static int hpsa_ioaccel_submit(struct ctlr_info *h, · 1 unmodified line | ||
| 5555 | 5558 | hpsa_cmd_init(h, c->cmdindex, c); |
| 5556 | 5559 | c->cmd_type = CMD_SCSI; |
| 5557 | 5560 | c->scsi_cmd = cmd; |
| 5561 | + c->device = dev; | |
| 5558 | 5562 | rc = hpsa_scsi_ioaccel_direct_map(h, c); |
| 5559 | 5563 | if (rc < 0) /* scsi_dma_map failed. */ |
| 5560 | 5564 | rc = SCSI_MLQUEUE_HOST_BUSY; |
| @@ -9055,7 +9055,6 @@ lpfc_sli4_queue_create(struct lpfc_hba *phba) · 9054 unmodified lines | ||
| 9055 | 9055 | } |
| 9056 | 9056 | } |
| 9057 | 9057 | |
| 9058 | −#if defined(BUILD_NVME) | |
| 9059 | 9058 | /* Clear NVME stats */ |
| 9060 | 9059 | if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { |
| 9061 | 9060 | for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { |
| @@ -9063,7 +9062,6 @@ lpfc_sli4_queue_create(struct lpfc_hba *phba) · 1 unmodified line | ||
| 9063 | 9062 | sizeof(phba->sli4_hba.hdwq[idx].nvme_cstat)); |
| 9064 | 9063 | } |
| 9065 | 9064 | } |
| 9066 | −#endif | |
| 9067 | 9065 | |
| 9068 | 9066 | /* Clear SCSI stats */ |
| 9069 | 9067 | if (phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) { |
| @@ -528,7 +528,6 @@ lpfc_sli4_io_xri_aborted(struct lpfc_hba *phba, · 527 unmodified lines | ||
| 528 | 528 | list_del_init(&psb->list); |
| 529 | 529 | psb->exch_busy = 0; |
| 530 | 530 | psb->status = IOSTAT_SUCCESS; |
| 531 | −#ifdef BUILD_NVME | |
| 532 | 531 | if (psb->cur_iocbq.iocb_flag == LPFC_IO_NVME) { |
| 533 | 532 | qp->abts_nvme_io_bufs--; |
| 534 | 533 | spin_unlock(&qp->abts_io_buf_list_lock); |
| @@ -536,7 +535,6 @@ lpfc_sli4_io_xri_aborted(struct lpfc_hba *phba, · 1 unmodified line | ||
| 536 | 535 | lpfc_sli4_nvme_xri_aborted(phba, axri, psb); |
| 537 | 536 | return; |
| 538 | 537 | } |
| 539 | −#endif | |
| 540 | 538 | qp->abts_scsi_io_bufs--; |
| 541 | 539 | spin_unlock(&qp->abts_io_buf_list_lock); |
| 542 | 540 | |
| @@ -3224,6 +3224,10 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) · 3223 unmodified lines | ||
| 3224 | 3224 | req->req_q_in, req->req_q_out, rsp->rsp_q_in, rsp->rsp_q_out); |
| 3225 | 3225 | |
| 3226 | 3226 | ha->wq = alloc_workqueue("qla2xxx_wq", 0, 0); |
| 3227 | + if (unlikely(!ha->wq)) { | |
| 3228 | + ret = -ENOMEM; | |
| 3229 | + goto probe_failed; | |
| 3230 | + } | |
| 3227 | 3231 | |
| 3228 | 3232 | if (ha->isp_ops->initialize_adapter(base_vha)) { |
| 3229 | 3233 | ql_log(ql_log_fatal, base_vha, 0x00d6, |
| @@ -730,6 +730,14 @@ sdev_store_delete(struct device *dev, struct device_attribute *attr, · 729 unmodified lines | ||
| 730 | 730 | const char *buf, size_t count) |
| 731 | 731 | { |
| 732 | 732 | 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; | |
| 733 | 741 | |
| 734 | 742 | kn = sysfs_break_active_protection(&dev->kobj, &attr->attr); |
| 735 | 743 | WARN_ON_ONCE(!kn); |
| @@ -744,9 +752,10 @@ sdev_store_delete(struct device *dev, struct device_attribute *attr, · 8 unmodified lines | ||
| 744 | 752 | * state into SDEV_DEL. |
| 745 | 753 | */ |
| 746 | 754 | device_remove_file(dev, attr); |
| 747 | − scsi_remove_device(to_scsi_device(dev)); | |
| 755 | + scsi_remove_device(sdev); | |
| 748 | 756 | if (kn) |
| 749 | 757 | sysfs_unbreak_active_protection(kn); |
| 758 | + scsi_device_put(sdev); | |
| 750 | 759 | return count; |
| 751 | 760 | }; |
| 752 | 761 | static DEVICE_ATTR(delete, S_IWUSR, NULL, sdev_store_delete); |
| @@ -66,10 +66,8 @@ static int snirm710_probe(struct platform_device *dev) · 65 unmodified lines | ||
| 66 | 66 | |
| 67 | 67 | base = res->start; |
| 68 | 68 | hostdata = kzalloc(sizeof(*hostdata), GFP_KERNEL); |
| 69 | − if (!hostdata) { | |
| 70 | − dev_printk(KERN_ERR, dev, "Failed to allocate host data\n"); | |
| 69 | + if (!hostdata) | |
| 71 | 70 | return -ENOMEM; |
| 72 | − } | |
| 73 | 71 | |
| 74 | 72 | hostdata->dev = &dev->dev; |
| 75 | 73 | dma_set_mask(&dev->dev, DMA_BIT_MASK(32)); |
| @@ -1074,27 +1074,6 @@ passthrough_parse_cdb(struct se_cmd *cmd, · 1073 unmodified lines | ||
| 1074 | 1074 | struct se_device *dev = cmd->se_dev; |
| 1075 | 1075 | unsigned int size; |
| 1076 | 1076 | |
| 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 | − | |
| 1098 | 1077 | /* |
| 1099 | 1078 | * For REPORT LUNS we always need to emulate the response, for everything |
| 1100 | 1079 | * else, pass it up. |