btrfs-progs/mkfs
Qu Wenruo 997f9977c2 btrfs-progs: mkfs: Prevent temporary system chunk to use space in reserved 1M range
When creating btrfs, mkfs.btrfs will firstly create a temporary system
chunk as basis, and then created needed trees or new devices.

However the layout temporary system chunk is hard-coded and uses
reserved [0, 1M) range of devid 1.

Change the temporary chunk layout from old:

0	1M				4M	5M
|<----------- temp chunk -------------->|
  And it's 1:1 mapped, which means it's a SINGLE chunk,
  and stripe offset is also 0.

to new layout:

0	1M				4M	5M
	|<----------- temp chunk -------------->|
  And still keeps the 1:1 mapping.

However this also affects btrfs_min_dev_size() which still assume
temporary chunks starts at device offset 0.

The problem can only be exposed by "-m single" or "-M" where we reuse the
temporary chunk.

With other meta profiles, system and meta chunks are allocated by later
btrfs_alloc_chunk() call, and old SINGLE chunks are removed, so it will
be no such problem for other meta profiles.

Reported-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Tested-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
[ folded fix for the minimal device size calculation ]
Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-31 15:14:02 +01:00
..
common.c btrfs-progs: mkfs: Prevent temporary system chunk to use space in reserved 1M range 2018-01-31 15:14:02 +01:00
common.h btrfs-progs: mkfs: Enhance minimal device size calculation to fix mkfs failure on small file 2018-01-03 17:10:11 +01:00
main.c btrfs-progs: mkfs: Prevent temporary system chunk to use space in reserved 1M range 2018-01-31 15:14:02 +01:00
rootdir.c btrfs-progs: mkfs: Separate shrink from rootdir 2018-01-08 18:15:15 +01:00
rootdir.h btrfs-progs: mkfs: Separate shrink from rootdir 2018-01-08 18:15:15 +01:00