|
|
cec386 |
From fcd0fd043749cd2623a918cf9862d10e2a227ae4 Mon Sep 17 00:00:00 2001
|
|
|
cec386 |
From: David Sterba <dsterba@suse.com>
|
|
|
cec386 |
Date: Tue, 21 Jul 2020 12:13:27 +0200
|
|
|
cec386 |
Subject: [PATCH 1/2] btrfs-progs: mkfs: clean up default profile settings
|
|
|
cec386 |
|
|
|
cec386 |
Extract the defaults for data and metadata profiles to a header and
|
|
|
cec386 |
use the symbolic names instead of hardcoding the profiles.
|
|
|
cec386 |
|
|
|
cec386 |
Signed-off-by: David Sterba <dsterba@suse.com>
|
|
|
cec386 |
(cherry picked from commit 071cb030a41fde2cab07217b52ba7c86b72fb8d8)
|
|
|
cec386 |
---
|
|
|
cec386 |
mkfs/common.h | 10 ++++++++++
|
|
|
cec386 |
mkfs/main.c | 21 ++++++++++++++++-----
|
|
|
cec386 |
2 files changed, 26 insertions(+), 5 deletions(-)
|
|
|
cec386 |
|
|
|
cec386 |
diff --git a/mkfs/common.h b/mkfs/common.h
|
|
|
cec386 |
index 426852be..61969dcc 100644
|
|
|
cec386 |
--- a/mkfs/common.h
|
|
|
cec386 |
+++ b/mkfs/common.h
|
|
|
cec386 |
@@ -28,6 +28,16 @@
|
|
|
cec386 |
#define BTRFS_MKFS_SYSTEM_GROUP_SIZE SZ_4M
|
|
|
cec386 |
#define BTRFS_MKFS_SMALL_VOLUME_SIZE SZ_1G
|
|
|
cec386 |
|
|
|
cec386 |
+/*
|
|
|
cec386 |
+ * Default settings for block group types
|
|
|
cec386 |
+ */
|
|
|
cec386 |
+#define BTRFS_MKFS_DEFAULT_DATA_ONE_DEVICE 0 /* SINGLE */
|
|
|
cec386 |
+#define BTRFS_MKFS_DEFAULT_META_ONE_DEVICE BTRFS_BLOCK_GROUP_DUP
|
|
|
cec386 |
+#define BTRFS_MKFS_DEFAULT_META_ONE_DEVICE_SSD 0 /* SINGLE */
|
|
|
cec386 |
+
|
|
|
cec386 |
+#define BTRFS_MKFS_DEFAULT_DATA_MULTI_DEVICE BTRFS_BLOCK_GROUP_RAID0
|
|
|
cec386 |
+#define BTRFS_MKFS_DEFAULT_META_MULTI_DEVICE BTRFS_BLOCK_GROUP_RAID1
|
|
|
cec386 |
+
|
|
|
cec386 |
/*
|
|
|
cec386 |
* Tree root blocks created during mkfs
|
|
|
cec386 |
*/
|
|
|
cec386 |
diff --git a/mkfs/main.c b/mkfs/main.c
|
|
|
cec386 |
index 0a4de617..6c9a24a4 100644
|
|
|
cec386 |
--- a/mkfs/main.c
|
|
|
cec386 |
+++ b/mkfs/main.c
|
|
|
cec386 |
@@ -1144,19 +1144,30 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
|
|
|
cec386 |
* For mixed groups defaults are single/single.
|
|
|
cec386 |
*/
|
|
|
cec386 |
if (!mixed) {
|
|
|
cec386 |
+ u64 tmp;
|
|
|
cec386 |
+
|
|
|
cec386 |
if (!metadata_profile_opt) {
|
|
|
cec386 |
if (dev_cnt == 1 && ssd && verbose)
|
|
|
cec386 |
printf("Detected a SSD, turning off metadata "
|
|
|
cec386 |
"duplication. Mkfs with -m dup if you want to "
|
|
|
cec386 |
"force metadata duplication.\n");
|
|
|
cec386 |
|
|
|
cec386 |
- metadata_profile = (dev_cnt > 1) ?
|
|
|
cec386 |
- BTRFS_BLOCK_GROUP_RAID1 : (ssd) ?
|
|
|
cec386 |
- 0: BTRFS_BLOCK_GROUP_DUP;
|
|
|
cec386 |
+ if (dev_cnt > 1) {
|
|
|
cec386 |
+ tmp = BTRFS_MKFS_DEFAULT_META_MULTI_DEVICE;
|
|
|
cec386 |
+ } else {
|
|
|
cec386 |
+ if (ssd)
|
|
|
cec386 |
+ tmp = BTRFS_MKFS_DEFAULT_META_ONE_DEVICE_SSD;
|
|
|
cec386 |
+ else
|
|
|
cec386 |
+ tmp = BTRFS_MKFS_DEFAULT_META_ONE_DEVICE;
|
|
|
cec386 |
+ }
|
|
|
cec386 |
+ metadata_profile = tmp;
|
|
|
cec386 |
}
|
|
|
cec386 |
if (!data_profile_opt) {
|
|
|
cec386 |
- data_profile = (dev_cnt > 1) ?
|
|
|
cec386 |
- BTRFS_BLOCK_GROUP_RAID0 : 0; /* raid0 or single */
|
|
|
cec386 |
+ if (dev_cnt > 1)
|
|
|
cec386 |
+ tmp = BTRFS_MKFS_DEFAULT_DATA_MULTI_DEVICE;
|
|
|
cec386 |
+ else
|
|
|
cec386 |
+ tmp = BTRFS_MKFS_DEFAULT_DATA_ONE_DEVICE;
|
|
|
cec386 |
+ data_profile = tmp;
|
|
|
cec386 |
}
|
|
|
cec386 |
} else {
|
|
|
cec386 |
u32 best_nodesize = max_t(u32, sysconf(_SC_PAGESIZE), sectorsize);
|
|
|
cec386 |
--
|
|
|
cec386 |
2.26.2
|
|
|
cec386 |
|