aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/scsi/zfcp_sysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/s390/scsi/zfcp_sysfs.c')
-rw-r--r--drivers/s390/scsi/zfcp_sysfs.c44
1 files changed, 18 insertions, 26 deletions
diff --git a/drivers/s390/scsi/zfcp_sysfs.c b/drivers/s390/scsi/zfcp_sysfs.c
index 8430b518357e..b4a7e17932c5 100644
--- a/drivers/s390/scsi/zfcp_sysfs.c
+++ b/drivers/s390/scsi/zfcp_sysfs.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * sysfs attributes. 4 * sysfs attributes.
5 * 5 *
6 * Copyright IBM Corporation 2008 6 * Copyright IBM Corporation 2008, 2009
7 */ 7 */
8 8
9#define KMSG_COMPONENT "zfcp" 9#define KMSG_COMPONENT "zfcp"
@@ -140,7 +140,6 @@ static ssize_t zfcp_sysfs_port_remove_store(struct device *dev,
140 struct zfcp_port *port; 140 struct zfcp_port *port;
141 u64 wwpn; 141 u64 wwpn;
142 int retval = 0; 142 int retval = 0;
143 LIST_HEAD(port_remove_lh);
144 143
145 mutex_lock(&zfcp_data.config_mutex); 144 mutex_lock(&zfcp_data.config_mutex);
146 if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_REMOVE) { 145 if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_REMOVE) {
@@ -154,23 +153,21 @@ static ssize_t zfcp_sysfs_port_remove_store(struct device *dev,
154 } 153 }
155 154
156 port = zfcp_get_port_by_wwpn(adapter, wwpn); 155 port = zfcp_get_port_by_wwpn(adapter, wwpn);
157 if (port && (atomic_read(&port->refcount) == 1)) {
158 atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &port->status);
159 write_lock_irq(&adapter->port_list_lock);
160 list_move(&port->list, &port_remove_lh);
161 write_unlock_irq(&adapter->port_list_lock);
162 } else
163 port = NULL;
164
165 if (!port) { 156 if (!port) {
166 retval = -ENXIO; 157 retval = -ENXIO;
167 goto out; 158 goto out;
168 } 159 }
169 160
161 atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &port->status);
162
163 write_lock_irq(&adapter->port_list_lock);
164 list_del(&port->list);
165 write_unlock_irq(&adapter->port_list_lock);
166
167 put_device(&port->sysfs_device);
168
170 zfcp_erp_port_shutdown(port, 0, "syprs_1", NULL); 169 zfcp_erp_port_shutdown(port, 0, "syprs_1", NULL);
171 zfcp_erp_wait(adapter); 170 zfcp_device_unregister(&port->sysfs_device, &zfcp_sysfs_port_attrs);
172 zfcp_port_put(port);
173 zfcp_port_dequeue(port);
174 out: 171 out:
175 mutex_unlock(&zfcp_data.config_mutex); 172 mutex_unlock(&zfcp_data.config_mutex);
176 return retval ? retval : (ssize_t) count; 173 return retval ? retval : (ssize_t) count;
@@ -224,7 +221,6 @@ static ssize_t zfcp_sysfs_unit_add_store(struct device *dev,
224 zfcp_erp_unit_reopen(unit, 0, "syuas_1", NULL); 221 zfcp_erp_unit_reopen(unit, 0, "syuas_1", NULL);
225 zfcp_erp_wait(unit->port->adapter); 222 zfcp_erp_wait(unit->port->adapter);
226 flush_work(&unit->scsi_work); 223 flush_work(&unit->scsi_work);
227 zfcp_unit_put(unit);
228out: 224out:
229 mutex_unlock(&zfcp_data.config_mutex); 225 mutex_unlock(&zfcp_data.config_mutex);
230 return retval ? retval : (ssize_t) count; 226 return retval ? retval : (ssize_t) count;
@@ -239,7 +235,6 @@ static ssize_t zfcp_sysfs_unit_remove_store(struct device *dev,
239 struct zfcp_unit *unit; 235 struct zfcp_unit *unit;
240 u64 fcp_lun; 236 u64 fcp_lun;
241 int retval = 0; 237 int retval = 0;
242 LIST_HEAD(unit_remove_lh);
243 238
244 mutex_lock(&zfcp_data.config_mutex); 239 mutex_lock(&zfcp_data.config_mutex);
245 if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_REMOVE) { 240 if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_REMOVE) {
@@ -261,19 +256,16 @@ static ssize_t zfcp_sysfs_unit_remove_store(struct device *dev,
261 /* wait for possible timeout during SCSI probe */ 256 /* wait for possible timeout during SCSI probe */
262 flush_work(&unit->scsi_work); 257 flush_work(&unit->scsi_work);
263 258
264 if (atomic_read(&unit->refcount) == 1) { 259 atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &unit->status);
265 atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &unit->status); 260
261 write_lock_irq(&port->unit_list_lock);
262 list_del(&unit->list);
263 write_unlock_irq(&port->unit_list_lock);
266 264
267 write_lock_irq(&port->unit_list_lock); 265 put_device(&unit->sysfs_device);
268 list_move(&unit->list, &unit_remove_lh);
269 write_unlock_irq(&port->unit_list_lock);
270 266
271 zfcp_erp_unit_shutdown(unit, 0, "syurs_1", NULL); 267 zfcp_erp_unit_shutdown(unit, 0, "syurs_1", NULL);
272 zfcp_erp_wait(unit->port->adapter); 268 zfcp_device_unregister(&unit->sysfs_device, &zfcp_sysfs_unit_attrs);
273 zfcp_unit_put(unit);
274 zfcp_unit_dequeue(unit);
275 } else
276 zfcp_unit_put(unit);
277out: 269out:
278 mutex_unlock(&zfcp_data.config_mutex); 270 mutex_unlock(&zfcp_data.config_mutex);
279 return retval ? retval : (ssize_t) count; 271 return retval ? retval : (ssize_t) count;