Commit cde4c406 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe
Browse files

block: simplify queue_next_fseq



We need to call blk_rq_init and elv_insert for all cases in queue_next_fseq,
so take these calls into common code.  Also move the end_io initialization
from queue_flush into queue_next_fseq and rename queue_flush to
init_flush_request now that it's old name doesn't apply anymore.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarJens Axboe <jaxboe@fusionio.com>
parent 1e87901e
...@@ -74,16 +74,11 @@ static void post_flush_end_io(struct request *rq, int error) ...@@ -74,16 +74,11 @@ static void post_flush_end_io(struct request *rq, int error)
blk_flush_complete_seq(rq->q, QUEUE_FSEQ_POSTFLUSH, error); blk_flush_complete_seq(rq->q, QUEUE_FSEQ_POSTFLUSH, error);
} }
static void queue_flush(struct request_queue *q, struct request *rq, static void init_flush_request(struct request *rq, struct gendisk *disk)
rq_end_io_fn *end_io)
{ {
blk_rq_init(q, rq);
rq->cmd_type = REQ_TYPE_FS; rq->cmd_type = REQ_TYPE_FS;
rq->cmd_flags = REQ_FLUSH; rq->cmd_flags = REQ_FLUSH;
rq->rq_disk = q->orig_flush_rq->rq_disk; rq->rq_disk = disk;
rq->end_io = end_io;
elv_insert(q, rq, ELEVATOR_INSERT_FRONT);
} }
static struct request *queue_next_fseq(struct request_queue *q) static struct request *queue_next_fseq(struct request_queue *q)
...@@ -91,29 +86,28 @@ static struct request *queue_next_fseq(struct request_queue *q) ...@@ -91,29 +86,28 @@ static struct request *queue_next_fseq(struct request_queue *q)
struct request *orig_rq = q->orig_flush_rq; struct request *orig_rq = q->orig_flush_rq;
struct request *rq = &q->flush_rq; struct request *rq = &q->flush_rq;
blk_rq_init(q, rq);
switch (blk_flush_cur_seq(q)) { switch (blk_flush_cur_seq(q)) {
case QUEUE_FSEQ_PREFLUSH: case QUEUE_FSEQ_PREFLUSH:
queue_flush(q, rq, pre_flush_end_io); init_flush_request(rq, orig_rq->rq_disk);
rq->end_io = pre_flush_end_io;
break; break;
case QUEUE_FSEQ_DATA: case QUEUE_FSEQ_DATA:
/* initialize proxy request, inherit FLUSH/FUA and queue it */
blk_rq_init(q, rq);
init_request_from_bio(rq, orig_rq->bio); init_request_from_bio(rq, orig_rq->bio);
rq->cmd_flags &= ~(REQ_FLUSH | REQ_FUA); rq->cmd_flags &= ~(REQ_FLUSH | REQ_FUA);
rq->cmd_flags |= orig_rq->cmd_flags & (REQ_FLUSH | REQ_FUA); rq->cmd_flags |= orig_rq->cmd_flags & (REQ_FLUSH | REQ_FUA);
rq->end_io = flush_data_end_io; rq->end_io = flush_data_end_io;
elv_insert(q, rq, ELEVATOR_INSERT_FRONT);
break; break;
case QUEUE_FSEQ_POSTFLUSH: case QUEUE_FSEQ_POSTFLUSH:
queue_flush(q, rq, post_flush_end_io); init_flush_request(rq, orig_rq->rq_disk);
rq->end_io = post_flush_end_io;
break; break;
default: default:
BUG(); BUG();
} }
elv_insert(q, rq, ELEVATOR_INSERT_FRONT);
return rq; return rq;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment