Skip to content

Commit 6b18333

Browse files
sswenJames Bottomley
authored andcommitted
[SCSI] zfcp: Remove STATUS_COMMON_REMOVE flag as it is not required anymore
The flag ZFCP_STATUS_COMMON_REMOVE was used to indicate that a resource is not ready to be used or about to be removed from the system. This is now better done by an improved list handling and therefore the additional indicator is not required anymore. Signed-off-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>
1 parent c1fad41 commit 6b18333

File tree

6 files changed

+34
-78
lines changed

6 files changed

+34
-78
lines changed

drivers/s390/scsi/zfcp_aux.c

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,9 @@ struct zfcp_unit *zfcp_get_unit_by_lun(struct zfcp_port *port, u64 fcp_lun)
245245

246246
read_lock_irqsave(&port->unit_list_lock, flags);
247247
list_for_each_entry(unit, &port->unit_list, list)
248-
if ((unit->fcp_lun == fcp_lun) &&
249-
!(atomic_read(&unit->status) & ZFCP_STATUS_COMMON_REMOVE)) {
250-
get_device(&unit->sysfs_device);
248+
if (unit->fcp_lun == fcp_lun) {
249+
if (!get_device(&unit->sysfs_device))
250+
unit = NULL;
251251
read_unlock_irqrestore(&port->unit_list_lock, flags);
252252
return unit;
253253
}
@@ -270,9 +270,9 @@ struct zfcp_port *zfcp_get_port_by_wwpn(struct zfcp_adapter *adapter,
270270

271271
read_lock_irqsave(&adapter->port_list_lock, flags);
272272
list_for_each_entry(port, &adapter->port_list, list)
273-
if ((port->wwpn == wwpn) &&
274-
!(atomic_read(&port->status) & ZFCP_STATUS_COMMON_REMOVE)) {
275-
get_device(&port->sysfs_device);
273+
if (port->wwpn == wwpn) {
274+
if (!get_device(&port->sysfs_device))
275+
port = NULL;
276276
read_unlock_irqrestore(&adapter->port_list_lock, flags);
277277
return port;
278278
}
@@ -334,9 +334,6 @@ struct zfcp_unit *zfcp_unit_enqueue(struct zfcp_port *port, u64 fcp_lun)
334334
}
335335
retval = -EINVAL;
336336

337-
/* mark unit unusable as long as sysfs registration is not complete */
338-
atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &unit->status);
339-
340337
INIT_WORK(&unit->scsi_work, zfcp_scsi_scan);
341338

342339
spin_lock_init(&unit->latencies.lock);
@@ -360,7 +357,6 @@ struct zfcp_unit *zfcp_unit_enqueue(struct zfcp_port *port, u64 fcp_lun)
360357
list_add_tail(&unit->list, &port->unit_list);
361358
write_unlock_irq(&port->unit_list_lock);
362359

363-
atomic_clear_mask(ZFCP_STATUS_COMMON_REMOVE, &unit->status);
364360
atomic_set_mask(ZFCP_STATUS_COMMON_RUNNING, &unit->status);
365361

366362
return unit;
@@ -565,17 +561,12 @@ struct zfcp_adapter *zfcp_adapter_enqueue(struct ccw_device *ccw_device)
565561

566562
adapter->service_level.seq_print = zfcp_print_sl;
567563

568-
/* mark adapter unusable as long as sysfs registration is not complete */
569-
atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &adapter->status);
570-
571564
dev_set_drvdata(&ccw_device->dev, adapter);
572565

573566
if (sysfs_create_group(&ccw_device->dev.kobj,
574567
&zfcp_sysfs_adapter_attrs))
575568
goto failed;
576569

577-
atomic_clear_mask(ZFCP_STATUS_COMMON_REMOVE, &adapter->status);
578-
579570
if (!zfcp_adapter_scsi_register(adapter))
580571
return adapter;
581572

@@ -692,9 +683,6 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, u64 wwpn,
692683
port->sysfs_device.parent = &adapter->ccw_device->dev;
693684
port->sysfs_device.release = zfcp_port_release;
694685

