linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs-progs: remove BTRFS_CRC32_SIZE definition
@ 2018-03-23  8:20 Misono Tomohiro
  2018-03-23  9:14 ` Qu Wenruo
  0 siblings, 1 reply; 5+ messages in thread
From: Misono Tomohiro @ 2018-03-23  8:20 UTC (permalink / raw)
  To: linux-btrfs, Qu Wenruo

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>
---
 convert/common.c |  2 +-
 convert/main.c   |  2 +-
 ctree.h          |  3 +--
 image/main.c     |  4 ++--
 mkfs/common.c    | 14 +++++++-------
 5 files changed, 12 insertions(+), 13 deletions(-)

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 17cdac76..4175cb85 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 16916ca2..50b99639 100644
--- a/mkfs/common.c
+++ b/mkfs/common.c
@@ -85,7 +85,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]);
@@ -276,7 +276,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);
@@ -364,7 +364,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);
@@ -404,7 +404,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);
@@ -417,7 +417,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);
@@ -429,7 +429,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);
@@ -440,7 +440,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) {
-- 
2.14.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] btrfs-progs: remove BTRFS_CRC32_SIZE definition
  2018-03-23  8:20 [PATCH] btrfs-progs: remove BTRFS_CRC32_SIZE definition Misono Tomohiro
@ 2018-03-23  9:14 ` Qu Wenruo
  2018-03-26  0:54   ` Misono Tomohiro
  0 siblings, 1 reply; 5+ messages in thread
From: Qu Wenruo @ 2018-03-23  9:14 UTC (permalink / raw)
  To: Misono Tomohiro, linux-btrfs, Qu Wenruo


[-- Attachment #1.1: Type: text/plain, Size: 6494 bytes --]



On 2018年03月23日 16:20, Misono Tomohiro wrote:
> 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>
> ---
>  convert/common.c |  2 +-
>  convert/main.c   |  2 +-
>  ctree.h          |  3 +--
>  image/main.c     |  4 ++--
>  mkfs/common.c    | 14 +++++++-------
>  5 files changed, 12 insertions(+), 13 deletions(-)
> 
> 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);

I'd say the normal kernel way to do this is like this, other than using
BTRFS_CSUM_TYPE_CRC32:
	u16 csum_size = btrfs_super_csum_size(fs_info->super_copy);

Thanks,
Qu

>  
>  	/* 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 17cdac76..4175cb85 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 16916ca2..50b99639 100644
> --- a/mkfs/common.c
> +++ b/mkfs/common.c
> @@ -85,7 +85,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]);
> @@ -276,7 +276,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);
> @@ -364,7 +364,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);
> @@ -404,7 +404,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);
> @@ -417,7 +417,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);
> @@ -429,7 +429,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);
> @@ -440,7 +440,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) {
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 520 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] btrfs-progs: remove BTRFS_CRC32_SIZE definition
  2018-03-23  9:14 ` Qu Wenruo
@ 2018-03-26  0:54   ` Misono Tomohiro
  2018-03-26  7:57     ` Qu Wenruo
  0 siblings, 1 reply; 5+ messages in thread
From: Misono Tomohiro @ 2018-03-26  0:54 UTC (permalink / raw)
  To: linux-btrfs, Qu Wenruo

On 2018/03/23 18:14, Qu Wenruo wrote:
> 
> 
> On 2018年03月23日 16:20, Misono Tomohiro wrote:
>> 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>
>> ---
>>  convert/common.c |  2 +-
>>  convert/main.c   |  2 +-
>>  ctree.h          |  3 +--
>>  image/main.c     |  4 ++--
>>  mkfs/common.c    | 14 +++++++-------
>>  5 files changed, 12 insertions(+), 13 deletions(-)
>>
>> 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);
> 
> I'd say the normal kernel way to do this is like this, other than using
> BTRFS_CSUM_TYPE_CRC32:
> 	u16 csum_size = btrfs_super_csum_size(fs_info->super_copy);
> 
> Thanks,
> Qu


