From 96158b59ff7249e60dc53631a0dec5f133622860 Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Nov 01 2012 13:51:07 +0000 Subject: - fix a bug when mkfs'ing a file (rhbz# 871778) --- diff --git a/Btrfs-progs-detect-if-the-disk-we-are-formatting-is-.patch b/Btrfs-progs-detect-if-the-disk-we-are-formatting-is-.patch index fe04876..e06491c 100644 --- a/Btrfs-progs-detect-if-the-disk-we-are-formatting-is-.patch +++ b/Btrfs-progs-detect-if-the-disk-we-are-formatting-is-.patch @@ -1,6 +1,25 @@ -diff -up btrfs-progs-0.20.rc1.20121017git91d9eec/Makefile.patch4 btrfs-progs-0.20.rc1.20121017git91d9eec/Makefile ---- btrfs-progs-0.20.rc1.20121017git91d9eec/Makefile.patch4 2012-10-04 20:35:31.000000000 -0400 -+++ btrfs-progs-0.20.rc1.20121017git91d9eec/Makefile 2012-10-17 13:48:02.331453645 -0400 +From fe4e9b20d9ffffbb6aade4083caa71d65f16230a Mon Sep 17 00:00:00 2001 +From: Josef Bacik +Date: Fri, 20 Jul 2012 11:09:43 -0400 +Subject: [PATCH] Btrfs-progs: detect if the disk we are formatting is a ssd + +SSD's do not gain anything by having metadata DUP turned on. The underlying +file system that is a part of all SSD's could easily map duplicate metadat +blocks into the same erase block which effectively eliminates the benefit of +duplicating the metadata on disk. So detect if we are formatting a single +SSD drive and if we are do not use DUP. Thanks, + +Signed-off-by: Josef Bacik +--- + Makefile | 2 +- + man/mkfs.btrfs.8.in | 5 +++- + mkfs.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++-- + 3 files changed, 65 insertions(+), 5 deletions(-) + +diff --git a/Makefile b/Makefile +index 4894903..c7fd97d 100644 +--- a/Makefile ++++ b/Makefile @@ -67,7 +67,7 @@ btrfsck: $(objects) btrfsck.o $(CC) $(CFLAGS) -o btrfsck btrfsck.o $(objects) $(LDFLAGS) $(LIBS) @@ -10,9 +29,10 @@ diff -up btrfs-progs-0.20.rc1.20121017git91d9eec/Makefile.patch4 btrfs-progs-0.2 btrfs-debug-tree: $(objects) debug-tree.o $(CC) $(CFLAGS) -o btrfs-debug-tree $(objects) debug-tree.o $(LDFLAGS) $(LIBS) -diff -up btrfs-progs-0.20.rc1.20121017git91d9eec/man/mkfs.btrfs.8.in.patch4 btrfs-progs-0.20.rc1.20121017git91d9eec/man/mkfs.btrfs.8.in ---- btrfs-progs-0.20.rc1.20121017git91d9eec/man/mkfs.btrfs.8.in.patch4 2012-10-04 20:35:31.000000000 -0400 -+++ btrfs-progs-0.20.rc1.20121017git91d9eec/man/mkfs.btrfs.8.in 2012-10-17 13:48:02.331453645 -0400 +diff --git a/man/mkfs.btrfs.8.in b/man/mkfs.btrfs.8.in +index 72025ed..b7bcc1b 100644 +--- a/man/mkfs.btrfs.8.in ++++ b/man/mkfs.btrfs.8.in @@ -47,7 +47,10 @@ Specify a label for the filesystem. .TP \fB\-m\fR, \fB\-\-metadata \fIprofile\fR @@ -25,9 +45,10 @@ diff -up btrfs-progs-0.20.rc1.20121017git91d9eec/man/mkfs.btrfs.8.in.patch4 btrf .TP \fB\-M\fR, \fB\-\-mixed\fR Mix data and metadata chunks together for more efficient space -diff -up btrfs-progs-0.20.rc1.20121017git91d9eec/mkfs.c.patch4 btrfs-progs-0.20.rc1.20121017git91d9eec/mkfs.c ---- btrfs-progs-0.20.rc1.20121017git91d9eec/mkfs.c.patch4 2012-10-17 13:48:02.329453660 -0400 -+++ btrfs-progs-0.20.rc1.20121017git91d9eec/mkfs.c 2012-10-17 13:53:36.954806793 -0400 +diff --git a/mkfs.c b/mkfs.c +index 47f0c9c..72f10fa 100644 +--- a/mkfs.c ++++ b/mkfs.c @@ -37,6 +37,7 @@ #include #include @@ -36,7 +57,7 @@ diff -up btrfs-progs-0.20.rc1.20121017git91d9eec/mkfs.c.patch4 btrfs-progs-0.20. #include "kerncompat.h" #include "ctree.h" #include "disk-io.h" -@@ -234,7 +235,7 @@ static int create_one_raid_group(struct +@@ -234,7 +235,7 @@ static int create_one_raid_group(struct btrfs_trans_handle *trans, static int create_raid_groups(struct btrfs_trans_handle *trans, struct btrfs_root *root, u64 data_profile, int data_profile_opt, u64 metadata_profile, @@ -45,7 +66,7 @@ diff -up btrfs-progs-0.20.rc1.20121017git91d9eec/mkfs.c.patch4 btrfs-progs-0.20. { u64 num_devices = btrfs_super_num_devices(&root->fs_info->super_copy); u64 allowed; -@@ -245,8 +246,12 @@ static int create_raid_groups(struct btr +@@ -245,8 +246,12 @@ static int create_raid_groups(struct btrfs_trans_handle *trans, * For mixed groups defaults are single/single. */ if (!metadata_profile_opt && !mixed) { @@ -59,7 +80,7 @@ diff -up btrfs-progs-0.20.rc1.20121017git91d9eec/mkfs.c.patch4 btrfs-progs-0.20. } if (!data_profile_opt && !mixed) { data_profile = (num_devices > 1) ? -@@ -1215,6 +1220,49 @@ static int check_leaf_or_node_size(u32 s +@@ -1222,6 +1227,54 @@ static int check_leaf_or_node_size(u32 size, u32 sectorsize) return 0; } @@ -82,7 +103,12 @@ diff -up btrfs-progs-0.20.rc1.20121017git91d9eec/mkfs.c.patch4 btrfs-progs-0.20. + * reason on F17 at least so we'll do this trickery + */ + disk = blkid_probe_get_wholedisk_devno(probe); ++ if (!disk) ++ return 0; ++ + devname = blkid_devno_to_devname(disk); ++ if (!devname) ++ return 0; + + dev = strrchr(devname, '/'); + dev++; @@ -109,7 +135,7 @@ diff -up btrfs-progs-0.20.rc1.20121017git91d9eec/mkfs.c.patch4 btrfs-progs-0.20. int main(int ac, char **av) { char *file; -@@ -1241,6 +1289,7 @@ int main(int ac, char **av) +@@ -1248,6 +1301,7 @@ int main(int ac, char **av) int data_profile_opt = 0; int metadata_profile_opt = 0; int nodiscard = 0; @@ -117,7 +143,7 @@ diff -up btrfs-progs-0.20.rc1.20121017git91d9eec/mkfs.c.patch4 btrfs-progs-0.20. char *source_dir = NULL; int source_dir_set = 0; -@@ -1360,6 +1409,9 @@ int main(int ac, char **av) +@@ -1367,6 +1421,9 @@ int main(int ac, char **av) exit(1); } } @@ -127,7 +153,7 @@ diff -up btrfs-progs-0.20.rc1.20121017git91d9eec/mkfs.c.patch4 btrfs-progs-0.20. if (mixed) { if (metadata_profile != data_profile) { fprintf(stderr, "With mixed block groups data and metadata " -@@ -1445,7 +1497,7 @@ raid_groups: +@@ -1452,7 +1509,7 @@ raid_groups: if (!source_dir_set) { ret = create_raid_groups(trans, root, data_profile, data_profile_opt, metadata_profile, @@ -136,3 +162,6 @@ diff -up btrfs-progs-0.20.rc1.20121017git91d9eec/mkfs.c.patch4 btrfs-progs-0.20. BUG_ON(ret); } +-- +1.7.7.6 + diff --git a/btrfs-progs.spec b/btrfs-progs.spec index d7ddc5d..479d4fa 100644 --- a/btrfs-progs.spec +++ b/btrfs-progs.spec @@ -1,6 +1,6 @@ Name: btrfs-progs Version: 0.20.rc1.20121017git91d9eec -Release: 1%{?dist} +Release: 2%{?dist} Summary: Userspace programs for btrfs Group: System Environment/Base @@ -68,6 +68,9 @@ rm -rf $RPM_BUILD_ROOT %{_mandir}/man8/btrfs.8.gz %changelog +* Thu Nov 1 2012 Josef Bacik 0.20.rc1.20121017git91d9eec-2 +- fix a bug when mkfs'ing a file (rhbz# 871778) + * Wed Oct 17 2012 Josef Bacik 0.20.rc1.20121017git91d9eec-1 - update to latest btrfs-progs