diff options
author | Christoph Hellwig <hch@lst.de> | 2010-09-03 05:56:17 -0400 |
---|---|---|
committer | Jens Axboe <jaxboe@fusionio.com> | 2010-09-10 06:35:37 -0400 |
commit | cde4c406d8fb051c5aafc917643adbb9dbd0abc2 (patch) | |
tree | 554f623851e5b30069e5e0c5706100ed7b82a3bd /block | |
parent | 1e87901e189c8f01750d67485009fe3827c691bf (diff) |
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: Christoph Hellwig <hch@lst.de>
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/blk-flush.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/block/blk-flush.c b/block/blk-flush.c index 452c552e9ead..72905f862d31 100644 --- a/block/blk-flush.c +++ b/block/blk-flush.c | |||
@@ -74,16 +74,11 @@ static void post_flush_end_io(struct request *rq, int error) | |||
74 | blk_flush_complete_seq(rq->q, QUEUE_FSEQ_POSTFLUSH, error); | 74 | blk_flush_complete_seq(rq->q, QUEUE_FSEQ_POSTFLUSH, error); |
75 | } | 75 | } |
76 | 76 | ||
77 | static void queue_flush(struct request_queue *q, struct request *rq, | 77 | static void init_flush_request(struct request *rq, struct gendisk *disk) |
78 | rq_end_io_fn *end_io) | ||
79 | { | 78 | { |
80 | blk_rq_init(q, rq); | ||
81 | rq->cmd_type = REQ_TYPE_FS; | 79 | rq->cmd_type = REQ_TYPE_FS; |
82 | rq->cmd_flags = REQ_FLUSH; | 80 | rq->cmd_flags = REQ_FLUSH; |
83 | rq->rq_disk = q->orig_flush_rq->rq_disk; | 81 | rq->rq_disk = disk; |
84 | rq->end_io = end_io; | ||
85 | |||
86 | elv_insert(q, rq, ELEVATOR_INSERT_FRONT); | ||
87 | } | 82 | } |
88 | 83 | ||
89 | static struct request *queue_next_fseq(struct request_queue *q) | 84 | 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 | struct request *orig_rq = q->orig_flush_rq; | 86 | struct request *orig_rq = q->orig_flush_rq; |
92 | struct request *rq = &q->flush_rq; | 87 | struct request *rq = &q->flush_rq; |
93 | 88 | ||
89 | blk_rq_init(q, rq); | ||
90 | |||
94 | switch (blk_flush_cur_seq(q)) { | 91 | switch (blk_flush_cur_seq(q)) { |
95 | case QUEUE_FSEQ_PREFLUSH: | 92 | case QUEUE_FSEQ_PREFLUSH: |
96 | queue_flush(q, rq, pre_flush_end_io); | 93 | init_flush_request(rq, orig_rq->rq_disk); |
94 | rq->end_io = pre_flush_end_io; | ||
97 | break; | 95 | break; |
98 | |||
99 | case QUEUE_FSEQ_DATA: | 96 | case QUEUE_FSEQ_DATA: |
100 | /* initialize proxy request, inherit FLUSH/FUA and queue it */ | ||
101 | blk_rq_init(q, rq); | ||
102 | init_request_from_bio(rq, orig_rq->bio); | 97 | init_request_from_bio(rq, orig_rq->bio); |
103 | rq->cmd_flags &= ~(REQ_FLUSH | REQ_FUA); | 98 | rq->cmd_flags &= ~(REQ_FLUSH | REQ_FUA); |
104 | rq->cmd_flags |= orig_rq->cmd_flags & (REQ_FLUSH | REQ_FUA); | 99 | rq->cmd_flags |= orig_rq->cmd_flags & (REQ_FLUSH | REQ_FUA); |
105 | rq->end_io = flush_data_end_io; | 100 | rq->end_io = flush_data_end_io; |
106 | |||
107 | elv_insert(q, rq, ELEVATOR_INSERT_FRONT); | ||
108 | break; | 101 | break; |
109 | |||
110 | case QUEUE_FSEQ_POSTFLUSH: | 102 | case QUEUE_FSEQ_POSTFLUSH: |
111 | queue_flush(q, rq, post_flush_end_io); | 103 | init_flush_request(rq, orig_rq->rq_disk); |
104 | rq->end_io = post_flush_end_io; | ||
112 | break; | 105 | break; |
113 | |||
114 | default: | 106 | default: |
115 | BUG(); | 107 | BUG(); |
116 | } | 108 | } |
109 | |||
110 | elv_insert(q, rq, ELEVATOR_INSERT_FRONT); | ||
117 | return rq; | 111 | return rq; |
118 | } | 112 | } |
119 | 113 | ||