All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chandan Rajendra <chandan@linux.vnet.ibm.com>
To: linux-btrfs@vger.kernel.org
Cc: Chandan Rajendra <chandan@linux.vnet.ibm.com>, dsterba@suse.com
Subject: [PATCH] btrfs-progs: Use helper functions to access btrfs_super_block->sys_chunk_array_size
Date: Tue, 29 Nov 2016 20:29:02 +0530	[thread overview]
Message-ID: <1480431542-16889-1-git-send-email-chandan@linux.vnet.ibm.com> (raw)

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


             reply	other threads:[~2016-11-29 15:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-29 14:59 Chandan Rajendra [this message]
2016-11-30 14:31 ` [PATCH] btrfs-progs: Use helper functions to access btrfs_super_block->sys_chunk_array_size David Sterba

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=1480431542-16889-1-git-send-email-chandan@linux.vnet.ibm.com \
    --to=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.