From 7dab264f53ff7078c2cae9b3c2adb33158013e8b Mon Sep 17 00:00:00 2001 From: Mike Snitzer Date: Fri, 11 Feb 2011 11:05:46 +0100 Subject: [PATCH] --- yaml --- r: 242239 b: refs/heads/master c: 9d5a4e946ce5352f19400b6370f4cd8e72806278 h: refs/heads/master i: 242237: 1bb3d13b5f5c4ecd6dbb82483270071e107cd152 242235: 3383c1eab02c98de71867e612920d5c40247d994 242231: e5f3abc10d78a5f60a9e4c901b0fbcfea7d25219 242223: 07d217058b392b96c371f4379e7213072e3ba6f6 242207: 3fb295667ab8c517e6be13300cec0d8fb4d59d74 242175: 039da57f2758b33536036a367841d25b55df1bdc v: v3 --- [refs] | 2 +- trunk/block/blk-core.c | 29 +++++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index 4c408bbe20c5..c07fefa5a79b 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: ae1b1539622fb46e51b4d13b3f9e5f4c713f86ae +refs/heads/master: 9d5a4e946ce5352f19400b6370f4cd8e72806278 diff --git a/trunk/block/blk-core.c b/trunk/block/blk-core.c index 05746093b45e..ab4a7696956d 100644 --- a/trunk/block/blk-core.c +++ b/trunk/block/blk-core.c @@ -737,6 +737,25 @@ static void freed_request(struct request_queue *q, int sync, int priv) __freed_request(q, sync ^ 1); } +/* + * Determine if elevator data should be initialized when allocating the + * request associated with @bio. + */ +static bool blk_rq_should_init_elevator(struct bio *bio) +{ + if (!bio) + return true; + + /* + * Flush requests do not use the elevator so skip initialization. + * This allows a request to share the flush and elevator data. + */ + if (bio->bi_rw & (REQ_FLUSH | REQ_FUA)) + return false; + + return true; +} + /* * Get a free request, queue_lock must be held. * Returns NULL on failure, with queue_lock held. @@ -749,7 +768,7 @@ static struct request *get_request(struct request_queue *q, int rw_flags, struct request_list *rl = &q->rq; struct io_context *ioc = NULL; const bool is_sync = rw_is_sync(rw_flags) != 0; - int may_queue, priv; + int may_queue, priv = 0; may_queue = elv_may_queue(q, rw_flags); if (may_queue == ELV_MQUEUE_NO) @@ -793,9 +812,11 @@ static struct request *get_request(struct request_queue *q, int rw_flags, rl->count[is_sync]++; rl->starved[is_sync] = 0; - priv = !test_bit(QUEUE_FLAG_ELVSWITCH, &q->queue_flags); - if (priv) - rl->elvpriv++; + if (blk_rq_should_init_elevator(bio)) { + priv = !test_bit(QUEUE_FLAG_ELVSWITCH, &q->queue_flags); + if (priv) + rl->elvpriv++; + } if (blk_queue_io_stat(q)) rw_flags |= REQ_IO_STAT;