raid10.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. #ifndef _RAID10_H
  2. #define _RAID10_H
  3. struct mirror_info {
  4. struct md_rdev *rdev, *replacement;
  5. sector_t head_position;
  6. int recovery_disabled; /* matches
  7. * mddev->recovery_disabled
  8. * when we shouldn't try
  9. * recovering this device.
  10. */
  11. };
  12. struct r10conf {
  13. struct mddev *mddev;
  14. struct mirror_info *mirrors;
  15. spinlock_t device_lock;
  16. /* geometry */
  17. struct geom {
  18. int raid_disks;
  19. int near_copies; /* number of copies laid out
  20. * raid0 style */
  21. int far_copies; /* number of copies laid out
  22. * at large strides across drives
  23. */
  24. int far_offset; /* far_copies are offset by 1
  25. * stripe instead of many
  26. */
  27. sector_t stride; /* distance between far copies.
  28. * This is size / far_copies unless
  29. * far_offset, in which case it is
  30. * 1 stripe.
  31. */
  32. int chunk_shift; /* shift from chunks to sectors */
  33. sector_t chunk_mask;
  34. } prev, geo;
  35. int copies; /* near_copies * far_copies.
  36. * must be <= raid_disks
  37. */
  38. sector_t dev_sectors; /* temp copy of
  39. * mddev->dev_sectors */
  40. sector_t reshape_progress;
  41. struct list_head retry_list;
  42. /* queue pending writes and submit them on unplug */
  43. struct bio_list pending_bio_list;
  44. int pending_count;
  45. spinlock_t resync_lock;
  46. int nr_pending;
  47. int nr_waiting;
  48. int nr_queued;
  49. int barrier;
  50. sector_t next_resync;
  51. int fullsync; /* set to 1 if a full sync is needed,
  52. * (fresh device added).
  53. * Cleared when a sync completes.
  54. */
  55. int have_replacement; /* There is at least one
  56. * replacement device.
  57. */
  58. wait_queue_head_t wait_barrier;
  59. mempool_t *r10bio_pool;
  60. mempool_t *r10buf_pool;
  61. struct page *tmppage;
  62. /* When taking over an array from a different personality, we store
  63. * the new thread here until we fully activate the array.
  64. */
  65. struct md_thread *thread;
  66. };
  67. /*
  68. * this is our 'private' RAID10 bio.
  69. *
  70. * it contains information about what kind of IO operations were started
  71. * for this RAID10 operation, and about their status:
  72. */
  73. struct r10bio {
  74. atomic_t remaining; /* 'have we finished' count,
  75. * used from IRQ handlers
  76. */
  77. sector_t sector; /* virtual sector number */
  78. int sectors;
  79. unsigned long state;
  80. struct mddev *mddev;
  81. /*
  82. * original bio going to /dev/mdx
  83. */
  84. struct bio *master_bio;
  85. /*
  86. * if the IO is in READ direction, then this is where we read
  87. */
  88. int read_slot;
  89. struct list_head retry_list;
  90. /*
  91. * if the IO is in WRITE direction, then multiple bios are used,
  92. * one for each copy.
  93. * When resyncing we also use one for each copy.
  94. * When reconstructing, we use 2 bios, one for read, one for write.
  95. * We choose the number when they are allocated.
  96. * We sometimes need an extra bio to write to the replacement.
  97. */
  98. struct {
  99. struct bio *bio;
  100. union {
  101. struct bio *repl_bio; /* used for resync and
  102. * writes */
  103. struct md_rdev *rdev; /* used for reads
  104. * (read_slot >= 0) */
  105. };
  106. sector_t addr;
  107. int devnum;
  108. } devs[0];
  109. };
  110. /* when we get a read error on a read-only array, we redirect to another
  111. * device without failing the first device, or trying to over-write to
  112. * correct the read error. To keep track of bad blocks on a per-bio
  113. * level, we store IO_BLOCKED in the appropriate 'bios' pointer
  114. */
  115. #define IO_BLOCKED ((struct bio*)1)
  116. /* When we successfully write to a known bad-block, we need to remove the
  117. * bad-block marking which must be done from process context. So we record
  118. * the success by setting devs[n].bio to IO_MADE_GOOD
  119. */
  120. #define IO_MADE_GOOD ((struct bio *)2)
  121. #define BIO_SPECIAL(bio) ((unsigned long)bio <= 2)
  122. /* bits for r10bio.state */
  123. enum r10bio_state {
  124. R10BIO_Uptodate,
  125. R10BIO_IsSync,
  126. R10BIO_IsRecover,
  127. R10BIO_Degraded,
  128. /* Set ReadError on bios that experience a read error
  129. * so that raid10d knows what to do with them.
  130. */
  131. R10BIO_ReadError,
  132. /* If a write for this request means we can clear some
  133. * known-bad-block records, we set this flag.
  134. */
  135. R10BIO_MadeGood,
  136. R10BIO_WriteError,
  137. /* During a reshape we might be performing IO on the
  138. * 'previous' part of the array, in which case this
  139. * flag is set
  140. */
  141. R10BIO_Previous,
  142. };
  143. #endif