Skip to content

Commit

Permalink
cfq-iosched: read_lock() does not always imply rcu_read_lock()
Browse files Browse the repository at this point in the history
For some configurations of CONFIG_PREEMPT that is not true. So
get rid of __call_for_each_cic() and always uses the explicitly
rcu_read_lock() protected call_for_each_cic() instead.

This fixes a potential bug related to IO scheduler removal or
online switching.

Thanks to Paul McKenney for clarifying this.

Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Jens Axboe committed Apr 19, 2011
1 parent bd900d4 commit 5f45c69
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions block/cfq-iosched.c
Original file line number Diff line number Diff line change
Expand Up @@ -2582,28 +2582,20 @@ static void cfq_put_queue(struct cfq_queue *cfqq)
}

/*
* Must always be called with the rcu_read_lock() held
* Call func for each cic attached to this ioc.
*/
static void
__call_for_each_cic(struct io_context *ioc,
void (*func)(struct io_context *, struct cfq_io_context *))
call_for_each_cic(struct io_context *ioc,
void (*func)(struct io_context *, struct cfq_io_context *))
{
struct cfq_io_context *cic;
struct hlist_node *n;

rcu_read_lock();

hlist_for_each_entry_rcu(cic, n, &ioc->cic_list, cic_list)
func(ioc, cic);
}

/*
* Call func for each cic attached to this ioc.
*/
static void
call_for_each_cic(struct io_context *ioc,
void (*func)(struct io_context *, struct cfq_io_context *))
{
rcu_read_lock();
__call_for_each_cic(ioc, func);
rcu_read_unlock();
}

Expand Down Expand Up @@ -2664,7 +2656,7 @@ static void cfq_free_io_context(struct io_context *ioc)
* should be ok to iterate over the known list, we will see all cic's
* since no new ones are added.
*/
__call_for_each_cic(ioc, cic_free_func);
call_for_each_cic(ioc, cic_free_func);
}

static void cfq_put_cooperator(struct cfq_queue *cfqq)
Expand Down

0 comments on commit 5f45c69

Please sign in to comment.