summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMisono, Tomohiro <misono.tomohiro@jp.fujitsu.com>2018-03-23 17:20:07 +0900
committerDavid Sterba <dsterba@suse.com>2018-03-30 22:15:55 +0200
commitc074434fb5f0874dcf8523191359976b668527f8 (patch)
treebd35797b19c61dca86fa2e3d2696bc6e77a8d9ec
parentdcb174ce2e2c9be1eaad73757d0312246560ba3d (diff)
btrfs-progs: remove BTRFS_CRC32_SIZE definition
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>
-rw-r--r--cmds-inspect-dump-super.c3
-rw-r--r--convert/common.c2
-rw-r--r--convert/main.c2
-rw-r--r--ctree.h3
-rw-r--r--image/main.c4
-rw-r--r--mkfs/common.c14
6 files changed, 14 insertions, 14 deletions
diff --git a/cmds-inspect-dump-super.c b/cmds-inspect-dump-super.c
index 85bff262..e965267c 100644
--- a/cmds-inspect-dump-super.c
+++ b/cmds-inspect-dump-super.c
@@ -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]");
diff --git a/convert/common.c b/convert/common.c
index 3860f3b9..2b944fd8 100644
--- a/convert/common.c
+++ b/convert/common.c
@@ -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);
diff --git a/convert/main.c b/convert/main.c
index b3ea31d7..6bdfab40 100644
--- a/convert/main.c
+++ b/convert/main.c
@@ -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 c76849d8..fa861ba0 100644
--- 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
diff --git a/image/main.c b/image/main.c
index 9c75c8b4..5f155c23 100644
--- a/image/main.c
+++ b/image/main.c
@@ -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)
diff --git a/mkfs/common.c b/mkfs/common.c
index 6924d9b7..a6d3e668 100644
--- a/mkfs/common.c
+++ b/mkfs/common.c
@@ -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) {