Message ID | 20190826114853.14860-2-jthumshirn@suse.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs-progs: support xxhash64 checksums | expand |
On Mon, Aug 26, 2019 at 01:48:43PM +0200, Johannes Thumshirn wrote: > The callers of csum_tree_block_size() blindly assume we're only having > crc32c as a possible checksum and thus pass in > btrfs_csum_sizes[BTRFS_CSUM_TYPE_CRC32] for the size argument of > csum_tree_block_size(). > > Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de> > Reviewed-by: Nikolay Borisov <nborisov@suse.com> > --- > mkfs/common.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/mkfs/common.c b/mkfs/common.c > index caca5e707233..b6e549b19272 100644 > --- a/mkfs/common.c > +++ b/mkfs/common.c > @@ -101,7 +101,7 @@ static int btrfs_create_tree_root(int fd, struct btrfs_mkfs_config *cfg, > } > > /* generate checksum */ > - csum_tree_block_size(buf, btrfs_csum_sizes[BTRFS_CSUM_TYPE_CRC32], 0); > + csum_tree_block_size(buf, btrfs_csum_sizes[cfg->csum_type], 0); Where is btrfs_mkfs_config::csum_type defined?
On Tue, Aug 27, 2019 at 06:33:02PM +0200, David Sterba wrote: > On Mon, Aug 26, 2019 at 01:48:43PM +0200, Johannes Thumshirn wrote: > > The callers of csum_tree_block_size() blindly assume we're only having > > crc32c as a possible checksum and thus pass in > > btrfs_csum_sizes[BTRFS_CSUM_TYPE_CRC32] for the size argument of > > csum_tree_block_size(). > > > > Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de> > > Reviewed-by: Nikolay Borisov <nborisov@suse.com> > > --- > > mkfs/common.c | 14 +++++++------- > > 1 file changed, 7 insertions(+), 7 deletions(-) > > > > diff --git a/mkfs/common.c b/mkfs/common.c > > index caca5e707233..b6e549b19272 100644 > > --- a/mkfs/common.c > > +++ b/mkfs/common.c > > @@ -101,7 +101,7 @@ static int btrfs_create_tree_root(int fd, struct btrfs_mkfs_config *cfg, > > } > > > > /* generate checksum */ > > - csum_tree_block_size(buf, btrfs_csum_sizes[BTRFS_CSUM_TYPE_CRC32], 0); > > + csum_tree_block_size(buf, btrfs_csum_sizes[cfg->csum_type], 0); > > Where is btrfs_mkfs_config::csum_type defined? Aha it's in 8/11.
On 27/08/2019 18:36, David Sterba wrote: > On Tue, Aug 27, 2019 at 06:33:02PM +0200, David Sterba wrote: >> On Mon, Aug 26, 2019 at 01:48:43PM +0200, Johannes Thumshirn wrote: >>> The callers of csum_tree_block_size() blindly assume we're only having >>> crc32c as a possible checksum and thus pass in >>> btrfs_csum_sizes[BTRFS_CSUM_TYPE_CRC32] for the size argument of >>> csum_tree_block_size(). >>> >>> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de> >>> Reviewed-by: Nikolay Borisov <nborisov@suse.com> >>> --- >>> mkfs/common.c | 14 +++++++------- >>> 1 file changed, 7 insertions(+), 7 deletions(-) >>> >>> diff --git a/mkfs/common.c b/mkfs/common.c >>> index caca5e707233..b6e549b19272 100644 >>> --- a/mkfs/common.c >>> +++ b/mkfs/common.c >>> @@ -101,7 +101,7 @@ static int btrfs_create_tree_root(int fd, struct btrfs_mkfs_config *cfg, >>> } >>> >>> /* generate checksum */ >>> - csum_tree_block_size(buf, btrfs_csum_sizes[BTRFS_CSUM_TYPE_CRC32], 0); >>> + csum_tree_block_size(buf, btrfs_csum_sizes[cfg->csum_type], 0); >> >> Where is btrfs_mkfs_config::csum_type defined? > > Aha it's in 8/11. Grr, more artifacts of rebasing/reorganizing the series. Sorry for that.
diff --git a/mkfs/common.c b/mkfs/common.c index caca5e707233..b6e549b19272 100644 --- a/mkfs/common.c +++ b/mkfs/common.c @@ -101,7 +101,7 @@ static int btrfs_create_tree_root(int fd, struct btrfs_mkfs_config *cfg, } /* generate checksum */ - csum_tree_block_size(buf, btrfs_csum_sizes[BTRFS_CSUM_TYPE_CRC32], 0); + csum_tree_block_size(buf, btrfs_csum_sizes[cfg->csum_type], 0); /* write back root tree */ ret = pwrite(fd, buf->data, cfg->nodesize, cfg->blocks[MKFS_ROOT_TREE]); @@ -292,7 +292,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_csum_sizes[BTRFS_CSUM_TYPE_CRC32], 0); + csum_tree_block_size(buf, btrfs_csum_sizes[cfg->csum_type], 0); ret = pwrite(fd, buf->data, cfg->nodesize, cfg->blocks[MKFS_EXTENT_TREE]); if (ret != cfg->nodesize) { ret = (ret < 0 ? -errno : -EIO); @@ -380,7 +380,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_csum_sizes[BTRFS_CSUM_TYPE_CRC32], 0); + csum_tree_block_size(buf, btrfs_csum_sizes[cfg->csum_type], 0); ret = pwrite(fd, buf->data, cfg->nodesize, cfg->blocks[MKFS_CHUNK_TREE]); if (ret != cfg->nodesize) { ret = (ret < 0 ? -errno : -EIO); @@ -420,7 +420,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_csum_sizes[BTRFS_CSUM_TYPE_CRC32], 0); + csum_tree_block_size(buf, btrfs_csum_sizes[cfg->csum_type], 0); ret = pwrite(fd, buf->data, cfg->nodesize, cfg->blocks[MKFS_DEV_TREE]); if (ret != cfg->nodesize) { ret = (ret < 0 ? -errno : -EIO); @@ -433,7 +433,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_csum_sizes[BTRFS_CSUM_TYPE_CRC32], 0); + csum_tree_block_size(buf, btrfs_csum_sizes[cfg->csum_type], 0); ret = pwrite(fd, buf->data, cfg->nodesize, cfg->blocks[MKFS_FS_TREE]); if (ret != cfg->nodesize) { ret = (ret < 0 ? -errno : -EIO); @@ -445,7 +445,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_csum_sizes[BTRFS_CSUM_TYPE_CRC32], 0); + csum_tree_block_size(buf, btrfs_csum_sizes[cfg->csum_type], 0); ret = pwrite(fd, buf->data, cfg->nodesize, cfg->blocks[MKFS_CSUM_TREE]); if (ret != cfg->nodesize) { ret = (ret < 0 ? -errno : -EIO); @@ -456,7 +456,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_csum_sizes[BTRFS_CSUM_TYPE_CRC32], 0); + csum_tree_block_size(buf, btrfs_csum_sizes[cfg->csum_type], 0); ret = pwrite(fd, buf->data, BTRFS_SUPER_INFO_SIZE, cfg->blocks[MKFS_SUPER_BLOCK]); if (ret != BTRFS_SUPER_INFO_SIZE) {