]> asedeno.scripts.mit.edu Git - linux.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)
commit321f69f86a0fc40203b43659c3a39464f15c2ee9
tree81f49161c70d86f27389284b3680a7479ab40571
parent3fff3975a7155c49b85736786c6bcb1dd9dcec18
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