Skip to content

Commit ece0278

Browse files
jsmart-ghChristoph Hellwig
authored andcommitted
nvmet-fc: remove redundant del_work_active flag
The transport has a del_work_active flag to avoid duplicate scheduling of the del_work item. This is redundant with the checks that schedule_work() makes. Remove the del_work_active flag. Signed-off-by: James Smart <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 34efa23 commit ece0278

File tree

1 file changed

+3
-24
lines changed
  • drivers/nvme/target

1 file changed

+3
-24
lines changed

drivers/nvme/target/fc.c

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ struct nvmet_fc_tgt_assoc {
167167
struct nvmet_fc_tgt_queue *queues[NVMET_NR_QUEUES + 1];
168168
struct kref ref;
169169
struct work_struct del_work;
170-
atomic_t del_work_active;
171170
};
172171

173172

@@ -1090,7 +1089,6 @@ nvmet_fc_delete_assoc(struct work_struct *work)
10901089
container_of(work, struct nvmet_fc_tgt_assoc, del_work);
10911090

10921091
nvmet_fc_delete_target_assoc(assoc);
1093-
atomic_set(&assoc->del_work_active, 0);
10941092
nvmet_fc_tgt_a_put(assoc);
10951093
}
10961094

@@ -1123,7 +1121,6 @@ nvmet_fc_alloc_target_assoc(struct nvmet_fc_tgtport *tgtport, void *hosthandle)
11231121
INIT_LIST_HEAD(&assoc->a_list);
11241122
kref_init(&assoc->ref);
11251123
INIT_WORK(&assoc->del_work, nvmet_fc_delete_assoc);
1126-
atomic_set(&assoc->del_work_active, 0);
11271124
atomic_set(&assoc->terminating, 0);
11281125

11291126
while (needrandom) {
@@ -1478,21 +1475,15 @@ __nvmet_fc_free_assocs(struct nvmet_fc_tgtport *tgtport)
14781475
{
14791476
struct nvmet_fc_tgt_assoc *assoc, *next;
14801477
unsigned long flags;
1481-
int ret;
14821478

14831479
spin_lock_irqsave(&tgtport->lock, flags);
14841480
list_for_each_entry_safe(assoc, next,
14851481
&tgtport->assoc_list, a_list) {
14861482
if (!nvmet_fc_tgt_a_get(assoc))
14871483
continue;
1488-
ret = atomic_cmpxchg(&assoc->del_work_active, 0, 1);
1489-
if (ret == 0) {
1490-
if (!schedule_work(&assoc->del_work))
1491-
nvmet_fc_tgt_a_put(assoc);
1492-
} else {
1484+
if (!schedule_work(&assoc->del_work))
14931485
/* already deleting - release local reference */
14941486
nvmet_fc_tgt_a_put(assoc);
1495-
}
14961487
}
14971488
spin_unlock_irqrestore(&tgtport->lock, flags);
14981489
}
@@ -1534,7 +1525,6 @@ nvmet_fc_invalidate_host(struct nvmet_fc_target_port *target_port,
15341525
struct nvmet_fc_tgt_assoc *assoc, *next;
15351526
unsigned long flags;
15361527
bool noassoc = true;
1537-
int ret;
15381528

15391529
spin_lock_irqsave(&tgtport->lock, flags);
15401530
list_for_each_entry_safe(assoc, next,
@@ -1546,14 +1536,9 @@ nvmet_fc_invalidate_host(struct nvmet_fc_target_port *target_port,
15461536
continue;
15471537
assoc->hostport->invalid = 1;
15481538
noassoc = false;
1549-
ret = atomic_cmpxchg(&assoc->del_work_active, 0, 1);
1550-
if (ret == 0) {
1551-
if (!schedule_work(&assoc->del_work))
1552-
nvmet_fc_tgt_a_put(assoc);
1553-
} else {
1539+
if (!schedule_work(&assoc->del_work))
15541540
/* already deleting - release local reference */
15551541
nvmet_fc_tgt_a_put(assoc);
1556-
}
15571542
}
15581543
spin_unlock_irqrestore(&tgtport->lock, flags);
15591544

@@ -1574,7 +1559,6 @@ nvmet_fc_delete_ctrl(struct nvmet_ctrl *ctrl)
15741559
struct nvmet_fc_tgt_queue *queue;
15751560
unsigned long flags;
15761561
bool found_ctrl = false;
1577-
int ret;
15781562

15791563
/* this is a bit ugly, but don't want to make locks layered */
15801564
spin_lock_irqsave(&nvmet_fc_tgtlock, flags);
@@ -1598,14 +1582,9 @@ nvmet_fc_delete_ctrl(struct nvmet_ctrl *ctrl)
15981582
nvmet_fc_tgtport_put(tgtport);
15991583

16001584
if (found_ctrl) {
1601-
ret = atomic_cmpxchg(&assoc->del_work_active, 0, 1);
1602-
if (ret == 0) {
1603-
if (!schedule_work(&assoc->del_work))
1604-
nvmet_fc_tgt_a_put(assoc);
1605-
} else {
1585+
if (!schedule_work(&assoc->del_work))
16061586
/* already deleting - release local reference */
16071587
nvmet_fc_tgt_a_put(assoc);
1608-
}
16091588
return;
16101589
}
16111590

0 commit comments

Comments
 (0)