@@ -6736,6 +6736,25 @@ static inline int check_eb_range(const struct extent_buffer *eb,
if (unlikely(check_add_overflow(start, len, &offset) || offset > eb->len))
return report_eb_range(eb, start, len);
+#ifdef CONFIG_BTRFS_DEBUG
+ /*
+ * Catch places where we may have the wrong header math, this can go
+ * away later.
+ */
+ if (btrfs_header_flag(eb, BTRFS_HEADER_FLAG_V2)) {
+ if (start >= sizeof(struct btrfs_header_v2))
+ return false;
+ if (start == 0 && len == eb->len)
+ return false;
+ if (start + len > sizeof(struct btrfs_header_v2)) {
+ btrfs_warn(eb->fs_info,
+ "access overlaps the header_v2 on eb %llu start %lu len %lu",
+ eb->start, start, len);
+ return true;
+ }
+ }
+#endif
+
return false;
}
There's a few places where we modify the extent buffer data that I missed in my initial conversion. This check helped me catch the places I missed. Simply check to see if the eb has FLAG_V2 set and then make sure we're not overlapping access with the header_v2. This will go away in the future, but is handy while I'm working on the code. Signed-off-by: Josef Bacik <josef@toxicpanda.com> --- fs/btrfs/extent_io.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)