Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 25879
b: refs/heads/master
c: dbecf3a
h: refs/heads/master
i:
  25877: b13c220
  25875: a226994
  25871: 224634b
v: v3
  • Loading branch information
OGAWA Hirofumi authored and Jens Axboe committed Apr 18, 2006
1 parent 2a41ae4 commit 6ee017b
Show file tree
Hide file tree
Showing 2 changed files with 28 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: fba822722e3f9d438fca8fd9541d7ddd447d7a48
refs/heads/master: dbecf3ab40b5a6cc4499543778cd9f9682c0abad
33 changes: 27 additions & 6 deletions trunk/block/cfq-iosched.c
Original file line number Diff line number Diff line change
Expand Up @@ -1472,15 +1472,31 @@ cfq_get_queue(struct cfq_data *cfqd, unsigned int key, struct task_struct *tsk,
return cfqq;
}

static void
cfq_drop_dead_cic(struct io_context *ioc, struct cfq_io_context *cic)
{
read_lock(&cfq_exit_lock);
rb_erase(&cic->rb_node, &ioc->cic_root);
read_unlock(&cfq_exit_lock);
kmem_cache_free(cfq_ioc_pool, cic);
atomic_dec(&ioc_count);
}

static struct cfq_io_context *
cfq_cic_rb_lookup(struct cfq_data *cfqd, struct io_context *ioc)
{
struct rb_node *n = ioc->cic_root.rb_node;
struct rb_node *n;
struct cfq_io_context *cic;
void *key = cfqd;

restart:
n = ioc->cic_root.rb_node;
while (n) {
cic = rb_entry(n, struct cfq_io_context, rb_node);
if (unlikely(!cic->key)) {
cfq_drop_dead_cic(ioc, cic);
goto restart;
}

if (key < cic->key)
n = n->rb_left;
Expand All @@ -1497,20 +1513,24 @@ static inline void
cfq_cic_link(struct cfq_data *cfqd, struct io_context *ioc,
struct cfq_io_context *cic)
{
struct rb_node **p = &ioc->cic_root.rb_node;
struct rb_node *parent = NULL;
struct rb_node **p;
struct rb_node *parent;
struct cfq_io_context *__cic;

read_lock(&cfq_exit_lock);

cic->ioc = ioc;
cic->key = cfqd;

ioc->set_ioprio = cfq_ioc_set_ioprio;

restart:
parent = NULL;
p = &ioc->cic_root.rb_node;
while (*p) {
parent = *p;
__cic = rb_entry(parent, struct cfq_io_context, rb_node);
if (unlikely(!__cic->key)) {
cfq_drop_dead_cic(ioc, cic);
goto restart;
}

if (cic->key < __cic->key)
p = &(*p)->rb_left;
Expand All @@ -1520,6 +1540,7 @@ cfq_cic_link(struct cfq_data *cfqd, struct io_context *ioc,
BUG();
}

read_lock(&cfq_exit_lock);
rb_link_node(&cic->rb_node, parent, p);
rb_insert_color(&cic->rb_node, &ioc->cic_root);
list_add(&cic->queue_list, &cfqd->cic_list);
Expand Down

0 comments on commit 6ee017b

Please sign in to comment.