btrfs-progs: move more mkfs declarations to the common header
authorDavid Sterba <dsterba@suse.com>
Tue, 31 Jan 2017 22:13:54 +0000 (23:13 +0100)
committerDavid Sterba <dsterba@suse.com>
Wed, 8 Mar 2017 12:00:46 +0000 (13:00 +0100)
Signed-off-by: David Sterba <dsterba@suse.com>
cmds-device.c
cmds-replace.c
mkfs/common.h
utils.c
utils.h

index 58f7dee..7915bc9 100644 (file)
@@ -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>]",
index ee7938c..a3ea977 100644 (file)
@@ -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);
index 2a18839..7011c67 100644 (file)
@@ -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 794f4e6..20cddd9 100644 (file)
--- 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 c5ff19f..f86101b 100644 (file)
--- 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);