Skip to content

Commit 8176080

Browse files
taosu-linuxaxboe
authored andcommitted
block: Skip destroyed blkg when restart in blkg_destroy_all()
Kernel hang in blkg_destroy_all() when total blkg greater than BLKG_DESTROY_BATCH_SIZE, because of not removing destroyed blkg in blkg_list. So the size of blkg_list is same after destroying a batch of blkg, and the infinite 'restart' occurs. Since blkg should stay on the queue list until blkg_free_workfn(), skip destroyed blkg when restart a new round, which will solve this kernel hang issue and satisfy the previous will to restart. Reported-by: Xiangfei Ma <xiangfeix.ma@intel.com> Tested-by: Xiangfei Ma <xiangfeix.ma@intel.com> Tested-by: Farrah Chen <farrah.chen@intel.com> Signed-off-by: Tao Su <tao1.su@linux.intel.com> Fixes: f1c006f ("blk-cgroup: synchronize pd_free_fn() from blkg_free_workfn() and blkcg_deactivate_policy()") Suggested-and-reviewed-by: Yu Kuai <yukuai3@huawei.com> Link: https://lore.kernel.org/r/20230428045149.1310073-1-tao1.su@linux.intel.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 3e46c89 commit 8176080

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

block/blk-cgroup.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,9 @@ static void blkg_destroy_all(struct gendisk *disk)
527527
list_for_each_entry_safe(blkg, n, &q->blkg_list, q_node) {
528528
struct blkcg *blkcg = blkg->blkcg;
529529

530+
if (hlist_unhashed(&blkg->blkcg_node))
531+
continue;
532+
530533
spin_lock(&blkcg->lock);
531534
blkg_destroy(blkg);
532535
spin_unlock(&blkcg->lock);

0 commit comments

Comments
 (0)