Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cf4b50af authored by Jens Axboe's avatar Jens Axboe
Browse files

blk-mq: fix race in IO start accounting



Commit c6d600c6 opened up a small race where we could attempt to
account IO completion on a request, racing with IO start accounting.
Fix this up by ensuring that we've accounted for IO start before
inserting the request.

Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent 4bb659b1
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -1088,17 +1088,15 @@ static void blk_mq_make_request(struct request_queue *q, struct bio *bio)
	}

	if (!(hctx->flags & BLK_MQ_F_SHOULD_MERGE)) {
		init_request_from_bio(rq, bio);

		blk_mq_bio_to_request(rq, bio);
		spin_lock(&ctx->lock);
insert_rq:
		__blk_mq_insert_request(hctx, rq, false);
		spin_unlock(&ctx->lock);
		blk_account_io_start(rq, 1);
	} else {
		spin_lock(&ctx->lock);
		if (!blk_mq_attempt_merge(q, ctx, bio)) {
			init_request_from_bio(rq, bio);
			blk_mq_bio_to_request(rq, bio);
			goto insert_rq;
		}