Btrfs: Off by one fixes for extent-tree.c

This change “Btrfs: Off by one fixes for extent-tree.c” (commit 5cf6642) in Linux kernel is authored by Yan <yanzheng [at] 21cn.com> on Fri Nov 16 14:57:09 2007 -0500.

Description of "Btrfs: Off by one fixes for extent-tree.c"

The change “Btrfs: Off by one fixes for extent-tree.c” introduces changes as follows.

Btrfs: Off by one fixes for extent-tree.c

Signed-off-by: Chris Mason <chris.mason@oracle.com>

Linux kernel releases containing commit 5cf6642

The Linux kernel releases containing this commit are as follows.

Linux kernel code changes from "Btrfs: Off by one fixes for extent-tree.c"

There are 10 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 fs/btrfs/extent-tree.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
 
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index e5340677d6c4..6a7a9ba75fd9 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -150,12 +150,9 @@ struct btrfs_block_group_cache *btrfs_lookup_block_group(struct
 		return NULL;
 
 	block_group = (struct btrfs_block_group_cache *)(unsigned long)ptr;
-
-
-	if (block_group->key.objectid <= bytenr && bytenr <=
+	if (block_group->key.objectid <= bytenr && bytenr <
 	    block_group->key.objectid + block_group->key.offset)
 		return block_group;
-
 	return NULL;
 }
 static u64 find_search_start(struct btrfs_root *root,
@@ -195,7 +192,7 @@ static u64 find_search_start(struct btrfs_root *root,
 			continue;
 		}
 		if (data != BTRFS_BLOCK_GROUP_MIXED &&
-		    start + num >= cache->key.objectid + cache->key.offset)
+		    start + num > cache->key.objectid + cache->key.offset)
 			goto new_group;
 		return start;
 	}
@@ -1088,9 +1085,8 @@ static int find_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root
 
 	if (ins->objectid + num_bytes >= search_end)
 		goto enospc;
-
 	if (!full_scan && data != BTRFS_BLOCK_GROUP_MIXED &&
-	    ins->objectid + num_bytes >= block_group->
+	    ins->objectid + num_bytes > block_group->
 	    key.objectid + block_group->key.offset) {
 		search_start = block_group->key.objectid +
 			block_group->key.offset;

The commit for this change in Linux stable tree is 5cf6642 (patch).

Last modified: 2020/02/10