Btrfs-progs: Do not force mixed block group creation unless '-M' option is specified
PATCH 1/1 Btrfs-progs: Do not force mixed block group creation unless '-M' option is specified
When creating small Btrfs filesystem instances (i.e. filesystem size <= 1GiB), mkfs.btrfs fails if both sectorsize and nodesize are specified on the command line and sectorsize != nodesize, since mixed block groups involves both data and metadata blocks sharing the same block group. This is an incorrect behavior when '-M' option isn't specified on the command line.
This commit makes optional the creation of mixed block groups i.e. Mixed block groups are created only when -M option is specified on the command line.
While at it, this commit fixes a bug which allowed creation of filesystem instances with "mixed block group" feature enabled and having differing block sizes for data and metadata. For e.g.
[root@localhost btrfs-progs]# ./mkfs.btrfs -f -M -s 4096 -n 16384 /dev/loop6 SMALL VOLUME: forcing mixed metadata/data groups
btrfs-progs v3.19-rc2-404-g71f7308
See http://btrfs.wiki.kernel.org for more information.
Performing full device TRIM (4.00GiB) ...
Label: (null) UUID: c82b5720-6d88-4fa1-ac05-d0d4cb797fd5 Node size: 16384 Sector size: 4096 Filesystem size: 4.00GiB Block group profiles: Data+Metadata: single 8.00MiB System: single 4.00MiB SSD detected: no Incompat features: mixed-bg, extref, skinny-metadata Number of devices: 1
Devices:
ID SIZE PATH
1 4.00GiB /dev/loop6
--- cmds-device.c | 3 +-- cmds-replace.c | 3 +-- mkfs.c | 45 ++++++++++++++++++++------------------------- utils.c | 5 +---- utils.h | 2 +- 5 files changed, 24 insertions(+), 34 deletions(-)
cmds-device.c +1 -2
@@ -92,7 +92,6 @@ static int cmd_device_add(int argc, char **argv)struct btrfs_ioctl_vol_args ioctl_args;int devfd, res;u64 dev_block_count =0 ; -int mixed =0 ;char *path; res =test_dev_for_mkfs (argv[i], force);
@@ -109,7 +108,7 @@ static int cmd_device_add(int argc, char **argv) } res =btrfs_prepare_device (devfd, argv[i],1 , &dev_block_count, -0 , &mixed, discard); +0 , discard);close (devfd);if (res) { ret++;
cmds-replace.c +1 -2
@@ -140,7 +140,6 @@ static int cmd_replace_start(int argc, char **argv)int force_using_targetdev =0 ;u64 dstdev_block_count;int do_not_background =0 ; -int mixed =0 ;DIR *dirstream =NULL ;u64 srcdev_size;u64 dstdev_size;
@@ -281,7 +280,7 @@ static int cmd_replace_start(int argc, char **argv)strncpy ((char *)start_args.start.tgtdev_name, dstdev,BTRFS_DEVICE_PATH_NAME_MAX ); ret =btrfs_prepare_device (fddstdev, dstdev,1 , &dstdev_block_count,0 , - &mixed,0 ); +0 );if (ret) goto leave_with_error;
mkfs.c +20 -25
110 lines not on this page · raw message
utils.c +1 -4
@@ -847,7 +847,7 @@ out: }int btrfs_prepare_device (int fd,char *file,int zero_end,u64 *block_count_ret, -u64 max_block_count,int *mixed,int discard) +u64 max_block_count,int discard) {u64 block_count;struct stat st;
@@ -867,9 +867,6 @@ int btrfs_prepare_device(int fd, char *file, int zero_end, u64 *block_count_ret,if (max_block_count) block_count =min (block_count, max_block_count); -if (block_count <BTRFS_MKFS_SMALL_VOLUME_SIZE && !(*mixed)) - *mixed =1 ; -if (discard) {/* * We intentionally ignore errors from the discard ioctl. It
utils.h +1 -1
@@ -120,7 +120,7 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg);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, -u64 max_block_count,int *mixed,int discard); +u64 max_block_count,int discard); 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,
Signature · 1 line
2.1.0