summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2017-01-31 23:13:54 +0100
committerDavid Sterba <dsterba@suse.com>2017-03-08 13:00:46 +0100
commit11c83cefb8b4a03b1835efaf603ddc95430a0c9e (patch)
tree40eadc38c54f41235a6defd65d0782c25ab496c8 /utils.c
parentdf32b5fa2298dab7fb3ee955c3f496570c20d5de (diff)
btrfs-progs: move more mkfs declarations to the common header
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/utils.c b/utils.c
index 794f4e68..20cddd9d 100644
--- a/utils.c
+++ b/utils.c
@@ -49,6 +49,7 @@
#include "volumes.h"
#include "ioctl.h"
#include "commands.h"
+#include "mkfs/common.h"
#ifndef BLKDISCARD
#define BLKDISCARD _IO(0x12,119)
@@ -1986,6 +1987,27 @@ int group_profile_max_safe_loss(u64 flags)
}
}
+u64 btrfs_min_dev_size(u32 nodesize)
+{
+ return 2 * (BTRFS_MKFS_SYSTEM_GROUP_SIZE +
+ btrfs_min_global_blk_rsv_size(nodesize));
+}
+
+/*
+ * Btrfs minimum size calculation is complicated, it should include at least:
+ * 1. system group size
+ * 2. minimum global block reserve
+ * 3. metadata used at mkfs
+ * 4. space reservation to create uuid for first mount.
+ * Also, raid factor should also be taken into consideration.
+ * To avoid the overkill calculation, (system group + global block rsv) * 2
+ * for *EACH* device should be good enough.
+ */
+u64 btrfs_min_global_blk_rsv_size(u32 nodesize)
+{
+ return (u64)nodesize << 10;
+}
+
/*
* Check if a device is suitable for btrfs
* returns: