[btrfs-devel][patch]Fix typo and off by one error in extent buffer codes

Yan Zheng yanzheng at 21cn.com
Mon Oct 22 01:27:49 PDT 2007


Hello

In alloc_extent_buffer, variable 'uptodate' should be 1 at first,
otherwise test for page update in subsequent codes  is nonsense.  The
off by one errors are obvious, I think no description is needed.

Regards
YZ

--
diff -r 9bf00d0c038f extent_map.c
--- a/extent_map.c	Fri Oct 19 14:01:21 2007 -0400
+++ b/extent_map.c	Mon Oct 22 12:37:35 2007 +0800
@@ -2045,7 +2045,7 @@ struct extent_buffer *alloc_extent_buffe
 	struct extent_buffer *eb;
 	struct page *p;
 	struct address_space *mapping = tree->mapping;
-	int uptodate = 0;
+	int uptodate = 1;

 	eb = __alloc_extent_buffer(tree, start, len, mask);
 	if (!eb || IS_ERR(eb))
@@ -2197,7 +2197,7 @@ int clear_extent_buffer_dirty(struct ext
 		 */
 		if ((i == 0 && (eb->start & (PAGE_CACHE_SIZE - 1))) ||
 		    ((i == num_pages - 1) &&
-		     ((eb->start + eb->len - 1) & (PAGE_CACHE_SIZE - 1)))) {
+		     ((eb->start + eb->len) & (PAGE_CACHE_SIZE - 1)))) {
 			start = page->index << PAGE_CACHE_SHIFT;
 			end  = start + PAGE_CACHE_SIZE - 1;
 			if (test_range_bit(tree, start, end,
@@ -2265,7 +2265,7 @@ int set_extent_buffer_uptodate(struct ex
 		page = extent_buffer_page(eb, i);
 		if ((i == 0 && (eb->start & (PAGE_CACHE_SIZE - 1))) ||
 		    ((i == num_pages - 1) &&
-		     ((eb->start + eb->len - 1) & (PAGE_CACHE_SIZE - 1)))) {
+		     ((eb->start + eb->len) & (PAGE_CACHE_SIZE - 1)))) {
 			check_page_uptodate(tree, page);
 			continue;
 		}
@@ -2401,7 +2401,7 @@ int map_private_extent_buffer(struct ext
 	struct page *p;
 	size_t start_offset = eb->start & ((u64)PAGE_CACHE_SIZE - 1);
 	unsigned long i = (start_offset + start) >> PAGE_CACHE_SHIFT;
-	unsigned long end_i = (start_offset + start + min_len) >>
+	unsigned long end_i = (start_offset + start + min_len - 1) >>
 		PAGE_CACHE_SHIFT;

 	if (i != end_i)



More information about the Btrfs-devel mailing list