mirror of
https://github.com/versity/scoutfs.git
synced 2026-08-31 21:31:34 +00:00
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:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user