Linux block layer
 help / color / mirror / Atom feed
* [PATCH 0/2] null_blk fix and cleanup
@ 2023-03-14  4:11 Damien Le Moal
  2023-03-14  4:11 ` [PATCH 1/2] block: null_blk: Fix handling of fake timeout request Damien Le Moal
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Damien Le Moal @ 2023-03-14  4:11 UTC (permalink / raw)
  To: Jens Axboe, linux-block; +Cc: Akinobu Mita

Patch 1 is the rewritten fix from Akinobu to correct handling of fake
timeouts. The second patch is a small cleanup of the null_queue_rq()
function without any functional change.

Damien Le Moal (2):
  block: null_blk: Fix handling of fake timeout request
  block: null_blk: cleanup null_queue_rq()

 drivers/block/null_blk/main.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

-- 
2.39.2


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

* [PATCH 1/2] block: null_blk: Fix handling of fake timeout request
  2023-03-14  4:11 [PATCH 0/2] null_blk fix and cleanup Damien Le Moal
@ 2023-03-14  4:11 ` Damien Le Moal
  2023-03-15  8:54   ` Johannes Thumshirn
  2023-03-14  4:11 ` [PATCH 2/2] block: null_blk: cleanup null_queue_rq() Damien Le Moal
  2023-03-15 12:51 ` [PATCH 0/2] null_blk fix and cleanup Jens Axboe
  2 siblings, 1 reply; 7+ messages in thread
From: Damien Le Moal @ 2023-03-14  4:11 UTC (permalink / raw)
  To: Jens Axboe, linux-block; +Cc: Akinobu Mita

When injecting a fake timeout into the null_blk driver using
fail_io_timeout, the request timeout handler does not execute
blk_mq_complete_request(), so the complete callback is never executed
for a timedout request.

The null_blk driver also has a driver-specific fake timeout mechanism
which does not have this problem. Fix the problem with fail_io_timeout
by using the same meachanism as null_blk internal timeout feature, using
the fake_timeout field of null_blk commands.

Reported-by: Akinobu Mita <akinobu.mita@gmail.com>
Fixes: de3510e52b0a ("null_blk: fix command timeout completion handling")
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
---
 drivers/block/null_blk/main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index 4c601ca9552a..7d95ad203c97 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -1413,8 +1413,7 @@ static inline void nullb_complete_cmd(struct nullb_cmd *cmd)
 	case NULL_IRQ_SOFTIRQ:
 		switch (cmd->nq->dev->queue_mode) {
 		case NULL_Q_MQ:
-			if (likely(!blk_should_fake_timeout(cmd->rq->q)))
-				blk_mq_complete_request(cmd->rq);
+			blk_mq_complete_request(cmd->rq);
 			break;
 		case NULL_Q_BIO:
 			/*
@@ -1675,7 +1674,8 @@ static blk_status_t null_queue_rq(struct blk_mq_hw_ctx *hctx,
 	cmd->rq = bd->rq;
 	cmd->error = BLK_STS_OK;
 	cmd->nq = nq;
-	cmd->fake_timeout = should_timeout_request(bd->rq);
+	cmd->fake_timeout = should_timeout_request(bd->rq) ||
+		blk_should_fake_timeout(bd->rq->q);
 
 	blk_mq_start_request(bd->rq);
 
-- 
2.39.2


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

* [PATCH 2/2] block: null_blk: cleanup null_queue_rq()
  2023-03-14  4:11 [PATCH 0/2] null_blk fix and cleanup Damien Le Moal
  2023-03-14  4:11 ` [PATCH 1/2] block: null_blk: Fix handling of fake timeout request Damien Le Moal
@ 2023-03-14  4:11 ` Damien Le Moal
  2023-03-14  9:51   ` Pankaj Raghav
  2023-03-15  8:53   ` Johannes Thumshirn
  2023-03-15 12:51 ` [PATCH 0/2] null_blk fix and cleanup Jens Axboe
  2 siblings, 2 replies; 7+ messages in thread
From: Damien Le Moal @ 2023-03-14  4:11 UTC (permalink / raw)
  To: Jens Axboe, linux-block; +Cc: Akinobu Mita

Use a local struct request pointer variable to avoid having to
dereference struct blk_mq_queue_data multiple times. While at it, also
fix the function argument indentation and remove a useless "else" after
a return.

Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
---
 drivers/block/null_blk/main.c | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index 7d95ad203c97..9e6b032c8ecc 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -1657,12 +1657,13 @@ static enum blk_eh_timer_return null_timeout_rq(struct request *rq)
 }
 
 static blk_status_t null_queue_rq(struct blk_mq_hw_ctx *hctx,
-			 const struct blk_mq_queue_data *bd)
+				  const struct blk_mq_queue_data *bd)
 {
-	struct nullb_cmd *cmd = blk_mq_rq_to_pdu(bd->rq);
+	struct request *rq = bd->rq;
+	struct nullb_cmd *cmd = blk_mq_rq_to_pdu(rq);
 	struct nullb_queue *nq = hctx->driver_data;
-	sector_t nr_sectors = blk_rq_sectors(bd->rq);
-	sector_t sector = blk_rq_pos(bd->rq);
+	sector_t nr_sectors = blk_rq_sectors(rq);
+	sector_t sector = blk_rq_pos(rq);
 	const bool is_poll = hctx->type == HCTX_TYPE_POLL;
 
 	might_sleep_if(hctx->flags & BLK_MQ_F_BLOCKING);
@@ -1671,15 +1672,15 @@ static blk_status_t null_queue_rq(struct blk_mq_hw_ctx *hctx,
 		hrtimer_init(&cmd->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 		cmd->timer.function = null_cmd_timer_expired;
 	}
-	cmd->rq = bd->rq;
+	cmd->rq = rq;
 	cmd->error = BLK_STS_OK;
 	cmd->nq = nq;
-	cmd->fake_timeout = should_timeout_request(bd->rq) ||
-		blk_should_fake_timeout(bd->rq->q);
+	cmd->fake_timeout = should_timeout_request(rq) ||
+		blk_should_fake_timeout(rq->q);
 
-	blk_mq_start_request(bd->rq);
+	blk_mq_start_request(rq);
 
-	if (should_requeue_request(bd->rq)) {
+	if (should_requeue_request(rq)) {
 		/*
 		 * Alternate between hitting the core BUSY path, and the
 		 * driver driven requeue path
@@ -1687,22 +1688,20 @@ static blk_status_t null_queue_rq(struct blk_mq_hw_ctx *hctx,
 		nq->requeue_selection++;
 		if (nq->requeue_selection & 1)
 			return BLK_STS_RESOURCE;
-		else {
-			blk_mq_requeue_request(bd->rq, true);
-			return BLK_STS_OK;
-		}
+		blk_mq_requeue_request(rq, true);
+		return BLK_STS_OK;
 	}
 
 	if (is_poll) {
 		spin_lock(&nq->poll_lock);
-		list_add_tail(&bd->rq->queuelist, &nq->poll_list);
+		list_add_tail(&rq->queuelist, &nq->poll_list);
 		spin_unlock(&nq->poll_lock);
 		return BLK_STS_OK;
 	}
 	if (cmd->fake_timeout)
 		return BLK_STS_OK;
 
-	return null_handle_cmd(cmd, sector, nr_sectors, req_op(bd->rq));
+	return null_handle_cmd(cmd, sector, nr_sectors, req_op(rq));
 }
 
 static void cleanup_queue(struct nullb_queue *nq)
-- 
2.39.2


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

* Re: [PATCH 2/2] block: null_blk: cleanup null_queue_rq()
  2023-03-14  4:11 ` [PATCH 2/2] block: null_blk: cleanup null_queue_rq() Damien Le Moal
@ 2023-03-14  9:51   ` Pankaj Raghav
  2023-03-15  8:53   ` Johannes Thumshirn
  1 sibling, 0 replies; 7+ messages in thread
From: Pankaj Raghav @ 2023-03-14  9:51 UTC (permalink / raw)
  To: Damien Le Moal; +Cc: Jens Axboe, linux-block, Akinobu Mita

On Tue, Mar 14, 2023 at 01:11:06PM +0900, Damien Le Moal wrote:
> Use a local struct request pointer variable to avoid having to
> dereference struct blk_mq_queue_data multiple times. While at it, also
> fix the function argument indentation and remove a useless "else" after
> a return.
> 
> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
> ---
>  drivers/block/null_blk/main.c | 29 ++++++++++++++---------------
>  1 file changed, 14 insertions(+), 15 deletions(-)

Looks good,
Reviewed-by: Pankaj Raghav <p.raghav@samsung.com>

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

* Re: [PATCH 2/2] block: null_blk: cleanup null_queue_rq()
  2023-03-14  4:11 ` [PATCH 2/2] block: null_blk: cleanup null_queue_rq() Damien Le Moal
  2023-03-14  9:51   ` Pankaj Raghav
@ 2023-03-15  8:53   ` Johannes Thumshirn
  1 sibling, 0 replies; 7+ messages in thread
From: Johannes Thumshirn @ 2023-03-15  8:53 UTC (permalink / raw)
  To: Damien Le Moal, Jens Axboe, linux-block@vger.kernel.org; +Cc: Akinobu Mita

Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

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

* Re: [PATCH 1/2] block: null_blk: Fix handling of fake timeout request
  2023-03-14  4:11 ` [PATCH 1/2] block: null_blk: Fix handling of fake timeout request Damien Le Moal
@ 2023-03-15  8:54   ` Johannes Thumshirn
  0 siblings, 0 replies; 7+ messages in thread
From: Johannes Thumshirn @ 2023-03-15  8:54 UTC (permalink / raw)
  To: Damien Le Moal, Jens Axboe, linux-block@vger.kernel.org; +Cc: Akinobu Mita

Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

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

* Re: [PATCH 0/2] null_blk fix and cleanup
  2023-03-14  4:11 [PATCH 0/2] null_blk fix and cleanup Damien Le Moal
  2023-03-14  4:11 ` [PATCH 1/2] block: null_blk: Fix handling of fake timeout request Damien Le Moal
  2023-03-14  4:11 ` [PATCH 2/2] block: null_blk: cleanup null_queue_rq() Damien Le Moal
@ 2023-03-15 12:51 ` Jens Axboe
  2 siblings, 0 replies; 7+ messages in thread
From: Jens Axboe @ 2023-03-15 12:51 UTC (permalink / raw)
  To: linux-block, Damien Le Moal; +Cc: Akinobu Mita


On Tue, 14 Mar 2023 13:11:04 +0900, Damien Le Moal wrote:
> Patch 1 is the rewritten fix from Akinobu to correct handling of fake
> timeouts. The second patch is a small cleanup of the null_queue_rq()
> function without any functional change.
> 
> Damien Le Moal (2):
>   block: null_blk: Fix handling of fake timeout request
>   block: null_blk: cleanup null_queue_rq()
> 
> [...]

Applied, thanks!

[1/2] block: null_blk: Fix handling of fake timeout request
      (no commit info)
[2/2] block: null_blk: cleanup null_queue_rq()
      (no commit info)

Best regards,
-- 
Jens Axboe




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

end of thread, other threads:[~2023-03-15 12:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-14  4:11 [PATCH 0/2] null_blk fix and cleanup Damien Le Moal
2023-03-14  4:11 ` [PATCH 1/2] block: null_blk: Fix handling of fake timeout request Damien Le Moal
2023-03-15  8:54   ` Johannes Thumshirn
2023-03-14  4:11 ` [PATCH 2/2] block: null_blk: cleanup null_queue_rq() Damien Le Moal
2023-03-14  9:51   ` Pankaj Raghav
2023-03-15  8:53   ` Johannes Thumshirn
2023-03-15 12:51 ` [PATCH 0/2] null_blk fix and cleanup Jens Axboe

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