Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi

Pull SCSI fixes from James Bottomley:
"Seven fixes, five in drivers.

The two core changes are a trivial warning removal in scsi_scan.c and
a change to rescan for capacity when a device makes a user induced
(via a write to the state variable) offline->running transition to fix
issues with device mapper"

* tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
scsi: core: Fix capacity set to zero after offlinining device
scsi: sr: Return correct event when media event code is 3
scsi: ibmvfc: Fix command state accounting and stale response detection
scsi: core: Avoid printing an error if target_alloc() returns -ENXIO
scsi: scsi_dh_rdac: Avoid crash during rdac_bus_attach()
scsi: megaraid_mm: Fix end of loop tests for list_for_each_entry()
scsi: pm80xx: Fix TMF task completion race condition

+59 -32
+2 -2
drivers/scsi/device_handler/scsi_dh_rdac.c
··· 453 453 if (!h->ctlr) 454 454 err = SCSI_DH_RES_TEMP_UNAVAIL; 455 455 else { 456 - list_add_rcu(&h->node, &h->ctlr->dh_list); 457 456 h->sdev = sdev; 457 + list_add_rcu(&h->node, &h->ctlr->dh_list); 458 458 } 459 459 spin_unlock(&list_lock); 460 460 err = SCSI_DH_OK; ··· 778 778 spin_lock(&list_lock); 779 779 if (h->ctlr) { 780 780 list_del_rcu(&h->node); 781 - h->sdev = NULL; 782 781 kref_put(&h->ctlr->kref, release_controller); 783 782 } 784 783 spin_unlock(&list_lock); 785 784 sdev->handler_data = NULL; 785 + synchronize_rcu(); 786 786 kfree(h); 787 787 } 788 788
+17 -2
drivers/scsi/ibmvscsi/ibmvfc.c
··· 807 807 for (i = 0; i < size; ++i) { 808 808 struct ibmvfc_event *evt = &pool->events[i]; 809 809 810 + /* 811 + * evt->active states 812 + * 1 = in flight 813 + * 0 = being completed 814 + * -1 = free/freed 815 + */ 816 + atomic_set(&evt->active, -1); 810 817 atomic_set(&evt->free, 1); 811 818 evt->crq.valid = 0x80; 812 819 evt->crq.ioba = cpu_to_be64(pool->iu_token + (sizeof(*evt->xfer_iu) * i)); ··· 1024 1017 1025 1018 BUG_ON(!ibmvfc_valid_event(pool, evt)); 1026 1019 BUG_ON(atomic_inc_return(&evt->free) != 1); 1020 + BUG_ON(atomic_dec_and_test(&evt->active)); 1027 1021 1028 1022 spin_lock_irqsave(&evt->queue->l_lock, flags); 1029 1023 list_add_tail(&evt->queue_list, &evt->queue->free); ··· 1080 1072 **/ 1081 1073 static void ibmvfc_fail_request(struct ibmvfc_event *evt, int error_code) 1082 1074 { 1075 + /* 1076 + * Anything we are failing should still be active. Otherwise, it 1077 + * implies we already got a response for the command and are doing 1078 + * something bad like double completing it. 1079 + */ 1080 + BUG_ON(!atomic_dec_and_test(&evt->active)); 1083 1081 if (evt->cmnd) { 1084 1082 evt->cmnd->result = (error_code << 16); 1085 1083 evt->done = ibmvfc_scsi_eh_done; ··· 1737 1723 1738 1724 evt->done(evt); 1739 1725 } else { 1726 + atomic_set(&evt->active, 1); 1740 1727 spin_unlock_irqrestore(&evt->queue->l_lock, flags); 1741 1728 ibmvfc_trc_start(evt); 1742 1729 } ··· 3266 3251 return; 3267 3252 } 3268 3253 3269 - if (unlikely(atomic_read(&evt->free))) { 3254 + if (unlikely(atomic_dec_if_positive(&evt->active))) { 3270 3255 dev_err(vhost->dev, "Received duplicate correlation_token 0x%08llx!\n", 3271 3256 crq->ioba); 3272 3257 return; ··· 3793 3778 return; 3794 3779 } 3795 3780 3796 - if (unlikely(atomic_read(&evt->free))) { 3781 + if (unlikely(atomic_dec_if_positive(&evt->active))) { 3797 3782 dev_err(vhost->dev, "Received duplicate correlation_token 0x%08llx!\n", 3798 3783 crq->ioba); 3799 3784 return;
+1
drivers/scsi/ibmvscsi/ibmvfc.h
··· 745 745 struct ibmvfc_target *tgt; 746 746 struct scsi_cmnd *cmnd; 747 747 atomic_t free; 748 + atomic_t active; 748 749 union ibmvfc_iu *xfer_iu; 749 750 void (*done)(struct ibmvfc_event *evt); 750 751 void (*_done)(struct ibmvfc_event *evt);
+15 -6
drivers/scsi/megaraid/megaraid_mm.c
··· 238 238 mimd_t mimd; 239 239 uint32_t adapno; 240 240 int iterator; 241 - 241 + bool is_found; 242 242 243 243 if (copy_from_user(&mimd, umimd, sizeof(mimd_t))) { 244 244 *rval = -EFAULT; ··· 254 254 255 255 adapter = NULL; 256 256 iterator = 0; 257 + is_found = false; 257 258 258 259 list_for_each_entry(adapter, &adapters_list_g, list) { 259 - if (iterator++ == adapno) break; 260 + if (iterator++ == adapno) { 261 + is_found = true; 262 + break; 263 + } 260 264 } 261 265 262 - if (!adapter) { 266 + if (!is_found) { 263 267 *rval = -ENODEV; 264 268 return NULL; 265 269 } ··· 729 725 uint32_t adapno; 730 726 int iterator; 731 727 mraid_mmadp_t* adapter; 728 + bool is_found; 732 729 733 730 /* 734 731 * When the kioc returns from driver, make sure it still doesn't ··· 752 747 iterator = 0; 753 748 adapter = NULL; 754 749 adapno = kioc->adapno; 750 + is_found = false; 755 751 756 752 con_log(CL_ANN, ( KERN_WARNING "megaraid cmm: completed " 757 753 "ioctl that was timedout before\n")); 758 754 759 755 list_for_each_entry(adapter, &adapters_list_g, list) { 760 - if (iterator++ == adapno) break; 756 + if (iterator++ == adapno) { 757 + is_found = true; 758 + break; 759 + } 761 760 } 762 761 763 762 kioc->timedout = 0; 764 763 765 - if (adapter) { 764 + if (is_found) 766 765 mraid_mm_dealloc_kioc( adapter, kioc ); 767 - } 766 + 768 767 } 769 768 else { 770 769 wake_up(&wait_q);
+15 -17
drivers/scsi/pm8001/pm8001_sas.c
··· 684 684 685 685 void pm8001_task_done(struct sas_task *task) 686 686 { 687 - if (!del_timer(&task->slow_task->timer)) 688 - return; 687 + del_timer(&task->slow_task->timer); 689 688 complete(&task->slow_task->completion); 690 689 } 691 690 ··· 692 693 { 693 694 struct sas_task_slow *slow = from_timer(slow, t, timer); 694 695 struct sas_task *task = slow->task; 696 + unsigned long flags; 695 697 696 - task->task_state_flags |= SAS_TASK_STATE_ABORTED; 697 - complete(&task->slow_task->completion); 698 + spin_lock_irqsave(&task->task_state_lock, flags); 699 + if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) { 700 + task->task_state_flags |= SAS_TASK_STATE_ABORTED; 701 + complete(&task->slow_task->completion); 702 + } 703 + spin_unlock_irqrestore(&task->task_state_lock, flags); 698 704 } 699 705 700 706 #define PM8001_TASK_TIMEOUT 20 ··· 752 748 } 753 749 res = -TMF_RESP_FUNC_FAILED; 754 750 /* Even TMF timed out, return direct. */ 755 - if ((task->task_state_flags & SAS_TASK_STATE_ABORTED)) { 756 - if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) { 757 - pm8001_dbg(pm8001_ha, FAIL, 758 - "TMF task[%x]timeout.\n", 759 - tmf->tmf); 760 - goto ex_err; 761 - } 751 + if (task->task_state_flags & SAS_TASK_STATE_ABORTED) { 752 + pm8001_dbg(pm8001_ha, FAIL, "TMF task[%x]timeout.\n", 753 + tmf->tmf); 754 + goto ex_err; 762 755 } 763 756 764 757 if (task->task_status.resp == SAS_TASK_COMPLETE && ··· 835 834 wait_for_completion(&task->slow_task->completion); 836 835 res = TMF_RESP_FUNC_FAILED; 837 836 /* Even TMF timed out, return direct. */ 838 - if ((task->task_state_flags & SAS_TASK_STATE_ABORTED)) { 839 - if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) { 840 - pm8001_dbg(pm8001_ha, FAIL, 841 - "TMF task timeout.\n"); 842 - goto ex_err; 843 - } 837 + if (task->task_state_flags & SAS_TASK_STATE_ABORTED) { 838 + pm8001_dbg(pm8001_ha, FAIL, "TMF task timeout.\n"); 839 + goto ex_err; 844 840 } 845 841 846 842 if (task->task_status.resp == SAS_TASK_COMPLETE &&
+2 -1
drivers/scsi/scsi_scan.c
··· 475 475 error = shost->hostt->target_alloc(starget); 476 476 477 477 if(error) { 478 - dev_printk(KERN_ERR, dev, "target allocation failed, error %d\n", error); 478 + if (error != -ENXIO) 479 + dev_err(dev, "target allocation failed, error %d\n", error); 479 480 /* don't want scsi_target_reap to do the final 480 481 * put because it will be under the host lock */ 481 482 scsi_target_destroy(starget);
+6 -3
drivers/scsi/scsi_sysfs.c
··· 807 807 mutex_lock(&sdev->state_mutex); 808 808 ret = scsi_device_set_state(sdev, state); 809 809 /* 810 - * If the device state changes to SDEV_RUNNING, we need to run 811 - * the queue to avoid I/O hang. 810 + * If the device state changes to SDEV_RUNNING, we need to 811 + * rescan the device to revalidate it, and run the queue to 812 + * avoid I/O hang. 812 813 */ 813 - if (ret == 0 && state == SDEV_RUNNING) 814 + if (ret == 0 && state == SDEV_RUNNING) { 815 + scsi_rescan_device(dev); 814 816 blk_mq_run_hw_queues(sdev->request_queue, true); 817 + } 815 818 mutex_unlock(&sdev->state_mutex); 816 819 817 820 return ret == 0 ? count : -EINVAL;
+1 -1
drivers/scsi/sr.c
··· 221 221 else if (med->media_event_code == 2) 222 222 return DISK_EVENT_MEDIA_CHANGE; 223 223 else if (med->media_event_code == 3) 224 - return DISK_EVENT_EJECT_REQUEST; 224 + return DISK_EVENT_MEDIA_CHANGE; 225 225 return 0; 226 226 } 227 227