mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git
synced 2024-11-16 00:34:32 +08:00
Btrfs-progs: only enforce a maximum size if we specify one
My patch
04609add88
introduced a regression where if you mkfs'ed a group of disks with different
sizes it limited the disks to the size of the first one that is specified.
This was not the intent of my patch, I only want it to limit the size based
on the -b option, so I've reworked the code to pass in a max block count and
that fixes the issue. Thanks,
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
This commit is contained in:
parent
45e9ec733d
commit
605e806166
@ -150,7 +150,8 @@ int main(int ac, char **av)
|
||||
if (cmd == BTRFS_IOC_ADD_DEV) {
|
||||
int mixed = 0;
|
||||
|
||||
ret = btrfs_prepare_device(devfd, device, 1, &dev_block_count, &mixed);
|
||||
ret = btrfs_prepare_device(devfd, device, 1, &dev_block_count,
|
||||
0, &mixed, 0);
|
||||
if (ret) {
|
||||
fprintf(stderr, "Unable to init %s\n", device);
|
||||
exit(1);
|
||||
|
@ -107,7 +107,8 @@ static int cmd_add_dev(int argc, char **argv)
|
||||
continue;
|
||||
}
|
||||
|
||||
res = btrfs_prepare_device(devfd, argv[i], 1, &dev_block_count, &mixed);
|
||||
res = btrfs_prepare_device(devfd, argv[i], 1, &dev_block_count,
|
||||
0, &mixed, 0);
|
||||
if (res) {
|
||||
fprintf(stderr, "ERROR: Unable to init '%s'\n", argv[i]);
|
||||
close(devfd);
|
||||
|
15
mkfs.c
15
mkfs.c
@ -1324,11 +1324,9 @@ int main(int ac, char **av)
|
||||
exit(1);
|
||||
}
|
||||
first_file = file;
|
||||
ret = __btrfs_prepare_device(fd, file, zero_end,
|
||||
&dev_block_count, &mixed, nodiscard);
|
||||
if (block_count == 0)
|
||||
block_count = dev_block_count;
|
||||
else if (block_count > dev_block_count) {
|
||||
ret = btrfs_prepare_device(fd, file, zero_end, &dev_block_count,
|
||||
block_count, &mixed, nodiscard);
|
||||
if (block_count && block_count > dev_block_count) {
|
||||
fprintf(stderr, "%s is smaller than requested size\n", file);
|
||||
exit(1);
|
||||
}
|
||||
@ -1366,7 +1364,7 @@ int main(int ac, char **av)
|
||||
leafsize * i;
|
||||
}
|
||||
|
||||
ret = make_btrfs(fd, file, label, blocks, block_count,
|
||||
ret = make_btrfs(fd, file, label, blocks, dev_block_count,
|
||||
nodesize, leafsize,
|
||||
sectorsize, stripesize);
|
||||
if (ret) {
|
||||
@ -1422,9 +1420,8 @@ int main(int ac, char **av)
|
||||
close(fd);
|
||||
continue;
|
||||
}
|
||||
dev_block_count = block_count;
|
||||
ret = __btrfs_prepare_device(fd, file, zero_end,
|
||||
&dev_block_count, &mixed, nodiscard);
|
||||
ret = btrfs_prepare_device(fd, file, zero_end, &dev_block_count,
|
||||
block_count, &mixed, nodiscard);
|
||||
mixed = old_mixed;
|
||||
BUG_ON(ret);
|
||||
|
||||
|
12
utils.c
12
utils.c
@ -537,13 +537,7 @@ int btrfs_add_to_fsid(struct btrfs_trans_handle *trans,
|
||||
}
|
||||
|
||||
int btrfs_prepare_device(int fd, char *file, int zero_end, u64 *block_count_ret,
|
||||
int *mixed)
|
||||
{
|
||||
/* discard by default when called from 'device add' */
|
||||
return __btrfs_prepare_device(fd, file, zero_end, block_count_ret, mixed, 0);
|
||||
}
|
||||
int __btrfs_prepare_device(int fd, char *file, int zero_end, u64 *block_count_ret,
|
||||
int *mixed, int nodiscard)
|
||||
u64 max_block_count, int *mixed, int nodiscard)
|
||||
{
|
||||
u64 block_count;
|
||||
u64 bytenr;
|
||||
@ -561,8 +555,8 @@ int __btrfs_prepare_device(int fd, char *file, int zero_end, u64 *block_count_re
|
||||
fprintf(stderr, "unable to find %s size\n", file);
|
||||
exit(1);
|
||||
}
|
||||
if (*block_count_ret)
|
||||
block_count = min(block_count, *block_count_ret);
|
||||
if (max_block_count)
|
||||
block_count = min(block_count, max_block_count);
|
||||
zero_end = 1;
|
||||
|
||||
if (block_count < 1024 * 1024 * 1024 && !(*mixed)) {
|
||||
|
6
utils.h
6
utils.h
@ -26,10 +26,8 @@ int make_btrfs(int fd, const char *device, const char *label,
|
||||
u32 leafsize, u32 sectorsize, u32 stripesize);
|
||||
int btrfs_make_root_dir(struct btrfs_trans_handle *trans,
|
||||
struct btrfs_root *root, u64 objectid);
|
||||
int btrfs_prepare_device(int fd, char *file, int zero_end,
|
||||
u64 *block_count_ret, int *mixed);
|
||||
int __btrfs_prepare_device(int fd, char *file, int zero_end,
|
||||
u64 *block_count_ret, int *mixed, int nodiscard);
|
||||
int btrfs_prepare_device(int fd, char *file, int zero_end, u64 *block_count_ret,
|
||||
u64 max_block_count, int *mixed, int nodiscard);
|
||||
int btrfs_add_to_fsid(struct btrfs_trans_handle *trans,
|
||||
struct btrfs_root *root, int fd, char *path,
|
||||
u64 block_count, u32 io_width, u32 io_align,
|
||||
|
Loading…
Reference in New Issue
Block a user