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