Linux block layer
 help / color / mirror / Atom feed
* [PATCH] blk-mq: only iterate over inflight requests in blk_mq_tagset_busy_iter
@ 2018-05-30 16:51 Christoph Hellwig
  2018-05-30 17:27 ` Josef Bacik
  2018-05-30 17:32 ` Jens Axboe
  0 siblings, 2 replies; 3+ messages in thread
From: Christoph Hellwig @ 2018-05-30 16:51 UTC (permalink / raw)
  To: axboe; +Cc: keith.busch, josef, linux-block, linux-nvme

We already check for started commands in all callbacks, but we should
also protect against already completed commands.  Do this by taking
the checks to common code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-mq-tag.c                |  2 +-
 drivers/block/mtip32xx/mtip32xx.c | 12 ++----------
 drivers/block/nbd.c               |  5 +----
 drivers/nvme/host/core.c          |  3 ---
 drivers/nvme/host/fc.c            |  3 ---
 5 files changed, 4 insertions(+), 21 deletions(-)

diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
index a4e58fc28a06..70356a2a11ab 100644
--- a/block/blk-mq-tag.c
+++ b/block/blk-mq-tag.c
@@ -271,7 +271,7 @@ static bool bt_tags_iter(struct sbitmap *bitmap, unsigned int bitnr, void *data)
 	 * test and set the bit before assining ->rqs[].
 	 */
 	rq = tags->rqs[bitnr];
-	if (rq)
+	if (rq && blk_mq_rq_state(rq) == MQ_RQ_IN_FLIGHT)
 		iter_data->fn(rq, iter_data->data, reserved);
 
 	return true;
diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index 95657b814543..c73626decb46 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -2725,15 +2725,11 @@ static void mtip_softirq_done_fn(struct request *rq)
 	blk_mq_end_request(rq, cmd->status);
 }
 
-static void mtip_abort_cmd(struct request *req, void *data,
-							bool reserved)
+static void mtip_abort_cmd(struct request *req, void *data, bool reserved)
 {
 	struct mtip_cmd *cmd = blk_mq_rq_to_pdu(req);
 	struct driver_data *dd = data;
 
-	if (!blk_mq_request_started(req))
-		return;
-
 	dbg_printk(MTIP_DRV_NAME " Aborting request, tag = %d\n", req->tag);
 
 	clear_bit(req->tag, dd->port->cmds_to_issue);
@@ -2741,14 +2737,10 @@ static void mtip_abort_cmd(struct request *req, void *data,
 	mtip_softirq_done_fn(req);
 }
 
-static void mtip_queue_cmd(struct request *req, void *data,
-							bool reserved)
+static void mtip_queue_cmd(struct request *req, void *data, bool reserved)
 {
 	struct driver_data *dd = data;
 
-	if (!blk_mq_request_started(req))
-		return;
-
 	set_bit(req->tag, dd->port->cmds_to_issue);
 	blk_abort_request(req);
 }
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 8860b24098bc..17d1d97d491e 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -666,11 +666,8 @@ static void recv_work(struct work_struct *work)
 
 static void nbd_clear_req(struct request *req, void *data, bool reserved)
 {
-	struct nbd_cmd *cmd;
+	struct nbd_cmd *cmd = blk_mq_rq_to_pdu(req);
 
-	if (!blk_mq_request_started(req))
-		return;
-	cmd = blk_mq_rq_to_pdu(req);
 	cmd->status = BLK_STS_IOERR;
 	blk_mq_complete_request(req);
 }
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 7ad3cfc9d4e1..1744d8dcadfd 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -251,9 +251,6 @@ EXPORT_SYMBOL_GPL(nvme_complete_rq);
 
 void nvme_cancel_request(struct request *req, void *data, bool reserved)
 {
-	if (!blk_mq_request_started(req))
-		return;
-
 	dev_dbg_ratelimited(((struct nvme_ctrl *) data)->device,
 				"Cancelling I/O %d", req->tag);
 
diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index ac35a80f5532..0bad65803271 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -2393,9 +2393,6 @@ nvme_fc_terminate_exchange(struct request *req, void *data, bool reserved)
 	struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl);
 	struct nvme_fc_fcp_op *op = blk_mq_rq_to_pdu(req);
 
-	if (!blk_mq_request_started(req))
-		return;
-
 	__nvme_fc_abort_op(ctrl, op);
 }
 
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] blk-mq: only iterate over inflight requests in blk_mq_tagset_busy_iter
  2018-05-30 16:51 [PATCH] blk-mq: only iterate over inflight requests in blk_mq_tagset_busy_iter Christoph Hellwig
@ 2018-05-30 17:27 ` Josef Bacik
  2018-05-30 17:32 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Josef Bacik @ 2018-05-30 17:27 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: axboe, keith.busch, josef, linux-block, linux-nvme

On Wed, May 30, 2018 at 06:51:00PM +0200, Christoph Hellwig wrote:
> We already check for started commands in all callbacks, but we should
> also protect against already completed commands.  Do this by taking
> the checks to common code.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Acked-by: Josef Bacik <josef@toxicpanda.com>

for the nbd portion.  Thanks,

Josef

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] blk-mq: only iterate over inflight requests in blk_mq_tagset_busy_iter
  2018-05-30 16:51 [PATCH] blk-mq: only iterate over inflight requests in blk_mq_tagset_busy_iter Christoph Hellwig
  2018-05-30 17:27 ` Josef Bacik
@ 2018-05-30 17:32 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2018-05-30 17:32 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: keith.busch, josef, linux-block, linux-nvme

On 5/30/18 10:51 AM, Christoph Hellwig wrote:
> We already check for started commands in all callbacks, but we should
> also protect against already completed commands.  Do this by taking
> the checks to common code.

Looks good, applied.

-- 
Jens Axboe

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-05-30 17:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-30 16:51 [PATCH] blk-mq: only iterate over inflight requests in blk_mq_tagset_busy_iter Christoph Hellwig
2018-05-30 17:27 ` Josef Bacik
2018-05-30 17:32 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox