Btrfs-progs: add support for mixed data+metadata block groups V2
PATCH 1/1 Btrfs-progs: add support for mixed data+metadata block groups V2
So alot of crazy people (I'm looking at you Meego) want to use btrfs on phones and such with small devices. Unfortunately the way we split out metadata/data chunks it makes space usage inefficient for volumes that are smaller than 1gigabyte. So add a -M option for mixing metadata+data, and default to this mixed mode if the filesystem is less than or equal to 1 gigabyte. I've tested this with xfstests on a 100mb filesystem and everything is a-ok.
Signed-off-by Josef Bacik <[email protected]>
---V1->V2: My original patch was screwing up if you specified the data or metadata profile. This update fixes that problem.
btrfs-vol.c | 4 ++- btrfs_cmds.c | 13 +++++-- mkfs.c | 114 ++++++++++++++++++++++++++++++++++++++++------------------ utils.c | 10 +++--- utils.h | 2 +- 5 files changed, 98 insertions(+), 45 deletions(-)
btrfs-vol.c +3 -1
@@ -129,7 +129,9 @@ int main(int ac, char **av)exit (1 ); }if (cmd ==BTRFS_IOC_ADD_DEV ) { - ret =btrfs_prepare_device (devfd, device,1 , &dev_block_count); +int mixed =0 ; + + ret =btrfs_prepare_device (devfd, device,1 , &dev_block_count, &mixed);if (ret) {fprintf (stderr,"Unable to init %s\n" , device);exit (1 );
btrfs_cmds.c +10 -3
@@ -705,6 +705,7 @@ int do_add_volume(int nargs, char **args)int devfd, res;u64 dev_block_count =0 ;struct stat st; +int mixed =0 ; devfd =open (args[i],O_RDWR );if (!devfd) {
@@ -727,7 +728,7 @@ int do_add_volume(int nargs, char **args)continue ; } - res =btrfs_prepare_device (devfd, args[i],1 , &dev_block_count); + res =btrfs_prepare_device (devfd, args[i],1 , &dev_block_count, &mixed);if (res) {fprintf (stderr,"ERROR: Unable to init '%s'\n" , args[i]);close (devfd);
@@ -889,8 +890,14 @@ int do_df_filesystem(int nargs, char **argv)memset (description,0 ,80 );if (flags &BTRFS_BLOCK_GROUP_DATA ) { -snprintf (description,5 ,"%s" ,"Data" ); - written +=4 ; +if (flags &BTRFS_BLOCK_GROUP_METADATA ) { +snprintf (description,15 ,"%s" , +"Data+Metadata" ); + written +=14 ; + }else { +snprintf (description,5 ,"%s" ,"Data" ); + written +=4 ; + } }else if (flags &BTRFS_BLOCK_GROUP_SYSTEM ) {snprintf (description,7 ,"%s" ,"System" ); written +=6 ;
mkfs.c +79 -35
226 lines not on this page · raw message
utils.c +5 -5
@@ -507,7 +507,8 @@ int btrfs_add_to_fsid(struct btrfs_trans_handle *trans,return 0 ; } -int btrfs_prepare_device (int fd,char *file,int zero_end,u64 *block_count_ret) +int btrfs_prepare_device (int fd,char *file,int zero_end,u64 *block_count_ret, +int *mixed) {u64 block_count;u64 bytenr;
@@ -527,10 +528,9 @@ int btrfs_prepare_device(int fd, char *file, int zero_end, u64 *block_count_ret) } zero_end =1 ; -if (block_count <256 *1024 *1024 ) { -fprintf (stderr,"device %s is too small " -"(must be at least 256 MB)\n" , file); -exit (1 ); +if (block_count <1024 *1024 *1024 && !(*mixed)) { +printf ("SMALL VOLUME: forcing mixed metadata/data groups\n" ); + *mixed =1 ; } ret =zero_dev_start (fd);if (ret) {
utils.h +1 -1
@@ -27,7 +27,7 @@ int make_btrfs(int fd, const char *device, const char *label,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 *block_count_ret,int *mixed); 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
1.6.6.1