Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions check/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ bool is_free_space_tree = false;
bool init_extent_tree = false;
bool check_data_csum = false;
static bool found_free_ino_cache = false;
static bool found_unknown_key = false;
struct cache_tree *roots_info_cache = NULL;

enum btrfs_check_mode {
Expand Down Expand Up @@ -1895,6 +1896,10 @@ static int process_one_leaf(struct btrfs_root *root, struct extent_buffer *eb,
ret = process_xattr_item(eb, i, &key, active_node);
break;
default:
error("Unknown key (%llu %u %llu) found in leaf %llu",
key.objectid, key.type, key.offset,
eb->start);
found_unknown_key = true;
break;
};
}
Expand Down Expand Up @@ -4027,6 +4032,8 @@ static int check_fs_roots(struct cache_tree *root_cache)
free_extent_cache_tree(&wc.shared);
if (!cache_tree_empty(&wc.shared))
fprintf(stderr, "warning line %d\n", __LINE__);
if (!err && found_unknown_key)
err = 1;

return err;
}
Expand Down
5 changes: 3 additions & 2 deletions check/mode-lowmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -2808,8 +2808,9 @@ static int check_inode_item(struct btrfs_root *root, struct btrfs_path *path)
case BTRFS_XATTR_ITEM_KEY:
break;
default:
error("ITEM[%llu %u %llu] UNKNOWN TYPE",
key.objectid, key.type, key.offset);
error("ITEM[%llu %u %llu] UNKNOWN TYPE in leaf %llu",
key.objectid, key.type, key.offset, node->start);
err |= UNKNOWN_KEY;
}
}

Expand Down
1 change: 1 addition & 0 deletions check/mode-lowmem.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#define INVALID_GENERATION (1U << 26) /* Generation is too new */
#define SUPER_BYTES_USED_ERROR (1U << 27) /* Super bytes_used is invalid */
#define DUP_FILENAME_ERROR (1U << 28) /* DIR_ITEM contains duplicate names */
#define UNKNOWN_KEY (1U << 29) /* Found unknown key type in fs trees */

/*
* Error bit for low memory mode check.
Expand Down
14 changes: 14 additions & 0 deletions tests/fsck-tests/069-unknown-fs-tree-key/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
#
# Verify that check can report unknown key types in subvolume trees

source "$TEST_TOP/common" || exit

check_prereq btrfs

check_image() {
run_mustfail "unknown keys in subvolume trees not reported as error" \
"$TOP/btrfs" check "$1"
}

check_all_images
Binary file not shown.