sizeof(struct btrfs_key_ptr));
}
-static int check_tree_block(struct btrfs_root *root, struct extent_buffer *buf)
+static int check_tree_block(struct btrfs_fs_info *fs_info,
+ struct extent_buffer *buf)
{
struct btrfs_fs_devices *fs_devices;
+ u32 leafsize = btrfs_super_leafsize(fs_info->super_copy);
int ret = BTRFS_BAD_FSID;
if (buf->start != btrfs_header_bytenr(buf))
if (btrfs_header_level(buf) >= BTRFS_MAX_LEVEL)
return BTRFS_BAD_LEVEL;
if (btrfs_header_nritems(buf) > max_nritems(btrfs_header_level(buf),
- root->nodesize))
+ leafsize))
return BTRFS_BAD_NRITEMS;
- fs_devices = root->fs_info->fs_devices;
+ fs_devices = fs_info->fs_devices;
while (fs_devices) {
- if (root->fs_info->ignore_fsid_mismatch ||
+ if (fs_info->ignore_fsid_mismatch ||
!memcmp_extent_buffer(buf, fs_devices->fsid,
btrfs_header_fsid(),
BTRFS_FSID_SIZE)) {
return ret;
}
-static void print_tree_block_error(struct btrfs_root *root,
+static void print_tree_block_error(struct btrfs_fs_info *fs_info,
struct extent_buffer *eb,
int err)
{
read_extent_buffer(eb, buf, btrfs_header_fsid(),
BTRFS_UUID_SIZE);
uuid_unparse(buf, found_uuid);
- uuid_unparse(root->fs_info->fsid, fs_uuid);
+ uuid_unparse(fs_info->fsid, fs_uuid);
fprintf(stderr, "fsid mismatch, want=%s, have=%s\n",
fs_uuid, found_uuid);
break;
return __csum_tree_block_size(buf, csum_size, 1, 1);
}
-int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf,
- int verify)
+static int csum_tree_block_fs_info(struct btrfs_fs_info *fs_info,
+ struct extent_buffer *buf, int verify)
{
u16 csum_size =
- btrfs_super_csum_size(root->fs_info->super_copy);
- if (verify && root->fs_info->suppress_check_block_errors)
+ btrfs_super_csum_size(fs_info->super_copy);
+ if (verify && fs_info->suppress_check_block_errors)
return verify_tree_block_csum_silent(buf, csum_size);
return csum_tree_block_size(buf, csum_size, verify);
}
+int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf,
+ int verify)
+{
+ return csum_tree_block_fs_info(root->fs_info, buf, verify);
+}
+
struct extent_buffer *btrfs_find_tree_block(struct btrfs_root *root,
u64 bytenr, u32 blocksize)
{
bytenr, blocksize);
}
-struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root,
- u64 bytenr, u32 blocksize)
+struct extent_buffer* btrfs_find_create_tree_block(
+ struct btrfs_fs_info *fs_info, u64 bytenr, u32 blocksize)
{
- return alloc_extent_buffer(&root->fs_info->extent_cache, bytenr,
- blocksize);
+ return alloc_extent_buffer(&fs_info->extent_cache, bytenr, blocksize);
}
void readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize,
return 0;
}
-struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
- u32 blocksize, u64 parent_transid)
+struct extent_buffer* read_tree_block_fs_info(
+ struct btrfs_fs_info *fs_info, u64 bytenr, u32 blocksize,
+ u64 parent_transid)
{
int ret;
struct extent_buffer *eb;
int num_copies;
int ignore = 0;
- eb = btrfs_find_create_tree_block(root, bytenr, blocksize);
+ eb = btrfs_find_create_tree_block(fs_info, bytenr, blocksize);
if (!eb)
return ERR_PTR(-ENOMEM);
return eb;
while (1) {
- ret = read_whole_eb(root->fs_info, eb, mirror_num);
- if (ret == 0 && csum_tree_block(root, eb, 1) == 0 &&
- check_tree_block(root, eb) == 0 &&
+ ret = read_whole_eb(fs_info, eb, mirror_num);
+ if (ret == 0 && csum_tree_block_fs_info(fs_info, eb, 1) == 0 &&
+ check_tree_block(fs_info, eb) == 0 &&
verify_parent_transid(eb->tree, eb, parent_transid, ignore)
== 0) {
if (eb->flags & EXTENT_BAD_TRANSID &&
list_empty(&eb->recow)) {
list_add_tail(&eb->recow,
- &root->fs_info->recow_ebs);
+ &fs_info->recow_ebs);
eb->refs++;
}
btrfs_set_buffer_uptodate(eb);
return eb;
}
if (ignore) {
- if (check_tree_block(root, eb)) {
- if (!root->fs_info->suppress_check_block_errors)
- print_tree_block_error(root, eb,
- check_tree_block(root, eb));
+ if (check_tree_block(fs_info, eb)) {
+ if (!fs_info->suppress_check_block_errors)
+ print_tree_block_error(fs_info, eb,
+ check_tree_block(fs_info, eb));
} else {
- if (!root->fs_info->suppress_check_block_errors)
+ if (!fs_info->suppress_check_block_errors)
fprintf(stderr, "Csum didn't match\n");
}
ret = -EIO;
break;
}
- num_copies = btrfs_num_copies(&root->fs_info->mapping_tree,
+ num_copies = btrfs_num_copies(&fs_info->mapping_tree,
eb->start, eb->len);
if (num_copies == 1) {
ignore = 1;
struct btrfs_root *root,
struct extent_buffer *eb)
{
- if (check_tree_block(root, eb)) {
- print_tree_block_error(root, eb, check_tree_block(root, eb));
+ if (check_tree_block(root->fs_info, eb)) {
+ print_tree_block_error(root->fs_info, eb,
+ check_tree_block(root->fs_info, eb));
BUG();
}
* million of places that assume a root has a valid ->node
*/
info_root->node =
- btrfs_find_create_tree_block(info_root, 0, leafsize);
+ btrfs_find_create_tree_block(fs_info, 0, leafsize);
if (!info_root->node)
return -ENOMEM;
clear_extent_buffer_uptodate(NULL, info_root->node);
struct btrfs_device;
int read_whole_eb(struct btrfs_fs_info *info, struct extent_buffer *eb, int mirror);
-struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
- u32 blocksize, u64 parent_transid);
+struct extent_buffer* read_tree_block_fs_info(
+ struct btrfs_fs_info *fs_info, u64 bytenr, u32 blocksize,
+ u64 parent_transid);
+static inline struct extent_buffer* read_tree_block(
+ struct btrfs_root *root, u64 bytenr, u32 blocksize,
+ u64 parent_transid)
+{
+ return read_tree_block_fs_info(root->fs_info, bytenr, blocksize,
+ parent_transid);
+}
+
int read_extent_data(struct btrfs_root *root, char *data, u64 logical,
u64 *len, int mirror);
void readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize,
u64 parent_transid);
-struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root,
- u64 bytenr, u32 blocksize);
+struct extent_buffer* btrfs_find_create_tree_block(
+ struct btrfs_fs_info *fs_info, u64 bytenr, u32 blocksize);
int __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize,
u32 stripesize, struct btrfs_root *root,