This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / include / linux / raid / raid10.h
1 #ifndef _RAID10_H
2 #define _RAID10_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 r10bio_s r10bio_t;
14
15 struct r10_private_data_s {
16         mddev_t                 *mddev;
17         mirror_info_t           *mirrors;
18         int                     raid_disks;
19         int                     working_disks;
20         spinlock_t              device_lock;
21
22         /* geometry */
23         int                     near_copies;  /* number of copies layed out raid0 style */
24         int                     far_copies;   /* number of copies layed out
25                                                * at large strides across drives
26                                                */
27         int                     copies;       /* near_copies * far_copies.
28                                                * must be <= raid_disks
29                                                */
30         sector_t                stride;       /* distance between far copies.
31                                                * This is size / far_copies
32                                                */
33
34         int chunk_shift; /* shift from chunks to sectors */
35         sector_t chunk_mask;
36
37         struct list_head        retry_list;
38         /* for use when syncing mirrors: */
39
40         spinlock_t              resync_lock;
41         int nr_pending;
42         int barrier;
43         sector_t                next_resync;
44
45         wait_queue_head_t       wait_idle;
46         wait_queue_head_t       wait_resume;
47
48         mempool_t *r10bio_pool;
49         mempool_t *r10buf_pool;
50 };
51
52 typedef struct r10_private_data_s conf_t;
53
54 /*
55  * this is the only point in the RAID code where we violate
56  * C type safety. mddev->private is an 'opaque' pointer.
57  */
58 #define mddev_to_conf(mddev) ((conf_t *) mddev->private)
59
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
67 struct r10bio_s {
68         atomic_t                remaining; /* 'have we finished' count,
69                                             * used from IRQ handlers
70                                             */
71         sector_t                sector; /* virtual sector number */
72         int                     sectors;
73         unsigned long           state;
74         mddev_t                 *mddev;
75         /*
76          * original bio going to /dev/mdx
77          */
78         struct bio              *master_bio;
79         /*
80          * if the IO is in READ direction, then this is where we read
81          */
82         int                     read_slot;
83
84         struct list_head        retry_list;
85         /*
86          * if the IO is in WRITE direction, then multiple bios are used,
87          * one for each copy.
88          * When resyncing we also use one for each copy.
89          * When reconstructing, we use 2 bios, one for read, one for write.
90          * We choose the number when they are allocated.
91          */
92         struct {
93                 struct bio              *bio;
94                 sector_t addr;
95                 int devnum;
96         } devs[0];
97 };
98
99 /* bits for r10bio.state */
100 #define R10BIO_Uptodate 0
101 #define R10BIO_IsSync   1
102 #define R10BIO_IsRecover 2
103 #endif