nvme_fc: replace ioabort msleep loop with completion
authorJames Smart <jsmart2021@gmail.com>
Mon, 22 May 2017 22:28:42 +0000 (15:28 -0700)
committerJens Axboe <axboe@kernel.dk>
Wed, 28 Jun 2017 14:14:13 +0000 (08:14 -0600)
Per the recommendation by Sagi on:
http://lists.infradead.org/pipermail/linux-nvme/2017-April/009261.html

Wait for io aborts to complete wait converted from msleep look to
using a struct completion.

Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/nvme/host/fc.c

index fe6f5b71979cc5e012692a61ea91b6547105038a..cdd138c1f22330365ef960c6aa5cd17c97d81940 100644 (file)
@@ -166,6 +166,7 @@ struct nvme_fc_ctrl {
        struct kref             ref;
        u32                     flags;
        u32                     iocnt;
+       wait_queue_head_t       ioabort_wait;
 
        struct nvme_fc_fcp_op   aen_ops[NVME_FC_NR_AEN_COMMANDS];
 
@@ -1239,8 +1240,10 @@ __nvme_fc_fcpop_chk_teardowns(struct nvme_fc_ctrl *ctrl,
 
        spin_lock_irqsave(&ctrl->lock, flags);
        if (unlikely(op->flags & FCOP_FLAGS_TERMIO)) {
-               if (ctrl->flags & FCCTRL_TERMIO)
-                       ctrl->iocnt--;
+               if (ctrl->flags & FCCTRL_TERMIO) {
+                       if (!--ctrl->iocnt)
+                               wake_up(&ctrl->ioabort_wait);
+               }
        }
        if (op->flags & FCOP_FLAGS_RELEASED)
                complete_rq = true;
@@ -2476,11 +2479,7 @@ nvme_fc_delete_association(struct nvme_fc_ctrl *ctrl)
 
        /* wait for all io that had to be aborted */
        spin_lock_irqsave(&ctrl->lock, flags);
-       while (ctrl->iocnt) {
-               spin_unlock_irqrestore(&ctrl->lock, flags);
-               msleep(1000);
-               spin_lock_irqsave(&ctrl->lock, flags);
-       }
+       wait_event_lock_irq(ctrl->ioabort_wait, ctrl->iocnt == 0, ctrl->lock);
        ctrl->flags &= ~FCCTRL_TERMIO;
        spin_unlock_irqrestore(&ctrl->lock, flags);