linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs-progs: Use helper functions to access btrfs_super_block->sys_chunk_array_size
@ 2016-11-29 14:59 Chandan Rajendra
  2016-11-30 14:31 ` David Sterba
  0 siblings, 1 reply; 2+ messages in thread
From: Chandan Rajendra @ 2016-11-29 14:59 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Chandan Rajendra, dsterba

btrfs_super_block->sys_chunk_array_size is stored as le32 data on
disk. However insert_temp_chunk_item() writes sys_chunk_array_size in
host cpu order. This commit fixes this by using super block access
helper functions to read and write
btrfs_super_block->sys_chunk_array_size field.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
---
 utils.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/utils.c b/utils.c
index d0189ad..7b17b20 100644
--- a/utils.c
+++ b/utils.c
@@ -562,14 +562,17 @@ static int insert_temp_chunk_item(int fd, struct extent_buffer *buf,
 	 */
 	if (type & BTRFS_BLOCK_GROUP_SYSTEM) {
 		char *cur;
+		u32 array_size;
 
 		cur = (char *)sb->sys_chunk_array + sb->sys_chunk_array_size;
 		memcpy(cur, &disk_key, sizeof(disk_key));
 		cur += sizeof(disk_key);
 		read_extent_buffer(buf, cur, (unsigned long int)chunk,
 				   btrfs_chunk_item_size(1));
-		sb->sys_chunk_array_size += btrfs_chunk_item_size(1) +
+		array_size = btrfs_super_sys_array_size(sb);
+		array_size += btrfs_chunk_item_size(1) +
 					    sizeof(disk_key);
+		btrfs_set_super_sys_array_size(sb, array_size);
 
 		ret = write_temp_super(fd, sb, cfg->super_bytenr);
 	}
-- 
2.5.5


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

* Re: [PATCH] btrfs-progs: Use helper functions to access btrfs_super_block->sys_chunk_array_size
  2016-11-29 14:59 [PATCH] btrfs-progs: Use helper functions to access btrfs_super_block->sys_chunk_array_size Chandan Rajendra
@ 2016-11-30 14:31 ` David Sterba
  0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2016-11-30 14:31 UTC (permalink / raw)
  To: Chandan Rajendra; +Cc: linux-btrfs, dsterba

On Tue, Nov 29, 2016 at 08:29:02PM +0530, Chandan Rajendra wrote:
> btrfs_super_block->sys_chunk_array_size is stored as le32 data on
> disk. However insert_temp_chunk_item() writes sys_chunk_array_size in
> host cpu order. This commit fixes this by using super block access
> helper functions to read and write
> btrfs_super_block->sys_chunk_array_size field.
> 
> Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
> ---
>  utils.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/utils.c b/utils.c
> index d0189ad..7b17b20 100644
> --- a/utils.c
> +++ b/utils.c
> @@ -562,14 +562,17 @@ static int insert_temp_chunk_item(int fd, struct extent_buffer *buf,
>  	 */
>  	if (type & BTRFS_BLOCK_GROUP_SYSTEM) {
>  		char *cur;
> +		u32 array_size;
>  
>  		cur = (char *)sb->sys_chunk_array + sb->sys_chunk_array_size;

This should also use the accessor, 'sb' is directly mapped to the buffer
read from disk.

>  		memcpy(cur, &disk_key, sizeof(disk_key));
>  		cur += sizeof(disk_key);
>  		read_extent_buffer(buf, cur, (unsigned long int)chunk,
>  				   btrfs_chunk_item_size(1));
> -		sb->sys_chunk_array_size += btrfs_chunk_item_size(1) +
> +		array_size = btrfs_super_sys_array_size(sb);
> +		array_size += btrfs_chunk_item_size(1) +
>  					    sizeof(disk_key);
> +		btrfs_set_super_sys_array_size(sb, array_size);
>  
>  		ret = write_temp_super(fd, sb, cfg->super_bytenr);
>  	}
> -- 
> 2.5.5
> 
> --
> 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

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

end of thread, other threads:[~2016-11-30 14:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-29 14:59 [PATCH] btrfs-progs: Use helper functions to access btrfs_super_block->sys_chunk_array_size Chandan Rajendra
2016-11-30 14:31 ` 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).