raid56.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2012 Fusion-io All rights reserved.
  4. * Copyright (C) 2012 Intel Corp. All rights reserved.
  5. */
  6. #ifndef BTRFS_RAID56_H
  7. #define BTRFS_RAID56_H
  8. static inline int nr_parity_stripes(const struct map_lookup *map)
  9. {
  10. if (map->type & BTRFS_BLOCK_GROUP_RAID5)
  11. return 1;
  12. else if (map->type & BTRFS_BLOCK_GROUP_RAID6)
  13. return 2;
  14. else
  15. return 0;
  16. }
  17. static inline int nr_data_stripes(const struct map_lookup *map)
  18. {
  19. return map->num_stripes - nr_parity_stripes(map);
  20. }
  21. #define RAID5_P_STRIPE ((u64)-2)
  22. #define RAID6_Q_STRIPE ((u64)-1)
  23. #define is_parity_stripe(x) (((x) == RAID5_P_STRIPE) || \
  24. ((x) == RAID6_Q_STRIPE))
  25. struct btrfs_raid_bio;
  26. struct btrfs_device;
  27. int raid56_parity_recover(struct btrfs_fs_info *fs_info, struct bio *bio,
  28. struct btrfs_bio *bbio, u64 stripe_len,
  29. int mirror_num, int generic_io);
  30. int raid56_parity_write(struct btrfs_fs_info *fs_info, struct bio *bio,
  31. struct btrfs_bio *bbio, u64 stripe_len);
  32. void raid56_add_scrub_pages(struct btrfs_raid_bio *rbio, struct page *page,
  33. u64 logical);
  34. struct btrfs_raid_bio *
  35. raid56_parity_alloc_scrub_rbio(struct btrfs_fs_info *fs_info, struct bio *bio,
  36. struct btrfs_bio *bbio, u64 stripe_len,
  37. struct btrfs_device *scrub_dev,
  38. unsigned long *dbitmap, int stripe_nsectors);
  39. void raid56_parity_submit_scrub_rbio(struct btrfs_raid_bio *rbio);
  40. struct btrfs_raid_bio *
  41. raid56_alloc_missing_rbio(struct btrfs_fs_info *fs_info, struct bio *bio,
  42. struct btrfs_bio *bbio, u64 length);
  43. void raid56_submit_missing_rbio(struct btrfs_raid_bio *rbio);
  44. int btrfs_alloc_stripe_hash_table(struct btrfs_fs_info *info);
  45. void btrfs_free_stripe_hash_table(struct btrfs_fs_info *info);
  46. #endif