695-
/* mark port unusable as long as sysfs registration is not complete */
696-
atomic_set_mask(status | ZFCP_STATUS_COMMON_REMOVE, &port->status);
697-
698686
if (dev_set_name(&port->sysfs_device, "0x%016llx",
699687
(unsigned long long)wwpn)) {
700688
kfree(port);
@@ -715,8 +703,7 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, u64 wwpn,
715703
list_add_tail(&port->list, &adapter->port_list);
716704
write_unlock_irq(&adapter->port_list_lock);
717705

718-
atomic_clear_mask(ZFCP_STATUS_COMMON_REMOVE, &port->status);
719-
atomic_set_mask(ZFCP_STATUS_COMMON_RUNNING, &port->status);
706+
atomic_set_mask(status | ZFCP_STATUS_COMMON_RUNNING, &port->status);
720707

721708
return port;
722709

drivers/s390/scsi/zfcp_ccw.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,11 @@ static void zfcp_ccw_remove(struct ccw_device *cdev)
113113
write_lock_irq(&adapter->port_list_lock);
114114
list_for_each_entry_safe(port, p, &adapter->port_list, list) {
115115
write_lock(&port->unit_list_lock);
116-
list_for_each_entry_safe(unit, u, &port->unit_list, list) {
117-
atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE,
118-
&unit->status);
116+
list_for_each_entry_safe(unit, u, &port->unit_list, list)
119117
list_move(&unit->list, &unit_remove_lh);
120-
}
121118
write_unlock(&port->unit_list_lock);
122-
atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &port->status);
123119
list_move(&port->list, &port_remove_lh);
124120
}
125-
atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &adapter->status);
126121
write_unlock_irq(&adapter->port_list_lock);
127122
zfcp_ccw_adapter_put(adapter); /* put from zfcp_ccw_adapter_by_cdev */
128123

drivers/s390/scsi/zfcp_def.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ struct zfcp_ls_adisc {
205205
#define ZFCP_COMMON_FLAGS 0xfff00000
206206

207207
/* common status bits */
208-
#define ZFCP_STATUS_COMMON_REMOVE 0x80000000
209208
#define ZFCP_STATUS_COMMON_RUNNING 0x40000000
210209
#define ZFCP_STATUS_COMMON_ERP_FAILED 0x20000000
211210
#define ZFCP_STATUS_COMMON_UNBLOCKED 0x10000000

drivers/s390/scsi/zfcp_erp.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ static struct zfcp_erp_action *zfcp_erp_setup_act(int need,
174174

175175
switch (need) {
176176
case ZFCP_ERP_ACTION_REOPEN_UNIT:
177-
get_device(&unit->sysfs_device);
177+
if (!get_device(&unit->sysfs_device))
178+
return NULL;
178179
atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &unit->status);
179180
erp_action = &unit->erp_action;
180181
if (!(atomic_read(&unit->status) & ZFCP_STATUS_COMMON_RUNNING))
@@ -183,7 +184,8 @@ static struct zfcp_erp_action *zfcp_erp_setup_act(int need,
183184

184185
case ZFCP_ERP_ACTION_REOPEN_PORT:
185186
case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
186-
get_device(&port->sysfs_device);
187+
if (!get_device(&port->sysfs_device))
188+
return NULL;
187189
zfcp_erp_action_dismiss_port(port);
188190
atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &port->status);
189191
erp_action = &port->erp_action;

drivers/s390/scsi/zfcp_fc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,6 @@ static void zfcp_fc_validate_port(struct zfcp_port *port, struct list_head *lh)
589589
!list_empty(&port->unit_list))
590590
return;
591591

592-
atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &port->status);
593592
list_move_tail(&port->list, lh);
594593
}
595594

drivers/s390/scsi/zfcp_sysfs.c

Lines changed: 22 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,8 @@ static ssize_t zfcp_sysfs_##_feat##_failed_store(struct device *dev, \
104104
unsigned long val; \
105105
int retval = 0; \
106106
\
107-
if (atomic_read(&_feat->status) & ZFCP_STATUS_COMMON_REMOVE) { \
108-
retval = -EBUSY; \
109-
goto out; \
110-
} \
107+
if (!(_feat && get_device(&_feat->sysfs_device))) \
108+
return -EBUSY; \
111109
\
112110
if (strict_strtoul(buf, 0, &val) || val != 0) { \
113111
retval = -EINVAL; \
@@ -120,6 +118,7 @@ static ssize_t zfcp_sysfs_##_feat##_failed_store(struct device *dev, \
120118
_reopen_id, NULL); \
121119
zfcp_erp_wait(_adapter); \
122120
out: \
121+
put_device(&_feat->sysfs_device); \
123122
return retval ? retval : (ssize_t) count; \
124123
} \
125124
static ZFCP_DEV_ATTR(_feat, failed, S_IWUSR | S_IRUGO, \
@@ -161,11 +160,6 @@ static ssize_t zfcp_sysfs_adapter_failed_store(struct device *dev,
161160
if (!adapter)
162161
return -ENODEV;
163162

164-
if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_REMOVE) {
165-
retval = -EBUSY;
166-
goto out;
167-
}
168-
169163
if (strict_strtoul(buf, 0, &val) || val != 0) {
170164
retval = -EINVAL;
171165
goto out;
@@ -195,14 +189,9 @@ static ssize_t zfcp_sysfs_port_rescan_store(struct device *dev,
195189
if (!adapter)
196190
return -ENODEV;
197191

198-
if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_REMOVE) {
199-
ret = -EBUSY;
200-
goto out;
201-
}
202-
203192
ret = zfcp_fc_scan_ports(adapter);
204-
out:
205193
zfcp_ccw_adapter_put(adapter);
194+
206195
return ret ? ret : (ssize_t) count;
207196
}
208197
static ZFCP_DEV_ATTR(adapter, port_rescan, S_IWUSR, NULL,
@@ -216,28 +205,19 @@ static ssize_t zfcp_sysfs_port_remove_store(struct device *dev,
216205
struct zfcp_adapter *adapter = zfcp_ccw_adapter_by_cdev(cdev);
217206
struct zfcp_port *port;
218207
u64 wwpn;
219-
int retval = 0;
208+
int retval = -EINVAL;
220209

221210
if (!adapter)
222211
return -ENODEV;
223212

224-
if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_REMOVE) {
225-
retval = -EBUSY;
213+
if (strict_strtoull(buf, 0, (unsigned long long *) &wwpn))
226214
goto out;
227-
}
228-
229-
if (strict_strtoull(buf, 0, (unsigned long long *) &wwpn)) {
230-
retval = -EINVAL;
231-
goto out;
232-
}
233215

234216
port = zfcp_get_port_by_wwpn(adapter, wwpn);
235-
if (!port) {
236-
retval = -ENXIO;
217+
if (!port)
237218
goto out;
238-
}
239-
240-
atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &port->status);
219+
else
220+
retval = 0;
241221

242222
write_lock_irq(&adapter->port_list_lock);
243223
list_del(&port->list);
@@ -283,24 +263,23 @@ static ssize_t zfcp_sysfs_unit_add_store(struct device *dev,
283263
u64 fcp_lun;
284264
int retval = -EINVAL;
285265

286-
if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_REMOVE) {
287-
retval = -EBUSY;
288-
goto out;
289-
}
266+
if (!(port && get_device(&port->sysfs_device)))
267+
return -EBUSY;
290268

291269
if (strict_strtoull(buf, 0, (unsigned long long *) &fcp_lun))
292270
goto out;
293271

294272
unit = zfcp_unit_enqueue(port, fcp_lun);
295273
if (IS_ERR(unit))
296274
goto out;
297-
298-
retval = 0;
275+
else
276+
retval = 0;
299277

300278
zfcp_erp_unit_reopen(unit, 0, "syuas_1", NULL);
301279
zfcp_erp_wait(unit->port->adapter);
302280
flush_work(&unit->scsi_work);
303281
out:
282+
put_device(&port->sysfs_device);
304283
return retval ? retval : (ssize_t) count;
305284
}
306285
static DEVICE_ATTR(unit_add, S_IWUSR, NULL, zfcp_sysfs_unit_add_store);
@@ -313,29 +292,23 @@ static ssize_t zfcp_sysfs_unit_remove_store(struct device *dev,
313292
sysfs_device);
314293
struct zfcp_unit *unit;
315294
u64 fcp_lun;
316-
int retval = 0;
295+
int retval = -EINVAL;
317296

318-
if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_REMOVE) {
319-
retval = -EBUSY;
320-
goto out;
321-
}
297+
if (!(port && get_device(&port->sysfs_device)))
298+
return -EBUSY;
322299

323-
if (strict_strtoull(buf, 0, (unsigned long long *) &fcp_lun)) {
324-
retval = -EINVAL;
300+
if (strict_strtoull(buf, 0, (unsigned long long *) &fcp_lun))
325301
goto out;
326-
}
327302

328303
unit = zfcp_get_unit_by_lun(port, fcp_lun);
329-
if (!unit) {
330-
retval = -EINVAL;
304+
if (!unit)
331305
goto out;
332-
}
306+
else
307+
retval = 0;
333308

334309
/* wait for possible timeout during SCSI probe */
335310
flush_work(&unit->scsi_work);
336311

337-
atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &unit->status);
338-
339312
write_lock_irq(&port->unit_list_lock);
340313
list_del(&unit->list);
341314
write_unlock_irq(&port->unit_list_lock);
@@ -345,6 +318,7 @@ static ssize_t zfcp_sysfs_unit_remove_store(struct device *dev,
345318
zfcp_erp_unit_shutdown(unit, 0, "syurs_1", NULL);
346319
zfcp_device_unregister(&unit->sysfs_device, &zfcp_sysfs_unit_attrs);
347320
out:
321+
put_device(&port->sysfs_device);
348322
return retval ? retval : (ssize_t) count;
349323
}
350324
static DEVICE_ATTR(unit_remove, S_IWUSR, NULL, zfcp_sysfs_unit_remove_store);

0 commit comments

Comments
 (0)