block: move disk unregistration work from del_gendisk() to a helper

There is quite a bit of code on del_gendisk() which relates to
unregistering the disk, using register_disk() as an counter.
Move all this code into a helper instead of re-writing our own,
which we'll need later to handle errors on add_disk().

I note that register_disk() links the bdi at the end, but since
del_gendisk() deals with this before queue de-registration we'll
take a hint that's the right order that this should be done, and
we shouldn't instead strictly unwind register_disk() exactly.

We'll instead keep whatever lessons have been learned from
del_gendisk().

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
1 file changed