raid10.h 4.3 KB

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