raid10.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. };
  8. typedef struct r10bio_s r10bio_t;
  9. struct r10_private_data_s {
  10. mddev_t *mddev;
  11. mirror_info_t *mirrors;
  12. int raid_disks;
  13. spinlock_t device_lock;
  14. /* geometry */
  15. int near_copies; /* number of copies layed out raid0 style */
  16. int far_copies; /* number of copies layed out
  17. * at large strides across drives
  18. */
  19. int far_offset; /* far_copies are offset by 1 stripe
  20. * instead of many
  21. */
  22. int copies; /* near_copies * far_copies.
  23. * must be <= raid_disks
  24. */
  25. sector_t stride; /* distance between far copies.
  26. * This is size / far_copies unless
  27. * far_offset, in which case it is
  28. * 1 stripe.
  29. */
  30. sector_t dev_sectors; /* temp copy of mddev->dev_sectors */
  31. int chunk_shift; /* shift from chunks to sectors */
  32. sector_t chunk_mask;
  33. int scale_disks; /* When starting array, multiply
  34. * each ->raid_disk by this.
  35. * Need for raid0->raid10 migration
  36. */
  37. struct list_head retry_list;
  38. /* queue pending writes and submit them on unplug */
  39. struct bio_list pending_bio_list;
  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 mdk_thread_s *thread;
  58. };
  59. typedef struct r10_private_data_s conf_t;
  60. /*
  61. * this is our 'private' RAID10 bio.
  62. *
  63. * it contains information about what kind of IO operations were started
  64. * for this RAID10 operation, and about their status:
  65. */
  66. struct r10bio_s {
  67. atomic_t remaining; /* 'have we finished' count,
  68. * used from IRQ handlers
  69. */
  70. sector_t sector; /* virtual sector number */
  71. int sectors;
  72. unsigned long state;
  73. mddev_t *mddev;
  74. /*
  75. * original bio going to /dev/mdx
  76. */
  77. struct bio *master_bio;
  78. /*
  79. * if the IO is in READ direction, then this is where we read
  80. */
  81. int read_slot;
  82. struct list_head retry_list;
  83. /*
  84. * if the IO is in WRITE direction, then multiple bios are used,
  85. * one for each copy.
  86. * When resyncing we also use one for each copy.
  87. * When reconstructing, we use 2 bios, one for read, one for write.
  88. * We choose the number when they are allocated.
  89. */
  90. struct {
  91. struct bio *bio;
  92. sector_t addr;
  93. int devnum;
  94. } devs[0];
  95. };
  96. /* when we get a read error on a read-only array, we redirect to another
  97. * device without failing the first device, or trying to over-write to
  98. * correct the read error. To keep track of bad blocks on a per-bio
  99. * level, we store IO_BLOCKED in the appropriate 'bios' pointer
  100. */
  101. #define IO_BLOCKED ((struct bio*)1)
  102. /* bits for r10bio.state */
  103. #define R10BIO_Uptodate 0
  104. #define R10BIO_IsSync 1
  105. #define R10BIO_IsRecover 2
  106. #define R10BIO_Degraded 3
  107. #endif