Eric Sandeen
2014-Jul-25 04:27 UTC
[PATCH] mkfs.btrfs: round all device sizes to sectorsize
make_btrfs() rounds down the first device size to a multiple of sectorsize: num_bytes = (num_bytes / sectorsize) * sectorsize; but subsequent device adds don't. This seems a bit odd & inconsistent, and it makes xfstest btrfs/011 _notrun(), because it explicitly checks that devices are the same size. I don't know that there is anything inherently wrong with having a few device bytes extend past the last block, but to be consistent, it seems like btrfs_add_to_fsid() should round the size in the same way. And now btrfs/011 runs more consistently; the test devices don't have to be sectorsize multiples in order for all mkfs'd device sizes to match. Signed-off-by: Eric Sandeen <sandeen@redhat.com> --- ideally this might go into btrfs_device_size(), but we don't have the chosen sector size anywhere near there... diff --git a/utils.c b/utils.c index e130849..4d7ee35 100644 --- a/utils.c +++ b/utils.c @@ -554,7 +554,7 @@ int btrfs_add_to_fsid(struct btrfs_trans_handle *trans, device->sector_size = sectorsize; device->fd = fd; device->writeable = 1; - device->total_bytes = block_count; + device->total_bytes = (block_count / sectorsize) * sectorsize; device->bytes_used = 0; device->total_ios = 0; device->dev_root = root->fs_info->dev_root; -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html