diff options
Diffstat (limited to 'drivers/s390/scsi/zfcp_sysfs.c')
-rw-r--r-- | drivers/s390/scsi/zfcp_sysfs.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/drivers/s390/scsi/zfcp_sysfs.c b/drivers/s390/scsi/zfcp_sysfs.c index c66af27b230b..1e0eb089dfba 100644 --- a/drivers/s390/scsi/zfcp_sysfs.c +++ b/drivers/s390/scsi/zfcp_sysfs.c | |||
@@ -227,6 +227,8 @@ static ssize_t zfcp_sysfs_port_rescan_store(struct device *dev, | |||
227 | static ZFCP_DEV_ATTR(adapter, port_rescan, S_IWUSR, NULL, | 227 | static ZFCP_DEV_ATTR(adapter, port_rescan, S_IWUSR, NULL, |
228 | zfcp_sysfs_port_rescan_store); | 228 | zfcp_sysfs_port_rescan_store); |
229 | 229 | ||
230 | DEFINE_MUTEX(zfcp_sysfs_port_units_mutex); | ||
231 | |||
230 | static ssize_t zfcp_sysfs_port_remove_store(struct device *dev, | 232 | static ssize_t zfcp_sysfs_port_remove_store(struct device *dev, |
231 | struct device_attribute *attr, | 233 | struct device_attribute *attr, |
232 | const char *buf, size_t count) | 234 | const char *buf, size_t count) |
@@ -249,6 +251,16 @@ static ssize_t zfcp_sysfs_port_remove_store(struct device *dev, | |||
249 | else | 251 | else |
250 | retval = 0; | 252 | retval = 0; |
251 | 253 | ||
254 | mutex_lock(&zfcp_sysfs_port_units_mutex); | ||
255 | if (atomic_read(&port->units) > 0) { | ||
256 | retval = -EBUSY; | ||
257 | mutex_unlock(&zfcp_sysfs_port_units_mutex); | ||
258 | goto out; | ||
259 | } | ||
260 | /* port is about to be removed, so no more unit_add */ | ||
261 | atomic_set(&port->units, -1); | ||
262 | mutex_unlock(&zfcp_sysfs_port_units_mutex); | ||
263 | |||
252 | write_lock_irq(&adapter->port_list_lock); | 264 | write_lock_irq(&adapter->port_list_lock); |
253 | list_del(&port->list); | 265 | list_del(&port->list); |
254 | write_unlock_irq(&adapter->port_list_lock); | 266 | write_unlock_irq(&adapter->port_list_lock); |
@@ -289,12 +301,14 @@ static ssize_t zfcp_sysfs_unit_add_store(struct device *dev, | |||
289 | { | 301 | { |
290 | struct zfcp_port *port = container_of(dev, struct zfcp_port, dev); | 302 | struct zfcp_port *port = container_of(dev, struct zfcp_port, dev); |
291 | u64 fcp_lun; | 303 | u64 fcp_lun; |
304 | int retval; | ||
292 | 305 | ||
293 | if (strict_strtoull(buf, 0, (unsigned long long *) &fcp_lun)) | 306 | if (strict_strtoull(buf, 0, (unsigned long long *) &fcp_lun)) |
294 | return -EINVAL; | 307 | return -EINVAL; |
295 | 308 | ||
296 | if (zfcp_unit_add(port, fcp_lun)) | 309 | retval = zfcp_unit_add(port, fcp_lun); |
297 | return -EINVAL; | 310 | if (retval) |
311 | return retval; | ||
298 | 312 | ||
299 | return count; | 313 | return count; |
300 | } | 314 | } |