1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 #ifndef _MD_H
19 #define _MD_H
20
21 #include <linux/major.h>
22 #include <linux/mm.h>
23 #include <linux/ioctl.h>
24
25 #define MD_VERSION "0.34"
26
27
28 #define REGISTER_DEV _IO (MD_MAJOR, 1)
29 #define START_MD _IO (MD_MAJOR, 2)
30 #define STOP_MD _IO (MD_MAJOR, 3)
31 #define MD_INVALID _IO (MD_MAJOR, 4)
32 #define MD_VALID _IO (MD_MAJOR, 5)
33
34
35
36
37
38
39
40
41
42
43
44 #define FAULT_SHIFT 8
45 #define PERSONALITY_SHIFT 16
46
47 #define FACTOR_MASK 0xFFUL
48 #define FAULT_MASK 0xFF00UL
49 #define PERSONALITY_MASK 0xFF0000UL
50
51 #define MD_RESERVED 0
52 #define LINEAR (1UL << PERSONALITY_SHIFT)
53 #define STRIPED (2UL << PERSONALITY_SHIFT)
54 #define STRIPPED STRIPED
55 #define RAID0 STRIPED
56 #define RAID1 (3UL << PERSONALITY_SHIFT)
57 #define RAID5 (4UL << PERSONALITY_SHIFT)
58 #define MAX_PERSONALITY 5
59
60 #ifdef __KERNEL__
61
62 #include <linux/config.h>
63 #include <sys/types.h>
64 #include <linux/fs.h>
65 #include <linux/blkdev.h>
66
67 #undef MD_COUNT_SIZE
68
69 #define MAX_REAL 8
70 #define MAX_MD_DEV 4
71
72 #define FACTOR(a) ((a)->repartition & FACTOR_MASK)
73 #define MAX_FAULT(a) (((a)->repartition & FAULT_MASK)>>8)
74 #define PERSONALITY(a) ((a)->repartition & PERSONALITY_MASK)
75
76 #define FACTOR_SHIFT(a) (PAGE_SHIFT + (a) - 10)
77
78
79 #define VALID 0
80 #define INVALID_NEXT 1
81 #define INVALID_ALWAYS 2
82 #define INVALID 3
83
84
85 #define REDIRECTED_BHREQ 0
86
87 #define REDIRECTED_REQ 1
88 #define REDIRECT_FAILED -1
89
90 struct real_dev
91 {
92 kdev_t dev;
93 int size;
94 int offset;
95
96 struct inode *inode;
97 int fault_count;
98 int invalid;
99
100
101
102
103 };
104
105 struct md_dev;
106
107 struct md_personality
108 {
109 char *name;
110 int (*map)(int minor, struct md_dev *md_dev, struct request *req);
111 int (*run)(int minor, struct md_dev *md_dev);
112 int (*stop)(int minor, struct md_dev *md_dev);
113 int (*status)(char *page, int minor, struct md_dev *md_dev);
114 int (*ioctl)(struct inode *inode, struct file *file,
115 unsigned int cmd, unsigned long arg);
116 int max_invalid_dev;
117 };
118
119 struct md_dev
120 {
121 struct md_personality *pers;
122 int repartition;
123 int invalid_dev_count;
124 int busy;
125 int nb_dev;
126 void *private;
127 #ifdef MD_COUNT_SIZE
128 unsigned int smallest_count;
129 unsigned int biggest_count;
130 unsigned int equal_count;
131 #endif
132 };
133
134 extern struct real_dev devices[MAX_MD_DEV][MAX_REAL];
135 extern struct md_dev md_dev[MAX_MD_DEV];
136 extern int md_size[MAX_MD_DEV];
137
138 extern void make_md_request(struct request *pending, int n);
139 extern char *partition_name (kdev_t dev);
140
141 #if defined(CONFIG_MD_SUPPORT_RAID1) || defined(CONFIG_MD_SUPPORT_RAID5)
142 extern int md_valid_device (int minor, kdev_t dev, int mode);
143 extern int md_can_reemit (int minor);
144 #endif
145
146 extern int register_md_personality (int p_num, struct md_personality *p);
147 extern int unregister_md_personality (int p_num);
148
149 #endif __KERNEL__
150 #endif _MD_H