File: /usr/include/linux/raid/raid1.h
1 #ifndef _RAID1_H
2 #define _RAID1_H
3
4 #include <linux/raid/md.h>
5
6 struct mirror_info {
7 int number;
8 int raid_disk;
9 kdev_t dev;
10 int sect_limit;
11 int head_position;
12
13 /*
14 * State bits:
15 */
16 int operational;
17 int write_only;
18 int spare;
19
20 int used_slot;
21 };
22
23 struct raid1_private_data {
24 mddev_t *mddev;
25 struct mirror_info mirrors[MD_SB_DISKS];
26 int nr_disks;
27 int raid_disks;
28 int working_disks;
29 int last_used;
30 unsigned long next_sect;
31 int sect_count;
32 mdk_thread_t *thread, *resync_thread;
33 int resync_mirrors;
34 struct mirror_info *spare;
35 md_spinlock_t device_lock;
36
37 /* buffer pool */
38 /* buffer_heads that we have pre-allocated have b_pprev -> &freebh
39 * and are linked into a stack using b_next
40 * raid1_bh that are pre-allocated have R1BH_PreAlloc set.
41 * All these variable are protected by device_lock
42 */
43 struct buffer_head *freebh;
44 int freebh_cnt; /* how many are on the list */
45 struct raid1_bh *freer1;
46 struct raid1_bh *freebuf; /* each bh_req has a page allocated */
47 md_wait_queue_head_t wait_buffer;
48
49 /* for use when syncing mirrors: */
50 unsigned long start_active, start_ready,
51 start_pending, start_future;
52 int cnt_done, cnt_active, cnt_ready,
53 cnt_pending, cnt_future;
54 int phase;
55 int window;
56 md_wait_queue_head_t wait_done;
57 md_wait_queue_head_t wait_ready;
58 md_spinlock_t segment_lock;
59 };
60
61 typedef struct raid1_private_data raid1_conf_t;
62
63 /*
64 * this is the only point in the RAID code where we violate
65 * C type safety. mddev->private is an 'opaque' pointer.
66 */
67 #define mddev_to_conf(mddev) ((raid1_conf_t *) mddev->private)
68
69 /*
70 * this is our 'private' 'collective' RAID1 buffer head.
71 * it contains information about what kind of IO operations were started
72 * for this RAID1 operation, and about their status:
73 */
74
75 struct raid1_bh {
76 atomic_t remaining; /* 'have we finished' count,
77 * used from IRQ handlers
78 */
79 int cmd;
80 unsigned long state;
81 mddev_t *mddev;
82 struct buffer_head *master_bh;
83 struct buffer_head *mirror_bh_list;
84 struct buffer_head bh_req;
85 struct raid1_bh *next_r1; /* next for retry or in free list */
86 };
87 /* bits for raid1_bh.state */
88 #define R1BH_Uptodate 1
89 #define R1BH_SyncPhase 2
90 #define R1BH_PreAlloc 3 /* this was pre-allocated, add to free list */
91 #endif
92