aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristof Schmitt <christof.schmitt@de.ibm.com>2009-08-18 09:43:28 -0400
committerJames Bottomley <James.Bottomley@suse.de>2009-09-05 09:49:42 -0400
commit24680defdb55e073c5e43d14318a164b842d8ce7 (patch)
treed1d054c831d85b175e560c562694a265f00a9191
parent143bb6bfe36d20618d8bf667915fe14d14b8ae2f (diff)
[SCSI] zfcp: Replace config semaphore with mutex
The config semaphore is only used as a mutex, so replace it with a simple mutex. Reviewed-by: Swen Schillig <swen@vnet.ibm.com> Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
-rw-r--r--drivers/s390/scsi/zfcp_aux.c22
-rw-r--r--drivers/s390/scsi/zfcp_ccw.c20
-rw-r--r--drivers/s390/scsi/zfcp_def.h3
-rw-r--r--drivers/s390/scsi/zfcp_fc.c4
-rw-r--r--drivers/s390/scsi/zfcp_sysfs.c16
5 files changed, 32 insertions, 33 deletions
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index d1e75d36ed1a..8e989159e4ed 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -84,7 +84,7 @@ static void __init zfcp_init_device_configure(char *busid, u64 wwpn, u64 lun)
84 struct zfcp_port *port; 84 struct zfcp_port *port;
85 struct zfcp_unit *unit; 85 struct zfcp_unit *unit;
86 86
87 down(&zfcp_data.config_sema); 87 mutex_lock(&zfcp_data.config_mutex);
88 read_lock_irq(&zfcp_data.config_lock); 88 read_lock_irq(&zfcp_data.config_lock);
89 adapter = zfcp_get_adapter_by_busid(busid); 89 adapter = zfcp_get_adapter_by_busid(busid);
90 if (adapter) 90 if (adapter)
@@ -99,20 +99,20 @@ static void __init zfcp_init_device_configure(char *busid, u64 wwpn, u64 lun)
99 unit = zfcp_unit_enqueue(port, lun); 99 unit = zfcp_unit_enqueue(port, lun);
100 if (IS_ERR(unit)) 100 if (IS_ERR(unit))
101 goto out_unit; 101 goto out_unit;
102 up(&zfcp_data.config_sema); 102 mutex_unlock(&zfcp_data.config_mutex);
103 ccw_device_set_online(adapter->ccw_device); 103 ccw_device_set_online(adapter->ccw_device);
104 104
105 zfcp_erp_wait(adapter); 105 zfcp_erp_wait(adapter);
106 flush_work(&unit->scsi_work); 106 flush_work(&unit->scsi_work);
107 107
108 down(&zfcp_data.config_sema); 108 mutex_lock(&zfcp_data.config_mutex);
109 zfcp_unit_put(unit); 109 zfcp_unit_put(unit);
110out_unit: 110out_unit:
111 zfcp_port_put(port); 111 zfcp_port_put(port);
112out_port: 112out_port:
113 zfcp_adapter_put(adapter); 113 zfcp_adapter_put(adapter);
114out_adapter: 114out_adapter:
115 up(&zfcp_data.config_sema); 115 mutex_unlock(&zfcp_data.config_mutex);
116 return; 116 return;
117} 117}
118 118
@@ -176,7 +176,7 @@ static int __init zfcp_module_init(void)
176 if (!zfcp_data.gid_pn_cache) 176 if (!zfcp_data.gid_pn_cache)
177 goto out_gid_cache; 177 goto out_gid_cache;
178 178
179 sema_init(&zfcp_data.config_sema, 1); 179 mutex_init(&zfcp_data.config_mutex);
180 rwlock_init(&zfcp_data.config_lock); 180 rwlock_init(&zfcp_data.config_lock);
181 181
182 zfcp_data.scsi_transport_template = 182 zfcp_data.scsi_transport_template =
@@ -266,7 +266,7 @@ static void zfcp_sysfs_unit_release(struct device *dev)
266 * @port: pointer to port where unit is added 266 * @port: pointer to port where unit is added
267 * @fcp_lun: FCP LUN of unit to be enqueued 267 * @fcp_lun: FCP LUN of unit to be enqueued
268 * Returns: pointer to enqueued unit on success, ERR_PTR on error 268 * Returns: pointer to enqueued unit on success, ERR_PTR on error
269 * Locks: config_sema must be held to serialize changes to the unit list 269 * Locks: config_mutex must be held to serialize changes to the unit list
270 * 270 *
271 * Sets up some unit internal structures and creates sysfs entry. 271 * Sets up some unit internal structures and creates sysfs entry.
272 */ 272 */
@@ -356,7 +356,7 @@ void zfcp_unit_dequeue(struct zfcp_unit *unit)
356 356
357static int zfcp_allocate_low_mem_buffers(struct zfcp_adapter *adapter) 357static int zfcp_allocate_low_mem_buffers(struct zfcp_adapter *adapter)
358{ 358{
359 /* must only be called with zfcp_data.config_sema taken */ 359 /* must only be called with zfcp_data.config_mutex taken */
360 adapter->pool.erp_req = 360 adapter->pool.erp_req =
361 mempool_create_kmalloc_pool(1, sizeof(struct zfcp_fsf_req)); 361 mempool_create_kmalloc_pool(1, sizeof(struct zfcp_fsf_req));
362 if (!adapter->pool.erp_req) 362 if (!adapter->pool.erp_req)
@@ -404,7 +404,7 @@ static int zfcp_allocate_low_mem_buffers(struct zfcp_adapter *adapter)
404 404
405static void zfcp_free_low_mem_buffers(struct zfcp_adapter *adapter) 405static void zfcp_free_low_mem_buffers(struct zfcp_adapter *adapter)
406{ 406{
407 /* zfcp_data.config_sema must be held */ 407 /* zfcp_data.config_mutex must be held */
408 if (adapter->pool.erp_req) 408 if (adapter->pool.erp_req)
409 mempool_destroy(adapter->pool.erp_req); 409 mempool_destroy(adapter->pool.erp_req);
410 if (adapter->pool.scsi_req) 410 if (adapter->pool.scsi_req)
@@ -491,7 +491,7 @@ static void zfcp_destroy_adapter_work_queue(struct zfcp_adapter *adapter)
491 * Enqueues an adapter at the end of the adapter list in the driver data. 491 * Enqueues an adapter at the end of the adapter list in the driver data.
492 * All adapter internal structures are set up. 492 * All adapter internal structures are set up.
493 * Proc-fs entries are also created. 493 * Proc-fs entries are also created.
494 * locks: config_sema must be held to serialise changes to the adapter list 494 * locks: config_mutex must be held to serialize changes to the adapter list
495 */ 495 */
496int zfcp_adapter_enqueue(struct ccw_device *ccw_device) 496int zfcp_adapter_enqueue(struct ccw_device *ccw_device)
497{ 497{
@@ -499,7 +499,7 @@ int zfcp_adapter_enqueue(struct ccw_device *ccw_device)
499 499
500 /* 500 /*
501 * Note: It is safe to release the list_lock, as any list changes 501 * Note: It is safe to release the list_lock, as any list changes
502 * are protected by the config_sema, which must be held to get here 502 * are protected by the config_mutex, which must be held to get here
503 */ 503 */
504 504
505 adapter = kzalloc(sizeof(struct zfcp_adapter), GFP_KERNEL); 505 adapter = kzalloc(sizeof(struct zfcp_adapter), GFP_KERNEL);
@@ -630,7 +630,7 @@ static void zfcp_sysfs_port_release(struct device *dev)
630 * @status: initial status for the port 630 * @status: initial status for the port
631 * @d_id: destination id of the remote port to be enqueued 631 * @d_id: destination id of the remote port to be enqueued
632 * Returns: pointer to enqueued port on success, ERR_PTR on error 632 * Returns: pointer to enqueued port on success, ERR_PTR on error
633 * Locks: config_sema must be held to serialize changes to the port list 633 * Locks: config_mutex must be held to serialize changes to the port list
634 * 634 *
635 * All port internal structures are set up and the sysfs entry is generated. 635 * All port internal structures are set up and the sysfs entry is generated.
636 * d_id is used to enqueue ports with a well known address like the Directory 636 * d_id is used to enqueue ports with a well known address like the Directory
diff --git a/drivers/s390/scsi/zfcp_ccw.c b/drivers/s390/scsi/zfcp_ccw.c
index 82ae6ed7ef83..0c90f8e71605 100644
--- a/drivers/s390/scsi/zfcp_ccw.c
+++ b/drivers/s390/scsi/zfcp_ccw.c
@@ -21,12 +21,12 @@ static int zfcp_ccw_suspend(struct ccw_device *cdev)
21 if (!adapter) 21 if (!adapter)
22 return 0; 22 return 0;
23 23
24 down(&zfcp_data.config_sema); 24 mutex_lock(&zfcp_data.config_mutex);
25 25
26 zfcp_erp_adapter_shutdown(adapter, 0, "ccsusp1", NULL); 26 zfcp_erp_adapter_shutdown(adapter, 0, "ccsusp1", NULL);
27 zfcp_erp_wait(adapter); 27 zfcp_erp_wait(adapter);
28 28
29 up(&zfcp_data.config_sema); 29 mutex_unlock(&zfcp_data.config_mutex);
30 30
31 return 0; 31 return 0;
32} 32}
@@ -98,7 +98,7 @@ static void zfcp_ccw_remove(struct ccw_device *ccw_device)
98 98
99 ccw_device_set_offline(ccw_device); 99 ccw_device_set_offline(ccw_device);
100 100
101 down(&zfcp_data.config_sema); 101 mutex_lock(&zfcp_data.config_mutex);
102 adapter = dev_get_drvdata(&ccw_device->dev); 102 adapter = dev_get_drvdata(&ccw_device->dev);
103 if (!adapter) 103 if (!adapter)
104 goto out; 104 goto out;
@@ -128,7 +128,7 @@ static void zfcp_ccw_remove(struct ccw_device *ccw_device)
128 zfcp_adapter_dequeue(adapter); 128 zfcp_adapter_dequeue(adapter);
129 129
130out: 130out:
131 up(&zfcp_data.config_sema); 131 mutex_unlock(&zfcp_data.config_mutex);
132} 132}
133 133
134/** 134/**
@@ -149,7 +149,7 @@ static int zfcp_ccw_set_online(struct ccw_device *ccw_device)
149 struct zfcp_adapter *adapter; 149 struct zfcp_adapter *adapter;
150 int ret = 0; 150 int ret = 0;
151 151
152 down(&zfcp_data.config_sema); 152 mutex_lock(&zfcp_data.config_mutex);
153 adapter = dev_get_drvdata(&ccw_device->dev); 153 adapter = dev_get_drvdata(&ccw_device->dev);
154 154
155 if (!adapter) { 155 if (!adapter) {
@@ -173,7 +173,7 @@ static int zfcp_ccw_set_online(struct ccw_device *ccw_device)
173 "ccsonl2", NULL); 173 "ccsonl2", NULL);
174 zfcp_erp_wait(adapter); 174 zfcp_erp_wait(adapter);
175out: 175out:
176 up(&zfcp_data.config_sema); 176 mutex_unlock(&zfcp_data.config_mutex);
177 if (!ret) 177 if (!ret)
178 flush_work(&adapter->scan_work); 178 flush_work(&adapter->scan_work);
179 return ret; 179 return ret;
@@ -190,14 +190,14 @@ static int zfcp_ccw_set_offline(struct ccw_device *ccw_device)
190{ 190{
191 struct zfcp_adapter *adapter; 191 struct zfcp_adapter *adapter;
192 192
193 down(&zfcp_data.config_sema); 193 mutex_lock(&zfcp_data.config_mutex);
194 adapter = dev_get_drvdata(&ccw_device->dev); 194 adapter = dev_get_drvdata(&ccw_device->dev);
195 if (!adapter) 195 if (!adapter)
196 goto out; 196 goto out;
197 197
198 zfcp_erp_adapter_shutdown(adapter, 0, "ccsoff1", NULL); 198 zfcp_erp_adapter_shutdown(adapter, 0, "ccsoff1", NULL);
199 zfcp_erp_wait(adapter); 199 zfcp_erp_wait(adapter);
200 up(&zfcp_data.config_sema); 200 mutex_unlock(&zfcp_data.config_mutex);
201out: 201out:
202 return 0; 202 return 0;
203} 203}
@@ -251,12 +251,12 @@ static void zfcp_ccw_shutdown(struct ccw_device *cdev)
251{ 251{
252 struct zfcp_adapter *adapter; 252 struct zfcp_adapter *adapter;
253 253
254 down(&zfcp_data.config_sema); 254 mutex_lock(&zfcp_data.config_mutex);
255 adapter = dev_get_drvdata(&cdev->dev); 255 adapter = dev_get_drvdata(&cdev->dev);
256 zfcp_erp_adapter_shutdown(adapter, 0, "ccshut1", NULL); 256 zfcp_erp_adapter_shutdown(adapter, 0, "ccshut1", NULL);
257 zfcp_erp_wait(adapter); 257 zfcp_erp_wait(adapter);
258 zfcp_erp_thread_kill(adapter); 258 zfcp_erp_thread_kill(adapter);
259 up(&zfcp_data.config_sema); 259 mutex_unlock(&zfcp_data.config_mutex);
260} 260}
261 261
262static struct ccw_driver zfcp_ccw_driver = { 262static struct ccw_driver zfcp_ccw_driver = {
diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h
index 99830758e873..cc98eead2c3c 100644
--- a/drivers/s390/scsi/zfcp_def.h
+++ b/drivers/s390/scsi/zfcp_def.h
@@ -604,8 +604,7 @@ struct zfcp_data {
604 rwlock_t config_lock; /* serialises changes 604 rwlock_t config_lock; /* serialises changes
605 to adapter/port/unit 605 to adapter/port/unit
606 lists */ 606 lists */
607 struct semaphore config_sema; /* serialises configuration 607 struct mutex config_mutex;
608 changes */
609 struct kmem_cache *gpn_ft_cache; 608 struct kmem_cache *gpn_ft_cache;
610 struct kmem_cache *qtcb_cache; 609 struct kmem_cache *qtcb_cache;
611 struct kmem_cache *sr_buffer_cache; 610 struct kmem_cache *sr_buffer_cache;
diff --git a/drivers/s390/scsi/zfcp_fc.c b/drivers/s390/scsi/zfcp_fc.c
index 82f148d09968..722f22de8753 100644
--- a/drivers/s390/scsi/zfcp_fc.c
+++ b/drivers/s390/scsi/zfcp_fc.c
@@ -613,7 +613,7 @@ static int zfcp_fc_eval_gpn_ft(struct zfcp_gpn_ft *gpn_ft, int max_entries)
613 return -E2BIG; 613 return -E2BIG;
614 } 614 }
615 615
616 down(&zfcp_data.config_sema); 616 mutex_lock(&zfcp_data.config_mutex);
617 617
618 /* first entry is the header */ 618 /* first entry is the header */
619 for (x = 1; x < max_entries && !last; x++) { 619 for (x = 1; x < max_entries && !last; x++) {
@@ -647,7 +647,7 @@ static int zfcp_fc_eval_gpn_ft(struct zfcp_gpn_ft *gpn_ft, int max_entries)
647 zfcp_erp_wait(adapter); 647 zfcp_erp_wait(adapter);
648 list_for_each_entry_safe(port, tmp, &adapter->port_list_head, list) 648 list_for_each_entry_safe(port, tmp, &adapter->port_list_head, list)
649 zfcp_fc_validate_port(port); 649 zfcp_fc_validate_port(port);
650 up(&zfcp_data.config_sema); 650 mutex_unlock(&zfcp_data.config_mutex);
651 return ret; 651 return ret;
652} 652}
653 653
diff --git a/drivers/s390/scsi/zfcp_sysfs.c b/drivers/s390/scsi/zfcp_sysfs.c
index c86496bb608b..079a8cf518a3 100644
--- a/drivers/s390/scsi/zfcp_sysfs.c
+++ b/drivers/s390/scsi/zfcp_sysfs.c
@@ -88,7 +88,7 @@ static ssize_t zfcp_sysfs_##_feat##_failed_store(struct device *dev, \
88 unsigned long val; \ 88 unsigned long val; \
89 int retval = 0; \ 89 int retval = 0; \
90 \ 90 \
91 down(&zfcp_data.config_sema); \ 91 mutex_lock(&zfcp_data.config_mutex); \
92 if (atomic_read(&_feat->status) & ZFCP_STATUS_COMMON_REMOVE) { \ 92 if (atomic_read(&_feat->status) & ZFCP_STATUS_COMMON_REMOVE) { \
93 retval = -EBUSY; \ 93 retval = -EBUSY; \
94 goto out; \ 94 goto out; \
@@ -105,7 +105,7 @@ static ssize_t zfcp_sysfs_##_feat##_failed_store(struct device *dev, \
105 _reopen_id, NULL); \ 105 _reopen_id, NULL); \
106 zfcp_erp_wait(_adapter); \ 106 zfcp_erp_wait(_adapter); \
107out: \ 107out: \
108 up(&zfcp_data.config_sema); \ 108 mutex_unlock(&zfcp_data.config_mutex); \
109 return retval ? retval : (ssize_t) count; \ 109 return retval ? retval : (ssize_t) count; \
110} \ 110} \
111static ZFCP_DEV_ATTR(_feat, failed, S_IWUSR | S_IRUGO, \ 111static ZFCP_DEV_ATTR(_feat, failed, S_IWUSR | S_IRUGO, \
@@ -142,7 +142,7 @@ static ssize_t zfcp_sysfs_port_remove_store(struct device *dev,
142 int retval = 0; 142 int retval = 0;
143 LIST_HEAD(port_remove_lh); 143 LIST_HEAD(port_remove_lh);
144 144
145 down(&zfcp_data.config_sema); 145 mutex_lock(&zfcp_data.config_mutex);
146 if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_REMOVE) { 146 if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_REMOVE) {
147 retval = -EBUSY; 147 retval = -EBUSY;
148 goto out; 148 goto out;
@@ -173,7 +173,7 @@ static ssize_t zfcp_sysfs_port_remove_store(struct device *dev,
173 zfcp_port_put(port); 173 zfcp_port_put(port);
174 zfcp_port_dequeue(port); 174 zfcp_port_dequeue(port);
175 out: 175 out:
176 up(&zfcp_data.config_sema); 176 mutex_unlock(&zfcp_data.config_mutex);
177 return retval ? retval : (ssize_t) count; 177 return retval ? retval : (ssize_t) count;
178} 178}
179static ZFCP_DEV_ATTR(adapter, port_remove, S_IWUSR, NULL, 179static ZFCP_DEV_ATTR(adapter, port_remove, S_IWUSR, NULL,
@@ -207,7 +207,7 @@ static ssize_t zfcp_sysfs_unit_add_store(struct device *dev,
207 u64 fcp_lun; 207 u64 fcp_lun;
208 int retval = -EINVAL; 208 int retval = -EINVAL;
209 209
210 down(&zfcp_data.config_sema); 210 mutex_lock(&zfcp_data.config_mutex);
211 if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_REMOVE) { 211 if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_REMOVE) {
212 retval = -EBUSY; 212 retval = -EBUSY;
213 goto out; 213 goto out;
@@ -226,7 +226,7 @@ static ssize_t zfcp_sysfs_unit_add_store(struct device *dev,
226 zfcp_erp_wait(unit->port->adapter); 226 zfcp_erp_wait(unit->port->adapter);
227 zfcp_unit_put(unit); 227 zfcp_unit_put(unit);
228out: 228out:
229 up(&zfcp_data.config_sema); 229 mutex_unlock(&zfcp_data.config_mutex);
230 return retval ? retval : (ssize_t) count; 230 return retval ? retval : (ssize_t) count;
231} 231}
232static DEVICE_ATTR(unit_add, S_IWUSR, NULL, zfcp_sysfs_unit_add_store); 232static DEVICE_ATTR(unit_add, S_IWUSR, NULL, zfcp_sysfs_unit_add_store);
@@ -241,7 +241,7 @@ static ssize_t zfcp_sysfs_unit_remove_store(struct device *dev,
241 int retval = 0; 241 int retval = 0;
242 LIST_HEAD(unit_remove_lh); 242 LIST_HEAD(unit_remove_lh);
243 243
244 down(&zfcp_data.config_sema); 244 mutex_lock(&zfcp_data.config_mutex);
245 if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_REMOVE) { 245 if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_REMOVE) {
246 retval = -EBUSY; 246 retval = -EBUSY;
247 goto out; 247 goto out;
@@ -282,7 +282,7 @@ static ssize_t zfcp_sysfs_unit_remove_store(struct device *dev,
282 zfcp_unit_put(unit); 282 zfcp_unit_put(unit);
283 zfcp_unit_dequeue(unit); 283 zfcp_unit_dequeue(unit);
284out: 284out:
285 up(&zfcp_data.config_sema); 285 mutex_unlock(&zfcp_data.config_mutex);
286 return retval ? retval : (ssize_t) count; 286 return retval ? retval : (ssize_t) count;
287} 287}
288static DEVICE_ATTR(unit_remove, S_IWUSR, NULL, zfcp_sysfs_unit_remove_store); 288static DEVICE_ATTR(unit_remove, S_IWUSR, NULL, zfcp_sysfs_unit_remove_store);