raid10.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. #ifndef _RAID10_H
  2. #define _RAID10_H
  3. struct raid10_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 raid10_info *mirrors;
  15. struct raid10_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 far_set_size; /* The number of devices in a set,
  34. * where a 'set' are devices that
  35. * contain far/offset copies of
  36. * each other.
  37. */
  38. int chunk_shift; /* shift from chunks to sectors */
  39. sector_t chunk_mask;
  40. } prev, geo;
  41. int copies; /* near_copies * far_copies.
  42. * must be <= raid_disks
  43. */
  44. sector_t dev_sectors; /* temp copy of
  45. * mddev->dev_sectors */
  46. sector_t reshape_progress;
  47. sector_t reshape_safe;
  48. unsigned long reshape_checkpoint;
  49. sector_t offset_diff;
  50. struct list_head retry_list;
  51. /* A separate list of r1bio which just need raid_end_bio_io called.
  52. * This mustn't happen for writes which had any errors if the superblock
  53. * needs to be written.
  54. */
  55. struct list_head bio_end_io_list;
  56. /* queue pending writes and submit them on unplug */
  57. struct bio_list pending_bio_list;
  58. int pending_count;
  59. spinlock_t resync_lock;
  60. int nr_pending;
  61. int nr_waiting;
  62. int nr_queued;
  63. int barrier;
  64. sector_t next_resync;
  65. int fullsync; /* set to 1 if a full sync is needed,
  66. * (fresh device added).
  67. * Cleared when a sync completes.
  68. */
  69. int have_replacement; /* There is at least one
  70. * replacement device.
  71. */
  72. wait_queue_head_t wait_barrier;
  73. mempool_t *r10bio_pool;
  74. mempool_t *r10buf_pool;
  75. struct page *tmppage;
  76. /* When taking over an array from a different personality, we store
  77. * the new thread here until we fully activate the array.
  78. */
  79. struct md_thread *thread;
  80. };
  81. /*
  82. * this is our 'private' RAID10 bio.
  83. *
  84. * it contains information about what kind of IO operations were started
  85. * for this RAID10 operation, and about their status:
  86. */
  87. struct r10bio {
  88. atomic_t remaining; /* 'have we finished' count,
  89. * used from IRQ handlers
  90. */
  91. sector_t sector; /* virtual sector number */
  92. int sectors;
  93. unsigned long state;
  94. struct mddev *mddev;
  95. /*
  96. * original bio going to /dev/mdx
  97. */
  98. struct bio *master_bio;
  99. /*
  100. * if the IO is in READ direction, then this is where we read
  101. */
  102. int read_slot;
  103. struct list_head retry_list;
  104. /*
  105. * if the IO is in WRITE direction, then multiple bios are used,
  106. * one for each copy.
  107. * When resyncing we also use one for each copy.
  108. * When reconstructing, we use 2 bios, one for read, one for write.
  109. * We choose the number when they are allocated.
  110. * We sometimes need an extra bio to write to the replacement.
  111. */
  112. struct r10dev {
  113. struct bio *bio;
  114. union {
  115. struct bio *repl_bio; /* used for resync and
  116. * writes */
  117. struct md_rdev *rdev; /* used for reads
  118. * (read_slot >= 0) */
  119. };
  120. sector_t addr;
  121. int devnum;
  122. } devs[0];
  123. };
  124. /* bits for r10bio.state */
  125. enum r10bio_state {
  126. R10BIO_Uptodate,
  127. R10BIO_IsSync,
  128. R10BIO_IsRecover,
  129. R10BIO_IsReshape,
  130. R10BIO_Degraded,
  131. /* Set ReadError on bios that experience a read error
  132. * so that raid10d knows what to do with them.
  133. */
  134. R10BIO_ReadError,
  135. /* If a write for this request means we can clear some
  136. * known-bad-block records, we set this flag.
  137. */
  138. R10BIO_MadeGood,
  139. R10BIO_WriteError,
  140. /* During a reshape we might be performing IO on the
  141. * 'previous' part of the array, in which case this
  142. * flag is set
  143. */
  144. R10BIO_Previous,
  145. };
  146. #endif