linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] blk-mq: include errors in did_work calculation
@ 2017-03-24 17:39 Jens Axboe
  2017-03-24 17:57 ` Josef Bacik
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jens Axboe @ 2017-03-24 17:39 UTC (permalink / raw)
  To: linux-block

Currently we return true in blk_mq_dispatch_rq_list() if we queued IO
successfully, but we really want to return whether or not the we made
progress. Progress includes if we got an error return.  If we don't,
this can lead to a hang in blk_mq_sched_dispatch_requests() when a
driver is draining IO by returning BLK_MQ_QUEUE_ERROR instead of
manually ending the IO in error and return BLK_MQ_QUEUE_OK.

Signed-off-by: Jens Axboe <axboe@fb.com>

diff --git a/block/blk-mq.c b/block/blk-mq.c
index a4546f060e80..e3b09abf9d5b 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -978,7 +978,7 @@ bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list)
 	struct request *rq;
 	LIST_HEAD(driver_list);
 	struct list_head *dptr;
-	int queued, ret = BLK_MQ_RQ_QUEUE_OK;
+	int errors, queued, ret = BLK_MQ_RQ_QUEUE_OK;
 
 	/*
 	 * Start off with dptr being NULL, so we start the first request
@@ -989,7 +989,7 @@ bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list)
 	/*
 	 * Now process all the entries, sending them to the driver.
 	 */
-	queued = 0;
+	errors = queued = 0;
 	while (!list_empty(list)) {
 		struct blk_mq_queue_data bd;
 
@@ -1046,6 +1046,7 @@ bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list)
 		default:
 			pr_err("blk-mq: bad return on queue: %d\n", ret);
 		case BLK_MQ_RQ_QUEUE_ERROR:
+			errors++;
 			rq->errors = -EIO;
 			blk_mq_end_request(rq, rq->errors);
 			break;
@@ -1097,7 +1098,7 @@ bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list)
 			blk_mq_run_hw_queue(hctx, true);
 	}
 
-	return queued != 0;
+	return (queued + errors) != 0;
 }
 
 static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx)

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

* Re: [PATCH] blk-mq: include errors in did_work calculation
  2017-03-24 17:39 [PATCH] blk-mq: include errors in did_work calculation Jens Axboe
@ 2017-03-24 17:57 ` Josef Bacik
  2017-03-24 18:01 ` Bart Van Assche
  2017-03-24 18:03 ` Omar Sandoval
  2 siblings, 0 replies; 4+ messages in thread
From: Josef Bacik @ 2017-03-24 17:57 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block


> On Mar 24, 2017, at 1:39 PM, Jens Axboe <axboe@kernel.dk> wrote:
>=20
> Currently we return true in blk_mq_dispatch_rq_list() if we queued IO
> successfully, but we really want to return whether or not the we made
> progress. Progress includes if we got an error return.  If we don't,
> this can lead to a hang in blk_mq_sched_dispatch_requests() when a
> driver is draining IO by returning BLK_MQ_QUEUE_ERROR instead of
> manually ending the IO in error and return BLK_MQ_QUEUE_OK.
>=20
> Signed-off-by: Jens Axboe <axboe@fb.com>
>=20
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index a4546f060e80..e3b09abf9d5b 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -978,7 +978,7 @@ bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx =
*hctx, struct list_head *list)
> 	struct request *rq;
> 	LIST_HEAD(driver_list);
> 	struct list_head *dptr;
> -	int queued, ret =3D BLK_MQ_RQ_QUEUE_OK;
> +	int errors, queued, ret =3D BLK_MQ_RQ_QUEUE_OK;
>=20
> 	/*
> 	 * Start off with dptr being NULL, so we start the first request
> @@ -989,7 +989,7 @@ bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx =
*hctx, struct list_head *list)
> 	/*
> 	 * Now process all the entries, sending them to the driver.
> 	 */
> -	queued =3D 0;
> +	errors =3D queued =3D 0;
> 	while (!list_empty(list)) {
> 		struct blk_mq_queue_data bd;
>=20
> @@ -1046,6 +1046,7 @@ bool blk_mq_dispatch_rq_list(struct =
blk_mq_hw_ctx *hctx, struct list_head *list)
> 		default:
> 			pr_err("blk-mq: bad return on queue: %d\n", =
ret);
> 		case BLK_MQ_RQ_QUEUE_ERROR:
> +			errors++;
> 			rq->errors =3D -EIO;
> 			blk_mq_end_request(rq, rq->errors);
> 			break;
> @@ -1097,7 +1098,7 @@ bool blk_mq_dispatch_rq_list(struct =
blk_mq_hw_ctx *hctx, struct list_head *list)
> 			blk_mq_run_hw_queue(hctx, true);
> 	}
>=20
> -	return queued !=3D 0;
> +	return (queued + errors) !=3D 0;
> }
>=20
> static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx)
>=20

Thanks this fixed it, you can add

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

Thanks,

Josef=

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

* Re: [PATCH] blk-mq: include errors in did_work calculation
  2017-03-24 17:39 [PATCH] blk-mq: include errors in did_work calculation Jens Axboe
  2017-03-24 17:57 ` Josef Bacik
@ 2017-03-24 18:01 ` Bart Van Assche
  2017-03-24 18:03 ` Omar Sandoval
  2 siblings, 0 replies; 4+ messages in thread
From: Bart Van Assche @ 2017-03-24 18:01 UTC (permalink / raw)
  To: linux-block, axboe

On Fri, 2017-03-24 at 11:39 -0600, Jens Axboe wrote:
> Currently we return true in blk_mq_dispatch_rq_list() if we queued IO
> successfully, but we really want to return whether or not the we made
> progress. Progress includes if we got an error return.  If we don't,
> this can lead to a hang in blk_mq_sched_dispatch_requests() when a
> driver is draining IO by returning BLK_MQ_QUEUE_ERROR instead of
> manually ending the IO in error and return BLK_MQ_QUEUE_OK.

Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>=

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

* Re: [PATCH] blk-mq: include errors in did_work calculation
  2017-03-24 17:39 [PATCH] blk-mq: include errors in did_work calculation Jens Axboe
  2017-03-24 17:57 ` Josef Bacik
  2017-03-24 18:01 ` Bart Van Assche
@ 2017-03-24 18:03 ` Omar Sandoval
  2 siblings, 0 replies; 4+ messages in thread
From: Omar Sandoval @ 2017-03-24 18:03 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block

On Fri, Mar 24, 2017 at 11:39:10AM -0600, Jens Axboe wrote:
> Currently we return true in blk_mq_dispatch_rq_list() if we queued IO
> successfully, but we really want to return whether or not the we made
> progress. Progress includes if we got an error return.  If we don't,
> this can lead to a hang in blk_mq_sched_dispatch_requests() when a
> driver is draining IO by returning BLK_MQ_QUEUE_ERROR instead of
> manually ending the IO in error and return BLK_MQ_QUEUE_OK.
> 
> Signed-off-by: Jens Axboe <axboe@fb.com>

Reviewed-by: Omar Sandoval <osandov@fb.com>

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

end of thread, other threads:[~2017-03-24 18:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-24 17:39 [PATCH] blk-mq: include errors in did_work calculation Jens Axboe
2017-03-24 17:57 ` Josef Bacik
2017-03-24 18:01 ` Bart Van Assche
2017-03-24 18:03 ` Omar Sandoval

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).