Thanks, but we cannot access fs_info or struct btrfs_super_block here (and others in this diff).
Should we pass the csum type parameter as an argument? Since currently the only
supported type is crc32, I'm not sure if we should write the code so generic at this time.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] btrfs-progs: remove BTRFS_CRC32_SIZE definition
  2018-03-26  0:54   ` Misono Tomohiro
@ 2018-03-26  7:57     ` Qu Wenruo
  2018-03-26 13:14       ` David Sterba
  0 siblings, 1 reply; 5+ messages in thread
From: Qu Wenruo @ 2018-03-26  7:57 UTC (permalink / raw)
  To: Misono Tomohiro, linux-btrfs, Qu Wenruo


[-- Attachment #1.1: Type: text/plain, Size: 1828 bytes --]



On 2018年03月26日 08:54, Misono Tomohiro wrote:
> On 2018/03/23 18:14, Qu Wenruo wrote:
>>
>>
>> On 2018年03月23日 16:20, Misono Tomohiro wrote:
>>> 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>
>>> ---
>>>  convert/common.c |  2 +-
>>>  convert/main.c   |  2 +-
>>>  ctree.h          |  3 +--
>>>  image/main.c     |  4 ++--
>>>  mkfs/common.c    | 14 +++++++-------
>>>  5 files changed, 12 insertions(+), 13 deletions(-)
>>>
>>> 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);
>>
>> I'd say the normal kernel way to do this is like this, other than using
>> BTRFS_CSUM_TYPE_CRC32:
>> 	u16 csum_size = btrfs_super_csum_size(fs_info->super_copy);
>>
>> Thanks,
>> Qu
> 
> 
> Thanks, but we cannot access fs_info or struct btrfs_super_block here (and others in this diff).
> Should we pass the csum type parameter as an argument? Since currently the only
> supported type is crc32, I'm not sure if we should write the code so generic at this time.

Fair enough.

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] btrfs-progs: remove BTRFS_CRC32_SIZE definition
  2018-03-26  7:57     ` Qu Wenruo
@ 2018-03-26 13:14       ` David Sterba
  0 siblings, 0 replies; 5+ messages in thread
From: David Sterba @ 2018-03-26 13:14 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: Misono Tomohiro, linux-btrfs, Qu Wenruo

On Mon, Mar 26, 2018 at 03:57:09PM +0800, Qu Wenruo wrote:
> 
> 
> On 2018年03月26日 08:54, Misono Tomohiro wrote:
> > On 2018/03/23 18:14, Qu Wenruo wrote:
> >>
> >>
> >> On 2018年03月23日 16:20, Misono Tomohiro wrote:
> >>> 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>
> >>> ---
> >>>  convert/common.c |  2 +-
> >>>  convert/main.c   |  2 +-
> >>>  ctree.h          |  3 +--
> >>>  image/main.c     |  4 ++--
> >>>  mkfs/common.c    | 14 +++++++-------
> >>>  5 files changed, 12 insertions(+), 13 deletions(-)
> >>>
> >>> 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);
> >>
> >> I'd say the normal kernel way to do this is like this, other than using
> >> BTRFS_CSUM_TYPE_CRC32:
> >> 	u16 csum_size = btrfs_super_csum_size(fs_info->super_copy);
> >>
> >> Thanks,
> >> Qu
> > 
> > 
> > Thanks, but we cannot access fs_info or struct btrfs_super_block here (and others in this diff).
> > Should we pass the csum type parameter as an argument? Since currently the only
> > supported type is crc32, I'm not sure if we should write the code so generic at this time.
> 
> Fair enough.

Yeah, at this point I'm ok with replacing it with just the reference to
the array. It's obvious that this could be generalized once there are
more csum algorithms.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-03-26 13:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-23  8:20 [PATCH] btrfs-progs: remove BTRFS_CRC32_SIZE definition Misono Tomohiro
2018-03-23  9:14 ` Qu Wenruo
2018-03-26  0:54   ` Misono Tomohiro
2018-03-26  7:57     ` Qu Wenruo
2018-03-26 13:14       ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).