aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/scsi/zfcp_scsi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/s390/scsi/zfcp_scsi.c')
-rw-r--r--drivers/s390/scsi/zfcp_scsi.c114
1 files changed, 52 insertions, 62 deletions
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
index 03837797c45..bc7217b8898 100644
--- a/drivers/s390/scsi/zfcp_scsi.c
+++ b/drivers/s390/scsi/zfcp_scsi.c
@@ -49,11 +49,12 @@ static int zfcp_scsi_change_queue_depth(struct scsi_device *sdev, int depth,
49 return sdev->queue_depth; 49 return sdev->queue_depth;
50} 50}
51 51
52static void zfcp_scsi_slave_destroy(struct scsi_device *sdpnt) 52static void zfcp_scsi_slave_destroy(struct scsi_device *sdev)
53{ 53{
54 struct zfcp_unit *unit = (struct zfcp_unit *) sdpnt->hostdata; 54 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev);
55 unit->device = NULL; 55
56 put_device(&unit->dev); 56 zfcp_erp_lun_shutdown_wait(sdev, "scssd_1");
57 put_device(&zfcp_sdev->port->dev);
57} 58}
58 59
59static int zfcp_scsi_slave_configure(struct scsi_device *sdp) 60static int zfcp_scsi_slave_configure(struct scsi_device *sdp)
@@ -78,23 +79,16 @@ static void zfcp_scsi_command_fail(struct scsi_cmnd *scpnt, int result)
78static int zfcp_scsi_queuecommand(struct scsi_cmnd *scpnt, 79static int zfcp_scsi_queuecommand(struct scsi_cmnd *scpnt,
79 void (*done) (struct scsi_cmnd *)) 80 void (*done) (struct scsi_cmnd *))
80{ 81{
81 struct zfcp_unit *unit; 82 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(scpnt->device);
82 struct zfcp_adapter *adapter; 83 struct zfcp_adapter *adapter = zfcp_sdev->port->adapter;
83 int status, scsi_result, ret;
84 struct fc_rport *rport = starget_to_rport(scsi_target(scpnt->device)); 84 struct fc_rport *rport = starget_to_rport(scsi_target(scpnt->device));
85 int status, scsi_result, ret;
85 86
86 /* reset the status for this request */ 87 /* reset the status for this request */
87 scpnt->result = 0; 88 scpnt->result = 0;
88 scpnt->host_scribble = NULL; 89 scpnt->host_scribble = NULL;
89 scpnt->scsi_done = done; 90 scpnt->scsi_done = done;
90 91
91 /*
92 * figure out adapter and target device
93 * (stored there by zfcp_scsi_slave_alloc)
94 */
95 adapter = (struct zfcp_adapter *) scpnt->device->host->hostdata[0];
96 unit = scpnt->device->hostdata;
97
98 scsi_result = fc_remote_port_chkready(rport); 92 scsi_result = fc_remote_port_chkready(rport);
99 if (unlikely(scsi_result)) { 93 if (unlikely(scsi_result)) {
100 scpnt->result = scsi_result; 94 scpnt->result = scsi_result;
@@ -103,11 +97,11 @@ static int zfcp_scsi_queuecommand(struct scsi_cmnd *scpnt,
103 return 0; 97 return 0;
104 } 98 }
105 99
106 status = atomic_read(&unit->status); 100 status = atomic_read(&zfcp_sdev->status);
107 if (unlikely(status & ZFCP_STATUS_COMMON_ERP_FAILED) && 101 if (unlikely(status & ZFCP_STATUS_COMMON_ERP_FAILED) &&
108 !(atomic_read(&unit->port->status) & 102 !(atomic_read(&zfcp_sdev->port->status) &
109 ZFCP_STATUS_COMMON_ERP_FAILED)) { 103 ZFCP_STATUS_COMMON_ERP_FAILED)) {
110 /* only unit access denied, but port is good 104 /* only LUN access denied, but port is good
111 * not covered by FC transport, have to fail here */ 105 * not covered by FC transport, have to fail here */
112 zfcp_scsi_command_fail(scpnt, DID_ERROR); 106 zfcp_scsi_command_fail(scpnt, DID_ERROR);
113 return 0; 107 return 0;
@@ -115,8 +109,8 @@ static int zfcp_scsi_queuecommand(struct scsi_cmnd *scpnt,
115 109
116 if (unlikely(!(status & ZFCP_STATUS_COMMON_UNBLOCKED))) { 110 if (unlikely(!(status & ZFCP_STATUS_COMMON_UNBLOCKED))) {
117 /* This could be either 111 /* This could be either
118 * open unit pending: this is temporary, will result in 112 * open LUN pending: this is temporary, will result in
119 * open unit or ERP_FAILED, so retry command 113 * open LUN or ERP_FAILED, so retry command
120 * call to rport_delete pending: mimic retry from 114 * call to rport_delete pending: mimic retry from
121 * fc_remote_port_chkready until rport is BLOCKED 115 * fc_remote_port_chkready until rport is BLOCKED
122 */ 116 */
@@ -124,7 +118,7 @@ static int zfcp_scsi_queuecommand(struct scsi_cmnd *scpnt,
124 return 0; 118 return 0;
125 } 119 }
126 120
127 ret = zfcp_fsf_send_fcp_command_task(unit, scpnt); 121 ret = zfcp_fsf_fcp_cmnd(scpnt);
128 if (unlikely(ret == -EBUSY)) 122 if (unlikely(ret == -EBUSY))
129 return SCSI_MLQUEUE_DEVICE_BUSY; 123 return SCSI_MLQUEUE_DEVICE_BUSY;
130 else if (unlikely(ret < 0)) 124 else if (unlikely(ret < 0))
@@ -133,45 +127,42 @@ static int zfcp_scsi_queuecommand(struct scsi_cmnd *scpnt,
133 return ret; 127 return ret;
134} 128}
135 129
136static struct zfcp_unit *zfcp_unit_lookup(struct zfcp_adapter *adapter, 130static int zfcp_scsi_slave_alloc(struct scsi_device *sdev)
137 unsigned int id, u64 lun)
138{ 131{
139 unsigned long flags; 132 struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
133 struct zfcp_adapter *adapter =
134 (struct zfcp_adapter *) sdev->host->hostdata[0];
135 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev);
140 struct zfcp_port *port; 136 struct zfcp_port *port;
141 struct zfcp_unit *unit = NULL; 137 struct zfcp_unit *unit;
142 138
143 read_lock_irqsave(&adapter->port_list_lock, flags); 139 port = zfcp_get_port_by_wwpn(adapter, rport->port_name);
144 list_for_each_entry(port, &adapter->port_list, list) { 140 if (!port)
145 if (!port->rport || (id != port->rport->scsi_target_id)) 141 return -ENXIO;
146 continue;
147 unit = zfcp_unit_find(port, lun);
148 if (unit)
149 break;
150 }
151 read_unlock_irqrestore(&adapter->port_list_lock, flags);
152 142
153 return unit; 143 unit = zfcp_unit_find(port, zfcp_scsi_dev_lun(sdev));
154} 144 if (unit)
145 put_device(&unit->dev);
146 else {
147 put_device(&port->dev);
148 return -ENXIO;
149 }
155 150
156static int zfcp_scsi_slave_alloc(struct scsi_device *sdp) 151 zfcp_sdev->port = port;
157{ 152 zfcp_sdev->latencies.write.channel.min = 0xFFFFFFFF;
158 struct zfcp_adapter *adapter; 153 zfcp_sdev->latencies.write.fabric.min = 0xFFFFFFFF;
159 struct zfcp_unit *unit; 154 zfcp_sdev->latencies.read.channel.min = 0xFFFFFFFF;
160 u64 lun; 155 zfcp_sdev->latencies.read.fabric.min = 0xFFFFFFFF;
156 zfcp_sdev->latencies.cmd.channel.min = 0xFFFFFFFF;
157 zfcp_sdev->latencies.cmd.fabric.min = 0xFFFFFFFF;
158 spin_lock_init(&zfcp_sdev->latencies.lock);
161 159
162 adapter = (struct zfcp_adapter *) sdp->host->hostdata[0]; 160 zfcp_erp_modify_lun_status(sdev, "scsla_0", NULL,
163 if (!adapter) 161 ZFCP_STATUS_COMMON_RUNNING, ZFCP_SET);
164 goto out; 162 zfcp_erp_lun_reopen(sdev, 0, "scsla_1", NULL);
163 zfcp_erp_wait(port->adapter);
165 164
166 int_to_scsilun(sdp->lun, (struct scsi_lun *)&lun); 165 return 0;
167 unit = zfcp_unit_lookup(adapter, sdp->id, lun);
168 if (unit) {
169 sdp->hostdata = unit;
170 unit->device = sdp;
171 return 0;
172 }
173out:
174 return -ENXIO;
175} 166}
176 167
177static int zfcp_scsi_eh_abort_handler(struct scsi_cmnd *scpnt) 168static int zfcp_scsi_eh_abort_handler(struct scsi_cmnd *scpnt)
@@ -179,7 +170,6 @@ static int zfcp_scsi_eh_abort_handler(struct scsi_cmnd *scpnt)
179 struct Scsi_Host *scsi_host = scpnt->device->host; 170 struct Scsi_Host *scsi_host = scpnt->device->host;
180 struct zfcp_adapter *adapter = 171 struct zfcp_adapter *adapter =
181 (struct zfcp_adapter *) scsi_host->hostdata[0]; 172 (struct zfcp_adapter *) scsi_host->hostdata[0];
182 struct zfcp_unit *unit = scpnt->device->hostdata;
183 struct zfcp_fsf_req *old_req, *abrt_req; 173 struct zfcp_fsf_req *old_req, *abrt_req;
184 unsigned long flags; 174 unsigned long flags;
185 unsigned long old_reqid = (unsigned long) scpnt->host_scribble; 175 unsigned long old_reqid = (unsigned long) scpnt->host_scribble;
@@ -203,7 +193,7 @@ static int zfcp_scsi_eh_abort_handler(struct scsi_cmnd *scpnt)
203 write_unlock_irqrestore(&adapter->abort_lock, flags); 193 write_unlock_irqrestore(&adapter->abort_lock, flags);
204 194
205 while (retry--) { 195 while (retry--) {
206 abrt_req = zfcp_fsf_abort_fcp_command(old_reqid, unit); 196 abrt_req = zfcp_fsf_abort_fcp_cmnd(scpnt);
207 if (abrt_req) 197 if (abrt_req)
208 break; 198 break;
209 199
@@ -238,14 +228,14 @@ static int zfcp_scsi_eh_abort_handler(struct scsi_cmnd *scpnt)
238 228
239static int zfcp_task_mgmt_function(struct scsi_cmnd *scpnt, u8 tm_flags) 229static int zfcp_task_mgmt_function(struct scsi_cmnd *scpnt, u8 tm_flags)
240{ 230{
241 struct zfcp_unit *unit = scpnt->device->hostdata; 231 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(scpnt->device);
242 struct zfcp_adapter *adapter = unit->port->adapter; 232 struct zfcp_adapter *adapter = zfcp_sdev->port->adapter;
243 struct zfcp_fsf_req *fsf_req = NULL; 233 struct zfcp_fsf_req *fsf_req = NULL;
244 int retval = SUCCESS, ret; 234 int retval = SUCCESS, ret;
245 int retry = 3; 235 int retry = 3;
246 236
247 while (retry--) { 237 while (retry--) {
248 fsf_req = zfcp_fsf_send_fcp_ctm(unit, tm_flags); 238 fsf_req = zfcp_fsf_fcp_task_mgmt(scpnt, tm_flags);
249 if (fsf_req) 239 if (fsf_req)
250 break; 240 break;
251 241
@@ -256,7 +246,7 @@ static int zfcp_task_mgmt_function(struct scsi_cmnd *scpnt, u8 tm_flags)
256 246
257 if (!(atomic_read(&adapter->status) & 247 if (!(atomic_read(&adapter->status) &
258 ZFCP_STATUS_COMMON_RUNNING)) { 248 ZFCP_STATUS_COMMON_RUNNING)) {
259 zfcp_dbf_scsi_devreset("nres", tm_flags, unit, scpnt); 249 zfcp_dbf_scsi_devreset("nres", scpnt, tm_flags);
260 return SUCCESS; 250 return SUCCESS;
261 } 251 }
262 } 252 }
@@ -266,10 +256,10 @@ static int zfcp_task_mgmt_function(struct scsi_cmnd *scpnt, u8 tm_flags)
266 wait_for_completion(&fsf_req->completion); 256 wait_for_completion(&fsf_req->completion);
267 257
268 if (fsf_req->status & ZFCP_STATUS_FSFREQ_TMFUNCFAILED) { 258 if (fsf_req->status & ZFCP_STATUS_FSFREQ_TMFUNCFAILED) {
269 zfcp_dbf_scsi_devreset("fail", tm_flags, unit, scpnt); 259 zfcp_dbf_scsi_devreset("fail", scpnt, tm_flags);
270 retval = FAILED; 260 retval = FAILED;
271 } else 261 } else
272 zfcp_dbf_scsi_devreset("okay", tm_flags, unit, scpnt); 262 zfcp_dbf_scsi_devreset("okay", scpnt, tm_flags);
273 263
274 zfcp_fsf_req_free(fsf_req); 264 zfcp_fsf_req_free(fsf_req);
275 return retval; 265 return retval;
@@ -287,8 +277,8 @@ static int zfcp_scsi_eh_target_reset_handler(struct scsi_cmnd *scpnt)
287 277
288static int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt) 278static int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt)
289{ 279{
290 struct zfcp_unit *unit = scpnt->device->hostdata; 280 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(scpnt->device);
291 struct zfcp_adapter *adapter = unit->port->adapter; 281 struct zfcp_adapter *adapter = zfcp_sdev->port->adapter;
292 int ret; 282 int ret;
293 283
294 zfcp_erp_adapter_reopen(adapter, 0, "schrh_1", scpnt); 284 zfcp_erp_adapter_reopen(adapter, 0, "schrh_1", scpnt);