"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "volumes.c" between
btrfs-progs-v5.4.tar.xz and btrfs-progs-v5.4.1.tar.xz

About: btrfs-progs are the userspace utilities for the Linux Btrfs filesystem.

volumes.c  (btrfs-progs-v5.4.tar.xz):volumes.c  (btrfs-progs-v5.4.1.tar.xz)
skipping to change at line 1802 skipping to change at line 1802
struct btrfs_device *dev; struct btrfs_device *dev;
int num_found = 0; int num_found = 0;
list_for_each_entry(dev, head, dev_list) { list_for_each_entry(dev, head, dev_list) {
if (dev->devid == devid && num_found++ == instance) if (dev->devid == devid && num_found++ == instance)
return dev; return dev;
} }
return NULL; return NULL;
} }
/*
* Return 0 if the chunk at @chunk_offset exists and is not read-only.
* Return 1 if the chunk at @chunk_offset exists and is read-only.
* Return <0 if we can't find chunk at @chunk_offset.
*/
int btrfs_chunk_readonly(struct btrfs_fs_info *fs_info, u64 chunk_offset) int btrfs_chunk_readonly(struct btrfs_fs_info *fs_info, u64 chunk_offset)
{ {
struct cache_extent *ce; struct cache_extent *ce;
struct map_lookup *map; struct map_lookup *map;
struct btrfs_mapping_tree *map_tree = &fs_info->mapping_tree; struct btrfs_mapping_tree *map_tree = &fs_info->mapping_tree;
int readonly = 0; int readonly = 0;
int i; int i;
/* /*
* During chunk recovering, we may fail to find block group's * During chunk recovering, we may fail to find block group's
* corresponding chunk, we will rebuild it later * corresponding chunk, we will rebuild it later
*/ */
ce = search_cache_extent(&map_tree->cache_tree, chunk_offset); if (fs_info->is_chunk_recover)
if (!fs_info->is_chunk_recover)
BUG_ON(!ce);
else
return 0; return 0;
ce = search_cache_extent(&map_tree->cache_tree, chunk_offset);
if (!ce)
return -ENOENT;
map = container_of(ce, struct map_lookup, ce); map = container_of(ce, struct map_lookup, ce);
for (i = 0; i < map->num_stripes; i++) { for (i = 0; i < map->num_stripes; i++) {
if (!map->stripes[i].dev->writeable) { if (!map->stripes[i].dev->writeable) {
readonly = 1; readonly = 1;
break; break;
} }
} }
return readonly; return readonly;
} }
skipping to change at line 1858 skipping to change at line 1864
int slot, u64 logical) int slot, u64 logical)
{ {
u64 length; u64 length;
u64 stripe_len; u64 stripe_len;
u16 num_stripes; u16 num_stripes;
u16 sub_stripes; u16 sub_stripes;
u64 type; u64 type;
u32 chunk_ondisk_size; u32 chunk_ondisk_size;
u32 sectorsize = fs_info->sectorsize; u32 sectorsize = fs_info->sectorsize;
/*
* Basic chunk item size check. Note that btrfs_chunk already contains
* one stripe, so no "==" check.
*/
if (slot >= 0 &&
btrfs_item_size_nr(leaf, slot) < sizeof(struct btrfs_chunk)) {
error("invalid chunk item size, have %u expect [%zu, %lu)",
btrfs_item_size_nr(leaf, slot),
sizeof(struct btrfs_chunk),
BTRFS_LEAF_DATA_SIZE(fs_info));
return -EUCLEAN;
}
length = btrfs_chunk_length(leaf, chunk); length = btrfs_chunk_length(leaf, chunk);
stripe_len = btrfs_chunk_stripe_len(leaf, chunk); stripe_len = btrfs_chunk_stripe_len(leaf, chunk);
num_stripes = btrfs_chunk_num_stripes(leaf, chunk); num_stripes = btrfs_chunk_num_stripes(leaf, chunk);
sub_stripes = btrfs_chunk_sub_stripes(leaf, chunk); sub_stripes = btrfs_chunk_sub_stripes(leaf, chunk);
type = btrfs_chunk_type(leaf, chunk); type = btrfs_chunk_type(leaf, chunk);
if (num_stripes == 0) {
error("invalid num_stripes, have %u expect non-zero",
num_stripes);
return -EUCLEAN;
}
if (slot >= 0 && btrfs_chunk_item_size(num_stripes) !=
btrfs_item_size_nr(leaf, slot)) {
error("invalid chunk item size, have %u expect %lu",
btrfs_item_size_nr(leaf, slot),
btrfs_chunk_item_size(num_stripes));
return -EUCLEAN;
}
/* /*
* These valid checks may be insufficient to cover every corner cases. * These valid checks may be insufficient to cover every corner cases.
*/ */
if (!IS_ALIGNED(logical, sectorsize)) { if (!IS_ALIGNED(logical, sectorsize)) {
error("invalid chunk logical %llu", logical); error("invalid chunk logical %llu", logical);
return -EIO; return -EIO;
} }
if (btrfs_chunk_sector_size(leaf, chunk) != sectorsize) { if (btrfs_chunk_sector_size(leaf, chunk) != sectorsize) {
error("invalid chunk sectorsize %llu", error("invalid chunk sectorsize %llu",
(unsigned long long)btrfs_chunk_sector_size(leaf, chunk)); (unsigned long long)btrfs_chunk_sector_size(leaf, chunk));
skipping to change at line 2144 skipping to change at line 2175
u32 array_size; u32 array_size;
u32 len = 0; u32 len = 0;
u32 cur_offset; u32 cur_offset;
struct btrfs_key key; struct btrfs_key key;
if (fs_info->nodesize < BTRFS_SUPER_INFO_SIZE) { if (fs_info->nodesize < BTRFS_SUPER_INFO_SIZE) {
printf("ERROR: nodesize %u too small to read superblock\n", printf("ERROR: nodesize %u too small to read superblock\n",
fs_info->nodesize); fs_info->nodesize);
return -EINVAL; return -EINVAL;
} }
sb = btrfs_find_create_tree_block(fs_info, BTRFS_SUPER_INFO_OFFSET); sb = alloc_dummy_extent_buffer(fs_info, BTRFS_SUPER_INFO_OFFSET,
BTRFS_SUPER_INFO_SIZE);
if (!sb) if (!sb)
return -ENOMEM; return -ENOMEM;
btrfs_set_buffer_uptodate(sb); btrfs_set_buffer_uptodate(sb);
write_extent_buffer(sb, super_copy, 0, sizeof(*super_copy)); write_extent_buffer(sb, super_copy, 0, sizeof(*super_copy));
array_size = btrfs_super_sys_array_size(super_copy); array_size = btrfs_super_sys_array_size(super_copy);
array_ptr = super_copy->sys_chunk_array; array_ptr = super_copy->sys_chunk_array;
sb_array_offset = offsetof(struct btrfs_super_block, sys_chunk_array); sb_array_offset = offsetof(struct btrfs_super_block, sys_chunk_array);
cur_offset = 0; cur_offset = 0;
 End of changes. 6 change blocks. 
5 lines changed or deleted 37 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)