Commit 9eae07ef authored by Swen Schillig's avatar Swen Schillig Committed by James Bottomley

[SCSI] zfcp: Assign scheduled work to driver queue

The port_scan work was scheduled to the work_queue provided by the
kernel. This resulted on SMP systems to a likely situation that more
than one scan_work were processed in parallel. This is not required
and openes the possibility of race conditions between the removal of
invalid ports and the enqueue of just scanned ports.  This patch
synchronizes the scan_work tasks by scheduling them to adapter local
work_queue.
Signed-off-by: default avatarSwen Schillig <swen@vnet.ibm.com>
Signed-off-by: default avatarChristof Schmitt <christof.schmitt@de.ibm.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent 6b183334
...@@ -522,7 +522,7 @@ struct zfcp_adapter *zfcp_adapter_enqueue(struct ccw_device *ccw_device) ...@@ -522,7 +522,7 @@ struct zfcp_adapter *zfcp_adapter_enqueue(struct ccw_device *ccw_device)
adapter->ccw_device = ccw_device; adapter->ccw_device = ccw_device;
INIT_WORK(&adapter->stat_work, _zfcp_status_read_scheduler); INIT_WORK(&adapter->stat_work, _zfcp_status_read_scheduler);
INIT_WORK(&adapter->scan_work, _zfcp_fc_scan_ports_later); INIT_WORK(&adapter->scan_work, zfcp_fc_scan_ports);
if (zfcp_qdio_setup(adapter)) if (zfcp_qdio_setup(adapter))
goto failed; goto failed;
......
...@@ -1197,7 +1197,7 @@ static void zfcp_erp_action_cleanup(struct zfcp_erp_action *act, int result) ...@@ -1197,7 +1197,7 @@ static void zfcp_erp_action_cleanup(struct zfcp_erp_action *act, int result)
case ZFCP_ERP_ACTION_REOPEN_ADAPTER: case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
if (result == ZFCP_ERP_SUCCEEDED) { if (result == ZFCP_ERP_SUCCEEDED) {
register_service_level(&adapter->service_level); register_service_level(&adapter->service_level);
schedule_work(&adapter->scan_work); queue_work(adapter->work_queue, &adapter->scan_work);
} else } else
unregister_service_level(&adapter->service_level); unregister_service_level(&adapter->service_level);
kref_put(&adapter->ref, zfcp_adapter_release); kref_put(&adapter->ref, zfcp_adapter_release);
......
...@@ -94,8 +94,7 @@ extern void zfcp_erp_adapter_access_changed(struct zfcp_adapter *, char *, ...@@ -94,8 +94,7 @@ extern void zfcp_erp_adapter_access_changed(struct zfcp_adapter *, char *,
extern void zfcp_erp_timeout_handler(unsigned long); extern void zfcp_erp_timeout_handler(unsigned long);
/* zfcp_fc.c */ /* zfcp_fc.c */
extern int zfcp_fc_scan_ports(struct zfcp_adapter *); extern void zfcp_fc_scan_ports(struct work_struct *);
extern void _zfcp_fc_scan_ports_later(struct work_struct *);
extern void zfcp_fc_incoming_els(struct zfcp_fsf_req *); extern void zfcp_fc_incoming_els(struct zfcp_fsf_req *);
extern void zfcp_fc_port_did_lookup(struct work_struct *); extern void zfcp_fc_port_did_lookup(struct work_struct *);
extern void zfcp_fc_trigger_did_lookup(struct zfcp_port *); extern void zfcp_fc_trigger_did_lookup(struct zfcp_port *);
......
...@@ -184,7 +184,7 @@ static void zfcp_fc_incoming_rscn(struct zfcp_fsf_req *fsf_req) ...@@ -184,7 +184,7 @@ static void zfcp_fc_incoming_rscn(struct zfcp_fsf_req *fsf_req)
range_mask = rscn_range_mask[fcp_rscn_element->addr_format]; range_mask = rscn_range_mask[fcp_rscn_element->addr_format];
_zfcp_fc_incoming_rscn(fsf_req, range_mask, fcp_rscn_element); _zfcp_fc_incoming_rscn(fsf_req, range_mask, fcp_rscn_element);
} }
schedule_work(&fsf_req->adapter->scan_work); queue_work(fsf_req->adapter->work_queue, &fsf_req->adapter->scan_work);
} }
static void zfcp_fc_incoming_wwpn(struct zfcp_fsf_req *req, u64 wwpn) static void zfcp_fc_incoming_wwpn(struct zfcp_fsf_req *req, u64 wwpn)
...@@ -664,10 +664,12 @@ static int zfcp_fc_eval_gpn_ft(struct zfcp_gpn_ft *gpn_ft, int max_entries) ...@@ -664,10 +664,12 @@ static int zfcp_fc_eval_gpn_ft(struct zfcp_gpn_ft *gpn_ft, int max_entries)
/** /**
* zfcp_fc_scan_ports - scan remote ports and attach new ports * zfcp_fc_scan_ports - scan remote ports and attach new ports
* @adapter: pointer to struct zfcp_adapter * @work: reference to scheduled work
*/ */
int zfcp_fc_scan_ports(struct zfcp_adapter *adapter) void zfcp_fc_scan_ports(struct work_struct *work)
{ {
struct zfcp_adapter *adapter = container_of(work, struct zfcp_adapter,
scan_work);
int ret, i; int ret, i;
struct zfcp_gpn_ft *gpn_ft; struct zfcp_gpn_ft *gpn_ft;
int chain, max_entries, buf_num, max_bytes; int chain, max_entries, buf_num, max_bytes;
...@@ -679,17 +681,14 @@ int zfcp_fc_scan_ports(struct zfcp_adapter *adapter) ...@@ -679,17 +681,14 @@ int zfcp_fc_scan_ports(struct zfcp_adapter *adapter)
if (fc_host_port_type(adapter->scsi_host) != FC_PORTTYPE_NPORT && if (fc_host_port_type(adapter->scsi_host) != FC_PORTTYPE_NPORT &&
fc_host_port_type(adapter->scsi_host) != FC_PORTTYPE_NPIV) fc_host_port_type(adapter->scsi_host) != FC_PORTTYPE_NPIV)
return 0; return;
ret = zfcp_fc_wka_port_get(&adapter->gs->ds); if (zfcp_fc_wka_port_get(&adapter->gs->ds))
if (ret) return;
return ret;
gpn_ft = zfcp_alloc_sg_env(buf_num); gpn_ft = zfcp_alloc_sg_env(buf_num);
if (!gpn_ft) { if (!gpn_ft)
ret = -ENOMEM;
goto out; goto out;
}
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
ret = zfcp_fc_send_gpn_ft(gpn_ft, adapter, max_bytes); ret = zfcp_fc_send_gpn_ft(gpn_ft, adapter, max_bytes);
...@@ -704,15 +703,9 @@ int zfcp_fc_scan_ports(struct zfcp_adapter *adapter) ...@@ -704,15 +703,9 @@ int zfcp_fc_scan_ports(struct zfcp_adapter *adapter)
zfcp_free_sg_env(gpn_ft, buf_num); zfcp_free_sg_env(gpn_ft, buf_num);
out: out:
zfcp_fc_wka_port_put(&adapter->gs->ds); zfcp_fc_wka_port_put(&adapter->gs->ds);
return ret;
} }
void _zfcp_fc_scan_ports_later(struct work_struct *work)
{
zfcp_fc_scan_ports(container_of(work, struct zfcp_adapter, scan_work));
}
struct zfcp_els_fc_job { struct zfcp_els_fc_job {
struct zfcp_send_els els; struct zfcp_send_els els;
struct fc_bsg_job *job; struct fc_bsg_job *job;
......
...@@ -287,7 +287,7 @@ static void zfcp_fsf_status_read_handler(struct zfcp_fsf_req *req) ...@@ -287,7 +287,7 @@ static void zfcp_fsf_status_read_handler(struct zfcp_fsf_req *req)
zfcp_erp_adapter_access_changed(adapter, "fssrh_3", zfcp_erp_adapter_access_changed(adapter, "fssrh_3",
req); req);
if (sr_buf->status_subtype & FSF_STATUS_READ_SUB_INCOMING_ELS) if (sr_buf->status_subtype & FSF_STATUS_READ_SUB_INCOMING_ELS)
schedule_work(&adapter->scan_work); queue_work(adapter->work_queue, &adapter->scan_work);
break; break;
case FSF_STATUS_READ_CFDC_UPDATED: case FSF_STATUS_READ_CFDC_UPDATED:
zfcp_erp_adapter_access_changed(adapter, "fssrh_4", req); zfcp_erp_adapter_access_changed(adapter, "fssrh_4", req);
......
...@@ -184,15 +184,16 @@ static ssize_t zfcp_sysfs_port_rescan_store(struct device *dev, ...@@ -184,15 +184,16 @@ static ssize_t zfcp_sysfs_port_rescan_store(struct device *dev,
{ {
struct ccw_device *cdev = to_ccwdev(dev); struct ccw_device *cdev = to_ccwdev(dev);
struct zfcp_adapter *adapter = zfcp_ccw_adapter_by_cdev(cdev); struct zfcp_adapter *adapter = zfcp_ccw_adapter_by_cdev(cdev);
int ret;
if (!adapter) if (!adapter)
return -ENODEV; return -ENODEV;
ret = zfcp_fc_scan_ports(adapter); /* sync the user-space- with the kernel-invocation of scan_work */
queue_work(adapter->work_queue, &adapter->scan_work);
flush_work(&adapter->scan_work);
zfcp_ccw_adapter_put(adapter); zfcp_ccw_adapter_put(adapter);
return ret ? ret : (ssize_t) count; return (ssize_t) count;
} }
static ZFCP_DEV_ATTR(adapter, port_rescan, S_IWUSR, NULL, static ZFCP_DEV_ATTR(adapter, port_rescan, S_IWUSR, NULL,
zfcp_sysfs_port_rescan_store); zfcp_sysfs_port_rescan_store);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment