diff mbox

[4/6] blk-mq: make blk_abort_request() trigger timeout path

Message ID 20171212190134.535941-5-tj@kernel.org (mailing list archive)
State New, archived
Headers show

Commit Message

Tejun Heo Dec. 12, 2017, 7:01 p.m. UTC
With issue/complete and timeout paths now using the generation number
and state based synchronization, blk_abort_request() is the only one
which depends on REQ_ATOM_COMPLETE for arbitrating completion.

There's no reason for blk_abort_request() to be a completely separate
path.  This patch makes blk_abort_request() piggyback on the timeout
path instead of trying to terminate the request directly.

This removes the last dependency on REQ_ATOM_COMPLETE in blk-mq.

Signed-off-by: Tejun Heo <tj@kernel.org>
---
 block/blk-mq.c      | 2 +-
 block/blk-mq.h      | 2 --
 block/blk-timeout.c | 7 ++++---
 3 files changed, 5 insertions(+), 6 deletions(-)

Comments

Bart Van Assche Dec. 14, 2017, 6:56 p.m. UTC | #1
On Tue, 2017-12-12 at 11:01 -0800, Tejun Heo wrote:
>  void blk_abort_request(struct request *req)

>  {

> -	if (blk_mark_rq_complete(req))

> -		return;

>  

>  	if (req->q->mq_ops) {

> -		blk_mq_rq_timed_out(req, false);

> +		req->deadline = jiffies;

> +		mod_timer(&req->q->timeout, 0);

>  	} else {

> +		if (blk_mark_rq_complete(req))

> +			return;

>  		blk_delete_timer(req);

>  		blk_rq_timed_out(req);

>  	}


This patch makes blk_abort_request() asynchronous for blk-mq. Have all callers
been audited to verify whether this change is safe?

Thanks,

Bart.
Tejun Heo Dec. 14, 2017, 7:26 p.m. UTC | #2
Hello,

On Thu, Dec 14, 2017 at 06:56:55PM +0000, Bart Van Assche wrote:
> On Tue, 2017-12-12 at 11:01 -0800, Tejun Heo wrote:
> >  void blk_abort_request(struct request *req)
> >  {
> > -	if (blk_mark_rq_complete(req))
> > -		return;
> >  
> >  	if (req->q->mq_ops) {
> > -		blk_mq_rq_timed_out(req, false);
> > +		req->deadline = jiffies;
> > +		mod_timer(&req->q->timeout, 0);
> >  	} else {
> > +		if (blk_mark_rq_complete(req))
> > +			return;
> >  		blk_delete_timer(req);
> >  		blk_rq_timed_out(req);
> >  	}
> 
> This patch makes blk_abort_request() asynchronous for blk-mq. Have all callers
> been audited to verify whether this change is safe?

I *think* so.  For all the ata related parts, I know they're.
mtip32xx and dasd_ioctl, it seems safe, but I can't tell for sure.
Will cc the respective maintainers on the next posting.

Thanks.
diff mbox

Patch

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 3a08d7a..73d6444 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -785,7 +785,7 @@  struct blk_mq_timeout_data {
 	unsigned int nr_expired;
 };
 
-void blk_mq_rq_timed_out(struct request *req, bool reserved)
+static void blk_mq_rq_timed_out(struct request *req, bool reserved)
 {
 	const struct blk_mq_ops *ops = req->q->mq_ops;
 	enum blk_eh_timer_return ret = BLK_EH_RESET_TIMER;
diff --git a/block/blk-mq.h b/block/blk-mq.h
index 154b2fa..1fa83fa 100644
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -94,8 +94,6 @@  extern int blk_mq_sysfs_register(struct request_queue *q);
 extern void blk_mq_sysfs_unregister(struct request_queue *q);
 extern void blk_mq_hctx_kobj_init(struct blk_mq_hw_ctx *hctx);
 
-extern void blk_mq_rq_timed_out(struct request *req, bool reserved);
-
 void blk_mq_release(struct request_queue *q);
 
 /**
diff --git a/block/blk-timeout.c b/block/blk-timeout.c
index 6427be7..051924f 100644
--- a/block/blk-timeout.c
+++ b/block/blk-timeout.c
@@ -156,12 +156,13 @@  void blk_timeout_work(struct work_struct *work)
  */
 void blk_abort_request(struct request *req)
 {
-	if (blk_mark_rq_complete(req))
-		return;
 
 	if (req->q->mq_ops) {
-		blk_mq_rq_timed_out(req, false);
+		req->deadline = jiffies;
+		mod_timer(&req->q->timeout, 0);
 	} else {
+		if (blk_mark_rq_complete(req))
+			return;
 		blk_delete_timer(req);
 		blk_rq_timed_out(req);
 	}