linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Cc: linux-btrfs@vger.kernel.org, dsterba@suse.com
Subject: Re: [PATCH] btrfs-progs: Use helper functions to access btrfs_super_block->sys_chunk_array_size
Date: Wed, 30 Nov 2016 15:31:11 +0100	[thread overview]
Message-ID: <20161130143111.GL12522@twin.jikos.cz> (raw)
In-Reply-To: <1480431542-16889-1-git-send-email-chandan@linux.vnet.ibm.com>

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

      reply	other threads:[~2016-11-30 14:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161130143111.GL12522@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=chandan@linux.vnet.ibm.com \
    --cc=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).