]> git.baikalelectronics.ru Git - kernel.git/commit
blkcg: make blkcg_print_stat() print stats only for online blkgs
authorTejun Heo <tj@kernel.org>
Tue, 5 Nov 2019 16:09:51 +0000 (08:09 -0800)
committerJens Axboe <axboe@kernel.dk>
Thu, 7 Nov 2019 00:08:38 +0000 (17:08 -0700)
commit6ecdc3c0c722bb4ff8dff20144ec49e6d50c026d
tree9c9c269d564efa33f2d3a6eebfd6f5a51db2e970
parent241d6a9b1c83e12f3437ff8b5d8167d7b70b12d7
blkcg: make blkcg_print_stat() print stats only for online blkgs

blkcg_print_stat() iterates blkgs under RCU and doesn't test whether
the blkg is online.  This can call into pd_stat_fn() on a pd which is
still being initialized leading to an oops.

The heaviest operation - recursively summing up rwstat counters - is
already done while holding the queue_lock.  Expand queue_lock to cover
the other operations and skip the blkg if it isn't online yet.  The
online state is protected by both blkcg and queue locks, so this
guarantees that only online blkgs are processed.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Roman Gushchin <guro@fb.com>
Cc: Josef Bacik <jbacik@fb.com>
Fixes: 893f4e1762dd ("blk-cgroup: allow controllers to output their own stats")
Cc: stable@vger.kernel.org # v4.19+
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-cgroup.c