raid1.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. /* for use when syncing mirrors: */
  31. spinlock_t resync_lock;
  32. int nr_pending;
  33. int barrier;
  34. sector_t next_resync;
  35. wait_queue_head_t wait_idle;
  36. wait_queue_head_t wait_resume;
  37. struct pool_info *poolinfo;
  38. mempool_t *r1bio_pool;
  39. mempool_t *r1buf_pool;
  40. };
  41. typedef struct r1_private_data_s conf_t;
  42. /*
  43. * this is the only point in the RAID code where we violate
  44. * C type safety. mddev->private is an 'opaque' pointer.
  45. */
  46. #define mddev_to_conf(mddev) ((conf_t *) mddev->private)
  47. /*
  48. * this is our 'private' RAID1 bio.
  49. *
  50. * it contains information about what kind of IO operations were started
  51. * for this RAID1 operation, and about their status:
  52. */
  53. struct r1bio_s {
  54. atomic_t remaining; /* 'have we finished' count,
  55. * used from IRQ handlers
  56. */
  57. sector_t sector;
  58. int sectors;
  59. unsigned long state;
  60. mddev_t *mddev;
  61. /*
  62. * original bio going to /dev/mdx
  63. */
  64. struct bio *master_bio;
  65. /*
  66. * if the IO is in READ direction, then this is where we read
  67. */
  68. int read_disk;
  69. struct list_head retry_list;
  70. /*
  71. * if the IO is in WRITE direction, then multiple bios are used.
  72. * We choose the number when they are allocated.
  73. */
  74. struct bio *bios[0];
  75. };
  76. /* bits for r1bio.state */
  77. #define R1BIO_Uptodate 0
  78. #define R1BIO_IsSync 1
  79. #endif