From 2450d3e7b8604d0abb042817f2502cb7ee0b782f Mon Sep 17 00:00:00 2001 From: Stefan Raspl Date: Wed, 1 Oct 2008 12:42:14 +0200 Subject: [SCSI] zfcp: add queue_full sysfs attribute Adds a new sysfs attribute queue_full for adapters that records the number of incidents where a requests could not be submitted due to insufficient free space on the request queue. Signed-off-by: Stefan Raspl Signed-off-by: Martin Peschke Signed-off-by: Christof Schmitt Signed-off-by: James Bottomley --- drivers/s390/scsi/zfcp_sysfs.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'drivers/s390/scsi/zfcp_sysfs.c') diff --git a/drivers/s390/scsi/zfcp_sysfs.c b/drivers/s390/scsi/zfcp_sysfs.c index 2e85c6c49e7d..7e857571fe44 100644 --- a/drivers/s390/scsi/zfcp_sysfs.c +++ b/drivers/s390/scsi/zfcp_sysfs.c @@ -487,10 +487,23 @@ ZFCP_SHOST_ATTR(megabytes, "%llu %llu\n", ZFCP_SHOST_ATTR(seconds_active, "%llu\n", (unsigned long long) stat_info.seconds_act); +static ssize_t zfcp_sysfs_adapter_q_full_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct Scsi_Host *scsi_host = class_to_shost(dev); + struct zfcp_adapter *adapter = + (struct zfcp_adapter *) scsi_host->hostdata[0]; + + return sprintf(buf, "%d\n", atomic_read(&adapter->qdio_outb_full)); +} +static DEVICE_ATTR(queue_full, S_IRUGO, zfcp_sysfs_adapter_q_full_show, NULL); + struct device_attribute *zfcp_sysfs_shost_attrs[] = { &dev_attr_utilization, &dev_attr_requests, &dev_attr_megabytes, &dev_attr_seconds_active, + &dev_attr_queue_full, NULL }; -- cgit v1.2.3 From 5ab944f97e09a3d52951fe903eed9a7b88d810b2 Mon Sep 17 00:00:00 2001 From: Swen Schillig Date: Wed, 1 Oct 2008 12:42:17 +0200 Subject: [SCSI] zfcp: attach and release SAN nameserver port on demand Changing the zfcp behaviour from always having the nameserver port open to an on-demand strategy. This strategy reduces the use of limited resources like port connections. The patch provides a common infrastructure which could be used for all WKA ports in future. Also reduce the number of nameserver lookups by changing the zfcp behaviour of always querying the nameserver for the corresponding destination ID of the remote port. If the destination ID has changed during the reopen process we will be informed and then trigger a nameserver query on demand. Signed-off-by: Swen Schillig Signed-off-by: Christof Schmitt Signed-off-by: James Bottomley --- drivers/s390/scsi/zfcp_aux.c | 65 ++----------- drivers/s390/scsi/zfcp_dbf.c | 14 +-- drivers/s390/scsi/zfcp_def.h | 31 ++++-- drivers/s390/scsi/zfcp_erp.c | 149 ++++++++-------------------- drivers/s390/scsi/zfcp_ext.h | 7 +- drivers/s390/scsi/zfcp_fc.c | 215 +++++++++++++++++++++++++++++------------ drivers/s390/scsi/zfcp_fsf.c | 137 ++++++++++++++++++++++++-- drivers/s390/scsi/zfcp_sysfs.c | 19 +--- 8 files changed, 362 insertions(+), 275 deletions(-) (limited to 'drivers/s390/scsi/zfcp_sysfs.c') diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c index ee13a455c823..181f88bb53b3 100644 --- a/drivers/s390/scsi/zfcp_aux.c +++ b/drivers/s390/scsi/zfcp_aux.c @@ -450,19 +450,6 @@ static void _zfcp_status_read_scheduler(struct work_struct *work) stat_work)); } -static int zfcp_nameserver_enqueue(struct zfcp_adapter *adapter) -{ - struct zfcp_port *port; - - port = zfcp_port_enqueue(adapter, 0, ZFCP_STATUS_PORT_WKA, - ZFCP_DID_DIRECTORY_SERVICE); - if (IS_ERR(port)) - return PTR_ERR(port); - zfcp_port_put(port); - - return 0; -} - /** * zfcp_adapter_enqueue - enqueue a new adapter to the list * @ccw_device: pointer to the struct cc_device @@ -552,7 +539,7 @@ int zfcp_adapter_enqueue(struct ccw_device *ccw_device) zfcp_data.adapters++; - zfcp_nameserver_enqueue(adapter); + zfcp_fc_nameserver_init(adapter); return 0; @@ -638,7 +625,6 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, wwn_t wwpn, { struct zfcp_port *port; int retval; - char *bus_id; port = kzalloc(sizeof(struct zfcp_port), GFP_KERNEL); if (!port) @@ -648,6 +634,7 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, wwn_t wwpn, INIT_LIST_HEAD(&port->unit_list_head); INIT_LIST_HEAD(&port->unit_remove_lh); + INIT_WORK(&port->gid_pn_work, zfcp_erp_port_strategy_open_lookup); port->adapter = adapter; port->d_id = d_id; @@ -657,34 +644,8 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, wwn_t wwpn, atomic_set_mask(status | ZFCP_STATUS_COMMON_REMOVE, &port->status); atomic_set(&port->refcount, 0); - if (status & ZFCP_STATUS_PORT_WKA) { - switch (d_id) { - case ZFCP_DID_DIRECTORY_SERVICE: - bus_id = "directory"; - break; - case ZFCP_DID_MANAGEMENT_SERVICE: - bus_id = "management"; - break; - case ZFCP_DID_KEY_DISTRIBUTION_SERVICE: - bus_id = "key_distribution"; - break; - case ZFCP_DID_ALIAS_SERVICE: - bus_id = "alias"; - break; - case ZFCP_DID_TIME_SERVICE: - bus_id = "time"; - break; - default: - kfree(port); - return ERR_PTR(-EINVAL); - } - snprintf(port->sysfs_device.bus_id, BUS_ID_SIZE, "%s", bus_id); - port->sysfs_device.parent = &adapter->generic_services; - } else { - snprintf(port->sysfs_device.bus_id, - BUS_ID_SIZE, "0x%016llx", wwpn); - port->sysfs_device.parent = &adapter->ccw_device->dev; - } + snprintf(port->sysfs_device.bus_id, BUS_ID_SIZE, "0x%016llx", wwpn); + port->sysfs_device.parent = &adapter->ccw_device->dev; port->sysfs_device.release = zfcp_sysfs_port_release; dev_set_drvdata(&port->sysfs_device, port); @@ -700,12 +661,8 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, wwn_t wwpn, if (device_register(&port->sysfs_device)) goto err_out_free; - if (status & ZFCP_STATUS_PORT_WKA) - retval = sysfs_create_group(&port->sysfs_device.kobj, - &zfcp_sysfs_ns_port_attrs); - else - retval = sysfs_create_group(&port->sysfs_device.kobj, - &zfcp_sysfs_port_attrs); + retval = sysfs_create_group(&port->sysfs_device.kobj, + &zfcp_sysfs_port_attrs); if (retval) { device_unregister(&port->sysfs_device); @@ -718,9 +675,6 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, wwn_t wwpn, list_add_tail(&port->list, &adapter->port_list_head); atomic_clear_mask(ZFCP_STATUS_COMMON_REMOVE, &port->status); atomic_set_mask(ZFCP_STATUS_COMMON_RUNNING, &port->status); - if (d_id == ZFCP_DID_DIRECTORY_SERVICE) - if (!adapter->nameserver_port) - adapter->nameserver_port = port; adapter->ports++; write_unlock_irq(&zfcp_data.config_lock); @@ -749,12 +703,7 @@ void zfcp_port_dequeue(struct zfcp_port *port) fc_remote_port_delete(port->rport); port->rport = NULL; zfcp_adapter_put(port->adapter); - if (atomic_read(&port->status) & ZFCP_STATUS_PORT_WKA) - sysfs_remove_group(&port->sysfs_device.kobj, - &zfcp_sysfs_ns_port_attrs); - else - sysfs_remove_group(&port->sysfs_device.kobj, - &zfcp_sysfs_port_attrs); + sysfs_remove_group(&port->sysfs_device.kobj, &zfcp_sysfs_port_attrs); device_unregister(&port->sysfs_device); } diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c index d088d30516f9..c1f69f611e69 100644 --- a/drivers/s390/scsi/zfcp_dbf.c +++ b/drivers/s390/scsi/zfcp_dbf.c @@ -519,7 +519,7 @@ static const char *zfcp_rec_dbf_ids[] = { [75] = "physical port recovery escalation after failed port " "recovery", [76] = "port recovery escalation after failed unit recovery", - [77] = "recovery opening nameserver port", + [77] = "", [78] = "duplicate request id", [79] = "link down", [80] = "exclusive read-only unit access unsupported", @@ -829,8 +829,8 @@ void zfcp_rec_dbf_event_action(u8 id2, struct zfcp_erp_action *erp_action) void zfcp_san_dbf_event_ct_request(struct zfcp_fsf_req *fsf_req) { struct zfcp_send_ct *ct = (struct zfcp_send_ct *)fsf_req->data; - struct zfcp_port *port = ct->port; - struct zfcp_adapter *adapter = port->adapter; + struct zfcp_wka_port *wka_port = ct->wka_port; + struct zfcp_adapter *adapter = wka_port->adapter; struct ct_hdr *hdr = sg_virt(ct->req); struct zfcp_san_dbf_record *r = &adapter->san_dbf_buf; struct zfcp_san_dbf_record_ct_request *oct = &r->u.ct_req; @@ -842,7 +842,7 @@ void zfcp_san_dbf_event_ct_request(struct zfcp_fsf_req *fsf_req) r->fsf_reqid = (unsigned long)fsf_req; r->fsf_seqno = fsf_req->seq_no; r->s_id = fc_host_port_id(adapter->scsi_host); - r->d_id = port->d_id; + r->d_id = wka_port->d_id; oct->cmd_req_code = hdr->cmd_rsp_code; oct->revision = hdr->revision; oct->gs_type = hdr->gs_type; @@ -863,8 +863,8 @@ void zfcp_san_dbf_event_ct_request(struct zfcp_fsf_req *fsf_req) void zfcp_san_dbf_event_ct_response(struct zfcp_fsf_req *fsf_req) { struct zfcp_send_ct *ct = (struct zfcp_send_ct *)fsf_req->data; - struct zfcp_port *port = ct->port; - struct zfcp_adapter *adapter = port->adapter; + struct zfcp_wka_port *wka_port = ct->wka_port; + struct zfcp_adapter *adapter = wka_port->adapter; struct ct_hdr *hdr = sg_virt(ct->resp); struct zfcp_san_dbf_record *r = &adapter->san_dbf_buf; struct zfcp_san_dbf_record_ct_response *rct = &r->u.ct_resp; @@ -875,7 +875,7 @@ void zfcp_san_dbf_event_ct_response(struct zfcp_fsf_req *fsf_req) strncpy(r->tag, "rctc", ZFCP_DBF_TAG_SIZE); r->fsf_reqid = (unsigned long)fsf_req; r->fsf_seqno = fsf_req->seq_no; - r->s_id = port->d_id; + r->s_id = wka_port->d_id; r->d_id = fc_host_port_id(adapter->scsi_host); rct->cmd_rsp_code = hdr->cmd_rsp_code; rct->revision = hdr->revision; diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h index 699ecaf2e503..0d6a388882d4 100644 --- a/drivers/s390/scsi/zfcp_def.h +++ b/drivers/s390/scsi/zfcp_def.h @@ -253,6 +253,7 @@ struct zfcp_ls_adisc { #define ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED 0x00000200 /* FC-PH/FC-GS well-known address identifiers for generic services */ +#define ZFCP_DID_WKA 0xFFFFF0 #define ZFCP_DID_MANAGEMENT_SERVICE 0xFFFFFA #define ZFCP_DID_TIME_SERVICE 0xFFFFFB #define ZFCP_DID_DIRECTORY_SERVICE 0xFFFFFC @@ -264,13 +265,15 @@ struct zfcp_ls_adisc { #define ZFCP_STATUS_PORT_DID_DID 0x00000002 #define ZFCP_STATUS_PORT_PHYS_CLOSING 0x00000004 #define ZFCP_STATUS_PORT_NO_WWPN 0x00000008 -#define ZFCP_STATUS_PORT_NO_SCSI_ID 0x00000010 #define ZFCP_STATUS_PORT_INVALID_WWPN 0x00000020 -/* for ports with well known addresses */ -#define ZFCP_STATUS_PORT_WKA \ - (ZFCP_STATUS_PORT_NO_WWPN | \ - ZFCP_STATUS_PORT_NO_SCSI_ID) +/* well known address (WKA) port status*/ +enum zfcp_wka_status { + ZFCP_WKA_PORT_OFFLINE, + ZFCP_WKA_PORT_CLOSING, + ZFCP_WKA_PORT_OPENING, + ZFCP_WKA_PORT_ONLINE, +}; /* logical unit status */ #define ZFCP_STATUS_UNIT_SHARED 0x00000004 @@ -340,7 +343,7 @@ typedef void (*zfcp_send_ct_handler_t)(unsigned long); /** * struct zfcp_send_ct - used to pass parameters to function zfcp_fsf_send_ct - * @port: port where the request is sent to + * @wka_port: port where the request is sent to * @req: scatter-gather list for request * @resp: scatter-gather list for response * @req_count: number of elements in request scatter-gather list @@ -352,7 +355,7 @@ typedef void (*zfcp_send_ct_handler_t)(unsigned long); * @status: used to pass error status to calling function */ struct zfcp_send_ct { - struct zfcp_port *port; + struct zfcp_wka_port *wka_port; struct scatterlist *req; struct scatterlist *resp; unsigned int req_count; @@ -406,6 +409,17 @@ struct zfcp_send_els { int status; }; +struct zfcp_wka_port { + struct zfcp_adapter *adapter; + wait_queue_head_t completion_wq; + enum zfcp_wka_status status; + atomic_t refcount; + u32 d_id; + u32 handle; + struct mutex mutex; + struct delayed_work work; +}; + struct zfcp_qdio_queue { struct qdio_buffer *sbal[QDIO_MAX_BUFFERS_PER_Q]; /* SBALs */ u8 first; /* index of next free bfr @@ -496,7 +510,7 @@ struct zfcp_adapter { actions */ u32 erp_low_mem_count; /* nr of erp actions waiting for memory */ - struct zfcp_port *nameserver_port; /* adapter's nameserver */ + struct zfcp_wka_port nsp; /* adapter's nameserver */ debug_info_t *rec_dbf; debug_info_t *hba_dbf; debug_info_t *san_dbf; /* debug feature areas */ @@ -540,6 +554,7 @@ struct zfcp_port { atomic_t erp_counter; u32 maxframe_size; u32 supported_classes; + struct work_struct gid_pn_work; }; struct zfcp_unit { diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c index b18c6dd37294..e7d3bce51429 100644 --- a/drivers/s390/scsi/zfcp_erp.c +++ b/drivers/s390/scsi/zfcp_erp.c @@ -23,7 +23,6 @@ enum zfcp_erp_steps { ZFCP_ERP_STEP_FSF_XCONFIG = 0x0001, ZFCP_ERP_STEP_PHYS_PORT_CLOSING = 0x0010, ZFCP_ERP_STEP_PORT_CLOSING = 0x0100, - ZFCP_ERP_STEP_NAMESERVER_OPEN = 0x0200, ZFCP_ERP_STEP_NAMESERVER_LOOKUP = 0x0400, ZFCP_ERP_STEP_PORT_OPENING = 0x0800, ZFCP_ERP_STEP_UNIT_CLOSING = 0x1000, @@ -532,8 +531,7 @@ static void _zfcp_erp_port_reopen_all(struct zfcp_adapter *adapter, struct zfcp_port *port; list_for_each_entry(port, &adapter->port_list_head, list) - if (!(atomic_read(&port->status) & ZFCP_STATUS_PORT_WKA)) - _zfcp_erp_port_reopen(port, clear, id, ref); + _zfcp_erp_port_reopen(port, clear, id, ref); } static void _zfcp_erp_unit_reopen_all(struct zfcp_port *port, int clear, u8 id, @@ -777,7 +775,6 @@ static int zfcp_erp_port_forced_strategy_close(struct zfcp_erp_action *act) static void zfcp_erp_port_strategy_clearstati(struct zfcp_port *port) { atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED | - ZFCP_STATUS_PORT_DID_DID | ZFCP_STATUS_PORT_PHYS_CLOSING | ZFCP_STATUS_PORT_INVALID_WWPN, &port->status); @@ -830,62 +827,6 @@ static int zfcp_erp_port_strategy_open_port(struct zfcp_erp_action *erp_action) return ZFCP_ERP_CONTINUES; } -static void zfcp_erp_port_strategy_open_ns_wake(struct zfcp_erp_action *ns_act) -{ - unsigned long flags; - struct zfcp_adapter *adapter = ns_act->adapter; - struct zfcp_erp_action *act, *tmp; - int status; - - read_lock_irqsave(&adapter->erp_lock, flags); - list_for_each_entry_safe(act, tmp, &adapter->erp_running_head, list) { - if (act->step == ZFCP_ERP_STEP_NAMESERVER_OPEN) { - status = atomic_read(&adapter->nameserver_port->status); - if (status & ZFCP_STATUS_COMMON_ERP_FAILED) - zfcp_erp_port_failed(act->port, 27, NULL); - zfcp_erp_action_ready(act); - } - } - read_unlock_irqrestore(&adapter->erp_lock, flags); -} - -static int zfcp_erp_port_strategy_open_nameserver(struct zfcp_erp_action *act) -{ - int retval; - - switch (act->step) { - case ZFCP_ERP_STEP_UNINITIALIZED: - case ZFCP_ERP_STEP_PHYS_PORT_CLOSING: - case ZFCP_ERP_STEP_PORT_CLOSING: - return zfcp_erp_port_strategy_open_port(act); - - case ZFCP_ERP_STEP_PORT_OPENING: - if (atomic_read(&act->port->status) & ZFCP_STATUS_COMMON_OPEN) - retval = ZFCP_ERP_SUCCEEDED; - else - retval = ZFCP_ERP_FAILED; - /* this is needed anyway */ - zfcp_erp_port_strategy_open_ns_wake(act); - return retval; - - default: - return ZFCP_ERP_FAILED; - } -} - -static int zfcp_erp_port_strategy_open_lookup(struct zfcp_erp_action *act) -{ - int retval; - - retval = zfcp_fc_ns_gid_pn_request(act); - if (retval == -ENOMEM) - return ZFCP_ERP_NOMEM; - act->step = ZFCP_ERP_STEP_NAMESERVER_LOOKUP; - if (retval) - return ZFCP_ERP_FAILED; - return ZFCP_ERP_CONTINUES; -} - static int zfcp_erp_open_ptp_port(struct zfcp_erp_action *act) { struct zfcp_adapter *adapter = act->adapter; @@ -900,11 +841,25 @@ static int zfcp_erp_open_ptp_port(struct zfcp_erp_action *act) return zfcp_erp_port_strategy_open_port(act); } +void zfcp_erp_port_strategy_open_lookup(struct work_struct *work) +{ + int retval; + struct zfcp_port *port = container_of(work, struct zfcp_port, + gid_pn_work); + + retval = zfcp_fc_ns_gid_pn(&port->erp_action); + if (retval == -ENOMEM) + zfcp_erp_notify(&port->erp_action, ZFCP_ERP_NOMEM); + port->erp_action.step = ZFCP_ERP_STEP_NAMESERVER_LOOKUP; + if (retval) + zfcp_erp_notify(&port->erp_action, ZFCP_ERP_FAILED); + +} + static int zfcp_erp_port_strategy_open_common(struct zfcp_erp_action *act) { struct zfcp_adapter *adapter = act->adapter; struct zfcp_port *port = act->port; - struct zfcp_port *ns_port = adapter->nameserver_port; int p_status = atomic_read(&port->status); switch (act->step) { @@ -913,29 +868,10 @@ static int zfcp_erp_port_strategy_open_common(struct zfcp_erp_action *act) case ZFCP_ERP_STEP_PORT_CLOSING: if (fc_host_port_type(adapter->scsi_host) == FC_PORTTYPE_PTP) return zfcp_erp_open_ptp_port(act); - if (!ns_port) { - dev_err(&adapter->ccw_device->dev, - "Attaching the name server port to the " - "FCP device failed\n"); - return ZFCP_ERP_FAILED; - } - if (!(atomic_read(&ns_port->status) & - ZFCP_STATUS_COMMON_UNBLOCKED)) { - /* nameserver port may live again */ - atomic_set_mask(ZFCP_STATUS_COMMON_RUNNING, - &ns_port->status); - if (zfcp_erp_port_reopen(ns_port, 0, 77, act) >= 0) { - act->step = ZFCP_ERP_STEP_NAMESERVER_OPEN; - return ZFCP_ERP_CONTINUES; - } - return ZFCP_ERP_FAILED; + if (!(p_status & ZFCP_STATUS_PORT_DID_DID)) { + schedule_work(&port->gid_pn_work); + return ZFCP_ERP_CONTINUES; } - /* else nameserver port is already open, fall through */ - case ZFCP_ERP_STEP_NAMESERVER_OPEN: - if (!(atomic_read(&ns_port->status) & ZFCP_STATUS_COMMON_OPEN)) - return ZFCP_ERP_FAILED; - return zfcp_erp_port_strategy_open_lookup(act); - case ZFCP_ERP_STEP_NAMESERVER_LOOKUP: if (!(p_status & ZFCP_STATUS_PORT_DID_DID)) { if (p_status & (ZFCP_STATUS_PORT_INVALID_WWPN)) { @@ -948,25 +884,26 @@ static int zfcp_erp_port_strategy_open_common(struct zfcp_erp_action *act) case ZFCP_ERP_STEP_PORT_OPENING: /* D_ID might have changed during open */ - if ((p_status & ZFCP_STATUS_COMMON_OPEN) && - (p_status & ZFCP_STATUS_PORT_DID_DID)) - return ZFCP_ERP_SUCCEEDED; + if (p_status & ZFCP_STATUS_COMMON_OPEN) { + if (p_status & ZFCP_STATUS_PORT_DID_DID) + return ZFCP_ERP_SUCCEEDED; + else { + act->step = ZFCP_ERP_STEP_PORT_CLOSING; + return ZFCP_ERP_CONTINUES; + } /* fall through otherwise */ + } } return ZFCP_ERP_FAILED; } -static int zfcp_erp_port_strategy_open(struct zfcp_erp_action *act) -{ - if (atomic_read(&act->port->status) & (ZFCP_STATUS_PORT_WKA)) - return zfcp_erp_port_strategy_open_nameserver(act); - return zfcp_erp_port_strategy_open_common(act); -} - static int zfcp_erp_port_strategy(struct zfcp_erp_action *erp_action) { struct zfcp_port *port = erp_action->port; + if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_NOESC) + goto close_init_done; + switch (erp_action->step) { case ZFCP_ERP_STEP_UNINITIALIZED: zfcp_erp_port_strategy_clearstati(port); @@ -979,12 +916,12 @@ static int zfcp_erp_port_strategy(struct zfcp_erp_action *erp_action) return ZFCP_ERP_FAILED; break; } + +close_init_done: if (erp_action->status & ZFCP_STATUS_ERP_CLOSE_ONLY) return ZFCP_ERP_EXIT; - else - return zfcp_erp_port_strategy_open(erp_action); - return ZFCP_ERP_FAILED; + return zfcp_erp_port_strategy_open_common(erp_action); } static void zfcp_erp_unit_strategy_clearstati(struct zfcp_unit *unit) @@ -1296,12 +1233,10 @@ static void zfcp_erp_rport_register(struct zfcp_port *port) static void zfcp_erp_rports_del(struct zfcp_adapter *adapter) { struct zfcp_port *port; - list_for_each_entry(port, &adapter->port_list_head, list) - if (port->rport && !(atomic_read(&port->status) & - ZFCP_STATUS_PORT_WKA)) { - fc_remote_port_delete(port->rport); - port->rport = NULL; - } + list_for_each_entry(port, &adapter->port_list_head, list) { + fc_remote_port_delete(port->rport); + port->rport = NULL; + } } static void zfcp_erp_action_cleanup(struct zfcp_erp_action *act, int result) @@ -1737,9 +1672,8 @@ static void zfcp_erp_port_access_changed(struct zfcp_port *port, u8 id, if (!(status & (ZFCP_STATUS_COMMON_ACCESS_DENIED | ZFCP_STATUS_COMMON_ACCESS_BOXED))) { - if (!(status & ZFCP_STATUS_PORT_WKA)) - list_for_each_entry(unit, &port->unit_list_head, list) - zfcp_erp_unit_access_changed(unit, id, ref); + list_for_each_entry(unit, &port->unit_list_head, list) + zfcp_erp_unit_access_changed(unit, id, ref); return; } @@ -1762,10 +1696,7 @@ void zfcp_erp_adapter_access_changed(struct zfcp_adapter *adapter, u8 id, return; read_lock_irqsave(&zfcp_data.config_lock, flags); - if (adapter->nameserver_port) - zfcp_erp_port_access_changed(adapter->nameserver_port, id, ref); list_for_each_entry(port, &adapter->port_list_head, list) - if (port != adapter->nameserver_port) - zfcp_erp_port_access_changed(port, id, ref); + zfcp_erp_port_access_changed(port, id, ref); read_unlock_irqrestore(&zfcp_data.config_lock, flags); } diff --git a/drivers/s390/scsi/zfcp_ext.h b/drivers/s390/scsi/zfcp_ext.h index a8dd105dc086..5c8a703b5ce1 100644 --- a/drivers/s390/scsi/zfcp_ext.h +++ b/drivers/s390/scsi/zfcp_ext.h @@ -91,17 +91,21 @@ extern void zfcp_erp_port_access_denied(struct zfcp_port *, u8, void *); extern void zfcp_erp_unit_access_denied(struct zfcp_unit *, u8, void *); extern void zfcp_erp_adapter_access_changed(struct zfcp_adapter *, u8, void *); extern void zfcp_erp_timeout_handler(unsigned long); +extern void zfcp_erp_port_strategy_open_lookup(struct work_struct *); /* zfcp_fc.c */ extern int zfcp_scan_ports(struct zfcp_adapter *); extern void _zfcp_scan_ports_later(struct work_struct *); extern void zfcp_fc_incoming_els(struct zfcp_fsf_req *); -extern int zfcp_fc_ns_gid_pn_request(struct zfcp_erp_action *); +extern int zfcp_fc_ns_gid_pn(struct zfcp_erp_action *); extern void zfcp_fc_plogi_evaluate(struct zfcp_port *, struct fsf_plogi *); extern void zfcp_test_link(struct zfcp_port *); +extern void zfcp_fc_nameserver_init(struct zfcp_adapter *); /* zfcp_fsf.c */ extern int zfcp_fsf_open_port(struct zfcp_erp_action *); +extern int zfcp_fsf_open_wka_port(struct zfcp_wka_port *); +extern int zfcp_fsf_close_wka_port(struct zfcp_wka_port *); extern int zfcp_fsf_close_port(struct zfcp_erp_action *); extern int zfcp_fsf_close_physical_port(struct zfcp_erp_action *); extern int zfcp_fsf_open_unit(struct zfcp_erp_action *); @@ -153,7 +157,6 @@ extern struct fc_function_template zfcp_transport_functions; /* zfcp_sysfs.c */ extern struct attribute_group zfcp_sysfs_unit_attrs; extern struct attribute_group zfcp_sysfs_adapter_attrs; -extern struct attribute_group zfcp_sysfs_ns_port_attrs; extern struct attribute_group zfcp_sysfs_port_attrs; extern struct device_attribute *zfcp_sysfs_sdev_attrs[]; extern struct device_attribute *zfcp_sysfs_shost_attrs[]; diff --git a/drivers/s390/scsi/zfcp_fc.c b/drivers/s390/scsi/zfcp_fc.c index 44456f74a12d..899e45b9e60b 100644 --- a/drivers/s390/scsi/zfcp_fc.c +++ b/drivers/s390/scsi/zfcp_fc.c @@ -39,6 +39,84 @@ struct zfcp_gpn_ft { struct scatterlist sg_resp[ZFCP_GPN_FT_BUFFERS]; }; +struct zfcp_fc_ns_handler_data { + struct completion done; + void (*handler)(unsigned long); + unsigned long handler_data; +}; + +static int zfcp_wka_port_get(struct zfcp_wka_port *wka_port) +{ + if (mutex_lock_interruptible(&wka_port->mutex)) + return -ERESTARTSYS; + + if (wka_port->status != ZFCP_WKA_PORT_ONLINE) { + wka_port->status = ZFCP_WKA_PORT_OPENING; + if (zfcp_fsf_open_wka_port(wka_port)) + wka_port->status = ZFCP_WKA_PORT_OFFLINE; + } + + mutex_unlock(&wka_port->mutex); + + wait_event_timeout( + wka_port->completion_wq, + wka_port->status == ZFCP_WKA_PORT_ONLINE || + wka_port->status == ZFCP_WKA_PORT_OFFLINE, + HZ >> 1); + + if (wka_port->status == ZFCP_WKA_PORT_ONLINE) { + atomic_inc(&wka_port->refcount); + return 0; + } + return -EIO; +} + +static void zfcp_wka_port_offline(struct work_struct *work) +{ + struct delayed_work *dw = container_of(work, struct delayed_work, work); + struct zfcp_wka_port *wka_port = + container_of(dw, struct zfcp_wka_port, work); + + wait_event(wka_port->completion_wq, + atomic_read(&wka_port->refcount) == 0); + + mutex_lock(&wka_port->mutex); + if ((atomic_read(&wka_port->refcount) != 0) || + (wka_port->status != ZFCP_WKA_PORT_ONLINE)) + goto out; + + wka_port->status = ZFCP_WKA_PORT_CLOSING; + if (zfcp_fsf_close_wka_port(wka_port)) { + wka_port->status = ZFCP_WKA_PORT_OFFLINE; + wake_up(&wka_port->completion_wq); + } +out: + mutex_unlock(&wka_port->mutex); +} + +static void zfcp_wka_port_put(struct zfcp_wka_port *wka_port) +{ + if (atomic_dec_return(&wka_port->refcount) != 0) + return; + /* wait 10 miliseconds, other reqs might pop in */ + schedule_delayed_work(&wka_port->work, HZ / 100); +} + +void zfcp_fc_nameserver_init(struct zfcp_adapter *adapter) +{ + struct zfcp_wka_port *wka_port = &adapter->nsp; + + init_waitqueue_head(&wka_port->completion_wq); + + wka_port->adapter = adapter; + wka_port->d_id = ZFCP_DID_DIRECTORY_SERVICE; + + wka_port->status = ZFCP_WKA_PORT_OFFLINE; + atomic_set(&wka_port->refcount, 0); + mutex_init(&wka_port->mutex); + INIT_DELAYED_WORK(&wka_port->work, zfcp_wka_port_offline); +} + static void _zfcp_fc_incoming_rscn(struct zfcp_fsf_req *fsf_req, u32 range, struct fcp_rscn_element *elem) { @@ -47,9 +125,6 @@ static void _zfcp_fc_incoming_rscn(struct zfcp_fsf_req *fsf_req, u32 range, read_lock_irqsave(&zfcp_data.config_lock, flags); list_for_each_entry(port, &fsf_req->adapter->port_list_head, list) { - if ((atomic_read(&port->status) & ZFCP_STATUS_PORT_WKA) == - ZFCP_STATUS_PORT_WKA) - continue; /* FIXME: ZFCP_STATUS_PORT_DID_DID check is racy */ if (!(atomic_read(&port->status) & ZFCP_STATUS_PORT_DID_DID)) /* Try to connect to unused ports anyway. */ @@ -158,7 +233,18 @@ void zfcp_fc_incoming_els(struct zfcp_fsf_req *fsf_req) zfcp_fc_incoming_rscn(fsf_req); } -static void zfcp_ns_gid_pn_handler(unsigned long data) +static void zfcp_fc_ns_handler(unsigned long data) +{ + struct zfcp_fc_ns_handler_data *compl_rec = + (struct zfcp_fc_ns_handler_data *) data; + + if (compl_rec->handler) + compl_rec->handler(compl_rec->handler_data); + + complete(&compl_rec->done); +} + +static void zfcp_fc_ns_gid_pn_eval(unsigned long data) { struct zfcp_gid_pn_data *gid_pn = (struct zfcp_gid_pn_data *) data; struct zfcp_send_ct *ct = &gid_pn->ct; @@ -167,43 +253,31 @@ static void zfcp_ns_gid_pn_handler(unsigned long data) struct zfcp_port *port = gid_pn->port; if (ct->status) - goto out; + return; if (ct_iu_resp->header.cmd_rsp_code != ZFCP_CT_ACCEPT) { atomic_set_mask(ZFCP_STATUS_PORT_INVALID_WWPN, &port->status); - goto out; + return; } /* paranoia */ if (ct_iu_req->wwpn != port->wwpn) - goto out; + return; /* looks like a valid d_id */ port->d_id = ct_iu_resp->d_id & ZFCP_DID_MASK; atomic_set_mask(ZFCP_STATUS_PORT_DID_DID, &port->status); -out: - mempool_free(gid_pn, port->adapter->pool.data_gid_pn); } -/** - * zfcp_fc_ns_gid_pn_request - initiate GID_PN nameserver request - * @erp_action: pointer to zfcp_erp_action where GID_PN request is needed - * return: -ENOMEM on error, 0 otherwise - */ -int zfcp_fc_ns_gid_pn_request(struct zfcp_erp_action *erp_action) +int static zfcp_fc_ns_gid_pn_request(struct zfcp_erp_action *erp_action, + struct zfcp_gid_pn_data *gid_pn) { - int ret; - struct zfcp_gid_pn_data *gid_pn; struct zfcp_adapter *adapter = erp_action->adapter; - - gid_pn = mempool_alloc(adapter->pool.data_gid_pn, GFP_ATOMIC); - if (!gid_pn) - return -ENOMEM; - - memset(gid_pn, 0, sizeof(*gid_pn)); + struct zfcp_fc_ns_handler_data compl_rec; + int ret; /* setup parameters for send generic command */ gid_pn->port = erp_action->port; - gid_pn->ct.port = adapter->nameserver_port; - gid_pn->ct.handler = zfcp_ns_gid_pn_handler; - gid_pn->ct.handler_data = (unsigned long) gid_pn; + gid_pn->ct.wka_port = &adapter->nsp; + gid_pn->ct.handler = zfcp_fc_ns_handler; + gid_pn->ct.handler_data = (unsigned long) &compl_rec; gid_pn->ct.timeout = ZFCP_NS_GID_PN_TIMEOUT; gid_pn->ct.req = &gid_pn->req; gid_pn->ct.resp = &gid_pn->resp; @@ -223,10 +297,42 @@ int zfcp_fc_ns_gid_pn_request(struct zfcp_erp_action *erp_action) gid_pn->ct_iu_req.header.max_res_size = ZFCP_CT_MAX_SIZE; gid_pn->ct_iu_req.wwpn = erp_action->port->wwpn; + init_completion(&compl_rec.done); + compl_rec.handler = zfcp_fc_ns_gid_pn_eval; + compl_rec.handler_data = (unsigned long) gid_pn; ret = zfcp_fsf_send_ct(&gid_pn->ct, adapter->pool.fsf_req_erp, erp_action); + if (!ret) + wait_for_completion(&compl_rec.done); + return ret; +} + +/** + * zfcp_fc_ns_gid_pn_request - initiate GID_PN nameserver request + * @erp_action: pointer to zfcp_erp_action where GID_PN request is needed + * return: -ENOMEM on error, 0 otherwise + */ +int zfcp_fc_ns_gid_pn(struct zfcp_erp_action *erp_action) +{ + int ret; + struct zfcp_gid_pn_data *gid_pn; + struct zfcp_adapter *adapter = erp_action->adapter; + + gid_pn = mempool_alloc(adapter->pool.data_gid_pn, GFP_ATOMIC); + if (!gid_pn) + return -ENOMEM; + + memset(gid_pn, 0, sizeof(*gid_pn)); + + ret = zfcp_wka_port_get(&adapter->nsp); if (ret) - mempool_free(gid_pn, adapter->pool.data_gid_pn); + goto out; + + ret = zfcp_fc_ns_gid_pn_request(erp_action, gid_pn); + + zfcp_wka_port_put(&adapter->nsp); +out: + mempool_free(gid_pn, adapter->pool.data_gid_pn); return ret; } @@ -339,30 +445,6 @@ void zfcp_test_link(struct zfcp_port *port) zfcp_erp_port_forced_reopen(port, 0, 65, NULL); } -static int zfcp_scan_get_nameserver(struct zfcp_adapter *adapter) -{ - int ret; - - if (!adapter->nameserver_port) - return -EINTR; - - if (!(atomic_read(&adapter->nameserver_port->status) & - ZFCP_STATUS_COMMON_UNBLOCKED)) { - ret = zfcp_erp_port_reopen(adapter->nameserver_port, 0, 148, - NULL); - if (ret) - return ret; - zfcp_erp_wait(adapter); - } - return !(atomic_read(&adapter->nameserver_port->status) & - ZFCP_STATUS_COMMON_UNBLOCKED); -} - -static void zfcp_gpn_ft_handler(unsigned long _done) -{ - complete((struct completion *)_done); -} - static void zfcp_free_sg_env(struct zfcp_gpn_ft *gpn_ft) { struct scatterlist *sg = &gpn_ft->sg_req; @@ -404,7 +486,7 @@ static int zfcp_scan_issue_gpn_ft(struct zfcp_gpn_ft *gpn_ft, { struct zfcp_send_ct *ct = &gpn_ft->ct; struct ct_iu_gpn_ft_req *req = sg_virt(&gpn_ft->sg_req); - struct completion done; + struct zfcp_fc_ns_handler_data compl_rec; int ret; /* prepare CT IU for GPN_FT */ @@ -421,19 +503,20 @@ static int zfcp_scan_issue_gpn_ft(struct zfcp_gpn_ft *gpn_ft, req->fc4_type = ZFCP_CT_SCSI_FCP; /* prepare zfcp_send_ct */ - ct->port = adapter->nameserver_port; - ct->handler = zfcp_gpn_ft_handler; - ct->handler_data = (unsigned long)&done; + ct->wka_port = &adapter->nsp; + ct->handler = zfcp_fc_ns_handler; + ct->handler_data = (unsigned long)&compl_rec; ct->timeout = 10; ct->req = &gpn_ft->sg_req; ct->resp = gpn_ft->sg_resp; ct->req_count = 1; ct->resp_count = ZFCP_GPN_FT_BUFFERS; - init_completion(&done); + init_completion(&compl_rec.done); + compl_rec.handler = NULL; ret = zfcp_fsf_send_ct(ct, NULL, NULL); if (!ret) - wait_for_completion(&done); + wait_for_completion(&compl_rec.done); return ret; } @@ -443,8 +526,6 @@ static void zfcp_validate_port(struct zfcp_port *port) atomic_clear_mask(ZFCP_STATUS_COMMON_NOESC, &port->status); - if (port == adapter->nameserver_port) - return; if ((port->supported_classes != 0) || (port->units != 0)) { zfcp_port_put(port); return; @@ -461,7 +542,7 @@ static int zfcp_scan_eval_gpn_ft(struct zfcp_gpn_ft *gpn_ft) struct scatterlist *sg = gpn_ft->sg_resp; struct ct_hdr *hdr = sg_virt(sg); struct gpn_ft_resp_acc *acc = sg_virt(sg); - struct zfcp_adapter *adapter = ct->port->adapter; + struct zfcp_adapter *adapter = ct->wka_port->adapter; struct zfcp_port *port, *tmp; u32 d_id; int ret = 0, x, last = 0; @@ -491,6 +572,9 @@ static int zfcp_scan_eval_gpn_ft(struct zfcp_gpn_ft *gpn_ft) d_id = acc->port_id[0] << 16 | acc->port_id[1] << 8 | acc->port_id[2]; + /* don't attach ports with a well known address */ + if ((d_id & ZFCP_DID_WKA) == ZFCP_DID_WKA) + continue; /* skip the adapter's port and known remote ports */ if (acc->wwpn == fc_host_port_name(adapter->scsi_host)) continue; @@ -529,13 +613,15 @@ int zfcp_scan_ports(struct zfcp_adapter *adapter) if (fc_host_port_type(adapter->scsi_host) != FC_PORTTYPE_NPORT) return 0; - ret = zfcp_scan_get_nameserver(adapter); + ret = zfcp_wka_port_get(&adapter->nsp); if (ret) return ret; gpn_ft = zfcp_alloc_sg_env(); - if (!gpn_ft) - return -ENOMEM; + if (!gpn_ft) { + ret = -ENOMEM; + goto out; + } for (i = 0; i < 3; i++) { ret = zfcp_scan_issue_gpn_ft(gpn_ft, adapter); @@ -548,7 +634,8 @@ int zfcp_scan_ports(struct zfcp_adapter *adapter) } } zfcp_free_sg_env(gpn_ft); - +out: + zfcp_wka_port_put(&adapter->nsp); return ret; } diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c index af75fd2ef1e2..23dd9088153f 100644 --- a/drivers/s390/scsi/zfcp_fsf.c +++ b/drivers/s390/scsi/zfcp_fsf.c @@ -961,7 +961,6 @@ static void zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *req) { struct zfcp_adapter *adapter = req->adapter; struct zfcp_send_ct *send_ct = req->data; - struct zfcp_port *port = send_ct->port; struct fsf_qtcb_header *header = &req->qtcb->header; send_ct->status = -EINVAL; @@ -980,17 +979,14 @@ static void zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *req) case FSF_ADAPTER_STATUS_AVAILABLE: switch (header->fsf_status_qual.word[0]){ case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: - zfcp_test_link(port); case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED: req->status |= ZFCP_STATUS_FSFREQ_ERROR; break; } break; case FSF_ACCESS_DENIED: - zfcp_fsf_access_denied_port(req, port); break; case FSF_PORT_BOXED: - zfcp_erp_port_boxed(port, 49, req); req->status |= ZFCP_STATUS_FSFREQ_ERROR | ZFCP_STATUS_FSFREQ_RETRY; break; @@ -1041,8 +1037,8 @@ static int zfcp_fsf_setup_sbals(struct zfcp_fsf_req *req, int zfcp_fsf_send_ct(struct zfcp_send_ct *ct, mempool_t *pool, struct zfcp_erp_action *erp_action) { - struct zfcp_port *port = ct->port; - struct zfcp_adapter *adapter = port->adapter; + struct zfcp_wka_port *wka_port = ct->wka_port; + struct zfcp_adapter *adapter = wka_port->adapter; struct zfcp_fsf_req *req; int ret = -EIO; @@ -1063,7 +1059,7 @@ int zfcp_fsf_send_ct(struct zfcp_send_ct *ct, mempool_t *pool, goto failed_send; req->handler = zfcp_fsf_send_ct_handler; - req->qtcb->header.port_handle = port->handle; + req->qtcb->header.port_handle = wka_port->handle; req->qtcb->bottom.support.service_class = FSF_CLASS_3; req->qtcb->bottom.support.timeout = ct->timeout; req->data = ct; @@ -1435,9 +1431,6 @@ static void zfcp_fsf_open_port_handler(struct zfcp_fsf_req *req) * another GID_PN straight after a port has been opened. * Alternately, an ADISC/PDISC ELS should suffice, as well. */ - if (atomic_read(&port->status) & ZFCP_STATUS_PORT_NO_WWPN) - break; - plogi = (struct fsf_plogi *) req->qtcb->bottom.support.els; if (req->qtcb->bottom.support.els1_length >= sizeof(*plogi)) { if (plogi->serv_param.wwpn != port->wwpn) @@ -1568,6 +1561,130 @@ out: return retval; } +static void zfcp_fsf_open_wka_port_handler(struct zfcp_fsf_req *req) +{ + struct zfcp_wka_port *wka_port = req->data; + struct fsf_qtcb_header *header = &req->qtcb->header; + + if (req->status & ZFCP_STATUS_FSFREQ_ERROR) { + wka_port->status = ZFCP_WKA_PORT_OFFLINE; + goto out; + } + + switch (header->fsf_status) { + case FSF_MAXIMUM_NUMBER_OF_PORTS_EXCEEDED: + dev_warn(&req->adapter->ccw_device->dev, + "Opening WKA port 0x%x failed\n", wka_port->d_id); + case FSF_ADAPTER_STATUS_AVAILABLE: + req->status |= ZFCP_STATUS_FSFREQ_ERROR; + case FSF_ACCESS_DENIED: + wka_port->status = ZFCP_WKA_PORT_OFFLINE; + break; + case FSF_PORT_ALREADY_OPEN: + case FSF_GOOD: + wka_port->handle = header->port_handle; + wka_port->status = ZFCP_WKA_PORT_ONLINE; + } +out: + wake_up(&wka_port->completion_wq); +} + +/** + * zfcp_fsf_open_wka_port - create and send open wka-port request + * @wka_port: pointer to struct zfcp_wka_port + * Returns: 0 on success, error otherwise + */ +int zfcp_fsf_open_wka_port(struct zfcp_wka_port *wka_port) +{ + struct qdio_buffer_element *sbale; + struct zfcp_adapter *adapter = wka_port->adapter; + struct zfcp_fsf_req *req; + int retval = -EIO; + + spin_lock_bh(&adapter->req_q.lock); + if (zfcp_fsf_req_sbal_get(adapter)) + goto out; + + req = zfcp_fsf_req_create(adapter, + FSF_QTCB_OPEN_PORT_WITH_DID, + ZFCP_REQ_AUTO_CLEANUP, + adapter->pool.fsf_req_erp); + if (unlikely(IS_ERR(req))) { + retval = PTR_ERR(req); + goto out; + } + + sbale = zfcp_qdio_sbale_req(req); + sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; + sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; + + req->handler = zfcp_fsf_open_wka_port_handler; + req->qtcb->bottom.support.d_id = wka_port->d_id; + req->data = wka_port; + + zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT); + retval = zfcp_fsf_req_send(req); + if (retval) + zfcp_fsf_req_free(req); +out: + spin_unlock_bh(&adapter->req_q.lock); + return retval; +} + +static void zfcp_fsf_close_wka_port_handler(struct zfcp_fsf_req *req) +{ + struct zfcp_wka_port *wka_port = req->data; + + if (req->qtcb->header.fsf_status == FSF_PORT_HANDLE_NOT_VALID) { + req->status |= ZFCP_STATUS_FSFREQ_ERROR; + zfcp_erp_adapter_reopen(wka_port->adapter, 0, 107, req); + } + + wka_port->status = ZFCP_WKA_PORT_OFFLINE; + wake_up(&wka_port->completion_wq); +} + +/** + * zfcp_fsf_close_wka_port - create and send close wka port request + * @erp_action: pointer to struct zfcp_erp_action + * Returns: 0 on success, error otherwise + */ +int zfcp_fsf_close_wka_port(struct zfcp_wka_port *wka_port) +{ + struct qdio_buffer_element *sbale; + struct zfcp_adapter *adapter = wka_port->adapter; + struct zfcp_fsf_req *req; + int retval = -EIO; + + spin_lock_bh(&adapter->req_q.lock); + if (zfcp_fsf_req_sbal_get(adapter)) + goto out; + + req = zfcp_fsf_req_create(adapter, FSF_QTCB_CLOSE_PORT, + ZFCP_REQ_AUTO_CLEANUP, + adapter->pool.fsf_req_erp); + if (unlikely(IS_ERR(req))) { + retval = PTR_ERR(req); + goto out; + } + + sbale = zfcp_qdio_sbale_req(req); + sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; + sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; + + req->handler = zfcp_fsf_close_wka_port_handler; + req->data = wka_port; + req->qtcb->header.port_handle = wka_port->handle; + + zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT); + retval = zfcp_fsf_req_send(req); + if (retval) + zfcp_fsf_req_free(req); +out: + spin_unlock_bh(&adapter->req_q.lock); + return retval; +} + static void zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req *req) { struct zfcp_port *port = req->data; diff --git a/drivers/s390/scsi/zfcp_sysfs.c b/drivers/s390/scsi/zfcp_sysfs.c index 7e857571fe44..430e486e9183 100644 --- a/drivers/s390/scsi/zfcp_sysfs.c +++ b/drivers/s390/scsi/zfcp_sysfs.c @@ -273,22 +273,7 @@ out: } static DEVICE_ATTR(unit_remove, S_IWUSR, NULL, zfcp_sysfs_unit_remove_store); -static struct attribute *zfcp_port_ns_attrs[] = { - &dev_attr_port_failed.attr, - &dev_attr_port_in_recovery.attr, - &dev_attr_port_status.attr, - &dev_attr_port_access_denied.attr, - NULL -}; - -/** - * zfcp_sysfs_ns_port_attrs - sysfs attributes for nameserver - */ -struct attribute_group zfcp_sysfs_ns_port_attrs = { - .attrs = zfcp_port_ns_attrs, -}; - -static struct attribute *zfcp_port_no_ns_attrs[] = { +static struct attribute *zfcp_port_attrs[] = { &dev_attr_unit_add.attr, &dev_attr_unit_remove.attr, &dev_attr_port_failed.attr, @@ -302,7 +287,7 @@ static struct attribute *zfcp_port_no_ns_attrs[] = { * zfcp_sysfs_port_attrs - sysfs attributes for all other ports */ struct attribute_group zfcp_sysfs_port_attrs = { - .attrs = zfcp_port_no_ns_attrs, + .attrs = zfcp_port_attrs, }; static struct attribute *zfcp_unit_attrs[] = { -- cgit v1.2.3 From 7ba58c9cc16d296290fe645acb11db2b01276544 Mon Sep 17 00:00:00 2001 From: Swen Schillig Date: Wed, 1 Oct 2008 12:42:18 +0200 Subject: [SCSI] zfcp: remove all typedefs and replace them with standards Remove typedefs from zfcp, use already existing types instead. Signed-off-by: Swen Schillig Signed-off-by: Christof Schmitt Signed-off-by: James Bottomley --- drivers/s390/scsi/zfcp_aux.c | 21 ++++++++++------- drivers/s390/scsi/zfcp_def.h | 39 ++++++++++++------------------- drivers/s390/scsi/zfcp_erp.c | 10 ++++---- drivers/s390/scsi/zfcp_ext.h | 11 ++++----- drivers/s390/scsi/zfcp_fc.c | 2 +- drivers/s390/scsi/zfcp_fsf.c | 53 ++++++++++++++++++++++++++++++------------ drivers/s390/scsi/zfcp_scsi.c | 14 ----------- drivers/s390/scsi/zfcp_sysfs.c | 22 ++++++++++-------- 8 files changed, 88 insertions(+), 84 deletions(-) (limited to 'drivers/s390/scsi/zfcp_sysfs.c') diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c index 181f88bb53b3..811ce8a28250 100644 --- a/drivers/s390/scsi/zfcp_aux.c +++ b/drivers/s390/scsi/zfcp_aux.c @@ -88,11 +88,13 @@ static int __init zfcp_device_setup(char *devstr) strncpy(zfcp_data.init_busid, token, BUS_ID_SIZE); token = strsep(&str, ","); - if (!token || strict_strtoull(token, 0, &zfcp_data.init_wwpn)) + if (!token || strict_strtoull(token, 0, + (unsigned long long *) &zfcp_data.init_wwpn)) goto err_out; token = strsep(&str, ","); - if (!token || strict_strtoull(token, 0, &zfcp_data.init_fcp_lun)) + if (!token || strict_strtoull(token, 0, + (unsigned long long *) &zfcp_data.init_fcp_lun)) goto err_out; kfree(str); @@ -231,8 +233,7 @@ module_init(zfcp_module_init); * * Returns: pointer to zfcp_unit or NULL */ -struct zfcp_unit *zfcp_get_unit_by_lun(struct zfcp_port *port, - fcp_lun_t fcp_lun) +struct zfcp_unit *zfcp_get_unit_by_lun(struct zfcp_port *port, u64 fcp_lun) { struct zfcp_unit *unit; @@ -251,7 +252,7 @@ struct zfcp_unit *zfcp_get_unit_by_lun(struct zfcp_port *port, * Returns: pointer to zfcp_port or NULL */ struct zfcp_port *zfcp_get_port_by_wwpn(struct zfcp_adapter *adapter, - wwn_t wwpn) + u64 wwpn) { struct zfcp_port *port; @@ -276,7 +277,7 @@ static void zfcp_sysfs_unit_release(struct device *dev) * * Sets up some unit internal structures and creates sysfs entry. */ -struct zfcp_unit *zfcp_unit_enqueue(struct zfcp_port *port, fcp_lun_t fcp_lun) +struct zfcp_unit *zfcp_unit_enqueue(struct zfcp_port *port, u64 fcp_lun) { struct zfcp_unit *unit; @@ -290,7 +291,8 @@ struct zfcp_unit *zfcp_unit_enqueue(struct zfcp_port *port, fcp_lun_t fcp_lun) unit->port = port; unit->fcp_lun = fcp_lun; - snprintf(unit->sysfs_device.bus_id, BUS_ID_SIZE, "0x%016llx", fcp_lun); + snprintf(unit->sysfs_device.bus_id, BUS_ID_SIZE, "0x%016llx", + (unsigned long long) fcp_lun); unit->sysfs_device.parent = &port->sysfs_device; unit->sysfs_device.release = zfcp_sysfs_unit_release; dev_set_drvdata(&unit->sysfs_device, unit); @@ -620,7 +622,7 @@ static void zfcp_sysfs_port_release(struct device *dev) * d_id is used to enqueue ports with a well known address like the Directory * Service for nameserver lookup. */ -struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, wwn_t wwpn, +struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, u64 wwpn, u32 status, u32 d_id) { struct zfcp_port *port; @@ -644,7 +646,8 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, wwn_t wwpn, atomic_set_mask(status | ZFCP_STATUS_COMMON_REMOVE, &port->status); atomic_set(&port->refcount, 0); - snprintf(port->sysfs_device.bus_id, BUS_ID_SIZE, "0x%016llx", wwpn); + snprintf(port->sysfs_device.bus_id, BUS_ID_SIZE, "0x%016llx", + (unsigned long long) wwpn); port->sysfs_device.parent = &adapter->ccw_device->dev; port->sysfs_device.release = zfcp_sysfs_port_release; diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h index 0d6a388882d4..cbbfd875d939 100644 --- a/drivers/s390/scsi/zfcp_def.h +++ b/drivers/s390/scsi/zfcp_def.h @@ -78,11 +78,6 @@ /*************** FIBRE CHANNEL PROTOCOL SPECIFIC DEFINES ********************/ -typedef unsigned long long wwn_t; -typedef unsigned long long fcp_lun_t; -/* data length field may be at variable position in FCP-2 FCP_CMND IU */ -typedef unsigned int fcp_dl_t; - /* timeout for name-server lookup (in seconds) */ #define ZFCP_NS_GID_PN_TIMEOUT 10 @@ -106,7 +101,7 @@ typedef unsigned int fcp_dl_t; /* FCP(-2) FCP_CMND IU */ struct fcp_cmnd_iu { - fcp_lun_t fcp_lun; /* FCP logical unit number */ + u64 fcp_lun; /* FCP logical unit number */ u8 crn; /* command reference number */ u8 reserved0:5; /* reserved */ u8 task_attribute:3; /* task attribute */ @@ -181,7 +176,7 @@ struct fcp_rscn_element { struct fcp_logo { u32 command; u32 nport_did; - wwn_t nport_wwpn; + u64 nport_wwpn; } __attribute__((packed)); /* @@ -330,7 +325,7 @@ struct ct_hdr { * a port name is required */ struct ct_iu_gid_pn_req { struct ct_hdr header; - wwn_t wwpn; + u64 wwpn; } __attribute__ ((packed)); /* FS_ACC IU and data unit for GID_PN nameserver request */ @@ -339,8 +334,6 @@ struct ct_iu_gid_pn_resp { u32 d_id; } __attribute__ ((packed)); -typedef void (*zfcp_send_ct_handler_t)(unsigned long); - /** * struct zfcp_send_ct - used to pass parameters to function zfcp_fsf_send_ct * @wka_port: port where the request is sent to @@ -360,7 +353,7 @@ struct zfcp_send_ct { struct scatterlist *resp; unsigned int req_count; unsigned int resp_count; - zfcp_send_ct_handler_t handler; + void (*handler)(unsigned long); unsigned long handler_data; int timeout; struct completion *completion; @@ -377,8 +370,6 @@ struct zfcp_gid_pn_data { struct zfcp_port *port; }; -typedef void (*zfcp_send_els_handler_t)(unsigned long); - /** * struct zfcp_send_els - used to pass parameters to function zfcp_fsf_send_els * @adapter: adapter where request is sent from @@ -402,7 +393,7 @@ struct zfcp_send_els { struct scatterlist *resp; unsigned int req_count; unsigned int resp_count; - zfcp_send_els_handler_t handler; + void (*handler)(unsigned long); unsigned long handler_data; struct completion *completion; int ls_code; @@ -468,8 +459,8 @@ struct zfcp_adapter { atomic_t refcount; /* reference count */ wait_queue_head_t remove_wq; /* can be used to wait for refcount drop to zero */ - wwn_t peer_wwnn; /* P2P peer WWNN */ - wwn_t peer_wwpn; /* P2P peer WWPN */ + u64 peer_wwnn; /* P2P peer WWNN */ + u64 peer_wwpn; /* P2P peer WWPN */ u32 peer_d_id; /* P2P peer D_ID */ struct ccw_device *ccw_device; /* S/390 ccw device */ u32 hydra_version; /* Hydra version */ @@ -546,8 +537,8 @@ struct zfcp_port { list */ u32 units; /* # of logical units in list */ atomic_t status; /* status of this remote port */ - wwn_t wwnn; /* WWNN if known */ - wwn_t wwpn; /* WWPN */ + u64 wwnn; /* WWNN if known */ + u64 wwpn; /* WWPN */ u32 d_id; /* D_ID */ u32 handle; /* handle assigned by FSF */ struct zfcp_erp_action erp_action; /* pending error recovery */ @@ -566,7 +557,7 @@ struct zfcp_unit { struct zfcp_port *port; /* remote port of unit */ atomic_t status; /* status of this logical unit */ unsigned int scsi_lun; /* own SCSI LUN */ - fcp_lun_t fcp_lun; /* own FCP_LUN */ + u64 fcp_lun; /* own FCP_LUN */ u32 handle; /* handle assigned by FSF */ struct scsi_device *device; /* scsi device struct pointer */ struct zfcp_erp_action erp_action; /* pending error recovery */ @@ -620,11 +611,11 @@ struct zfcp_data { changes */ atomic_t loglevel; /* current loglevel */ char init_busid[BUS_ID_SIZE]; - wwn_t init_wwpn; - fcp_lun_t init_fcp_lun; - struct kmem_cache *fsf_req_qtcb_cache; - struct kmem_cache *sr_buffer_cache; - struct kmem_cache *gid_pn_cache; + u64 init_wwpn; + u64 init_fcp_lun; + struct kmem_cache *fsf_req_qtcb_cache; + struct kmem_cache *sr_buffer_cache; + struct kmem_cache *gid_pn_cache; }; /* struct used by memory pools for fsf_requests */ diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c index e7d3bce51429..07d22f343cc5 100644 --- a/drivers/s390/scsi/zfcp_erp.c +++ b/drivers/s390/scsi/zfcp_erp.c @@ -991,7 +991,8 @@ static int zfcp_erp_strategy_check_unit(struct zfcp_unit *unit, int result) dev_err(&unit->port->adapter->ccw_device->dev, "ERP failed for unit 0x%016Lx on " "port 0x%016Lx\n", - unit->fcp_lun, unit->port->wwpn); + (unsigned long long)unit->fcp_lun, + (unsigned long long)unit->port->wwpn); zfcp_erp_unit_failed(unit, 21, NULL); } break; @@ -1021,7 +1022,7 @@ static int zfcp_erp_strategy_check_port(struct zfcp_port *port, int result) if (atomic_read(&port->erp_counter) > ZFCP_MAX_ERPS) { dev_err(&port->adapter->ccw_device->dev, "ERP failed for remote port 0x%016Lx\n", - port->wwpn); + (unsigned long long)port->wwpn); zfcp_erp_port_failed(port, 22, NULL); } break; @@ -1199,7 +1200,8 @@ static void zfcp_erp_schedule_work(struct zfcp_unit *unit) if (!p) { dev_err(&unit->port->adapter->ccw_device->dev, "Registering unit 0x%016Lx on port 0x%016Lx failed\n", - unit->fcp_lun, unit->port->wwpn); + (unsigned long long)unit->fcp_lun, + (unsigned long long)unit->port->wwpn); return; } @@ -1221,7 +1223,7 @@ static void zfcp_erp_rport_register(struct zfcp_port *port) if (!port->rport) { dev_err(&port->adapter->ccw_device->dev, "Registering port 0x%016Lx failed\n", - port->wwpn); + (unsigned long long)port->wwpn); return; } diff --git a/drivers/s390/scsi/zfcp_ext.h b/drivers/s390/scsi/zfcp_ext.h index 5c8a703b5ce1..ca1db974fc5c 100644 --- a/drivers/s390/scsi/zfcp_ext.h +++ b/drivers/s390/scsi/zfcp_ext.h @@ -12,16 +12,14 @@ #include "zfcp_def.h" /* zfcp_aux.c */ -extern struct zfcp_unit *zfcp_get_unit_by_lun(struct zfcp_port *, - fcp_lun_t); -extern struct zfcp_port *zfcp_get_port_by_wwpn(struct zfcp_adapter *, - wwn_t); +extern struct zfcp_unit *zfcp_get_unit_by_lun(struct zfcp_port *, u64); +extern struct zfcp_port *zfcp_get_port_by_wwpn(struct zfcp_adapter *, u64); extern int zfcp_adapter_enqueue(struct ccw_device *); extern void zfcp_adapter_dequeue(struct zfcp_adapter *); -extern struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *, wwn_t, u32, +extern struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *, u64, u32, u32); extern void zfcp_port_dequeue(struct zfcp_port *); -extern struct zfcp_unit *zfcp_unit_enqueue(struct zfcp_port *, fcp_lun_t); +extern struct zfcp_unit *zfcp_unit_enqueue(struct zfcp_port *, u64); extern void zfcp_unit_dequeue(struct zfcp_unit *); extern int zfcp_reqlist_isempty(struct zfcp_adapter *); extern void zfcp_sg_free_table(struct scatterlist *, int); @@ -150,7 +148,6 @@ extern void zfcp_qdio_close(struct zfcp_adapter *); extern struct zfcp_data zfcp_data; extern int zfcp_adapter_scsi_register(struct zfcp_adapter *); extern void zfcp_adapter_scsi_unregister(struct zfcp_adapter *); -extern void zfcp_set_fcp_dl(struct fcp_cmnd_iu *, fcp_dl_t); extern char *zfcp_get_fcp_sns_info_ptr(struct fcp_rsp_iu *); extern struct fc_function_template zfcp_transport_functions; diff --git a/drivers/s390/scsi/zfcp_fc.c b/drivers/s390/scsi/zfcp_fc.c index 899e45b9e60b..3a573b03eb86 100644 --- a/drivers/s390/scsi/zfcp_fc.c +++ b/drivers/s390/scsi/zfcp_fc.c @@ -178,7 +178,7 @@ static void zfcp_fc_incoming_rscn(struct zfcp_fsf_req *fsf_req) schedule_work(&fsf_req->adapter->scan_work); } -static void zfcp_fc_incoming_wwpn(struct zfcp_fsf_req *req, wwn_t wwpn) +static void zfcp_fc_incoming_wwpn(struct zfcp_fsf_req *req, u64 wwpn) { struct zfcp_adapter *adapter = req->adapter; struct zfcp_port *port; diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c index 23dd9088153f..02a570084d88 100644 --- a/drivers/s390/scsi/zfcp_fsf.c +++ b/drivers/s390/scsi/zfcp_fsf.c @@ -68,7 +68,7 @@ static void zfcp_fsf_access_denied_port(struct zfcp_fsf_req *req, struct fsf_qtcb_header *header = &req->qtcb->header; dev_warn(&req->adapter->ccw_device->dev, "Access denied to port 0x%016Lx\n", - port->wwpn); + (unsigned long long)port->wwpn); zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[0]); zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[1]); zfcp_erp_port_access_denied(port, 55, req); @@ -81,7 +81,8 @@ static void zfcp_fsf_access_denied_unit(struct zfcp_fsf_req *req, struct fsf_qtcb_header *header = &req->qtcb->header; dev_warn(&req->adapter->ccw_device->dev, "Access denied to unit 0x%016Lx on port 0x%016Lx\n", - unit->fcp_lun, unit->port->wwpn); + (unsigned long long)unit->fcp_lun, + (unsigned long long)unit->port->wwpn); zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[0]); zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[1]); zfcp_erp_unit_access_denied(unit, 59, req); @@ -1390,7 +1391,8 @@ static void zfcp_fsf_open_port_handler(struct zfcp_fsf_req *req) case FSF_MAXIMUM_NUMBER_OF_PORTS_EXCEEDED: dev_warn(&req->adapter->ccw_device->dev, "Not enough FCP adapter resources to open " - "remote port 0x%016Lx\n", port->wwpn); + "remote port 0x%016Lx\n", + (unsigned long long)port->wwpn); zfcp_erp_port_failed(port, 31, req); req->status |= ZFCP_STATUS_FSFREQ_ERROR; break; @@ -1403,7 +1405,7 @@ static void zfcp_fsf_open_port_handler(struct zfcp_fsf_req *req) case FSF_SQ_NO_RETRY_POSSIBLE: dev_warn(&req->adapter->ccw_device->dev, "Remote port 0x%016Lx could not be opened\n", - port->wwpn); + (unsigned long long)port->wwpn); zfcp_erp_port_failed(port, 32, req); req->status |= ZFCP_STATUS_FSFREQ_ERROR; break; @@ -1824,8 +1826,8 @@ static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req) dev_warn(&adapter->ccw_device->dev, "LUN 0x%Lx on port 0x%Lx is already in " "use by CSS%d, MIF Image ID %x\n", - unit->fcp_lun, - unit->port->wwpn, + (unsigned long long)unit->fcp_lun, + (unsigned long long)unit->port->wwpn, queue_designator->cssid, queue_designator->hla); else @@ -1840,7 +1842,8 @@ static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req) dev_warn(&adapter->ccw_device->dev, "No handle is available for LUN " "0x%016Lx on port 0x%016Lx\n", - unit->fcp_lun, unit->port->wwpn); + (unsigned long long)unit->fcp_lun, + (unsigned long long)unit->port->wwpn); zfcp_erp_unit_failed(unit, 34, req); /* fall through */ case FSF_INVALID_COMMAND_OPTION: @@ -1879,7 +1882,8 @@ static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req) dev_info(&adapter->ccw_device->dev, "SCSI device at LUN 0x%016Lx on port " "0x%016Lx opened read-only\n", - unit->fcp_lun, unit->port->wwpn); + (unsigned long long)unit->fcp_lun, + (unsigned long long)unit->port->wwpn); } if (exclusive && !readwrite) { @@ -1887,7 +1891,8 @@ static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req) "Exclusive read-only access not " "supported (unit 0x%016Lx, " "port 0x%016Lx)\n", - unit->fcp_lun, unit->port->wwpn); + (unsigned long long)unit->fcp_lun, + (unsigned long long)unit->port->wwpn); zfcp_erp_unit_failed(unit, 35, req); req->status |= ZFCP_STATUS_FSFREQ_ERROR; zfcp_erp_unit_shutdown(unit, 0, 80, req); @@ -1896,7 +1901,8 @@ static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req) "Shared read-write access not " "supported (unit 0x%016Lx, port " "0x%016Lx\n)", - unit->fcp_lun, unit->port->wwpn); + (unsigned long long)unit->fcp_lun, + (unsigned long long)unit->port->wwpn); zfcp_erp_unit_failed(unit, 36, req); req->status |= ZFCP_STATUS_FSFREQ_ERROR; zfcp_erp_unit_shutdown(unit, 0, 81, req); @@ -2197,7 +2203,8 @@ static void zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *req) "Incorrect direction %d, unit 0x%016Lx on port " "0x%016Lx closed\n", req->qtcb->bottom.io.data_direction, - unit->fcp_lun, unit->port->wwpn); + (unsigned long long)unit->fcp_lun, + (unsigned long long)unit->port->wwpn); zfcp_erp_adapter_shutdown(unit->port->adapter, 0, 133, req); req->status |= ZFCP_STATUS_FSFREQ_ERROR; break; @@ -2206,7 +2213,8 @@ static void zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *req) "Incorrect CDB length %d, unit 0x%016Lx on " "port 0x%016Lx closed\n", req->qtcb->bottom.io.fcp_cmnd_length, - unit->fcp_lun, unit->port->wwpn); + (unsigned long long)unit->fcp_lun, + (unsigned long long)unit->port->wwpn); zfcp_erp_adapter_shutdown(unit->port->adapter, 0, 134, req); req->status |= ZFCP_STATUS_FSFREQ_ERROR; break; @@ -2237,6 +2245,20 @@ skip_fsfstatus: } } +static void zfcp_set_fcp_dl(struct fcp_cmnd_iu *fcp_cmd, u32 fcp_dl) +{ + u32 *fcp_dl_ptr; + + /* + * fcp_dl_addr = start address of fcp_cmnd structure + + * size of fixed part + size of dynamically sized add_dcp_cdb field + * SEE FCP-2 documentation + */ + fcp_dl_ptr = (u32 *) ((unsigned char *) &fcp_cmd[1] + + (fcp_cmd->add_fcp_cdb_length << 2)); + *fcp_dl_ptr = fcp_dl; +} + /** * zfcp_fsf_send_fcp_command_task - initiate an FCP command (for a SCSI command) * @adapter: adapter where scsi command is issued @@ -2322,7 +2344,7 @@ int zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *adapter, memcpy(fcp_cmnd_iu->fcp_cdb, scsi_cmnd->cmnd, scsi_cmnd->cmd_len); req->qtcb->bottom.io.fcp_cmnd_length = sizeof(struct fcp_cmnd_iu) + - fcp_cmnd_iu->add_fcp_cdb_length + sizeof(fcp_dl_t); + fcp_cmnd_iu->add_fcp_cdb_length + sizeof(u32); real_bytes = zfcp_qdio_sbals_from_sg(req, sbtype, scsi_sglist(scsi_cmnd), @@ -2334,7 +2356,8 @@ int zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *adapter, dev_err(&adapter->ccw_device->dev, "Oversize data package, unit 0x%016Lx " "on port 0x%016Lx closed\n", - unit->fcp_lun, unit->port->wwpn); + (unsigned long long)unit->fcp_lun, + (unsigned long long)unit->port->wwpn); zfcp_erp_unit_shutdown(unit, 0, 131, req); retval = -EINVAL; } @@ -2397,7 +2420,7 @@ struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_adapter *adapter, req->qtcb->bottom.io.data_direction = FSF_DATADIR_CMND; req->qtcb->bottom.io.service_class = FSF_CLASS_3; req->qtcb->bottom.io.fcp_cmnd_length = sizeof(struct fcp_cmnd_iu) + - sizeof(fcp_dl_t); + sizeof(u32); sbale = zfcp_qdio_sbale_req(req); sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE; diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c index 2095a1e41e80..cf6a14793371 100644 --- a/drivers/s390/scsi/zfcp_scsi.c +++ b/drivers/s390/scsi/zfcp_scsi.c @@ -21,20 +21,6 @@ char *zfcp_get_fcp_sns_info_ptr(struct fcp_rsp_iu *fcp_rsp_iu) return fcp_sns_info_ptr; } -void zfcp_set_fcp_dl(struct fcp_cmnd_iu *fcp_cmd, fcp_dl_t fcp_dl) -{ - fcp_dl_t *fcp_dl_ptr; - - /* - * fcp_dl_addr = start address of fcp_cmnd structure + - * size of fixed part + size of dynamically sized add_dcp_cdb field - * SEE FCP-2 documentation - */ - fcp_dl_ptr = (fcp_dl_t *) ((unsigned char *) &fcp_cmd[1] + - (fcp_cmd->add_fcp_cdb_length << 2)); - *fcp_dl_ptr = fcp_dl; -} - static void zfcp_scsi_slave_destroy(struct scsi_device *sdpnt) { struct zfcp_unit *unit = (struct zfcp_unit *) sdpnt->hostdata; diff --git a/drivers/s390/scsi/zfcp_sysfs.c b/drivers/s390/scsi/zfcp_sysfs.c index 430e486e9183..7f7384c02a53 100644 --- a/drivers/s390/scsi/zfcp_sysfs.c +++ b/drivers/s390/scsi/zfcp_sysfs.c @@ -26,9 +26,9 @@ static ZFCP_DEV_ATTR(_feat, _name, S_IRUGO, \ ZFCP_DEFINE_ATTR(zfcp_adapter, adapter, status, "0x%08x\n", atomic_read(&adapter->status)); ZFCP_DEFINE_ATTR(zfcp_adapter, adapter, peer_wwnn, "0x%016llx\n", - adapter->peer_wwnn); + (unsigned long long) adapter->peer_wwnn); ZFCP_DEFINE_ATTR(zfcp_adapter, adapter, peer_wwpn, "0x%016llx\n", - adapter->peer_wwpn); + (unsigned long long) adapter->peer_wwpn); ZFCP_DEFINE_ATTR(zfcp_adapter, adapter, peer_d_id, "0x%06x\n", adapter->peer_d_id); ZFCP_DEFINE_ATTR(zfcp_adapter, adapter, card_version, "0x%04x\n", @@ -135,7 +135,7 @@ static ssize_t zfcp_sysfs_port_remove_store(struct device *dev, { struct zfcp_adapter *adapter = dev_get_drvdata(dev); struct zfcp_port *port; - wwn_t wwpn; + u64 wwpn; int retval = 0; down(&zfcp_data.config_sema); @@ -144,7 +144,7 @@ static ssize_t zfcp_sysfs_port_remove_store(struct device *dev, goto out; } - if (strict_strtoull(buf, 0, &wwpn)) { + if (strict_strtoull(buf, 0, (unsigned long long *) &wwpn)) { retval = -EINVAL; goto out; } @@ -200,7 +200,7 @@ static ssize_t zfcp_sysfs_unit_add_store(struct device *dev, { struct zfcp_port *port = dev_get_drvdata(dev); struct zfcp_unit *unit; - fcp_lun_t fcp_lun; + u64 fcp_lun; int retval = -EINVAL; down(&zfcp_data.config_sema); @@ -209,7 +209,7 @@ static ssize_t zfcp_sysfs_unit_add_store(struct device *dev, goto out; } - if (strict_strtoull(buf, 0, &fcp_lun)) + if (strict_strtoull(buf, 0, (unsigned long long *) &fcp_lun)) goto out; unit = zfcp_unit_enqueue(port, fcp_lun); @@ -233,7 +233,7 @@ static ssize_t zfcp_sysfs_unit_remove_store(struct device *dev, { struct zfcp_port *port = dev_get_drvdata(dev); struct zfcp_unit *unit; - fcp_lun_t fcp_lun; + u64 fcp_lun; int retval = 0; down(&zfcp_data.config_sema); @@ -242,7 +242,7 @@ static ssize_t zfcp_sysfs_unit_remove_store(struct device *dev, goto out; } - if (strict_strtoull(buf, 0, &fcp_lun)) { + if (strict_strtoull(buf, 0, (unsigned long long *) &fcp_lun)) { retval = -EINVAL; goto out; } @@ -380,8 +380,10 @@ static DEVICE_ATTR(_name, S_IRUGO, zfcp_sysfs_scsi_##_name##_show, NULL); ZFCP_DEFINE_SCSI_ATTR(hba_id, "%s\n", unit->port->adapter->ccw_device->dev.bus_id); -ZFCP_DEFINE_SCSI_ATTR(wwpn, "0x%016llx\n", unit->port->wwpn); -ZFCP_DEFINE_SCSI_ATTR(fcp_lun, "0x%016llx\n", unit->fcp_lun); +ZFCP_DEFINE_SCSI_ATTR(wwpn, "0x%016llx\n", + (unsigned long long) unit->port->wwpn); +ZFCP_DEFINE_SCSI_ATTR(fcp_lun, "0x%016llx\n", + (unsigned long long) unit->fcp_lun); struct device_attribute *zfcp_sysfs_sdev_attrs[] = { &dev_attr_fcp_lun, -- cgit v1.2.3 From 0406289ed57955860a4f8d744a14f4c819260ce4 Mon Sep 17 00:00:00 2001 From: Christof Schmitt Date: Wed, 1 Oct 2008 12:42:20 +0200 Subject: [SCSI] zfcp: Simplify zfcp data structures Reduce the size of zfcp data structures by removing unused and redundant members. scsi_lun is only the mangled version of the fcp_lun. So, remove the redundant field and use the fcp_lun instead. Since the queue lock and the pci_batch indicator are only used in the request queue, move them from the common queue struct to the adapter struct. Signed-off-by: Christof Schmitt Signed-off-by: Swen Schillig Signed-off-by: James Bottomley --- drivers/s390/scsi/zfcp_aux.c | 34 +--------------- drivers/s390/scsi/zfcp_ccw.c | 10 +++-- drivers/s390/scsi/zfcp_def.h | 26 +++--------- drivers/s390/scsi/zfcp_erp.c | 2 +- drivers/s390/scsi/zfcp_fc.c | 3 +- drivers/s390/scsi/zfcp_fsf.c | 89 +++++++++++++++++++++--------------------- drivers/s390/scsi/zfcp_qdio.c | 12 +++--- drivers/s390/scsi/zfcp_scsi.c | 8 +++- drivers/s390/scsi/zfcp_sysfs.c | 6 ++- 9 files changed, 77 insertions(+), 113 deletions(-) (limited to 'drivers/s390/scsi/zfcp_sysfs.c') diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c index 6397de01b85e..b9984648aca6 100644 --- a/drivers/s390/scsi/zfcp_aux.c +++ b/drivers/s390/scsi/zfcp_aux.c @@ -169,8 +169,6 @@ static int __init zfcp_module_init(void) goto out_gid_cache; INIT_LIST_HEAD(&zfcp_data.adapter_list_head); - INIT_LIST_HEAD(&zfcp_data.adapter_remove_lh); - sema_init(&zfcp_data.config_sema, 1); rwlock_init(&zfcp_data.config_lock); @@ -312,7 +310,6 @@ struct zfcp_unit *zfcp_unit_enqueue(struct zfcp_port *port, u64 fcp_lun) } zfcp_unit_get(unit); - unit->scsi_lun = scsilun_to_int((struct scsi_lun *)&unit->fcp_lun); write_lock_irq(&zfcp_data.config_lock); list_add_tail(&unit->list, &port->unit_list_head); @@ -321,7 +318,6 @@ struct zfcp_unit *zfcp_unit_enqueue(struct zfcp_port *port, u64 fcp_lun) write_unlock_irq(&zfcp_data.config_lock); - port->units++; zfcp_port_get(port); return unit; @@ -344,7 +340,6 @@ void zfcp_unit_dequeue(struct zfcp_unit *unit) write_lock_irq(&zfcp_data.config_lock); list_del(&unit->list); write_unlock_irq(&zfcp_data.config_lock); - unit->port->units--; zfcp_port_put(unit->port); sysfs_remove_group(&unit->sysfs_device.kobj, &zfcp_sysfs_unit_attrs); device_unregister(&unit->sysfs_device); @@ -405,11 +400,6 @@ static void zfcp_free_low_mem_buffers(struct zfcp_adapter *adapter) mempool_destroy(adapter->pool.data_gid_pn); } -static void zfcp_dummy_release(struct device *dev) -{ - return; -} - /** * zfcp_status_read_refill - refill the long running status_read_requests * @adapter: ptr to struct zfcp_adapter for which the buffers should be refilled @@ -484,7 +474,6 @@ int zfcp_adapter_enqueue(struct ccw_device *ccw_device) init_waitqueue_head(&adapter->erp_done_wqh); INIT_LIST_HEAD(&adapter->port_list_head); - INIT_LIST_HEAD(&adapter->port_remove_lh); INIT_LIST_HEAD(&adapter->erp_ready_head); INIT_LIST_HEAD(&adapter->erp_running_head); @@ -494,7 +483,7 @@ int zfcp_adapter_enqueue(struct ccw_device *ccw_device) spin_lock_init(&adapter->san_dbf_lock); spin_lock_init(&adapter->scsi_dbf_lock); spin_lock_init(&adapter->rec_dbf_lock); - spin_lock_init(&adapter->req_q.lock); + spin_lock_init(&adapter->req_q_lock); rwlock_init(&adapter->erp_lock); rwlock_init(&adapter->abort_lock); @@ -513,28 +502,15 @@ int zfcp_adapter_enqueue(struct ccw_device *ccw_device) &zfcp_sysfs_adapter_attrs)) goto sysfs_failed; - adapter->generic_services.parent = &adapter->ccw_device->dev; - adapter->generic_services.release = zfcp_dummy_release; - snprintf(adapter->generic_services.bus_id, BUS_ID_SIZE, - "generic_services"); - - if (device_register(&adapter->generic_services)) - goto generic_services_failed; - write_lock_irq(&zfcp_data.config_lock); atomic_clear_mask(ZFCP_STATUS_COMMON_REMOVE, &adapter->status); list_add_tail(&adapter->list, &zfcp_data.adapter_list_head); write_unlock_irq(&zfcp_data.config_lock); - zfcp_data.adapters++; - zfcp_fc_nameserver_init(adapter); return 0; -generic_services_failed: - sysfs_remove_group(&ccw_device->dev.kobj, - &zfcp_sysfs_adapter_attrs); sysfs_failed: zfcp_adapter_debug_unregister(adapter); debug_register_failed: @@ -561,7 +537,6 @@ void zfcp_adapter_dequeue(struct zfcp_adapter *adapter) cancel_work_sync(&adapter->scan_work); cancel_work_sync(&adapter->stat_work); zfcp_adapter_scsi_unregister(adapter); - device_unregister(&adapter->generic_services); sysfs_remove_group(&adapter->ccw_device->dev.kobj, &zfcp_sysfs_adapter_attrs); dev_set_drvdata(&adapter->ccw_device->dev, NULL); @@ -579,9 +554,6 @@ void zfcp_adapter_dequeue(struct zfcp_adapter *adapter) list_del(&adapter->list); write_unlock_irq(&zfcp_data.config_lock); - /* decrease number of adapters in list */ - zfcp_data.adapters--; - zfcp_qdio_free(adapter); zfcp_free_low_mem_buffers(adapter); @@ -620,9 +592,7 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, u64 wwpn, return ERR_PTR(-ENOMEM); init_waitqueue_head(&port->remove_wq); - INIT_LIST_HEAD(&port->unit_list_head); - INIT_LIST_HEAD(&port->unit_remove_lh); INIT_WORK(&port->gid_pn_work, zfcp_erp_port_strategy_open_lookup); port->adapter = adapter; @@ -665,7 +635,6 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, u64 wwpn, list_add_tail(&port->list, &adapter->port_list_head); atomic_clear_mask(ZFCP_STATUS_COMMON_REMOVE, &port->status); atomic_set_mask(ZFCP_STATUS_COMMON_RUNNING, &port->status); - adapter->ports++; write_unlock_irq(&zfcp_data.config_lock); @@ -687,7 +656,6 @@ void zfcp_port_dequeue(struct zfcp_port *port) wait_event(port->remove_wq, atomic_read(&port->refcount) == 0); write_lock_irq(&zfcp_data.config_lock); list_del(&port->list); - port->adapter->ports--; write_unlock_irq(&zfcp_data.config_lock); if (port->rport) fc_remote_port_delete(port->rport); diff --git a/drivers/s390/scsi/zfcp_ccw.c b/drivers/s390/scsi/zfcp_ccw.c index 3a9bd5451a49..b04038c74786 100644 --- a/drivers/s390/scsi/zfcp_ccw.c +++ b/drivers/s390/scsi/zfcp_ccw.c @@ -47,6 +47,8 @@ static void zfcp_ccw_remove(struct ccw_device *ccw_device) struct zfcp_adapter *adapter; struct zfcp_port *port, *p; struct zfcp_unit *unit, *u; + LIST_HEAD(unit_remove_lh); + LIST_HEAD(port_remove_lh); ccw_device_set_offline(ccw_device); down(&zfcp_data.config_sema); @@ -55,18 +57,18 @@ static void zfcp_ccw_remove(struct ccw_device *ccw_device) write_lock_irq(&zfcp_data.config_lock); list_for_each_entry_safe(port, p, &adapter->port_list_head, list) { list_for_each_entry_safe(unit, u, &port->unit_list_head, list) { - list_move(&unit->list, &port->unit_remove_lh); + list_move(&unit->list, &unit_remove_lh); atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &unit->status); } - list_move(&port->list, &adapter->port_remove_lh); + list_move(&port->list, &port_remove_lh); atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &port->status); } atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &adapter->status); write_unlock_irq(&zfcp_data.config_lock); - list_for_each_entry_safe(port, p, &adapter->port_remove_lh, list) { - list_for_each_entry_safe(unit, u, &port->unit_remove_lh, list) { + list_for_each_entry_safe(port, p, &port_remove_lh, list) { + list_for_each_entry_safe(unit, u, &unit_remove_lh, list) { if (atomic_read(&unit->status) & ZFCP_STATUS_UNIT_REGISTERED) scsi_remove_device(unit->device); diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h index cbbfd875d939..7fa8937c8c58 100644 --- a/drivers/s390/scsi/zfcp_def.h +++ b/drivers/s390/scsi/zfcp_def.h @@ -412,14 +412,9 @@ struct zfcp_wka_port { }; struct zfcp_qdio_queue { - struct qdio_buffer *sbal[QDIO_MAX_BUFFERS_PER_Q]; /* SBALs */ - u8 first; /* index of next free bfr - in queue (free_count>0) */ - atomic_t count; /* number of free buffers - in queue */ - spinlock_t lock; /* lock for operations on queue */ - int pci_batch; /* SBALs since PCI indication - was last set */ + struct qdio_buffer *sbal[QDIO_MAX_BUFFERS_PER_Q]; + u8 first; /* index of next free bfr in queue */ + atomic_t count; /* number of free buffers in queue */ }; struct zfcp_erp_action { @@ -471,13 +466,13 @@ struct zfcp_adapter { u16 timer_ticks; /* time int for a tick */ struct Scsi_Host *scsi_host; /* Pointer to mid-layer */ struct list_head port_list_head; /* remote port list */ - struct list_head port_remove_lh; /* head of ports to be - removed */ - u32 ports; /* number of remote ports */ unsigned long req_no; /* unique FSF req number */ struct list_head *req_list; /* list of pending reqs */ spinlock_t req_list_lock; /* request list lock */ struct zfcp_qdio_queue req_q; /* request queue */ + spinlock_t req_q_lock; /* for operations on queue */ + int req_q_pci_batch; /* SBALs since PCI indication + was last set */ u32 fsf_req_seq_no; /* FSF cmnd seq number */ wait_queue_head_t request_wq; /* can be used to wait for more avaliable SBALs */ @@ -516,7 +511,6 @@ struct zfcp_adapter { struct zfcp_scsi_dbf_record scsi_dbf_buf; struct zfcp_adapter_mempool pool; /* Adapter memory pools */ struct qdio_initialize qdio_init_data; /* for qdio_establish */ - struct device generic_services; /* directory for WKA ports */ struct fc_host_statistics *fc_stats; struct fsf_qtcb_bottom_port *stats_reset_data; unsigned long stats_reset; @@ -533,9 +527,6 @@ struct zfcp_port { refcount drop to zero */ struct zfcp_adapter *adapter; /* adapter used to access port */ struct list_head unit_list_head; /* head of logical unit list */ - struct list_head unit_remove_lh; /* head of luns to be removed - list */ - u32 units; /* # of logical units in list */ atomic_t status; /* status of this remote port */ u64 wwnn; /* WWNN if known */ u64 wwpn; /* WWPN */ @@ -556,7 +547,6 @@ struct zfcp_unit { refcount drop to zero */ struct zfcp_port *port; /* remote port of unit */ atomic_t status; /* status of this logical unit */ - unsigned int scsi_lun; /* own SCSI LUN */ u64 fcp_lun; /* own FCP_LUN */ u32 handle; /* handle assigned by FSF */ struct scsi_device *device; /* scsi device struct pointer */ @@ -599,11 +589,7 @@ struct zfcp_fsf_req { struct zfcp_data { struct scsi_host_template scsi_host_template; struct scsi_transport_template *scsi_transport_template; - atomic_t status; /* Module status flags */ struct list_head adapter_list_head; /* head of adapter list */ - struct list_head adapter_remove_lh; /* head of adapters to be - removed */ - u32 adapters; /* # of adapters in list */ rwlock_t config_lock; /* serialises changes to adapter/port/unit lists */ diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c index 07d22f343cc5..174b38fe7623 100644 --- a/drivers/s390/scsi/zfcp_erp.c +++ b/drivers/s390/scsi/zfcp_erp.c @@ -1186,7 +1186,7 @@ static void zfcp_erp_scsi_scan(struct work_struct *work) struct zfcp_unit *unit = p->unit; struct fc_rport *rport = unit->port->rport; scsi_scan_target(&rport->dev, 0, rport->scsi_target_id, - unit->scsi_lun, 0); + scsilun_to_int((struct scsi_lun *)&unit->fcp_lun), 0); atomic_clear_mask(ZFCP_STATUS_UNIT_SCSI_WORK_PENDING, &unit->status); zfcp_unit_put(unit); kfree(p); diff --git a/drivers/s390/scsi/zfcp_fc.c b/drivers/s390/scsi/zfcp_fc.c index 3a573b03eb86..1a7c80a77ff5 100644 --- a/drivers/s390/scsi/zfcp_fc.c +++ b/drivers/s390/scsi/zfcp_fc.c @@ -526,7 +526,8 @@ static void zfcp_validate_port(struct zfcp_port *port) atomic_clear_mask(ZFCP_STATUS_COMMON_NOESC, &port->status); - if ((port->supported_classes != 0) || (port->units != 0)) { + if ((port->supported_classes != 0) || + !list_empty(&port->unit_list_head)) { zfcp_port_put(port); return; } diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c index 02a570084d88..c10b88d235d2 100644 --- a/drivers/s390/scsi/zfcp_fsf.c +++ b/drivers/s390/scsi/zfcp_fsf.c @@ -639,12 +639,14 @@ static void zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req *req) } } -static int zfcp_fsf_sbal_check(struct zfcp_qdio_queue *queue) +static int zfcp_fsf_sbal_check(struct zfcp_adapter *adapter) { - spin_lock_bh(&queue->lock); - if (atomic_read(&queue->count)) + struct zfcp_qdio_queue *req_q = &adapter->req_q; + + spin_lock_bh(&adapter->req_q_lock); + if (atomic_read(&req_q->count)) return 1; - spin_unlock_bh(&queue->lock); + spin_unlock_bh(&adapter->req_q_lock); return 0; } @@ -659,17 +661,16 @@ static int zfcp_fsf_sbal_available(struct zfcp_adapter *adapter) static int zfcp_fsf_req_sbal_get(struct zfcp_adapter *adapter) { long ret; - struct zfcp_qdio_queue *req_q = &adapter->req_q; - spin_unlock_bh(&req_q->lock); + spin_unlock_bh(&adapter->req_q_lock); ret = wait_event_interruptible_timeout(adapter->request_wq, - zfcp_fsf_sbal_check(req_q), 5 * HZ); + zfcp_fsf_sbal_check(adapter), 5 * HZ); if (ret > 0) return 0; if (!ret) atomic_inc(&adapter->qdio_outb_full); - spin_lock_bh(&req_q->lock); + spin_lock_bh(&adapter->req_q_lock); return -EIO; } @@ -811,7 +812,7 @@ int zfcp_fsf_status_read(struct zfcp_adapter *adapter) struct qdio_buffer_element *sbale; int retval = -EIO; - spin_lock_bh(&adapter->req_q.lock); + spin_lock_bh(&adapter->req_q_lock); if (zfcp_fsf_req_sbal_get(adapter)) goto out; @@ -851,7 +852,7 @@ failed_buf: zfcp_fsf_req_free(req); zfcp_hba_dbf_event_fsf_unsol("fail", adapter, NULL); out: - spin_unlock_bh(&adapter->req_q.lock); + spin_unlock_bh(&adapter->req_q_lock); return retval; } @@ -924,7 +925,7 @@ struct zfcp_fsf_req *zfcp_fsf_abort_fcp_command(unsigned long old_req_id, struct qdio_buffer_element *sbale; struct zfcp_fsf_req *req = NULL; - spin_lock(&adapter->req_q.lock); + spin_lock(&adapter->req_q_lock); if (!zfcp_fsf_sbal_available(adapter)) goto out; req = zfcp_fsf_req_create(adapter, FSF_QTCB_ABORT_FCP_CMND, @@ -954,7 +955,7 @@ out_error_free: zfcp_fsf_req_free(req); req = NULL; out: - spin_unlock(&adapter->req_q.lock); + spin_unlock(&adapter->req_q_lock); return req; } @@ -1043,7 +1044,7 @@ int zfcp_fsf_send_ct(struct zfcp_send_ct *ct, mempool_t *pool, struct zfcp_fsf_req *req; int ret = -EIO; - spin_lock_bh(&adapter->req_q.lock); + spin_lock_bh(&adapter->req_q_lock); if (zfcp_fsf_req_sbal_get(adapter)) goto out; @@ -1085,7 +1086,7 @@ failed_send: if (erp_action) erp_action->fsf_req = NULL; out: - spin_unlock_bh(&adapter->req_q.lock); + spin_unlock_bh(&adapter->req_q_lock); return ret; } @@ -1155,7 +1156,7 @@ int zfcp_fsf_send_els(struct zfcp_send_els *els) ZFCP_STATUS_COMMON_UNBLOCKED))) return -EBUSY; - spin_lock(&adapter->req_q.lock); + spin_lock(&adapter->req_q_lock); if (!zfcp_fsf_sbal_available(adapter)) goto out; req = zfcp_fsf_req_create(adapter, FSF_QTCB_SEND_ELS, @@ -1189,7 +1190,7 @@ int zfcp_fsf_send_els(struct zfcp_send_els *els) failed_send: zfcp_fsf_req_free(req); out: - spin_unlock(&adapter->req_q.lock); + spin_unlock(&adapter->req_q_lock); return ret; } @@ -1200,7 +1201,7 @@ int zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action) struct zfcp_adapter *adapter = erp_action->adapter; int retval = -EIO; - spin_lock_bh(&adapter->req_q.lock); + spin_lock_bh(&adapter->req_q_lock); if (!zfcp_fsf_sbal_available(adapter)) goto out; req = zfcp_fsf_req_create(adapter, @@ -1232,7 +1233,7 @@ int zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action) erp_action->fsf_req = NULL; } out: - spin_unlock_bh(&adapter->req_q.lock); + spin_unlock_bh(&adapter->req_q_lock); return retval; } @@ -1243,7 +1244,7 @@ int zfcp_fsf_exchange_config_data_sync(struct zfcp_adapter *adapter, struct zfcp_fsf_req *req = NULL; int retval = -EIO; - spin_lock_bh(&adapter->req_q.lock); + spin_lock_bh(&adapter->req_q_lock); if (zfcp_fsf_req_sbal_get(adapter)) goto out; @@ -1271,7 +1272,7 @@ int zfcp_fsf_exchange_config_data_sync(struct zfcp_adapter *adapter, zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT); retval = zfcp_fsf_req_send(req); out: - spin_unlock_bh(&adapter->req_q.lock); + spin_unlock_bh(&adapter->req_q_lock); if (!retval) wait_event(req->completion_wq, req->status & ZFCP_STATUS_FSFREQ_COMPLETED); @@ -1296,7 +1297,7 @@ int zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action) if (!(adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT)) return -EOPNOTSUPP; - spin_lock_bh(&adapter->req_q.lock); + spin_lock_bh(&adapter->req_q_lock); if (!zfcp_fsf_sbal_available(adapter)) goto out; req = zfcp_fsf_req_create(adapter, FSF_QTCB_EXCHANGE_PORT_DATA, @@ -1322,7 +1323,7 @@ int zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action) erp_action->fsf_req = NULL; } out: - spin_unlock_bh(&adapter->req_q.lock); + spin_unlock_bh(&adapter->req_q_lock); return retval; } @@ -1342,7 +1343,7 @@ int zfcp_fsf_exchange_port_data_sync(struct zfcp_adapter *adapter, if (!(adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT)) return -EOPNOTSUPP; - spin_lock_bh(&adapter->req_q.lock); + spin_lock_bh(&adapter->req_q_lock); if (!zfcp_fsf_sbal_available(adapter)) goto out; @@ -1364,7 +1365,7 @@ int zfcp_fsf_exchange_port_data_sync(struct zfcp_adapter *adapter, zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT); retval = zfcp_fsf_req_send(req); out: - spin_unlock_bh(&adapter->req_q.lock); + spin_unlock_bh(&adapter->req_q_lock); if (!retval) wait_event(req->completion_wq, req->status & ZFCP_STATUS_FSFREQ_COMPLETED); @@ -1462,7 +1463,7 @@ int zfcp_fsf_open_port(struct zfcp_erp_action *erp_action) struct zfcp_fsf_req *req; int retval = -EIO; - spin_lock_bh(&adapter->req_q.lock); + spin_lock_bh(&adapter->req_q_lock); if (zfcp_fsf_req_sbal_get(adapter)) goto out; @@ -1492,7 +1493,7 @@ int zfcp_fsf_open_port(struct zfcp_erp_action *erp_action) erp_action->fsf_req = NULL; } out: - spin_unlock_bh(&adapter->req_q.lock); + spin_unlock_bh(&adapter->req_q_lock); return retval; } @@ -1530,7 +1531,7 @@ int zfcp_fsf_close_port(struct zfcp_erp_action *erp_action) struct zfcp_fsf_req *req; int retval = -EIO; - spin_lock_bh(&adapter->req_q.lock); + spin_lock_bh(&adapter->req_q_lock); if (zfcp_fsf_req_sbal_get(adapter)) goto out; @@ -1559,7 +1560,7 @@ int zfcp_fsf_close_port(struct zfcp_erp_action *erp_action) erp_action->fsf_req = NULL; } out: - spin_unlock_bh(&adapter->req_q.lock); + spin_unlock_bh(&adapter->req_q_lock); return retval; } @@ -1603,7 +1604,7 @@ int zfcp_fsf_open_wka_port(struct zfcp_wka_port *wka_port) struct zfcp_fsf_req *req; int retval = -EIO; - spin_lock_bh(&adapter->req_q.lock); + spin_lock_bh(&adapter->req_q_lock); if (zfcp_fsf_req_sbal_get(adapter)) goto out; @@ -1629,7 +1630,7 @@ int zfcp_fsf_open_wka_port(struct zfcp_wka_port *wka_port) if (retval) zfcp_fsf_req_free(req); out: - spin_unlock_bh(&adapter->req_q.lock); + spin_unlock_bh(&adapter->req_q_lock); return retval; } @@ -1658,7 +1659,7 @@ int zfcp_fsf_close_wka_port(struct zfcp_wka_port *wka_port) struct zfcp_fsf_req *req; int retval = -EIO; - spin_lock_bh(&adapter->req_q.lock); + spin_lock_bh(&adapter->req_q_lock); if (zfcp_fsf_req_sbal_get(adapter)) goto out; @@ -1683,7 +1684,7 @@ int zfcp_fsf_close_wka_port(struct zfcp_wka_port *wka_port) if (retval) zfcp_fsf_req_free(req); out: - spin_unlock_bh(&adapter->req_q.lock); + spin_unlock_bh(&adapter->req_q_lock); return retval; } @@ -1750,7 +1751,7 @@ int zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action) struct zfcp_fsf_req *req; int retval = -EIO; - spin_lock_bh(&adapter->req_q.lock); + spin_lock_bh(&adapter->req_q_lock); if (zfcp_fsf_req_sbal_get(adapter)) goto out; @@ -1781,7 +1782,7 @@ int zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action) erp_action->fsf_req = NULL; } out: - spin_unlock_bh(&adapter->req_q.lock); + spin_unlock_bh(&adapter->req_q_lock); return retval; } @@ -1924,7 +1925,7 @@ int zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action) struct zfcp_fsf_req *req; int retval = -EIO; - spin_lock_bh(&adapter->req_q.lock); + spin_lock_bh(&adapter->req_q_lock); if (zfcp_fsf_req_sbal_get(adapter)) goto out; @@ -1957,7 +1958,7 @@ int zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action) erp_action->fsf_req = NULL; } out: - spin_unlock_bh(&adapter->req_q.lock); + spin_unlock_bh(&adapter->req_q_lock); return retval; } @@ -2010,7 +2011,7 @@ int zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action) struct zfcp_fsf_req *req; int retval = -EIO; - spin_lock_bh(&adapter->req_q.lock); + spin_lock_bh(&adapter->req_q_lock); if (zfcp_fsf_req_sbal_get(adapter)) goto out; req = zfcp_fsf_req_create(adapter, FSF_QTCB_CLOSE_LUN, @@ -2039,7 +2040,7 @@ int zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action) erp_action->fsf_req = NULL; } out: - spin_unlock_bh(&adapter->req_q.lock); + spin_unlock_bh(&adapter->req_q_lock); return retval; } @@ -2281,7 +2282,7 @@ int zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *adapter, ZFCP_STATUS_COMMON_UNBLOCKED))) return -EBUSY; - spin_lock(&adapter->req_q.lock); + spin_lock(&adapter->req_q_lock); if (!zfcp_fsf_sbal_available(adapter)) goto out; req = zfcp_fsf_req_create(adapter, FSF_QTCB_FCP_CMND, req_flags, @@ -2380,7 +2381,7 @@ failed_scsi_cmnd: zfcp_fsf_req_free(req); scsi_cmnd->host_scribble = NULL; out: - spin_unlock(&adapter->req_q.lock); + spin_unlock(&adapter->req_q_lock); return retval; } @@ -2404,7 +2405,7 @@ struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_adapter *adapter, ZFCP_STATUS_COMMON_UNBLOCKED))) return NULL; - spin_lock(&adapter->req_q.lock); + spin_lock(&adapter->req_q_lock); if (!zfcp_fsf_sbal_available(adapter)) goto out; req = zfcp_fsf_req_create(adapter, FSF_QTCB_FCP_CMND, req_flags, @@ -2437,7 +2438,7 @@ struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_adapter *adapter, zfcp_fsf_req_free(req); req = NULL; out: - spin_unlock(&adapter->req_q.lock); + spin_unlock(&adapter->req_q_lock); return req; } @@ -2475,7 +2476,7 @@ struct zfcp_fsf_req *zfcp_fsf_control_file(struct zfcp_adapter *adapter, return ERR_PTR(-EINVAL); } - spin_lock_bh(&adapter->req_q.lock); + spin_lock_bh(&adapter->req_q_lock); if (zfcp_fsf_req_sbal_get(adapter)) goto out; @@ -2505,7 +2506,7 @@ struct zfcp_fsf_req *zfcp_fsf_control_file(struct zfcp_adapter *adapter, zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT); retval = zfcp_fsf_req_send(req); out: - spin_unlock_bh(&adapter->req_q.lock); + spin_unlock_bh(&adapter->req_q_lock); if (!retval) { wait_event(req->completion_wq, diff --git a/drivers/s390/scsi/zfcp_qdio.c b/drivers/s390/scsi/zfcp_qdio.c index 0dfaa176af7f..3e05080e62d4 100644 --- a/drivers/s390/scsi/zfcp_qdio.c +++ b/drivers/s390/scsi/zfcp_qdio.c @@ -346,7 +346,7 @@ int zfcp_qdio_send(struct zfcp_fsf_req *fsf_req) struct qdio_buffer_element *sbale; /* acknowledgements for transferred buffers */ - pci_batch = req_q->pci_batch + count; + pci_batch = adapter->req_q_pci_batch + count; if (unlikely(pci_batch >= ZFCP_QDIO_PCI_INTERVAL)) { pci_batch %= ZFCP_QDIO_PCI_INTERVAL; pci = first + count - (pci_batch + 1); @@ -366,7 +366,7 @@ int zfcp_qdio_send(struct zfcp_fsf_req *fsf_req) atomic_sub(count, &req_q->count); req_q->first += count; req_q->first %= QDIO_MAX_BUFFERS_PER_Q; - req_q->pci_batch = pci_batch; + adapter->req_q_pci_batch = pci_batch; return 0; } @@ -422,9 +422,9 @@ void zfcp_qdio_close(struct zfcp_adapter *adapter) /* clear QDIOUP flag, thus do_QDIO is not called during qdio_shutdown */ req_q = &adapter->req_q; - spin_lock_bh(&req_q->lock); + spin_lock_bh(&adapter->req_q_lock); atomic_clear_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status); - spin_unlock_bh(&req_q->lock); + spin_unlock_bh(&adapter->req_q_lock); qdio_shutdown(adapter->ccw_device, QDIO_FLAG_CLEANUP_USING_CLEAR); @@ -437,7 +437,7 @@ void zfcp_qdio_close(struct zfcp_adapter *adapter) } req_q->first = 0; atomic_set(&req_q->count, 0); - req_q->pci_batch = 0; + adapter->req_q_pci_batch = 0; adapter->resp_q.first = 0; atomic_set(&adapter->resp_q.count, 0); } @@ -475,7 +475,7 @@ int zfcp_qdio_open(struct zfcp_adapter *adapter) /* set index of first avalable SBALS / number of available SBALS */ adapter->req_q.first = 0; atomic_set(&adapter->req_q.count, QDIO_MAX_BUFFERS_PER_Q); - adapter->req_q.pci_batch = 0; + adapter->req_q_pci_batch = 0; return 0; diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c index cf6a14793371..ca8f85f3dad4 100644 --- a/drivers/s390/scsi/zfcp_scsi.c +++ b/drivers/s390/scsi/zfcp_scsi.c @@ -105,13 +105,17 @@ static struct zfcp_unit *zfcp_unit_lookup(struct zfcp_adapter *adapter, { struct zfcp_port *port; struct zfcp_unit *unit; + int scsi_lun; list_for_each_entry(port, &adapter->port_list_head, list) { if (!port->rport || (id != port->rport->scsi_target_id)) continue; - list_for_each_entry(unit, &port->unit_list_head, list) - if (lun == unit->scsi_lun) + list_for_each_entry(unit, &port->unit_list_head, list) { + scsi_lun = scsilun_to_int( + (struct scsi_lun *)&unit->fcp_lun); + if (lun == scsi_lun) return unit; + } } return NULL; diff --git a/drivers/s390/scsi/zfcp_sysfs.c b/drivers/s390/scsi/zfcp_sysfs.c index 7f7384c02a53..2809d789b55c 100644 --- a/drivers/s390/scsi/zfcp_sysfs.c +++ b/drivers/s390/scsi/zfcp_sysfs.c @@ -137,6 +137,7 @@ static ssize_t zfcp_sysfs_port_remove_store(struct device *dev, struct zfcp_port *port; u64 wwpn; int retval = 0; + LIST_HEAD(port_remove_lh); down(&zfcp_data.config_sema); if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_REMOVE) { @@ -154,7 +155,7 @@ static ssize_t zfcp_sysfs_port_remove_store(struct device *dev, if (port && (atomic_read(&port->refcount) == 0)) { zfcp_port_get(port); atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &port->status); - list_move(&port->list, &adapter->port_remove_lh); + list_move(&port->list, &port_remove_lh); } else port = NULL; write_unlock_irq(&zfcp_data.config_lock); @@ -235,6 +236,7 @@ static ssize_t zfcp_sysfs_unit_remove_store(struct device *dev, struct zfcp_unit *unit; u64 fcp_lun; int retval = 0; + LIST_HEAD(unit_remove_lh); down(&zfcp_data.config_sema); if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_REMOVE) { @@ -252,7 +254,7 @@ static ssize_t zfcp_sysfs_unit_remove_store(struct device *dev, if (unit && (atomic_read(&unit->refcount) == 0)) { zfcp_unit_get(unit); atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &unit->status); - list_move(&unit->list, &port->unit_remove_lh); + list_move(&unit->list, &unit_remove_lh); } else unit = NULL; -- cgit v1.2.3