diff options
-rw-r--r-- | block/blk-cgroup.c | 7 | ||||
-rw-r--r-- | block/blk-cgroup.h | 17 |
2 files changed, 9 insertions, 15 deletions
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 069bc202ffe3..1463ca6b7aae 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c | |||
@@ -80,7 +80,7 @@ static struct blkcg_gq *blkg_alloc(struct blkcg *blkcg, struct request_queue *q, | |||
80 | blkg->q = q; | 80 | blkg->q = q; |
81 | INIT_LIST_HEAD(&blkg->q_node); | 81 | INIT_LIST_HEAD(&blkg->q_node); |
82 | blkg->blkcg = blkcg; | 82 | blkg->blkcg = blkcg; |
83 | blkg->refcnt = 1; | 83 | atomic_set(&blkg->refcnt, 1); |
84 | 84 | ||
85 | /* root blkg uses @q->root_rl, init rl only for !root blkgs */ | 85 | /* root blkg uses @q->root_rl, init rl only for !root blkgs */ |
86 | if (blkcg != &blkcg_root) { | 86 | if (blkcg != &blkcg_root) { |
@@ -399,11 +399,8 @@ void __blkg_release_rcu(struct rcu_head *rcu_head) | |||
399 | 399 | ||
400 | /* release the blkcg and parent blkg refs this blkg has been holding */ | 400 | /* release the blkcg and parent blkg refs this blkg has been holding */ |
401 | css_put(&blkg->blkcg->css); | 401 | css_put(&blkg->blkcg->css); |
402 | if (blkg->parent) { | 402 | if (blkg->parent) |
403 | spin_lock_irq(blkg->q->queue_lock); | ||
404 | blkg_put(blkg->parent); | 403 | blkg_put(blkg->parent); |
405 | spin_unlock_irq(blkg->q->queue_lock); | ||
406 | } | ||
407 | 404 | ||
408 | blkg_free(blkg); | 405 | blkg_free(blkg); |
409 | } | 406 | } |
diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h index cbb7f943f78a..1c401b057151 100644 --- a/block/blk-cgroup.h +++ b/block/blk-cgroup.h | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/seq_file.h> | 18 | #include <linux/seq_file.h> |
19 | #include <linux/radix-tree.h> | 19 | #include <linux/radix-tree.h> |
20 | #include <linux/blkdev.h> | 20 | #include <linux/blkdev.h> |
21 | #include <linux/atomic.h> | ||
21 | 22 | ||
22 | /* Max limits for throttle policy */ | 23 | /* Max limits for throttle policy */ |
23 | #define THROTL_IOPS_MAX UINT_MAX | 24 | #define THROTL_IOPS_MAX UINT_MAX |
@@ -104,7 +105,7 @@ struct blkcg_gq { | |||
104 | struct request_list rl; | 105 | struct request_list rl; |
105 | 106 | ||
106 | /* reference count */ | 107 | /* reference count */ |
107 | int refcnt; | 108 | atomic_t refcnt; |
108 | 109 | ||
109 | /* is this blkg online? protected by both blkcg and q locks */ | 110 | /* is this blkg online? protected by both blkcg and q locks */ |
110 | bool online; | 111 | bool online; |
@@ -257,13 +258,12 @@ static inline int blkg_path(struct blkcg_gq *blkg, char *buf, int buflen) | |||
257 | * blkg_get - get a blkg reference | 258 | * blkg_get - get a blkg reference |
258 | * @blkg: blkg to get | 259 | * @blkg: blkg to get |
259 | * | 260 | * |
260 | * The caller should be holding queue_lock and an existing reference. | 261 | * The caller should be holding an existing reference. |
261 | */ | 262 | */ |
262 | static inline void blkg_get(struct blkcg_gq *blkg) | 263 | static inline void blkg_get(struct blkcg_gq *blkg) |
263 | { | 264 | { |
264 | lockdep_assert_held(blkg->q->queue_lock); | 265 | WARN_ON_ONCE(atomic_read(&blkg->refcnt) <= 0); |
265 | WARN_ON_ONCE(!blkg->refcnt); | 266 | atomic_inc(&blkg->refcnt); |
266 | blkg->refcnt++; | ||
267 | } | 267 | } |
268 | 268 | ||
269 | void __blkg_release_rcu(struct rcu_head *rcu); | 269 | void __blkg_release_rcu(struct rcu_head *rcu); |
@@ -271,14 +271,11 @@ void __blkg_release_rcu(struct rcu_head *rcu); | |||
271 | /** | 271 | /** |
272 | * blkg_put - put a blkg reference | 272 | * blkg_put - put a blkg reference |
273 | * @blkg: blkg to put | 273 | * @blkg: blkg to put |
274 | * | ||
275 | * The caller should be holding queue_lock. | ||
276 | */ | 274 | */ |
277 | static inline void blkg_put(struct blkcg_gq *blkg) | 275 | static inline void blkg_put(struct blkcg_gq *blkg) |
278 | { | 276 | { |
279 | lockdep_assert_held(blkg->q->queue_lock); | 277 | WARN_ON_ONCE(atomic_read(&blkg->refcnt) <= 0); |
280 | WARN_ON_ONCE(blkg->refcnt <= 0); | 278 | if (atomic_dec_and_test(&blkg->refcnt)) |
281 | if (!--blkg->refcnt) | ||
282 | call_rcu(&blkg->rcu_head, __blkg_release_rcu); | 279 | call_rcu(&blkg->rcu_head, __blkg_release_rcu); |
283 | } | 280 | } |
284 | 281 | ||