• J
    block: Allow bdi re-registration · b6f8fec4
    Jan Kara 提交于
    SCSI can call device_add_disk() several times for one request queue when
    a device in unbound and bound, creating new gendisk each time. This will
    lead to bdi being repeatedly registered and unregistered. This was not a
    big problem until commit 165a5e22 "block: Move bdi_unregister() to
    del_gendisk()" since bdi was only registered repeatedly (bdi_register()
    handles repeated calls fine, only we ended up leaking reference to
    gendisk due to overwriting bdi->owner) but unregistered only in
    blk_cleanup_queue() which didn't get called repeatedly. After
    165a5e22 we were doing correct bdi_register() - bdi_unregister()
    cycles however bdi_unregister() is not prepared for it. So make sure
    bdi_unregister() cleans up bdi in such a way that it is prepared for
    a possible following bdi_register() call.
    
    An easy way to provoke this behavior is to enable
    CONFIG_DEBUG_TEST_DRIVER_REMOVE and use scsi_debug driver to create a
    scsi disk which immediately hangs without this fix.
    
    Fixes: 165a5e22Signed-off-by: NJan Kara <jack@suse.cz>
    Tested-by: NOmar Sandoval <osandov@fb.com>
    Signed-off-by: NJens Axboe <axboe@fb.com>
    b6f8fec4
backing-dev.c 27.2 KB