btrfs: reloc: fix wrong file extent type check to avoid false ENOENT
[linux-2.6-microblaze.git] / fs / btrfs / relocation.c
index 19b7db8..df63ef6 100644 (file)
@@ -2975,11 +2975,16 @@ static int delete_v1_space_cache(struct extent_buffer *leaf,
                return 0;
 
        for (i = 0; i < btrfs_header_nritems(leaf); i++) {
+               u8 type;
+
                btrfs_item_key_to_cpu(leaf, &key, i);
                if (key.type != BTRFS_EXTENT_DATA_KEY)
                        continue;
                ei = btrfs_item_ptr(leaf, i, struct btrfs_file_extent_item);
-               if (btrfs_file_extent_type(leaf, ei) == BTRFS_FILE_EXTENT_REG &&
+               type = btrfs_file_extent_type(leaf, ei);
+
+               if ((type == BTRFS_FILE_EXTENT_REG ||
+                    type == BTRFS_FILE_EXTENT_PREALLOC) &&
                    btrfs_file_extent_disk_bytenr(leaf, ei) == data_bytenr) {
                        found = true;
                        space_cache_ino = key.objectid;