if (!repair || ret) {
err |= FILE_EXTENT_ERROR;
error(
- "root %llu EXTENT_DATA[%llu %llu] interrupt, should start at %llu",
- root->objectid, fkey->objectid, fkey->offset, *end);
+"root %llu EXTENT_DATA[%llu %llu] gap exists, expected: EXTENT_DATA[%llu %llu]",
+ root->objectid, fkey->objectid, fkey->offset,
+ fkey->objectid, *end);
}
}
u32 nodesize = root->fs_info->nodesize;
u32 item_size;
u64 offset;
- int tree_reloc_root = 0;
int found_ref = 0;
int err = 0;
int ret;
int strict = 1;
int parent = 0;
- if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID &&
- btrfs_header_bytenr(root->node) == bytenr)
- tree_reloc_root = 1;
btrfs_init_path(&path);
key.objectid = bytenr;
if (btrfs_fs_incompat(root->fs_info, SKINNY_METADATA))
/*
* Backref of tree reloc root points to itself, no need
* to check backref any more.
+ *
+ * This may be an error of loop backref, but extent tree
+ * checker should have already handled it.
+ * Here we only need to avoid infinite iteration.
*/
- if (tree_reloc_root) {
+ if (offset == bytenr) {
found_ref = 1;
} else {
/*
if (!ret)
found_ref = 1;
}
+ /*
+ * Finally check SHARED BLOCK REF, any found will be good
+ * Here we're not doing comprehensive extent backref checking,
+ * only need to ensure there is some extent referring to this
+ * tree block.
+ */
+ if (!found_ref) {
+ btrfs_release_path(&path);
+ key.objectid = bytenr;
+ key.type = BTRFS_SHARED_BLOCK_REF_KEY;
+ key.offset = (u64)-1;
+
+ ret = btrfs_search_slot(NULL, extent_root, &key, &path, 0, 0);
+ if (ret < 0) {
+ err |= BACKREF_MISSING;
+ goto out;
+ }
+ ret = btrfs_previous_extent_item(extent_root, &path, bytenr);
+ if (ret) {
+ err |= BACKREF_MISSING;
+ goto out;
+ }
+ found_ref = 1;
+ }
if (!found_ref)
err |= BACKREF_MISSING;
out:
* Except normal disk bytenr and disk num bytes, we still
* need to do extra check on dbackref offset as
* dbackref offset = file_offset - file_extent_offset
+ *
+ * Also, we must check the leaf owner.
+ * In case of shared tree blocks (snapshots) we can inherit
+ * leaves from source snapshot.
+ * In that case, reference from source snapshot should not
+ * count.
*/
if (btrfs_file_extent_disk_bytenr(leaf, fi) == bytenr &&
btrfs_file_extent_disk_num_bytes(leaf, fi) == len &&
(u64)(key.offset - btrfs_file_extent_offset(leaf, fi)) ==
- offset)
+ offset && btrfs_header_owner(leaf) == root_id)
found_count++;
next: