btrfs-progs: Use helper functions to access btrfs_super_block->sys_chunk_array_size
PATCH 1/1 btrfs-progs: Use helper functions 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 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
utils.c +4 -1
@@ -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); }
Signature · 1 line
2.5.5
Quoted 16 lines · Chandan Rajendra
btrfs_super_block->sys_chunk_array_sizeis stored as le32 data on disk. Howeverinsert_temp_chunk_item()writessys_chunk_array_sizein host cpu order. This commit fixes this by using super block access helper functions to read and writebtrfs_super_block->sys_chunk_array_sizefield.Signed-off-by Chandan Rajendra <[email protected]>--- utils.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)utils.c +0
-0
utils.c static int insert_temp_chunk_item(int fd, struct extent_buffer *buf, · line 567
Quoted 6 lines
utils.c +1
-0@@ -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.
Quoted 19 lines
utils.c +3
-1memcpy (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 · 6 lines
2.5.5 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html