raid10.h 3.8 KB

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