raid10.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #ifndef _RAID10_H
  2. #define _RAID10_H
  3. typedef struct mirror_info mirror_info_t;
  4. struct mirror_info {
  5. mdk_rdev_t *rdev;
  6. sector_t head_position;
  7. };
  8. typedef struct r10bio_s r10bio_t;
  9. struct r10_private_data_s {
  10. mddev_t *mddev;
  11. mirror_info_t *mirrors;
  12. int raid_disks;
  13. spinlock_t device_lock;
  14. /* geometry */
  15. int near_copies; /* number of copies layed out raid0 style */
  16. int far_copies; /* number of copies layed out
  17. * at large strides across drives
  18. */
  19. int far_offset; /* far_copies are offset by 1 stripe
  20. * instead of many
  21. */
  22. int copies; /* near_copies * far_copies.
  23. * must be <= raid_disks
  24. */
  25. sector_t stride; /* distance between far copies.
  26. * This is size / far_copies unless
  27. * far_offset, in which case it is
  28. * 1 stripe.
  29. */
  30. int chunk_shift; /* shift from chunks to sectors */
  31. sector_t chunk_mask;
  32. struct list_head retry_list;
  33. /* queue pending writes and submit them on unplug */
  34. struct bio_list pending_bio_list;
  35. spinlock_t resync_lock;
  36. int nr_pending;
  37. int nr_waiting;
  38. int nr_queued;
  39. int barrier;
  40. sector_t next_resync;
  41. int fullsync; /* set to 1 if a full sync is needed,
  42. * (fresh device added).
  43. * Cleared when a sync completes.
  44. */
  45. wait_queue_head_t wait_barrier;
  46. mempool_t *r10bio_pool;
  47. mempool_t *r10buf_pool;
  48. struct page *tmppage;
  49. };
  50. typedef struct r10_private_data_s conf_t;
  51. /*
  52. * this is our 'private' RAID10 bio.
  53. *
  54. * it contains information about what kind of IO operations were started
  55. * for this RAID10 operation, and about their status:
  56. */
  57. struct r10bio_s {
  58. atomic_t remaining; /* 'have we finished' count,
  59. * used from IRQ handlers
  60. */
  61. sector_t sector; /* virtual sector number */
  62. int sectors;
  63. unsigned long state;
  64. mddev_t *mddev;
  65. /*
  66. * original bio going to /dev/mdx
  67. */
  68. struct bio *master_bio;
  69. /*
  70. * if the IO is in READ direction, then this is where we read
  71. */
  72. int read_slot;
  73. struct list_head retry_list;
  74. /*
  75. * if the IO is in WRITE direction, then multiple bios are used,
  76. * one for each copy.
  77. * When resyncing we also use one for each copy.
  78. * When reconstructing, we use 2 bios, one for read, one for write.
  79. * We choose the number when they are allocated.
  80. */
  81. struct {
  82. struct bio *bio;
  83. sector_t addr;
  84. int devnum;
  85. } devs[0];
  86. };
  87. /* when we get a read error on a read-only array, we redirect to another
  88. * device without failing the first device, or trying to over-write to
  89. * correct the read error. To keep track of bad blocks on a per-bio
  90. * level, we store IO_BLOCKED in the appropriate 'bios' pointer
  91. */
  92. #define IO_BLOCKED ((struct bio*)1)
  93. /* bits for r10bio.state */
  94. #define R10BIO_Uptodate 0
  95. #define R10BIO_IsSync 1
  96. #define R10BIO_IsRecover 2
  97. #define R10BIO_Degraded 3
  98. #endif