Set license using %license
[platform/upstream/btrfs-progs.git] / convert / common.c
index d37d2b2..6ddf4a4 100644 (file)
@@ -64,7 +64,7 @@ static inline int write_temp_super(int fd, struct btrfs_super_block *sb,
        u32 crc = ~(u32)0;
        int ret;
 
-       crc = btrfs_csum_data(NULL, (char *)sb + BTRFS_CSUM_SIZE, crc,
+       crc = btrfs_csum_data((char *)sb + BTRFS_CSUM_SIZE, crc,
                              BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE);
        btrfs_csum_final(crc, &sb->csum[0]);
        ret = pwrite(fd, sb, BTRFS_SUPER_INFO_SIZE, sb_bytenr);
@@ -116,7 +116,7 @@ static int setup_temp_super(int fd, struct btrfs_mkfs_config *cfg,
 
        btrfs_set_super_bytenr(super, cfg->super_bytenr);
        btrfs_set_super_num_devices(super, 1);
-       btrfs_set_super_magic(super, BTRFS_MAGIC_PARTIAL);
+       btrfs_set_super_magic(super, BTRFS_MAGIC_TEMPORARY);
        btrfs_set_super_generation(super, 1);
        btrfs_set_super_root(super, root_bytenr);
        btrfs_set_super_chunk_root(super, chunk_bytenr);
@@ -128,7 +128,7 @@ static int setup_temp_super(int fd, struct btrfs_mkfs_config *cfg,
         */
        btrfs_set_super_bytes_used(super, 6 * cfg->nodesize);
        btrfs_set_super_sectorsize(super, cfg->sectorsize);
-       btrfs_set_super_leafsize(super, cfg->nodesize);
+       super->__unused_leafsize = cpu_to_le32(cfg->nodesize);
        btrfs_set_super_nodesize(super, cfg->nodesize);
        btrfs_set_super_stripesize(super, cfg->stripesize);
        btrfs_set_super_csum_type(super, BTRFS_CSUM_TYPE_CRC32);
@@ -167,7 +167,7 @@ static int setup_temp_extent_buffer(struct extent_buffer *buf,
        btrfs_set_header_generation(buf, 1);
        btrfs_set_header_backref_rev(buf, BTRFS_MIXED_BACKREF_REV);
        btrfs_set_header_owner(buf, owner);
-       btrfs_set_header_flags(buf, BTRFS_HEADER_FLAG_WRITTEN);
+       btrfs_set_header_flag(buf, BTRFS_HEADER_FLAG_WRITTEN);
        write_extent_buffer(buf, chunk_uuid, btrfs_header_chunk_tree_uuid(buf),
                            BTRFS_UUID_SIZE);
        write_extent_buffer(buf, fsid, btrfs_header_fsid(), BTRFS_FSID_SIZE);
@@ -219,7 +219,7 @@ static inline int write_temp_extent_buffer(int fd, struct extent_buffer *buf,
 {
        int ret;
 
-       csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0);
+       csum_tree_block_size(buf, btrfs_csum_sizes[BTRFS_CSUM_TYPE_CRC32], 0);
 
        /* Temporary extent buffer is always mapped 1:1 on disk */
        ret = pwrite(fd, buf->data, buf->len, bytenr);
@@ -796,8 +796,8 @@ int make_convert_btrfs(int fd, struct btrfs_mkfs_config *cfg,
        u64 csum_bytenr;
        int ret;
 
-       /* Shouldn't happen */
-       BUG_ON(cache_tree_empty(used_space));
+       /* Source filesystem must be opened, checked and analyzed in advance */
+       ASSERT(!cache_tree_empty(used_space));
 
        /*
         * reserve space for temporary superblock first