]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: reset device back to allocation state when removing
authorJohannes Thumshirn <jthumshirn@suse.de>
Wed, 4 Dec 2019 13:36:39 +0000 (14:36 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 20 Jan 2020 15:40:53 +0000 (16:40 +0100)
commitb64ea9c975b7d93c1f08183875ed510352743dfe
tree81f49161c70d86f27389284b3680a7479ab40571
parentdc3f0a2fedf8cd29dc457aa29c2b5f71303d8329
btrfs: reset device back to allocation state when removing

When closing a device, btrfs_close_one_device() first allocates a new
device, copies the device to close's name, replaces it in the dev_list
with the copy and then finally frees it.

This involves two memory allocation, which can potentially fail. As this
code path is tricky to unwind, the allocation failures where handled by
BUG_ON()s.

But this copying isn't strictly needed, all that is needed is resetting
the device in question to it's state it had after the allocation.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/volumes.c