raid10.h 4.0 KB

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