raid10.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. atomic_t nr_pending;
  61. int nr_waiting;
  62. int nr_queued;
  63. int barrier;
  64. int array_freeze_pending;
  65. sector_t next_resync;
  66. int fullsync; /* set to 1 if a full sync is needed,
  67. * (fresh device added).
  68. * Cleared when a sync completes.
  69. */
  70. int have_replacement; /* There is at least one
  71. * replacement device.
  72. */
  73. wait_queue_head_t wait_barrier;
  74. mempool_t *r10bio_pool;
  75. mempool_t *r10buf_pool;
  76. struct page *tmppage;
  77. /* When taking over an array from a different personality, we store
  78. * the new thread here until we fully activate the array.
  79. */
  80. struct md_thread *thread;
  81. };
  82. /*
  83. * this is our 'private' RAID10 bio.
  84. *
  85. * it contains information about what kind of IO operations were started
  86. * for this RAID10 operation, and about their status:
  87. */
  88. struct r10bio {
  89. atomic_t remaining; /* 'have we finished' count,
  90. * used from IRQ handlers
  91. */
  92. sector_t sector; /* virtual sector number */
  93. int sectors;
  94. unsigned long state;
  95. struct mddev *mddev;
  96. /*
  97. * original bio going to /dev/mdx
  98. */
  99. struct bio *master_bio;
  100. /*
  101. * if the IO is in READ direction, then this is where we read
  102. */
  103. int read_slot;
  104. struct list_head retry_list;
  105. /*
  106. * if the IO is in WRITE direction, then multiple bios are used,
  107. * one for each copy.
  108. * When resyncing we also use one for each copy.
  109. * When reconstructing, we use 2 bios, one for read, one for write.
  110. * We choose the number when they are allocated.
  111. * We sometimes need an extra bio to write to the replacement.
  112. */
  113. struct r10dev {
  114. struct bio *bio;
  115. union {
  116. struct bio *repl_bio; /* used for resync and
  117. * writes */
  118. struct md_rdev *rdev; /* used for reads
  119. * (read_slot >= 0) */
  120. };
  121. sector_t addr;
  122. int devnum;
  123. } devs[0];
  124. };
  125. /* bits for r10bio.state */
  126. enum r10bio_state {
  127. R10BIO_Uptodate,
  128. R10BIO_IsSync,
  129. R10BIO_IsRecover,
  130. R10BIO_IsReshape,
  131. R10BIO_Degraded,
  132. /* Set ReadError on bios that experience a read error
  133. * so that raid10d knows what to do with them.
  134. */
  135. R10BIO_ReadError,
  136. /* If a write for this request means we can clear some
  137. * known-bad-block records, we set this flag.
  138. */
  139. R10BIO_MadeGood,
  140. R10BIO_WriteError,
  141. /* During a reshape we might be performing IO on the
  142. * 'previous' part of the array, in which case this
  143. * flag is set
  144. */
  145. R10BIO_Previous,
  146. };
  147. #endif