]> git.baikalelectronics.ru Git - kernel.git/commit
block: Allow bdi re-registration
authorJan Kara <jack@suse.cz>
Wed, 8 Mar 2017 16:48:31 +0000 (17:48 +0100)
committerJens Axboe <axboe@fb.com>
Wed, 8 Mar 2017 17:55:17 +0000 (10:55 -0700)
commitccdd315f7576e3d60f65501ead285c175217d78b
tree659041df7070189896307ebe2bee2cf2b6d713b7
parent3c92e2980166ed14538e6ae4233486a87485daae
block: Allow bdi re-registration

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 62e779c8065e "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
62e779c8065e 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: 62e779c8065e4a24a1b964a77aa6be941cc5c13b
Signed-off-by: Jan Kara <jack@suse.cz>
Tested-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
mm/backing-dev.c