btrfs-progs: mkfs: avoid BUG_ON for chunk allocation when ENOSPC happens
authorQu Wenruo <wqu@suse.com>
Thu, 19 Oct 2017 05:41:33 +0000 (13:41 +0800)
committerDavid Sterba <dsterba@suse.com>
Tue, 14 Nov 2017 14:59:00 +0000 (15:59 +0100)
commit66e485873cf21e03cee5fe59b5dce807d2ac53ea
tree4875a0c74adcea344140bfe4eadcf8df279cd185
parenta624f1616731da6113ab9c6613be733ab41e664b
btrfs-progs: mkfs: avoid BUG_ON for chunk allocation when ENOSPC happens

When passing directory larger than block device using --rootdir
parameter, we get the following backtrace:

------
extent-tree.c:2693: btrfs_reserve_extent: BUG_ON `ret` triggered, value -28
./mkfs.btrfs(+0x1a05d)[0x557939e6b05d]
./mkfs.btrfs(btrfs_reserve_extent+0xb5a)[0x557939e710c8]
./mkfs.btrfs(+0xb0b6)[0x557939e5c0b6]
./mkfs.btrfs(main+0x15d5)[0x557939e5de04]
/usr/lib/libc.so.6(__libc_start_main+0xea)[0x7f83b101af6a]
./mkfs.btrfs(_start+0x2a)[0x557939e5af5a]
------

Nothing special, just BUG_ON() abusing from ancient code.

Fix them by using correct return.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
extent-tree.c
volumes.c