Skip to content

Commit

Permalink
blk-mq: request deadline must be visible before marking rq as started
Browse files Browse the repository at this point in the history
When we start the request, we set the deadline and flip the bits
marking the request as started and non-complete. However, it's
important that the deadline store is ordered before flipping the
bits, otherwise we could have a small window where the request is
marked started but with an invalid deadline. This can confuse the
timeout handling.

Suggested-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
  • Loading branch information
Jens Axboe committed Sep 22, 2014
1 parent 37504a3 commit 538b753
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions block/blk-mq.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,12 @@ static void blk_mq_start_request(struct request *rq, bool last)

blk_add_timer(rq);

/*
* Ensure that ->deadline is visible before set the started
* flag and clear the completed flag.
*/
smp_mb__before_atomic();

/*
* Mark us as started and clear complete. Complete might have been
* set if requeue raced with timeout, which then marked it as
Expand Down

0 comments on commit 538b753

Please sign in to comment.