btrfs-progs: convert: Fix inline file extent creation condition
[platform/upstream/btrfs-progs.git] / check / main.c
index 97baae5..5fa09ab 100644 (file)
@@ -1511,8 +1511,15 @@ static int process_file_extent(struct btrfs_root *root,
                        if (found < num_bytes)
                                rec->some_csum_missing = 1;
                } else if (extent_type == BTRFS_FILE_EXTENT_PREALLOC) {
-                       if (found > 0)
-                               rec->errors |= I_ERR_ODD_CSUM_ITEM;
+                       if (found > 0) {
+                               ret = check_prealloc_extent_written(root->fs_info,
+                                                                   disk_bytenr,
+                                                                   num_bytes);
+                               if (ret < 0)
+                                       return ret;
+                               if (ret == 0)
+                                       rec->errors |= I_ERR_ODD_CSUM_ITEM;
+                       }
                }
        }
        return 0;
@@ -5339,7 +5346,9 @@ static int check_space_cache(struct btrfs_root *root)
                        error += ret;
                } else {
                        ret = load_free_space_cache(root->fs_info, cache);
-                       if (!ret)
+                       if (ret < 0)
+                               error++;
+                       if (ret <= 0)
                                continue;
                }
 
@@ -7638,28 +7647,6 @@ repair_abort:
        return err;
 }
 
-u64 calc_stripe_length(u64 type, u64 length, int num_stripes)
-{
-       u64 stripe_size;
-
-       if (type & BTRFS_BLOCK_GROUP_RAID0) {
-               stripe_size = length;
-               stripe_size /= num_stripes;
-       } else if (type & BTRFS_BLOCK_GROUP_RAID10) {
-               stripe_size = length * 2;
-               stripe_size /= num_stripes;
-       } else if (type & BTRFS_BLOCK_GROUP_RAID5) {
-               stripe_size = length;
-               stripe_size /= (num_stripes - 1);
-       } else if (type & BTRFS_BLOCK_GROUP_RAID6) {
-               stripe_size = length;
-               stripe_size /= (num_stripes - 2);
-       } else {
-               stripe_size = length;
-       }
-       return stripe_size;
-}
-
 /*
  * Check the chunk with its block group/dev list ref:
  * Return 0 if all refs seems valid.