raid10.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #ifndef _RAID10_H
  2. #define _RAID10_H
  3. #include <linux/raid/md.h>
  4. typedef struct mirror_info mirror_info_t;
  5. struct mirror_info {
  6. mdk_rdev_t *rdev;
  7. sector_t head_position;
  8. };
  9. typedef struct r10bio_s r10bio_t;
  10. struct r10_private_data_s {
  11. mddev_t *mddev;
  12. mirror_info_t *mirrors;
  13. int raid_disks;
  14. int working_disks;
  15. spinlock_t device_lock;
  16. /* geometry */
  17. int near_copies; /* number of copies layed out raid0 style */
  18. int far_copies; /* number of copies layed out
  19. * at large strides across drives
  20. */
  21. int copies; /* near_copies * far_copies.
  22. * must be <= raid_disks
  23. */
  24. sector_t stride; /* distance between far copies.
  25. * This is size / far_copies
  26. */
  27. int chunk_shift; /* shift from chunks to sectors */
  28. sector_t chunk_mask;
  29. struct list_head retry_list;
  30. /* for use when syncing mirrors: */
  31. spinlock_t resync_lock;
  32. int nr_pending;
  33. int barrier;
  34. sector_t next_resync;
  35. wait_queue_head_t wait_idle;
  36. wait_queue_head_t wait_resume;
  37. mempool_t *r10bio_pool;
  38. mempool_t *r10buf_pool;
  39. };
  40. typedef struct r10_private_data_s conf_t;
  41. /*
  42. * this is the only point in the RAID code where we violate
  43. * C type safety. mddev->private is an 'opaque' pointer.
  44. */
  45. #define mddev_to_conf(mddev) ((conf_t *) mddev->private)
  46. /*
  47. * this is our 'private' RAID10 bio.
  48. *
  49. * it contains information about what kind of IO operations were started
  50. * for this RAID10 operation, and about their status:
  51. */
  52. struct r10bio_s {
  53. atomic_t remaining; /* 'have we finished' count,
  54. * used from IRQ handlers
  55. */
  56. sector_t sector; /* virtual sector number */
  57. int sectors;
  58. unsigned long state;
  59. mddev_t *mddev;
  60. /*
  61. * original bio going to /dev/mdx
  62. */
  63. struct bio *master_bio;
  64. /*
  65. * if the IO is in READ direction, then this is where we read
  66. */
  67. int read_slot;
  68. struct list_head retry_list;
  69. /*
  70. * if the IO is in WRITE direction, then multiple bios are used,
  71. * one for each copy.
  72. * When resyncing we also use one for each copy.
  73. * When reconstructing, we use 2 bios, one for read, one for write.
  74. * We choose the number when they are allocated.
  75. */
  76. struct {
  77. struct bio *bio;
  78. sector_t addr;
  79. int devnum;
  80. } devs[0];
  81. };
  82. /* bits for r10bio.state */
  83. #define R10BIO_Uptodate 0
  84. #define R10BIO_IsSync 1
  85. #define R10BIO_IsRecover 2
  86. #endif