raid10.h 4.0 KB

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