blob: 577e15708598272ac50b591198ef7db7f130e09c [file] [log] [blame]
Swen Schillig41fa2ad2007-09-07 09:15:31 +02001/*
Christof Schmitt553448f2008-06-10 18:20:58 +02002 * zfcp device driver
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
Christof Schmitt553448f2008-06-10 18:20:58 +02004 * Error Recovery Procedures (ERP).
Swen Schillig41fa2ad2007-09-07 09:15:31 +02005 *
Christof Schmitta2fa0ae2009-03-02 13:09:08 +01006 * Copyright IBM Corporation 2002, 2009
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 */
8
Christof Schmittecf39d42008-12-25 13:39:53 +01009#define KMSG_COMPONENT "zfcp"
10#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
11
Christof Schmitt347c6a92009-08-18 15:43:25 +020012#include <linux/kthread.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include "zfcp_ext.h"
14
Christof Schmitt287ac012008-07-02 10:56:40 +020015#define ZFCP_MAX_ERPS 3
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
Christof Schmitt287ac012008-07-02 10:56:40 +020017enum zfcp_erp_act_flags {
18 ZFCP_STATUS_ERP_TIMEDOUT = 0x10000000,
19 ZFCP_STATUS_ERP_CLOSE_ONLY = 0x01000000,
20 ZFCP_STATUS_ERP_DISMISSING = 0x00100000,
21 ZFCP_STATUS_ERP_DISMISSED = 0x00200000,
22 ZFCP_STATUS_ERP_LOWMEM = 0x00400000,
23};
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
Christof Schmitt287ac012008-07-02 10:56:40 +020025enum zfcp_erp_steps {
26 ZFCP_ERP_STEP_UNINITIALIZED = 0x0000,
27 ZFCP_ERP_STEP_FSF_XCONFIG = 0x0001,
28 ZFCP_ERP_STEP_PHYS_PORT_CLOSING = 0x0010,
29 ZFCP_ERP_STEP_PORT_CLOSING = 0x0100,
Christof Schmitt287ac012008-07-02 10:56:40 +020030 ZFCP_ERP_STEP_PORT_OPENING = 0x0800,
31 ZFCP_ERP_STEP_UNIT_CLOSING = 0x1000,
32 ZFCP_ERP_STEP_UNIT_OPENING = 0x2000,
33};
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Christof Schmitt287ac012008-07-02 10:56:40 +020035enum zfcp_erp_act_type {
36 ZFCP_ERP_ACTION_REOPEN_UNIT = 1,
37 ZFCP_ERP_ACTION_REOPEN_PORT = 2,
38 ZFCP_ERP_ACTION_REOPEN_PORT_FORCED = 3,
39 ZFCP_ERP_ACTION_REOPEN_ADAPTER = 4,
40};
Linus Torvalds1da177e2005-04-16 15:20:36 -070041
Christof Schmitt287ac012008-07-02 10:56:40 +020042enum zfcp_erp_act_state {
43 ZFCP_ERP_ACTION_RUNNING = 1,
44 ZFCP_ERP_ACTION_READY = 2,
45};
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
Christof Schmitt287ac012008-07-02 10:56:40 +020047enum zfcp_erp_act_result {
48 ZFCP_ERP_SUCCEEDED = 0,
49 ZFCP_ERP_FAILED = 1,
50 ZFCP_ERP_CONTINUES = 2,
51 ZFCP_ERP_EXIT = 3,
52 ZFCP_ERP_DISMISSED = 4,
53 ZFCP_ERP_NOMEM = 5,
54};
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
Christof Schmitt287ac012008-07-02 10:56:40 +020056static void zfcp_erp_adapter_block(struct zfcp_adapter *adapter, int mask)
Andreas Herrmann2abbe862006-09-18 22:29:56 +020057{
Swen Schillig5ffd51a2009-03-02 13:09:04 +010058 zfcp_erp_modify_adapter_status(adapter, "erablk1", NULL,
Christof Schmitt287ac012008-07-02 10:56:40 +020059 ZFCP_STATUS_COMMON_UNBLOCKED | mask,
60 ZFCP_CLEAR);
Andreas Herrmann2abbe862006-09-18 22:29:56 +020061}
Linus Torvalds1da177e2005-04-16 15:20:36 -070062
Christof Schmitt287ac012008-07-02 10:56:40 +020063static int zfcp_erp_action_exists(struct zfcp_erp_action *act)
Linus Torvalds1da177e2005-04-16 15:20:36 -070064{
Christof Schmitt287ac012008-07-02 10:56:40 +020065 struct zfcp_erp_action *curr_act;
66
67 list_for_each_entry(curr_act, &act->adapter->erp_running_head, list)
68 if (act == curr_act)
69 return ZFCP_ERP_ACTION_RUNNING;
70 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070071}
72
Christof Schmitt287ac012008-07-02 10:56:40 +020073static void zfcp_erp_action_ready(struct zfcp_erp_action *act)
Linus Torvalds1da177e2005-04-16 15:20:36 -070074{
Christof Schmitt287ac012008-07-02 10:56:40 +020075 struct zfcp_adapter *adapter = act->adapter;
76
77 list_move(&act->list, &act->adapter->erp_ready_head);
Swen Schillig57717102009-08-18 15:43:21 +020078 zfcp_dbf_rec_action("erardy1", act);
Christof Schmitt347c6a92009-08-18 15:43:25 +020079 wake_up(&adapter->erp_ready_wq);
Swen Schillig57717102009-08-18 15:43:21 +020080 zfcp_dbf_rec_thread("erardy2", adapter->dbf);
Linus Torvalds1da177e2005-04-16 15:20:36 -070081}
82
Christof Schmitt287ac012008-07-02 10:56:40 +020083static void zfcp_erp_action_dismiss(struct zfcp_erp_action *act)
Linus Torvalds1da177e2005-04-16 15:20:36 -070084{
Christof Schmitt287ac012008-07-02 10:56:40 +020085 act->status |= ZFCP_STATUS_ERP_DISMISSED;
86 if (zfcp_erp_action_exists(act) == ZFCP_ERP_ACTION_RUNNING)
87 zfcp_erp_action_ready(act);
88}
Linus Torvalds1da177e2005-04-16 15:20:36 -070089
Christof Schmitt287ac012008-07-02 10:56:40 +020090static void zfcp_erp_action_dismiss_unit(struct zfcp_unit *unit)
91{
92 if (atomic_read(&unit->status) & ZFCP_STATUS_COMMON_ERP_INUSE)
93 zfcp_erp_action_dismiss(&unit->erp_action);
94}
95
96static void zfcp_erp_action_dismiss_port(struct zfcp_port *port)
97{
98 struct zfcp_unit *unit;
99
100 if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_INUSE)
101 zfcp_erp_action_dismiss(&port->erp_action);
102 else
103 list_for_each_entry(unit, &port->unit_list_head, list)
104 zfcp_erp_action_dismiss_unit(unit);
105}
106
107static void zfcp_erp_action_dismiss_adapter(struct zfcp_adapter *adapter)
108{
109 struct zfcp_port *port;
110
111 if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_ERP_INUSE)
112 zfcp_erp_action_dismiss(&adapter->erp_action);
113 else
114 list_for_each_entry(port, &adapter->port_list_head, list)
115 zfcp_erp_action_dismiss_port(port);
116}
117
118static int zfcp_erp_required_act(int want, struct zfcp_adapter *adapter,
119 struct zfcp_port *port,
120 struct zfcp_unit *unit)
121{
122 int need = want;
123 int u_status, p_status, a_status;
124
125 switch (want) {
126 case ZFCP_ERP_ACTION_REOPEN_UNIT:
127 u_status = atomic_read(&unit->status);
128 if (u_status & ZFCP_STATUS_COMMON_ERP_INUSE)
129 return 0;
130 p_status = atomic_read(&port->status);
131 if (!(p_status & ZFCP_STATUS_COMMON_RUNNING) ||
132 p_status & ZFCP_STATUS_COMMON_ERP_FAILED)
133 return 0;
134 if (!(p_status & ZFCP_STATUS_COMMON_UNBLOCKED))
135 need = ZFCP_ERP_ACTION_REOPEN_PORT;
136 /* fall through */
137 case ZFCP_ERP_ACTION_REOPEN_PORT:
138 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
139 p_status = atomic_read(&port->status);
140 if (p_status & ZFCP_STATUS_COMMON_ERP_INUSE)
141 return 0;
142 a_status = atomic_read(&adapter->status);
143 if (!(a_status & ZFCP_STATUS_COMMON_RUNNING) ||
144 a_status & ZFCP_STATUS_COMMON_ERP_FAILED)
145 return 0;
146 if (!(a_status & ZFCP_STATUS_COMMON_UNBLOCKED))
147 need = ZFCP_ERP_ACTION_REOPEN_ADAPTER;
148 /* fall through */
149 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
150 a_status = atomic_read(&adapter->status);
151 if (a_status & ZFCP_STATUS_COMMON_ERP_INUSE)
152 return 0;
153 }
154
155 return need;
156}
157
158static struct zfcp_erp_action *zfcp_erp_setup_act(int need,
159 struct zfcp_adapter *adapter,
160 struct zfcp_port *port,
161 struct zfcp_unit *unit)
162{
163 struct zfcp_erp_action *erp_action;
164 u32 status = 0;
165
166 switch (need) {
167 case ZFCP_ERP_ACTION_REOPEN_UNIT:
168 zfcp_unit_get(unit);
169 atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &unit->status);
170 erp_action = &unit->erp_action;
171 if (!(atomic_read(&unit->status) & ZFCP_STATUS_COMMON_RUNNING))
172 status = ZFCP_STATUS_ERP_CLOSE_ONLY;
173 break;
174
175 case ZFCP_ERP_ACTION_REOPEN_PORT:
176 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
177 zfcp_port_get(port);
178 zfcp_erp_action_dismiss_port(port);
179 atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &port->status);
180 erp_action = &port->erp_action;
181 if (!(atomic_read(&port->status) & ZFCP_STATUS_COMMON_RUNNING))
182 status = ZFCP_STATUS_ERP_CLOSE_ONLY;
183 break;
184
185 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
186 zfcp_adapter_get(adapter);
187 zfcp_erp_action_dismiss_adapter(adapter);
188 atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &adapter->status);
189 erp_action = &adapter->erp_action;
190 if (!(atomic_read(&adapter->status) &
191 ZFCP_STATUS_COMMON_RUNNING))
192 status = ZFCP_STATUS_ERP_CLOSE_ONLY;
193 break;
194
195 default:
196 return NULL;
197 }
198
199 memset(erp_action, 0, sizeof(struct zfcp_erp_action));
200 erp_action->adapter = adapter;
201 erp_action->port = port;
202 erp_action->unit = unit;
203 erp_action->action = need;
204 erp_action->status = status;
205
206 return erp_action;
207}
208
209static int zfcp_erp_action_enqueue(int want, struct zfcp_adapter *adapter,
210 struct zfcp_port *port,
Swen Schillig5ffd51a2009-03-02 13:09:04 +0100211 struct zfcp_unit *unit, char *id, void *ref)
Christof Schmitt287ac012008-07-02 10:56:40 +0200212{
213 int retval = 1, need;
214 struct zfcp_erp_action *act = NULL;
215
Christof Schmitt347c6a92009-08-18 15:43:25 +0200216 if (!adapter->erp_thread)
Christof Schmitt287ac012008-07-02 10:56:40 +0200217 return -EIO;
218
219 need = zfcp_erp_required_act(want, adapter, port, unit);
220 if (!need)
221 goto out;
222
223 atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING, &adapter->status);
224 act = zfcp_erp_setup_act(need, adapter, port, unit);
225 if (!act)
226 goto out;
227 ++adapter->erp_total_count;
228 list_add_tail(&act->list, &adapter->erp_ready_head);
Christof Schmitt347c6a92009-08-18 15:43:25 +0200229 wake_up(&adapter->erp_ready_wq);
Swen Schillig57717102009-08-18 15:43:21 +0200230 zfcp_dbf_rec_thread("eracte1", adapter->dbf);
Christof Schmitt287ac012008-07-02 10:56:40 +0200231 retval = 0;
232 out:
Swen Schillig57717102009-08-18 15:43:21 +0200233 zfcp_dbf_rec_trigger(id, ref, want, need, act, adapter, port, unit);
Christof Schmitt287ac012008-07-02 10:56:40 +0200234 return retval;
235}
236
237static int _zfcp_erp_adapter_reopen(struct zfcp_adapter *adapter,
Swen Schillig5ffd51a2009-03-02 13:09:04 +0100238 int clear_mask, char *id, void *ref)
Christof Schmitt287ac012008-07-02 10:56:40 +0200239{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 zfcp_erp_adapter_block(adapter, clear_mask);
Christof Schmitta2fa0ae2009-03-02 13:09:08 +0100241 zfcp_scsi_schedule_rports_block(adapter);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242
Christof Schmitt287ac012008-07-02 10:56:40 +0200243 /* ensure propagation of failed status to new devices */
244 if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_ERP_FAILED) {
Swen Schillig5ffd51a2009-03-02 13:09:04 +0100245 zfcp_erp_adapter_failed(adapter, "erareo1", NULL);
Christof Schmitt287ac012008-07-02 10:56:40 +0200246 return -EIO;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247 }
Christof Schmitt287ac012008-07-02 10:56:40 +0200248 return zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_ADAPTER,
249 adapter, NULL, NULL, id, ref);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250}
251
252/**
Christof Schmitt287ac012008-07-02 10:56:40 +0200253 * zfcp_erp_adapter_reopen - Reopen adapter.
254 * @adapter: Adapter to reopen.
255 * @clear: Status flags to clear.
256 * @id: Id for debug trace event.
257 * @ref: Reference for debug trace event.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258 */
Christof Schmitt287ac012008-07-02 10:56:40 +0200259void zfcp_erp_adapter_reopen(struct zfcp_adapter *adapter, int clear,
Swen Schillig5ffd51a2009-03-02 13:09:04 +0100260 char *id, void *ref)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261{
Christof Schmitt287ac012008-07-02 10:56:40 +0200262 unsigned long flags;
263
264 read_lock_irqsave(&zfcp_data.config_lock, flags);
265 write_lock(&adapter->erp_lock);
266 _zfcp_erp_adapter_reopen(adapter, clear, id, ref);
267 write_unlock(&adapter->erp_lock);
268 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
269}
270
271/**
272 * zfcp_erp_adapter_shutdown - Shutdown adapter.
273 * @adapter: Adapter to shut down.
274 * @clear: Status flags to clear.
275 * @id: Id for debug trace event.
276 * @ref: Reference for debug trace event.
277 */
278void zfcp_erp_adapter_shutdown(struct zfcp_adapter *adapter, int clear,
Swen Schillig5ffd51a2009-03-02 13:09:04 +0100279 char *id, void *ref)
Christof Schmitt287ac012008-07-02 10:56:40 +0200280{
281 int flags = ZFCP_STATUS_COMMON_RUNNING | ZFCP_STATUS_COMMON_ERP_FAILED;
282 zfcp_erp_adapter_reopen(adapter, clear | flags, id, ref);
283}
284
285/**
286 * zfcp_erp_port_shutdown - Shutdown port
287 * @port: Port to shut down.
288 * @clear: Status flags to clear.
289 * @id: Id for debug trace event.
290 * @ref: Reference for debug trace event.
291 */
Swen Schillig5ffd51a2009-03-02 13:09:04 +0100292void zfcp_erp_port_shutdown(struct zfcp_port *port, int clear, char *id,
293 void *ref)
Christof Schmitt287ac012008-07-02 10:56:40 +0200294{
295 int flags = ZFCP_STATUS_COMMON_RUNNING | ZFCP_STATUS_COMMON_ERP_FAILED;
296 zfcp_erp_port_reopen(port, clear | flags, id, ref);
297}
298
299/**
300 * zfcp_erp_unit_shutdown - Shutdown unit
301 * @unit: Unit to shut down.
302 * @clear: Status flags to clear.
303 * @id: Id for debug trace event.
304 * @ref: Reference for debug trace event.
305 */
Swen Schillig5ffd51a2009-03-02 13:09:04 +0100306void zfcp_erp_unit_shutdown(struct zfcp_unit *unit, int clear, char *id,
307 void *ref)
Christof Schmitt287ac012008-07-02 10:56:40 +0200308{
309 int flags = ZFCP_STATUS_COMMON_RUNNING | ZFCP_STATUS_COMMON_ERP_FAILED;
310 zfcp_erp_unit_reopen(unit, clear | flags, id, ref);
311}
312
313static void zfcp_erp_port_block(struct zfcp_port *port, int clear)
314{
Swen Schillig5ffd51a2009-03-02 13:09:04 +0100315 zfcp_erp_modify_port_status(port, "erpblk1", NULL,
Christof Schmitt287ac012008-07-02 10:56:40 +0200316 ZFCP_STATUS_COMMON_UNBLOCKED | clear,
317 ZFCP_CLEAR);
318}
319
320static void _zfcp_erp_port_forced_reopen(struct zfcp_port *port,
Swen Schillig5ffd51a2009-03-02 13:09:04 +0100321 int clear, char *id, void *ref)
Christof Schmitt287ac012008-07-02 10:56:40 +0200322{
323 zfcp_erp_port_block(port, clear);
Christof Schmitta2fa0ae2009-03-02 13:09:08 +0100324 zfcp_scsi_schedule_rport_block(port);
Christof Schmitt287ac012008-07-02 10:56:40 +0200325
326 if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_FAILED)
327 return;
328
329 zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_PORT_FORCED,
330 port->adapter, port, NULL, id, ref);
331}
332
333/**
334 * zfcp_erp_port_forced_reopen - Forced close of port and open again
335 * @port: Port to force close and to reopen.
336 * @id: Id for debug trace event.
337 * @ref: Reference for debug trace event.
338 */
Swen Schillig5ffd51a2009-03-02 13:09:04 +0100339void zfcp_erp_port_forced_reopen(struct zfcp_port *port, int clear, char *id,
Christof Schmitt287ac012008-07-02 10:56:40 +0200340 void *ref)
341{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342 unsigned long flags;
343 struct zfcp_adapter *adapter = port->adapter;
344
345 read_lock_irqsave(&zfcp_data.config_lock, flags);
346 write_lock(&adapter->erp_lock);
Christof Schmitt287ac012008-07-02 10:56:40 +0200347 _zfcp_erp_port_forced_reopen(port, clear, id, ref);
348 write_unlock(&adapter->erp_lock);
349 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
350}
351
Swen Schillig5ffd51a2009-03-02 13:09:04 +0100352static int _zfcp_erp_port_reopen(struct zfcp_port *port, int clear, char *id,
Christof Schmitt287ac012008-07-02 10:56:40 +0200353 void *ref)
354{
355 zfcp_erp_port_block(port, clear);
Christof Schmitta2fa0ae2009-03-02 13:09:08 +0100356 zfcp_scsi_schedule_rport_block(port);
Christof Schmitt287ac012008-07-02 10:56:40 +0200357
358 if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_FAILED) {
359 /* ensure propagation of failed status to new devices */
Swen Schillig5ffd51a2009-03-02 13:09:04 +0100360 zfcp_erp_port_failed(port, "erpreo1", NULL);
Christof Schmitt287ac012008-07-02 10:56:40 +0200361 return -EIO;
362 }
363
364 return zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_PORT,
365 port->adapter, port, NULL, id, ref);
366}
367
368/**
369 * zfcp_erp_port_reopen - trigger remote port recovery
370 * @port: port to recover
371 * @clear_mask: flags in port status to be cleared
372 *
373 * Returns 0 if recovery has been triggered, < 0 if not.
374 */
Swen Schillig5ffd51a2009-03-02 13:09:04 +0100375int zfcp_erp_port_reopen(struct zfcp_port *port, int clear, char *id, void *ref)
Christof Schmitt287ac012008-07-02 10:56:40 +0200376{
377 unsigned long flags;
378 int retval;
379 struct zfcp_adapter *adapter = port->adapter;
380
381 read_lock_irqsave(&zfcp_data.config_lock, flags);
382 write_lock(&adapter->erp_lock);
383 retval = _zfcp_erp_port_reopen(port, clear, id, ref);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384 write_unlock(&adapter->erp_lock);
385 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
386
387 return retval;
388}
389
Christof Schmitt287ac012008-07-02 10:56:40 +0200390static void zfcp_erp_unit_block(struct zfcp_unit *unit, int clear_mask)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391{
Swen Schillig5ffd51a2009-03-02 13:09:04 +0100392 zfcp_erp_modify_unit_status(unit, "erublk1", NULL,
Christof Schmitt287ac012008-07-02 10:56:40 +0200393 ZFCP_STATUS_COMMON_UNBLOCKED | clear_mask,
394 ZFCP_CLEAR);
395}
396
Swen Schillig5ffd51a2009-03-02 13:09:04 +0100397static void _zfcp_erp_unit_reopen(struct zfcp_unit *unit, int clear, char *id,
Christof Schmitt287ac012008-07-02 10:56:40 +0200398 void *ref)
399{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 struct zfcp_adapter *adapter = unit->port->adapter;
401
Christof Schmitt287ac012008-07-02 10:56:40 +0200402 zfcp_erp_unit_block(unit, clear);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403
Christof Schmitt287ac012008-07-02 10:56:40 +0200404 if (atomic_read(&unit->status) & ZFCP_STATUS_COMMON_ERP_FAILED)
405 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406
Christof Schmitt287ac012008-07-02 10:56:40 +0200407 zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_UNIT,
408 adapter, unit->port, unit, id, ref);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409}
410
411/**
412 * zfcp_erp_unit_reopen - initiate reopen of a unit
413 * @unit: unit to be reopened
414 * @clear_mask: specifies flags in unit status to be cleared
415 * Return: 0 on success, < 0 on error
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416 */
Swen Schillig5ffd51a2009-03-02 13:09:04 +0100417void zfcp_erp_unit_reopen(struct zfcp_unit *unit, int clear, char *id,
418 void *ref)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420 unsigned long flags;
Christof Schmitt287ac012008-07-02 10:56:40 +0200421 struct zfcp_port *port = unit->port;
422 struct zfcp_adapter *adapter = port->adapter;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423
424 read_lock_irqsave(&zfcp_data.config_lock, flags);
425 write_lock(&adapter->erp_lock);
Christof Schmitt287ac012008-07-02 10:56:40 +0200426 _zfcp_erp_unit_reopen(unit, clear, id, ref);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427 write_unlock(&adapter->erp_lock);
428 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429}
430
Christof Schmitt287ac012008-07-02 10:56:40 +0200431static int status_change_set(unsigned long mask, atomic_t *status)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432{
Christof Schmitt287ac012008-07-02 10:56:40 +0200433 return (atomic_read(status) ^ mask) & mask;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434}
435
Christof Schmitt287ac012008-07-02 10:56:40 +0200436static int status_change_clear(unsigned long mask, atomic_t *status)
Martin Peschke698ec0162008-03-27 14:22:02 +0100437{
Christof Schmitt287ac012008-07-02 10:56:40 +0200438 return atomic_read(status) & mask;
Martin Peschke698ec0162008-03-27 14:22:02 +0100439}
440
Andreas Herrmannf6c0e7a2006-08-02 11:05:52 +0200441static void zfcp_erp_adapter_unblock(struct zfcp_adapter *adapter)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442{
Christof Schmitt287ac012008-07-02 10:56:40 +0200443 if (status_change_set(ZFCP_STATUS_COMMON_UNBLOCKED, &adapter->status))
Swen Schillig57717102009-08-18 15:43:21 +0200444 zfcp_dbf_rec_adapter("eraubl1", NULL, adapter->dbf);
Christof Schmitt287ac012008-07-02 10:56:40 +0200445 atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &adapter->status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446}
447
Christof Schmitt287ac012008-07-02 10:56:40 +0200448static void zfcp_erp_port_unblock(struct zfcp_port *port)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449{
Christof Schmitt287ac012008-07-02 10:56:40 +0200450 if (status_change_set(ZFCP_STATUS_COMMON_UNBLOCKED, &port->status))
Swen Schillig57717102009-08-18 15:43:21 +0200451 zfcp_dbf_rec_port("erpubl1", NULL, port);
Christof Schmitt287ac012008-07-02 10:56:40 +0200452 atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &port->status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453}
454
Christof Schmitt287ac012008-07-02 10:56:40 +0200455static void zfcp_erp_unit_unblock(struct zfcp_unit *unit)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456{
Christof Schmitt287ac012008-07-02 10:56:40 +0200457 if (status_change_set(ZFCP_STATUS_COMMON_UNBLOCKED, &unit->status))
Swen Schillig57717102009-08-18 15:43:21 +0200458 zfcp_dbf_rec_unit("eruubl1", NULL, unit);
Christof Schmitt287ac012008-07-02 10:56:40 +0200459 atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &unit->status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460}
461
Christof Schmitt287ac012008-07-02 10:56:40 +0200462static void zfcp_erp_action_to_running(struct zfcp_erp_action *erp_action)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463{
Christof Schmitt287ac012008-07-02 10:56:40 +0200464 list_move(&erp_action->list, &erp_action->adapter->erp_running_head);
Swen Schillig57717102009-08-18 15:43:21 +0200465 zfcp_dbf_rec_action("erator1", erp_action);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466}
467
Christof Schmitt287ac012008-07-02 10:56:40 +0200468static void zfcp_erp_strategy_check_fsfreq(struct zfcp_erp_action *act)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469{
Christof Schmitt287ac012008-07-02 10:56:40 +0200470 struct zfcp_adapter *adapter = act->adapter;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471
Christof Schmitt287ac012008-07-02 10:56:40 +0200472 if (!act->fsf_req)
473 return;
474
475 spin_lock(&adapter->req_list_lock);
476 if (zfcp_reqlist_find_safe(adapter, act->fsf_req) &&
477 act->fsf_req->erp_action == act) {
478 if (act->status & (ZFCP_STATUS_ERP_DISMISSED |
479 ZFCP_STATUS_ERP_TIMEDOUT)) {
480 act->fsf_req->status |= ZFCP_STATUS_FSFREQ_DISMISSED;
Swen Schillig57717102009-08-18 15:43:21 +0200481 zfcp_dbf_rec_action("erscf_1", act);
Martin Petermann7ea633f2008-11-04 16:35:11 +0100482 act->fsf_req->erp_action = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483 }
Christof Schmitt287ac012008-07-02 10:56:40 +0200484 if (act->status & ZFCP_STATUS_ERP_TIMEDOUT)
Swen Schillig57717102009-08-18 15:43:21 +0200485 zfcp_dbf_rec_action("erscf_2", act);
Swen Schillig058b8642009-08-18 15:43:14 +0200486 if (act->fsf_req->status & ZFCP_STATUS_FSFREQ_DISMISSED)
Christof Schmitt287ac012008-07-02 10:56:40 +0200487 act->fsf_req = NULL;
488 } else
489 act->fsf_req = NULL;
490 spin_unlock(&adapter->req_list_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491}
492
Andreas Herrmannf6c0e7a2006-08-02 11:05:52 +0200493/**
Christof Schmitt287ac012008-07-02 10:56:40 +0200494 * zfcp_erp_notify - Trigger ERP action.
495 * @erp_action: ERP action to continue.
496 * @set_mask: ERP action status flags to set.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497 */
Christof Schmitt287ac012008-07-02 10:56:40 +0200498void zfcp_erp_notify(struct zfcp_erp_action *erp_action, unsigned long set_mask)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499{
500 struct zfcp_adapter *adapter = erp_action->adapter;
501 unsigned long flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502
503 write_lock_irqsave(&adapter->erp_lock, flags);
Christof Schmitt287ac012008-07-02 10:56:40 +0200504 if (zfcp_erp_action_exists(erp_action) == ZFCP_ERP_ACTION_RUNNING) {
505 erp_action->status |= set_mask;
506 zfcp_erp_action_ready(erp_action);
507 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700508 write_unlock_irqrestore(&adapter->erp_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509}
510
Andreas Herrmannf6c0e7a2006-08-02 11:05:52 +0200511/**
Christof Schmitt287ac012008-07-02 10:56:40 +0200512 * zfcp_erp_timeout_handler - Trigger ERP action from timed out ERP request
513 * @data: ERP action (from timer data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700514 */
Christof Schmitt287ac012008-07-02 10:56:40 +0200515void zfcp_erp_timeout_handler(unsigned long data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516{
Christof Schmitt287ac012008-07-02 10:56:40 +0200517 struct zfcp_erp_action *act = (struct zfcp_erp_action *) data;
518 zfcp_erp_notify(act, ZFCP_STATUS_ERP_TIMEDOUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519}
520
Christof Schmitt287ac012008-07-02 10:56:40 +0200521static void zfcp_erp_memwait_handler(unsigned long data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522{
Christof Schmitt287ac012008-07-02 10:56:40 +0200523 zfcp_erp_notify((struct zfcp_erp_action *)data, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524}
525
Christof Schmitt287ac012008-07-02 10:56:40 +0200526static void zfcp_erp_strategy_memwait(struct zfcp_erp_action *erp_action)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528 init_timer(&erp_action->timer);
529 erp_action->timer.function = zfcp_erp_memwait_handler;
530 erp_action->timer.data = (unsigned long) erp_action;
Christof Schmitt287ac012008-07-02 10:56:40 +0200531 erp_action->timer.expires = jiffies + HZ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532 add_timer(&erp_action->timer);
Christof Schmitt287ac012008-07-02 10:56:40 +0200533}
534
535static void _zfcp_erp_port_reopen_all(struct zfcp_adapter *adapter,
Swen Schillig5ffd51a2009-03-02 13:09:04 +0100536 int clear, char *id, void *ref)
Christof Schmitt287ac012008-07-02 10:56:40 +0200537{
538 struct zfcp_port *port;
539
540 list_for_each_entry(port, &adapter->port_list_head, list)
Swen Schillig5ab944f2008-10-01 12:42:17 +0200541 _zfcp_erp_port_reopen(port, clear, id, ref);
Christof Schmitt287ac012008-07-02 10:56:40 +0200542}
543
Swen Schillig5ffd51a2009-03-02 13:09:04 +0100544static void _zfcp_erp_unit_reopen_all(struct zfcp_port *port, int clear,
545 char *id, void *ref)
Christof Schmitt287ac012008-07-02 10:56:40 +0200546{
547 struct zfcp_unit *unit;
548
549 list_for_each_entry(unit, &port->unit_list_head, list)
550 _zfcp_erp_unit_reopen(unit, clear, id, ref);
551}
552
Christof Schmitt85600f72009-07-13 15:06:09 +0200553static void zfcp_erp_strategy_followup_failed(struct zfcp_erp_action *act)
Christof Schmitt287ac012008-07-02 10:56:40 +0200554{
Christof Schmitt287ac012008-07-02 10:56:40 +0200555 switch (act->action) {
Christof Schmitt287ac012008-07-02 10:56:40 +0200556 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
Christof Schmitt85600f72009-07-13 15:06:09 +0200557 _zfcp_erp_adapter_reopen(act->adapter, 0, "ersff_1", NULL);
Christof Schmitt287ac012008-07-02 10:56:40 +0200558 break;
Christof Schmitt287ac012008-07-02 10:56:40 +0200559 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
Christof Schmitt85600f72009-07-13 15:06:09 +0200560 _zfcp_erp_port_forced_reopen(act->port, 0, "ersff_2", NULL);
Christof Schmitt287ac012008-07-02 10:56:40 +0200561 break;
Christof Schmitt287ac012008-07-02 10:56:40 +0200562 case ZFCP_ERP_ACTION_REOPEN_PORT:
Christof Schmitt85600f72009-07-13 15:06:09 +0200563 _zfcp_erp_port_reopen(act->port, 0, "ersff_3", NULL);
Christof Schmitt287ac012008-07-02 10:56:40 +0200564 break;
Christof Schmitt287ac012008-07-02 10:56:40 +0200565 case ZFCP_ERP_ACTION_REOPEN_UNIT:
Christof Schmitt85600f72009-07-13 15:06:09 +0200566 _zfcp_erp_unit_reopen(act->unit, 0, "ersff_4", NULL);
567 break;
568 }
569}
570
571static void zfcp_erp_strategy_followup_success(struct zfcp_erp_action *act)
572{
573 switch (act->action) {
574 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
575 _zfcp_erp_port_reopen_all(act->adapter, 0, "ersfs_1", NULL);
576 break;
577 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
578 _zfcp_erp_port_reopen(act->port, 0, "ersfs_2", NULL);
579 break;
580 case ZFCP_ERP_ACTION_REOPEN_PORT:
581 _zfcp_erp_unit_reopen_all(act->port, 0, "ersfs_3", NULL);
Christof Schmitt287ac012008-07-02 10:56:40 +0200582 break;
583 }
584}
585
586static void zfcp_erp_wakeup(struct zfcp_adapter *adapter)
587{
588 unsigned long flags;
589
590 read_lock_irqsave(&zfcp_data.config_lock, flags);
591 read_lock(&adapter->erp_lock);
592 if (list_empty(&adapter->erp_ready_head) &&
593 list_empty(&adapter->erp_running_head)) {
594 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING,
595 &adapter->status);
596 wake_up(&adapter->erp_done_wqh);
597 }
598 read_unlock(&adapter->erp_lock);
599 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
600}
601
602static int zfcp_erp_adapter_strategy_open_qdio(struct zfcp_erp_action *act)
603{
Swen Schillig564e1c82009-08-18 15:43:19 +0200604 struct zfcp_qdio *qdio = act->adapter->qdio;
605
606 if (zfcp_qdio_open(qdio))
Christof Schmitt287ac012008-07-02 10:56:40 +0200607 return ZFCP_ERP_FAILED;
Swen Schillig564e1c82009-08-18 15:43:19 +0200608 init_waitqueue_head(&qdio->req_q_wq);
Christof Schmitt287ac012008-07-02 10:56:40 +0200609 atomic_set_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &act->adapter->status);
610 return ZFCP_ERP_SUCCEEDED;
611}
612
613static void zfcp_erp_enqueue_ptp_port(struct zfcp_adapter *adapter)
614{
615 struct zfcp_port *port;
616 port = zfcp_port_enqueue(adapter, adapter->peer_wwpn, 0,
617 adapter->peer_d_id);
618 if (IS_ERR(port)) /* error or port already attached */
619 return;
Swen Schillig5ffd51a2009-03-02 13:09:04 +0100620 _zfcp_erp_port_reopen(port, 0, "ereptp1", NULL);
Christof Schmitt287ac012008-07-02 10:56:40 +0200621}
622
623static int zfcp_erp_adapter_strat_fsf_xconf(struct zfcp_erp_action *erp_action)
624{
625 int retries;
626 int sleep = 1;
627 struct zfcp_adapter *adapter = erp_action->adapter;
628
629 atomic_clear_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK, &adapter->status);
630
631 for (retries = 7; retries; retries--) {
632 atomic_clear_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT,
633 &adapter->status);
634 write_lock_irq(&adapter->erp_lock);
635 zfcp_erp_action_to_running(erp_action);
636 write_unlock_irq(&adapter->erp_lock);
637 if (zfcp_fsf_exchange_config_data(erp_action)) {
638 atomic_clear_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT,
639 &adapter->status);
640 return ZFCP_ERP_FAILED;
641 }
642
Swen Schillig57717102009-08-18 15:43:21 +0200643 zfcp_dbf_rec_thread_lock("erasfx1", adapter->dbf);
Christof Schmitt347c6a92009-08-18 15:43:25 +0200644 wait_event(adapter->erp_ready_wq,
645 !list_empty(&adapter->erp_ready_head));
Swen Schillig57717102009-08-18 15:43:21 +0200646 zfcp_dbf_rec_thread_lock("erasfx2", adapter->dbf);
Christof Schmitt287ac012008-07-02 10:56:40 +0200647 if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT)
648 break;
649
650 if (!(atomic_read(&adapter->status) &
651 ZFCP_STATUS_ADAPTER_HOST_CON_INIT))
652 break;
653
654 ssleep(sleep);
655 sleep *= 2;
656 }
657
658 atomic_clear_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT,
659 &adapter->status);
660
661 if (!(atomic_read(&adapter->status) & ZFCP_STATUS_ADAPTER_XCONFIG_OK))
662 return ZFCP_ERP_FAILED;
663
664 if (fc_host_port_type(adapter->scsi_host) == FC_PORTTYPE_PTP)
665 zfcp_erp_enqueue_ptp_port(adapter);
666
667 return ZFCP_ERP_SUCCEEDED;
668}
669
670static int zfcp_erp_adapter_strategy_open_fsf_xport(struct zfcp_erp_action *act)
671{
672 int ret;
673 struct zfcp_adapter *adapter = act->adapter;
674
Christof Schmitt287ac012008-07-02 10:56:40 +0200675 write_lock_irq(&adapter->erp_lock);
676 zfcp_erp_action_to_running(act);
677 write_unlock_irq(&adapter->erp_lock);
678
679 ret = zfcp_fsf_exchange_port_data(act);
680 if (ret == -EOPNOTSUPP)
681 return ZFCP_ERP_SUCCEEDED;
682 if (ret)
683 return ZFCP_ERP_FAILED;
684
Swen Schillig57717102009-08-18 15:43:21 +0200685 zfcp_dbf_rec_thread_lock("erasox1", adapter->dbf);
Christof Schmitt347c6a92009-08-18 15:43:25 +0200686 wait_event(adapter->erp_ready_wq,
687 !list_empty(&adapter->erp_ready_head));
Swen Schillig57717102009-08-18 15:43:21 +0200688 zfcp_dbf_rec_thread_lock("erasox2", adapter->dbf);
Christof Schmitt287ac012008-07-02 10:56:40 +0200689 if (act->status & ZFCP_STATUS_ERP_TIMEDOUT)
690 return ZFCP_ERP_FAILED;
691
692 return ZFCP_ERP_SUCCEEDED;
693}
694
695static int zfcp_erp_adapter_strategy_open_fsf(struct zfcp_erp_action *act)
696{
697 if (zfcp_erp_adapter_strat_fsf_xconf(act) == ZFCP_ERP_FAILED)
698 return ZFCP_ERP_FAILED;
699
700 if (zfcp_erp_adapter_strategy_open_fsf_xport(act) == ZFCP_ERP_FAILED)
701 return ZFCP_ERP_FAILED;
702
703 atomic_set(&act->adapter->stat_miss, 16);
704 if (zfcp_status_read_refill(act->adapter))
705 return ZFCP_ERP_FAILED;
706
707 return ZFCP_ERP_SUCCEEDED;
708}
709
Swen Schilligcf13c082009-03-02 13:09:03 +0100710static void zfcp_erp_adapter_strategy_close(struct zfcp_erp_action *act)
Christof Schmitt287ac012008-07-02 10:56:40 +0200711{
Christof Schmitt287ac012008-07-02 10:56:40 +0200712 struct zfcp_adapter *adapter = act->adapter;
713
Christof Schmitt287ac012008-07-02 10:56:40 +0200714 /* close queues to ensure that buffers are not accessed by adapter */
Swen Schillig564e1c82009-08-18 15:43:19 +0200715 zfcp_qdio_close(adapter->qdio);
Christof Schmitt287ac012008-07-02 10:56:40 +0200716 zfcp_fsf_req_dismiss_all(adapter);
717 adapter->fsf_req_seq_no = 0;
Christof Schmitt55c770f2009-08-18 15:43:12 +0200718 zfcp_fc_wka_ports_force_offline(adapter->gs);
Christof Schmitt287ac012008-07-02 10:56:40 +0200719 /* all ports and units are closed */
Swen Schillig5ffd51a2009-03-02 13:09:04 +0100720 zfcp_erp_modify_adapter_status(adapter, "erascl1", NULL,
Christof Schmitt287ac012008-07-02 10:56:40 +0200721 ZFCP_STATUS_COMMON_OPEN, ZFCP_CLEAR);
Swen Schilligcf13c082009-03-02 13:09:03 +0100722
Christof Schmitt287ac012008-07-02 10:56:40 +0200723 atomic_clear_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK |
Swen Schilligcf13c082009-03-02 13:09:03 +0100724 ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, &adapter->status);
725}
726
727static int zfcp_erp_adapter_strategy_open(struct zfcp_erp_action *act)
728{
729 struct zfcp_adapter *adapter = act->adapter;
730
731 if (zfcp_erp_adapter_strategy_open_qdio(act)) {
732 atomic_clear_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK |
733 ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED,
734 &adapter->status);
735 return ZFCP_ERP_FAILED;
736 }
737
738 if (zfcp_erp_adapter_strategy_open_fsf(act)) {
739 zfcp_erp_adapter_strategy_close(act);
740 return ZFCP_ERP_FAILED;
741 }
742
743 atomic_set_mask(ZFCP_STATUS_COMMON_OPEN, &adapter->status);
744
745 return ZFCP_ERP_SUCCEEDED;
Christof Schmitt287ac012008-07-02 10:56:40 +0200746}
747
748static int zfcp_erp_adapter_strategy(struct zfcp_erp_action *act)
749{
Swen Schilligcf13c082009-03-02 13:09:03 +0100750 struct zfcp_adapter *adapter = act->adapter;
Christof Schmitt287ac012008-07-02 10:56:40 +0200751
Swen Schilligcf13c082009-03-02 13:09:03 +0100752 if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_OPEN) {
753 zfcp_erp_adapter_strategy_close(act);
754 if (act->status & ZFCP_STATUS_ERP_CLOSE_ONLY)
755 return ZFCP_ERP_EXIT;
756 }
Christof Schmitt287ac012008-07-02 10:56:40 +0200757
Swen Schilligcf13c082009-03-02 13:09:03 +0100758 if (zfcp_erp_adapter_strategy_open(act)) {
Christof Schmitt287ac012008-07-02 10:56:40 +0200759 ssleep(8);
Swen Schilligcf13c082009-03-02 13:09:03 +0100760 return ZFCP_ERP_FAILED;
761 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700762
Swen Schilligcf13c082009-03-02 13:09:03 +0100763 return ZFCP_ERP_SUCCEEDED;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764}
765
Christof Schmitt287ac012008-07-02 10:56:40 +0200766static int zfcp_erp_port_forced_strategy_close(struct zfcp_erp_action *act)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767{
Christof Schmitt287ac012008-07-02 10:56:40 +0200768 int retval;
769
770 retval = zfcp_fsf_close_physical_port(act);
771 if (retval == -ENOMEM)
772 return ZFCP_ERP_NOMEM;
773 act->step = ZFCP_ERP_STEP_PHYS_PORT_CLOSING;
774 if (retval)
775 return ZFCP_ERP_FAILED;
776
777 return ZFCP_ERP_CONTINUES;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700778}
779
Christof Schmitt287ac012008-07-02 10:56:40 +0200780static void zfcp_erp_port_strategy_clearstati(struct zfcp_port *port)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700781{
Christof Schmitta5b11dd2009-03-02 13:08:54 +0100782 atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED, &port->status);
Christof Schmitt287ac012008-07-02 10:56:40 +0200783}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700784
Christof Schmitt287ac012008-07-02 10:56:40 +0200785static int zfcp_erp_port_forced_strategy(struct zfcp_erp_action *erp_action)
786{
787 struct zfcp_port *port = erp_action->port;
788 int status = atomic_read(&port->status);
789
790 switch (erp_action->step) {
791 case ZFCP_ERP_STEP_UNINITIALIZED:
792 zfcp_erp_port_strategy_clearstati(port);
793 if ((status & ZFCP_STATUS_PORT_PHYS_OPEN) &&
794 (status & ZFCP_STATUS_COMMON_OPEN))
795 return zfcp_erp_port_forced_strategy_close(erp_action);
796 else
797 return ZFCP_ERP_FAILED;
798
799 case ZFCP_ERP_STEP_PHYS_PORT_CLOSING:
Christof Schmittddb3e0c2009-07-13 15:06:08 +0200800 if (!(status & ZFCP_STATUS_PORT_PHYS_OPEN))
Christof Schmitt287ac012008-07-02 10:56:40 +0200801 return ZFCP_ERP_SUCCEEDED;
802 }
803 return ZFCP_ERP_FAILED;
804}
805
806static int zfcp_erp_port_strategy_close(struct zfcp_erp_action *erp_action)
807{
808 int retval;
809
810 retval = zfcp_fsf_close_port(erp_action);
811 if (retval == -ENOMEM)
812 return ZFCP_ERP_NOMEM;
813 erp_action->step = ZFCP_ERP_STEP_PORT_CLOSING;
814 if (retval)
815 return ZFCP_ERP_FAILED;
816 return ZFCP_ERP_CONTINUES;
817}
818
819static int zfcp_erp_port_strategy_open_port(struct zfcp_erp_action *erp_action)
820{
821 int retval;
822
823 retval = zfcp_fsf_open_port(erp_action);
824 if (retval == -ENOMEM)
825 return ZFCP_ERP_NOMEM;
826 erp_action->step = ZFCP_ERP_STEP_PORT_OPENING;
827 if (retval)
828 return ZFCP_ERP_FAILED;
829 return ZFCP_ERP_CONTINUES;
830}
831
Christof Schmitt287ac012008-07-02 10:56:40 +0200832static int zfcp_erp_open_ptp_port(struct zfcp_erp_action *act)
833{
834 struct zfcp_adapter *adapter = act->adapter;
835 struct zfcp_port *port = act->port;
836
837 if (port->wwpn != adapter->peer_wwpn) {
Swen Schillig5ffd51a2009-03-02 13:09:04 +0100838 zfcp_erp_port_failed(port, "eroptp1", NULL);
Christof Schmitt287ac012008-07-02 10:56:40 +0200839 return ZFCP_ERP_FAILED;
840 }
841 port->d_id = adapter->peer_d_id;
Christof Schmitt287ac012008-07-02 10:56:40 +0200842 return zfcp_erp_port_strategy_open_port(act);
843}
844
845static int zfcp_erp_port_strategy_open_common(struct zfcp_erp_action *act)
846{
847 struct zfcp_adapter *adapter = act->adapter;
848 struct zfcp_port *port = act->port;
Christof Schmitt287ac012008-07-02 10:56:40 +0200849 int p_status = atomic_read(&port->status);
850
851 switch (act->step) {
852 case ZFCP_ERP_STEP_UNINITIALIZED:
853 case ZFCP_ERP_STEP_PHYS_PORT_CLOSING:
854 case ZFCP_ERP_STEP_PORT_CLOSING:
855 if (fc_host_port_type(adapter->scsi_host) == FC_PORTTYPE_PTP)
856 return zfcp_erp_open_ptp_port(act);
Christof Schmittb98478d2008-12-19 16:56:59 +0100857 if (!port->d_id) {
Swen Schillig947a9ac2009-03-02 13:09:10 +0100858 zfcp_port_get(port);
Swen Schillig45446832009-08-18 15:43:17 +0200859 if (!queue_work(adapter->work_queue,
Swen Schillig947a9ac2009-03-02 13:09:10 +0100860 &port->gid_pn_work))
861 zfcp_port_put(port);
Christof Schmitt799b76d2009-08-18 15:43:20 +0200862 return ZFCP_ERP_EXIT;
Christof Schmitt287ac012008-07-02 10:56:40 +0200863 }
Christof Schmitt287ac012008-07-02 10:56:40 +0200864 return zfcp_erp_port_strategy_open_port(act);
865
866 case ZFCP_ERP_STEP_PORT_OPENING:
867 /* D_ID might have changed during open */
Swen Schillig5ab944f2008-10-01 12:42:17 +0200868 if (p_status & ZFCP_STATUS_COMMON_OPEN) {
Christof Schmittb98478d2008-12-19 16:56:59 +0100869 if (port->d_id)
Swen Schillig5ab944f2008-10-01 12:42:17 +0200870 return ZFCP_ERP_SUCCEEDED;
871 else {
872 act->step = ZFCP_ERP_STEP_PORT_CLOSING;
873 return ZFCP_ERP_CONTINUES;
874 }
Swen Schillig5ab944f2008-10-01 12:42:17 +0200875 }
Swen Schilligea460a82009-05-15 13:18:20 +0200876 if (port->d_id && !(p_status & ZFCP_STATUS_COMMON_NOESC)) {
877 port->d_id = 0;
878 _zfcp_erp_port_reopen(port, 0, "erpsoc1", NULL);
879 return ZFCP_ERP_EXIT;
880 }
881 /* fall through otherwise */
Christof Schmitt287ac012008-07-02 10:56:40 +0200882 }
883 return ZFCP_ERP_FAILED;
884}
885
Christof Schmitt287ac012008-07-02 10:56:40 +0200886static int zfcp_erp_port_strategy(struct zfcp_erp_action *erp_action)
887{
888 struct zfcp_port *port = erp_action->port;
889
Swen Schillig5ab944f2008-10-01 12:42:17 +0200890 if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_NOESC)
891 goto close_init_done;
892
Christof Schmitt287ac012008-07-02 10:56:40 +0200893 switch (erp_action->step) {
894 case ZFCP_ERP_STEP_UNINITIALIZED:
895 zfcp_erp_port_strategy_clearstati(port);
896 if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_OPEN)
897 return zfcp_erp_port_strategy_close(erp_action);
898 break;
899
900 case ZFCP_ERP_STEP_PORT_CLOSING:
901 if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_OPEN)
902 return ZFCP_ERP_FAILED;
903 break;
904 }
Swen Schillig5ab944f2008-10-01 12:42:17 +0200905
906close_init_done:
Christof Schmitt287ac012008-07-02 10:56:40 +0200907 if (erp_action->status & ZFCP_STATUS_ERP_CLOSE_ONLY)
908 return ZFCP_ERP_EXIT;
Christof Schmitt287ac012008-07-02 10:56:40 +0200909
Swen Schillig5ab944f2008-10-01 12:42:17 +0200910 return zfcp_erp_port_strategy_open_common(erp_action);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700911}
912
Christof Schmitt287ac012008-07-02 10:56:40 +0200913static void zfcp_erp_unit_strategy_clearstati(struct zfcp_unit *unit)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700914{
Swen Schillig44cc76f2008-10-01 12:42:16 +0200915 atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED |
Christof Schmitt287ac012008-07-02 10:56:40 +0200916 ZFCP_STATUS_UNIT_SHARED |
917 ZFCP_STATUS_UNIT_READONLY,
918 &unit->status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700919}
920
Christof Schmitt287ac012008-07-02 10:56:40 +0200921static int zfcp_erp_unit_strategy_close(struct zfcp_erp_action *erp_action)
922{
923 int retval = zfcp_fsf_close_unit(erp_action);
924 if (retval == -ENOMEM)
925 return ZFCP_ERP_NOMEM;
926 erp_action->step = ZFCP_ERP_STEP_UNIT_CLOSING;
927 if (retval)
928 return ZFCP_ERP_FAILED;
929 return ZFCP_ERP_CONTINUES;
930}
931
932static int zfcp_erp_unit_strategy_open(struct zfcp_erp_action *erp_action)
933{
934 int retval = zfcp_fsf_open_unit(erp_action);
935 if (retval == -ENOMEM)
936 return ZFCP_ERP_NOMEM;
937 erp_action->step = ZFCP_ERP_STEP_UNIT_OPENING;
938 if (retval)
939 return ZFCP_ERP_FAILED;
940 return ZFCP_ERP_CONTINUES;
941}
942
943static int zfcp_erp_unit_strategy(struct zfcp_erp_action *erp_action)
944{
945 struct zfcp_unit *unit = erp_action->unit;
946
947 switch (erp_action->step) {
948 case ZFCP_ERP_STEP_UNINITIALIZED:
949 zfcp_erp_unit_strategy_clearstati(unit);
950 if (atomic_read(&unit->status) & ZFCP_STATUS_COMMON_OPEN)
951 return zfcp_erp_unit_strategy_close(erp_action);
952 /* already closed, fall through */
953 case ZFCP_ERP_STEP_UNIT_CLOSING:
954 if (atomic_read(&unit->status) & ZFCP_STATUS_COMMON_OPEN)
955 return ZFCP_ERP_FAILED;
956 if (erp_action->status & ZFCP_STATUS_ERP_CLOSE_ONLY)
957 return ZFCP_ERP_EXIT;
958 return zfcp_erp_unit_strategy_open(erp_action);
959
960 case ZFCP_ERP_STEP_UNIT_OPENING:
961 if (atomic_read(&unit->status) & ZFCP_STATUS_COMMON_OPEN)
962 return ZFCP_ERP_SUCCEEDED;
963 }
964 return ZFCP_ERP_FAILED;
965}
966
967static int zfcp_erp_strategy_check_unit(struct zfcp_unit *unit, int result)
968{
969 switch (result) {
970 case ZFCP_ERP_SUCCEEDED :
971 atomic_set(&unit->erp_counter, 0);
972 zfcp_erp_unit_unblock(unit);
973 break;
974 case ZFCP_ERP_FAILED :
975 atomic_inc(&unit->erp_counter);
Christof Schmittff3b24f2008-10-01 12:42:15 +0200976 if (atomic_read(&unit->erp_counter) > ZFCP_MAX_ERPS) {
977 dev_err(&unit->port->adapter->ccw_device->dev,
978 "ERP failed for unit 0x%016Lx on "
979 "port 0x%016Lx\n",
Swen Schillig7ba58c92008-10-01 12:42:18 +0200980 (unsigned long long)unit->fcp_lun,
981 (unsigned long long)unit->port->wwpn);
Swen Schillig5ffd51a2009-03-02 13:09:04 +0100982 zfcp_erp_unit_failed(unit, "erusck1", NULL);
Christof Schmittff3b24f2008-10-01 12:42:15 +0200983 }
Christof Schmitt287ac012008-07-02 10:56:40 +0200984 break;
985 }
986
987 if (atomic_read(&unit->status) & ZFCP_STATUS_COMMON_ERP_FAILED) {
988 zfcp_erp_unit_block(unit, 0);
989 result = ZFCP_ERP_EXIT;
990 }
991 return result;
992}
993
994static int zfcp_erp_strategy_check_port(struct zfcp_port *port, int result)
995{
996 switch (result) {
997 case ZFCP_ERP_SUCCEEDED :
998 atomic_set(&port->erp_counter, 0);
999 zfcp_erp_port_unblock(port);
1000 break;
1001
1002 case ZFCP_ERP_FAILED :
1003 if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_NOESC) {
1004 zfcp_erp_port_block(port, 0);
1005 result = ZFCP_ERP_EXIT;
1006 }
1007 atomic_inc(&port->erp_counter);
Christof Schmittff3b24f2008-10-01 12:42:15 +02001008 if (atomic_read(&port->erp_counter) > ZFCP_MAX_ERPS) {
1009 dev_err(&port->adapter->ccw_device->dev,
1010 "ERP failed for remote port 0x%016Lx\n",
Swen Schillig7ba58c92008-10-01 12:42:18 +02001011 (unsigned long long)port->wwpn);
Swen Schillig5ffd51a2009-03-02 13:09:04 +01001012 zfcp_erp_port_failed(port, "erpsck1", NULL);
Christof Schmittff3b24f2008-10-01 12:42:15 +02001013 }
Christof Schmitt287ac012008-07-02 10:56:40 +02001014 break;
1015 }
1016
1017 if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_FAILED) {
1018 zfcp_erp_port_block(port, 0);
1019 result = ZFCP_ERP_EXIT;
1020 }
1021 return result;
1022}
1023
1024static int zfcp_erp_strategy_check_adapter(struct zfcp_adapter *adapter,
1025 int result)
1026{
1027 switch (result) {
1028 case ZFCP_ERP_SUCCEEDED :
1029 atomic_set(&adapter->erp_counter, 0);
1030 zfcp_erp_adapter_unblock(adapter);
1031 break;
1032
1033 case ZFCP_ERP_FAILED :
1034 atomic_inc(&adapter->erp_counter);
Christof Schmittff3b24f2008-10-01 12:42:15 +02001035 if (atomic_read(&adapter->erp_counter) > ZFCP_MAX_ERPS) {
1036 dev_err(&adapter->ccw_device->dev,
1037 "ERP cannot recover an error "
1038 "on the FCP device\n");
Swen Schillig5ffd51a2009-03-02 13:09:04 +01001039 zfcp_erp_adapter_failed(adapter, "erasck1", NULL);
Christof Schmittff3b24f2008-10-01 12:42:15 +02001040 }
Christof Schmitt287ac012008-07-02 10:56:40 +02001041 break;
1042 }
1043
1044 if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_ERP_FAILED) {
1045 zfcp_erp_adapter_block(adapter, 0);
1046 result = ZFCP_ERP_EXIT;
1047 }
1048 return result;
1049}
1050
1051static int zfcp_erp_strategy_check_target(struct zfcp_erp_action *erp_action,
1052 int result)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001053{
1054 struct zfcp_adapter *adapter = erp_action->adapter;
1055 struct zfcp_port *port = erp_action->port;
1056 struct zfcp_unit *unit = erp_action->unit;
1057
Linus Torvalds1da177e2005-04-16 15:20:36 -07001058 switch (erp_action->action) {
1059
1060 case ZFCP_ERP_ACTION_REOPEN_UNIT:
1061 result = zfcp_erp_strategy_check_unit(unit, result);
1062 break;
1063
1064 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
1065 case ZFCP_ERP_ACTION_REOPEN_PORT:
1066 result = zfcp_erp_strategy_check_port(port, result);
1067 break;
1068
1069 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
1070 result = zfcp_erp_strategy_check_adapter(adapter, result);
1071 break;
1072 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001073 return result;
1074}
1075
Christof Schmitt287ac012008-07-02 10:56:40 +02001076static int zfcp_erp_strat_change_det(atomic_t *target_status, u32 erp_status)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001077{
Christof Schmitt287ac012008-07-02 10:56:40 +02001078 int status = atomic_read(target_status);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001079
Christof Schmitt287ac012008-07-02 10:56:40 +02001080 if ((status & ZFCP_STATUS_COMMON_RUNNING) &&
1081 (erp_status & ZFCP_STATUS_ERP_CLOSE_ONLY))
1082 return 1; /* take it online */
1083
1084 if (!(status & ZFCP_STATUS_COMMON_RUNNING) &&
1085 !(erp_status & ZFCP_STATUS_ERP_CLOSE_ONLY))
1086 return 1; /* take it offline */
1087
1088 return 0;
1089}
1090
1091static int zfcp_erp_strategy_statechange(struct zfcp_erp_action *act, int ret)
1092{
1093 int action = act->action;
1094 struct zfcp_adapter *adapter = act->adapter;
1095 struct zfcp_port *port = act->port;
1096 struct zfcp_unit *unit = act->unit;
1097 u32 erp_status = act->status;
1098
1099 switch (action) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001100 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
Christof Schmitt287ac012008-07-02 10:56:40 +02001101 if (zfcp_erp_strat_change_det(&adapter->status, erp_status)) {
1102 _zfcp_erp_adapter_reopen(adapter,
1103 ZFCP_STATUS_COMMON_ERP_FAILED,
Swen Schillig5ffd51a2009-03-02 13:09:04 +01001104 "ersscg1", NULL);
Christof Schmitt287ac012008-07-02 10:56:40 +02001105 return ZFCP_ERP_EXIT;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001106 }
1107 break;
1108
1109 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
1110 case ZFCP_ERP_ACTION_REOPEN_PORT:
Christof Schmitt287ac012008-07-02 10:56:40 +02001111 if (zfcp_erp_strat_change_det(&port->status, erp_status)) {
1112 _zfcp_erp_port_reopen(port,
1113 ZFCP_STATUS_COMMON_ERP_FAILED,
Swen Schillig5ffd51a2009-03-02 13:09:04 +01001114 "ersscg2", NULL);
Christof Schmitt287ac012008-07-02 10:56:40 +02001115 return ZFCP_ERP_EXIT;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001116 }
1117 break;
1118
1119 case ZFCP_ERP_ACTION_REOPEN_UNIT:
Christof Schmitt287ac012008-07-02 10:56:40 +02001120 if (zfcp_erp_strat_change_det(&unit->status, erp_status)) {
1121 _zfcp_erp_unit_reopen(unit,
1122 ZFCP_STATUS_COMMON_ERP_FAILED,
Swen Schillig5ffd51a2009-03-02 13:09:04 +01001123 "ersscg3", NULL);
Christof Schmitt287ac012008-07-02 10:56:40 +02001124 return ZFCP_ERP_EXIT;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001125 }
1126 break;
1127 }
Christof Schmitt287ac012008-07-02 10:56:40 +02001128 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001129}
1130
Christof Schmitt287ac012008-07-02 10:56:40 +02001131static void zfcp_erp_action_dequeue(struct zfcp_erp_action *erp_action)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001132{
Christof Schmitt287ac012008-07-02 10:56:40 +02001133 struct zfcp_adapter *adapter = erp_action->adapter;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001134
Christof Schmitt287ac012008-07-02 10:56:40 +02001135 adapter->erp_total_count--;
1136 if (erp_action->status & ZFCP_STATUS_ERP_LOWMEM) {
1137 adapter->erp_low_mem_count--;
1138 erp_action->status &= ~ZFCP_STATUS_ERP_LOWMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001139 }
1140
Christof Schmitt287ac012008-07-02 10:56:40 +02001141 list_del(&erp_action->list);
Swen Schillig57717102009-08-18 15:43:21 +02001142 zfcp_dbf_rec_action("eractd1", erp_action);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001143
Christof Schmitt287ac012008-07-02 10:56:40 +02001144 switch (erp_action->action) {
1145 case ZFCP_ERP_ACTION_REOPEN_UNIT:
1146 atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE,
1147 &erp_action->unit->status);
1148 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001149
Christof Schmitt287ac012008-07-02 10:56:40 +02001150 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
1151 case ZFCP_ERP_ACTION_REOPEN_PORT:
1152 atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE,
1153 &erp_action->port->status);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001154 break;
Christof Schmitt287ac012008-07-02 10:56:40 +02001155
1156 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
1157 atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE,
1158 &erp_action->adapter->status);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001159 break;
1160 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001161}
1162
Christof Schmitt287ac012008-07-02 10:56:40 +02001163static void zfcp_erp_action_cleanup(struct zfcp_erp_action *act, int result)
Maxim Shchetyninaef4a982005-09-13 21:51:16 +02001164{
Christof Schmitt287ac012008-07-02 10:56:40 +02001165 struct zfcp_adapter *adapter = act->adapter;
1166 struct zfcp_port *port = act->port;
1167 struct zfcp_unit *unit = act->unit;
Maxim Shchetyninaef4a982005-09-13 21:51:16 +02001168
Christof Schmitt287ac012008-07-02 10:56:40 +02001169 switch (act->action) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001170 case ZFCP_ERP_ACTION_REOPEN_UNIT:
Christof Schmitta2fa0ae2009-03-02 13:09:08 +01001171 if ((result == ZFCP_ERP_SUCCEEDED) && !unit->device) {
Swen Schillig92d51932009-04-17 15:08:04 +02001172 zfcp_unit_get(unit);
1173 if (scsi_queue_work(unit->port->adapter->scsi_host,
1174 &unit->scsi_work) <= 0)
1175 zfcp_unit_put(unit);
Andreas Herrmannad58f7d2006-03-10 00:56:16 +01001176 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001177 zfcp_unit_put(unit);
1178 break;
Christof Schmitt287ac012008-07-02 10:56:40 +02001179
Linus Torvalds1da177e2005-04-16 15:20:36 -07001180 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
1181 case ZFCP_ERP_ACTION_REOPEN_PORT:
Christof Schmitta2fa0ae2009-03-02 13:09:08 +01001182 if (result == ZFCP_ERP_SUCCEEDED)
1183 zfcp_scsi_schedule_rport_register(port);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001184 zfcp_port_put(port);
1185 break;
Christof Schmitt287ac012008-07-02 10:56:40 +02001186
Linus Torvalds1da177e2005-04-16 15:20:36 -07001187 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
Christof Schmitta2fa0ae2009-03-02 13:09:08 +01001188 if (result == ZFCP_ERP_SUCCEEDED) {
Christof Schmittbd43a42b72008-12-25 13:38:50 +01001189 register_service_level(&adapter->service_level);
Swen Schilligfca55b62008-11-26 18:07:40 +01001190 schedule_work(&adapter->scan_work);
Christof Schmitta2fa0ae2009-03-02 13:09:08 +01001191 } else
1192 unregister_service_level(&adapter->service_level);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001193 zfcp_adapter_put(adapter);
1194 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001195 }
1196}
1197
Christof Schmitt287ac012008-07-02 10:56:40 +02001198static int zfcp_erp_strategy_do_action(struct zfcp_erp_action *erp_action)
1199{
1200 switch (erp_action->action) {
1201 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
1202 return zfcp_erp_adapter_strategy(erp_action);
1203 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
1204 return zfcp_erp_port_forced_strategy(erp_action);
1205 case ZFCP_ERP_ACTION_REOPEN_PORT:
1206 return zfcp_erp_port_strategy(erp_action);
1207 case ZFCP_ERP_ACTION_REOPEN_UNIT:
1208 return zfcp_erp_unit_strategy(erp_action);
1209 }
1210 return ZFCP_ERP_FAILED;
1211}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001212
Christof Schmitt287ac012008-07-02 10:56:40 +02001213static int zfcp_erp_strategy(struct zfcp_erp_action *erp_action)
1214{
1215 int retval;
1216 struct zfcp_adapter *adapter = erp_action->adapter;
1217 unsigned long flags;
1218
1219 read_lock_irqsave(&zfcp_data.config_lock, flags);
1220 write_lock(&adapter->erp_lock);
1221
1222 zfcp_erp_strategy_check_fsfreq(erp_action);
1223
1224 if (erp_action->status & ZFCP_STATUS_ERP_DISMISSED) {
1225 zfcp_erp_action_dequeue(erp_action);
1226 retval = ZFCP_ERP_DISMISSED;
1227 goto unlock;
1228 }
1229
1230 zfcp_erp_action_to_running(erp_action);
1231
1232 /* no lock to allow for blocking operations */
1233 write_unlock(&adapter->erp_lock);
1234 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
1235 retval = zfcp_erp_strategy_do_action(erp_action);
1236 read_lock_irqsave(&zfcp_data.config_lock, flags);
1237 write_lock(&adapter->erp_lock);
1238
1239 if (erp_action->status & ZFCP_STATUS_ERP_DISMISSED)
1240 retval = ZFCP_ERP_CONTINUES;
1241
1242 switch (retval) {
1243 case ZFCP_ERP_NOMEM:
1244 if (!(erp_action->status & ZFCP_STATUS_ERP_LOWMEM)) {
1245 ++adapter->erp_low_mem_count;
1246 erp_action->status |= ZFCP_STATUS_ERP_LOWMEM;
1247 }
1248 if (adapter->erp_total_count == adapter->erp_low_mem_count)
Swen Schillig5ffd51a2009-03-02 13:09:04 +01001249 _zfcp_erp_adapter_reopen(adapter, 0, "erstgy1", NULL);
Christof Schmitt287ac012008-07-02 10:56:40 +02001250 else {
1251 zfcp_erp_strategy_memwait(erp_action);
1252 retval = ZFCP_ERP_CONTINUES;
1253 }
1254 goto unlock;
1255
1256 case ZFCP_ERP_CONTINUES:
1257 if (erp_action->status & ZFCP_STATUS_ERP_LOWMEM) {
1258 --adapter->erp_low_mem_count;
1259 erp_action->status &= ~ZFCP_STATUS_ERP_LOWMEM;
1260 }
1261 goto unlock;
1262 }
1263
1264 retval = zfcp_erp_strategy_check_target(erp_action, retval);
1265 zfcp_erp_action_dequeue(erp_action);
1266 retval = zfcp_erp_strategy_statechange(erp_action, retval);
1267 if (retval == ZFCP_ERP_EXIT)
1268 goto unlock;
Christof Schmitt85600f72009-07-13 15:06:09 +02001269 if (retval == ZFCP_ERP_SUCCEEDED)
1270 zfcp_erp_strategy_followup_success(erp_action);
1271 if (retval == ZFCP_ERP_FAILED)
1272 zfcp_erp_strategy_followup_failed(erp_action);
Christof Schmitt287ac012008-07-02 10:56:40 +02001273
1274 unlock:
1275 write_unlock(&adapter->erp_lock);
1276 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
1277
1278 if (retval != ZFCP_ERP_CONTINUES)
1279 zfcp_erp_action_cleanup(erp_action, retval);
1280
1281 return retval;
1282}
1283
1284static int zfcp_erp_thread(void *data)
1285{
1286 struct zfcp_adapter *adapter = (struct zfcp_adapter *) data;
1287 struct list_head *next;
1288 struct zfcp_erp_action *act;
1289 unsigned long flags;
1290
Christof Schmitt347c6a92009-08-18 15:43:25 +02001291 for (;;) {
Swen Schillig57717102009-08-18 15:43:21 +02001292 zfcp_dbf_rec_thread_lock("erthrd1", adapter->dbf);
Christof Schmitt347c6a92009-08-18 15:43:25 +02001293 wait_event_interruptible(adapter->erp_ready_wq,
1294 !list_empty(&adapter->erp_ready_head) ||
1295 kthread_should_stop());
Swen Schillig57717102009-08-18 15:43:21 +02001296 zfcp_dbf_rec_thread_lock("erthrd2", adapter->dbf);
Swen Schillig94ab4b32009-04-17 15:08:06 +02001297
Christof Schmitt347c6a92009-08-18 15:43:25 +02001298 if (kthread_should_stop())
1299 break;
1300
Christof Schmitt287ac012008-07-02 10:56:40 +02001301 write_lock_irqsave(&adapter->erp_lock, flags);
1302 next = adapter->erp_ready_head.next;
1303 write_unlock_irqrestore(&adapter->erp_lock, flags);
1304
1305 if (next != &adapter->erp_ready_head) {
1306 act = list_entry(next, struct zfcp_erp_action, list);
1307
1308 /* there is more to come after dismission, no notify */
1309 if (zfcp_erp_strategy(act) != ZFCP_ERP_DISMISSED)
1310 zfcp_erp_wakeup(adapter);
1311 }
Christof Schmitt287ac012008-07-02 10:56:40 +02001312 }
1313
Christof Schmitt287ac012008-07-02 10:56:40 +02001314 return 0;
1315}
1316
1317/**
1318 * zfcp_erp_thread_setup - Start ERP thread for adapter
1319 * @adapter: Adapter to start the ERP thread for
1320 *
1321 * Returns 0 on success or error code from kernel_thread()
1322 */
1323int zfcp_erp_thread_setup(struct zfcp_adapter *adapter)
1324{
Christof Schmitt347c6a92009-08-18 15:43:25 +02001325 struct task_struct *thread;
Christof Schmitt287ac012008-07-02 10:56:40 +02001326
Christof Schmitt347c6a92009-08-18 15:43:25 +02001327 thread = kthread_run(zfcp_erp_thread, adapter, "zfcperp%s",
1328 dev_name(&adapter->ccw_device->dev));
1329 if (IS_ERR(thread)) {
Christof Schmitt287ac012008-07-02 10:56:40 +02001330 dev_err(&adapter->ccw_device->dev,
Christof Schmittff3b24f2008-10-01 12:42:15 +02001331 "Creating an ERP thread for the FCP device failed.\n");
Christof Schmitt347c6a92009-08-18 15:43:25 +02001332 return PTR_ERR(thread);
Christof Schmitt287ac012008-07-02 10:56:40 +02001333 }
Christof Schmitt347c6a92009-08-18 15:43:25 +02001334
1335 adapter->erp_thread = thread;
Christof Schmitt287ac012008-07-02 10:56:40 +02001336 return 0;
1337}
1338
1339/**
1340 * zfcp_erp_thread_kill - Stop ERP thread.
1341 * @adapter: Adapter where the ERP thread should be stopped.
1342 *
1343 * The caller of this routine ensures that the specified adapter has
1344 * been shut down and that this operation has been completed. Thus,
1345 * there are no pending erp_actions which would need to be handled
1346 * here.
1347 */
1348void zfcp_erp_thread_kill(struct zfcp_adapter *adapter)
1349{
Christof Schmitt347c6a92009-08-18 15:43:25 +02001350 kthread_stop(adapter->erp_thread);
1351 adapter->erp_thread = NULL;
Christof Schmitt287ac012008-07-02 10:56:40 +02001352}
1353
1354/**
1355 * zfcp_erp_adapter_failed - Set adapter status to failed.
1356 * @adapter: Failed adapter.
1357 * @id: Event id for debug trace.
1358 * @ref: Reference for debug trace.
1359 */
Swen Schillig5ffd51a2009-03-02 13:09:04 +01001360void zfcp_erp_adapter_failed(struct zfcp_adapter *adapter, char *id, void *ref)
Christof Schmitt287ac012008-07-02 10:56:40 +02001361{
1362 zfcp_erp_modify_adapter_status(adapter, id, ref,
1363 ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET);
Christof Schmitt287ac012008-07-02 10:56:40 +02001364}
1365
1366/**
1367 * zfcp_erp_port_failed - Set port status to failed.
1368 * @port: Failed port.
1369 * @id: Event id for debug trace.
1370 * @ref: Reference for debug trace.
1371 */
Swen Schillig5ffd51a2009-03-02 13:09:04 +01001372void zfcp_erp_port_failed(struct zfcp_port *port, char *id, void *ref)
Christof Schmitt287ac012008-07-02 10:56:40 +02001373{
1374 zfcp_erp_modify_port_status(port, id, ref,
1375 ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET);
Christof Schmitt287ac012008-07-02 10:56:40 +02001376}
1377
1378/**
1379 * zfcp_erp_unit_failed - Set unit status to failed.
1380 * @unit: Failed unit.
1381 * @id: Event id for debug trace.
1382 * @ref: Reference for debug trace.
1383 */
Swen Schillig5ffd51a2009-03-02 13:09:04 +01001384void zfcp_erp_unit_failed(struct zfcp_unit *unit, char *id, void *ref)
Christof Schmitt287ac012008-07-02 10:56:40 +02001385{
1386 zfcp_erp_modify_unit_status(unit, id, ref,
1387 ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET);
Christof Schmitt287ac012008-07-02 10:56:40 +02001388}
1389
1390/**
1391 * zfcp_erp_wait - wait for completion of error recovery on an adapter
1392 * @adapter: adapter for which to wait for completion of its error recovery
1393 */
1394void zfcp_erp_wait(struct zfcp_adapter *adapter)
1395{
1396 wait_event(adapter->erp_done_wqh,
1397 !(atomic_read(&adapter->status) &
1398 ZFCP_STATUS_ADAPTER_ERP_PENDING));
1399}
1400
1401/**
1402 * zfcp_erp_modify_adapter_status - change adapter status bits
1403 * @adapter: adapter to change the status
1404 * @id: id for the debug trace
1405 * @ref: reference for the debug trace
1406 * @mask: status bits to change
1407 * @set_or_clear: ZFCP_SET or ZFCP_CLEAR
1408 *
1409 * Changes in common status bits are propagated to attached ports and units.
1410 */
Swen Schillig5ffd51a2009-03-02 13:09:04 +01001411void zfcp_erp_modify_adapter_status(struct zfcp_adapter *adapter, char *id,
Christof Schmitt287ac012008-07-02 10:56:40 +02001412 void *ref, u32 mask, int set_or_clear)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001413{
Linus Torvalds1da177e2005-04-16 15:20:36 -07001414 struct zfcp_port *port;
Christof Schmitt287ac012008-07-02 10:56:40 +02001415 u32 common_mask = mask & ZFCP_COMMON_FLAGS;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001416
Christof Schmitt287ac012008-07-02 10:56:40 +02001417 if (set_or_clear == ZFCP_SET) {
1418 if (status_change_set(mask, &adapter->status))
Swen Schillig57717102009-08-18 15:43:21 +02001419 zfcp_dbf_rec_adapter(id, ref, adapter->dbf);
Christof Schmitt287ac012008-07-02 10:56:40 +02001420 atomic_set_mask(mask, &adapter->status);
1421 } else {
1422 if (status_change_clear(mask, &adapter->status))
Swen Schillig57717102009-08-18 15:43:21 +02001423 zfcp_dbf_rec_adapter(id, ref, adapter->dbf);
Christof Schmitt287ac012008-07-02 10:56:40 +02001424 atomic_clear_mask(mask, &adapter->status);
1425 if (mask & ZFCP_STATUS_COMMON_ERP_FAILED)
1426 atomic_set(&adapter->erp_counter, 0);
1427 }
1428
1429 if (common_mask)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001430 list_for_each_entry(port, &adapter->port_list_head, list)
Christof Schmitt287ac012008-07-02 10:56:40 +02001431 zfcp_erp_modify_port_status(port, id, ref, common_mask,
1432 set_or_clear);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001433}
1434
Christof Schmitt287ac012008-07-02 10:56:40 +02001435/**
1436 * zfcp_erp_modify_port_status - change port status bits
1437 * @port: port to change the status bits
1438 * @id: id for the debug trace
1439 * @ref: reference for the debug trace
1440 * @mask: status bits to change
1441 * @set_or_clear: ZFCP_SET or ZFCP_CLEAR
1442 *
1443 * Changes in common status bits are propagated to attached units.
1444 */
Swen Schillig5ffd51a2009-03-02 13:09:04 +01001445void zfcp_erp_modify_port_status(struct zfcp_port *port, char *id, void *ref,
Christof Schmitt287ac012008-07-02 10:56:40 +02001446 u32 mask, int set_or_clear)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001447{
Linus Torvalds1da177e2005-04-16 15:20:36 -07001448 struct zfcp_unit *unit;
Christof Schmitt287ac012008-07-02 10:56:40 +02001449 u32 common_mask = mask & ZFCP_COMMON_FLAGS;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001450
Christof Schmitt287ac012008-07-02 10:56:40 +02001451 if (set_or_clear == ZFCP_SET) {
1452 if (status_change_set(mask, &port->status))
Swen Schillig57717102009-08-18 15:43:21 +02001453 zfcp_dbf_rec_port(id, ref, port);
Christof Schmitt287ac012008-07-02 10:56:40 +02001454 atomic_set_mask(mask, &port->status);
1455 } else {
1456 if (status_change_clear(mask, &port->status))
Swen Schillig57717102009-08-18 15:43:21 +02001457 zfcp_dbf_rec_port(id, ref, port);
Christof Schmitt287ac012008-07-02 10:56:40 +02001458 atomic_clear_mask(mask, &port->status);
1459 if (mask & ZFCP_STATUS_COMMON_ERP_FAILED)
1460 atomic_set(&port->erp_counter, 0);
1461 }
1462
1463 if (common_mask)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001464 list_for_each_entry(unit, &port->unit_list_head, list)
Christof Schmitt287ac012008-07-02 10:56:40 +02001465 zfcp_erp_modify_unit_status(unit, id, ref, common_mask,
1466 set_or_clear);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001467}
1468
Christof Schmitt287ac012008-07-02 10:56:40 +02001469/**
1470 * zfcp_erp_modify_unit_status - change unit status bits
1471 * @unit: unit to change the status bits
1472 * @id: id for the debug trace
1473 * @ref: reference for the debug trace
1474 * @mask: status bits to change
1475 * @set_or_clear: ZFCP_SET or ZFCP_CLEAR
1476 */
Swen Schillig5ffd51a2009-03-02 13:09:04 +01001477void zfcp_erp_modify_unit_status(struct zfcp_unit *unit, char *id, void *ref,
Christof Schmitt287ac012008-07-02 10:56:40 +02001478 u32 mask, int set_or_clear)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001479{
Christof Schmitt287ac012008-07-02 10:56:40 +02001480 if (set_or_clear == ZFCP_SET) {
1481 if (status_change_set(mask, &unit->status))
Swen Schillig57717102009-08-18 15:43:21 +02001482 zfcp_dbf_rec_unit(id, ref, unit);
Christof Schmitt287ac012008-07-02 10:56:40 +02001483 atomic_set_mask(mask, &unit->status);
1484 } else {
1485 if (status_change_clear(mask, &unit->status))
Swen Schillig57717102009-08-18 15:43:21 +02001486 zfcp_dbf_rec_unit(id, ref, unit);
Christof Schmitt287ac012008-07-02 10:56:40 +02001487 atomic_clear_mask(mask, &unit->status);
1488 if (mask & ZFCP_STATUS_COMMON_ERP_FAILED) {
1489 atomic_set(&unit->erp_counter, 0);
1490 }
1491 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001492}
1493
Christof Schmitt287ac012008-07-02 10:56:40 +02001494/**
1495 * zfcp_erp_port_boxed - Mark port as "boxed" and start ERP
1496 * @port: The "boxed" port.
1497 * @id: The debug trace id.
1498 * @id: Reference for the debug trace.
1499 */
Swen Schillig5ffd51a2009-03-02 13:09:04 +01001500void zfcp_erp_port_boxed(struct zfcp_port *port, char *id, void *ref)
Andreas Herrmannd736a27b2005-06-13 13:23:57 +02001501{
Andreas Herrmannd736a27b2005-06-13 13:23:57 +02001502 unsigned long flags;
1503
Andreas Herrmannd736a27b2005-06-13 13:23:57 +02001504 read_lock_irqsave(&zfcp_data.config_lock, flags);
Martin Peschke698ec0162008-03-27 14:22:02 +01001505 zfcp_erp_modify_port_status(port, id, ref,
1506 ZFCP_STATUS_COMMON_ACCESS_BOXED, ZFCP_SET);
Andreas Herrmannd736a27b2005-06-13 13:23:57 +02001507 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
Martin Peschke9467a9b2008-03-27 14:22:03 +01001508 zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED, id, ref);
Andreas Herrmannd736a27b2005-06-13 13:23:57 +02001509}
1510
Christof Schmitt287ac012008-07-02 10:56:40 +02001511/**
1512 * zfcp_erp_unit_boxed - Mark unit as "boxed" and start ERP
1513 * @port: The "boxed" unit.
1514 * @id: The debug trace id.
1515 * @id: Reference for the debug trace.
1516 */
Swen Schillig5ffd51a2009-03-02 13:09:04 +01001517void zfcp_erp_unit_boxed(struct zfcp_unit *unit, char *id, void *ref)
Andreas Herrmannd736a27b2005-06-13 13:23:57 +02001518{
Martin Peschke698ec0162008-03-27 14:22:02 +01001519 zfcp_erp_modify_unit_status(unit, id, ref,
1520 ZFCP_STATUS_COMMON_ACCESS_BOXED, ZFCP_SET);
Martin Peschke9467a9b2008-03-27 14:22:03 +01001521 zfcp_erp_unit_reopen(unit, ZFCP_STATUS_COMMON_ERP_FAILED, id, ref);
Andreas Herrmannd736a27b2005-06-13 13:23:57 +02001522}
1523
Christof Schmitt287ac012008-07-02 10:56:40 +02001524/**
1525 * zfcp_erp_port_access_denied - Adapter denied access to port.
1526 * @port: port where access has been denied
1527 * @id: id for debug trace
1528 * @ref: reference for debug trace
1529 *
1530 * Since the adapter has denied access, stop using the port and the
1531 * attached units.
1532 */
Swen Schillig5ffd51a2009-03-02 13:09:04 +01001533void zfcp_erp_port_access_denied(struct zfcp_port *port, char *id, void *ref)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001534{
Linus Torvalds1da177e2005-04-16 15:20:36 -07001535 unsigned long flags;
1536
Linus Torvalds1da177e2005-04-16 15:20:36 -07001537 read_lock_irqsave(&zfcp_data.config_lock, flags);
Martin Peschke698ec0162008-03-27 14:22:02 +01001538 zfcp_erp_modify_port_status(port, id, ref,
1539 ZFCP_STATUS_COMMON_ERP_FAILED |
1540 ZFCP_STATUS_COMMON_ACCESS_DENIED, ZFCP_SET);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001541 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
1542}
1543
Christof Schmitt287ac012008-07-02 10:56:40 +02001544/**
1545 * zfcp_erp_unit_access_denied - Adapter denied access to unit.
1546 * @unit: unit where access has been denied
1547 * @id: id for debug trace
1548 * @ref: reference for debug trace
1549 *
1550 * Since the adapter has denied access, stop using the unit.
1551 */
Swen Schillig5ffd51a2009-03-02 13:09:04 +01001552void zfcp_erp_unit_access_denied(struct zfcp_unit *unit, char *id, void *ref)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001553{
Martin Peschke698ec0162008-03-27 14:22:02 +01001554 zfcp_erp_modify_unit_status(unit, id, ref,
1555 ZFCP_STATUS_COMMON_ERP_FAILED |
1556 ZFCP_STATUS_COMMON_ACCESS_DENIED, ZFCP_SET);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001557}
1558
Swen Schillig5ffd51a2009-03-02 13:09:04 +01001559static void zfcp_erp_unit_access_changed(struct zfcp_unit *unit, char *id,
Christof Schmitt287ac012008-07-02 10:56:40 +02001560 void *ref)
1561{
1562 int status = atomic_read(&unit->status);
1563 if (!(status & (ZFCP_STATUS_COMMON_ACCESS_DENIED |
1564 ZFCP_STATUS_COMMON_ACCESS_BOXED)))
1565 return;
1566
1567 zfcp_erp_unit_reopen(unit, ZFCP_STATUS_COMMON_ERP_FAILED, id, ref);
1568}
1569
Swen Schillig5ffd51a2009-03-02 13:09:04 +01001570static void zfcp_erp_port_access_changed(struct zfcp_port *port, char *id,
Christof Schmitt287ac012008-07-02 10:56:40 +02001571 void *ref)
1572{
1573 struct zfcp_unit *unit;
1574 int status = atomic_read(&port->status);
1575
1576 if (!(status & (ZFCP_STATUS_COMMON_ACCESS_DENIED |
1577 ZFCP_STATUS_COMMON_ACCESS_BOXED))) {
Swen Schillig5ab944f2008-10-01 12:42:17 +02001578 list_for_each_entry(unit, &port->unit_list_head, list)
1579 zfcp_erp_unit_access_changed(unit, id, ref);
Christof Schmitt287ac012008-07-02 10:56:40 +02001580 return;
1581 }
1582
1583 zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED, id, ref);
1584}
1585
1586/**
1587 * zfcp_erp_adapter_access_changed - Process change in adapter ACT
1588 * @adapter: Adapter where the Access Control Table (ACT) changed
1589 * @id: Id for debug trace
1590 * @ref: Reference for debug trace
1591 */
Swen Schillig5ffd51a2009-03-02 13:09:04 +01001592void zfcp_erp_adapter_access_changed(struct zfcp_adapter *adapter, char *id,
Martin Peschke1f6f7122008-04-18 12:51:55 +02001593 void *ref)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001594{
1595 struct zfcp_port *port;
1596 unsigned long flags;
1597
Maxim Shchetyninaef4a982005-09-13 21:51:16 +02001598 if (adapter->connection_features & FSF_FEATURE_NPIV_MODE)
1599 return;
1600
Linus Torvalds1da177e2005-04-16 15:20:36 -07001601 read_lock_irqsave(&zfcp_data.config_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001602 list_for_each_entry(port, &adapter->port_list_head, list)
Swen Schillig5ab944f2008-10-01 12:42:17 +02001603 zfcp_erp_port_access_changed(port, id, ref);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001604 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
1605}