Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 263150
b: refs/heads/master
c: 4853aba
h: refs/heads/master
v: v3
  • Loading branch information
Jeff Moyer authored and Jens Axboe committed Aug 15, 2011
1 parent 9990249 commit cb72e03
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: bcf30e75b773b60379338768677a1301ef602ff9
refs/heads/master: 4853abaae7e4a2af938115ce9071ef8684fb7af4
8 changes: 6 additions & 2 deletions trunk/block/blk-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1700,6 +1700,7 @@ EXPORT_SYMBOL_GPL(blk_rq_check_limits);
int blk_insert_cloned_request(struct request_queue *q, struct request *rq)
{
unsigned long flags;
int where = ELEVATOR_INSERT_BACK;

if (blk_rq_check_limits(q, rq))
return -EIO;
Expand All @@ -1716,7 +1717,10 @@ int blk_insert_cloned_request(struct request_queue *q, struct request *rq)
*/
BUG_ON(blk_queued_rq(rq));

add_acct_request(q, rq, ELEVATOR_INSERT_BACK);
if (rq->cmd_flags & (REQ_FLUSH|REQ_FUA))
where = ELEVATOR_INSERT_FLUSH;

add_acct_request(q, rq, where);
spin_unlock_irqrestore(q->queue_lock, flags);

return 0;
Expand Down Expand Up @@ -2273,7 +2277,7 @@ static bool blk_end_bidi_request(struct request *rq, int error,
* %false - we are done with this request
* %true - still buffers pending for this request
**/
static bool __blk_end_bidi_request(struct request *rq, int error,
bool __blk_end_bidi_request(struct request *rq, int error,
unsigned int nr_bytes, unsigned int bidi_bytes)
{
if (blk_update_bidi_request(rq, error, nr_bytes, bidi_bytes))
Expand Down
20 changes: 16 additions & 4 deletions trunk/block/blk-flush.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ static void blk_flush_restore_request(struct request *rq)

/* make @rq a normal request */
rq->cmd_flags &= ~REQ_FLUSH_SEQ;
rq->end_io = NULL;
rq->end_io = rq->flush.saved_end_io;
}

/**
Expand Down Expand Up @@ -301,9 +301,6 @@ void blk_insert_flush(struct request *rq)
unsigned int fflags = q->flush_flags; /* may change, cache */
unsigned int policy = blk_flush_policy(fflags, rq);

BUG_ON(rq->end_io);
BUG_ON(!rq->bio || rq->bio != rq->biotail);

/*
* @policy now records what operations need to be done. Adjust
* REQ_FLUSH and FUA for the driver.
Expand All @@ -312,6 +309,19 @@ void blk_insert_flush(struct request *rq)
if (!(fflags & REQ_FUA))
rq->cmd_flags &= ~REQ_FUA;

/*
* An empty flush handed down from a stacking driver may
* translate into nothing if the underlying device does not
* advertise a write-back cache. In this case, simply
* complete the request.
*/
if (!policy) {
__blk_end_bidi_request(rq, 0, 0, 0);
return;
}

BUG_ON(!rq->bio || rq->bio != rq->biotail);

/*
* If there's data but flush is not necessary, the request can be
* processed directly without going through flush machinery. Queue
Expand All @@ -320,6 +330,7 @@ void blk_insert_flush(struct request *rq)
if ((policy & REQ_FSEQ_DATA) &&
!(policy & (REQ_FSEQ_PREFLUSH | REQ_FSEQ_POSTFLUSH))) {
list_add_tail(&rq->queuelist, &q->queue_head);
blk_run_queue_async(q);
return;
}

Expand All @@ -330,6 +341,7 @@ void blk_insert_flush(struct request *rq)
memset(&rq->flush, 0, sizeof(rq->flush));
INIT_LIST_HEAD(&rq->flush.list);
rq->cmd_flags |= REQ_FLUSH_SEQ;
rq->flush.saved_end_io = rq->end_io; /* Usually NULL */
rq->end_io = flush_data_end_io;

blk_flush_complete_seq(rq, REQ_FSEQ_ACTIONS & ~policy, 0);
Expand Down
2 changes: 2 additions & 0 deletions trunk/block/blk.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ int blk_rq_append_bio(struct request_queue *q, struct request *rq,
struct bio *bio);
void blk_dequeue_request(struct request *rq);
void __blk_queue_free_tags(struct request_queue *q);
bool __blk_end_bidi_request(struct request *rq, int error,
unsigned int nr_bytes, unsigned int bidi_bytes);

void blk_rq_timed_out_timer(unsigned long data);
void blk_delete_timer(struct request *);
Expand Down
1 change: 1 addition & 0 deletions trunk/include/linux/blkdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ struct request {
struct {
unsigned int seq;
struct list_head list;
rq_end_io_fn *saved_end_io;
} flush;
};

Expand Down

0 comments on commit cb72e03

Please sign in to comment.