diff --git a/kmod/src/btree.c b/kmod/src/btree.c index 15e28c8c..d8ff6d51 100644 --- a/kmod/src/btree.c +++ b/kmod/src/btree.c @@ -27,6 +27,7 @@ #include "counters.h" #include "triggers.h" #include "options.h" +#include "msg.h" #include "scoutfs_trace.h" @@ -1145,6 +1146,15 @@ restart: /* XXX more aggressive block verification, before ref updates? */ if (bt->level != level) { + scoutfs_corruption(sb, SC_BTREE_BLOCK_LEVEL, + corrupt_btree_block_level, + "root_height %u root_blkno %llu root_seq %llu blkno %llu seq %llu level %u expected %u", + root->height, + le64_to_cpu(root->ref.blkno), + le64_to_cpu(root->ref.seq), + le64_to_cpu(bt->blkno), + le64_to_cpu(bt->seq), bt->level, + level); ret = -EIO; break; } @@ -1177,6 +1187,15 @@ restart: /* Find the next child block for the search key. */ pos = find_pos(bt, key, key_len, &cmp); if (pos >= nr) { + scoutfs_corruption(sb, SC_BTREE_NO_CHILD_REF, + corrupt_btree_block_level, + "root_height %u root_blkno %llu root_seq %llu blkno %llu seq %llu level %u nr %u pos %u cmp %d", + root->height, + le64_to_cpu(root->ref.blkno), + le64_to_cpu(root->ref.seq), + le64_to_cpu(bt->blkno), + le64_to_cpu(bt->seq), bt->level, + nr, pos, cmp); ret = -EIO; break; } diff --git a/kmod/src/counters.h b/kmod/src/counters.h index a919b191..6ecbd8e5 100644 --- a/kmod/src/counters.h +++ b/kmod/src/counters.h @@ -23,6 +23,8 @@ EXPAND_COUNTER(compact_stale_error) \ EXPAND_COUNTER(compact_sticky_upper) \ EXPAND_COUNTER(compact_sticky_written) \ + EXPAND_COUNTER(corrupt_btree_block_level) \ + EXPAND_COUNTER(corrupt_btree_no_child_ref) \ EXPAND_COUNTER(corrupt_dirent_backref_name_len) \ EXPAND_COUNTER(corrupt_dirent_name_len) \ EXPAND_COUNTER(corrupt_dirent_readdir_name_len) \ diff --git a/kmod/src/format.h b/kmod/src/format.h index 54857d24..4b60a75c 100644 --- a/kmod/src/format.h +++ b/kmod/src/format.h @@ -655,6 +655,8 @@ enum { SC_SYMLINK_INODE_SIZE, SC_SYMLINK_MISSING_ITEM, SC_SYMLINK_NOT_NULL_TERM, + SC_BTREE_BLOCK_LEVEL, + SC_BTREE_NO_CHILD_REF, SC_NR_SOURCES, };