[PATCH 03/21] btrfs: Add start < end check in btrfs_debug_check_extent_io_range()

Goldwyn Rodrigues
2023-03-02T22:25:15Z

For issues such as zero size writes, we can get start > end. Check them
in btrfs_debug_check_extent_io_range() so this may be caught early.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
fs/btrfs/extent-io-tree.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/extent-io-tree.c b/fs/btrfs/extent-io-tree.c
index 482721dd1eba..d467c614c84e 100644
--- a/fs/btrfs/extent-io-tree.c
+++ b/fs/btrfs/extent-io-tree.c
@@ -65,7 +65,8 @@ static inline void __btrfs_debug_check_extent_io_range(const char *caller,
return;

isize = i_size_read(&inode->vfs_inode);
- if (end >= PAGE_SIZE && (end % 2) == 0 && end != isize - 1) {
+ if ((start > end) ||
+ (end >= PAGE_SIZE && (end % 2) == 0 && end != isize - 1)) {
btrfs_debug_rl(inode->root->fs_info,
"%s: ino %llu isize %llu odd range [%llu,%llu]",
caller, btrfs_ino(inode), isize, start, end);
--
2.39.2