raid10.h 4.2 KB

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