For the record, this fixup is needed
--- a/utils.c
+++ b/utils.c
@@ -273,6 +273,9 @@ int make_btrfs(int fd, const char *device, const char *label,
btrfs_set_item_offset(buf, btrfs_item_nr(buf, nritems), itemoff);
btrfs_set_item_size(buf, btrfs_item_nr(buf, nritems), item_size);
+ if (num_bytes < dev_num_bytes)
+ dev_num_bytes = num_bytes;
+
dev_item = btrfs_item_ptr(buf, nritems, struct btrfs_dev_item);
btrfs_set_device_id(buf, dev_item, 1);
btrfs_set_device_generation(buf, dev_item, 0);
---
otherwise a filesystem smaller than the block device will not report correct
size of the device and this inconsistency will trigger a bug (xfstests/015)
cow_file_range:
895 BUG_ON(disk_num_bytes >
896 btrfs_super_total_bytes(root->fs_info->super_copy));
$ mkfs.btrfs-small-bd-big-fs -b 100M /dev/sda10
SMALL VOLUME: forcing mixed metadata/data groups
WARNING! - Btrfs v0.19-190-gc1d427d IS EXPERIMENTAL
WARNING! - see http://btrfs.wiki.kernel.org before using
Created a data/metadata chunk of size 8388608
fs created label (null) on /dev/sda10
nodesize 4096 leafsize 4096 sectorsize 4096 size 100.00MB
Btrfs v0.19-190-gc1d427d
$ btrfs fi show
Label: none uuid: efecdeb1-bab3-40aa-bafa-4aae1e410f28
Total devices 1 FS bytes used 28.00KB
devid 1 size 10.00GB used 12.00MB path /dev/sda10
^^^^^^^
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda10 100M 28K 10G 1% /mnt/a10
^^^
I'm writing a kernel-side patch to prevent mounting such fs, unless -o recovery
is given and this will fix the fs size in superblock to sum of all device
sizes. Fsck could be enhanced in the same way.
david
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html