blkcg: perpcu_ref init/exit should be done from blkg_alloc/free()
authorTejun Heo <tj@kernel.org>
Thu, 13 Jun 2019 22:30:39 +0000 (15:30 -0700)
committerJens Axboe <axboe@kernel.dk>
Sat, 15 Jun 2019 16:39:39 +0000 (10:39 -0600)
commitef069b97feec11c2399bbc5f6f347b35482105dc
tree72014b442cbeacfac5af39651a51f33e28fcb2b9
parentf539da82f2158916e154d206054e0efd5df7ab61
blkcg: perpcu_ref init/exit should be done from blkg_alloc/free()

blkg alloc is performed as a separate step from the rest of blkg
creation so that GFP_KERNEL allocations can be used when creating
blkgs from configuration file writes because otherwise user actions
may fail due to failures of opportunistic GFP_NOWAIT allocations.

While making blkgs use percpu_ref, 7fcf2b033b84 ("blkcg: change blkg
reference counting to use percpu_ref") incorrectly added unconditional
opportunistic percpu_ref_init() to blkg_create() breaking this
guarantee.

This patch moves percpu_ref_init() to blkg_alloc() so makes it use
@gfp_mask that blkg_alloc() is called with.  Also, percpu_ref_exit()
is moved to blkg_free() for consistency.

Signed-off-by: Tejun Heo <tj@kernel.org>
Fixes: 7fcf2b033b84 ("blkcg: change blkg reference counting to use percpu_ref")
Cc: Dennis Zhou <dennis@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-cgroup.c