提交 f671620e 编写于 作者: T Tejun Heo 提交者: Jens Axboe

block: make every barrier action optional

In all barrier sequences, the barrier write itself was always assumed
to be issued and thus didn't have corresponding control flag.  This
patch adds QUEUE_ORDERED_DO_BAR and unify action mask handling in
start_ordered() such that any barrier action can be skipped.

This patch doesn't introduce any visible behavior changes.
Signed-off-by: NTejun Heo <tj@kernel.org>
Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
上级 a7384677
...@@ -158,19 +158,10 @@ static inline struct request *start_ordered(struct request_queue *q, ...@@ -158,19 +158,10 @@ static inline struct request *start_ordered(struct request_queue *q,
q->ordered = q->next_ordered; q->ordered = q->next_ordered;
q->ordseq |= QUEUE_ORDSEQ_STARTED; q->ordseq |= QUEUE_ORDSEQ_STARTED;
/* /* stash away the original request */
* Prep proxy barrier request.
*/
elv_dequeue_request(q, rq); elv_dequeue_request(q, rq);
q->orig_bar_rq = rq; q->orig_bar_rq = rq;
rq = &q->bar_rq; rq = NULL;
blk_rq_init(q, rq);
if (bio_data_dir(q->orig_bar_rq->bio) == WRITE)
rq->cmd_flags |= REQ_RW;
if (q->ordered & QUEUE_ORDERED_DO_FUA)
rq->cmd_flags |= REQ_FUA;
init_request_from_bio(rq, q->orig_bar_rq->bio);
rq->end_io = bar_end_io;
/* /*
* Queue ordered sequence. As we stack them at the head, we * Queue ordered sequence. As we stack them at the head, we
...@@ -181,12 +172,28 @@ static inline struct request *start_ordered(struct request_queue *q, ...@@ -181,12 +172,28 @@ static inline struct request *start_ordered(struct request_queue *q,
* there will be no data written between the pre and post flush. * there will be no data written between the pre and post flush.
* Hence a single flush will suffice. * Hence a single flush will suffice.
*/ */
if ((q->ordered & QUEUE_ORDERED_DO_POSTFLUSH) && !blk_empty_barrier(rq)) if ((q->ordered & QUEUE_ORDERED_DO_POSTFLUSH) &&
!blk_empty_barrier(q->orig_bar_rq)) {
queue_flush(q, QUEUE_ORDERED_DO_POSTFLUSH); queue_flush(q, QUEUE_ORDERED_DO_POSTFLUSH);
else rq = &q->post_flush_rq;
} else
q->ordseq |= QUEUE_ORDSEQ_POSTFLUSH; q->ordseq |= QUEUE_ORDSEQ_POSTFLUSH;
elv_insert(q, rq, ELEVATOR_INSERT_FRONT); if (q->ordered & QUEUE_ORDERED_DO_BAR) {
rq = &q->bar_rq;
/* initialize proxy request and queue it */
blk_rq_init(q, rq);
if (bio_data_dir(q->orig_bar_rq->bio) == WRITE)
rq->cmd_flags |= REQ_RW;
if (q->ordered & QUEUE_ORDERED_DO_FUA)
rq->cmd_flags |= REQ_FUA;
init_request_from_bio(rq, q->orig_bar_rq->bio);
rq->end_io = bar_end_io;
elv_insert(q, rq, ELEVATOR_INSERT_FRONT);
} else
q->ordseq |= QUEUE_ORDSEQ_BAR;
if (q->ordered & QUEUE_ORDERED_DO_PREFLUSH) { if (q->ordered & QUEUE_ORDERED_DO_PREFLUSH) {
queue_flush(q, QUEUE_ORDERED_DO_PREFLUSH); queue_flush(q, QUEUE_ORDERED_DO_PREFLUSH);
...@@ -194,10 +201,10 @@ static inline struct request *start_ordered(struct request_queue *q, ...@@ -194,10 +201,10 @@ static inline struct request *start_ordered(struct request_queue *q,
} else } else
q->ordseq |= QUEUE_ORDSEQ_PREFLUSH; q->ordseq |= QUEUE_ORDSEQ_PREFLUSH;
if ((q->ordered & QUEUE_ORDERED_BY_TAG) || q->in_flight == 0) if ((q->ordered & QUEUE_ORDERED_BY_DRAIN) && q->in_flight)
q->ordseq |= QUEUE_ORDSEQ_DRAIN;
else
rq = NULL; rq = NULL;
else
q->ordseq |= QUEUE_ORDSEQ_DRAIN;
return rq; return rq;
} }
......
...@@ -526,12 +526,14 @@ enum { ...@@ -526,12 +526,14 @@ enum {
QUEUE_ORDERED_BY_DRAIN = 0x01, QUEUE_ORDERED_BY_DRAIN = 0x01,
QUEUE_ORDERED_BY_TAG = 0x02, QUEUE_ORDERED_BY_TAG = 0x02,
QUEUE_ORDERED_DO_PREFLUSH = 0x10, QUEUE_ORDERED_DO_PREFLUSH = 0x10,
QUEUE_ORDERED_DO_BAR = 0x20,
QUEUE_ORDERED_DO_POSTFLUSH = 0x40, QUEUE_ORDERED_DO_POSTFLUSH = 0x40,
QUEUE_ORDERED_DO_FUA = 0x80, QUEUE_ORDERED_DO_FUA = 0x80,
QUEUE_ORDERED_NONE = 0x00, QUEUE_ORDERED_NONE = 0x00,
QUEUE_ORDERED_DRAIN = QUEUE_ORDERED_BY_DRAIN, QUEUE_ORDERED_DRAIN = QUEUE_ORDERED_BY_DRAIN |
QUEUE_ORDERED_DO_BAR,
QUEUE_ORDERED_DRAIN_FLUSH = QUEUE_ORDERED_DRAIN | QUEUE_ORDERED_DRAIN_FLUSH = QUEUE_ORDERED_DRAIN |
QUEUE_ORDERED_DO_PREFLUSH | QUEUE_ORDERED_DO_PREFLUSH |
QUEUE_ORDERED_DO_POSTFLUSH, QUEUE_ORDERED_DO_POSTFLUSH,
...@@ -539,7 +541,8 @@ enum { ...@@ -539,7 +541,8 @@ enum {
QUEUE_ORDERED_DO_PREFLUSH | QUEUE_ORDERED_DO_PREFLUSH |
QUEUE_ORDERED_DO_FUA, QUEUE_ORDERED_DO_FUA,
QUEUE_ORDERED_TAG = QUEUE_ORDERED_BY_TAG, QUEUE_ORDERED_TAG = QUEUE_ORDERED_BY_TAG |
QUEUE_ORDERED_DO_BAR,
QUEUE_ORDERED_TAG_FLUSH = QUEUE_ORDERED_TAG | QUEUE_ORDERED_TAG_FLUSH = QUEUE_ORDERED_TAG |
QUEUE_ORDERED_DO_PREFLUSH | QUEUE_ORDERED_DO_PREFLUSH |
QUEUE_ORDERED_DO_POSTFLUSH, QUEUE_ORDERED_DO_POSTFLUSH,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册