raid10.h 3.7 KB

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