diff options
author | Christof Schmitt <christof.schmitt@de.ibm.com> | 2010-09-08 08:39:55 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2010-09-16 22:54:17 -0400 |
commit | b62a8d9b45b971a67a0f8413338c230e3117dff5 (patch) | |
tree | a38acd9f0fcb14e41e26503d8a25d8f1539dd27d | |
parent | fdbd1c5e27dabfa950d4b0f52a20069aeaf67b9d (diff) |
[SCSI] zfcp: Use SCSI device data zfcp_scsi_dev instead of zfcp_unit
This is the large change to switch from using the data in
zfcp_unit to zfcp_scsi_dev. Keeping everything working requires doing
the switch in one piece. To ensure that no code keeps using the data
in zfcp_unit, this patch also removes the data from zfcp_unit that is
now being replaced with zfcp_scsi_dev.
For zfcp, the scsi_device together with zfcp_scsi_dev exist from the
call of slave_alloc to the call of slave_destroy. The data in
zfcp_scsi_dev is initialized in zfcp_scsi_slave_alloc and the LUN is
opened; the final shutdown for the LUN is run from slave_destroy.
Where the scsi_device or zfcp_scsi_dev is needed, the pointer to the
scsi_device is passed as function argument and inside the function
converted to the pointer to zfcp_scsi_dev; this avoids back and forth
conversion betweeen scsi_device and zfcp_scsi_dev.
While changing the function arguments from zfcp_unit to scsi_device,
the functions names are renamed form "unit" to "lun". This is to have
a seperation between zfcp_scsi_dev/LUN and the zfcp_unit; only code
referring to the remaining configuration information in zfcp_unit
struct uses "unit".
Reviewed-by: Swen Schillig <swen@vnet.ibm.com>
Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
-rw-r--r-- | drivers/s390/scsi/zfcp_dbf.c | 28 | ||||
-rw-r--r-- | drivers/s390/scsi/zfcp_dbf.h | 12 | ||||
-rw-r--r-- | drivers/s390/scsi/zfcp_def.h | 34 | ||||
-rw-r--r-- | drivers/s390/scsi/zfcp_erp.c | 369 | ||||
-rw-r--r-- | drivers/s390/scsi/zfcp_ext.h | 32 | ||||
-rw-r--r-- | drivers/s390/scsi/zfcp_fsf.c | 279 | ||||
-rw-r--r-- | drivers/s390/scsi/zfcp_scsi.c | 114 | ||||
-rw-r--r-- | drivers/s390/scsi/zfcp_sysfs.c | 66 | ||||
-rw-r--r-- | drivers/s390/scsi/zfcp_unit.c | 11 |
9 files changed, 480 insertions, 465 deletions
diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c index a86117b0d6e1..2224caa8b92d 100644 --- a/drivers/s390/scsi/zfcp_dbf.c +++ b/drivers/s390/scsi/zfcp_dbf.c | |||
@@ -482,7 +482,7 @@ static int zfcp_dbf_rec_view_format(debug_info_t *id, struct debug_view *view, | |||
482 | zfcp_dbf_out(&p, "fcp_lun", "0x%016Lx", r->u.trigger.fcp_lun); | 482 | zfcp_dbf_out(&p, "fcp_lun", "0x%016Lx", r->u.trigger.fcp_lun); |
483 | zfcp_dbf_out(&p, "adapter_status", "0x%08x", r->u.trigger.as); | 483 | zfcp_dbf_out(&p, "adapter_status", "0x%08x", r->u.trigger.as); |
484 | zfcp_dbf_out(&p, "port_status", "0x%08x", r->u.trigger.ps); | 484 | zfcp_dbf_out(&p, "port_status", "0x%08x", r->u.trigger.ps); |
485 | zfcp_dbf_out(&p, "unit_status", "0x%08x", r->u.trigger.us); | 485 | zfcp_dbf_out(&p, "lun_status", "0x%08x", r->u.trigger.ls); |
486 | break; | 486 | break; |
487 | case ZFCP_REC_DBF_ID_ACTION: | 487 | case ZFCP_REC_DBF_ID_ACTION: |
488 | zfcp_dbf_out(&p, "erp_action", "0x%016Lx", r->u.action.action); | 488 | zfcp_dbf_out(&p, "erp_action", "0x%016Lx", r->u.action.action); |
@@ -600,19 +600,20 @@ void zfcp_dbf_rec_port(char *id, void *ref, struct zfcp_port *port) | |||
600 | } | 600 | } |
601 | 601 | ||
602 | /** | 602 | /** |
603 | * zfcp_dbf_rec_unit - trace event for unit state change | 603 | * zfcp_dbf_rec_lun - trace event for LUN state change |
604 | * @id: identifier for trigger of state change | 604 | * @id: identifier for trigger of state change |
605 | * @ref: additional reference (e.g. request) | 605 | * @ref: additional reference (e.g. request) |
606 | * @unit: unit | 606 | * @sdev: SCSI device |
607 | */ | 607 | */ |
608 | void zfcp_dbf_rec_unit(char *id, void *ref, struct zfcp_unit *unit) | 608 | void zfcp_dbf_rec_lun(char *id, void *ref, struct scsi_device *sdev) |
609 | { | 609 | { |
610 | struct zfcp_port *port = unit->port; | 610 | struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); |
611 | struct zfcp_port *port = zfcp_sdev->port; | ||
611 | struct zfcp_dbf *dbf = port->adapter->dbf; | 612 | struct zfcp_dbf *dbf = port->adapter->dbf; |
612 | 613 | ||
613 | zfcp_dbf_rec_target(id, ref, dbf, &unit->status, | 614 | zfcp_dbf_rec_target(id, ref, dbf, &zfcp_sdev->status, |
614 | &unit->erp_counter, port->wwpn, port->d_id, | 615 | &zfcp_sdev->erp_counter, port->wwpn, port->d_id, |
615 | unit->fcp_lun); | 616 | zfcp_scsi_dev_lun(sdev)); |
616 | } | 617 | } |
617 | 618 | ||
618 | /** | 619 | /** |
@@ -624,11 +625,11 @@ void zfcp_dbf_rec_unit(char *id, void *ref, struct zfcp_unit *unit) | |||
624 | * @action: address of error recovery action struct | 625 | * @action: address of error recovery action struct |
625 | * @adapter: adapter | 626 | * @adapter: adapter |
626 | * @port: port | 627 | * @port: port |
627 | * @unit: unit | 628 | * @sdev: SCSI device |
628 | */ | 629 | */ |
629 | void zfcp_dbf_rec_trigger(char *id2, void *ref, u8 want, u8 need, void *action, | 630 | void zfcp_dbf_rec_trigger(char *id2, void *ref, u8 want, u8 need, void *action, |
630 | struct zfcp_adapter *adapter, struct zfcp_port *port, | 631 | struct zfcp_adapter *adapter, struct zfcp_port *port, |
631 | struct zfcp_unit *unit) | 632 | struct scsi_device *sdev) |
632 | { | 633 | { |
633 | struct zfcp_dbf *dbf = adapter->dbf; | 634 | struct zfcp_dbf *dbf = adapter->dbf; |
634 | struct zfcp_dbf_rec_record *r = &dbf->rec_buf; | 635 | struct zfcp_dbf_rec_record *r = &dbf->rec_buf; |
@@ -647,9 +648,10 @@ void zfcp_dbf_rec_trigger(char *id2, void *ref, u8 want, u8 need, void *action, | |||
647 | r->u.trigger.ps = atomic_read(&port->status); | 648 | r->u.trigger.ps = atomic_read(&port->status); |
648 | r->u.trigger.wwpn = port->wwpn; | 649 | r->u.trigger.wwpn = port->wwpn; |
649 | } | 650 | } |
650 | if (unit) | 651 | if (sdev) |
651 | r->u.trigger.us = atomic_read(&unit->status); | 652 | r->u.trigger.ls = atomic_read(&sdev_to_zfcp(sdev)->status); |
652 | r->u.trigger.fcp_lun = unit ? unit->fcp_lun : ZFCP_DBF_INVALID_LUN; | 653 | r->u.trigger.fcp_lun = sdev ? zfcp_scsi_dev_lun(sdev) : |
654 | ZFCP_DBF_INVALID_LUN; | ||
653 | debug_event(dbf->rec, action ? 1 : 4, r, sizeof(*r)); | 655 | debug_event(dbf->rec, action ? 1 : 4, r, sizeof(*r)); |
654 | spin_unlock_irqrestore(&dbf->rec_lock, flags); | 656 | spin_unlock_irqrestore(&dbf->rec_lock, flags); |
655 | } | 657 | } |
diff --git a/drivers/s390/scsi/zfcp_dbf.h b/drivers/s390/scsi/zfcp_dbf.h index 2bcc3403126a..6a48c197b45d 100644 --- a/drivers/s390/scsi/zfcp_dbf.h +++ b/drivers/s390/scsi/zfcp_dbf.h | |||
@@ -60,7 +60,7 @@ struct zfcp_dbf_rec_record_trigger { | |||
60 | u8 need; | 60 | u8 need; |
61 | u32 as; | 61 | u32 as; |
62 | u32 ps; | 62 | u32 ps; |
63 | u32 us; | 63 | u32 ls; |
64 | u64 ref; | 64 | u64 ref; |
65 | u64 action; | 65 | u64 action; |
66 | u64 wwpn; | 66 | u64 wwpn; |
@@ -350,16 +350,16 @@ void zfcp_dbf_scsi_abort(const char *tag, struct zfcp_dbf *dbf, | |||
350 | /** | 350 | /** |
351 | * zfcp_dbf_scsi_devreset - trace event for Logical Unit or Target Reset | 351 | * zfcp_dbf_scsi_devreset - trace event for Logical Unit or Target Reset |
352 | * @tag: tag indicating success or failure of reset operation | 352 | * @tag: tag indicating success or failure of reset operation |
353 | * @scmnd: SCSI command which caused this error recovery | ||
353 | * @flag: indicates type of reset (Target Reset, Logical Unit Reset) | 354 | * @flag: indicates type of reset (Target Reset, Logical Unit Reset) |
354 | * @unit: unit that needs reset | ||
355 | * @scsi_cmnd: SCSI command which caused this error recovery | ||
356 | */ | 355 | */ |
357 | static inline | 356 | static inline |
358 | void zfcp_dbf_scsi_devreset(const char *tag, u8 flag, struct zfcp_unit *unit, | 357 | void zfcp_dbf_scsi_devreset(const char *tag, struct scsi_cmnd *scmnd, u8 flag) |
359 | struct scsi_cmnd *scsi_cmnd) | ||
360 | { | 358 | { |
359 | struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(scmnd->device); | ||
360 | |||
361 | zfcp_dbf_scsi(flag == FCP_TMF_TGT_RESET ? "trst" : "lrst", tag, 1, | 361 | zfcp_dbf_scsi(flag == FCP_TMF_TGT_RESET ? "trst" : "lrst", tag, 1, |
362 | unit->port->adapter->dbf, scsi_cmnd, NULL, 0); | 362 | zfcp_sdev->port->adapter->dbf, scmnd, NULL, 0); |
363 | } | 363 | } |
364 | 364 | ||
365 | #endif /* ZFCP_DBF_H */ | 365 | #endif /* ZFCP_DBF_H */ |
diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h index d31158c0de93..6dfae7091aa4 100644 --- a/drivers/s390/scsi/zfcp_def.h +++ b/drivers/s390/scsi/zfcp_def.h | |||
@@ -85,8 +85,8 @@ struct zfcp_reqlist; | |||
85 | #define ZFCP_STATUS_PORT_LINK_TEST 0x00000002 | 85 | #define ZFCP_STATUS_PORT_LINK_TEST 0x00000002 |
86 | 86 | ||
87 | /* logical unit status */ | 87 | /* logical unit status */ |
88 | #define ZFCP_STATUS_UNIT_SHARED 0x00000004 | 88 | #define ZFCP_STATUS_LUN_SHARED 0x00000004 |
89 | #define ZFCP_STATUS_UNIT_READONLY 0x00000008 | 89 | #define ZFCP_STATUS_LUN_READONLY 0x00000008 |
90 | 90 | ||
91 | /* FSF request status (this does not have a common part) */ | 91 | /* FSF request status (this does not have a common part) */ |
92 | #define ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT 0x00000002 | 92 | #define ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT 0x00000002 |
@@ -118,7 +118,7 @@ struct zfcp_erp_action { | |||
118 | int action; /* requested action code */ | 118 | int action; /* requested action code */ |
119 | struct zfcp_adapter *adapter; /* device which should be recovered */ | 119 | struct zfcp_adapter *adapter; /* device which should be recovered */ |
120 | struct zfcp_port *port; | 120 | struct zfcp_port *port; |
121 | struct zfcp_unit *unit; | 121 | struct scsi_device *sdev; |
122 | u32 status; /* recovery status */ | 122 | u32 status; /* recovery status */ |
123 | u32 step; /* active step of this erp action */ | 123 | u32 step; /* active step of this erp action */ |
124 | unsigned long fsf_req_id; | 124 | unsigned long fsf_req_id; |
@@ -219,17 +219,23 @@ struct zfcp_port { | |||
219 | unsigned int starget_id; | 219 | unsigned int starget_id; |
220 | }; | 220 | }; |
221 | 221 | ||
222 | /** | ||
223 | * struct zfcp_unit - LUN configured via zfcp sysfs | ||
224 | * @dev: struct device for sysfs representation and reference counting | ||
225 | * @list: entry in LUN/unit list per zfcp_port | ||
226 | * @port: reference to zfcp_port where this LUN is configured | ||
227 | * @fcp_lun: 64 bit LUN value | ||
228 | * @scsi_work: for running scsi_scan_target | ||
229 | * | ||
230 | * This is the representation of a LUN that has been configured for | ||
231 | * usage. The main data here is the 64 bit LUN value, data for | ||
232 | * running I/O and recovery is in struct zfcp_scsi_dev. | ||
233 | */ | ||
222 | struct zfcp_unit { | 234 | struct zfcp_unit { |
223 | struct device dev; | 235 | struct device dev; |
224 | struct list_head list; /* list of logical units */ | 236 | struct list_head list; |
225 | struct zfcp_port *port; /* remote port of unit */ | 237 | struct zfcp_port *port; |
226 | atomic_t status; /* status of this logical unit */ | 238 | u64 fcp_lun; |
227 | u64 fcp_lun; /* own FCP_LUN */ | ||
228 | u32 handle; /* handle assigned by FSF */ | ||
229 | struct scsi_device *device; /* scsi device struct pointer */ | ||
230 | struct zfcp_erp_action erp_action; /* pending error recovery */ | ||
231 | atomic_t erp_counter; | ||
232 | struct zfcp_latencies latencies; | ||
233 | struct work_struct scsi_work; | 239 | struct work_struct scsi_work; |
234 | }; | 240 | }; |
235 | 241 | ||
@@ -288,7 +294,6 @@ static inline u64 zfcp_scsi_dev_lun(struct scsi_device *sdev) | |||
288 | * @erp_action: reference to erp action if request issued on behalf of ERP | 294 | * @erp_action: reference to erp action if request issued on behalf of ERP |
289 | * @pool: reference to memory pool if used for this request | 295 | * @pool: reference to memory pool if used for this request |
290 | * @issued: time when request was send (STCK) | 296 | * @issued: time when request was send (STCK) |
291 | * @unit: reference to unit if this request is a SCSI request | ||
292 | * @handler: handler which should be called to process response | 297 | * @handler: handler which should be called to process response |
293 | */ | 298 | */ |
294 | struct zfcp_fsf_req { | 299 | struct zfcp_fsf_req { |
@@ -306,7 +311,6 @@ struct zfcp_fsf_req { | |||
306 | struct zfcp_erp_action *erp_action; | 311 | struct zfcp_erp_action *erp_action; |
307 | mempool_t *pool; | 312 | mempool_t *pool; |
308 | unsigned long long issued; | 313 | unsigned long long issued; |
309 | struct zfcp_unit *unit; | ||
310 | void (*handler)(struct zfcp_fsf_req *); | 314 | void (*handler)(struct zfcp_fsf_req *); |
311 | }; | 315 | }; |
312 | 316 | ||
diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c index 50514b4c8732..734fc838931f 100644 --- a/drivers/s390/scsi/zfcp_erp.c +++ b/drivers/s390/scsi/zfcp_erp.c | |||
@@ -30,12 +30,12 @@ enum zfcp_erp_steps { | |||
30 | ZFCP_ERP_STEP_PHYS_PORT_CLOSING = 0x0010, | 30 | ZFCP_ERP_STEP_PHYS_PORT_CLOSING = 0x0010, |
31 | ZFCP_ERP_STEP_PORT_CLOSING = 0x0100, | 31 | ZFCP_ERP_STEP_PORT_CLOSING = 0x0100, |
32 | ZFCP_ERP_STEP_PORT_OPENING = 0x0800, | 32 | ZFCP_ERP_STEP_PORT_OPENING = 0x0800, |
33 | ZFCP_ERP_STEP_UNIT_CLOSING = 0x1000, | 33 | ZFCP_ERP_STEP_LUN_CLOSING = 0x1000, |
34 | ZFCP_ERP_STEP_UNIT_OPENING = 0x2000, | 34 | ZFCP_ERP_STEP_LUN_OPENING = 0x2000, |
35 | }; | 35 | }; |
36 | 36 | ||
37 | enum zfcp_erp_act_type { | 37 | enum zfcp_erp_act_type { |
38 | ZFCP_ERP_ACTION_REOPEN_UNIT = 1, | 38 | ZFCP_ERP_ACTION_REOPEN_LUN = 1, |
39 | ZFCP_ERP_ACTION_REOPEN_PORT = 2, | 39 | ZFCP_ERP_ACTION_REOPEN_PORT = 2, |
40 | ZFCP_ERP_ACTION_REOPEN_PORT_FORCED = 3, | 40 | ZFCP_ERP_ACTION_REOPEN_PORT_FORCED = 3, |
41 | ZFCP_ERP_ACTION_REOPEN_ADAPTER = 4, | 41 | ZFCP_ERP_ACTION_REOPEN_ADAPTER = 4, |
@@ -89,24 +89,24 @@ static void zfcp_erp_action_dismiss(struct zfcp_erp_action *act) | |||
89 | zfcp_erp_action_ready(act); | 89 | zfcp_erp_action_ready(act); |
90 | } | 90 | } |
91 | 91 | ||
92 | static void zfcp_erp_action_dismiss_unit(struct zfcp_unit *unit) | 92 | static void zfcp_erp_action_dismiss_lun(struct scsi_device *sdev) |
93 | { | 93 | { |
94 | if (atomic_read(&unit->status) & ZFCP_STATUS_COMMON_ERP_INUSE) | 94 | struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); |
95 | zfcp_erp_action_dismiss(&unit->erp_action); | 95 | |
96 | if (atomic_read(&zfcp_sdev->status) & ZFCP_STATUS_COMMON_ERP_INUSE) | ||
97 | zfcp_erp_action_dismiss(&zfcp_sdev->erp_action); | ||
96 | } | 98 | } |
97 | 99 | ||
98 | static void zfcp_erp_action_dismiss_port(struct zfcp_port *port) | 100 | static void zfcp_erp_action_dismiss_port(struct zfcp_port *port) |
99 | { | 101 | { |
100 | struct zfcp_unit *unit; | 102 | struct scsi_device *sdev; |
101 | 103 | ||
102 | if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_INUSE) | 104 | if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_INUSE) |
103 | zfcp_erp_action_dismiss(&port->erp_action); | 105 | zfcp_erp_action_dismiss(&port->erp_action); |
104 | else { | 106 | else |
105 | read_lock(&port->unit_list_lock); | 107 | shost_for_each_device(sdev, port->adapter->scsi_host) |
106 | list_for_each_entry(unit, &port->unit_list, list) | 108 | if (sdev_to_zfcp(sdev)->port == port) |
107 | zfcp_erp_action_dismiss_unit(unit); | 109 | zfcp_erp_action_dismiss_lun(sdev); |
108 | read_unlock(&port->unit_list_lock); | ||
109 | } | ||
110 | } | 110 | } |
111 | 111 | ||
112 | static void zfcp_erp_action_dismiss_adapter(struct zfcp_adapter *adapter) | 112 | static void zfcp_erp_action_dismiss_adapter(struct zfcp_adapter *adapter) |
@@ -125,15 +125,17 @@ static void zfcp_erp_action_dismiss_adapter(struct zfcp_adapter *adapter) | |||
125 | 125 | ||
126 | static int zfcp_erp_required_act(int want, struct zfcp_adapter *adapter, | 126 | static int zfcp_erp_required_act(int want, struct zfcp_adapter *adapter, |
127 | struct zfcp_port *port, | 127 | struct zfcp_port *port, |
128 | struct zfcp_unit *unit) | 128 | struct scsi_device *sdev) |
129 | { | 129 | { |
130 | int need = want; | 130 | int need = want; |
131 | int u_status, p_status, a_status; | 131 | int l_status, p_status, a_status; |
132 | struct zfcp_scsi_dev *zfcp_sdev; | ||
132 | 133 | ||
133 | switch (want) { | 134 | switch (want) { |
134 | case ZFCP_ERP_ACTION_REOPEN_UNIT: | 135 | case ZFCP_ERP_ACTION_REOPEN_LUN: |
135 | u_status = atomic_read(&unit->status); | 136 | zfcp_sdev = sdev_to_zfcp(sdev); |
136 | if (u_status & ZFCP_STATUS_COMMON_ERP_INUSE) | 137 | l_status = atomic_read(&zfcp_sdev->status); |
138 | if (l_status & ZFCP_STATUS_COMMON_ERP_INUSE) | ||
137 | return 0; | 139 | return 0; |
138 | p_status = atomic_read(&port->status); | 140 | p_status = atomic_read(&port->status); |
139 | if (!(p_status & ZFCP_STATUS_COMMON_RUNNING) || | 141 | if (!(p_status & ZFCP_STATUS_COMMON_RUNNING) || |
@@ -173,18 +175,22 @@ static int zfcp_erp_required_act(int want, struct zfcp_adapter *adapter, | |||
173 | static struct zfcp_erp_action *zfcp_erp_setup_act(int need, u32 act_status, | 175 | static struct zfcp_erp_action *zfcp_erp_setup_act(int need, u32 act_status, |
174 | struct zfcp_adapter *adapter, | 176 | struct zfcp_adapter *adapter, |
175 | struct zfcp_port *port, | 177 | struct zfcp_port *port, |
176 | struct zfcp_unit *unit) | 178 | struct scsi_device *sdev) |
177 | { | 179 | { |
178 | struct zfcp_erp_action *erp_action; | 180 | struct zfcp_erp_action *erp_action; |
181 | struct zfcp_scsi_dev *zfcp_sdev; | ||
179 | 182 | ||
180 | switch (need) { | 183 | switch (need) { |
181 | case ZFCP_ERP_ACTION_REOPEN_UNIT: | 184 | case ZFCP_ERP_ACTION_REOPEN_LUN: |
185 | zfcp_sdev = sdev_to_zfcp(sdev); | ||
182 | if (!(act_status & ZFCP_STATUS_ERP_NO_REF)) | 186 | if (!(act_status & ZFCP_STATUS_ERP_NO_REF)) |
183 | if (!get_device(&unit->dev)) | 187 | if (scsi_device_get(sdev)) |
184 | return NULL; | 188 | return NULL; |
185 | atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &unit->status); | 189 | atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, |
186 | erp_action = &unit->erp_action; | 190 | &zfcp_sdev->status); |
187 | if (!(atomic_read(&unit->status) & ZFCP_STATUS_COMMON_RUNNING)) | 191 | erp_action = &zfcp_sdev->erp_action; |
192 | if (!(atomic_read(&zfcp_sdev->status) & | ||
193 | ZFCP_STATUS_COMMON_RUNNING)) | ||
188 | act_status |= ZFCP_STATUS_ERP_CLOSE_ONLY; | 194 | act_status |= ZFCP_STATUS_ERP_CLOSE_ONLY; |
189 | break; | 195 | break; |
190 | 196 | ||
@@ -216,7 +222,7 @@ static struct zfcp_erp_action *zfcp_erp_setup_act(int need, u32 act_status, | |||
216 | memset(erp_action, 0, sizeof(struct zfcp_erp_action)); | 222 | memset(erp_action, 0, sizeof(struct zfcp_erp_action)); |
217 | erp_action->adapter = adapter; | 223 | erp_action->adapter = adapter; |
218 | erp_action->port = port; | 224 | erp_action->port = port; |
219 | erp_action->unit = unit; | 225 | erp_action->sdev = sdev; |
220 | erp_action->action = need; | 226 | erp_action->action = need; |
221 | erp_action->status = act_status; | 227 | erp_action->status = act_status; |
222 | 228 | ||
@@ -225,8 +231,8 @@ static struct zfcp_erp_action *zfcp_erp_setup_act(int need, u32 act_status, | |||
225 | 231 | ||
226 | static int zfcp_erp_action_enqueue(int want, struct zfcp_adapter *adapter, | 232 | static int zfcp_erp_action_enqueue(int want, struct zfcp_adapter *adapter, |
227 | struct zfcp_port *port, | 233 | struct zfcp_port *port, |
228 | struct zfcp_unit *unit, char *id, void *ref, | 234 | struct scsi_device *sdev, |
229 | u32 act_status) | 235 | char *id, void *ref, u32 act_status) |
230 | { | 236 | { |
231 | int retval = 1, need; | 237 | int retval = 1, need; |
232 | struct zfcp_erp_action *act = NULL; | 238 | struct zfcp_erp_action *act = NULL; |
@@ -234,11 +240,11 @@ static int zfcp_erp_action_enqueue(int want, struct zfcp_adapter *adapter, | |||
234 | if (!adapter->erp_thread) | 240 | if (!adapter->erp_thread) |
235 | return -EIO; | 241 | return -EIO; |
236 | 242 | ||
237 | need = zfcp_erp_required_act(want, adapter, port, unit); | 243 | need = zfcp_erp_required_act(want, adapter, port, sdev); |
238 | if (!need) | 244 | if (!need) |
239 | goto out; | 245 | goto out; |
240 | 246 | ||
241 | act = zfcp_erp_setup_act(need, act_status, adapter, port, unit); | 247 | act = zfcp_erp_setup_act(need, act_status, adapter, port, sdev); |
242 | if (!act) | 248 | if (!act) |
243 | goto out; | 249 | goto out; |
244 | atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING, &adapter->status); | 250 | atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING, &adapter->status); |
@@ -248,7 +254,7 @@ static int zfcp_erp_action_enqueue(int want, struct zfcp_adapter *adapter, | |||
248 | zfcp_dbf_rec_thread("eracte1", adapter->dbf); | 254 | zfcp_dbf_rec_thread("eracte1", adapter->dbf); |
249 | retval = 0; | 255 | retval = 0; |
250 | out: | 256 | out: |
251 | zfcp_dbf_rec_trigger(id, ref, want, need, act, adapter, port, unit); | 257 | zfcp_dbf_rec_trigger(id, ref, want, need, act, adapter, port, sdev); |
252 | return retval; | 258 | return retval; |
253 | } | 259 | } |
254 | 260 | ||
@@ -392,77 +398,81 @@ int zfcp_erp_port_reopen(struct zfcp_port *port, int clear, char *id, void *ref) | |||
392 | return retval; | 398 | return retval; |
393 | } | 399 | } |
394 | 400 | ||
395 | static void zfcp_erp_unit_block(struct zfcp_unit *unit, int clear_mask) | 401 | static void zfcp_erp_lun_block(struct scsi_device *sdev, int clear_mask) |
396 | { | 402 | { |
397 | zfcp_erp_modify_unit_status(unit, "erublk1", NULL, | 403 | zfcp_erp_modify_lun_status(sdev, "erlblk1", NULL, |
398 | ZFCP_STATUS_COMMON_UNBLOCKED | clear_mask, | 404 | ZFCP_STATUS_COMMON_UNBLOCKED | clear_mask, |
399 | ZFCP_CLEAR); | 405 | ZFCP_CLEAR); |
400 | } | 406 | } |
401 | 407 | ||
402 | static void _zfcp_erp_unit_reopen(struct zfcp_unit *unit, int clear, char *id, | 408 | static void _zfcp_erp_lun_reopen(struct scsi_device *sdev, int clear, char *id, |
403 | void *ref, u32 act_status) | 409 | void *ref, u32 act_status) |
404 | { | 410 | { |
405 | struct zfcp_adapter *adapter = unit->port->adapter; | 411 | struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); |
412 | struct zfcp_adapter *adapter = zfcp_sdev->port->adapter; | ||
406 | 413 | ||
407 | zfcp_erp_unit_block(unit, clear); | 414 | zfcp_erp_lun_block(sdev, clear); |
408 | 415 | ||
409 | if (atomic_read(&unit->status) & ZFCP_STATUS_COMMON_ERP_FAILED) | 416 | if (atomic_read(&zfcp_sdev->status) & ZFCP_STATUS_COMMON_ERP_FAILED) |
410 | return; | 417 | return; |
411 | 418 | ||
412 | zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_UNIT, | 419 | zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_LUN, adapter, |
413 | adapter, unit->port, unit, id, ref, act_status); | 420 | zfcp_sdev->port, sdev, id, ref, act_status); |
414 | } | 421 | } |
415 | 422 | ||
416 | /** | 423 | /** |
417 | * zfcp_erp_unit_reopen - initiate reopen of a unit | 424 | * zfcp_erp_lun_reopen - initiate reopen of a LUN |
418 | * @unit: unit to be reopened | 425 | * @sdev: SCSI device / LUN to be reopened |
419 | * @clear_mask: specifies flags in unit status to be cleared | 426 | * @clear_mask: specifies flags in LUN status to be cleared |
420 | * Return: 0 on success, < 0 on error | 427 | * Return: 0 on success, < 0 on error |
421 | */ | 428 | */ |
422 | void zfcp_erp_unit_reopen(struct zfcp_unit *unit, int clear, char *id, | 429 | void zfcp_erp_lun_reopen(struct scsi_device *sdev, int clear, char *id, |
423 | void *ref) | 430 | void *ref) |
424 | { | 431 | { |
425 | unsigned long flags; | 432 | unsigned long flags; |
426 | struct zfcp_port *port = unit->port; | 433 | struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); |
434 | struct zfcp_port *port = zfcp_sdev->port; | ||
427 | struct zfcp_adapter *adapter = port->adapter; | 435 | struct zfcp_adapter *adapter = port->adapter; |
428 | 436 | ||
429 | write_lock_irqsave(&adapter->erp_lock, flags); | 437 | write_lock_irqsave(&adapter->erp_lock, flags); |
430 | _zfcp_erp_unit_reopen(unit, clear, id, ref, 0); | 438 | _zfcp_erp_lun_reopen(sdev, clear, id, ref, 0); |
431 | write_unlock_irqrestore(&adapter->erp_lock, flags); | 439 | write_unlock_irqrestore(&adapter->erp_lock, flags); |
432 | } | 440 | } |
433 | 441 | ||
434 | /** | 442 | /** |
435 | * zfcp_erp_unit_shutdown - Shutdown unit | 443 | * zfcp_erp_lun_shutdown - Shutdown LUN |
436 | * @unit: Unit to shut down. | 444 | * @sdev: SCSI device / LUN to shut down. |
437 | * @clear: Status flags to clear. | 445 | * @clear: Status flags to clear. |
438 | * @id: Id for debug trace event. | 446 | * @id: Id for debug trace event. |
439 | * @ref: Reference for debug trace event. | 447 | * @ref: Reference for debug trace event. |
440 | */ | 448 | */ |
441 | void zfcp_erp_unit_shutdown(struct zfcp_unit *unit, int clear, char *id, | 449 | void zfcp_erp_lun_shutdown(struct scsi_device *sdev, int clear, char *id, |
442 | void *ref) | 450 | void *ref) |
443 | { | 451 | { |
444 | int flags = ZFCP_STATUS_COMMON_RUNNING | ZFCP_STATUS_COMMON_ERP_FAILED; | 452 | int flags = ZFCP_STATUS_COMMON_RUNNING | ZFCP_STATUS_COMMON_ERP_FAILED; |
445 | zfcp_erp_unit_reopen(unit, clear | flags, id, ref); | 453 | zfcp_erp_lun_reopen(sdev, clear | flags, id, ref); |
446 | } | 454 | } |
447 | 455 | ||
448 | /** | 456 | /** |
449 | * zfcp_erp_unit_shutdown_wait - Shutdown unit and wait for erp completion | 457 | * zfcp_erp_lun_shutdown_wait - Shutdown LUN and wait for erp completion |
450 | * @unit: Unit to shut down. | 458 | * @sdev: SCSI device / LUN to shut down. |
451 | * @id: Id for debug trace event. | 459 | * @id: Id for debug trace event. |
452 | * | 460 | * |
453 | * Do not acquire a reference for the unit when creating the ERP | 461 | * Do not acquire a reference for the LUN when creating the ERP |
454 | * action. It is safe, because this function waits for the ERP to | 462 | * action. It is safe, because this function waits for the ERP to |
455 | * complete first. | 463 | * complete first. This allows to shutdown the LUN, even when the SCSI |
464 | * device is in the state SDEV_DEL when scsi_device_get will fail. | ||
456 | */ | 465 | */ |
457 | void zfcp_erp_unit_shutdown_wait(struct zfcp_unit *unit, char *id) | 466 | void zfcp_erp_lun_shutdown_wait(struct scsi_device *sdev, char *id) |
458 | { | 467 | { |
459 | unsigned long flags; | 468 | unsigned long flags; |
460 | struct zfcp_port *port = unit->port; | 469 | struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); |
470 | struct zfcp_port *port = zfcp_sdev->port; | ||
461 | struct zfcp_adapter *adapter = port->adapter; | 471 | struct zfcp_adapter *adapter = port->adapter; |
462 | int clear = ZFCP_STATUS_COMMON_RUNNING | ZFCP_STATUS_COMMON_ERP_FAILED; | 472 | int clear = ZFCP_STATUS_COMMON_RUNNING | ZFCP_STATUS_COMMON_ERP_FAILED; |
463 | 473 | ||
464 | write_lock_irqsave(&adapter->erp_lock, flags); | 474 | write_lock_irqsave(&adapter->erp_lock, flags); |
465 | _zfcp_erp_unit_reopen(unit, clear, id, NULL, ZFCP_STATUS_ERP_NO_REF); | 475 | _zfcp_erp_lun_reopen(sdev, clear, id, NULL, ZFCP_STATUS_ERP_NO_REF); |
466 | write_unlock_irqrestore(&adapter->erp_lock, flags); | 476 | write_unlock_irqrestore(&adapter->erp_lock, flags); |
467 | 477 | ||
468 | zfcp_erp_wait(adapter); | 478 | zfcp_erp_wait(adapter); |
@@ -492,11 +502,13 @@ static void zfcp_erp_port_unblock(struct zfcp_port *port) | |||
492 | atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &port->status); | 502 | atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &port->status); |
493 | } | 503 | } |
494 | 504 | ||
495 | static void zfcp_erp_unit_unblock(struct zfcp_unit *unit) | 505 | static void zfcp_erp_lun_unblock(struct scsi_device *sdev) |
496 | { | 506 | { |
497 | if (status_change_set(ZFCP_STATUS_COMMON_UNBLOCKED, &unit->status)) | 507 | struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); |
498 | zfcp_dbf_rec_unit("eruubl1", NULL, unit); | 508 | |
499 | atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &unit->status); | 509 | if (status_change_set(ZFCP_STATUS_COMMON_UNBLOCKED, &zfcp_sdev->status)) |
510 | zfcp_dbf_rec_lun("erlubl1", NULL, sdev); | ||
511 | atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &zfcp_sdev->status); | ||
500 | } | 512 | } |
501 | 513 | ||
502 | static void zfcp_erp_action_to_running(struct zfcp_erp_action *erp_action) | 514 | static void zfcp_erp_action_to_running(struct zfcp_erp_action *erp_action) |
@@ -584,15 +596,14 @@ static void _zfcp_erp_port_reopen_all(struct zfcp_adapter *adapter, | |||
584 | read_unlock(&adapter->port_list_lock); | 596 | read_unlock(&adapter->port_list_lock); |
585 | } | 597 | } |
586 | 598 | ||
587 | static void _zfcp_erp_unit_reopen_all(struct zfcp_port *port, int clear, | 599 | static void _zfcp_erp_lun_reopen_all(struct zfcp_port *port, int clear, |
588 | char *id, void *ref) | 600 | char *id, void *ref) |
589 | { | 601 | { |
590 | struct zfcp_unit *unit; | 602 | struct scsi_device *sdev; |
591 | 603 | ||
592 | read_lock(&port->unit_list_lock); | 604 | shost_for_each_device(sdev, port->adapter->scsi_host) |
593 | list_for_each_entry(unit, &port->unit_list, list) | 605 | if (sdev_to_zfcp(sdev)->port == port) |
594 | _zfcp_erp_unit_reopen(unit, clear, id, ref, 0); | 606 | _zfcp_erp_lun_reopen(sdev, clear, id, ref, 0); |
595 | read_unlock(&port->unit_list_lock); | ||
596 | } | 607 | } |
597 | 608 | ||
598 | static void zfcp_erp_strategy_followup_failed(struct zfcp_erp_action *act) | 609 | static void zfcp_erp_strategy_followup_failed(struct zfcp_erp_action *act) |
@@ -607,8 +618,8 @@ static void zfcp_erp_strategy_followup_failed(struct zfcp_erp_action *act) | |||
607 | case ZFCP_ERP_ACTION_REOPEN_PORT: | 618 | case ZFCP_ERP_ACTION_REOPEN_PORT: |
608 | _zfcp_erp_port_reopen(act->port, 0, "ersff_3", NULL); | 619 | _zfcp_erp_port_reopen(act->port, 0, "ersff_3", NULL); |
609 | break; | 620 | break; |
610 | case ZFCP_ERP_ACTION_REOPEN_UNIT: | 621 | case ZFCP_ERP_ACTION_REOPEN_LUN: |
611 | _zfcp_erp_unit_reopen(act->unit, 0, "ersff_4", NULL, 0); | 622 | _zfcp_erp_lun_reopen(act->sdev, 0, "ersff_4", NULL, 0); |
612 | break; | 623 | break; |
613 | } | 624 | } |
614 | } | 625 | } |
@@ -623,7 +634,7 @@ static void zfcp_erp_strategy_followup_success(struct zfcp_erp_action *act) | |||
623 | _zfcp_erp_port_reopen(act->port, 0, "ersfs_2", NULL); | 634 | _zfcp_erp_port_reopen(act->port, 0, "ersfs_2", NULL); |
624 | break; | 635 | break; |
625 | case ZFCP_ERP_ACTION_REOPEN_PORT: | 636 | case ZFCP_ERP_ACTION_REOPEN_PORT: |
626 | _zfcp_erp_unit_reopen_all(act->port, 0, "ersfs_3", NULL); | 637 | _zfcp_erp_lun_reopen_all(act->port, 0, "ersfs_3", NULL); |
627 | break; | 638 | break; |
628 | } | 639 | } |
629 | } | 640 | } |
@@ -767,7 +778,7 @@ static void zfcp_erp_adapter_strategy_close(struct zfcp_erp_action *act) | |||
767 | zfcp_fsf_req_dismiss_all(adapter); | 778 | zfcp_fsf_req_dismiss_all(adapter); |
768 | adapter->fsf_req_seq_no = 0; | 779 | adapter->fsf_req_seq_no = 0; |
769 | zfcp_fc_wka_ports_force_offline(adapter->gs); | 780 | zfcp_fc_wka_ports_force_offline(adapter->gs); |
770 | /* all ports and units are closed */ | 781 | /* all ports and LUNs are closed */ |
771 | zfcp_erp_modify_adapter_status(adapter, "erascl1", NULL, | 782 | zfcp_erp_modify_adapter_status(adapter, "erascl1", NULL, |
772 | ZFCP_STATUS_COMMON_OPEN, ZFCP_CLEAR); | 783 | ZFCP_STATUS_COMMON_OPEN, ZFCP_CLEAR); |
773 | 784 | ||
@@ -958,82 +969,86 @@ close_init_done: | |||
958 | return zfcp_erp_port_strategy_open_common(erp_action); | 969 | return zfcp_erp_port_strategy_open_common(erp_action); |
959 | } | 970 | } |
960 | 971 | ||
961 | static void zfcp_erp_unit_strategy_clearstati(struct zfcp_unit *unit) | 972 | static void zfcp_erp_lun_strategy_clearstati(struct scsi_device *sdev) |
962 | { | 973 | { |
974 | struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); | ||
975 | |||
963 | atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED | | 976 | atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED | |
964 | ZFCP_STATUS_UNIT_SHARED | | 977 | ZFCP_STATUS_LUN_SHARED | ZFCP_STATUS_LUN_READONLY, |
965 | ZFCP_STATUS_UNIT_READONLY, | 978 | &zfcp_sdev->status); |
966 | &unit->status); | ||
967 | } | 979 | } |
968 | 980 | ||
969 | static int zfcp_erp_unit_strategy_close(struct zfcp_erp_action *erp_action) | 981 | static int zfcp_erp_lun_strategy_close(struct zfcp_erp_action *erp_action) |
970 | { | 982 | { |
971 | int retval = zfcp_fsf_close_unit(erp_action); | 983 | int retval = zfcp_fsf_close_lun(erp_action); |
972 | if (retval == -ENOMEM) | 984 | if (retval == -ENOMEM) |
973 | return ZFCP_ERP_NOMEM; | 985 | return ZFCP_ERP_NOMEM; |
974 | erp_action->step = ZFCP_ERP_STEP_UNIT_CLOSING; | 986 | erp_action->step = ZFCP_ERP_STEP_LUN_CLOSING; |
975 | if (retval) | 987 | if (retval) |
976 | return ZFCP_ERP_FAILED; | 988 | return ZFCP_ERP_FAILED; |
977 | return ZFCP_ERP_CONTINUES; | 989 | return ZFCP_ERP_CONTINUES; |
978 | } | 990 | } |
979 | 991 | ||
980 | static int zfcp_erp_unit_strategy_open(struct zfcp_erp_action *erp_action) | 992 | static int zfcp_erp_lun_strategy_open(struct zfcp_erp_action *erp_action) |
981 | { | 993 | { |
982 | int retval = zfcp_fsf_open_unit(erp_action); | 994 | int retval = zfcp_fsf_open_lun(erp_action); |
983 | if (retval == -ENOMEM) | 995 | if (retval == -ENOMEM) |
984 | return ZFCP_ERP_NOMEM; | 996 | return ZFCP_ERP_NOMEM; |
985 | erp_action->step = ZFCP_ERP_STEP_UNIT_OPENING; | 997 | erp_action->step = ZFCP_ERP_STEP_LUN_OPENING; |
986 | if (retval) | 998 | if (retval) |
987 | return ZFCP_ERP_FAILED; | 999 | return ZFCP_ERP_FAILED; |
988 | return ZFCP_ERP_CONTINUES; | 1000 | return ZFCP_ERP_CONTINUES; |
989 | } | 1001 | } |
990 | 1002 | ||
991 | static int zfcp_erp_unit_strategy(struct zfcp_erp_action *erp_action) | 1003 | static int zfcp_erp_lun_strategy(struct zfcp_erp_action *erp_action) |
992 | { | 1004 | { |
993 | struct zfcp_unit *unit = erp_action->unit; | 1005 | struct scsi_device *sdev = erp_action->sdev; |
1006 | struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); | ||
994 | 1007 | ||
995 | switch (erp_action->step) { | 1008 | switch (erp_action->step) { |
996 | case ZFCP_ERP_STEP_UNINITIALIZED: | 1009 | case ZFCP_ERP_STEP_UNINITIALIZED: |
997 | zfcp_erp_unit_strategy_clearstati(unit); | 1010 | zfcp_erp_lun_strategy_clearstati(sdev); |
998 | if (atomic_read(&unit->status) & ZFCP_STATUS_COMMON_OPEN) | 1011 | if (atomic_read(&zfcp_sdev->status) & ZFCP_STATUS_COMMON_OPEN) |
999 | return zfcp_erp_unit_strategy_close(erp_action); | 1012 | return zfcp_erp_lun_strategy_close(erp_action); |
1000 | /* already closed, fall through */ | 1013 | /* already closed, fall through */ |
1001 | case ZFCP_ERP_STEP_UNIT_CLOSING: | 1014 | case ZFCP_ERP_STEP_LUN_CLOSING: |
1002 | if (atomic_read(&unit->status) & ZFCP_STATUS_COMMON_OPEN) | 1015 | if (atomic_read(&zfcp_sdev->status) & ZFCP_STATUS_COMMON_OPEN) |
1003 | return ZFCP_ERP_FAILED; | 1016 | return ZFCP_ERP_FAILED; |
1004 | if (erp_action->status & ZFCP_STATUS_ERP_CLOSE_ONLY) | 1017 | if (erp_action->status & ZFCP_STATUS_ERP_CLOSE_ONLY) |
1005 | return ZFCP_ERP_EXIT; | 1018 | return ZFCP_ERP_EXIT; |
1006 | return zfcp_erp_unit_strategy_open(erp_action); | 1019 | return zfcp_erp_lun_strategy_open(erp_action); |
1007 | 1020 | ||
1008 | case ZFCP_ERP_STEP_UNIT_OPENING: | 1021 | case ZFCP_ERP_STEP_LUN_OPENING: |
1009 | if (atomic_read(&unit->status) & ZFCP_STATUS_COMMON_OPEN) | 1022 | if (atomic_read(&zfcp_sdev->status) & ZFCP_STATUS_COMMON_OPEN) |
1010 | return ZFCP_ERP_SUCCEEDED; | 1023 | return ZFCP_ERP_SUCCEEDED; |
1011 | } | 1024 | } |
1012 | return ZFCP_ERP_FAILED; | 1025 | return ZFCP_ERP_FAILED; |
1013 | } | 1026 | } |
1014 | 1027 | ||
1015 | static int zfcp_erp_strategy_check_unit(struct zfcp_unit *unit, int result) | 1028 | static int zfcp_erp_strategy_check_lun(struct scsi_device *sdev, int result) |
1016 | { | 1029 | { |
1030 | struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); | ||
1031 | |||
1017 | switch (result) { | 1032 | switch (result) { |
1018 | case ZFCP_ERP_SUCCEEDED : | 1033 | case ZFCP_ERP_SUCCEEDED : |
1019 | atomic_set(&unit->erp_counter, 0); | 1034 | atomic_set(&zfcp_sdev->erp_counter, 0); |
1020 | zfcp_erp_unit_unblock(unit); | 1035 | zfcp_erp_lun_unblock(sdev); |
1021 | break; | 1036 | break; |
1022 | case ZFCP_ERP_FAILED : | 1037 | case ZFCP_ERP_FAILED : |
1023 | atomic_inc(&unit->erp_counter); | 1038 | atomic_inc(&zfcp_sdev->erp_counter); |
1024 | if (atomic_read(&unit->erp_counter) > ZFCP_MAX_ERPS) { | 1039 | if (atomic_read(&zfcp_sdev->erp_counter) > ZFCP_MAX_ERPS) { |
1025 | dev_err(&unit->port->adapter->ccw_device->dev, | 1040 | dev_err(&zfcp_sdev->port->adapter->ccw_device->dev, |
1026 | "ERP failed for unit 0x%016Lx on " | 1041 | "ERP failed for LUN 0x%016Lx on " |
1027 | "port 0x%016Lx\n", | 1042 | "port 0x%016Lx\n", |
1028 | (unsigned long long)unit->fcp_lun, | 1043 | (unsigned long long)zfcp_scsi_dev_lun(sdev), |
1029 | (unsigned long long)unit->port->wwpn); | 1044 | (unsigned long long)zfcp_sdev->port->wwpn); |
1030 | zfcp_erp_unit_failed(unit, "erusck1", NULL); | 1045 | zfcp_erp_lun_failed(sdev, "ersckl1", NULL); |
1031 | } | 1046 | } |
1032 | break; | 1047 | break; |
1033 | } | 1048 | } |
1034 | 1049 | ||
1035 | if (atomic_read(&unit->status) & ZFCP_STATUS_COMMON_ERP_FAILED) { | 1050 | if (atomic_read(&zfcp_sdev->status) & ZFCP_STATUS_COMMON_ERP_FAILED) { |
1036 | zfcp_erp_unit_block(unit, 0); | 1051 | zfcp_erp_lun_block(sdev, 0); |
1037 | result = ZFCP_ERP_EXIT; | 1052 | result = ZFCP_ERP_EXIT; |
1038 | } | 1053 | } |
1039 | return result; | 1054 | return result; |
@@ -1101,12 +1116,12 @@ static int zfcp_erp_strategy_check_target(struct zfcp_erp_action *erp_action, | |||
1101 | { | 1116 | { |
1102 | struct zfcp_adapter *adapter = erp_action->adapter; | 1117 | struct zfcp_adapter *adapter = erp_action->adapter; |
1103 | struct zfcp_port *port = erp_action->port; | 1118 | struct zfcp_port *port = erp_action->port; |
1104 | struct zfcp_unit *unit = erp_action->unit; | 1119 | struct scsi_device *sdev = erp_action->sdev; |
1105 | 1120 | ||
1106 | switch (erp_action->action) { | 1121 | switch (erp_action->action) { |
1107 | 1122 | ||
1108 | case ZFCP_ERP_ACTION_REOPEN_UNIT: | 1123 | case ZFCP_ERP_ACTION_REOPEN_LUN: |
1109 | result = zfcp_erp_strategy_check_unit(unit, result); | 1124 | result = zfcp_erp_strategy_check_lun(sdev, result); |
1110 | break; | 1125 | break; |
1111 | 1126 | ||
1112 | case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: | 1127 | case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: |
@@ -1141,7 +1156,8 @@ static int zfcp_erp_strategy_statechange(struct zfcp_erp_action *act, int ret) | |||
1141 | int action = act->action; | 1156 | int action = act->action; |
1142 | struct zfcp_adapter *adapter = act->adapter; | 1157 | struct zfcp_adapter *adapter = act->adapter; |
1143 | struct zfcp_port *port = act->port; | 1158 | struct zfcp_port *port = act->port; |
1144 | struct zfcp_unit *unit = act->unit; | 1159 | struct scsi_device *sdev = act->sdev; |
1160 | struct zfcp_scsi_dev *zfcp_sdev; | ||
1145 | u32 erp_status = act->status; | 1161 | u32 erp_status = act->status; |
1146 | 1162 | ||
1147 | switch (action) { | 1163 | switch (action) { |
@@ -1164,11 +1180,12 @@ static int zfcp_erp_strategy_statechange(struct zfcp_erp_action *act, int ret) | |||
1164 | } | 1180 | } |
1165 | break; | 1181 | break; |
1166 | 1182 | ||
1167 | case ZFCP_ERP_ACTION_REOPEN_UNIT: | 1183 | case ZFCP_ERP_ACTION_REOPEN_LUN: |
1168 | if (zfcp_erp_strat_change_det(&unit->status, erp_status)) { | 1184 | zfcp_sdev = sdev_to_zfcp(sdev); |
1169 | _zfcp_erp_unit_reopen(unit, | 1185 | if (zfcp_erp_strat_change_det(&zfcp_sdev->status, erp_status)) { |
1170 | ZFCP_STATUS_COMMON_ERP_FAILED, | 1186 | _zfcp_erp_lun_reopen(sdev, |
1171 | "ersscg3", NULL, 0); | 1187 | ZFCP_STATUS_COMMON_ERP_FAILED, |
1188 | "ersscg3", NULL, 0); | ||
1172 | return ZFCP_ERP_EXIT; | 1189 | return ZFCP_ERP_EXIT; |
1173 | } | 1190 | } |
1174 | break; | 1191 | break; |
@@ -1179,6 +1196,7 @@ static int zfcp_erp_strategy_statechange(struct zfcp_erp_action *act, int ret) | |||
1179 | static void zfcp_erp_action_dequeue(struct zfcp_erp_action *erp_action) | 1196 | static void zfcp_erp_action_dequeue(struct zfcp_erp_action *erp_action) |
1180 | { | 1197 | { |
1181 | struct zfcp_adapter *adapter = erp_action->adapter; | 1198 | struct zfcp_adapter *adapter = erp_action->adapter; |
1199 | struct zfcp_scsi_dev *zfcp_sdev; | ||
1182 | 1200 | ||
1183 | adapter->erp_total_count--; | 1201 | adapter->erp_total_count--; |
1184 | if (erp_action->status & ZFCP_STATUS_ERP_LOWMEM) { | 1202 | if (erp_action->status & ZFCP_STATUS_ERP_LOWMEM) { |
@@ -1190,9 +1208,10 @@ static void zfcp_erp_action_dequeue(struct zfcp_erp_action *erp_action) | |||
1190 | zfcp_dbf_rec_action("eractd1", erp_action); | 1208 | zfcp_dbf_rec_action("eractd1", erp_action); |
1191 | 1209 | ||
1192 | switch (erp_action->action) { | 1210 | switch (erp_action->action) { |
1193 | case ZFCP_ERP_ACTION_REOPEN_UNIT: | 1211 | case ZFCP_ERP_ACTION_REOPEN_LUN: |
1212 | zfcp_sdev = sdev_to_zfcp(erp_action->sdev); | ||
1194 | atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE, | 1213 | atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE, |
1195 | &erp_action->unit->status); | 1214 | &zfcp_sdev->status); |
1196 | break; | 1215 | break; |
1197 | 1216 | ||
1198 | case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: | 1217 | case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: |
@@ -1212,12 +1231,12 @@ static void zfcp_erp_action_cleanup(struct zfcp_erp_action *act, int result) | |||
1212 | { | 1231 | { |
1213 | struct zfcp_adapter *adapter = act->adapter; | 1232 | struct zfcp_adapter *adapter = act->adapter; |
1214 | struct zfcp_port *port = act->port; | 1233 | struct zfcp_port *port = act->port; |
1215 | struct zfcp_unit *unit = act->unit; | 1234 | struct scsi_device *sdev = act->sdev; |
1216 | 1235 | ||
1217 | switch (act->action) { | 1236 | switch (act->action) { |
1218 | case ZFCP_ERP_ACTION_REOPEN_UNIT: | 1237 | case ZFCP_ERP_ACTION_REOPEN_LUN: |
1219 | if (!(act->status & ZFCP_STATUS_ERP_NO_REF)) | 1238 | if (!(act->status & ZFCP_STATUS_ERP_NO_REF)) |
1220 | put_device(&unit->dev); | 1239 | scsi_device_put(sdev); |
1221 | break; | 1240 | break; |
1222 | 1241 | ||
1223 | case ZFCP_ERP_ACTION_REOPEN_PORT: | 1242 | case ZFCP_ERP_ACTION_REOPEN_PORT: |
@@ -1248,8 +1267,8 @@ static int zfcp_erp_strategy_do_action(struct zfcp_erp_action *erp_action) | |||
1248 | return zfcp_erp_port_forced_strategy(erp_action); | 1267 | return zfcp_erp_port_forced_strategy(erp_action); |
1249 | case ZFCP_ERP_ACTION_REOPEN_PORT: | 1268 | case ZFCP_ERP_ACTION_REOPEN_PORT: |
1250 | return zfcp_erp_port_strategy(erp_action); | 1269 | return zfcp_erp_port_strategy(erp_action); |
1251 | case ZFCP_ERP_ACTION_REOPEN_UNIT: | 1270 | case ZFCP_ERP_ACTION_REOPEN_LUN: |
1252 | return zfcp_erp_unit_strategy(erp_action); | 1271 | return zfcp_erp_lun_strategy(erp_action); |
1253 | } | 1272 | } |
1254 | return ZFCP_ERP_FAILED; | 1273 | return ZFCP_ERP_FAILED; |
1255 | } | 1274 | } |
@@ -1426,15 +1445,15 @@ void zfcp_erp_port_failed(struct zfcp_port *port, char *id, void *ref) | |||
1426 | } | 1445 | } |
1427 | 1446 | ||
1428 | /** | 1447 | /** |
1429 | * zfcp_erp_unit_failed - Set unit status to failed. | 1448 | * zfcp_erp_lun_failed - Set LUN status to failed. |
1430 | * @unit: Failed unit. | 1449 | * @sdev: Failed SCSI device / LUN |
1431 | * @id: Event id for debug trace. | 1450 | * @id: Event id for debug trace. |
1432 | * @ref: Reference for debug trace. | 1451 | * @ref: Reference for debug trace. |
1433 | */ | 1452 | */ |
1434 | void zfcp_erp_unit_failed(struct zfcp_unit *unit, char *id, void *ref) | 1453 | void zfcp_erp_lun_failed(struct scsi_device *sdev, char *id, void *ref) |
1435 | { | 1454 | { |
1436 | zfcp_erp_modify_unit_status(unit, id, ref, | 1455 | zfcp_erp_modify_lun_status(sdev, id, ref, |
1437 | ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET); | 1456 | ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET); |
1438 | } | 1457 | } |
1439 | 1458 | ||
1440 | /** | 1459 | /** |
@@ -1456,7 +1475,7 @@ void zfcp_erp_wait(struct zfcp_adapter *adapter) | |||
1456 | * @mask: status bits to change | 1475 | * @mask: status bits to change |
1457 | * @set_or_clear: ZFCP_SET or ZFCP_CLEAR | 1476 | * @set_or_clear: ZFCP_SET or ZFCP_CLEAR |
1458 | * | 1477 | * |
1459 | * Changes in common status bits are propagated to attached ports and units. | 1478 | * Changes in common status bits are propagated to attached ports and LUNs. |
1460 | */ | 1479 | */ |
1461 | void zfcp_erp_modify_adapter_status(struct zfcp_adapter *adapter, char *id, | 1480 | void zfcp_erp_modify_adapter_status(struct zfcp_adapter *adapter, char *id, |
1462 | void *ref, u32 mask, int set_or_clear) | 1481 | void *ref, u32 mask, int set_or_clear) |
@@ -1494,13 +1513,12 @@ void zfcp_erp_modify_adapter_status(struct zfcp_adapter *adapter, char *id, | |||
1494 | * @mask: status bits to change | 1513 | * @mask: status bits to change |
1495 | * @set_or_clear: ZFCP_SET or ZFCP_CLEAR | 1514 | * @set_or_clear: ZFCP_SET or ZFCP_CLEAR |
1496 | * | 1515 | * |
1497 | * Changes in common status bits are propagated to attached units. | 1516 | * Changes in common status bits are propagated to attached LUNs. |
1498 | */ | 1517 | */ |
1499 | void zfcp_erp_modify_port_status(struct zfcp_port *port, char *id, void *ref, | 1518 | void zfcp_erp_modify_port_status(struct zfcp_port *port, char *id, void *ref, |
1500 | u32 mask, int set_or_clear) | 1519 | u32 mask, int set_or_clear) |
1501 | { | 1520 | { |
1502 | struct zfcp_unit *unit; | 1521 | struct scsi_device *sdev; |
1503 | unsigned long flags; | ||
1504 | u32 common_mask = mask & ZFCP_COMMON_FLAGS; | 1522 | u32 common_mask = mask & ZFCP_COMMON_FLAGS; |
1505 | 1523 | ||
1506 | if (set_or_clear == ZFCP_SET) { | 1524 | if (set_or_clear == ZFCP_SET) { |
@@ -1515,36 +1533,37 @@ void zfcp_erp_modify_port_status(struct zfcp_port *port, char *id, void *ref, | |||
1515 | atomic_set(&port->erp_counter, 0); | 1533 | atomic_set(&port->erp_counter, 0); |
1516 | } | 1534 | } |
1517 | 1535 | ||
1518 | if (common_mask) { | 1536 | if (common_mask) |
1519 | read_lock_irqsave(&port->unit_list_lock, flags); | 1537 | shost_for_each_device(sdev, port->adapter->scsi_host) |
1520 | list_for_each_entry(unit, &port->unit_list, list) | 1538 | if (sdev_to_zfcp(sdev)->port == port) |
1521 | zfcp_erp_modify_unit_status(unit, id, ref, common_mask, | 1539 | zfcp_erp_modify_lun_status(sdev, id, ref, |
1522 | set_or_clear); | 1540 | common_mask, |
1523 | read_unlock_irqrestore(&port->unit_list_lock, flags); | 1541 | set_or_clear); |
1524 | } | ||
1525 | } | 1542 | } |
1526 | 1543 | ||
1527 | /** | 1544 | /** |
1528 | * zfcp_erp_modify_unit_status - change unit status bits | 1545 | * zfcp_erp_modify_lun_status - change LUN status bits |
1529 | * @unit: unit to change the status bits | 1546 | * @sdev: SCSI device / LUN where to change the status bits |
1530 | * @id: id for the debug trace | 1547 | * @id: id for the debug trace |
1531 | * @ref: reference for the debug trace | 1548 | * @ref: reference for the debug trace |
1532 | * @mask: status bits to change | 1549 | * @mask: status bits to change |
1533 | * @set_or_clear: ZFCP_SET or ZFCP_CLEAR | 1550 | * @set_or_clear: ZFCP_SET or ZFCP_CLEAR |
1534 | */ | 1551 | */ |
1535 | void zfcp_erp_modify_unit_status(struct zfcp_unit *unit, char *id, void *ref, | 1552 | void zfcp_erp_modify_lun_status(struct scsi_device *sdev, char *id, void *ref, |
1536 | u32 mask, int set_or_clear) | 1553 | u32 mask, int set_or_clear) |
1537 | { | 1554 | { |
1555 | struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); | ||
1556 | |||
1538 | if (set_or_clear == ZFCP_SET) { | 1557 | if (set_or_clear == ZFCP_SET) { |
1539 | if (status_change_set(mask, &unit->status)) | 1558 | if (status_change_set(mask, &zfcp_sdev->status)) |
1540 | zfcp_dbf_rec_unit(id, ref, unit); | 1559 | zfcp_dbf_rec_lun(id, ref, sdev); |
1541 | atomic_set_mask(mask, &unit->status); | 1560 | atomic_set_mask(mask, &zfcp_sdev->status); |
1542 | } else { | 1561 | } else { |
1543 | if (status_change_clear(mask, &unit->status)) | 1562 | if (status_change_clear(mask, &zfcp_sdev->status)) |
1544 | zfcp_dbf_rec_unit(id, ref, unit); | 1563 | zfcp_dbf_rec_lun(id, ref, sdev); |
1545 | atomic_clear_mask(mask, &unit->status); | 1564 | atomic_clear_mask(mask, &zfcp_sdev->status); |
1546 | if (mask & ZFCP_STATUS_COMMON_ERP_FAILED) { | 1565 | if (mask & ZFCP_STATUS_COMMON_ERP_FAILED) { |
1547 | atomic_set(&unit->erp_counter, 0); | 1566 | atomic_set(&zfcp_sdev->erp_counter, 0); |
1548 | } | 1567 | } |
1549 | } | 1568 | } |
1550 | } | 1569 | } |
@@ -1563,16 +1582,16 @@ void zfcp_erp_port_boxed(struct zfcp_port *port, char *id, void *ref) | |||
1563 | } | 1582 | } |
1564 | 1583 | ||
1565 | /** | 1584 | /** |
1566 | * zfcp_erp_unit_boxed - Mark unit as "boxed" and start ERP | 1585 | * zfcp_erp_lun_boxed - Mark LUN as "boxed" and start ERP |
1567 | * @port: The "boxed" unit. | 1586 | * @sdev: The "boxed" SCSI device / LUN. |
1568 | * @id: The debug trace id. | 1587 | * @id: The debug trace id. |
1569 | * @id: Reference for the debug trace. | 1588 | * @ref: Reference for the debug trace. |
1570 | */ | 1589 | */ |
1571 | void zfcp_erp_unit_boxed(struct zfcp_unit *unit, char *id, void *ref) | 1590 | void zfcp_erp_lun_boxed(struct scsi_device *sdev, char *id, void *ref) |
1572 | { | 1591 | { |
1573 | zfcp_erp_modify_unit_status(unit, id, ref, | 1592 | zfcp_erp_modify_lun_status(sdev, id, ref, |
1574 | ZFCP_STATUS_COMMON_ACCESS_BOXED, ZFCP_SET); | 1593 | ZFCP_STATUS_COMMON_ACCESS_BOXED, ZFCP_SET); |
1575 | zfcp_erp_unit_reopen(unit, ZFCP_STATUS_COMMON_ERP_FAILED, id, ref); | 1594 | zfcp_erp_lun_reopen(sdev, ZFCP_STATUS_COMMON_ERP_FAILED, id, ref); |
1576 | } | 1595 | } |
1577 | 1596 | ||
1578 | /** | 1597 | /** |
@@ -1582,7 +1601,7 @@ void zfcp_erp_unit_boxed(struct zfcp_unit *unit, char *id, void *ref) | |||
1582 | * @ref: reference for debug trace | 1601 | * @ref: reference for debug trace |
1583 | * | 1602 | * |
1584 | * Since the adapter has denied access, stop using the port and the | 1603 | * Since the adapter has denied access, stop using the port and the |
1585 | * attached units. | 1604 | * attached LUNs. |
1586 | */ | 1605 | */ |
1587 | void zfcp_erp_port_access_denied(struct zfcp_port *port, char *id, void *ref) | 1606 | void zfcp_erp_port_access_denied(struct zfcp_port *port, char *id, void *ref) |
1588 | { | 1607 | { |
@@ -1592,44 +1611,44 @@ void zfcp_erp_port_access_denied(struct zfcp_port *port, char *id, void *ref) | |||
1592 | } | 1611 | } |
1593 | 1612 | ||
1594 | /** | 1613 | /** |
1595 | * zfcp_erp_unit_access_denied - Adapter denied access to unit. | 1614 | * zfcp_erp_lun_access_denied - Adapter denied access to LUN. |
1596 | * @unit: unit where access has been denied | 1615 | * @sdev: SCSI device / LUN where access has been denied |
1597 | * @id: id for debug trace | 1616 | * @id: id for debug trace |
1598 | * @ref: reference for debug trace | 1617 | * @ref: reference for debug trace |
1599 | * | 1618 | * |
1600 | * Since the adapter has denied access, stop using the unit. | 1619 | * Since the adapter has denied access, stop using the LUN. |
1601 | */ | 1620 | */ |
1602 | void zfcp_erp_unit_access_denied(struct zfcp_unit *unit, char *id, void *ref) | 1621 | void zfcp_erp_lun_access_denied(struct scsi_device *sdev, char *id, void *ref) |
1603 | { | 1622 | { |
1604 | zfcp_erp_modify_unit_status(unit, id, ref, | 1623 | zfcp_erp_modify_lun_status(sdev, id, ref, |
1605 | ZFCP_STATUS_COMMON_ERP_FAILED | | 1624 | ZFCP_STATUS_COMMON_ERP_FAILED | |
1606 | ZFCP_STATUS_COMMON_ACCESS_DENIED, ZFCP_SET); | 1625 | ZFCP_STATUS_COMMON_ACCESS_DENIED, ZFCP_SET); |
1607 | } | 1626 | } |
1608 | 1627 | ||
1609 | static void zfcp_erp_unit_access_changed(struct zfcp_unit *unit, char *id, | 1628 | static void zfcp_erp_lun_access_changed(struct scsi_device *sdev, char *id, |
1610 | void *ref) | 1629 | void *ref) |
1611 | { | 1630 | { |
1612 | int status = atomic_read(&unit->status); | 1631 | struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); |
1632 | int status = atomic_read(&zfcp_sdev->status); | ||
1633 | |||
1613 | if (!(status & (ZFCP_STATUS_COMMON_ACCESS_DENIED | | 1634 | if (!(status & (ZFCP_STATUS_COMMON_ACCESS_DENIED | |
1614 | ZFCP_STATUS_COMMON_ACCESS_BOXED))) | 1635 | ZFCP_STATUS_COMMON_ACCESS_BOXED))) |
1615 | return; | 1636 | return; |
1616 | 1637 | ||
1617 | zfcp_erp_unit_reopen(unit, ZFCP_STATUS_COMMON_ERP_FAILED, id, ref); | 1638 | zfcp_erp_lun_reopen(sdev, ZFCP_STATUS_COMMON_ERP_FAILED, id, ref); |
1618 | } | 1639 | } |
1619 | 1640 | ||
1620 | static void zfcp_erp_port_access_changed(struct zfcp_port *port, char *id, | 1641 | static void zfcp_erp_port_access_changed(struct zfcp_port *port, char *id, |
1621 | void *ref) | 1642 | void *ref) |
1622 | { | 1643 | { |
1623 | struct zfcp_unit *unit; | 1644 | struct scsi_device *sdev; |
1624 | unsigned long flags; | ||
1625 | int status = atomic_read(&port->status); | 1645 | int status = atomic_read(&port->status); |
1626 | 1646 | ||
1627 | if (!(status & (ZFCP_STATUS_COMMON_ACCESS_DENIED | | 1647 | if (!(status & (ZFCP_STATUS_COMMON_ACCESS_DENIED | |
1628 | ZFCP_STATUS_COMMON_ACCESS_BOXED))) { | 1648 | ZFCP_STATUS_COMMON_ACCESS_BOXED))) { |
1629 | read_lock_irqsave(&port->unit_list_lock, flags); | 1649 | shost_for_each_device(sdev, port->adapter->scsi_host) |
1630 | list_for_each_entry(unit, &port->unit_list, list) | 1650 | if (sdev_to_zfcp(sdev)->port == port) |
1631 | zfcp_erp_unit_access_changed(unit, id, ref); | 1651 | zfcp_erp_lun_access_changed(sdev, id, ref); |
1632 | read_unlock_irqrestore(&port->unit_list_lock, flags); | ||
1633 | return; | 1652 | return; |
1634 | } | 1653 | } |
1635 | 1654 | ||
diff --git a/drivers/s390/scsi/zfcp_ext.h b/drivers/s390/scsi/zfcp_ext.h index 3c90604076e0..80714679f5d6 100644 --- a/drivers/s390/scsi/zfcp_ext.h +++ b/drivers/s390/scsi/zfcp_ext.h | |||
@@ -42,10 +42,10 @@ extern void zfcp_dbf_rec_thread(char *, struct zfcp_dbf *); | |||
42 | extern void zfcp_dbf_rec_thread_lock(char *, struct zfcp_dbf *); | 42 | extern void zfcp_dbf_rec_thread_lock(char *, struct zfcp_dbf *); |
43 | extern void zfcp_dbf_rec_adapter(char *, void *, struct zfcp_dbf *); | 43 | extern void zfcp_dbf_rec_adapter(char *, void *, struct zfcp_dbf *); |
44 | extern void zfcp_dbf_rec_port(char *, void *, struct zfcp_port *); | 44 | extern void zfcp_dbf_rec_port(char *, void *, struct zfcp_port *); |
45 | extern void zfcp_dbf_rec_unit(char *, void *, struct zfcp_unit *); | 45 | extern void zfcp_dbf_rec_lun(char *, void *, struct scsi_device *); |
46 | extern void zfcp_dbf_rec_trigger(char *, void *, u8, u8, void *, | 46 | extern void zfcp_dbf_rec_trigger(char *, void *, u8, u8, void *, |
47 | struct zfcp_adapter *, struct zfcp_port *, | 47 | struct zfcp_adapter *, struct zfcp_port *, |
48 | struct zfcp_unit *); | 48 | struct scsi_device *); |
49 | extern void zfcp_dbf_rec_action(char *, struct zfcp_erp_action *); | 49 | extern void zfcp_dbf_rec_action(char *, struct zfcp_erp_action *); |
50 | extern void _zfcp_dbf_hba_fsf_response(const char *, int, struct zfcp_fsf_req *, | 50 | extern void _zfcp_dbf_hba_fsf_response(const char *, int, struct zfcp_fsf_req *, |
51 | struct zfcp_dbf *); | 51 | struct zfcp_dbf *); |
@@ -76,20 +76,20 @@ extern void zfcp_erp_port_shutdown(struct zfcp_port *, int, char *, void *); | |||
76 | extern void zfcp_erp_port_forced_reopen(struct zfcp_port *, int, char *, | 76 | extern void zfcp_erp_port_forced_reopen(struct zfcp_port *, int, char *, |
77 | void *); | 77 | void *); |
78 | extern void zfcp_erp_port_failed(struct zfcp_port *, char *, void *); | 78 | extern void zfcp_erp_port_failed(struct zfcp_port *, char *, void *); |
79 | extern void zfcp_erp_modify_unit_status(struct zfcp_unit *, char *, void *, u32, | 79 | extern void zfcp_erp_modify_lun_status(struct scsi_device *, char *, void *, |
80 | int); | 80 | u32, int); |
81 | extern void zfcp_erp_unit_reopen(struct zfcp_unit *, int, char *, void *); | 81 | extern void zfcp_erp_lun_reopen(struct scsi_device *, int, char *, void *); |
82 | extern void zfcp_erp_unit_shutdown(struct zfcp_unit *, int, char *, void *); | 82 | extern void zfcp_erp_lun_shutdown(struct scsi_device *, int, char *, void *); |
83 | extern void zfcp_erp_unit_shutdown_wait(struct zfcp_unit *, char *); | 83 | extern void zfcp_erp_lun_shutdown_wait(struct scsi_device *, char *); |
84 | extern void zfcp_erp_unit_failed(struct zfcp_unit *, char *, void *); | 84 | extern void zfcp_erp_lun_failed(struct scsi_device *, char *, void *); |
85 | extern int zfcp_erp_thread_setup(struct zfcp_adapter *); | 85 | extern int zfcp_erp_thread_setup(struct zfcp_adapter *); |
86 | extern void zfcp_erp_thread_kill(struct zfcp_adapter *); | 86 | extern void zfcp_erp_thread_kill(struct zfcp_adapter *); |
87 | extern void zfcp_erp_wait(struct zfcp_adapter *); | 87 | extern void zfcp_erp_wait(struct zfcp_adapter *); |
88 | extern void zfcp_erp_notify(struct zfcp_erp_action *, unsigned long); | 88 | extern void zfcp_erp_notify(struct zfcp_erp_action *, unsigned long); |
89 | extern void zfcp_erp_port_boxed(struct zfcp_port *, char *, void *); | 89 | extern void zfcp_erp_port_boxed(struct zfcp_port *, char *, void *); |
90 | extern void zfcp_erp_unit_boxed(struct zfcp_unit *, char *, void *); | 90 | extern void zfcp_erp_lun_boxed(struct scsi_device *, char *, void *); |
91 | extern void zfcp_erp_port_access_denied(struct zfcp_port *, char *, void *); | 91 | extern void zfcp_erp_port_access_denied(struct zfcp_port *, char *, void *); |
92 | extern void zfcp_erp_unit_access_denied(struct zfcp_unit *, char *, void *); | 92 | extern void zfcp_erp_lun_access_denied(struct scsi_device *, char *, void *); |
93 | extern void zfcp_erp_adapter_access_changed(struct zfcp_adapter *, char *, | 93 | extern void zfcp_erp_adapter_access_changed(struct zfcp_adapter *, char *, |
94 | void *); | 94 | void *); |
95 | extern void zfcp_erp_timeout_handler(unsigned long); | 95 | extern void zfcp_erp_timeout_handler(unsigned long); |
@@ -117,8 +117,8 @@ extern int zfcp_fsf_open_wka_port(struct zfcp_fc_wka_port *); | |||
117 | extern int zfcp_fsf_close_wka_port(struct zfcp_fc_wka_port *); | 117 | extern int zfcp_fsf_close_wka_port(struct zfcp_fc_wka_port *); |
118 | extern int zfcp_fsf_close_port(struct zfcp_erp_action *); | 118 | extern int zfcp_fsf_close_port(struct zfcp_erp_action *); |
119 | extern int zfcp_fsf_close_physical_port(struct zfcp_erp_action *); | 119 | extern int zfcp_fsf_close_physical_port(struct zfcp_erp_action *); |
120 | extern int zfcp_fsf_open_unit(struct zfcp_erp_action *); | 120 | extern int zfcp_fsf_open_lun(struct zfcp_erp_action *); |
121 | extern int zfcp_fsf_close_unit(struct zfcp_erp_action *); | 121 | extern int zfcp_fsf_close_lun(struct zfcp_erp_action *); |
122 | extern int zfcp_fsf_exchange_config_data(struct zfcp_erp_action *); | 122 | extern int zfcp_fsf_exchange_config_data(struct zfcp_erp_action *); |
123 | extern int zfcp_fsf_exchange_config_data_sync(struct zfcp_qdio *, | 123 | extern int zfcp_fsf_exchange_config_data_sync(struct zfcp_qdio *, |
124 | struct fsf_qtcb_bottom_config *); | 124 | struct fsf_qtcb_bottom_config *); |
@@ -134,12 +134,10 @@ extern int zfcp_fsf_send_ct(struct zfcp_fc_wka_port *, struct zfcp_fsf_ct_els *, | |||
134 | mempool_t *, unsigned int); | 134 | mempool_t *, unsigned int); |
135 | extern int zfcp_fsf_send_els(struct zfcp_adapter *, u32, | 135 | extern int zfcp_fsf_send_els(struct zfcp_adapter *, u32, |
136 | struct zfcp_fsf_ct_els *, unsigned int); | 136 | struct zfcp_fsf_ct_els *, unsigned int); |
137 | extern int zfcp_fsf_send_fcp_command_task(struct zfcp_unit *, | 137 | extern int zfcp_fsf_fcp_cmnd(struct scsi_cmnd *); |
138 | struct scsi_cmnd *); | ||
139 | extern void zfcp_fsf_req_free(struct zfcp_fsf_req *); | 138 | extern void zfcp_fsf_req_free(struct zfcp_fsf_req *); |
140 | extern struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_unit *, u8); | 139 | extern struct zfcp_fsf_req *zfcp_fsf_fcp_task_mgmt(struct scsi_cmnd *, u8); |
141 | extern struct zfcp_fsf_req *zfcp_fsf_abort_fcp_command(unsigned long, | 140 | extern struct zfcp_fsf_req *zfcp_fsf_abort_fcp_cmnd(struct scsi_cmnd *); |
142 | struct zfcp_unit *); | ||
143 | extern void zfcp_fsf_reqid_check(struct zfcp_qdio *, int); | 141 | extern void zfcp_fsf_reqid_check(struct zfcp_qdio *, int); |
144 | 142 | ||
145 | /* zfcp_qdio.c */ | 143 | /* zfcp_qdio.c */ |
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c index 9d1d7d1842ce..2fbd80257bca 100644 --- a/drivers/s390/scsi/zfcp_fsf.c +++ b/drivers/s390/scsi/zfcp_fsf.c | |||
@@ -86,17 +86,19 @@ static void zfcp_fsf_access_denied_port(struct zfcp_fsf_req *req, | |||
86 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; | 86 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
87 | } | 87 | } |
88 | 88 | ||
89 | static void zfcp_fsf_access_denied_unit(struct zfcp_fsf_req *req, | 89 | static void zfcp_fsf_access_denied_lun(struct zfcp_fsf_req *req, |
90 | struct zfcp_unit *unit) | 90 | struct scsi_device *sdev) |
91 | { | 91 | { |
92 | struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); | ||
93 | |||
92 | struct fsf_qtcb_header *header = &req->qtcb->header; | 94 | struct fsf_qtcb_header *header = &req->qtcb->header; |
93 | dev_warn(&req->adapter->ccw_device->dev, | 95 | dev_warn(&req->adapter->ccw_device->dev, |
94 | "Access denied to unit 0x%016Lx on port 0x%016Lx\n", | 96 | "Access denied to LUN 0x%016Lx on port 0x%016Lx\n", |
95 | (unsigned long long)unit->fcp_lun, | 97 | (unsigned long long)zfcp_scsi_dev_lun(sdev), |
96 | (unsigned long long)unit->port->wwpn); | 98 | (unsigned long long)zfcp_sdev->port->wwpn); |
97 | zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[0]); | 99 | zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[0]); |
98 | zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[1]); | 100 | zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[1]); |
99 | zfcp_erp_unit_access_denied(unit, "fsuad_1", req); | 101 | zfcp_erp_lun_access_denied(sdev, "fsadl_1", req); |
100 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; | 102 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
101 | } | 103 | } |
102 | 104 | ||
@@ -811,7 +813,8 @@ out: | |||
811 | 813 | ||
812 | static void zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *req) | 814 | static void zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *req) |
813 | { | 815 | { |
814 | struct zfcp_unit *unit = req->data; | 816 | struct scsi_device *sdev = req->data; |
817 | struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); | ||
815 | union fsf_status_qual *fsq = &req->qtcb->header.fsf_status_qual; | 818 | union fsf_status_qual *fsq = &req->qtcb->header.fsf_status_qual; |
816 | 819 | ||
817 | if (req->status & ZFCP_STATUS_FSFREQ_ERROR) | 820 | if (req->status & ZFCP_STATUS_FSFREQ_ERROR) |
@@ -820,14 +823,15 @@ static void zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *req) | |||
820 | switch (req->qtcb->header.fsf_status) { | 823 | switch (req->qtcb->header.fsf_status) { |
821 | case FSF_PORT_HANDLE_NOT_VALID: | 824 | case FSF_PORT_HANDLE_NOT_VALID: |
822 | if (fsq->word[0] == fsq->word[1]) { | 825 | if (fsq->word[0] == fsq->word[1]) { |
823 | zfcp_erp_adapter_reopen(unit->port->adapter, 0, | 826 | zfcp_erp_adapter_reopen(zfcp_sdev->port->adapter, 0, |
824 | "fsafch1", req); | 827 | "fsafch1", req); |
825 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; | 828 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
826 | } | 829 | } |
827 | break; | 830 | break; |
828 | case FSF_LUN_HANDLE_NOT_VALID: | 831 | case FSF_LUN_HANDLE_NOT_VALID: |
829 | if (fsq->word[0] == fsq->word[1]) { | 832 | if (fsq->word[0] == fsq->word[1]) { |
830 | zfcp_erp_port_reopen(unit->port, 0, "fsafch2", req); | 833 | zfcp_erp_port_reopen(zfcp_sdev->port, 0, "fsafch2", |
834 | req); | ||
831 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; | 835 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
832 | } | 836 | } |
833 | break; | 837 | break; |
@@ -835,17 +839,17 @@ static void zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *req) | |||
835 | req->status |= ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED; | 839 | req->status |= ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED; |
836 | break; | 840 | break; |
837 | case FSF_PORT_BOXED: | 841 | case FSF_PORT_BOXED: |
838 | zfcp_erp_port_boxed(unit->port, "fsafch3", req); | 842 | zfcp_erp_port_boxed(zfcp_sdev->port, "fsafch3", req); |
839 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; | 843 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
840 | break; | 844 | break; |
841 | case FSF_LUN_BOXED: | 845 | case FSF_LUN_BOXED: |
842 | zfcp_erp_unit_boxed(unit, "fsafch4", req); | 846 | zfcp_erp_lun_boxed(sdev, "fsafch4", req); |
843 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; | 847 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
844 | break; | 848 | break; |
845 | case FSF_ADAPTER_STATUS_AVAILABLE: | 849 | case FSF_ADAPTER_STATUS_AVAILABLE: |
846 | switch (fsq->word[0]) { | 850 | switch (fsq->word[0]) { |
847 | case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: | 851 | case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: |
848 | zfcp_fc_test_link(unit->port); | 852 | zfcp_fc_test_link(zfcp_sdev->port); |
849 | /* fall through */ | 853 | /* fall through */ |
850 | case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED: | 854 | case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED: |
851 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; | 855 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
@@ -859,17 +863,18 @@ static void zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *req) | |||
859 | } | 863 | } |
860 | 864 | ||
861 | /** | 865 | /** |
862 | * zfcp_fsf_abort_fcp_command - abort running SCSI command | 866 | * zfcp_fsf_abort_fcp_cmnd - abort running SCSI command |
863 | * @old_req_id: unsigned long | 867 | * @scmnd: The SCSI command to abort |
864 | * @unit: pointer to struct zfcp_unit | ||
865 | * Returns: pointer to struct zfcp_fsf_req | 868 | * Returns: pointer to struct zfcp_fsf_req |
866 | */ | 869 | */ |
867 | 870 | ||
868 | struct zfcp_fsf_req *zfcp_fsf_abort_fcp_command(unsigned long old_req_id, | 871 | struct zfcp_fsf_req *zfcp_fsf_abort_fcp_cmnd(struct scsi_cmnd *scmnd) |
869 | struct zfcp_unit *unit) | ||
870 | { | 872 | { |
871 | struct zfcp_fsf_req *req = NULL; | 873 | struct zfcp_fsf_req *req = NULL; |
872 | struct zfcp_qdio *qdio = unit->port->adapter->qdio; | 874 | struct scsi_device *sdev = scmnd->device; |
875 | struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); | ||
876 | struct zfcp_qdio *qdio = zfcp_sdev->port->adapter->qdio; | ||
877 | unsigned long old_req_id = (unsigned long) scmnd->host_scribble; | ||
873 | 878 | ||
874 | spin_lock_bh(&qdio->req_q_lock); | 879 | spin_lock_bh(&qdio->req_q_lock); |
875 | if (zfcp_qdio_sbal_get(qdio)) | 880 | if (zfcp_qdio_sbal_get(qdio)) |
@@ -882,16 +887,16 @@ struct zfcp_fsf_req *zfcp_fsf_abort_fcp_command(unsigned long old_req_id, | |||
882 | goto out; | 887 | goto out; |
883 | } | 888 | } |
884 | 889 | ||
885 | if (unlikely(!(atomic_read(&unit->status) & | 890 | if (unlikely(!(atomic_read(&zfcp_sdev->status) & |
886 | ZFCP_STATUS_COMMON_UNBLOCKED))) | 891 | ZFCP_STATUS_COMMON_UNBLOCKED))) |
887 | goto out_error_free; | 892 | goto out_error_free; |
888 | 893 | ||
889 | zfcp_qdio_set_sbale_last(qdio, &req->qdio_req); | 894 | zfcp_qdio_set_sbale_last(qdio, &req->qdio_req); |
890 | 895 | ||
891 | req->data = unit; | 896 | req->data = zfcp_sdev; |
892 | req->handler = zfcp_fsf_abort_fcp_command_handler; | 897 | req->handler = zfcp_fsf_abort_fcp_command_handler; |
893 | req->qtcb->header.lun_handle = unit->handle; | 898 | req->qtcb->header.lun_handle = zfcp_sdev->lun_handle; |
894 | req->qtcb->header.port_handle = unit->port->handle; | 899 | req->qtcb->header.port_handle = zfcp_sdev->port->handle; |
895 | req->qtcb->bottom.support.req_handle = (u64) old_req_id; | 900 | req->qtcb->bottom.support.req_handle = (u64) old_req_id; |
896 | 901 | ||
897 | zfcp_fsf_start_timer(req, ZFCP_SCSI_ER_TIMEOUT); | 902 | zfcp_fsf_start_timer(req, ZFCP_SCSI_ER_TIMEOUT); |
@@ -1666,7 +1671,7 @@ static void zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req *req) | |||
1666 | { | 1671 | { |
1667 | struct zfcp_port *port = req->data; | 1672 | struct zfcp_port *port = req->data; |
1668 | struct fsf_qtcb_header *header = &req->qtcb->header; | 1673 | struct fsf_qtcb_header *header = &req->qtcb->header; |
1669 | struct zfcp_unit *unit; | 1674 | struct scsi_device *sdev; |
1670 | 1675 | ||
1671 | if (req->status & ZFCP_STATUS_FSFREQ_ERROR) | 1676 | if (req->status & ZFCP_STATUS_FSFREQ_ERROR) |
1672 | return; | 1677 | return; |
@@ -1683,11 +1688,10 @@ static void zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req *req) | |||
1683 | /* can't use generic zfcp_erp_modify_port_status because | 1688 | /* can't use generic zfcp_erp_modify_port_status because |
1684 | * ZFCP_STATUS_COMMON_OPEN must not be reset for the port */ | 1689 | * ZFCP_STATUS_COMMON_OPEN must not be reset for the port */ |
1685 | atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_OPEN, &port->status); | 1690 | atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_OPEN, &port->status); |
1686 | read_lock(&port->unit_list_lock); | 1691 | shost_for_each_device(sdev, port->adapter->scsi_host) |
1687 | list_for_each_entry(unit, &port->unit_list, list) | 1692 | if (sdev_to_zfcp(sdev)->port == port) |
1688 | atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN, | 1693 | atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN, |
1689 | &unit->status); | 1694 | &sdev_to_zfcp(sdev)->status); |
1690 | read_unlock(&port->unit_list_lock); | ||
1691 | zfcp_erp_port_boxed(port, "fscpph2", req); | 1695 | zfcp_erp_port_boxed(port, "fscpph2", req); |
1692 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; | 1696 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
1693 | break; | 1697 | break; |
@@ -1705,11 +1709,10 @@ static void zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req *req) | |||
1705 | * ZFCP_STATUS_COMMON_OPEN must not be reset for the port | 1709 | * ZFCP_STATUS_COMMON_OPEN must not be reset for the port |
1706 | */ | 1710 | */ |
1707 | atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_OPEN, &port->status); | 1711 | atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_OPEN, &port->status); |
1708 | read_lock(&port->unit_list_lock); | 1712 | shost_for_each_device(sdev, port->adapter->scsi_host) |
1709 | list_for_each_entry(unit, &port->unit_list, list) | 1713 | if (sdev_to_zfcp(sdev)->port == port) |
1710 | atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN, | 1714 | atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN, |
1711 | &unit->status); | 1715 | &sdev_to_zfcp(sdev)->status); |
1712 | read_unlock(&port->unit_list_lock); | ||
1713 | break; | 1716 | break; |
1714 | } | 1717 | } |
1715 | } | 1718 | } |
@@ -1758,10 +1761,11 @@ out: | |||
1758 | return retval; | 1761 | return retval; |
1759 | } | 1762 | } |
1760 | 1763 | ||
1761 | static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req) | 1764 | static void zfcp_fsf_open_lun_handler(struct zfcp_fsf_req *req) |
1762 | { | 1765 | { |
1763 | struct zfcp_adapter *adapter = req->adapter; | 1766 | struct zfcp_adapter *adapter = req->adapter; |
1764 | struct zfcp_unit *unit = req->data; | 1767 | struct scsi_device *sdev = req->data; |
1768 | struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); | ||
1765 | struct fsf_qtcb_header *header = &req->qtcb->header; | 1769 | struct fsf_qtcb_header *header = &req->qtcb->header; |
1766 | struct fsf_qtcb_bottom_support *bottom = &req->qtcb->bottom.support; | 1770 | struct fsf_qtcb_bottom_support *bottom = &req->qtcb->bottom.support; |
1767 | struct fsf_queue_designator *queue_designator = | 1771 | struct fsf_queue_designator *queue_designator = |
@@ -1773,24 +1777,24 @@ static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req) | |||
1773 | 1777 | ||
1774 | atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED | | 1778 | atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED | |
1775 | ZFCP_STATUS_COMMON_ACCESS_BOXED | | 1779 | ZFCP_STATUS_COMMON_ACCESS_BOXED | |
1776 | ZFCP_STATUS_UNIT_SHARED | | 1780 | ZFCP_STATUS_LUN_SHARED | |
1777 | ZFCP_STATUS_UNIT_READONLY, | 1781 | ZFCP_STATUS_LUN_READONLY, |
1778 | &unit->status); | 1782 | &zfcp_sdev->status); |
1779 | 1783 | ||
1780 | switch (header->fsf_status) { | 1784 | switch (header->fsf_status) { |
1781 | 1785 | ||
1782 | case FSF_PORT_HANDLE_NOT_VALID: | 1786 | case FSF_PORT_HANDLE_NOT_VALID: |
1783 | zfcp_erp_adapter_reopen(unit->port->adapter, 0, "fsouh_1", req); | 1787 | zfcp_erp_adapter_reopen(adapter, 0, "fsouh_1", req); |
1784 | /* fall through */ | 1788 | /* fall through */ |
1785 | case FSF_LUN_ALREADY_OPEN: | 1789 | case FSF_LUN_ALREADY_OPEN: |
1786 | break; | 1790 | break; |
1787 | case FSF_ACCESS_DENIED: | 1791 | case FSF_ACCESS_DENIED: |
1788 | zfcp_fsf_access_denied_unit(req, unit); | 1792 | zfcp_fsf_access_denied_lun(req, sdev); |
1789 | atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED, &unit->status); | 1793 | atomic_clear_mask(ZFCP_STATUS_LUN_SHARED, &zfcp_sdev->status); |
1790 | atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY, &unit->status); | 1794 | atomic_clear_mask(ZFCP_STATUS_LUN_READONLY, &zfcp_sdev->status); |
1791 | break; | 1795 | break; |
1792 | case FSF_PORT_BOXED: | 1796 | case FSF_PORT_BOXED: |
1793 | zfcp_erp_port_boxed(unit->port, "fsouh_2", req); | 1797 | zfcp_erp_port_boxed(zfcp_sdev->port, "fsouh_2", req); |
1794 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; | 1798 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
1795 | break; | 1799 | break; |
1796 | case FSF_LUN_SHARING_VIOLATION: | 1800 | case FSF_LUN_SHARING_VIOLATION: |
@@ -1798,25 +1802,25 @@ static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req) | |||
1798 | dev_warn(&adapter->ccw_device->dev, | 1802 | dev_warn(&adapter->ccw_device->dev, |
1799 | "LUN 0x%Lx on port 0x%Lx is already in " | 1803 | "LUN 0x%Lx on port 0x%Lx is already in " |
1800 | "use by CSS%d, MIF Image ID %x\n", | 1804 | "use by CSS%d, MIF Image ID %x\n", |
1801 | (unsigned long long)unit->fcp_lun, | 1805 | (unsigned long long)zfcp_scsi_dev_lun(sdev), |
1802 | (unsigned long long)unit->port->wwpn, | 1806 | (unsigned long long)zfcp_sdev->port->wwpn, |
1803 | queue_designator->cssid, | 1807 | queue_designator->cssid, |
1804 | queue_designator->hla); | 1808 | queue_designator->hla); |
1805 | else | 1809 | else |
1806 | zfcp_act_eval_err(adapter, | 1810 | zfcp_act_eval_err(adapter, |
1807 | header->fsf_status_qual.word[2]); | 1811 | header->fsf_status_qual.word[2]); |
1808 | zfcp_erp_unit_access_denied(unit, "fsouh_3", req); | 1812 | zfcp_erp_lun_access_denied(sdev, "fsolh_3", req); |
1809 | atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED, &unit->status); | 1813 | atomic_clear_mask(ZFCP_STATUS_LUN_SHARED, &zfcp_sdev->status); |
1810 | atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY, &unit->status); | 1814 | atomic_clear_mask(ZFCP_STATUS_LUN_READONLY, &zfcp_sdev->status); |
1811 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; | 1815 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
1812 | break; | 1816 | break; |
1813 | case FSF_MAXIMUM_NUMBER_OF_LUNS_EXCEEDED: | 1817 | case FSF_MAXIMUM_NUMBER_OF_LUNS_EXCEEDED: |
1814 | dev_warn(&adapter->ccw_device->dev, | 1818 | dev_warn(&adapter->ccw_device->dev, |
1815 | "No handle is available for LUN " | 1819 | "No handle is available for LUN " |
1816 | "0x%016Lx on port 0x%016Lx\n", | 1820 | "0x%016Lx on port 0x%016Lx\n", |
1817 | (unsigned long long)unit->fcp_lun, | 1821 | (unsigned long long)zfcp_scsi_dev_lun(sdev), |
1818 | (unsigned long long)unit->port->wwpn); | 1822 | (unsigned long long)zfcp_sdev->port->wwpn); |
1819 | zfcp_erp_unit_failed(unit, "fsouh_4", req); | 1823 | zfcp_erp_lun_failed(sdev, "fsolh_4", req); |
1820 | /* fall through */ | 1824 | /* fall through */ |
1821 | case FSF_INVALID_COMMAND_OPTION: | 1825 | case FSF_INVALID_COMMAND_OPTION: |
1822 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; | 1826 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
@@ -1824,7 +1828,7 @@ static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req) | |||
1824 | case FSF_ADAPTER_STATUS_AVAILABLE: | 1828 | case FSF_ADAPTER_STATUS_AVAILABLE: |
1825 | switch (header->fsf_status_qual.word[0]) { | 1829 | switch (header->fsf_status_qual.word[0]) { |
1826 | case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: | 1830 | case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: |
1827 | zfcp_fc_test_link(unit->port); | 1831 | zfcp_fc_test_link(zfcp_sdev->port); |
1828 | /* fall through */ | 1832 | /* fall through */ |
1829 | case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED: | 1833 | case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED: |
1830 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; | 1834 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
@@ -1833,8 +1837,8 @@ static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req) | |||
1833 | break; | 1837 | break; |
1834 | 1838 | ||
1835 | case FSF_GOOD: | 1839 | case FSF_GOOD: |
1836 | unit->handle = header->lun_handle; | 1840 | zfcp_sdev->lun_handle = header->lun_handle; |
1837 | atomic_set_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status); | 1841 | atomic_set_mask(ZFCP_STATUS_COMMON_OPEN, &zfcp_sdev->status); |
1838 | 1842 | ||
1839 | if (!(adapter->connection_features & FSF_FEATURE_NPIV_MODE) && | 1843 | if (!(adapter->connection_features & FSF_FEATURE_NPIV_MODE) && |
1840 | (adapter->adapter_features & FSF_FEATURE_LUN_SHARING) && | 1844 | (adapter->adapter_features & FSF_FEATURE_LUN_SHARING) && |
@@ -1845,39 +1849,39 @@ static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req) | |||
1845 | FSF_UNIT_ACCESS_OUTBOUND_TRANSFER); | 1849 | FSF_UNIT_ACCESS_OUTBOUND_TRANSFER); |
1846 | 1850 | ||
1847 | if (!exclusive) | 1851 | if (!exclusive) |
1848 | atomic_set_mask(ZFCP_STATUS_UNIT_SHARED, | 1852 | atomic_set_mask(ZFCP_STATUS_LUN_SHARED, |
1849 | &unit->status); | 1853 | &zfcp_sdev->status); |
1850 | 1854 | ||
1851 | if (!readwrite) { | 1855 | if (!readwrite) { |
1852 | atomic_set_mask(ZFCP_STATUS_UNIT_READONLY, | 1856 | atomic_set_mask(ZFCP_STATUS_LUN_READONLY, |
1853 | &unit->status); | 1857 | &zfcp_sdev->status); |
1854 | dev_info(&adapter->ccw_device->dev, | 1858 | dev_info(&adapter->ccw_device->dev, |
1855 | "SCSI device at LUN 0x%016Lx on port " | 1859 | "SCSI device at LUN 0x%016Lx on port " |
1856 | "0x%016Lx opened read-only\n", | 1860 | "0x%016Lx opened read-only\n", |
1857 | (unsigned long long)unit->fcp_lun, | 1861 | (unsigned long long)zfcp_scsi_dev_lun(sdev), |
1858 | (unsigned long long)unit->port->wwpn); | 1862 | (unsigned long long)zfcp_sdev->port->wwpn); |
1859 | } | 1863 | } |
1860 | 1864 | ||
1861 | if (exclusive && !readwrite) { | 1865 | if (exclusive && !readwrite) { |
1862 | dev_err(&adapter->ccw_device->dev, | 1866 | dev_err(&adapter->ccw_device->dev, |
1863 | "Exclusive read-only access not " | 1867 | "Exclusive read-only access not " |
1864 | "supported (unit 0x%016Lx, " | 1868 | "supported (LUN 0x%016Lx, " |
1865 | "port 0x%016Lx)\n", | 1869 | "port 0x%016Lx)\n", |
1866 | (unsigned long long)unit->fcp_lun, | 1870 | (unsigned long long)zfcp_scsi_dev_lun(sdev), |
1867 | (unsigned long long)unit->port->wwpn); | 1871 | (unsigned long long)zfcp_sdev->port->wwpn); |
1868 | zfcp_erp_unit_failed(unit, "fsouh_5", req); | 1872 | zfcp_erp_lun_failed(sdev, "fsolh_5", req); |
1869 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; | 1873 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
1870 | zfcp_erp_unit_shutdown(unit, 0, "fsouh_6", req); | 1874 | zfcp_erp_lun_shutdown(sdev, 0, "fsolh_6", req); |
1871 | } else if (!exclusive && readwrite) { | 1875 | } else if (!exclusive && readwrite) { |
1872 | dev_err(&adapter->ccw_device->dev, | 1876 | dev_err(&adapter->ccw_device->dev, |
1873 | "Shared read-write access not " | 1877 | "Shared read-write access not " |
1874 | "supported (unit 0x%016Lx, port " | 1878 | "supported (LUN 0x%016Lx, port " |
1875 | "0x%016Lx)\n", | 1879 | "0x%016Lx)\n", |
1876 | (unsigned long long)unit->fcp_lun, | 1880 | (unsigned long long)zfcp_scsi_dev_lun(sdev), |
1877 | (unsigned long long)unit->port->wwpn); | 1881 | (unsigned long long)zfcp_sdev->port->wwpn); |
1878 | zfcp_erp_unit_failed(unit, "fsouh_7", req); | 1882 | zfcp_erp_lun_failed(sdev, "fsolh_7", req); |
1879 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; | 1883 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
1880 | zfcp_erp_unit_shutdown(unit, 0, "fsouh_8", req); | 1884 | zfcp_erp_lun_shutdown(sdev, 0, "fsolh_8", req); |
1881 | } | 1885 | } |
1882 | } | 1886 | } |
1883 | break; | 1887 | break; |
@@ -1885,11 +1889,11 @@ static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req) | |||
1885 | } | 1889 | } |
1886 | 1890 | ||
1887 | /** | 1891 | /** |
1888 | * zfcp_fsf_open_unit - open unit | 1892 | * zfcp_fsf_open_lun - open LUN |
1889 | * @erp_action: pointer to struct zfcp_erp_action | 1893 | * @erp_action: pointer to struct zfcp_erp_action |
1890 | * Returns: 0 on success, error otherwise | 1894 | * Returns: 0 on success, error otherwise |
1891 | */ | 1895 | */ |
1892 | int zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action) | 1896 | int zfcp_fsf_open_lun(struct zfcp_erp_action *erp_action) |
1893 | { | 1897 | { |
1894 | struct zfcp_adapter *adapter = erp_action->adapter; | 1898 | struct zfcp_adapter *adapter = erp_action->adapter; |
1895 | struct zfcp_qdio *qdio = adapter->qdio; | 1899 | struct zfcp_qdio *qdio = adapter->qdio; |
@@ -1913,9 +1917,9 @@ int zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action) | |||
1913 | zfcp_qdio_set_sbale_last(qdio, &req->qdio_req); | 1917 | zfcp_qdio_set_sbale_last(qdio, &req->qdio_req); |
1914 | 1918 | ||
1915 | req->qtcb->header.port_handle = erp_action->port->handle; | 1919 | req->qtcb->header.port_handle = erp_action->port->handle; |
1916 | req->qtcb->bottom.support.fcp_lun = erp_action->unit->fcp_lun; | 1920 | req->qtcb->bottom.support.fcp_lun = zfcp_scsi_dev_lun(erp_action->sdev); |
1917 | req->handler = zfcp_fsf_open_unit_handler; | 1921 | req->handler = zfcp_fsf_open_lun_handler; |
1918 | req->data = erp_action->unit; | 1922 | req->data = erp_action->sdev; |
1919 | req->erp_action = erp_action; | 1923 | req->erp_action = erp_action; |
1920 | erp_action->fsf_req_id = req->req_id; | 1924 | erp_action->fsf_req_id = req->req_id; |
1921 | 1925 | ||
@@ -1933,30 +1937,32 @@ out: | |||
1933 | return retval; | 1937 | return retval; |
1934 | } | 1938 | } |
1935 | 1939 | ||
1936 | static void zfcp_fsf_close_unit_handler(struct zfcp_fsf_req *req) | 1940 | static void zfcp_fsf_close_lun_handler(struct zfcp_fsf_req *req) |
1937 | { | 1941 | { |
1938 | struct zfcp_unit *unit = req->data; | 1942 | struct scsi_device *sdev = req->data; |
1943 | struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); | ||
1939 | 1944 | ||
1940 | if (req->status & ZFCP_STATUS_FSFREQ_ERROR) | 1945 | if (req->status & ZFCP_STATUS_FSFREQ_ERROR) |
1941 | return; | 1946 | return; |
1942 | 1947 | ||
1943 | switch (req->qtcb->header.fsf_status) { | 1948 | switch (req->qtcb->header.fsf_status) { |
1944 | case FSF_PORT_HANDLE_NOT_VALID: | 1949 | case FSF_PORT_HANDLE_NOT_VALID: |
1945 | zfcp_erp_adapter_reopen(unit->port->adapter, 0, "fscuh_1", req); | 1950 | zfcp_erp_adapter_reopen(zfcp_sdev->port->adapter, 0, "fscuh_1", |
1951 | req); | ||
1946 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; | 1952 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
1947 | break; | 1953 | break; |
1948 | case FSF_LUN_HANDLE_NOT_VALID: | 1954 | case FSF_LUN_HANDLE_NOT_VALID: |
1949 | zfcp_erp_port_reopen(unit->port, 0, "fscuh_2", req); | 1955 | zfcp_erp_port_reopen(zfcp_sdev->port, 0, "fscuh_2", req); |
1950 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; | 1956 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
1951 | break; | 1957 | break; |
1952 | case FSF_PORT_BOXED: | 1958 | case FSF_PORT_BOXED: |
1953 | zfcp_erp_port_boxed(unit->port, "fscuh_3", req); | 1959 | zfcp_erp_port_boxed(zfcp_sdev->port, "fscuh_3", req); |
1954 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; | 1960 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
1955 | break; | 1961 | break; |
1956 | case FSF_ADAPTER_STATUS_AVAILABLE: | 1962 | case FSF_ADAPTER_STATUS_AVAILABLE: |
1957 | switch (req->qtcb->header.fsf_status_qual.word[0]) { | 1963 | switch (req->qtcb->header.fsf_status_qual.word[0]) { |
1958 | case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: | 1964 | case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: |
1959 | zfcp_fc_test_link(unit->port); | 1965 | zfcp_fc_test_link(zfcp_sdev->port); |
1960 | /* fall through */ | 1966 | /* fall through */ |
1961 | case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED: | 1967 | case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED: |
1962 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; | 1968 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
@@ -1964,19 +1970,20 @@ static void zfcp_fsf_close_unit_handler(struct zfcp_fsf_req *req) | |||
1964 | } | 1970 | } |
1965 | break; | 1971 | break; |
1966 | case FSF_GOOD: | 1972 | case FSF_GOOD: |
1967 | atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status); | 1973 | atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN, &zfcp_sdev->status); |
1968 | break; | 1974 | break; |
1969 | } | 1975 | } |
1970 | } | 1976 | } |
1971 | 1977 | ||
1972 | /** | 1978 | /** |
1973 | * zfcp_fsf_close_unit - close zfcp unit | 1979 | * zfcp_fsf_close_LUN - close LUN |
1974 | * @erp_action: pointer to struct zfcp_unit | 1980 | * @erp_action: pointer to erp_action triggering the "close LUN" |
1975 | * Returns: 0 on success, error otherwise | 1981 | * Returns: 0 on success, error otherwise |
1976 | */ | 1982 | */ |
1977 | int zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action) | 1983 | int zfcp_fsf_close_lun(struct zfcp_erp_action *erp_action) |
1978 | { | 1984 | { |
1979 | struct zfcp_qdio *qdio = erp_action->adapter->qdio; | 1985 | struct zfcp_qdio *qdio = erp_action->adapter->qdio; |
1986 | struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(erp_action->sdev); | ||
1980 | struct zfcp_fsf_req *req; | 1987 | struct zfcp_fsf_req *req; |
1981 | int retval = -EIO; | 1988 | int retval = -EIO; |
1982 | 1989 | ||
@@ -1997,9 +2004,9 @@ int zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action) | |||
1997 | zfcp_qdio_set_sbale_last(qdio, &req->qdio_req); | 2004 | zfcp_qdio_set_sbale_last(qdio, &req->qdio_req); |
1998 | 2005 | ||
1999 | req->qtcb->header.port_handle = erp_action->port->handle; | 2006 | req->qtcb->header.port_handle = erp_action->port->handle; |
2000 | req->qtcb->header.lun_handle = erp_action->unit->handle; | 2007 | req->qtcb->header.lun_handle = zfcp_sdev->lun_handle; |
2001 | req->handler = zfcp_fsf_close_unit_handler; | 2008 | req->handler = zfcp_fsf_close_lun_handler; |
2002 | req->data = erp_action->unit; | 2009 | req->data = erp_action->sdev; |
2003 | req->erp_action = erp_action; | 2010 | req->erp_action = erp_action; |
2004 | erp_action->fsf_req_id = req->req_id; | 2011 | erp_action->fsf_req_id = req->req_id; |
2005 | 2012 | ||
@@ -2025,7 +2032,7 @@ static void zfcp_fsf_req_trace(struct zfcp_fsf_req *req, struct scsi_cmnd *scsi) | |||
2025 | { | 2032 | { |
2026 | struct fsf_qual_latency_info *lat_in; | 2033 | struct fsf_qual_latency_info *lat_in; |
2027 | struct latency_cont *lat = NULL; | 2034 | struct latency_cont *lat = NULL; |
2028 | struct zfcp_unit *unit = req->unit; | 2035 | struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(scsi->device); |
2029 | struct zfcp_blk_drv_data blktrc; | 2036 | struct zfcp_blk_drv_data blktrc; |
2030 | int ticks = req->adapter->timer_ticks; | 2037 | int ticks = req->adapter->timer_ticks; |
2031 | 2038 | ||
@@ -2048,24 +2055,24 @@ static void zfcp_fsf_req_trace(struct zfcp_fsf_req *req, struct scsi_cmnd *scsi) | |||
2048 | case FSF_DATADIR_DIF_READ_STRIP: | 2055 | case FSF_DATADIR_DIF_READ_STRIP: |
2049 | case FSF_DATADIR_DIF_READ_CONVERT: | 2056 | case FSF_DATADIR_DIF_READ_CONVERT: |
2050 | case FSF_DATADIR_READ: | 2057 | case FSF_DATADIR_READ: |
2051 | lat = &unit->latencies.read; | 2058 | lat = &zfcp_sdev->latencies.read; |
2052 | break; | 2059 | break; |
2053 | case FSF_DATADIR_DIF_WRITE_INSERT: | 2060 | case FSF_DATADIR_DIF_WRITE_INSERT: |
2054 | case FSF_DATADIR_DIF_WRITE_CONVERT: | 2061 | case FSF_DATADIR_DIF_WRITE_CONVERT: |
2055 | case FSF_DATADIR_WRITE: | 2062 | case FSF_DATADIR_WRITE: |
2056 | lat = &unit->latencies.write; | 2063 | lat = &zfcp_sdev->latencies.write; |
2057 | break; | 2064 | break; |
2058 | case FSF_DATADIR_CMND: | 2065 | case FSF_DATADIR_CMND: |
2059 | lat = &unit->latencies.cmd; | 2066 | lat = &zfcp_sdev->latencies.cmd; |
2060 | break; | 2067 | break; |
2061 | } | 2068 | } |
2062 | 2069 | ||
2063 | if (lat) { | 2070 | if (lat) { |
2064 | spin_lock(&unit->latencies.lock); | 2071 | spin_lock(&zfcp_sdev->latencies.lock); |
2065 | zfcp_fsf_update_lat(&lat->channel, lat_in->channel_lat); | 2072 | zfcp_fsf_update_lat(&lat->channel, lat_in->channel_lat); |
2066 | zfcp_fsf_update_lat(&lat->fabric, lat_in->fabric_lat); | 2073 | zfcp_fsf_update_lat(&lat->fabric, lat_in->fabric_lat); |
2067 | lat->counter++; | 2074 | lat->counter++; |
2068 | spin_unlock(&unit->latencies.lock); | 2075 | spin_unlock(&zfcp_sdev->latencies.lock); |
2069 | } | 2076 | } |
2070 | } | 2077 | } |
2071 | 2078 | ||
@@ -2141,68 +2148,66 @@ static void zfcp_fsf_send_fcp_ctm_handler(struct zfcp_fsf_req *req) | |||
2141 | 2148 | ||
2142 | static void zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *req) | 2149 | static void zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *req) |
2143 | { | 2150 | { |
2144 | struct zfcp_unit *unit; | 2151 | struct scsi_cmnd *scmnd = req->data; |
2152 | struct scsi_device *sdev = scmnd->device; | ||
2153 | struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); | ||
2145 | struct fsf_qtcb_header *header = &req->qtcb->header; | 2154 | struct fsf_qtcb_header *header = &req->qtcb->header; |
2146 | 2155 | ||
2147 | if (unlikely(req->status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT)) | ||
2148 | unit = req->data; | ||
2149 | else | ||
2150 | unit = req->unit; | ||
2151 | |||
2152 | if (unlikely(req->status & ZFCP_STATUS_FSFREQ_ERROR)) | 2156 | if (unlikely(req->status & ZFCP_STATUS_FSFREQ_ERROR)) |
2153 | goto skip_fsfstatus; | 2157 | goto skip_fsfstatus; |
2154 | 2158 | ||
2155 | switch (header->fsf_status) { | 2159 | switch (header->fsf_status) { |
2156 | case FSF_HANDLE_MISMATCH: | 2160 | case FSF_HANDLE_MISMATCH: |
2157 | case FSF_PORT_HANDLE_NOT_VALID: | 2161 | case FSF_PORT_HANDLE_NOT_VALID: |
2158 | zfcp_erp_adapter_reopen(unit->port->adapter, 0, "fssfch1", req); | 2162 | zfcp_erp_adapter_reopen(zfcp_sdev->port->adapter, 0, "fssfch1", |
2163 | req); | ||
2159 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; | 2164 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
2160 | break; | 2165 | break; |
2161 | case FSF_FCPLUN_NOT_VALID: | 2166 | case FSF_FCPLUN_NOT_VALID: |
2162 | case FSF_LUN_HANDLE_NOT_VALID: | 2167 | case FSF_LUN_HANDLE_NOT_VALID: |
2163 | zfcp_erp_port_reopen(unit->port, 0, "fssfch2", req); | 2168 | zfcp_erp_port_reopen(zfcp_sdev->port, 0, "fssfch2", req); |
2164 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; | 2169 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
2165 | break; | 2170 | break; |
2166 | case FSF_SERVICE_CLASS_NOT_SUPPORTED: | 2171 | case FSF_SERVICE_CLASS_NOT_SUPPORTED: |
2167 | zfcp_fsf_class_not_supp(req); | 2172 | zfcp_fsf_class_not_supp(req); |
2168 | break; | 2173 | break; |
2169 | case FSF_ACCESS_DENIED: | 2174 | case FSF_ACCESS_DENIED: |
2170 | zfcp_fsf_access_denied_unit(req, unit); | 2175 | zfcp_fsf_access_denied_lun(req, sdev); |
2171 | break; | 2176 | break; |
2172 | case FSF_DIRECTION_INDICATOR_NOT_VALID: | 2177 | case FSF_DIRECTION_INDICATOR_NOT_VALID: |
2173 | dev_err(&req->adapter->ccw_device->dev, | 2178 | dev_err(&req->adapter->ccw_device->dev, |
2174 | "Incorrect direction %d, unit 0x%016Lx on port " | 2179 | "Incorrect direction %d, LUN 0x%016Lx on port " |
2175 | "0x%016Lx closed\n", | 2180 | "0x%016Lx closed\n", |
2176 | req->qtcb->bottom.io.data_direction, | 2181 | req->qtcb->bottom.io.data_direction, |
2177 | (unsigned long long)unit->fcp_lun, | 2182 | (unsigned long long)zfcp_scsi_dev_lun(sdev), |
2178 | (unsigned long long)unit->port->wwpn); | 2183 | (unsigned long long)zfcp_sdev->port->wwpn); |
2179 | zfcp_erp_adapter_shutdown(unit->port->adapter, 0, "fssfch3", | 2184 | zfcp_erp_adapter_shutdown(zfcp_sdev->port->adapter, 0, |
2180 | req); | 2185 | "fssfch3", req); |
2181 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; | 2186 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
2182 | break; | 2187 | break; |
2183 | case FSF_CMND_LENGTH_NOT_VALID: | 2188 | case FSF_CMND_LENGTH_NOT_VALID: |
2184 | dev_err(&req->adapter->ccw_device->dev, | 2189 | dev_err(&req->adapter->ccw_device->dev, |
2185 | "Incorrect CDB length %d, unit 0x%016Lx on " | 2190 | "Incorrect CDB length %d, LUN 0x%016Lx on " |
2186 | "port 0x%016Lx closed\n", | 2191 | "port 0x%016Lx closed\n", |
2187 | req->qtcb->bottom.io.fcp_cmnd_length, | 2192 | req->qtcb->bottom.io.fcp_cmnd_length, |
2188 | (unsigned long long)unit->fcp_lun, | 2193 | (unsigned long long)zfcp_scsi_dev_lun(sdev), |
2189 | (unsigned long long)unit->port->wwpn); | 2194 | (unsigned long long)zfcp_sdev->port->wwpn); |
2190 | zfcp_erp_adapter_shutdown(unit->port->adapter, 0, "fssfch4", | 2195 | zfcp_erp_adapter_shutdown(zfcp_sdev->port->adapter, 0, |
2191 | req); | 2196 | "fssfch4", req); |
2192 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; | 2197 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
2193 | break; | 2198 | break; |
2194 | case FSF_PORT_BOXED: | 2199 | case FSF_PORT_BOXED: |
2195 | zfcp_erp_port_boxed(unit->port, "fssfch5", req); | 2200 | zfcp_erp_port_boxed(zfcp_sdev->port, "fssfch5", req); |
2196 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; | 2201 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
2197 | break; | 2202 | break; |
2198 | case FSF_LUN_BOXED: | 2203 | case FSF_LUN_BOXED: |
2199 | zfcp_erp_unit_boxed(unit, "fssfch6", req); | 2204 | zfcp_erp_lun_boxed(sdev, "fssfch6", req); |
2200 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; | 2205 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
2201 | break; | 2206 | break; |
2202 | case FSF_ADAPTER_STATUS_AVAILABLE: | 2207 | case FSF_ADAPTER_STATUS_AVAILABLE: |
2203 | if (header->fsf_status_qual.word[0] == | 2208 | if (header->fsf_status_qual.word[0] == |
2204 | FSF_SQ_INVOKE_LINK_TEST_PROCEDURE) | 2209 | FSF_SQ_INVOKE_LINK_TEST_PROCEDURE) |
2205 | zfcp_fc_test_link(unit->port); | 2210 | zfcp_fc_test_link(zfcp_sdev->port); |
2206 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; | 2211 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
2207 | break; | 2212 | break; |
2208 | } | 2213 | } |
@@ -2211,8 +2216,6 @@ skip_fsfstatus: | |||
2211 | zfcp_fsf_send_fcp_ctm_handler(req); | 2216 | zfcp_fsf_send_fcp_ctm_handler(req); |
2212 | else { | 2217 | else { |
2213 | zfcp_fsf_send_fcp_command_task_handler(req); | 2218 | zfcp_fsf_send_fcp_command_task_handler(req); |
2214 | req->unit = NULL; | ||
2215 | put_device(&unit->dev); | ||
2216 | } | 2219 | } |
2217 | } | 2220 | } |
2218 | 2221 | ||
@@ -2255,22 +2258,22 @@ static int zfcp_fsf_set_data_dir(struct scsi_cmnd *scsi_cmnd, u32 *data_dir) | |||
2255 | } | 2258 | } |
2256 | 2259 | ||
2257 | /** | 2260 | /** |
2258 | * zfcp_fsf_send_fcp_command_task - initiate an FCP command (for a SCSI command) | 2261 | * zfcp_fsf_fcp_cmnd - initiate an FCP command (for a SCSI command) |
2259 | * @unit: unit where command is sent to | ||
2260 | * @scsi_cmnd: scsi command to be sent | 2262 | * @scsi_cmnd: scsi command to be sent |
2261 | */ | 2263 | */ |
2262 | int zfcp_fsf_send_fcp_command_task(struct zfcp_unit *unit, | 2264 | int zfcp_fsf_fcp_cmnd(struct scsi_cmnd *scsi_cmnd) |
2263 | struct scsi_cmnd *scsi_cmnd) | ||
2264 | { | 2265 | { |
2265 | struct zfcp_fsf_req *req; | 2266 | struct zfcp_fsf_req *req; |
2266 | struct fcp_cmnd *fcp_cmnd; | 2267 | struct fcp_cmnd *fcp_cmnd; |
2267 | unsigned int sbtype = SBAL_FLAGS0_TYPE_READ; | 2268 | unsigned int sbtype = SBAL_FLAGS0_TYPE_READ; |
2268 | int real_bytes, retval = -EIO, dix_bytes = 0; | 2269 | int real_bytes, retval = -EIO, dix_bytes = 0; |
2269 | struct zfcp_adapter *adapter = unit->port->adapter; | 2270 | struct scsi_device *sdev = scsi_cmnd->device; |
2271 | struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); | ||
2272 | struct zfcp_adapter *adapter = zfcp_sdev->port->adapter; | ||
2270 | struct zfcp_qdio *qdio = adapter->qdio; | 2273 | struct zfcp_qdio *qdio = adapter->qdio; |
2271 | struct fsf_qtcb_bottom_io *io; | 2274 | struct fsf_qtcb_bottom_io *io; |
2272 | 2275 | ||
2273 | if (unlikely(!(atomic_read(&unit->status) & | 2276 | if (unlikely(!(atomic_read(&zfcp_sdev->status) & |
2274 | ZFCP_STATUS_COMMON_UNBLOCKED))) | 2277 | ZFCP_STATUS_COMMON_UNBLOCKED))) |
2275 | return -EBUSY; | 2278 | return -EBUSY; |
2276 | 2279 | ||
@@ -2295,11 +2298,10 @@ int zfcp_fsf_send_fcp_command_task(struct zfcp_unit *unit, | |||
2295 | 2298 | ||
2296 | io = &req->qtcb->bottom.io; | 2299 | io = &req->qtcb->bottom.io; |
2297 | req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; | 2300 | req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; |
2298 | req->unit = unit; | ||
2299 | req->data = scsi_cmnd; | 2301 | req->data = scsi_cmnd; |
2300 | req->handler = zfcp_fsf_send_fcp_command_handler; | 2302 | req->handler = zfcp_fsf_send_fcp_command_handler; |
2301 | req->qtcb->header.lun_handle = unit->handle; | 2303 | req->qtcb->header.lun_handle = zfcp_sdev->lun_handle; |
2302 | req->qtcb->header.port_handle = unit->port->handle; | 2304 | req->qtcb->header.port_handle = zfcp_sdev->port->handle; |
2303 | io->service_class = FSF_CLASS_3; | 2305 | io->service_class = FSF_CLASS_3; |
2304 | io->fcp_cmnd_length = FCP_CMND_LEN; | 2306 | io->fcp_cmnd_length = FCP_CMND_LEN; |
2305 | 2307 | ||
@@ -2310,8 +2312,6 @@ int zfcp_fsf_send_fcp_command_task(struct zfcp_unit *unit, | |||
2310 | 2312 | ||
2311 | zfcp_fsf_set_data_dir(scsi_cmnd, &io->data_direction); | 2313 | zfcp_fsf_set_data_dir(scsi_cmnd, &io->data_direction); |
2312 | 2314 | ||
2313 | get_device(&unit->dev); | ||
2314 | |||
2315 | fcp_cmnd = (struct fcp_cmnd *) &req->qtcb->bottom.io.fcp_cmnd; | 2315 | fcp_cmnd = (struct fcp_cmnd *) &req->qtcb->bottom.io.fcp_cmnd; |
2316 | zfcp_fc_scsi_to_fcp(fcp_cmnd, scsi_cmnd); | 2316 | zfcp_fc_scsi_to_fcp(fcp_cmnd, scsi_cmnd); |
2317 | 2317 | ||
@@ -2338,7 +2338,6 @@ int zfcp_fsf_send_fcp_command_task(struct zfcp_unit *unit, | |||
2338 | goto out; | 2338 | goto out; |
2339 | 2339 | ||
2340 | failed_scsi_cmnd: | 2340 | failed_scsi_cmnd: |
2341 | put_device(&unit->dev); | ||
2342 | zfcp_fsf_req_free(req); | 2341 | zfcp_fsf_req_free(req); |
2343 | scsi_cmnd->host_scribble = NULL; | 2342 | scsi_cmnd->host_scribble = NULL; |
2344 | out: | 2343 | out: |
@@ -2347,18 +2346,20 @@ out: | |||
2347 | } | 2346 | } |
2348 | 2347 | ||
2349 | /** | 2348 | /** |
2350 | * zfcp_fsf_send_fcp_ctm - send SCSI task management command | 2349 | * zfcp_fsf_fcp_task_mgmt - send SCSI task management command |
2351 | * @unit: pointer to struct zfcp_unit | 2350 | * @scmnd: SCSI command to send the task management command for |
2352 | * @tm_flags: unsigned byte for task management flags | 2351 | * @tm_flags: unsigned byte for task management flags |
2353 | * Returns: on success pointer to struct fsf_req, NULL otherwise | 2352 | * Returns: on success pointer to struct fsf_req, NULL otherwise |
2354 | */ | 2353 | */ |
2355 | struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_unit *unit, u8 tm_flags) | 2354 | struct zfcp_fsf_req *zfcp_fsf_fcp_task_mgmt(struct scsi_cmnd *scmnd, |
2355 | u8 tm_flags) | ||
2356 | { | 2356 | { |
2357 | struct zfcp_fsf_req *req = NULL; | 2357 | struct zfcp_fsf_req *req = NULL; |
2358 | struct fcp_cmnd *fcp_cmnd; | 2358 | struct fcp_cmnd *fcp_cmnd; |
2359 | struct zfcp_qdio *qdio = unit->port->adapter->qdio; | 2359 | struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(scmnd->device); |
2360 | struct zfcp_qdio *qdio = zfcp_sdev->port->adapter->qdio; | ||
2360 | 2361 | ||
2361 | if (unlikely(!(atomic_read(&unit->status) & | 2362 | if (unlikely(!(atomic_read(&zfcp_sdev->status) & |
2362 | ZFCP_STATUS_COMMON_UNBLOCKED))) | 2363 | ZFCP_STATUS_COMMON_UNBLOCKED))) |
2363 | return NULL; | 2364 | return NULL; |
2364 | 2365 | ||
@@ -2376,10 +2377,10 @@ struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_unit *unit, u8 tm_flags) | |||
2376 | } | 2377 | } |
2377 | 2378 | ||
2378 | req->status |= ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT; | 2379 | req->status |= ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT; |
2379 | req->data = unit; | 2380 | req->data = scmnd; |
2380 | req->handler = zfcp_fsf_send_fcp_command_handler; | 2381 | req->handler = zfcp_fsf_send_fcp_command_handler; |
2381 | req->qtcb->header.lun_handle = unit->handle; | 2382 | req->qtcb->header.lun_handle = zfcp_sdev->lun_handle; |
2382 | req->qtcb->header.port_handle = unit->port->handle; | 2383 | req->qtcb->header.port_handle = zfcp_sdev->port->handle; |
2383 | req->qtcb->bottom.io.data_direction = FSF_DATADIR_CMND; | 2384 | req->qtcb->bottom.io.data_direction = FSF_DATADIR_CMND; |
2384 | req->qtcb->bottom.io.service_class = FSF_CLASS_3; | 2385 | req->qtcb->bottom.io.service_class = FSF_CLASS_3; |
2385 | req->qtcb->bottom.io.fcp_cmnd_length = FCP_CMND_LEN; | 2386 | req->qtcb->bottom.io.fcp_cmnd_length = FCP_CMND_LEN; |
@@ -2387,7 +2388,7 @@ struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_unit *unit, u8 tm_flags) | |||
2387 | zfcp_qdio_set_sbale_last(qdio, &req->qdio_req); | 2388 | zfcp_qdio_set_sbale_last(qdio, &req->qdio_req); |
2388 | 2389 | ||
2389 | fcp_cmnd = (struct fcp_cmnd *) &req->qtcb->bottom.io.fcp_cmnd; | 2390 | fcp_cmnd = (struct fcp_cmnd *) &req->qtcb->bottom.io.fcp_cmnd; |
2390 | zfcp_fc_fcp_tm(fcp_cmnd, unit->device, tm_flags); | 2391 | zfcp_fc_fcp_tm(fcp_cmnd, scmnd->device, tm_flags); |
2391 | 2392 | ||
2392 | zfcp_fsf_start_timer(req, ZFCP_SCSI_ER_TIMEOUT); | 2393 | zfcp_fsf_start_timer(req, ZFCP_SCSI_ER_TIMEOUT); |
2393 | if (!zfcp_fsf_req_send(req)) | 2394 | if (!zfcp_fsf_req_send(req)) |
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c index 03837797c45e..bc7217b88989 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 | ||
52 | static void zfcp_scsi_slave_destroy(struct scsi_device *sdpnt) | 52 | static 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 | ||
59 | static int zfcp_scsi_slave_configure(struct scsi_device *sdp) | 60 | static 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) | |||
78 | static int zfcp_scsi_queuecommand(struct scsi_cmnd *scpnt, | 79 | static 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 | ||
136 | static struct zfcp_unit *zfcp_unit_lookup(struct zfcp_adapter *adapter, | 130 | static 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 | ||
156 | static 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 | } | ||
173 | out: | ||
174 | return -ENXIO; | ||
175 | } | 166 | } |
176 | 167 | ||
177 | static int zfcp_scsi_eh_abort_handler(struct scsi_cmnd *scpnt) | 168 | static 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 | ||
239 | static int zfcp_task_mgmt_function(struct scsi_cmnd *scpnt, u8 tm_flags) | 229 | static 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 | ||
288 | static int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt) | 278 | static 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); |
diff --git a/drivers/s390/scsi/zfcp_sysfs.c b/drivers/s390/scsi/zfcp_sysfs.c index 6b43bc46bf97..4f59356b07bb 100644 --- a/drivers/s390/scsi/zfcp_sysfs.c +++ b/drivers/s390/scsi/zfcp_sysfs.c | |||
@@ -68,19 +68,19 @@ ZFCP_DEFINE_ATTR(zfcp_port, port, access_denied, "%d\n", | |||
68 | ZFCP_STATUS_COMMON_ACCESS_DENIED) != 0); | 68 | ZFCP_STATUS_COMMON_ACCESS_DENIED) != 0); |
69 | 69 | ||
70 | ZFCP_DEFINE_ATTR(zfcp_unit, unit, status, "0x%08x\n", | 70 | ZFCP_DEFINE_ATTR(zfcp_unit, unit, status, "0x%08x\n", |
71 | atomic_read(&unit->status)); | 71 | zfcp_unit_sdev_status(unit)); |
72 | ZFCP_DEFINE_ATTR(zfcp_unit, unit, in_recovery, "%d\n", | 72 | ZFCP_DEFINE_ATTR(zfcp_unit, unit, in_recovery, "%d\n", |
73 | (atomic_read(&unit->status) & | 73 | (zfcp_unit_sdev_status(unit) & |
74 | ZFCP_STATUS_COMMON_ERP_INUSE) != 0); | 74 | ZFCP_STATUS_COMMON_ERP_INUSE) != 0); |
75 | ZFCP_DEFINE_ATTR(zfcp_unit, unit, access_denied, "%d\n", | 75 | ZFCP_DEFINE_ATTR(zfcp_unit, unit, access_denied, "%d\n", |
76 | (atomic_read(&unit->status) & | 76 | (zfcp_unit_sdev_status(unit) & |
77 | ZFCP_STATUS_COMMON_ACCESS_DENIED) != 0); | 77 | ZFCP_STATUS_COMMON_ACCESS_DENIED) != 0); |
78 | ZFCP_DEFINE_ATTR(zfcp_unit, unit, access_shared, "%d\n", | 78 | ZFCP_DEFINE_ATTR(zfcp_unit, unit, access_shared, "%d\n", |
79 | (atomic_read(&unit->status) & | 79 | (zfcp_unit_sdev_status(unit) & |
80 | ZFCP_STATUS_UNIT_SHARED) != 0); | 80 | ZFCP_STATUS_LUN_SHARED) != 0); |
81 | ZFCP_DEFINE_ATTR(zfcp_unit, unit, access_readonly, "%d\n", | 81 | ZFCP_DEFINE_ATTR(zfcp_unit, unit, access_readonly, "%d\n", |
82 | (atomic_read(&unit->status) & | 82 | (zfcp_unit_sdev_status(unit) & |
83 | ZFCP_STATUS_UNIT_READONLY) != 0); | 83 | ZFCP_STATUS_LUN_READONLY) != 0); |
84 | 84 | ||
85 | static ssize_t zfcp_sysfs_port_failed_show(struct device *dev, | 85 | static ssize_t zfcp_sysfs_port_failed_show(struct device *dev, |
86 | struct device_attribute *attr, | 86 | struct device_attribute *attr, |
@@ -121,11 +121,17 @@ static ssize_t zfcp_sysfs_unit_failed_show(struct device *dev, | |||
121 | char *buf) | 121 | char *buf) |
122 | { | 122 | { |
123 | struct zfcp_unit *unit = container_of(dev, struct zfcp_unit, dev); | 123 | struct zfcp_unit *unit = container_of(dev, struct zfcp_unit, dev); |
124 | struct scsi_device *sdev; | ||
125 | unsigned int status, failed = 1; | ||
126 | |||
127 | sdev = zfcp_unit_sdev(unit); | ||
128 | if (sdev) { | ||
129 | status = atomic_read(&sdev_to_zfcp(sdev)->status); | ||
130 | failed = status & ZFCP_STATUS_COMMON_ERP_FAILED ? 1 : 0; | ||
131 | scsi_device_put(sdev); | ||
132 | } | ||
124 | 133 | ||
125 | if (atomic_read(&unit->status) & ZFCP_STATUS_COMMON_ERP_FAILED) | 134 | return sprintf(buf, "%d\n", failed); |
126 | return sprintf(buf, "1\n"); | ||
127 | |||
128 | return sprintf(buf, "0\n"); | ||
129 | } | 135 | } |
130 | 136 | ||
131 | static ssize_t zfcp_sysfs_unit_failed_store(struct device *dev, | 137 | static ssize_t zfcp_sysfs_unit_failed_store(struct device *dev, |
@@ -134,15 +140,21 @@ static ssize_t zfcp_sysfs_unit_failed_store(struct device *dev, | |||
134 | { | 140 | { |
135 | struct zfcp_unit *unit = container_of(dev, struct zfcp_unit, dev); | 141 | struct zfcp_unit *unit = container_of(dev, struct zfcp_unit, dev); |
136 | unsigned long val; | 142 | unsigned long val; |
143 | struct scsi_device *sdev; | ||
137 | 144 | ||
138 | if (strict_strtoul(buf, 0, &val) || val != 0) | 145 | if (strict_strtoul(buf, 0, &val) || val != 0) |
139 | return -EINVAL; | 146 | return -EINVAL; |
140 | 147 | ||
141 | zfcp_erp_modify_unit_status(unit, "syufai1", NULL, | 148 | sdev = zfcp_unit_sdev(unit); |
142 | ZFCP_STATUS_COMMON_RUNNING, ZFCP_SET); | 149 | if (sdev) { |
143 | zfcp_erp_unit_reopen(unit, ZFCP_STATUS_COMMON_ERP_FAILED, | 150 | zfcp_erp_modify_lun_status(sdev, "syufai1", NULL, |
144 | "syufai2", NULL); | 151 | ZFCP_STATUS_COMMON_RUNNING, |
145 | zfcp_erp_wait(unit->port->adapter); | 152 | ZFCP_SET); |
153 | zfcp_erp_lun_reopen(sdev, ZFCP_STATUS_COMMON_ERP_FAILED, | ||
154 | "syufai2", NULL); | ||
155 | zfcp_erp_wait(unit->port->adapter); | ||
156 | } else | ||
157 | zfcp_unit_scsi_scan(unit); | ||
146 | 158 | ||
147 | return count; | 159 | return count; |
148 | } | 160 | } |
@@ -347,9 +359,9 @@ zfcp_sysfs_unit_##_name##_latency_show(struct device *dev, \ | |||
347 | struct device_attribute *attr, \ | 359 | struct device_attribute *attr, \ |
348 | char *buf) { \ | 360 | char *buf) { \ |
349 | struct scsi_device *sdev = to_scsi_device(dev); \ | 361 | struct scsi_device *sdev = to_scsi_device(dev); \ |
350 | struct zfcp_unit *unit = sdev->hostdata; \ | 362 | struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); \ |
351 | struct zfcp_latencies *lat = &unit->latencies; \ | 363 | struct zfcp_latencies *lat = &zfcp_sdev->latencies; \ |
352 | struct zfcp_adapter *adapter = unit->port->adapter; \ | 364 | struct zfcp_adapter *adapter = zfcp_sdev->port->adapter; \ |
353 | unsigned long long fsum, fmin, fmax, csum, cmin, cmax, cc; \ | 365 | unsigned long long fsum, fmin, fmax, csum, cmin, cmax, cc; \ |
354 | \ | 366 | \ |
355 | spin_lock_bh(&lat->lock); \ | 367 | spin_lock_bh(&lat->lock); \ |
@@ -378,8 +390,8 @@ zfcp_sysfs_unit_##_name##_latency_store(struct device *dev, \ | |||
378 | const char *buf, size_t count) \ | 390 | const char *buf, size_t count) \ |
379 | { \ | 391 | { \ |
380 | struct scsi_device *sdev = to_scsi_device(dev); \ | 392 | struct scsi_device *sdev = to_scsi_device(dev); \ |
381 | struct zfcp_unit *unit = sdev->hostdata; \ | 393 | struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); \ |
382 | struct zfcp_latencies *lat = &unit->latencies; \ | 394 | struct zfcp_latencies *lat = &zfcp_sdev->latencies; \ |
383 | unsigned long flags; \ | 395 | unsigned long flags; \ |
384 | \ | 396 | \ |
385 | spin_lock_irqsave(&lat->lock, flags); \ | 397 | spin_lock_irqsave(&lat->lock, flags); \ |
@@ -407,26 +419,26 @@ static ssize_t zfcp_sysfs_scsi_##_name##_show(struct device *dev, \ | |||
407 | struct device_attribute *attr,\ | 419 | struct device_attribute *attr,\ |
408 | char *buf) \ | 420 | char *buf) \ |
409 | { \ | 421 | { \ |
410 | struct scsi_device *sdev = to_scsi_device(dev); \ | 422 | struct scsi_device *sdev = to_scsi_device(dev); \ |
411 | struct zfcp_unit *unit = sdev->hostdata; \ | 423 | struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); \ |
424 | struct zfcp_port *port = zfcp_sdev->port; \ | ||
412 | \ | 425 | \ |
413 | return sprintf(buf, _format, _value); \ | 426 | return sprintf(buf, _format, _value); \ |
414 | } \ | 427 | } \ |
415 | static DEVICE_ATTR(_name, S_IRUGO, zfcp_sysfs_scsi_##_name##_show, NULL); | 428 | static DEVICE_ATTR(_name, S_IRUGO, zfcp_sysfs_scsi_##_name##_show, NULL); |
416 | 429 | ||
417 | ZFCP_DEFINE_SCSI_ATTR(hba_id, "%s\n", | 430 | ZFCP_DEFINE_SCSI_ATTR(hba_id, "%s\n", |
418 | dev_name(&unit->port->adapter->ccw_device->dev)); | 431 | dev_name(&port->adapter->ccw_device->dev)); |
419 | ZFCP_DEFINE_SCSI_ATTR(wwpn, "0x%016llx\n", | 432 | ZFCP_DEFINE_SCSI_ATTR(wwpn, "0x%016llx\n", |
420 | (unsigned long long) unit->port->wwpn); | 433 | (unsigned long long) port->wwpn); |
421 | 434 | ||
422 | static ssize_t zfcp_sysfs_scsi_fcp_lun_show(struct device *dev, | 435 | static ssize_t zfcp_sysfs_scsi_fcp_lun_show(struct device *dev, |
423 | struct device_attribute *attr, | 436 | struct device_attribute *attr, |
424 | char *buf) | 437 | char *buf) |
425 | { | 438 | { |
426 | struct scsi_device *sdev = to_scsi_device(dev); | 439 | struct scsi_device *sdev = to_scsi_device(dev); |
427 | struct zfcp_unit *unit = sdev->hostdata; | ||
428 | 440 | ||
429 | return sprintf(buf, "0x%016llx\n", (unsigned long long) unit->fcp_lun); | 441 | return sprintf(buf, "0x%016llx\n", zfcp_scsi_dev_lun(sdev)); |
430 | } | 442 | } |
431 | static DEVICE_ATTR(fcp_lun, S_IRUGO, zfcp_sysfs_scsi_fcp_lun_show, NULL); | 443 | static DEVICE_ATTR(fcp_lun, S_IRUGO, zfcp_sysfs_scsi_fcp_lun_show, NULL); |
432 | 444 | ||
diff --git a/drivers/s390/scsi/zfcp_unit.c b/drivers/s390/scsi/zfcp_unit.c index e210c41ee389..1119c535a667 100644 --- a/drivers/s390/scsi/zfcp_unit.c +++ b/drivers/s390/scsi/zfcp_unit.c | |||
@@ -134,14 +134,7 @@ int zfcp_unit_add(struct zfcp_port *port, u64 fcp_lun) | |||
134 | unit->fcp_lun = fcp_lun; | 134 | unit->fcp_lun = fcp_lun; |
135 | unit->dev.parent = &port->dev; | 135 | unit->dev.parent = &port->dev; |
136 | unit->dev.release = zfcp_unit_release; | 136 | unit->dev.release = zfcp_unit_release; |
137 | unit->latencies.write.channel.min = 0xFFFFFFFF; | ||
138 | unit->latencies.write.fabric.min = 0xFFFFFFFF; | ||
139 | unit->latencies.read.channel.min = 0xFFFFFFFF; | ||
140 | unit->latencies.read.fabric.min = 0xFFFFFFFF; | ||
141 | unit->latencies.cmd.channel.min = 0xFFFFFFFF; | ||
142 | unit->latencies.cmd.fabric.min = 0xFFFFFFFF; | ||
143 | INIT_WORK(&unit->scsi_work, zfcp_unit_scsi_scan_work); | 137 | INIT_WORK(&unit->scsi_work, zfcp_unit_scsi_scan_work); |
144 | spin_lock_init(&unit->latencies.lock); | ||
145 | 138 | ||
146 | if (dev_set_name(&unit->dev, "0x%016llx", | 139 | if (dev_set_name(&unit->dev, "0x%016llx", |
147 | (unsigned long long) fcp_lun)) { | 140 | (unsigned long long) fcp_lun)) { |
@@ -165,9 +158,6 @@ int zfcp_unit_add(struct zfcp_port *port, u64 fcp_lun) | |||
165 | list_add_tail(&unit->list, &port->unit_list); | 158 | list_add_tail(&unit->list, &port->unit_list); |
166 | write_unlock_irq(&port->unit_list_lock); | 159 | write_unlock_irq(&port->unit_list_lock); |
167 | 160 | ||
168 | atomic_set_mask(ZFCP_STATUS_COMMON_RUNNING, &unit->status); | ||
169 | zfcp_erp_unit_reopen(unit, 0, "syuas_1", NULL); | ||
170 | zfcp_erp_wait(unit->port->adapter); | ||
171 | zfcp_unit_scsi_scan(unit); | 161 | zfcp_unit_scsi_scan(unit); |
172 | 162 | ||
173 | return 0; | 163 | return 0; |
@@ -248,7 +238,6 @@ int zfcp_unit_remove(struct zfcp_port *port, u64 fcp_lun) | |||
248 | 238 | ||
249 | put_device(&unit->dev); | 239 | put_device(&unit->dev); |
250 | 240 | ||
251 | zfcp_erp_unit_shutdown(unit, 0, "unrem_1", NULL); | ||
252 | zfcp_device_unregister(&unit->dev, &zfcp_sysfs_unit_attrs); | 241 | zfcp_device_unregister(&unit->dev, &zfcp_sysfs_unit_attrs); |
253 | 242 | ||
254 | return 0; | 243 | return 0; |