btrfs-progs: mkfs: make make_cfg::blocks an internal member
authorDavid Sterba <dsterba@suse.com>
Wed, 1 Feb 2017 13:25:18 +0000 (14:25 +0100)
committerDavid Sterba <dsterba@suse.com>
Wed, 8 Mar 2017 12:00:46 +0000 (13:00 +0100)
The caller of make_btrfs does not need to set it, it's for internal use
and can be read after mkfs ends.

Signed-off-by: David Sterba <dsterba@suse.com>
mkfs/common.c
mkfs/common.h
mkfs/main.c

index 8d92eae..1e6a324 100644 (file)
@@ -92,6 +92,12 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg)
        uuid_generate(super.dev_item.uuid);
        uuid_generate(chunk_tree_uuid);
 
+       cfg->blocks[0] = BTRFS_SUPER_INFO_OFFSET;
+       for (i = 1; i < 7; i++) {
+               cfg->blocks[i] = BTRFS_SUPER_INFO_OFFSET + 1024 * 1024 +
+                       cfg->nodesize * i;
+       }
+
        btrfs_set_super_bytenr(&super, cfg->blocks[0]);
        btrfs_set_super_num_devices(&super, 1);
        btrfs_set_super_magic(&super, BTRFS_MAGIC_PARTIAL);
index 09edc28..00f219a 100644 (file)
@@ -39,10 +39,11 @@ struct btrfs_mkfs_config {
        u64 features;
        /* Size of the filesystem in bytes */
        u64 num_bytes;
-       /* Logical addresses of superblock [0] and other tree roots */
-       u64 blocks[8];
 
        /* Output fields, set during creation */
+
+       /* Logical addresses of superblock [0] and other tree roots */
+       u64 blocks[8];
        char fs_uuid[BTRFS_UUID_UNPARSED_SIZE];
        char chunk_uuid[BTRFS_UUID_UNPARSED_SIZE];
 
index 0823b4f..be84263 100644 (file)
@@ -1400,7 +1400,6 @@ int main(int argc, char **argv)
        char *label = NULL;
        u64 block_count = 0;
        u64 dev_block_count = 0;
-       u64 blocks[7];
        u64 alloc_start = 0;
        u64 metadata_profile = 0;
        u64 data_profile = 0;
@@ -1723,12 +1722,6 @@ int main(int argc, char **argv)
                exit(1);
        }
 
-       blocks[0] = BTRFS_SUPER_INFO_OFFSET;
-       for (i = 1; i < 7; i++) {
-               blocks[i] = BTRFS_SUPER_INFO_OFFSET + 1024 * 1024 +
-                       nodesize * i;
-       }
-
        if (group_profile_max_safe_loss(metadata_profile) <
                group_profile_max_safe_loss(data_profile)){
                warning("metadata has lower redundancy than data!\n");
@@ -1736,7 +1729,6 @@ int main(int argc, char **argv)
 
        mkfs_cfg.label = label;
        memcpy(mkfs_cfg.fs_uuid, fs_uuid, sizeof(mkfs_cfg.fs_uuid));
-       memcpy(mkfs_cfg.blocks, blocks, sizeof(blocks));
        mkfs_cfg.num_bytes = dev_block_count;
        mkfs_cfg.nodesize = nodesize;
        mkfs_cfg.sectorsize = sectorsize;