[Btrfs-devel][PATCH]Off by one fixes for extent-tree.c

Yan Zheng yanzheng at 21cn.com
Sun Nov 11 17:47:48 PST 2007


---
diff -r dc03d8df4762 extent-tree.c
--- a/extent-tree.c	Wed Nov 07 21:08:16 2007 -0500
+++ b/extent-tree.c	Mon Nov 12 09:41:57 2007 +0800
@@ -152,7 +152,7 @@ struct btrfs_block_group_cache *btrfs_lo
 	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;

@@ -195,7 +195,7 @@ again:
 			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;
 	}
@@ -1066,7 +1066,7 @@ check_pending:
 		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;



More information about the Btrfs-devel mailing list