block, cfq: move ioc ioprio/cgroup changed handling to cic

ioprio/cgroup change was handled by marking the changed state in ioc
and, on the following access to the ioc, performing RCU-protected
iteration through all cic's grabbing the matching queue_lock.

This patch moves the changed state to each cic.  When ioprio or cgroup
changes, the respective bit is set on all cic's of the ioc and when
each of those cic (not ioc) is accessed, change is applied for that
specific ioc-queue pair.

This also fixes the following two race conditions between setting and
clearing of changed states.

* Missing barrier between assign/load of ioprio and ioprio_changed
  allowed applying old ioprio.

* Change requests could happen between application of change and
  clearing of changed variables.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Tejun Heo 2011-12-14 00:33:38 +01:00 committed by Jens Axboe
parent 283287a52e
commit dc86900e0a
5 changed files with 65 additions and 27 deletions

View file

@ -13,6 +13,11 @@ struct cfq_ttime {
unsigned long ttime_mean;
};
enum {
CIC_IOPRIO_CHANGED,
CIC_CGROUP_CHANGED,
};
struct cfq_io_context {
void *key;
struct request_queue *q;
@ -26,6 +31,8 @@ struct cfq_io_context {
struct list_head queue_list;
struct hlist_node cic_list;
unsigned long changed;
void (*dtor)(struct io_context *); /* destructor */
void (*exit)(struct io_context *); /* called on task exit */
@ -44,11 +51,6 @@ struct io_context {
spinlock_t lock;
unsigned short ioprio;
unsigned short ioprio_changed;
#if defined(CONFIG_BLK_CGROUP) || defined(CONFIG_BLK_CGROUP_MODULE)
unsigned short cgroup_changed;
#endif
/*
* For request batching
@ -81,6 +83,8 @@ void put_io_context(struct io_context *ioc);
void exit_io_context(struct task_struct *task);
struct io_context *get_task_io_context(struct task_struct *task,
gfp_t gfp_flags, int node);
void ioc_ioprio_changed(struct io_context *ioc, int ioprio);
void ioc_cgroup_changed(struct io_context *ioc);
#else
struct io_context;
static inline void put_io_context(struct io_context *ioc) { }