summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmds-device.c1
-rw-r--r--cmds-replace.c1
-rw-r--r--mkfs/common.h10
-rw-r--r--utils.c22
-rw-r--r--utils.h29
5 files changed, 34 insertions, 29 deletions
diff --git a/cmds-device.c b/cmds-device.c
index 58f7dee1..7915bc97 100644
--- a/cmds-device.c
+++ b/cmds-device.c
@@ -33,6 +33,7 @@
#include "commands.h"
#include "help.h"
+#include "mkfs/common.h"
static const char * const device_cmd_group_usage[] = {
"btrfs device <command> [<args>]",
diff --git a/cmds-replace.c b/cmds-replace.c
index ee7938cd..a3ea977c 100644
--- a/cmds-replace.c
+++ b/cmds-replace.c
@@ -38,6 +38,7 @@
#include "commands.h"
#include "help.h"
+#include "mkfs/common.h"
static int print_replace_status(int fd, const char *path, int once);
static char *time2string(char *buf, size_t s, __u64 t);
diff --git a/mkfs/common.h b/mkfs/common.h
index 2a188390..7011c672 100644
--- a/mkfs/common.h
+++ b/mkfs/common.h
@@ -25,6 +25,9 @@
#include "kerncompat.h"
#include "common-defs.h"
+#define BTRFS_MKFS_SYSTEM_GROUP_SIZE SZ_4M
+#define BTRFS_MKFS_SMALL_VOLUME_SIZE SZ_1G
+
struct btrfs_mkfs_config {
char *label;
char fs_uuid[BTRFS_UUID_UNPARSED_SIZE];
@@ -41,5 +44,12 @@ struct btrfs_mkfs_config {
};
int make_btrfs(int fd, struct btrfs_mkfs_config *cfg);
+u64 btrfs_min_dev_size(u32 nodesize);
+u64 btrfs_min_global_blk_rsv_size(u32 nodesize);
+int test_minimum_size(const char *file, u32 nodesize);
+int is_vol_small(const char *file);
+int test_num_disk_vs_raid(u64 metadata_profile, u64 data_profile,
+ u64 dev_cnt, int mixed, int ssd);
+int test_dev_for_mkfs(const char *file, int force_overwrite);
#endif
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:
diff --git a/utils.h b/utils.h
index c5ff19f9..f86101b2 100644
--- a/utils.h
+++ b/utils.h
@@ -28,9 +28,6 @@
#include "btrfs-list.h"
#include "sizes.h"
-#define BTRFS_MKFS_SYSTEM_GROUP_SIZE SZ_4M
-#define BTRFS_MKFS_SMALL_VOLUME_SIZE SZ_1G
-
#define BTRFS_CONVERT_META_GROUP_SIZE SZ_32M
#define BTRFS_SCAN_MOUNTED (1ULL << 0)
@@ -116,13 +113,9 @@ int btrfs_open_dir(const char *path, DIR **dirstream, int verbose);
u64 btrfs_device_size(int fd, struct stat *st);
/* Helper to always get proper size of the destination string */
#define strncpy_null(dest, src) __strncpy_null(dest, src, sizeof(dest))
-int test_dev_for_mkfs(const char *file, int force_overwrite);
int get_label_mounted(const char *mount_path, char *labelp);
int get_label_unmounted(const char *dev, char *label);
-int test_num_disk_vs_raid(u64 metadata_profile, u64 data_profile,
- u64 dev_cnt, int mixed, int ssd);
int group_profile_max_safe_loss(u64 flags);
-int is_vol_small(const char *file);
int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf,
int verify);
int ask_user(const char *question);
@@ -136,7 +129,6 @@ int test_uuid_unique(char *fs_uuid);
u64 disk_size(const char *path);
u64 get_partition_size(const char *dev);
-int test_minimum_size(const char *file, u32 nodesize);
int test_issubvolname(const char *name);
int test_issubvolume(const char *path);
int test_isdir(const char *path);
@@ -144,27 +136,6 @@ int test_isdir(const char *path);
const char *subvol_strip_mountpoint(const char *mnt, const char *full_path);
int get_subvol_info(const char *fullpath, struct root_info *get_ri);
-/*
- * 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.
- */
-static inline u64 btrfs_min_global_blk_rsv_size(u32 nodesize)
-{
- return (u64)nodesize << 10;
-}
-
-static inline u64 btrfs_min_dev_size(u32 nodesize)
-{
- return 2 * (BTRFS_MKFS_SYSTEM_GROUP_SIZE +
- btrfs_min_global_blk_rsv_size(nodesize));
-}
-
int find_next_key(struct btrfs_path *path, struct btrfs_key *key);
const char* btrfs_group_type_str(u64 flag);
const char* btrfs_group_profile_str(u64 flag);