Skip to content

Commit

Permalink
block: avoid to use q->flush_rq directly
Browse files Browse the repository at this point in the history
This patch trys to use local variable to access flush request,
so that we can convert to per-queue flush machinery a bit easier.

Reviewed-by: Christoph Hellwig <[email protected]>
Signed-off-by: Ming Lei <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Ming Lei authored and axboe committed Sep 25, 2014
1 parent 3c09676 commit 7ddab5d
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions block/blk-flush.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ static void flush_end_io(struct request *flush_rq, int error)

if (q->mq_ops) {
spin_lock_irqsave(&q->mq_flush_lock, flags);
q->flush_rq->tag = -1;
flush_rq->tag = -1;
}

running = &q->flush_queue[q->flush_running_idx];
Expand Down Expand Up @@ -281,6 +281,7 @@ static bool blk_kick_flush(struct request_queue *q)
struct list_head *pending = &q->flush_queue[q->flush_pending_idx];
struct request *first_rq =
list_first_entry(pending, struct request, flush.list);
struct request *flush_rq = q->flush_rq;

/* C1 described at the top of this file */
if (q->flush_pending_idx != q->flush_running_idx || list_empty(pending))
Expand All @@ -298,16 +299,16 @@ static bool blk_kick_flush(struct request_queue *q)
*/
q->flush_pending_idx ^= 1;

blk_rq_init(q, q->flush_rq);
blk_rq_init(q, flush_rq);
if (q->mq_ops)
blk_mq_clone_flush_request(q->flush_rq, first_rq);
blk_mq_clone_flush_request(flush_rq, first_rq);

q->flush_rq->cmd_type = REQ_TYPE_FS;
q->flush_rq->cmd_flags = WRITE_FLUSH | REQ_FLUSH_SEQ;
q->flush_rq->rq_disk = first_rq->rq_disk;
q->flush_rq->end_io = flush_end_io;
flush_rq->cmd_type = REQ_TYPE_FS;
flush_rq->cmd_flags = WRITE_FLUSH | REQ_FLUSH_SEQ;
flush_rq->rq_disk = first_rq->rq_disk;
flush_rq->end_io = flush_end_io;

return blk_flush_queue_rq(q->flush_rq, false);
return blk_flush_queue_rq(flush_rq, false);
}

static void flush_data_end_io(struct request *rq, int error)
Expand Down

0 comments on commit 7ddab5d

Please sign in to comment.