btrfs-progs: remove BTRFS_CRC32_SIZE definition
authorMisono, Tomohiro <misono.tomohiro@jp.fujitsu.com>
Fri, 23 Mar 2018 08:20:07 +0000 (17:20 +0900)
committerDavid Sterba <dsterba@suse.com>
Fri, 30 Mar 2018 20:15:55 +0000 (22:15 +0200)
The kernel code no longer has BTRFS_CRC32_SIZE and only uses
btrfs_csum_sizes[]. So, update the progs code as well.

Suggested-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
cmds-inspect-dump-super.c
convert/common.c
convert/main.c
ctree.h
image/main.c
mkfs/common.c

index 85bff26..e965267 100644 (file)
@@ -339,7 +339,8 @@ static void dump_superblock(struct btrfs_super_block *sb, int full)
        printf("csum\t\t\t0x");
        for (i = 0, p = sb->csum; i < csum_size; i++)
                printf("%02x", p[i]);
-       if (csum_type != BTRFS_CSUM_TYPE_CRC32 || csum_size != BTRFS_CRC32_SIZE)
+       if (csum_type != BTRFS_CSUM_TYPE_CRC32 ||
+           csum_size != btrfs_csum_sizes[BTRFS_CSUM_TYPE_CRC32])
                printf(" [UNKNOWN CSUM TYPE OR SIZE]");
        else if (check_csum_sblock(sb, csum_size))
                printf(" [match]");
index 3860f3b..2b944fd 100644 (file)
@@ -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);
index b3ea31d..6bdfab4 100644 (file)
@@ -1026,7 +1026,7 @@ static int migrate_super_block(int fd, u64 old_bytenr)
        BUG_ON(btrfs_super_bytenr(super) != old_bytenr);
        btrfs_set_super_bytenr(super, BTRFS_SUPER_INFO_OFFSET);
 
-       csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0);
+       csum_tree_block_size(buf, btrfs_csum_sizes[BTRFS_CSUM_TYPE_CRC32], 0);
        ret = pwrite(fd, buf->data, BTRFS_SUPER_INFO_SIZE,
                BTRFS_SUPER_INFO_OFFSET);
        if (ret != BTRFS_SUPER_INFO_SIZE)
diff --git a/ctree.h b/ctree.h
index c76849d..fa861ba 100644 (file)
--- a/ctree.h
+++ b/ctree.h
@@ -167,10 +167,9 @@ struct btrfs_free_space_ctl;
 /* csum types */
 #define BTRFS_CSUM_TYPE_CRC32  0
 
+/* four bytes for CRC32 */
 static int btrfs_csum_sizes[] = { 4 };
 
-/* four bytes for CRC32 */
-#define BTRFS_CRC32_SIZE 4
 #define BTRFS_EMPTY_DIR_SIZE 0
 
 #define BTRFS_FT_UNKNOWN       0
index 9c75c8b..5f155c2 100644 (file)
@@ -119,11 +119,11 @@ static struct extent_buffer *alloc_dummy_eb(u64 bytenr, u32 size);
 
 static void csum_block(u8 *buf, size_t len)
 {
-       u8 result[BTRFS_CRC32_SIZE];
+       u8 result[btrfs_csum_sizes[BTRFS_CSUM_TYPE_CRC32]];
        u32 crc = ~(u32)0;
        crc = crc32c(crc, buf + BTRFS_CSUM_SIZE, len - BTRFS_CSUM_SIZE);
        btrfs_csum_final(crc, result);
-       memcpy(buf, result, BTRFS_CRC32_SIZE);
+       memcpy(buf, result, btrfs_csum_sizes[BTRFS_CSUM_TYPE_CRC32]);
 }
 
 static int has_name(struct btrfs_key *key)
index 6924d9b..a6d3e66 100644 (file)
@@ -99,7 +99,7 @@ static int btrfs_create_tree_root(int fd, struct btrfs_mkfs_config *cfg,
        }
 
        /* generate checksum */
-       csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0);
+       csum_tree_block_size(buf, btrfs_csum_sizes[BTRFS_CSUM_TYPE_CRC32], 0);
 
        /* write back root tree */
        ret = pwrite(fd, buf->data, cfg->nodesize, cfg->blocks[MKFS_ROOT_TREE]);
