From cec386dcf93326cac0e918d35cb4ba339126058a Mon Sep 17 00:00:00 2001 From: Neal Gompa Date: Jul 21 2020 18:22:35 +0000 Subject: Backport fix to not use raid0 by default for mkfs multi-disk (#1855174) --- diff --git a/0001-btrfs-progs-mkfs-clean-up-default-profile-settings.patch b/0001-btrfs-progs-mkfs-clean-up-default-profile-settings.patch new file mode 100644 index 0000000..f72d0e3 --- /dev/null +++ b/0001-btrfs-progs-mkfs-clean-up-default-profile-settings.patch @@ -0,0 +1,79 @@ +From fcd0fd043749cd2623a918cf9862d10e2a227ae4 Mon Sep 17 00:00:00 2001 +From: David Sterba +Date: Tue, 21 Jul 2020 12:13:27 +0200 +Subject: [PATCH 1/2] btrfs-progs: mkfs: clean up default profile settings + +Extract the defaults for data and metadata profiles to a header and +use the symbolic names instead of hardcoding the profiles. + +Signed-off-by: David Sterba +(cherry picked from commit 071cb030a41fde2cab07217b52ba7c86b72fb8d8) +--- + mkfs/common.h | 10 ++++++++++ + mkfs/main.c | 21 ++++++++++++++++----- + 2 files changed, 26 insertions(+), 5 deletions(-) + +diff --git a/mkfs/common.h b/mkfs/common.h +index 426852be..61969dcc 100644 +--- a/mkfs/common.h ++++ b/mkfs/common.h +@@ -28,6 +28,16 @@ + #define BTRFS_MKFS_SYSTEM_GROUP_SIZE SZ_4M + #define BTRFS_MKFS_SMALL_VOLUME_SIZE SZ_1G + ++/* ++ * Default settings for block group types ++ */ ++#define BTRFS_MKFS_DEFAULT_DATA_ONE_DEVICE 0 /* SINGLE */ ++#define BTRFS_MKFS_DEFAULT_META_ONE_DEVICE BTRFS_BLOCK_GROUP_DUP ++#define BTRFS_MKFS_DEFAULT_META_ONE_DEVICE_SSD 0 /* SINGLE */ ++ ++#define BTRFS_MKFS_DEFAULT_DATA_MULTI_DEVICE BTRFS_BLOCK_GROUP_RAID0 ++#define BTRFS_MKFS_DEFAULT_META_MULTI_DEVICE BTRFS_BLOCK_GROUP_RAID1 ++ + /* + * Tree root blocks created during mkfs + */ +diff --git a/mkfs/main.c b/mkfs/main.c +index 0a4de617..6c9a24a4 100644 +--- a/mkfs/main.c ++++ b/mkfs/main.c +@@ -1144,19 +1144,30 @@ int BOX_MAIN(mkfs)(int argc, char **argv) + * For mixed groups defaults are single/single. + */ + if (!mixed) { ++ u64 tmp; ++ + if (!metadata_profile_opt) { + if (dev_cnt == 1 && ssd && verbose) + printf("Detected a SSD, turning off metadata " + "duplication. Mkfs with -m dup if you want to " + "force metadata duplication.\n"); + +- metadata_profile = (dev_cnt > 1) ? +- BTRFS_BLOCK_GROUP_RAID1 : (ssd) ? +- 0: BTRFS_BLOCK_GROUP_DUP; ++ if (dev_cnt > 1) { ++ tmp = BTRFS_MKFS_DEFAULT_META_MULTI_DEVICE; ++ } else { ++ if (ssd) ++ tmp = BTRFS_MKFS_DEFAULT_META_ONE_DEVICE_SSD; ++ else ++ tmp = BTRFS_MKFS_DEFAULT_META_ONE_DEVICE; ++ } ++ metadata_profile = tmp; + } + if (!data_profile_opt) { +- data_profile = (dev_cnt > 1) ? +- BTRFS_BLOCK_GROUP_RAID0 : 0; /* raid0 or single */ ++ if (dev_cnt > 1) ++ tmp = BTRFS_MKFS_DEFAULT_DATA_MULTI_DEVICE; ++ else ++ tmp = BTRFS_MKFS_DEFAULT_DATA_ONE_DEVICE; ++ data_profile = tmp; + } + } else { + u32 best_nodesize = max_t(u32, sysconf(_SC_PAGESIZE), sectorsize); +-- +2.26.2 + diff --git a/0002-btrfs-progs-mkfs-switch-to-single-as-default-profile.patch b/0002-btrfs-progs-mkfs-switch-to-single-as-default-profile.patch new file mode 100644 index 0000000..aecef39 --- /dev/null +++ b/0002-btrfs-progs-mkfs-switch-to-single-as-default-profile.patch @@ -0,0 +1,49 @@ +From 5e76619fcda3d792b2cb188fc2d950c61d7ebf09 Mon Sep 17 00:00:00 2001 +From: David Sterba +Date: Tue, 21 Jul 2020 12:28:05 +0200 +Subject: [PATCH 2/2] btrfs-progs: mkfs: switch to single as default profile + for multiple-devices + +The single profile is better suited as default for data on multiple +devices. Switch from RAID0 because: + +- it's easier to convert to other profiles, as single consumes some + chunks per device, but RAID0 has chunks on all devices regardless of + the used space + +- RAID0 has no redundancy and compared one disk failure affects many + files due to striping, while with single the chances are a bit higher + that complete files are stored on one device + +- when the device sizes are not equal and not even close to equal, the + maximum achievable size with RAID0 is size of the smallest device due + to striping, with single it's the sum of all device sizes + +The changed defaults could affect scripts and deployments that rely on +the old values, but given the number of possible profiles for multiple +devices let's hope that they're specified explicitly in majority of +cases. + +Issue: #270 +Signed-off-by: David Sterba +(cherry picked from commit f1507716c67e2d6012f1e7a0f1538d4f669faa23) +--- + mkfs/common.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/mkfs/common.h b/mkfs/common.h +index 61969dcc..cc88db71 100644 +--- a/mkfs/common.h ++++ b/mkfs/common.h +@@ -35,7 +35,7 @@ + #define BTRFS_MKFS_DEFAULT_META_ONE_DEVICE BTRFS_BLOCK_GROUP_DUP + #define BTRFS_MKFS_DEFAULT_META_ONE_DEVICE_SSD 0 /* SINGLE */ + +-#define BTRFS_MKFS_DEFAULT_DATA_MULTI_DEVICE BTRFS_BLOCK_GROUP_RAID0 ++#define BTRFS_MKFS_DEFAULT_DATA_MULTI_DEVICE 0 /* SINGLE */ + #define BTRFS_MKFS_DEFAULT_META_MULTI_DEVICE BTRFS_BLOCK_GROUP_RAID1 + + /* +-- +2.26.2 + diff --git a/btrfs-progs.spec b/btrfs-progs.spec index a418211..761e199 100644 --- a/btrfs-progs.spec +++ b/btrfs-progs.spec @@ -3,13 +3,17 @@ Name: btrfs-progs Version: 5.7 -Release: 2%{?dist} +Release: 3%{?dist} Summary: Userspace programs for btrfs License: GPLv2 URL: https://btrfs.wiki.kernel.org/index.php/Main_Page Source0: https://www.kernel.org/pub/linux/kernel/people/kdave/%{name}/%{name}-v%{version_no_tilde}.tar.xz +# Backports from upstream +Patch0001: 0001-btrfs-progs-mkfs-clean-up-default-profile-settings.patch +Patch0002: 0002-btrfs-progs-mkfs-switch-to-single-as-default-profile.patch + BuildRequires: gcc, autoconf, automake BuildRequires: e2fsprogs-devel, libuuid-devel, zlib-devel, libzstd-devel BuildRequires: libacl-devel, libblkid-devel, lzo-devel @@ -79,7 +83,7 @@ btrfs filesystem-specific programs in Python. %endif %prep -%autosetup -n %{name}-v%{version_no_tilde} +%autosetup -n %{name}-v%{version_no_tilde} -p1 %build ./autogen.sh @@ -142,6 +146,9 @@ popd %endif %changelog +* Tue Jul 21 2020 Neal Gompa - 5.7-3 +- Backport fix to not use raid0 by default for mkfs multi-disk (#1855174) + * Wed Jul 08 2020 Carl George - 5.7-2 - Include bash completion