Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 309210
b: refs/heads/master
c: 923adde
h: refs/heads/master
v: v3
  • Loading branch information
Tejun Heo authored and Jens Axboe committed Mar 6, 2012
1 parent 11f87af commit 2cc2d81
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 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: 5efd611351d1a847c72d74fb12ff4bd187c0cb2c
refs/heads/master: 923adde1be1df57cebd80c563058e503376645e8
48 changes: 47 additions & 1 deletion trunk/block/blk-cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
static DEFINE_SPINLOCK(blkio_list_lock);
static LIST_HEAD(blkio_list);

static DEFINE_MUTEX(all_q_mutex);
static LIST_HEAD(all_q_list);

struct blkio_cgroup blkio_root_cgroup = { .weight = 2*BLKIO_WEIGHT_DEFAULT };
EXPORT_SYMBOL_GPL(blkio_root_cgroup);

Expand Down Expand Up @@ -1472,9 +1475,20 @@ blkiocg_create(struct cgroup_subsys *subsys, struct cgroup *cgroup)
*/
int blkcg_init_queue(struct request_queue *q)
{
int ret;

might_sleep();

return blk_throtl_init(q);
ret = blk_throtl_init(q);
if (ret)
return ret;

mutex_lock(&all_q_mutex);
INIT_LIST_HEAD(&q->all_q_node);
list_add_tail(&q->all_q_node, &all_q_list);
mutex_unlock(&all_q_mutex);

return 0;
}

/**
Expand All @@ -1498,6 +1512,10 @@ void blkcg_drain_queue(struct request_queue *q)
*/
void blkcg_exit_queue(struct request_queue *q)
{
mutex_lock(&all_q_mutex);
list_del_init(&q->all_q_node);
mutex_unlock(&all_q_mutex);

blk_throtl_exit(q);
}

Expand Down Expand Up @@ -1543,26 +1561,54 @@ static void blkiocg_attach(struct cgroup_subsys *ss, struct cgroup *cgrp,
}
}

static void blkcg_bypass_start(void)
__acquires(&all_q_mutex)
{
struct request_queue *q;

mutex_lock(&all_q_mutex);

list_for_each_entry(q, &all_q_list, all_q_node) {
blk_queue_bypass_start(q);
blkg_destroy_all(q);
}
}

static void blkcg_bypass_end(void)
__releases(&all_q_mutex)
{
struct request_queue *q;

list_for_each_entry(q, &all_q_list, all_q_node)
blk_queue_bypass_end(q);

mutex_unlock(&all_q_mutex);
}

void blkio_policy_register(struct blkio_policy_type *blkiop)
{
blkcg_bypass_start();
spin_lock(&blkio_list_lock);

BUG_ON(blkio_policy[blkiop->plid]);
blkio_policy[blkiop->plid] = blkiop;
list_add_tail(&blkiop->list, &blkio_list);

spin_unlock(&blkio_list_lock);
blkcg_bypass_end();
}
EXPORT_SYMBOL_GPL(blkio_policy_register);

void blkio_policy_unregister(struct blkio_policy_type *blkiop)
{
blkcg_bypass_start();
spin_lock(&blkio_list_lock);

BUG_ON(blkio_policy[blkiop->plid] != blkiop);
blkio_policy[blkiop->plid] = NULL;
list_del_init(&blkiop->list);

spin_unlock(&blkio_list_lock);
blkcg_bypass_end();
}
EXPORT_SYMBOL_GPL(blkio_policy_unregister);
3 changes: 3 additions & 0 deletions trunk/include/linux/blkdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,9 @@ struct request_queue {
struct bsg_class_device bsg_dev;
#endif

#ifdef CONFIG_BLK_CGROUP
struct list_head all_q_node;
#endif
#ifdef CONFIG_BLK_DEV_THROTTLING
/* Throttle data */
struct throtl_data *td;
Expand Down

0 comments on commit 2cc2d81

Please sign in to comment.