read_extent_buffer(eb, namebuf, (unsigned long)(di + 1), len);
+ if (key->type == BTRFS_DIR_ITEM_KEY &&
+ key->offset != btrfs_name_hash(namebuf, len)) {
+ rec->errors |= I_ERR_ODD_DIR_ITEM;
+ error("DIR_ITEM[%llu %llu] name %s namelen %u filetype %u mismatch with its hash, wanted %llu have %llu",
+ key->objectid, key->offset, namebuf, len, filetype,
+ key->offset, btrfs_name_hash(namebuf, len));
+ }
+
if (location.type == BTRFS_INODE_ITEM_KEY) {
add_inode_backref(inode_cache, location.objectid,
key->objectid, key->offset, namebuf,
read_extent_buffer(node, namebuf, (unsigned long)(di + 1), len);
filetype = btrfs_dir_type(node, di);
+ if (key->type == BTRFS_DIR_ITEM_KEY &&
+ key->offset != btrfs_name_hash(namebuf, len)) {
+ err |= -EIO;
+ error("root %llu DIR_ITEM[%llu %llu] name %s namelen %u filetype %u mismatch with its hash, wanted %llu have %llu",
+ root->objectid, key->objectid, key->offset,
+ namebuf, len, filetype, key->offset,
+ btrfs_name_hash(namebuf, len));
+ }
+
btrfs_init_path(&path);
btrfs_dir_item_key_to_cpu(node, di, &location);
* wrong onwer(3) out of chunk tree, to pass both chunk tree check
* and owner<->key_type check.
*/
- ret = btrfs_check_chunk_valid(global_info->tree_root, eb, chunk, slot,
+ ret = btrfs_check_chunk_valid(global_info, eb, chunk, slot,
key->offset);
if (ret < 0) {
error("chunk(%llu, %llu) is not valid, ignore it",
l = path.nodes[0];
chunk = btrfs_item_ptr(l, path.slots[0], struct btrfs_chunk);
- ret = btrfs_check_chunk_valid(chunk_root, l, chunk, path.slots[0],
+ ret = btrfs_check_chunk_valid(fs_info, l, chunk, path.slots[0],
chunk_key.offset);
if (ret < 0)
goto out;
chunk = btrfs_item_ptr(eb, slot, struct btrfs_chunk);
length = btrfs_chunk_length(eb, chunk);
chunk_end = chunk_key.offset + length;
- ret = btrfs_check_chunk_valid(extent_root, eb, chunk, slot,
+ ret = btrfs_check_chunk_valid(fs_info, eb, chunk, slot,
chunk_key.offset);
if (ret < 0) {
error("chunk[%llu %llu) is invalid", chunk_key.offset,
{ NULL, 0, NULL, 0}
};
- c = getopt_long(argc, argv, "as:br:p", long_options, NULL);
+ c = getopt_long(argc, argv, "as:br:pEQ", long_options, NULL);
if (c < 0)
break;
switch(c) {