• Ming Lei's avatar
    block: fix q->blkg_list corruption during disk rebind · 8b8ace08
    Ming Lei authored
    Multiple gendisk instances can allocated/added for single request queue
    in case of disk rebind. blkg may still stay in q->blkg_list when calling
    blkcg_init_disk() for rebind, then q->blkg_list becomes corrupted.
    
    Fix the list corruption issue by:
    
    - add blkg_init_queue() to initialize q->blkg_list & q->blkcg_mutex only
    - move calling blkg_init_queue() into blk_alloc_queue()
    
    The list corruption should be started since commit f1c006f1 ("blk-cgroup:
    synchronize pd_free_fn() from blkg_free_workfn() and blkcg_deactivate_policy()")
    which delays removing blkg from q->blkg_list into blkg_free_workfn().
    
    Fixes: f1c006f1 ("blk-cgroup: synchronize pd_free_fn() from blkg_free_workfn() and blkcg_deactivate_policy()")
    Fixes: 1059699f ("block: move blkcg initialization/destroy into disk allocation/release handler")
    Cc: Yu Kuai <yukuai3@huawei.com>
    Cc: Tejun Heo <tj@kernel.org>
    Signed-off-by: default avatarMing Lei <ming.lei@redhat.com>
    Reviewed-by: default avatarYu Kuai <yukuai3@huawei.com>
    Link: https://lore.kernel.org/r/20240407125910.4053377-1-ming.lei@redhat.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
    8b8ace08
blk-cgroup.c 56.6 KB