summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
Diffstat (limited to 'block')
-rw-r--r--block/Kconfig.iosched2
-rw-r--r--block/as-iosched.c68
-rw-r--r--block/blktrace.c1
-rw-r--r--block/cfq-iosched.c207
-rw-r--r--block/deadline-iosched.c54
-rw-r--r--block/elevator.c4
-rw-r--r--block/genhd.c8
-rw-r--r--block/ll_rw_blk.c30
8 files changed, 160 insertions, 214 deletions
diff --git a/block/Kconfig.iosched b/block/Kconfig.iosched
index f3b7753aac99..48d090e266fc 100644
--- a/block/Kconfig.iosched
+++ b/block/Kconfig.iosched
@@ -40,7 +40,7 @@ config IOSCHED_CFQ
choice
prompt "Default I/O scheduler"
- default DEFAULT_AS
+ default DEFAULT_CFQ
help
Select the I/O scheduler which will be used by default for all
block devices.
diff --git a/block/as-iosched.c b/block/as-iosched.c
index a7caf35ca0c2..5da56d48fbd3 100644
--- a/block/as-iosched.c
+++ b/block/as-iosched.c
@@ -10,7 +10,6 @@
#include <linux/blkdev.h>
#include <linux/elevator.h>
#include <linux/bio.h>
-#include <linux/config.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/init.h>
@@ -96,7 +95,7 @@ struct as_data {
struct as_rq *next_arq[2]; /* next in sort order */
sector_t last_sector[2]; /* last REQ_SYNC & REQ_ASYNC sectors */
- struct list_head *hash; /* request hash */
+ struct hlist_head *hash; /* request hash */
unsigned long exit_prob; /* probability a task will exit while
being waited on */
@@ -165,8 +164,7 @@ struct as_rq {
/*
* request hash, key is the ending offset (for back merge lookup)
*/
- struct list_head hash;
- unsigned int on_hash;
+ struct hlist_node hash;
/*
* expire fifo
@@ -282,17 +280,15 @@ static const int as_hash_shift = 6;
#define AS_HASH_FN(sec) (hash_long(AS_HASH_BLOCK((sec)), as_hash_shift))
#define AS_HASH_ENTRIES (1 << as_hash_shift)
#define rq_hash_key(rq) ((rq)->sector + (rq)->nr_sectors)
-#define list_entry_hash(ptr) list_entry((ptr), struct as_rq, hash)
static inline void __as_del_arq_hash(struct as_rq *arq)
{
- arq->on_hash = 0;
- list_del_init(&arq->hash);
+ hlist_del_init(&arq->hash);
}
static inline void as_del_arq_hash(struct as_rq *arq)
{
- if (arq->on_hash)
+ if (!hlist_unhashed(&arq->hash))
__as_del_arq_hash(arq);
}
@@ -300,10 +296,9 @@ static void as_add_arq_hash(struct as_data *ad, struct as_rq *arq)
{
struct request *rq = arq->request;
- BUG_ON(arq->on_hash);
+ BUG_ON(!hlist_unhashed(&arq->hash));
- arq->on_hash = 1;
- list_add(&arq->hash, &ad->hash[AS_HASH_FN(rq_hash_key(rq))]);
+ hlist_add_head(&arq->hash, &ad->hash[AS_HASH_FN(rq_hash_key(rq))]);
}
/*
@@ -312,31 +307,29 @@ static void as_add_arq_hash(struct as_data *ad, struct as_rq *arq)
static inline void as_hot_arq_hash(struct as_data *ad, struct as_rq *arq)
{
struct request *rq = arq->request;
- struct list_head *head = &ad->hash[AS_HASH_FN(rq_hash_key(rq))];
+ struct hlist_head *head = &ad->hash[AS_HASH_FN(rq_hash_key(rq))];
- if (!arq->on_hash) {
+ if (hlist_unhashed(&arq->hash)) {
WARN_ON(1);
return;
}
- if (arq->hash.prev != head) {
- list_del(&arq->hash);
- list_add(&arq->hash, head);
+ if (&arq->hash != head->first) {
+ hlist_del(&arq->hash);
+ hlist_add_head(&arq->hash, head);
}
}
static struct request *as_find_arq_hash(struct as_data *ad, sector_t offset)
{
- struct list_head *hash_list = &ad->hash[AS_HASH_FN(offset)];
- struct list_head *entry, *next = hash_list->next;
+ struct hlist_head *hash_list = &ad->hash[AS_HASH_FN(offset)];
+ struct hlist_node *entry, *next;
+ struct as_rq *arq;
- while ((entry = next) != hash_list) {
- struct as_rq *arq = list_entry_hash(entry);
+ hlist_for_each_entry_safe(arq, entry, next, hash_list, hash) {
struct request *__rq = arq->request;
- next = entry->next;
-
- BUG_ON(!arq->on_hash);
+ BUG_ON(hlist_unhashed(&arq->hash));
if (!rq_mergeable(__rq)) {
as_del_arq_hash(arq);
@@ -353,10 +346,6 @@ static struct request *as_find_arq_hash(struct as_data *ad, sector_t offset)
/*
* rb tree support functions
*/
-#define RB_NONE (2)
-#define RB_EMPTY(root) ((root)->rb_node == NULL)
-#define ON_RB(node) ((node)->rb_color != RB_NONE)
-#define RB_CLEAR(node) ((node)->rb_color = RB_NONE)
#define rb_entry_arq(node) rb_entry((node), struct as_rq, rb_node)
#define ARQ_RB_ROOT(ad, arq) (&(ad)->sort_list[(arq)->is_sync])
#define rq_rb_key(rq) (rq)->sector
@@ -425,13 +414,13 @@ static void as_add_arq_rb(struct as_data *ad, struct as_rq *arq)
static inline void as_del_arq_rb(struct as_data *ad, struct as_rq *arq)
{
- if (!ON_RB(&arq->rb_node)) {
+ if (!RB_EMPTY_NODE(&arq->rb_node)) {
WARN_ON(1);
return;
}
rb_erase(&arq->rb_node, ARQ_RB_ROOT(ad, arq));
- RB_CLEAR(&arq->rb_node);
+ RB_CLEAR_NODE(&arq->rb_node);
}
static struct request *
@@ -552,7 +541,7 @@ static struct as_rq *as_find_next_arq(struct as_data *ad, struct as_rq *last)
struct rb_node *rbprev = rb_prev(&last->rb_node);
struct as_rq *arq_next, *arq_prev;
- BUG_ON(!ON_RB(&last->rb_node));
+ BUG_ON(!RB_EMPTY_NODE(&last->rb_node));
if (rbprev)
arq_prev = rb_entry_arq(rbprev);
@@ -902,7 +891,7 @@ static int as_can_break_anticipation(struct as_data *ad, struct as_rq *arq)
}
/*
- * as_can_anticipate indicates weather we should either run arq
+ * as_can_anticipate indicates whether we should either run arq
* or keep anticipating a better request.
*/
static int as_can_anticipate(struct as_data *ad, struct as_rq *arq)
@@ -1129,7 +1118,7 @@ static void as_move_to_dispatch(struct as_data *ad, struct as_rq *arq)
struct request *rq = arq->request;
const int data_dir = arq->is_sync;
- BUG_ON(!ON_RB(&arq->rb_node));
+ BUG_ON(!RB_EMPTY_NODE(&arq->rb_node));
as_antic_stop(ad);
ad->antic_status = ANTIC_OFF;
@@ -1254,7 +1243,7 @@ static int as_dispatch_request(request_queue_t *q, int force)
*/
if (reads) {
- BUG_ON(RB_EMPTY(&ad->sort_list[REQ_SYNC]));
+ BUG_ON(RB_EMPTY_ROOT(&ad->sort_list[REQ_SYNC]));
if (writes && ad->batch_data_dir == REQ_SYNC)
/*
@@ -1278,7 +1267,7 @@ static int as_dispatch_request(request_queue_t *q, int force)
if (writes) {
dispatch_writes:
- BUG_ON(RB_EMPTY(&ad->sort_list[REQ_ASYNC]));
+ BUG_ON(RB_EMPTY_ROOT(&ad->sort_list[REQ_ASYNC]));
if (ad->batch_data_dir == REQ_SYNC) {
ad->changed_batch = 1;
@@ -1346,7 +1335,7 @@ static void as_add_request(request_queue_t *q, struct request *rq)
arq->state = AS_RQ_NEW;
if (rq_data_dir(arq->request) == READ
- || current->flags&PF_SYNCWRITE)
+ || (arq->request->flags & REQ_RW_SYNC))
arq->is_sync = 1;
else
arq->is_sync = 0;
@@ -1598,12 +1587,11 @@ static int as_set_request(request_queue_t *q, struct request *rq,
if (arq) {
memset(arq, 0, sizeof(*arq));
- RB_CLEAR(&arq->rb_node);
+ RB_CLEAR_NODE(&arq->rb_node);
arq->request = rq;
arq->state = AS_RQ_PRESCHED;
arq->io_context = NULL;
- INIT_LIST_HEAD(&arq->hash);
- arq->on_hash = 0;
+ INIT_HLIST_NODE(&arq->hash);
INIT_LIST_HEAD(&arq->fifo);
rq->elevator_private = arq;
return 0;
@@ -1663,7 +1651,7 @@ static void *as_init_queue(request_queue_t *q, elevator_t *e)
ad->q = q; /* Identify what queue the data belongs to */
- ad->hash = kmalloc_node(sizeof(struct list_head)*AS_HASH_ENTRIES,
+ ad->hash = kmalloc_node(sizeof(struct hlist_head)*AS_HASH_ENTRIES,
GFP_KERNEL, q->node);
if (!ad->hash) {
kfree(ad);
@@ -1685,7 +1673,7 @@ static void *as_init_queue(request_queue_t *q, elevator_t *e)
INIT_WORK(&ad->antic_work, as_work_handler, q);
for (i = 0; i < AS_HASH_ENTRIES; i++)
- INIT_LIST_HEAD(&ad->hash[i]);
+ INIT_HLIST_HEAD(&ad->hash[i]);
INIT_LIST_HEAD(&ad->fifo_list[REQ_SYNC]);
INIT_LIST_HEAD(&ad->fifo_list[REQ_ASYNC]);
diff --git a/block/blktrace.c b/block/blktrace.c
index 36f3a172275f..92925e7d9e6c 100644
--- a/block/blktrace.c
+++ b/block/blktrace.c
@@ -15,7 +15,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/blkdev.h>
#include <linux/blktrace_api.h>
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index 052b17487625..102ebc2c5c34 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -6,7 +6,6 @@
*
* Copyright (C) 2003 Jens Axboe <axboe@suse.de>
*/
-#include <linux/config.h>
#include <linux/module.h>
#include <linux/blkdev.h>
#include <linux/elevator.h>
@@ -26,7 +25,7 @@ static const int cfq_back_penalty = 2; /* penalty of a backwards seek */
static const int cfq_slice_sync = HZ / 10;
static int cfq_slice_async = HZ / 25;
static const int cfq_slice_async_rq = 2;
-static int cfq_slice_idle = HZ / 70;
+static int cfq_slice_idle = HZ / 125;
#define CFQ_IDLE_GRACE (HZ / 10)
#define CFQ_SLICE_SCALE (5)
@@ -60,16 +59,6 @@ static DEFINE_SPINLOCK(cfq_exit_lock);
/*
* rb-tree defines
*/
-#define RB_NONE (2)
-#define RB_EMPTY(node) ((node)->rb_node == NULL)
-#define RB_CLEAR_COLOR(node) (node)->rb_color = RB_NONE
-#define RB_CLEAR(node) do { \
- (node)->rb_parent = NULL; \
- RB_CLEAR_COLOR((node)); \
- (node)->rb_right = NULL; \
- (node)->rb_left = NULL; \
-} while (0)
-#define RB_CLEAR_ROOT(root) ((root)->rb_node = NULL)
#define rb_entry_crq(node) rb_entry((node), struct cfq_rq, rb_node)
#define rq_rb_key(rq) (rq)->sector
@@ -128,8 +117,6 @@ struct cfq_data {
*/
struct hlist_head *crq_hash;
- unsigned int max_queued;
-
mempool_t *crq_pool;
int rq_in_driver;
@@ -284,8 +271,6 @@ static struct cfq_queue *cfq_find_cfq_hash(struct cfq_data *, unsigned int, unsi
static void cfq_dispatch_insert(request_queue_t *, struct cfq_rq *);
static struct cfq_queue *cfq_get_queue(struct cfq_data *cfqd, unsigned int key, struct task_struct *tsk, gfp_t gfp_mask);
-#define process_sync(tsk) ((tsk)->flags & PF_SYNCWRITE)
-
/*
* lots of deadline iosched dupes, can be abstracted later...
*/
@@ -341,7 +326,7 @@ static int cfq_queue_empty(request_queue_t *q)
static inline pid_t cfq_queue_pid(struct task_struct *task, int rw)
{
- if (rw == READ || process_sync(task))
+ if (rw == READ || rw == WRITE_SYNC)
return task->pid;
return CFQ_KEY_ASYNC;
@@ -567,9 +552,8 @@ static inline void cfq_del_crq_rb(struct cfq_rq *crq)
cfq_update_next_crq(crq);
rb_erase(&crq->rb_node, &cfqq->sort_list);
- RB_CLEAR_COLOR(&crq->rb_node);
- if (cfq_cfqq_on_rr(cfqq) && RB_EMPTY(&cfqq->sort_list))
+ if (cfq_cfqq_on_rr(cfqq) && RB_EMPTY_ROOT(&cfqq->sort_list))
cfq_del_cfqq_rr(cfqd, cfqq);
}
@@ -916,13 +900,15 @@ static struct cfq_queue *cfq_set_active_queue(struct cfq_data *cfqd)
return cfqq;
}
+#define CIC_SEEKY(cic) ((cic)->seek_mean > (128 * 1024))
+
static int cfq_arm_slice_timer(struct cfq_data *cfqd, struct cfq_queue *cfqq)
{
struct cfq_io_context *cic;
unsigned long sl;
- WARN_ON(!RB_EMPTY(&cfqq->sort_list));
+ WARN_ON(!RB_EMPTY_ROOT(&cfqq->sort_list));
WARN_ON(cfqq != cfqd->active_queue);
/*
@@ -949,7 +935,7 @@ static int cfq_arm_slice_timer(struct cfq_data *cfqd, struct cfq_queue *cfqq)
* fair distribution of slice time for a process doing back-to-back
* seeks. so allow a little bit of time for him to submit a new rq
*/
- if (sample_valid(cic->seek_samples) && cic->seek_mean > 131072)
+ if (sample_valid(cic->seek_samples) && CIC_SEEKY(cic))
sl = 2;
mod_timer(&cfqd->idle_slice_timer, jiffies + sl);
@@ -960,11 +946,15 @@ static void cfq_dispatch_insert(request_queue_t *q, struct cfq_rq *crq)
{
struct cfq_data *cfqd = q->elevator->elevator_data;
struct cfq_queue *cfqq = crq->cfq_queue;
+ struct request *rq;
cfqq->next_crq = cfq_find_next_crq(cfqd, cfqq, crq);
cfq_remove_request(crq->request);
cfqq->on_dispatch[cfq_crq_is_sync(crq)]++;
elv_dispatch_sort(q, crq->request);
+
+ rq = list_entry(q->queue_head.prev, struct request, queuelist);
+ cfqd->last_sector = rq->sector + rq->nr_sectors;
}
/*
@@ -1046,10 +1036,12 @@ static struct cfq_queue *cfq_select_queue(struct cfq_data *cfqd)
* if queue has requests, dispatch one. if not, check if
* enough slice is left to wait for one
*/
- if (!RB_EMPTY(&cfqq->sort_list))
+ if (!RB_EMPTY_ROOT(&cfqq->sort_list))
goto keep_queue;
- else if (cfq_cfqq_class_sync(cfqq) &&
- time_before(now, cfqq->slice_end)) {
+ else if (cfq_cfqq_dispatched(cfqq)) {
+ cfqq = NULL;
+ goto keep_queue;
+ } else if (cfq_cfqq_class_sync(cfqq)) {
if (cfq_arm_slice_timer(cfqd, cfqq))
return NULL;
}
@@ -1068,7 +1060,7 @@ __cfq_dispatch_requests(struct cfq_data *cfqd, struct cfq_queue *cfqq,
{
int dispatched = 0;
- BUG_ON(RB_EMPTY(&cfqq->sort_list));
+ BUG_ON(RB_EMPTY_ROOT(&cfqq->sort_list));
do {
struct cfq_rq *crq;
@@ -1092,14 +1084,13 @@ __cfq_dispatch_requests(struct cfq_data *cfqd, struct cfq_queue *cfqq,
cfqd->active_cic = crq->io_context;
}
- if (RB_EMPTY(&cfqq->sort_list))
+ if (RB_EMPTY_ROOT(&cfqq->sort_list))
break;
} while (dispatched < max_dispatch);
/*
- * if slice end isn't set yet, set it. if at least one request was
- * sync, use the sync time slice value
+ * if slice end isn't set yet, set it.
*/
if (!cfqq->slice_end)
cfq_set_prio_slice(cfqd, cfqq);
@@ -1110,7 +1101,8 @@ __cfq_dispatch_requests(struct cfq_data *cfqd, struct cfq_queue *cfqq,
*/
if ((!cfq_cfqq_sync(cfqq) &&
cfqd->dispatch_slice >= cfq_prio_to_maxrq(cfqd, cfqq)) ||
- cfq_class_idle(cfqq))
+ cfq_class_idle(cfqq) ||
+ !cfq_cfqq_idle_window(cfqq))
cfq_slice_expired(cfqd, 0);
return dispatched;
@@ -1119,10 +1111,11 @@ __cfq_dispatch_requests(struct cfq_data *cfqd, struct cfq_queue *cfqq,
static int
cfq_forced_dispatch_cfqqs(struct list_head *list)
{
- int dispatched = 0;
struct cfq_queue *cfqq, *next;
struct cfq_rq *crq;
+ int dispatched;
+ dispatched = 0;
list_for_each_entry_safe(cfqq, next, list, cfq_list) {
while ((crq = cfqq->next_crq)) {
cfq_dispatch_insert(cfqq->cfqd->queue, crq);
@@ -1130,6 +1123,7 @@ cfq_forced_dispatch_cfqqs(struct list_head *list)
}
BUG_ON(!list_empty(&cfqq->fifo));
}
+
return dispatched;
}
@@ -1156,7 +1150,8 @@ static int
cfq_dispatch_requests(request_queue_t *q, int force)
{
struct cfq_data *cfqd = q->elevator->elevator_data;
- struct cfq_queue *cfqq;
+ struct cfq_queue *cfqq, *prev_cfqq;
+ int dispatched;
if (!cfqd->busy_queues)
return 0;
@@ -1164,10 +1159,17 @@ cfq_dispatch_requests(request_queue_t *q, int force)
if (unlikely(force))
return cfq_forced_dispatch(cfqd);
- cfqq = cfq_select_queue(cfqd);
- if (cfqq) {
+ dispatched = 0;
+ prev_cfqq = NULL;
+ while ((cfqq = cfq_select_queue(cfqd)) != NULL) {
int max_dispatch;
+ /*
+ * Don't repeat dispatch from the previous queue.
+ */
+ if (prev_cfqq == cfqq)
+ break;
+
cfq_clear_cfqq_must_dispatch(cfqq);
cfq_clear_cfqq_wait_request(cfqq);
del_timer(&cfqd->idle_slice_timer);
@@ -1176,10 +1178,19 @@ cfq_dispatch_requests(request_queue_t *q, int force)
if (cfq_class_idle(cfqq))
max_dispatch = 1;
- return __cfq_dispatch_requests(cfqd, cfqq, max_dispatch);
+ dispatched += __cfq_dispatch_requests(cfqd, cfqq, max_dispatch);
+
+ /*
+ * If the dispatch cfqq has idling enabled and is still
+ * the active queue, break out.
+ */
+ if (cfq_cfqq_idle_window(cfqq) && cfqd->active_queue)
+ break;
+
+ prev_cfqq = cfqq;
}
- return 0;
+ return dispatched;
}
/*
@@ -1324,7 +1335,6 @@ cfq_alloc_io_context(struct cfq_data *cfqd, gfp_t gfp_mask)
if (cic) {
memset(cic, 0, sizeof(*cic));
- RB_CLEAR_COLOR(&cic->rb_node);
cic->last_end_request = jiffies;
INIT_LIST_HEAD(&cic->queue_list);
cic->dtor = cfq_free_io_context;
@@ -1386,25 +1396,28 @@ static inline void changed_ioprio(struct cfq_io_context *cic)
{
struct cfq_data *cfqd = cic->key;
struct cfq_queue *cfqq;
- if (cfqd) {
- spin_lock(cfqd->queue->queue_lock);
- cfqq = cic->cfqq[ASYNC];
- if (cfqq) {
- struct cfq_queue *new_cfqq;
- new_cfqq = cfq_get_queue(cfqd, CFQ_KEY_ASYNC,
- cic->ioc->task, GFP_ATOMIC);
- if (new_cfqq) {
- cic->cfqq[ASYNC] = new_cfqq;
- cfq_put_queue(cfqq);
- }
- }
- cfqq = cic->cfqq[SYNC];
- if (cfqq) {
- cfq_mark_cfqq_prio_changed(cfqq);
- cfq_init_prio_data(cfqq);
+
+ if (unlikely(!cfqd))
+ return;
+
+ spin_lock(cfqd->queue->queue_lock);
+
+ cfqq = cic->cfqq[ASYNC];
+ if (cfqq) {
+ struct cfq_queue *new_cfqq;
+ new_cfqq = cfq_get_queue(cfqd, CFQ_KEY_ASYNC, cic->ioc->task,
+ GFP_ATOMIC);
+ if (new_cfqq) {
+ cic->cfqq[ASYNC] = new_cfqq;
+ cfq_put_queue(cfqq);
}
- spin_unlock(cfqd->queue->queue_lock);
}
+
+ cfqq = cic->cfqq[SYNC];
+ if (cfqq)
+ cfq_mark_cfqq_prio_changed(cfqq);
+
+ spin_unlock(cfqd->queue->queue_lock);
}
/*
@@ -1461,7 +1474,6 @@ retry:
INIT_HLIST_NODE(&cfqq->cfq_hash);
INIT_LIST_HEAD(&cfqq->cfq_list);
- RB_CLEAR_ROOT(&cfqq->sort_list);
INIT_LIST_HEAD(&cfqq->fifo);
cfqq->key = key;
@@ -1473,8 +1485,7 @@ retry:
* set ->slice_left to allow preemption for a new process
*/
cfqq->slice_left = 2 * cfqd->cfq_slice_idle;
- if (!cfqd->hw_tag)
- cfq_mark_cfqq_idle_window(cfqq);
+ cfq_mark_cfqq_idle_window(cfqq);
cfq_mark_cfqq_prio_changed(cfqq);
cfq_init_prio_data(cfqq);
}
@@ -1665,7 +1676,8 @@ cfq_update_idle_window(struct cfq_data *cfqd, struct cfq_queue *cfqq,
{
int enable_idle = cfq_cfqq_idle_window(cfqq);
- if (!cic->ioc->task || !cfqd->cfq_slice_idle || cfqd->hw_tag)
+ if (!cic->ioc->task || !cfqd->cfq_slice_idle ||
+ (cfqd->hw_tag && CIC_SEEKY(cic)))
enable_idle = 0;
else if (sample_valid(cic->ttime_samples)) {
if (cic->ttime_mean > cfqd->cfq_slice_idle)
@@ -1695,7 +1707,7 @@ cfq_should_preempt(struct cfq_data *cfqd, struct cfq_queue *new_cfqq,
return 0;
if (!cfqq)
- return 1;
+ return 0;
if (cfq_class_idle(cfqq))
return 1;
@@ -1727,7 +1739,7 @@ static void cfq_preempt_queue(struct cfq_data *cfqd, struct cfq_queue *cfqq)
cfqq->slice_left = cfq_prio_to_slice(cfqd, cfqq) / 2;
cfqq->slice_end = cfqq->slice_left + jiffies;
- __cfq_slice_expired(cfqd, cfqq, 1);
+ cfq_slice_expired(cfqd, 1);
__cfq_set_active_queue(cfqd, cfqq);
}
@@ -1752,11 +1764,7 @@ static void
cfq_crq_enqueued(struct cfq_data *cfqd, struct cfq_queue *cfqq,
struct cfq_rq *crq)
{
- struct cfq_io_context *cic;
-
- cfqq->next_crq = cfq_choose_req(cfqd, cfqq->next_crq, crq);
-
- cic = crq->io_context;
+ struct cfq_io_context *cic = crq->io_context;
/*
* we never wait for an async request and we don't allow preemption
@@ -1846,11 +1854,23 @@ static void cfq_completed_request(request_queue_t *q, struct request *rq)
cfqq->service_last = now;
cfq_resort_rr_list(cfqq, 0);
}
- cfq_schedule_dispatch(cfqd);
}
- if (cfq_crq_is_sync(crq))
+ if (sync)
crq->io_context->last_end_request = now;
+
+ /*
+ * If this is the active queue, check if it needs to be expired,
+ * or if we want to idle in case it has no pending requests.
+ */
+ if (cfqd->active_queue == cfqq) {
+ if (time_after(now, cfqq->slice_end))
+ cfq_slice_expired(cfqd, 0);
+ else if (sync && RB_EMPTY_ROOT(&cfqq->sort_list)) {
+ if (!cfq_arm_slice_timer(cfqd, cfqq))
+ cfq_schedule_dispatch(cfqd);
+ }
+ }
}
static struct request *
@@ -1917,7 +1937,6 @@ static inline int
__cfq_may_queue(struct cfq_data *cfqd, struct cfq_queue *cfqq,
struct task_struct *task, int rw)
{
-#if 1
if ((cfq_cfqq_wait_request(cfqq) || cfq_cfqq_must_alloc(cfqq)) &&
!cfq_cfqq_must_alloc_slice(cfqq)) {
cfq_mark_cfqq_must_alloc_slice(cfqq);
@@ -1925,39 +1944,6 @@ __cfq_may_queue(struct cfq_data *cfqd, struct cfq_queue *cfqq,
}
return ELV_MQUEUE_MAY;
-#else
- if (!cfqq || task->flags & PF_MEMALLOC)
- return ELV_MQUEUE_MAY;
- if (!cfqq->allocated[rw] || cfq_cfqq_must_alloc(cfqq)) {
- if (cfq_cfqq_wait_request(cfqq))
- return ELV_MQUEUE_MUST;
-
- /*
- * only allow 1 ELV_MQUEUE_MUST per slice, otherwise we
- * can quickly flood the queue with writes from a single task
- */
- if (rw == READ || !cfq_cfqq_must_alloc_slice(cfqq)) {
- cfq_mark_cfqq_must_alloc_slice(cfqq);
- return ELV_MQUEUE_MUST;
- }
-
- return ELV_MQUEUE_MAY;
- }
- if (cfq_class_idle(cfqq))
- return ELV_MQUEUE_NO;
- if (cfqq->allocated[rw] >= cfqd->max_queued) {
- struct io_context *ioc = get_io_context(GFP_ATOMIC);
- int ret = ELV_MQUEUE_NO;
-
- if (ioc && ioc->nr_batch_requests)
- ret = ELV_MQUEUE_MAY;
-
- put_io_context(ioc);
- return ret;
- }
-
- return ELV_MQUEUE_MAY;
-#endif
}
static int cfq_may_queue(request_queue_t *q, int rw, struct bio *bio)
@@ -1986,16 +1972,13 @@ static int cfq_may_queue(request_queue_t *q, int rw, struct bio *bio)
static void cfq_check_waiters(request_queue_t *q, struct cfq_queue *cfqq)
{
struct cfq_data *cfqd = q->elevator->elevator_data;
- struct request_list *rl = &q->rq;
- if (cfqq->allocated[READ] <= cfqd->max_queued || cfqd->rq_starved) {
+ if (unlikely(cfqd->rq_starved)) {
+ struct request_list *rl = &q->rq;
+
smp_mb();
if (waitqueue_active(&rl->wait[READ]))
wake_up(&rl->wait[READ]);
- }
-
- if (cfqq->allocated[WRITE] <= cfqd->max_queued || cfqd->rq_starved) {
- smp_mb();
if (waitqueue_active(&rl->wait[WRITE]))
wake_up(&rl->wait[WRITE]);
}
@@ -2069,7 +2052,7 @@ cfq_set_request(request_queue_t *q, struct request *rq, struct bio *bio,
crq = mempool_alloc(cfqd->crq_pool, gfp_mask);
if (crq) {
- RB_CLEAR(&crq->rb_node);
+ RB_CLEAR_NODE(&crq->rb_node);
crq->rb_key = 0;
crq->request = rq;
INIT_HLIST_NODE(&crq->hash);
@@ -2155,16 +2138,13 @@ static void cfq_idle_slice_timer(unsigned long data)
* only expire and reinvoke request handler, if there are
* other queues with pending requests
*/
- if (!cfqd->busy_queues) {
- cfqd->idle_slice_timer.expires = min(now + cfqd->cfq_slice_idle, cfqq->slice_end);
- add_timer(&cfqd->idle_slice_timer);
+ if (!cfqd->busy_queues)
goto out_cont;
- }
/*
* not expired and it has a request pending, let it dispatch
*/
- if (!RB_EMPTY(&cfqq->sort_list)) {
+ if (!RB_EMPTY_ROOT(&cfqq->sort_list)) {
cfq_mark_cfqq_must_dispatch(cfqq);
goto out_kick;
}
@@ -2285,9 +2265,6 @@ static void *cfq_init_queue(request_queue_t *q, elevator_t *e)
cfqd->queue = q;
- cfqd->max_queued = q->nr_requests / 4;
- q->nr_batching = cfq_queued;
-
init_timer(&cfqd->idle_slice_timer);
cfqd->idle_slice_timer.function = cfq_idle_slice_timer;
cfqd->idle_slice_timer.data = (unsigned long) cfqd;
diff --git a/block/deadline-iosched.c b/block/deadline-iosched.c
index 3bd0415a9828..c7ca9f0b6498 100644
--- a/block/deadline-iosched.c
+++ b/block/deadline-iosched.c
@@ -8,7 +8,6 @@
#include <linux/blkdev.h>
#include <linux/elevator.h>
#include <linux/bio.h>
-#include <linux/config.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/init.h>
@@ -30,8 +29,7 @@ static const int deadline_hash_shift = 5;
#define DL_HASH_FN(sec) (hash_long(DL_HASH_BLOCK((sec)), deadline_hash_shift))
#define DL_HASH_ENTRIES (1 << deadline_hash_shift)
#define rq_hash_key(rq) ((rq)->sector + (rq)->nr_sectors)
-#define list_entry_hash(ptr) list_entry((ptr), struct deadline_rq, hash)
-#define ON_HASH(drq) (drq)->on_hash
+#define ON_HASH(drq) (!hlist_unhashed(&(drq)->hash))
struct deadline_data {
/*
@@ -48,7 +46,7 @@ struct deadline_data {
* next in sort order. read, write or both are NULL
*/
struct deadline_rq *next_drq[2];
- struct list_head *hash; /* request hash */
+ struct hlist_head *hash; /* request hash */
unsigned int batching; /* number of sequential requests made */
sector_t last_sector; /* head position */
unsigned int starved; /* times reads have starved writes */
@@ -79,8 +77,7 @@ struct deadline_rq {
/*
* request hash, key is the ending offset (for back merge lookup)
*/
- struct list_head hash;
- char on_hash;
+ struct hlist_node hash;
/*
* expire fifo
@@ -100,8 +97,7 @@ static kmem_cache_t *drq_pool;
*/
static inline void __deadline_del_drq_hash(struct deadline_rq *drq)
{
- drq->on_hash = 0;
- list_del_init(&drq->hash);
+ hlist_del_init(&drq->hash);
}
static inline void deadline_del_drq_hash(struct deadline_rq *drq)
@@ -117,8 +113,7 @@ deadline_add_drq_hash(struct deadline_data *dd, struct deadline_rq *drq)
BUG_ON(ON_HASH(drq));
- drq->on_hash = 1;
- list_add(&drq->hash, &dd->hash[DL_HASH_FN(rq_hash_key(rq))]);
+ hlist_add_head(&drq->hash, &dd->hash[DL_HASH_FN(rq_hash_key(rq))]);
}
/*
@@ -128,26 +123,24 @@ static inline void
deadline_hot_drq_hash(struct deadline_data *dd, struct deadline_rq *drq)
{
struct request *rq = drq->request;
- struct list_head *head = &dd->hash[DL_HASH_FN(rq_hash_key(rq))];
+ struct hlist_head *head = &dd->hash[DL_HASH_FN(rq_hash_key(rq))];
- if (ON_HASH(drq) && drq->hash.prev != head) {
- list_del(&drq->hash);
- list_add(&drq->hash, head);
+ if (ON_HASH(drq) && &drq->hash != head->first) {
+ hlist_del(&drq->hash);
+ hlist_add_head(&drq->hash, head);
}
}
static struct request *
deadline_find_drq_hash(struct deadline_data *dd, sector_t offset)
{
- struct list_head *hash_list = &dd->hash[DL_HASH_FN(offset)];
- struct list_head *entry, *next = hash_list->next;
+ struct hlist_head *hash_list = &dd->hash[DL_HASH_FN(offset)];
+ struct hlist_node *entry, *next;
+ struct deadline_rq *drq;
- while ((entry = next) != hash_list) {
- struct deadline_rq *drq = list_entry_hash(entry);
+ hlist_for_each_entry_safe(drq, entry, next, hash_list, hash) {
struct request *__rq = drq->request;
- next = entry->next;
-
BUG_ON(!ON_HASH(drq));
if (!rq_mergeable(__rq)) {
@@ -165,10 +158,6 @@ deadline_find_drq_hash(struct deadline_data *dd, sector_t offset)
/*
* rb tree support functions
*/
-#define RB_NONE (2)
-#define RB_EMPTY(root) ((root)->rb_node == NULL)
-#define ON_RB(node) ((node)->rb_color != RB_NONE)
-#define RB_CLEAR(node) ((node)->rb_color = RB_NONE)
#define rb_entry_drq(node) rb_entry((node), struct deadline_rq, rb_node)
#define DRQ_RB_ROOT(dd, drq) (&(dd)->sort_list[rq_data_dir((drq)->request)])
#define rq_rb_key(rq) (rq)->sector
@@ -227,9 +216,9 @@ deadline_del_drq_rb(struct deadline_data *dd, struct deadline_rq *drq)
dd->next_drq[data_dir] = rb_entry_drq(rbnext);
}
- BUG_ON(!ON_RB(&drq->rb_node));
+ BUG_ON(!RB_EMPTY_NODE(&drq->rb_node));
rb_erase(&drq->rb_node, DRQ_RB_ROOT(dd, drq));
- RB_CLEAR(&drq->rb_node);
+ RB_CLEAR_NODE(&drq->rb_node);
}
static struct request *
@@ -503,7 +492,7 @@ static int deadline_dispatch_requests(request_queue_t *q, int force)
*/
if (reads) {
- BUG_ON(RB_EMPTY(&dd->sort_list[READ]));
+ BUG_ON(RB_EMPTY_ROOT(&dd->sort_list[READ]));
if (writes && (dd->starved++ >= dd->writes_starved))
goto dispatch_writes;
@@ -519,7 +508,7 @@ static int deadline_dispatch_requests(request_queue_t *q, int force)
if (writes) {
dispatch_writes:
- BUG_ON(RB_EMPTY(&dd->sort_list[WRITE]));
+ BUG_ON(RB_EMPTY_ROOT(&dd->sort_list[WRITE]));
dd->starved = 0;
@@ -626,7 +615,7 @@ static void *deadline_init_queue(request_queue_t *q, elevator_t *e)
return NULL;
memset(dd, 0, sizeof(*dd));
- dd->hash = kmalloc_node(sizeof(struct list_head)*DL_HASH_ENTRIES,
+ dd->hash = kmalloc_node(sizeof(struct hlist_head)*DL_HASH_ENTRIES,
GFP_KERNEL, q->node);
if (!dd->hash) {
kfree(dd);
@@ -642,7 +631,7 @@ static void *deadline_init_queue(request_queue_t *q, elevator_t *e)
}
for (i = 0; i < DL_HASH_ENTRIES; i++)
- INIT_LIST_HEAD(&dd->hash[i]);
+ INIT_HLIST_HEAD(&dd->hash[i]);
INIT_LIST_HEAD(&dd->fifo_list[READ]);
INIT_LIST_HEAD(&dd->fifo_list[WRITE]);
@@ -675,11 +664,10 @@ deadline_set_request(request_queue_t *q, struct request *rq, struct bio *bio,
drq = mempool_alloc(dd->drq_pool, gfp_mask);
if (drq) {
memset(drq, 0, sizeof(*drq));
- RB_CLEAR(&drq->rb_node);
+ RB_CLEAR_NODE(&drq->rb_node);
drq->request = rq;
- INIT_LIST_HEAD(&drq->hash);
- drq->on_hash = 0;
+ INIT_HLIST_NODE(&drq->hash);
INIT_LIST_HEAD(&drq->fifo);
diff --git a/block/elevator.c b/block/elevator.c
index a0afdd317cef..bc7baeec0d10 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -27,7 +27,6 @@
#include <linux/blkdev.h>
#include <linux/elevator.h>
#include <linux/bio.h>
-#include <linux/config.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/init.h>
@@ -850,12 +849,9 @@ fail_register:
* one again (along with re-adding the sysfs dir)
*/
elevator_exit(e);
- e = NULL;
q->elevator = old_elevator;
elv_register_queue(q);
clear_bit(QUEUE_FLAG_ELVSWITCH, &q->queue_flags);
- if (e)
- kobject_put(&e->kobj);
return 0;
}
diff --git a/block/genhd.c b/block/genhd.c
index 5a8d3bf02f17..25d1f42568cc 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -2,7 +2,6 @@
* gendisk handling
*/
-#include <linux/config.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/genhd.h>
@@ -17,8 +16,7 @@
#include <linux/buffer_head.h>
#include <linux/mutex.h>
-static struct subsystem block_subsys;
-
+struct subsystem block_subsys;
static DEFINE_MUTEX(block_subsys_lock);
/*
@@ -511,9 +509,7 @@ static struct kset_uevent_ops block_uevent_ops = {
.uevent = block_uevent,
};
-/* declare block_subsys. */
-static decl_subsys(block, &ktype_block, &block_uevent_ops);
-
+decl_subsys(block, &ktype_block, &block_uevent_ops);
/*
* aggregate disk stat collector. Uses the same stats that the sysfs
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index 7eb36c53f4b7..5813d63c20af 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -10,7 +10,6 @@
/*
* This handles all read/write requests to block devices
*/
-#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/backing-dev.h>
@@ -638,7 +637,7 @@ void blk_queue_bounce_limit(request_queue_t *q, u64 dma_addr)
/* Assume anything <= 4GB can be handled by IOMMU.
Actually some IOMMUs can handle everything, but I don't
know of a way to test this here. */
- if (bounce_pfn < (0xffffffff>>PAGE_SHIFT))
+ if (bounce_pfn < (min_t(u64,0xffffffff,BLK_BOUNCE_HIGH) >> PAGE_SHIFT))
dma = 1;
q->bounce_pfn = max_low_pfn;
#else
@@ -1663,6 +1662,8 @@ static void blk_unplug_timeout(unsigned long data)
**/
void blk_start_queue(request_queue_t *q)
{
+ WARN_ON(!irqs_disabled());
+
clear_bit(QUEUE_FLAG_STOPPED, &q->queue_flags);
/*
@@ -1878,7 +1879,8 @@ EXPORT_SYMBOL(blk_alloc_queue_node);
* get dealt with eventually.
*
* The queue spin lock must be held while manipulating the requests on the
- * request queue.
+ * request queue; this lock will be taken also from interrupt context, so irq
+ * disabling is needed for it.
*
* Function returns a pointer to the initialized request queue, or NULL if
* it didn't succeed.
@@ -2742,7 +2744,7 @@ static int attempt_merge(request_queue_t *q, struct request *req,
return 0;
/*
- * not contigious
+ * not contiguous
*/
if (req->sector + req->nr_sectors != next->sector)
return 0;
@@ -2824,6 +2826,9 @@ static void init_request_from_bio(struct request *req, struct bio *bio)
if (unlikely(bio_barrier(bio)))
req->flags |= (REQ_HARDBARRIER | REQ_NOMERGE);
+ if (bio_sync(bio))
+ req->flags |= REQ_RW_SYNC;
+
req->errors = 0;
req->hard_sector = req->sector = bio->bi_sector;
req->hard_nr_sectors = req->nr_sectors = bio_sectors(bio);
@@ -3111,9 +3116,9 @@ void submit_bio(int rw, struct bio *bio)
BIO_BUG_ON(!bio->bi_io_vec);
bio->bi_rw |= rw;
if (rw & WRITE)
- mod_page_state(pgpgout, count);
+ count_vm_events(PGPGOUT, count);
else
- mod_page_state(pgpgin, count);
+ count_vm_events(PGPGIN, count);
if (unlikely(block_dump)) {
char b[BDEVNAME_SIZE];
@@ -3359,12 +3364,11 @@ EXPORT_SYMBOL(end_that_request_chunk);
*/
static void blk_done_softirq(struct softirq_action *h)
{
- struct list_head *cpu_list;
- LIST_HEAD(local_list);
+ struct list_head *cpu_list, local_list;
local_irq_disable();
cpu_list = &__get_cpu_var(blk_cpu_done);
- list_splice_init(cpu_list, &local_list);
+ list_replace_init(cpu_list, &local_list);
local_irq_enable();
while (!list_empty(&local_list)) {
@@ -3398,7 +3402,7 @@ static int blk_cpu_notify(struct notifier_block *self, unsigned long action,
}
-static struct notifier_block blk_cpu_notifier = {
+static struct notifier_block __devinitdata blk_cpu_notifier = {
.notifier_call = blk_cpu_notify,
};
@@ -3410,7 +3414,7 @@ static struct notifier_block blk_cpu_notifier = {
*
* Description:
* Ends all I/O on a request. It does not handle partial completions,
- * unless the driver actually implements this in its completionc callback
+ * unless the driver actually implements this in its completion callback
* through requeueing. Theh actual completion happens out-of-order,
* through a softirq handler. The user must have registered a completion
* callback through blk_queue_softirq_done().
@@ -3536,9 +3540,7 @@ int __init blk_dev_init(void)
INIT_LIST_HEAD(&per_cpu(blk_cpu_done, i));
open_softirq(BLOCK_SOFTIRQ, blk_done_softirq, NULL);
-#ifdef CONFIG_HOTPLUG_CPU
- register_cpu_notifier(&blk_cpu_notifier);
-#endif
+ register_hotcpu_notifier(&blk_cpu_notifier);
blk_max_low_pfn = max_low_pfn;
blk_max_pfn = max_pfn;