@@ -290,7 +290,7 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg)
        btrfs_set_header_bytenr(buf, cfg->blocks[MKFS_EXTENT_TREE]);
        btrfs_set_header_owner(buf, BTRFS_EXTENT_TREE_OBJECTID);
        btrfs_set_header_nritems(buf, nritems);
-       csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0);
+       csum_tree_block_size(buf, btrfs_csum_sizes[BTRFS_CSUM_TYPE_CRC32], 0);
        ret = pwrite(fd, buf->data, cfg->nodesize, cfg->blocks[MKFS_EXTENT_TREE]);
        if (ret != cfg->nodesize) {
                ret = (ret < 0 ? -errno : -EIO);
@@ -378,7 +378,7 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg)
        btrfs_set_header_bytenr(buf, cfg->blocks[MKFS_CHUNK_TREE]);
        btrfs_set_header_owner(buf, BTRFS_CHUNK_TREE_OBJECTID);
        btrfs_set_header_nritems(buf, nritems);
-       csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0);
+       csum_tree_block_size(buf, btrfs_csum_sizes[BTRFS_CSUM_TYPE_CRC32], 0);
        ret = pwrite(fd, buf->data, cfg->nodesize, cfg->blocks[MKFS_CHUNK_TREE]);
        if (ret != cfg->nodesize) {
                ret = (ret < 0 ? -errno : -EIO);
@@ -418,7 +418,7 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg)
        btrfs_set_header_bytenr(buf, cfg->blocks[MKFS_DEV_TREE]);
        btrfs_set_header_owner(buf, BTRFS_DEV_TREE_OBJECTID);
        btrfs_set_header_nritems(buf, nritems);
-       csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0);
+       csum_tree_block_size(buf, btrfs_csum_sizes[BTRFS_CSUM_TYPE_CRC32], 0);
        ret = pwrite(fd, buf->data, cfg->nodesize, cfg->blocks[MKFS_DEV_TREE]);
        if (ret != cfg->nodesize) {
                ret = (ret < 0 ? -errno : -EIO);
@@ -431,7 +431,7 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg)
        btrfs_set_header_bytenr(buf, cfg->blocks[MKFS_FS_TREE]);
        btrfs_set_header_owner(buf, BTRFS_FS_TREE_OBJECTID);
        btrfs_set_header_nritems(buf, 0);
-       csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0);
+       csum_tree_block_size(buf, btrfs_csum_sizes[BTRFS_CSUM_TYPE_CRC32], 0);
        ret = pwrite(fd, buf->data, cfg->nodesize, cfg->blocks[MKFS_FS_TREE]);
        if (ret != cfg->nodesize) {
                ret = (ret < 0 ? -errno : -EIO);
@@ -443,7 +443,7 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg)
        btrfs_set_header_bytenr(buf, cfg->blocks[MKFS_CSUM_TREE]);
        btrfs_set_header_owner(buf, BTRFS_CSUM_TREE_OBJECTID);
        btrfs_set_header_nritems(buf, 0);
-       csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0);
+       csum_tree_block_size(buf, btrfs_csum_sizes[BTRFS_CSUM_TYPE_CRC32], 0);
        ret = pwrite(fd, buf->data, cfg->nodesize, cfg->blocks[MKFS_CSUM_TREE]);
        if (ret != cfg->nodesize) {
                ret = (ret < 0 ? -errno : -EIO);
@@ -454,7 +454,7 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg)
        memset(buf->data, 0, BTRFS_SUPER_INFO_SIZE);
        memcpy(buf->data, &super, sizeof(super));
        buf->len = BTRFS_SUPER_INFO_SIZE;
-       csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0);
+       csum_tree_block_size(buf, btrfs_csum_sizes[BTRFS_CSUM_TYPE_CRC32], 0);
        ret = pwrite(fd, buf->data, BTRFS_SUPER_INFO_SIZE,
                        cfg->blocks[MKFS_SUPER_BLOCK]);
        if (ret != BTRFS_SUPER_INFO_SIZE) {