diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index b5c2ad8fe2cad302ef456da76585e6b932471a6c..9d39d08a15556ea3177258ca803fed1203255915 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -5982,7 +5982,14 @@ struct extent_map *btrfs_get_extent(struct inode *inode, struct page *page, found_type = btrfs_key_type(&found_key); if (found_key.objectid != objectid || found_type != BTRFS_EXTENT_DATA_KEY) { - goto not_found; + /* + * If we backup past the first extent we want to move forward + * and see if there is an extent in front of us, otherwise we'll + * say there is a hole for our whole search range which can + * cause problems. + */ + extent_end = start; + goto next; } found_type = btrfs_file_extent_type(leaf, item); @@ -5997,7 +6004,7 @@ struct extent_map *btrfs_get_extent(struct inode *inode, struct page *page, size = btrfs_file_extent_inline_len(leaf, item); extent_end = ALIGN(extent_start + size, root->sectorsize); } - +next: if (start >= extent_end) { path->slots[0]++; if (path->slots[0] >= btrfs_header_nritems(leaf)) {