aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMike Christie <michaelc@cs.wisc.edu>2012-04-15 22:47:50 -0400
committerJames Bottomley <JBottomley@Parallels.com>2012-05-10 03:59:23 -0400
commit8fb2ef89b696624ea9853868e370d2e132e76f54 (patch)
treeb10e8bc41a7d643a47dce1ac99567f4919e0a9fd /drivers
parent7c018a901c3fef2af9d713ba849e8e52eb82dde1 (diff)
[SCSI] fc class: fix scanning when devs are offline
When a rport is added back or the role is changed the fc class will queue a scan and then call scsi_target_unblock. The problem with this is if the devices are in the SDEV_OFFLINE state and the scan is run before the scsi_target_unblock, then the scan will see LUN0 as offline and the scan will fail. This patch moves the unblock call to before the scan, so we know the device state will be set correctly when the scan is run. Signed-off-by: Mike Christie <michaelc@cs.wisc.edu> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/scsi_transport_fc.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 80fbe2ac0b47..579760420d53 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -2808,17 +2808,20 @@ fc_remote_port_add(struct Scsi_Host *shost, int channel,
2808 FC_RPORT_DEVLOSS_PENDING | 2808 FC_RPORT_DEVLOSS_PENDING |
2809 FC_RPORT_DEVLOSS_CALLBK_DONE); 2809 FC_RPORT_DEVLOSS_CALLBK_DONE);
2810 2810
2811 spin_unlock_irqrestore(shost->host_lock, flags);
2812
2811 /* if target, initiate a scan */ 2813 /* if target, initiate a scan */
2812 if (rport->scsi_target_id != -1) { 2814 if (rport->scsi_target_id != -1) {
2815 scsi_target_unblock(&rport->dev);
2816
2817 spin_lock_irqsave(shost->host_lock,
2818 flags);
2813 rport->flags |= FC_RPORT_SCAN_PENDING; 2819 rport->flags |= FC_RPORT_SCAN_PENDING;
2814 scsi_queue_work(shost, 2820 scsi_queue_work(shost,
2815 &rport->scan_work); 2821 &rport->scan_work);
2816 spin_unlock_irqrestore(shost->host_lock, 2822 spin_unlock_irqrestore(shost->host_lock,
2817 flags); 2823 flags);
2818 scsi_target_unblock(&rport->dev); 2824 }
2819 } else
2820 spin_unlock_irqrestore(shost->host_lock,
2821 flags);
2822 2825
2823 fc_bsg_goose_queue(rport); 2826 fc_bsg_goose_queue(rport);
2824 2827
@@ -2876,16 +2879,17 @@ fc_remote_port_add(struct Scsi_Host *shost, int channel,
2876 if (fci->f->dd_fcrport_size) 2879 if (fci->f->dd_fcrport_size)
2877 memset(rport->dd_data, 0, 2880 memset(rport->dd_data, 0,
2878 fci->f->dd_fcrport_size); 2881 fci->f->dd_fcrport_size);
2882 spin_unlock_irqrestore(shost->host_lock, flags);
2883
2884 if (ids->roles & FC_PORT_ROLE_FCP_TARGET) {
2885 scsi_target_unblock(&rport->dev);
2879 2886
2880 if (rport->roles & FC_PORT_ROLE_FCP_TARGET) {
2881 /* initiate a scan of the target */ 2887 /* initiate a scan of the target */
2888 spin_lock_irqsave(shost->host_lock, flags);
2882 rport->flags |= FC_RPORT_SCAN_PENDING; 2889 rport->flags |= FC_RPORT_SCAN_PENDING;
2883 scsi_queue_work(shost, &rport->scan_work); 2890 scsi_queue_work(shost, &rport->scan_work);
2884 spin_unlock_irqrestore(shost->host_lock, flags); 2891 spin_unlock_irqrestore(shost->host_lock, flags);
2885 scsi_target_unblock(&rport->dev); 2892 }
2886 } else
2887 spin_unlock_irqrestore(shost->host_lock, flags);
2888
2889 return rport; 2893 return rport;
2890 } 2894 }
2891 } 2895 }
@@ -3083,12 +3087,12 @@ fc_remote_port_rolechg(struct fc_rport *rport, u32 roles)
3083 /* ensure any stgt delete functions are done */ 3087 /* ensure any stgt delete functions are done */
3084 fc_flush_work(shost); 3088 fc_flush_work(shost);
3085 3089
3090 scsi_target_unblock(&rport->dev);
3086 /* initiate a scan of the target */ 3091 /* initiate a scan of the target */
3087 spin_lock_irqsave(shost->host_lock, flags); 3092 spin_lock_irqsave(shost->host_lock, flags);
3088 rport->flags |= FC_RPORT_SCAN_PENDING; 3093 rport->flags |= FC_RPORT_SCAN_PENDING;
3089 scsi_queue_work(shost, &rport->scan_work); 3094 scsi_queue_work(shost, &rport->scan_work);
3090 spin_unlock_irqrestore(shost->host_lock, flags); 3095 spin_unlock_irqrestore(shost->host_lock, flags);
3091 scsi_target_unblock(&rport->dev);
3092 } 3096 }
3093} 3097}
3094EXPORT_SYMBOL(fc_remote_port_rolechg); 3098EXPORT_SYMBOL(fc_remote_port_rolechg);