Skip to contentSkip to conversation

btrfs-progs: Use helper function to access btrfs_super_block->sys_chunk_array_size

PATCH Applied Chandan Rajendra 2 participants 2 messages Dec 1, 2016 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 btrfs-progs: Use helper function to access btrfs_super_block->sys_chunk_array_size

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.

---
 utils.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
utils.c +6 -2
index d0189ad..74dde1e 100644
@@ -562,14 +562,18 @@ 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;
+		cur = (char *)sb->sys_chunk_array
+			+ btrfs_super_sys_array_size(sb);
 		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);
 	}
Signature · 1 line
2.5.5
Applied
#1 lore raw
Quoted 7 lines · Chandan Rajendra

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.

Applied, thanks.