scoutfs: bug if btree item creation corrupts

Add a BUG_ON() assertion for the case where we create an item that
starts in the item offset array.  This happens if the callers free space
calculations are incorrect.  It shouldn't be triggerable by corrupt
blocks if we're verifying the blocks as we read them in.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2016-09-08 14:28:22 -07:00
parent 5375ed5f38
commit 164bcb5d99

View File

@@ -181,6 +181,9 @@ static struct scoutfs_btree_item *create_item(struct scoutfs_btree_block *bt,
bt->item_offs[pos] = bt->free_end;
bt->nr_items++;
BUG_ON(le16_to_cpu(bt->free_end) <
offsetof(struct scoutfs_btree_block, item_offs[bt->nr_items]));
item = pos_item(bt, pos);
item->key = *key;
item->seq = bt->hdr.seq;