|
18 | 18 | #include <linux/seq_file.h>
|
19 | 19 | #include <linux/radix-tree.h>
|
20 | 20 | #include <linux/blkdev.h>
|
| 21 | +#include <linux/atomic.h> |
21 | 22 |
|
22 | 23 | /* Max limits for throttle policy */
|
23 | 24 | #define THROTL_IOPS_MAX UINT_MAX
|
@@ -104,7 +105,7 @@ struct blkcg_gq {
|
104 | 105 | struct request_list rl;
|
105 | 106 |
|
106 | 107 | /* reference count */
|
107 |
| - int refcnt; |
| 108 | + atomic_t refcnt; |
108 | 109 |
|
109 | 110 | /* is this blkg online? protected by both blkcg and q locks */
|
110 | 111 | bool online;
|
@@ -253,28 +254,24 @@ static inline int blkg_path(struct blkcg_gq *blkg, char *buf, int buflen)
|
253 | 254 | * blkg_get - get a blkg reference
|
254 | 255 | * @blkg: blkg to get
|
255 | 256 | *
|
256 |
| - * The caller should be holding queue_lock and an existing reference. |
| 257 | + * The caller should be holding an existing reference. |
257 | 258 | */
|
258 | 259 | static inline void blkg_get(struct blkcg_gq *blkg)
|
259 | 260 | {
|
260 |
| - lockdep_assert_held(blkg->q->queue_lock); |
261 |
| - WARN_ON_ONCE(!blkg->refcnt); |
262 |
| - blkg->refcnt++; |
| 261 | + WARN_ON_ONCE(atomic_read(&blkg->refcnt) <= 0); |
| 262 | + atomic_inc(&blkg->refcnt); |
263 | 263 | }
|
264 | 264 |
|
265 | 265 | void __blkg_release_rcu(struct rcu_head *rcu);
|
266 | 266 |
|
267 | 267 | /**
|
268 | 268 | * blkg_put - put a blkg reference
|
269 | 269 | * @blkg: blkg to put
|
270 |
| - * |
271 |
| - * The caller should be holding queue_lock. |
272 | 270 | */
|
273 | 271 | static inline void blkg_put(struct blkcg_gq *blkg)
|
274 | 272 | {
|
275 |
| - lockdep_assert_held(blkg->q->queue_lock); |
276 |
| - WARN_ON_ONCE(blkg->refcnt <= 0); |
277 |
| - if (!--blkg->refcnt) |
| 273 | + WARN_ON_ONCE(atomic_read(&blkg->refcnt) <= 0); |
| 274 | + if (atomic_dec_and_test(&blkg->refcnt)) |
278 | 275 | call_rcu(&blkg->rcu_head, __blkg_release_rcu);
|
279 | 276 | }
|
280 | 277 |
|
|
0 commit comments