scoutfs: add bug on for out of order seg items

We've seen some cases where compaction writes a new segment that
contains items that aren't sorted.  This eventually leads to read being
mislead in its binary search of the items in a segment and failing to
find the items it was looking for.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2017-06-06 15:45:15 -07:00
parent a1dadd9763
commit 0280971fab
+10
View File
@@ -565,6 +565,16 @@ void scoutfs_seg_append_item(struct super_block *sb,
pos = le32_to_cpu(sblk->nr_items);
sblk->nr_items = cpu_to_le32(pos + 1);
/*
* It's very bad data corruption if we write out of order items
* to a segment. It'll mislead the key search during read and
* stop it from finding its items.
*/
if (pos) {
scoutfs_seg_item_ptrs(seg, pos - 1, &item_key, NULL, NULL);
BUG_ON(scoutfs_key_compare(key, &item_key) <= 0);
}
prev = pos_ptr(seg, pos - 1);
item = pos_ptr(seg, pos);