ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / linux / raid / raid1.h
1 #ifndef _RAID1_H
2 #define _RAID1_H
3
4 #include <linux/raid/md.h>
5
6 typedef struct mirror_info mirror_info_t;
7
8 struct mirror_info {
9         mdk_rdev_t      *rdev;
10         sector_t        head_position;
11 };
12
13 typedef struct r1bio_s r1bio_t;
14
15 struct r1_private_data_s {
16         mddev_t                 *mddev;
17         mirror_info_t           *mirrors;
18         int                     raid_disks;
19         int                     working_disks;
20         int                     last_used;
21         sector_t                next_seq_sect;
22         spinlock_t              device_lock;
23
24         /* for use when syncing mirrors: */
25
26         spinlock_t              resync_lock;
27         int nr_pending;
28         int barrier;
29         sector_t                next_resync;
30
31         wait_queue_head_t       wait_idle;
32         wait_queue_head_t       wait_resume;
33
34         mempool_t *r1bio_pool;
35         mempool_t *r1buf_pool;
36 };
37
38 typedef struct r1_private_data_s conf_t;
39
40 /*
41  * this is the only point in the RAID code where we violate
42  * C type safety. mddev->private is an 'opaque' pointer.
43  */
44 #define mddev_to_conf(mddev) ((conf_t *) mddev->private)
45
46 /*
47  * this is our 'private' RAID1 bio.
48  *
49  * it contains information about what kind of IO operations were started
50  * for this RAID1 operation, and about their status:
51  */
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
70         struct list_head        retry_list;
71         /*
72          * if the IO is in WRITE direction, then multiple bios are used.
73          * We choose the number when they are allocated.
74          */
75         struct bio              *bios[0];
76 };
77
78 /* bits for r1bio.state */
79 #define R1BIO_Uptodate  0
80 #define R1BIO_IsSync    1
81 #endif