diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c index cd92f417cc807a1d82cafcad096eafc4c898d6a8..b663cd8b9e46f68d6854119f2a960f4d4213dcba 100644 --- a/block/bfq-cgroup.c +++ b/block/bfq-cgroup.c @@ -254,14 +254,12 @@ struct bfq_group *bfqq_group(struct bfq_queue *bfqq) static void bfqg_get(struct bfq_group *bfqg) { - bfqg->ref++; + refcount_inc(&bfqg->ref); } static void bfqg_put(struct bfq_group *bfqg) { - bfqg->ref--; - - if (bfqg->ref == 0) + if (refcount_dec_and_test(&bfqg->ref)) kfree(bfqg); } @@ -448,7 +446,7 @@ static struct blkg_policy_data *bfq_pd_alloc(gfp_t gfp, int node) } /* see comments in bfq_bic_update_cgroup for why refcounting */ - bfqg_get(bfqg); + refcount_set(&bfqg->ref, 1); return &bfqg->pd; } diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h index bb2b9c71048e3ec32339cef72299ac3aa6fa60a0..9bbd8ea906dd6de07069f0d911c3dcb2e6b1cf6b 100644 --- a/block/bfq-iosched.h +++ b/block/bfq-iosched.h @@ -862,7 +862,7 @@ struct bfq_group { char blkg_path[128]; /* reference counter (see comments in bfq_bic_update_cgroup) */ - int ref; + refcount_t ref; struct bfq_entity entity; struct bfq_sched_data sched_data;