nvme_fc: replace ioabort msleep loop with completion
Subsystems (2)
PATCH 1/1 nvme_fc: replace ioabort msleep loop with completion
From: James Smart <[email protected]>
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.
--- drivers/nvme/host/fc.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/nvme/host/fc.c +11 -4
@@ -167,6 +167,7 @@ struct nvme_fc_ctrl {struct kref ref;u32 flags;u32 iocnt; +struct completion ioaborts_done;struct nvme_fc_fcp_op aen_ops[NVME_FC_NR_AEN_COMMANDS ];
@@ -1241,8 +1242,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)) +complete (&ctrl->ioaborts_done); + } }if (op->flags &FCOP_FLAGS_RELEASED ) complete_rq = true;
@@ -2488,10 +2491,14 @@ 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) { +if (ctrl->iocnt) { +init_completion (&ctrl->ioaborts_done);spin_unlock_irqrestore (&ctrl->lock, flags); -msleep (1000 ); + +wait_for_completion (&ctrl->ioaborts_done); +spin_lock_irqsave (&ctrl->lock, flags); +WARN_ON (ctrl->iocnt); } ctrl->flags &= ~FCCTRL_TERMIO ;spin_unlock_irqrestore (&ctrl->lock, flags);
Signature · 1 line
2.9.3
PATCH 1/1 nvme_fc: replace ioabort msleep loop with completion
Quoted 10 lines · On 04/26/2017 12:32 AM, [email protected] wrote:
From: James Smart <jsmart2021 at gmail.com>
Per the recommendation by Sagi on:
http://lists.infradead.org/pipermail/linux-nvme/2017-April/009261.htmlWait for io aborts to complete wait converted from msleep look to using a struct completion.
Signed-off-by James Smart <james.smart at broadcom.com>---
Looks good,
Reviewed-by: Johannes Thumshirn <jthumshirn at suse.de>
Signature · 6 lines
Johannes Thumshirn Storage jthumshirn at suse.de +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg GF: Felix Imend?rffer, Jane Smithard, Graham Norton HRB 21284 (AG N?rnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
PATCH 1/1 nvme_fc: replace ioabort msleep loop with completion
In reply to [email protected]drivers/nvme/host/fc.c __nvme_fc_fcpop_chk_teardowns(struct nvme_fc_ctrl *ctrl, · line 1246
Quoted 1 line
drivers/nvme/host/fc.c +1
-0+if (!(--ctrl->iocnt))
No need for the inner braces here.
drivers/nvme/host/fc.c nvme_fc_delete_association(struct nvme_fc_ctrl *ctrl) · line 2501
Quoted 10 lines
drivers/nvme/host/fc.c +6
-2-while (ctrl->iocnt) { +if (ctrl->iocnt) { +init_completion (&ctrl->ioaborts_done);spin_unlock_irqrestore (&ctrl->lock, flags); -msleep (1000 ); + +wait_for_completion (&ctrl->ioaborts_done); +spin_lock_irqsave (&ctrl->lock, flags); +WARN_ON (ctrl->iocnt);
But more importantly the single wait is potentially wrong. Please switch to a waitqueue and use wait_event_lock_irq here.
PATCH 1/1 nvme_fc: replace ioabort msleep loop with completion
Quoted 5 lines · Christoph Hellwig
Quoted 5 lines
drivers/nvme/host/fc.c +2
-2-while (ctrl->iocnt) { +if (ctrl->iocnt) { +init_completion (&ctrl->ioaborts_done);spin_unlock_irqrestore (&ctrl->lock, flags); -msleep (1000 );
Quoted 9 lines
drivers/nvme/host/fc.c nvme_fc_delete_association(struct nvme_fc_ctrl *ctrl) · line 2501
Quoted 5 lines
drivers/nvme/host/fc.c +4
-0+ +wait_for_completion (&ctrl->ioaborts_done); +spin_lock_irqsave (&ctrl->lock, flags); +WARN_ON (ctrl->iocnt);But more importantly the single wait is potentially wrong. Please switch to a waitqueue and use
wait_event_lock_irqhere.
Why do you think a single wait is wrong ?
All aborts have been scheduled, which is what ctrl->iocnt tracks, and will not increase. Thus ctrl->iocnt is set to its max prior to init'ing the completion and releasing the lock. The completion only triggers on decrement of ctrl->iocnt to zero checked under lock.
-- james