Skip to content

Commit 358f70d

Browse files
htejunaxboe
authored andcommitted
blk-mq: make blk_abort_request() trigger timeout path
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. Note that this makes blk_abort_request() asynchronous - it initiates abortion but the actual termination will happen after a short while, even when the caller owns the request. AFAICS, SCSI and ATA should be fine with that and I think mtip32xx and dasd should be safe but not completely sure. It'd be great if people who know the drivers take a look. v2: - Add comment explaining the lack of synchronization around ->deadline update as requested by Bart. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Asai Thambi SP <asamymuthupa@micron.com> Cc: Stefan Haberland <sth@linux.vnet.ibm.com> Cc: Jan Hoeppner <hoeppner@linux.vnet.ibm.com> Cc: Bart Van Assche <Bart.VanAssche@wdc.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 67818d2 commit 358f70d

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

‎block/blk-mq.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ struct blk_mq_timeout_data {
820820
unsigned int nr_expired;
821821
};
822822

823-
void blk_mq_rq_timed_out(struct request *req, bool reserved)
823+
static void blk_mq_rq_timed_out(struct request *req, bool reserved)
824824
{
825825
const struct blk_mq_ops *ops = req->q->mq_ops;
826826
enum blk_eh_timer_return ret = BLK_EH_RESET_TIMER;

‎block/blk-mq.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ extern int blk_mq_sysfs_register(struct request_queue *q);
9494
extern void blk_mq_sysfs_unregister(struct request_queue *q);
9595
extern void blk_mq_hctx_kobj_init(struct blk_mq_hw_ctx *hctx);
9696

97-
extern void blk_mq_rq_timed_out(struct request *req, bool reserved);
98-
9997
void blk_mq_release(struct request_queue *q);
10098

10199
/**

‎block/blk-timeout.c‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,17 @@ void blk_timeout_work(struct work_struct *work)
156156
*/
157157
void blk_abort_request(struct request *req)
158158
{
159-
if (blk_mark_rq_complete(req))
160-
return;
161-
162159
if (req->q->mq_ops) {
163-
blk_mq_rq_timed_out(req, false);
160+
/*
161+
* All we need to ensure is that timeout scan takes place
162+
* immediately and that scan sees the new timeout value.
163+
* No need for fancy synchronizations.
164+
*/
165+
req->deadline = jiffies;
166+
mod_timer(&req->q->timeout, 0);
164167
} else {
168+
if (blk_mark_rq_complete(req))
169+
return;
165170
blk_delete_timer(req);
166171
blk_rq_timed_out(req);
167172
}

0 commit comments

Comments
 (0)