raid10.h 4.3 KB

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