Right... Andrei Borzenkov reported that when using raid5 in the options,
the program crashes:
File "/home/bor/src/python-btrfs/bin/btrfs/volumes.py", line 192,
in chunk_length_to_dev_extent_length
dev_extent_length = raw_data_bytes // num_data_stripes
ZeroDivisionError: integer division or modulo by zero
The way this space calculator works is a little bit naughty. By
constructing some fake replacements for the official Chunk, Stripe etc
classes, we fool the usage report module and have it believe it's
looking at an actual filesystem.
In order to do so, we need to present at least one fake chunk of each
chosen profile (for data, metadata etc) to it, so it can take over from
there and do a simulation filling up the rest of the raw space.
The FakeChunk had num_stripes = 1 hardcoded, which obviously is fragile.
In the specific case of RAID5, it crashes because the nparity is
subtracted from num_stripes, which makes it 0.
Fix this a bit more properly by changing the usage reporting code to
allow passing a completely empty filesystem to it.
This means:
* Target profiles have to be set explicitly, because there's no chunk
with highest vaddr yet to look at.
* virtual_block_group_type_usage has to deal with questions about unused
but allocated space for a type it hasn't seen yet.
This removes a bunch of Fake classes, which is good.
Closes: #19