raid10.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #ifndef _RAID10_H
  2. #define _RAID10_H
  3. #include <linux/raid/md.h>
  4. typedef struct mirror_info mirror_info_t;
  5. struct mirror_info {
  6. mdk_rdev_t *rdev;
  7. sector_t head_position;
  8. };
  9. typedef struct r10bio_s r10bio_t;
  10. struct r10_private_data_s {
  11. mddev_t *mddev;
  12. mirror_info_t *mirrors;
  13. int raid_disks;
  14. spinlock_t device_lock;
  15. /* geometry */
  16. int near_copies; /* number of copies layed out raid0 style */
  17. int far_copies; /* number of copies layed out
  18. * at large strides across drives
  19. */
  20. int far_offset; /* far_copies are offset by 1 stripe
  21. * instead of many
  22. */
  23. int copies; /* near_copies * far_copies.
  24. * must be <= raid_disks
  25. */
  26. sector_t stride; /* distance between far copies.
  27. * This is size / far_copies unless
  28. * far_offset, in which case it is
  29. * 1 stripe.
  30. */
  31. int chunk_shift; /* shift from chunks to sectors */
  32. sector_t chunk_mask;
  33. struct list_head retry_list;
  34. /* queue pending writes and submit them on unplug */
  35. struct bio_list pending_bio_list;
  36. spinlock_t resync_lock;
  37. int nr_pending;
  38. int nr_waiting;
  39. int nr_queued;
  40. int barrier;
  41. sector_t next_resync;
  42. int fullsync; /* set to 1 if a full sync is needed,
  43. * (fresh device added).
  44. * Cleared when a sync completes.
  45. */
  46. wait_queue_head_t wait_barrier;
  47. mempool_t *r10bio_pool;
  48. mempool_t *r10buf_pool;
  49. struct page *tmppage;
  50. };
  51. typedef struct r10_private_data_s conf_t;
  52. /*
  53. * this is the only point in the RAID code where we violate
  54. * C type safety. mddev->private is an 'opaque' pointer.
  55. */
  56. #define mddev_to_conf(mddev) ((conf_t *) mddev->private)
  57. /*
  58. * this is our 'private' RAID10 bio.
  59. *
  60. * it contains information about what kind of IO operations were started
  61. * for this RAID10 operation, and about their status:
  62. */
  63. struct r10bio_s {
  64. atomic_t remaining; /* 'have we finished' count,
  65. * used from IRQ handlers
  66. */
  67. sector_t sector; /* virtual sector number */
  68. int sectors;
  69. unsigned long state;
  70. mddev_t *mddev;
  71. /*
  72. * original bio going to /dev/mdx
  73. */
  74. struct bio *master_bio;
  75. /*
  76. * if the IO is in READ direction, then this is where we read
  77. */
  78. int read_slot;
  79. struct list_head retry_list;
  80. /*
  81. * if the IO is in WRITE direction, then multiple bios are used,
  82. * one for each copy.
  83. * When resyncing we also use one for each copy.
  84. * When reconstructing, we use 2 bios, one for read, one for write.
  85. * We choose the number when they are allocated.
  86. */
  87. struct {
  88. struct bio *bio;
  89. sector_t addr;
  90. int devnum;
  91. } devs[0];
  92. };
  93. /* when we get a read error on a read-only array, we redirect to another
  94. * device without failing the first device, or trying to over-write to
  95. * correct the read error. To keep track of bad blocks on a per-bio
  96. * level, we store IO_BLOCKED in the appropriate 'bios' pointer
  97. */
  98. #define IO_BLOCKED ((struct bio*)1)
  99. /* bits for r10bio.state */
  100. #define R10BIO_Uptodate 0
  101. #define R10BIO_IsSync 1
  102. #define R10BIO_IsRecover 2
  103. #define R10BIO_Degraded 3
  104. #endif