nvmet-fc: perform small cleanups on unneeded checks
authorJames Smart <jsmart2021@gmail.com>
Tue, 31 Mar 2020 16:49:56 +0000 (09:49 -0700)
committerJens Axboe <axboe@kernel.dk>
Sat, 9 May 2020 22:18:34 +0000 (16:18 -0600)
While code reviewing saw a couple of items that can be cleaned up:
- In nvmet_fc_delete_target_queue(), the routine unlocks, then checks
  and relocks.  Reorganize to avoid the unlock/relock.
- In nvmet_fc_delete_target_queue(), there's a check on the disconnect
  state that is unnecessary as the routine validates the state before
  starting any action.

Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/nvme/target/fc.c

index a91c443..01488fc 100644 (file)
@@ -677,7 +677,7 @@ nvmet_fc_delete_target_queue(struct nvmet_fc_tgt_queue *queue)
        struct nvmet_fc_fcp_iod *fod = queue->fod;
        struct nvmet_fc_defer_fcp_req *deferfcp, *tempptr;
        unsigned long flags;
-       int i, writedataactive;
+       int i;
        bool disconnect;
 
        disconnect = atomic_xchg(&queue->connected, 0);
@@ -688,20 +688,18 @@ nvmet_fc_delete_target_queue(struct nvmet_fc_tgt_queue *queue)
                if (fod->active) {
                        spin_lock(&fod->flock);
                        fod->abort = true;
-                       writedataactive = fod->writedataactive;
-                       spin_unlock(&fod->flock);
                        /*
                         * only call lldd abort routine if waiting for
                         * writedata. other outstanding ops should finish
                         * on their own.
                         */
-                       if (writedataactive) {
-                               spin_lock(&fod->flock);
+                       if (fod->writedataactive) {
                                fod->aborted = true;
                                spin_unlock(&fod->flock);
                                tgtport->ops->fcp_abort(
                                        &tgtport->fc_target_port, fod->fcpreq);
-                       }
+                       } else
+                               spin_unlock(&fod->flock);
                }
        }
 
@@ -741,8 +739,7 @@ nvmet_fc_delete_target_queue(struct nvmet_fc_tgt_queue *queue)
 
        flush_workqueue(queue->work_q);
 
-       if (disconnect)
-               nvmet_sq_destroy(&queue->nvme_sq);
+       nvmet_sq_destroy(&queue->nvme_sq);
 
        nvmet_fc_tgt_q_put(queue);
 }