btrfs_drop_extents: make sure the item is getting smaller before truncate

Signed-off-by: Chris Mason <chris.mason@oracle.com>
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 3c00f96..55abdf9 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -45,6 +45,9 @@
 	u64 first_free;
 	int found = 0;
 
+	if (!block_group)
+		return 0;
+
 	root = root->fs_info->extent_root;
 	free_space_cache = &root->fs_info->free_space_cache;
 
@@ -168,6 +171,11 @@
 	u64 cache_miss = 0;
 	int wrapped = 0;
 
+	if (!cache) {
+		cache = btrfs_lookup_block_group(root->fs_info, search_start);
+		if (!cache)
+			return search_start;
+	}
 again:
 	ret = cache_block_group(root, cache);
 	if (ret)