raid1.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #ifndef _RAID1_H
  2. #define _RAID1_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. /*
  10. * memory pools need a pointer to the mddev, so they can force an unplug
  11. * when memory is tight, and a count of the number of drives that the
  12. * pool was allocated for, so they know how much to allocate and free.
  13. * mddev->raid_disks cannot be used, as it can change while a pool is active
  14. * These two datums are stored in a kmalloced struct.
  15. */
  16. struct pool_info {
  17. mddev_t *mddev;
  18. int raid_disks;
  19. };
  20. typedef struct r1bio_s r1bio_t;
  21. struct r1_private_data_s {
  22. mddev_t *mddev;
  23. mirror_info_t *mirrors;
  24. int raid_disks;
  25. int working_disks;
  26. int last_used;
  27. sector_t next_seq_sect;
  28. spinlock_t device_lock;
  29. struct list_head retry_list;
  30. /* queue pending writes and submit them on unplug */
  31. struct bio_list pending_bio_list;
  32. /* queue of writes that have been unplugged */
  33. struct bio_list flushing_bio_list;
  34. /* for use when syncing mirrors: */
  35. spinlock_t resync_lock;
  36. int nr_pending;
  37. int nr_waiting;
  38. int nr_queued;
  39. int barrier;
  40. sector_t next_resync;
  41. int fullsync; /* set to 1 if a full sync is needed,
  42. * (fresh device added).
  43. * Cleared when a sync completes.
  44. */
  45. wait_queue_head_t wait_barrier;
  46. struct pool_info *poolinfo;
  47. struct page *tmppage;
  48. mempool_t *r1bio_pool;
  49. mempool_t *r1buf_pool;
  50. };
  51. typedef struct r1_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' RAID1 bio.
  59. *
  60. * it contains information about what kind of IO operations were started
  61. * for this RAID1 operation, and about their status:
  62. */
  63. struct r1bio_s {
  64. atomic_t remaining; /* 'have we finished' count,
  65. * used from IRQ handlers
  66. */
  67. atomic_t behind_remaining; /* number of write-behind ios remaining
  68. * in this BehindIO request
  69. */
  70. sector_t sector;
  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_disk;
  82. struct list_head retry_list;
  83. struct bitmap_update *bitmap_update;
  84. /*
  85. * if the IO is in WRITE direction, then multiple bios are used.
  86. * We choose the number when they are allocated.
  87. */
  88. struct bio *bios[0];
  89. /* DO NOT PUT ANY NEW FIELDS HERE - bios array is contiguously alloced*/
  90. };
  91. /* when we get a read error on a read-only array, we redirect to another
  92. * device without failing the first device, or trying to over-write to
  93. * correct the read error. To keep track of bad blocks on a per-bio
  94. * level, we store IO_BLOCKED in the appropriate 'bios' pointer
  95. */
  96. #define IO_BLOCKED ((struct bio*)1)
  97. /* bits for r1bio.state */
  98. #define R1BIO_Uptodate 0
  99. #define R1BIO_IsSync 1
  100. #define R1BIO_Degraded 2
  101. #define R1BIO_BehindIO 3
  102. #define R1BIO_Barrier 4
  103. #define R1BIO_BarrierRetry 5
  104. /* For write-behind requests, we call bi_end_io when
  105. * the last non-write-behind device completes, providing
  106. * any write was successful. Otherwise we call when
  107. * any write-behind write succeeds, otherwise we call
  108. * with failure when last write completes (and all failed).
  109. * Record that bi_end_io was called with this flag...
  110. */
  111. #define R1BIO_Returned 6
  112. #endif