Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 251157
b: refs/heads/master
c: 4843c69
h: refs/heads/master
i:
  251155: e7d8ed9
v: v3
  • Loading branch information
Vivek Goyal authored and Jens Axboe committed May 20, 2011
1 parent 8d3e553 commit 730f361
Show file tree
Hide file tree
Showing 2 changed files with 22 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: 5617cbef7723952cbdff28c7a10ff8a254945f4f
refs/heads/master: 4843c69d496a8d2e4caab6182fe016b9a79136e0
22 changes: 21 additions & 1 deletion trunk/block/blk-throttle.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ struct throtl_grp {

/* Some throttle limits got updated for the group */
int limits_changed;

struct rcu_head rcu_head;
};

struct throtl_data
Expand Down Expand Up @@ -151,12 +153,30 @@ static inline struct throtl_grp *throtl_ref_get_tg(struct throtl_grp *tg)
return tg;
}

static void throtl_free_tg(struct rcu_head *head)
{
struct throtl_grp *tg;

tg = container_of(head, struct throtl_grp, rcu_head);
kfree(tg);
}

static void throtl_put_tg(struct throtl_grp *tg)
{
BUG_ON(atomic_read(&tg->ref) <= 0);
if (!atomic_dec_and_test(&tg->ref))
return;
kfree(tg);

/*
* A group is freed in rcu manner. But having an rcu lock does not
* mean that one can access all the fields of blkg and assume these
* are valid. For example, don't try to follow throtl_data and
* request queue links.
*
* Having a reference to blkg under an rcu allows acess to only
* values local to groups like group stats and group rate limits
*/
call_rcu(&tg->rcu_head, throtl_free_tg);
}

static void throtl_init_group(struct throtl_grp *tg)
Expand Down

0 comments on commit 730f361

Please sign in to comment.