Update btree block validator for 8byte alignment

The change to aligning values didn't update the btree block verifier's
total length calculation, and while we're in there we can also check
that values are correctly aligned.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2021-06-17 09:36:00 -07:00
parent 045b3ca8d4
commit 9febc6b5dc
+9 -5
View File
@@ -928,7 +928,6 @@ static void verify_btree_block(struct super_block *sb, char *str,
int end_off;
int tot = 0;
int i = 0;
int j = 0;
int nr;
if (bt->level != level) {
@@ -967,8 +966,9 @@ static void verify_btree_block(struct super_block *sb, char *str,
goto out;
}
for (j = 0; j < sizeof(item->__pad); j++) {
WARN_ON_ONCE(item->__pad[j] != 0);
if (memchr_inv(item->__pad, '\0', sizeof(item->__pad))) {
reason = "item struct __pad isn't zero";
goto out;
}
if (scoutfs_key_compare(&item->key, start) < 0 ||
@@ -994,14 +994,18 @@ static void verify_btree_block(struct super_block *sb, char *str,
goto out;
}
if (le16_to_cpu(item->val_off) % SCOUTFS_BTREE_VALUE_ALIGN) {
reason = "item value not aligned";
goto out;
}
if (((int)le16_to_cpu(item->val_off) +
le16_to_cpu(item->val_len)) > end_off) {
reason = "item value outside valid";
goto out;
}
tot += sizeof(struct scoutfs_btree_item) +
le16_to_cpu(item->val_len);
tot += item_len_bytes(le16_to_cpu(item->val_len));
if (item->val_len != 0) {
first_val = min_t(int, first_val,