diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-03 12:08:19 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-03 12:08:19 -0400 |
commit | 223cdea4c4b5af5181b2da00ac85711d1e0c737c (patch) | |
tree | dfe7226c70ddabbf2e2e63924ba636345278e79c /include | |
parent | 31e6e2dac575c9d21a6ec56ca52ae89086baa705 (diff) | |
parent | c8f517c444e4f9f55b5b5ca202b8404691a35805 (diff) |
Merge branch 'for-linus' of git://neil.brown.name/md
* 'for-linus' of git://neil.brown.name/md: (53 commits)
md/raid5 revise rules for when to update metadata during reshape
md/raid5: minor code cleanups in make_request.
md: remove CONFIG_MD_RAID_RESHAPE config option.
md/raid5: be more careful about write ordering when reshaping.
md: don't display meaningless values in sysfs files resync_start and sync_speed
md/raid5: allow layout and chunksize to be changed on active array.
md/raid5: reshape using largest of old and new chunk size
md/raid5: prepare for allowing reshape to change layout
md/raid5: prepare for allowing reshape to change chunksize.
md/raid5: clearly differentiate 'before' and 'after' stripes during reshape.
Documentation/md.txt update
md: allow number of drives in raid5 to be reduced
md/raid5: change reshape-progress measurement to cope with reshaping backwards.
md: add explicit method to signal the end of a reshape.
md/raid5: enhance raid5_size to work correctly with negative delta_disks
md/raid5: drop qd_idx from r6_state
md/raid6: move raid6 data processing to raid6_pq.ko
md: raid5 run(): Fix max_degraded for raid level 4.
md: 'array_size' sysfs attribute
md: centralize ->array_sectors modifications
...
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/raid/bitmap.h | 288 | ||||
-rw-r--r-- | include/linux/raid/linear.h | 31 | ||||
-rw-r--r-- | include/linux/raid/md.h | 81 | ||||
-rw-r--r-- | include/linux/raid/md_k.h | 402 | ||||
-rw-r--r-- | include/linux/raid/md_u.h | 35 | ||||
-rw-r--r-- | include/linux/raid/multipath.h | 42 | ||||
-rw-r--r-- | include/linux/raid/pq.h | 132 | ||||
-rw-r--r-- | include/linux/raid/raid0.h | 30 | ||||
-rw-r--r-- | include/linux/raid/raid1.h | 134 | ||||
-rw-r--r-- | include/linux/raid/raid10.h | 123 | ||||
-rw-r--r-- | include/linux/raid/raid5.h | 402 | ||||
-rw-r--r-- | include/linux/raid/xor.h | 2 |
12 files changed, 167 insertions, 1535 deletions
diff --git a/include/linux/raid/bitmap.h b/include/linux/raid/bitmap.h deleted file mode 100644 index e98900671ca9..000000000000 --- a/include/linux/raid/bitmap.h +++ /dev/null | |||
@@ -1,288 +0,0 @@ | |||
1 | /* | ||
2 | * bitmap.h: Copyright (C) Peter T. Breuer (ptb@ot.uc3m.es) 2003 | ||
3 | * | ||
4 | * additions: Copyright (C) 2003-2004, Paul Clements, SteelEye Technology, Inc. | ||
5 | */ | ||
6 | #ifndef BITMAP_H | ||
7 | #define BITMAP_H 1 | ||
8 | |||
9 | #define BITMAP_MAJOR_LO 3 | ||
10 | /* version 4 insists the bitmap is in little-endian order | ||
11 | * with version 3, it is host-endian which is non-portable | ||
12 | */ | ||
13 | #define BITMAP_MAJOR_HI 4 | ||
14 | #define BITMAP_MAJOR_HOSTENDIAN 3 | ||
15 | |||
16 | #define BITMAP_MINOR 39 | ||
17 | |||
18 | /* | ||
19 | * in-memory bitmap: | ||
20 | * | ||
21 | * Use 16 bit block counters to track pending writes to each "chunk". | ||
22 | * The 2 high order bits are special-purpose, the first is a flag indicating | ||
23 | * whether a resync is needed. The second is a flag indicating whether a | ||
24 | * resync is active. | ||
25 | * This means that the counter is actually 14 bits: | ||
26 | * | ||
27 | * +--------+--------+------------------------------------------------+ | ||
28 | * | resync | resync | counter | | ||
29 | * | needed | active | | | ||
30 | * | (0-1) | (0-1) | (0-16383) | | ||
31 | * +--------+--------+------------------------------------------------+ | ||
32 | * | ||
33 | * The "resync needed" bit is set when: | ||
34 | * a '1' bit is read from storage at startup. | ||
35 | * a write request fails on some drives | ||
36 | * a resync is aborted on a chunk with 'resync active' set | ||
37 | * It is cleared (and resync-active set) when a resync starts across all drives | ||
38 | * of the chunk. | ||
39 | * | ||
40 | * | ||
41 | * The "resync active" bit is set when: | ||
42 | * a resync is started on all drives, and resync_needed is set. | ||
43 | * resync_needed will be cleared (as long as resync_active wasn't already set). | ||
44 | * It is cleared when a resync completes. | ||
45 | * | ||
46 | * The counter counts pending write requests, plus the on-disk bit. | ||
47 | * When the counter is '1' and the resync bits are clear, the on-disk | ||
48 | * bit can be cleared aswell, thus setting the counter to 0. | ||
49 | * When we set a bit, or in the counter (to start a write), if the fields is | ||
50 | * 0, we first set the disk bit and set the counter to 1. | ||
51 | * | ||
52 | * If the counter is 0, the on-disk bit is clear and the stipe is clean | ||
53 | * Anything that dirties the stipe pushes the counter to 2 (at least) | ||
54 | * and sets the on-disk bit (lazily). | ||
55 | * If a periodic sweep find the counter at 2, it is decremented to 1. | ||
56 | * If the sweep find the counter at 1, the on-disk bit is cleared and the | ||
57 | * counter goes to zero. | ||
58 | * | ||
59 | * Also, we'll hijack the "map" pointer itself and use it as two 16 bit block | ||
60 | * counters as a fallback when "page" memory cannot be allocated: | ||
61 | * | ||
62 | * Normal case (page memory allocated): | ||
63 | * | ||
64 | * page pointer (32-bit) | ||
65 | * | ||
66 | * [ ] ------+ | ||
67 | * | | ||
68 | * +-------> [ ][ ]..[ ] (4096 byte page == 2048 counters) | ||
69 | * c1 c2 c2048 | ||
70 | * | ||
71 | * Hijacked case (page memory allocation failed): | ||
72 | * | ||
73 | * hijacked page pointer (32-bit) | ||
74 | * | ||
75 | * [ ][ ] (no page memory allocated) | ||
76 | * counter #1 (16-bit) counter #2 (16-bit) | ||
77 | * | ||
78 | */ | ||
79 | |||
80 | #ifdef __KERNEL__ | ||
81 | |||
82 | #define PAGE_BITS (PAGE_SIZE << 3) | ||
83 | #define PAGE_BIT_SHIFT (PAGE_SHIFT + 3) | ||
84 | |||
85 | typedef __u16 bitmap_counter_t; | ||
86 | #define COUNTER_BITS 16 | ||
87 | #define COUNTER_BIT_SHIFT 4 | ||
88 | #define COUNTER_BYTE_RATIO (COUNTER_BITS / 8) | ||
89 | #define COUNTER_BYTE_SHIFT (COUNTER_BIT_SHIFT - 3) | ||
90 | |||
91 | #define NEEDED_MASK ((bitmap_counter_t) (1 << (COUNTER_BITS - 1))) | ||
92 | #define RESYNC_MASK ((bitmap_counter_t) (1 << (COUNTER_BITS - 2))) | ||
93 | #define COUNTER_MAX ((bitmap_counter_t) RESYNC_MASK - 1) | ||
94 | #define NEEDED(x) (((bitmap_counter_t) x) & NEEDED_MASK) | ||
95 | #define RESYNC(x) (((bitmap_counter_t) x) & RESYNC_MASK) | ||
96 | #define COUNTER(x) (((bitmap_counter_t) x) & COUNTER_MAX) | ||
97 | |||
98 | /* how many counters per page? */ | ||
99 | #define PAGE_COUNTER_RATIO (PAGE_BITS / COUNTER_BITS) | ||
100 | /* same, except a shift value for more efficient bitops */ | ||
101 | #define PAGE_COUNTER_SHIFT (PAGE_BIT_SHIFT - COUNTER_BIT_SHIFT) | ||
102 | /* same, except a mask value for more efficient bitops */ | ||
103 | #define PAGE_COUNTER_MASK (PAGE_COUNTER_RATIO - 1) | ||
104 | |||
105 | #define BITMAP_BLOCK_SIZE 512 | ||
106 | #define BITMAP_BLOCK_SHIFT 9 | ||
107 | |||
108 | /* how many blocks per chunk? (this is variable) */ | ||
109 | #define CHUNK_BLOCK_RATIO(bitmap) ((bitmap)->chunksize >> BITMAP_BLOCK_SHIFT) | ||
110 | #define CHUNK_BLOCK_SHIFT(bitmap) ((bitmap)->chunkshift - BITMAP_BLOCK_SHIFT) | ||
111 | #define CHUNK_BLOCK_MASK(bitmap) (CHUNK_BLOCK_RATIO(bitmap) - 1) | ||
112 | |||
113 | /* when hijacked, the counters and bits represent even larger "chunks" */ | ||
114 | /* there will be 1024 chunks represented by each counter in the page pointers */ | ||
115 | #define PAGEPTR_BLOCK_RATIO(bitmap) \ | ||
116 | (CHUNK_BLOCK_RATIO(bitmap) << PAGE_COUNTER_SHIFT >> 1) | ||
117 | #define PAGEPTR_BLOCK_SHIFT(bitmap) \ | ||
118 | (CHUNK_BLOCK_SHIFT(bitmap) + PAGE_COUNTER_SHIFT - 1) | ||
119 | #define PAGEPTR_BLOCK_MASK(bitmap) (PAGEPTR_BLOCK_RATIO(bitmap) - 1) | ||
120 | |||
121 | /* | ||
122 | * on-disk bitmap: | ||
123 | * | ||
124 | * Use one bit per "chunk" (block set). We do the disk I/O on the bitmap | ||
125 | * file a page at a time. There's a superblock at the start of the file. | ||
126 | */ | ||
127 | |||
128 | /* map chunks (bits) to file pages - offset by the size of the superblock */ | ||
129 | #define CHUNK_BIT_OFFSET(chunk) ((chunk) + (sizeof(bitmap_super_t) << 3)) | ||
130 | |||
131 | #endif | ||
132 | |||
133 | /* | ||
134 | * bitmap structures: | ||
135 | */ | ||
136 | |||
137 | #define BITMAP_MAGIC 0x6d746962 | ||
138 | |||
139 | /* use these for bitmap->flags and bitmap->sb->state bit-fields */ | ||
140 | enum bitmap_state { | ||
141 | BITMAP_STALE = 0x002, /* the bitmap file is out of date or had -EIO */ | ||
142 | BITMAP_WRITE_ERROR = 0x004, /* A write error has occurred */ | ||
143 | BITMAP_HOSTENDIAN = 0x8000, | ||
144 | }; | ||
145 | |||
146 | /* the superblock at the front of the bitmap file -- little endian */ | ||
147 | typedef struct bitmap_super_s { | ||
148 | __le32 magic; /* 0 BITMAP_MAGIC */ | ||
149 | __le32 version; /* 4 the bitmap major for now, could change... */ | ||
150 | __u8 uuid[16]; /* 8 128 bit uuid - must match md device uuid */ | ||
151 | __le64 events; /* 24 event counter for the bitmap (1)*/ | ||
152 | __le64 events_cleared;/*32 event counter when last bit cleared (2) */ | ||
153 | __le64 sync_size; /* 40 the size of the md device's sync range(3) */ | ||
154 | __le32 state; /* 48 bitmap state information */ | ||
155 | __le32 chunksize; /* 52 the bitmap chunk size in bytes */ | ||
156 | __le32 daemon_sleep; /* 56 seconds between disk flushes */ | ||
157 | __le32 write_behind; /* 60 number of outstanding write-behind writes */ | ||
158 | |||
159 | __u8 pad[256 - 64]; /* set to zero */ | ||
160 | } bitmap_super_t; | ||
161 | |||
162 | /* notes: | ||
163 | * (1) This event counter is updated before the eventcounter in the md superblock | ||
164 | * When a bitmap is loaded, it is only accepted if this event counter is equal | ||
165 | * to, or one greater than, the event counter in the superblock. | ||
166 | * (2) This event counter is updated when the other one is *if*and*only*if* the | ||
167 | * array is not degraded. As bits are not cleared when the array is degraded, | ||
168 | * this represents the last time that any bits were cleared. | ||
169 | * If a device is being added that has an event count with this value or | ||
170 | * higher, it is accepted as conforming to the bitmap. | ||
171 | * (3)This is the number of sectors represented by the bitmap, and is the range that | ||
172 | * resync happens across. For raid1 and raid5/6 it is the size of individual | ||
173 | * devices. For raid10 it is the size of the array. | ||
174 | */ | ||
175 | |||
176 | #ifdef __KERNEL__ | ||
177 | |||
178 | /* the in-memory bitmap is represented by bitmap_pages */ | ||
179 | struct bitmap_page { | ||
180 | /* | ||
181 | * map points to the actual memory page | ||
182 | */ | ||
183 | char *map; | ||
184 | /* | ||
185 | * in emergencies (when map cannot be alloced), hijack the map | ||
186 | * pointer and use it as two counters itself | ||
187 | */ | ||
188 | unsigned int hijacked:1; | ||
189 | /* | ||
190 | * count of dirty bits on the page | ||
191 | */ | ||
192 | unsigned int count:31; | ||
193 | }; | ||
194 | |||
195 | /* keep track of bitmap file pages that have pending writes on them */ | ||
196 | struct page_list { | ||
197 | struct list_head list; | ||
198 | struct page *page; | ||
199 | }; | ||
200 | |||
201 | /* the main bitmap structure - one per mddev */ | ||
202 | struct bitmap { | ||
203 | struct bitmap_page *bp; | ||
204 | unsigned long pages; /* total number of pages in the bitmap */ | ||
205 | unsigned long missing_pages; /* number of pages not yet allocated */ | ||
206 | |||
207 | mddev_t *mddev; /* the md device that the bitmap is for */ | ||
208 | |||
209 | int counter_bits; /* how many bits per block counter */ | ||
210 | |||
211 | /* bitmap chunksize -- how much data does each bit represent? */ | ||
212 | unsigned long chunksize; | ||
213 | unsigned long chunkshift; /* chunksize = 2^chunkshift (for bitops) */ | ||
214 | unsigned long chunks; /* total number of data chunks for the array */ | ||
215 | |||
216 | /* We hold a count on the chunk currently being synced, and drop | ||
217 | * it when the last block is started. If the resync is aborted | ||
218 | * midway, we need to be able to drop that count, so we remember | ||
219 | * the counted chunk.. | ||
220 | */ | ||
221 | unsigned long syncchunk; | ||
222 | |||
223 | __u64 events_cleared; | ||
224 | int need_sync; | ||
225 | |||
226 | /* bitmap spinlock */ | ||
227 | spinlock_t lock; | ||
228 | |||
229 | long offset; /* offset from superblock if file is NULL */ | ||
230 | struct file *file; /* backing disk file */ | ||
231 | struct page *sb_page; /* cached copy of the bitmap file superblock */ | ||
232 | struct page **filemap; /* list of cache pages for the file */ | ||
233 | unsigned long *filemap_attr; /* attributes associated w/ filemap pages */ | ||
234 | unsigned long file_pages; /* number of pages in the file */ | ||
235 | int last_page_size; /* bytes in the last page */ | ||
236 | |||
237 | unsigned long flags; | ||
238 | |||
239 | int allclean; | ||
240 | |||
241 | unsigned long max_write_behind; /* write-behind mode */ | ||
242 | atomic_t behind_writes; | ||
243 | |||
244 | /* | ||
245 | * the bitmap daemon - periodically wakes up and sweeps the bitmap | ||
246 | * file, cleaning up bits and flushing out pages to disk as necessary | ||
247 | */ | ||
248 | unsigned long daemon_lastrun; /* jiffies of last run */ | ||
249 | unsigned long daemon_sleep; /* how many seconds between updates? */ | ||
250 | unsigned long last_end_sync; /* when we lasted called end_sync to | ||
251 | * update bitmap with resync progress */ | ||
252 | |||
253 | atomic_t pending_writes; /* pending writes to the bitmap file */ | ||
254 | wait_queue_head_t write_wait; | ||
255 | wait_queue_head_t overflow_wait; | ||
256 | |||
257 | }; | ||
258 | |||
259 | /* the bitmap API */ | ||
260 | |||
261 | /* these are used only by md/bitmap */ | ||
262 | int bitmap_create(mddev_t *mddev); | ||
263 | void bitmap_flush(mddev_t *mddev); | ||
264 | void bitmap_destroy(mddev_t *mddev); | ||
265 | |||
266 | void bitmap_print_sb(struct bitmap *bitmap); | ||
267 | void bitmap_update_sb(struct bitmap *bitmap); | ||
268 | |||
269 | int bitmap_setallbits(struct bitmap *bitmap); | ||
270 | void bitmap_write_all(struct bitmap *bitmap); | ||
271 | |||
272 | void bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long e); | ||
273 | |||
274 | /* these are exported */ | ||
275 | int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, | ||
276 | unsigned long sectors, int behind); | ||
277 | void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, | ||
278 | unsigned long sectors, int success, int behind); | ||
279 | int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks, int degraded); | ||
280 | void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, int *blocks, int aborted); | ||
281 | void bitmap_close_sync(struct bitmap *bitmap); | ||
282 | void bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector); | ||
283 | |||
284 | void bitmap_unplug(struct bitmap *bitmap); | ||
285 | void bitmap_daemon_work(struct bitmap *bitmap); | ||
286 | #endif | ||
287 | |||
288 | #endif | ||
diff --git a/include/linux/raid/linear.h b/include/linux/raid/linear.h deleted file mode 100644 index f38b9c586afb..000000000000 --- a/include/linux/raid/linear.h +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
1 | #ifndef _LINEAR_H | ||
2 | #define _LINEAR_H | ||
3 | |||
4 | #include <linux/raid/md.h> | ||
5 | |||
6 | struct dev_info { | ||
7 | mdk_rdev_t *rdev; | ||
8 | sector_t num_sectors; | ||
9 | sector_t start_sector; | ||
10 | }; | ||
11 | |||
12 | typedef struct dev_info dev_info_t; | ||
13 | |||
14 | struct linear_private_data | ||
15 | { | ||
16 | struct linear_private_data *prev; /* earlier version */ | ||
17 | dev_info_t **hash_table; | ||
18 | sector_t spacing; | ||
19 | sector_t array_sectors; | ||
20 | int sector_shift; /* shift before dividing | ||
21 | * by spacing | ||
22 | */ | ||
23 | dev_info_t disks[0]; | ||
24 | }; | ||
25 | |||
26 | |||
27 | typedef struct linear_private_data linear_conf_t; | ||
28 | |||
29 | #define mddev_to_conf(mddev) ((linear_conf_t *) mddev->private) | ||
30 | |||
31 | #endif | ||
diff --git a/include/linux/raid/md.h b/include/linux/raid/md.h deleted file mode 100644 index 82bea14cae1a..000000000000 --- a/include/linux/raid/md.h +++ /dev/null | |||
@@ -1,81 +0,0 @@ | |||
1 | /* | ||
2 | md.h : Multiple Devices driver for Linux | ||
3 | Copyright (C) 1996-98 Ingo Molnar, Gadi Oxman | ||
4 | Copyright (C) 1994-96 Marc ZYNGIER | ||
5 | <zyngier@ufr-info-p7.ibp.fr> or | ||
6 | <maz@gloups.fdn.fr> | ||
7 | |||
8 | This program is free software; you can redistribute it and/or modify | ||
9 | it under the terms of the GNU General Public License as published by | ||
10 | the Free Software Foundation; either version 2, or (at your option) | ||
11 | any later version. | ||
12 | |||
13 | You should have received a copy of the GNU General Public License | ||
14 | (for example /usr/src/linux/COPYING); if not, write to the Free | ||
15 | Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
16 | */ | ||
17 | |||
18 | #ifndef _MD_H | ||
19 | #define _MD_H | ||
20 | |||
21 | #include <linux/blkdev.h> | ||
22 | #include <linux/seq_file.h> | ||
23 | |||
24 | /* | ||
25 | * 'md_p.h' holds the 'physical' layout of RAID devices | ||
26 | * 'md_u.h' holds the user <=> kernel API | ||
27 | * | ||
28 | * 'md_k.h' holds kernel internal definitions | ||
29 | */ | ||
30 | |||
31 | #include <linux/raid/md_p.h> | ||
32 | #include <linux/raid/md_u.h> | ||
33 | #include <linux/raid/md_k.h> | ||
34 | |||
35 | #ifdef CONFIG_MD | ||
36 | |||
37 | /* | ||
38 | * Different major versions are not compatible. | ||
39 | * Different minor versions are only downward compatible. | ||
40 | * Different patchlevel versions are downward and upward compatible. | ||
41 | */ | ||
42 | #define MD_MAJOR_VERSION 0 | ||
43 | #define MD_MINOR_VERSION 90 | ||
44 | /* | ||
45 | * MD_PATCHLEVEL_VERSION indicates kernel functionality. | ||
46 | * >=1 means different superblock formats are selectable using SET_ARRAY_INFO | ||
47 | * and major_version/minor_version accordingly | ||
48 | * >=2 means that Internal bitmaps are supported by setting MD_SB_BITMAP_PRESENT | ||
49 | * in the super status byte | ||
50 | * >=3 means that bitmap superblock version 4 is supported, which uses | ||
51 | * little-ending representation rather than host-endian | ||
52 | */ | ||
53 | #define MD_PATCHLEVEL_VERSION 3 | ||
54 | |||
55 | extern int mdp_major; | ||
56 | |||
57 | extern int register_md_personality(struct mdk_personality *p); | ||
58 | extern int unregister_md_personality(struct mdk_personality *p); | ||
59 | extern mdk_thread_t * md_register_thread(void (*run) (mddev_t *mddev), | ||
60 | mddev_t *mddev, const char *name); | ||
61 | extern void md_unregister_thread(mdk_thread_t *thread); | ||
62 | extern void md_wakeup_thread(mdk_thread_t *thread); | ||
63 | extern void md_check_recovery(mddev_t *mddev); | ||
64 | extern void md_write_start(mddev_t *mddev, struct bio *bi); | ||
65 | extern void md_write_end(mddev_t *mddev); | ||
66 | extern void md_done_sync(mddev_t *mddev, int blocks, int ok); | ||
67 | extern void md_error(mddev_t *mddev, mdk_rdev_t *rdev); | ||
68 | |||
69 | extern void md_super_write(mddev_t *mddev, mdk_rdev_t *rdev, | ||
70 | sector_t sector, int size, struct page *page); | ||
71 | extern void md_super_wait(mddev_t *mddev); | ||
72 | extern int sync_page_io(struct block_device *bdev, sector_t sector, int size, | ||
73 | struct page *page, int rw); | ||
74 | extern void md_do_sync(mddev_t *mddev); | ||
75 | extern void md_new_event(mddev_t *mddev); | ||
76 | extern int md_allow_write(mddev_t *mddev); | ||
77 | extern void md_wait_for_blocked_rdev(mdk_rdev_t *rdev, mddev_t *mddev); | ||
78 | |||
79 | #endif /* CONFIG_MD */ | ||
80 | #endif | ||
81 | |||
diff --git a/include/linux/raid/md_k.h b/include/linux/raid/md_k.h deleted file mode 100644 index 9743e4dbc918..000000000000 --- a/include/linux/raid/md_k.h +++ /dev/null | |||
@@ -1,402 +0,0 @@ | |||
1 | /* | ||
2 | md_k.h : kernel internal structure of the Linux MD driver | ||
3 | Copyright (C) 1996-98 Ingo Molnar, Gadi Oxman | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2, or (at your option) | ||
8 | any later version. | ||
9 | |||
10 | You should have received a copy of the GNU General Public License | ||
11 | (for example /usr/src/linux/COPYING); if not, write to the Free | ||
12 | Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
13 | */ | ||
14 | |||
15 | #ifndef _MD_K_H | ||
16 | #define _MD_K_H | ||
17 | |||
18 | /* and dm-bio-list.h is not under include/linux because.... ??? */ | ||
19 | #include "../../../drivers/md/dm-bio-list.h" | ||
20 | |||
21 | #ifdef CONFIG_BLOCK | ||
22 | |||
23 | #define LEVEL_MULTIPATH (-4) | ||
24 | #define LEVEL_LINEAR (-1) | ||
25 | #define LEVEL_FAULTY (-5) | ||
26 | |||
27 | /* we need a value for 'no level specified' and 0 | ||
28 | * means 'raid0', so we need something else. This is | ||
29 | * for internal use only | ||
30 | */ | ||
31 | #define LEVEL_NONE (-1000000) | ||
32 | |||
33 | #define MaxSector (~(sector_t)0) | ||
34 | |||
35 | typedef struct mddev_s mddev_t; | ||
36 | typedef struct mdk_rdev_s mdk_rdev_t; | ||
37 | |||
38 | /* | ||
39 | * options passed in raidrun: | ||
40 | */ | ||
41 | |||
42 | /* Currently this must fit in an 'int' */ | ||
43 | #define MAX_CHUNK_SIZE (1<<30) | ||
44 | |||
45 | /* | ||
46 | * MD's 'extended' device | ||
47 | */ | ||
48 | struct mdk_rdev_s | ||
49 | { | ||
50 | struct list_head same_set; /* RAID devices within the same set */ | ||
51 | |||
52 | sector_t size; /* Device size (in blocks) */ | ||
53 | mddev_t *mddev; /* RAID array if running */ | ||
54 | long last_events; /* IO event timestamp */ | ||
55 | |||
56 | struct block_device *bdev; /* block device handle */ | ||
57 | |||
58 | struct page *sb_page; | ||
59 | int sb_loaded; | ||
60 | __u64 sb_events; | ||
61 | sector_t data_offset; /* start of data in array */ | ||
62 | sector_t sb_start; /* offset of the super block (in 512byte sectors) */ | ||
63 | int sb_size; /* bytes in the superblock */ | ||
64 | int preferred_minor; /* autorun support */ | ||
65 | |||
66 | struct kobject kobj; | ||
67 | |||
68 | /* A device can be in one of three states based on two flags: | ||
69 | * Not working: faulty==1 in_sync==0 | ||
70 | * Fully working: faulty==0 in_sync==1 | ||
71 | * Working, but not | ||
72 | * in sync with array | ||
73 | * faulty==0 in_sync==0 | ||
74 | * | ||
75 | * It can never have faulty==1, in_sync==1 | ||
76 | * This reduces the burden of testing multiple flags in many cases | ||
77 | */ | ||
78 | |||
79 | unsigned long flags; | ||
80 | #define Faulty 1 /* device is known to have a fault */ | ||
81 | #define In_sync 2 /* device is in_sync with rest of array */ | ||
82 | #define WriteMostly 4 /* Avoid reading if at all possible */ | ||
83 | #define BarriersNotsupp 5 /* BIO_RW_BARRIER is not supported */ | ||
84 | #define AllReserved 6 /* If whole device is reserved for | ||
85 | * one array */ | ||
86 | #define AutoDetected 7 /* added by auto-detect */ | ||
87 | #define Blocked 8 /* An error occured on an externally | ||
88 | * managed array, don't allow writes | ||
89 | * until it is cleared */ | ||
90 | #define StateChanged 9 /* Faulty or Blocked has changed during | ||
91 | * interrupt, so it needs to be | ||
92 | * notified by the thread */ | ||
93 | wait_queue_head_t blocked_wait; | ||
94 | |||
95 | int desc_nr; /* descriptor index in the superblock */ | ||
96 | int raid_disk; /* role of device in array */ | ||
97 | int saved_raid_disk; /* role that device used to have in the | ||
98 | * array and could again if we did a partial | ||
99 | * resync from the bitmap | ||
100 | */ | ||
101 | sector_t recovery_offset;/* If this device has been partially | ||
102 | * recovered, this is where we were | ||
103 | * up to. | ||
104 | */ | ||
105 | |||
106 | atomic_t nr_pending; /* number of pending requests. | ||
107 | * only maintained for arrays that | ||
108 | * support hot removal | ||
109 | */ | ||
110 | atomic_t read_errors; /* number of consecutive read errors that | ||
111 | * we have tried to ignore. | ||
112 | */ | ||
113 | atomic_t corrected_errors; /* number of corrected read errors, | ||
114 | * for reporting to userspace and storing | ||
115 | * in superblock. | ||
116 | */ | ||
117 | struct work_struct del_work; /* used for delayed sysfs removal */ | ||
118 | |||
119 | struct sysfs_dirent *sysfs_state; /* handle for 'state' | ||
120 | * sysfs entry */ | ||
121 | }; | ||
122 | |||
123 | struct mddev_s | ||
124 | { | ||
125 | void *private; | ||
126 | struct mdk_personality *pers; | ||
127 | dev_t unit; | ||
128 | int md_minor; | ||
129 | struct list_head disks; | ||
130 | unsigned long flags; | ||
131 | #define MD_CHANGE_DEVS 0 /* Some device status has changed */ | ||
132 | #define MD_CHANGE_CLEAN 1 /* transition to or from 'clean' */ | ||
133 | #define MD_CHANGE_PENDING 2 /* superblock update in progress */ | ||
134 | |||
135 | int ro; | ||
136 | |||
137 | struct gendisk *gendisk; | ||
138 | |||
139 | struct kobject kobj; | ||
140 | int hold_active; | ||
141 | #define UNTIL_IOCTL 1 | ||
142 | #define UNTIL_STOP 2 | ||
143 | |||
144 | /* Superblock information */ | ||
145 | int major_version, | ||
146 | minor_version, | ||
147 | patch_version; | ||
148 | int persistent; | ||
149 | int external; /* metadata is | ||
150 | * managed externally */ | ||
151 | char metadata_type[17]; /* externally set*/ | ||
152 | int chunk_size; | ||
153 | time_t ctime, utime; | ||
154 | int level, layout; | ||
155 | char clevel[16]; | ||
156 | int raid_disks; | ||
157 | int max_disks; | ||
158 | sector_t size; /* used size of component devices */ | ||
159 | sector_t array_sectors; /* exported array size */ | ||
160 | __u64 events; | ||
161 | |||
162 | char uuid[16]; | ||
163 | |||
164 | /* If the array is being reshaped, we need to record the | ||
165 | * new shape and an indication of where we are up to. | ||
166 | * This is written to the superblock. | ||
167 | * If reshape_position is MaxSector, then no reshape is happening (yet). | ||
168 | */ | ||
169 | sector_t reshape_position; | ||
170 | int delta_disks, new_level, new_layout, new_chunk; | ||
171 | |||
172 | struct mdk_thread_s *thread; /* management thread */ | ||
173 | struct mdk_thread_s *sync_thread; /* doing resync or reconstruct */ | ||
174 | sector_t curr_resync; /* last block scheduled */ | ||
175 | unsigned long resync_mark; /* a recent timestamp */ | ||
176 | sector_t resync_mark_cnt;/* blocks written at resync_mark */ | ||
177 | sector_t curr_mark_cnt; /* blocks scheduled now */ | ||
178 | |||
179 | sector_t resync_max_sectors; /* may be set by personality */ | ||
180 | |||
181 | sector_t resync_mismatches; /* count of sectors where | ||
182 | * parity/replica mismatch found | ||
183 | */ | ||
184 | |||
185 | /* allow user-space to request suspension of IO to regions of the array */ | ||
186 | sector_t suspend_lo; | ||
187 | sector_t suspend_hi; | ||
188 | /* if zero, use the system-wide default */ | ||
189 | int sync_speed_min; | ||
190 | int sync_speed_max; | ||
191 | |||
192 | /* resync even though the same disks are shared among md-devices */ | ||
193 | int parallel_resync; | ||
194 | |||
195 | int ok_start_degraded; | ||
196 | /* recovery/resync flags | ||
197 | * NEEDED: we might need to start a resync/recover | ||
198 | * RUNNING: a thread is running, or about to be started | ||
199 | * SYNC: actually doing a resync, not a recovery | ||
200 | * RECOVER: doing recovery, or need to try it. | ||
201 | * INTR: resync needs to be aborted for some reason | ||
202 | * DONE: thread is done and is waiting to be reaped | ||
203 | * REQUEST: user-space has requested a sync (used with SYNC) | ||
204 | * CHECK: user-space request for for check-only, no repair | ||
205 | * RESHAPE: A reshape is happening | ||
206 | * | ||
207 | * If neither SYNC or RESHAPE are set, then it is a recovery. | ||
208 | */ | ||
209 | #define MD_RECOVERY_RUNNING 0 | ||
210 | #define MD_RECOVERY_SYNC 1 | ||
211 | #define MD_RECOVERY_RECOVER 2 | ||
212 | #define MD_RECOVERY_INTR 3 | ||
213 | #define MD_RECOVERY_DONE 4 | ||
214 | #define MD_RECOVERY_NEEDED 5 | ||
215 | #define MD_RECOVERY_REQUESTED 6 | ||
216 | #define MD_RECOVERY_CHECK 7 | ||
217 | #define MD_RECOVERY_RESHAPE 8 | ||
218 | #define MD_RECOVERY_FROZEN 9 | ||
219 | |||
220 | unsigned long recovery; | ||
221 | int recovery_disabled; /* if we detect that recovery | ||
222 | * will always fail, set this | ||
223 | * so we don't loop trying */ | ||
224 | |||
225 | int in_sync; /* know to not need resync */ | ||
226 | struct mutex reconfig_mutex; | ||
227 | atomic_t active; /* general refcount */ | ||
228 | atomic_t openers; /* number of active opens */ | ||
229 | |||
230 | int changed; /* true if we might need to reread partition info */ | ||
231 | int degraded; /* whether md should consider | ||
232 | * adding a spare | ||
233 | */ | ||
234 | int barriers_work; /* initialised to true, cleared as soon | ||
235 | * as a barrier request to slave | ||
236 | * fails. Only supported | ||
237 | */ | ||
238 | struct bio *biolist; /* bios that need to be retried | ||
239 | * because BIO_RW_BARRIER is not supported | ||
240 | */ | ||
241 | |||
242 | atomic_t recovery_active; /* blocks scheduled, but not written */ | ||
243 | wait_queue_head_t recovery_wait; | ||
244 | sector_t recovery_cp; | ||
245 | sector_t resync_min; /* user requested sync | ||
246 | * starts here */ | ||
247 | sector_t resync_max; /* resync should pause | ||
248 | * when it gets here */ | ||
249 | |||
250 | struct sysfs_dirent *sysfs_state; /* handle for 'array_state' | ||
251 | * file in sysfs. | ||
252 | */ | ||
253 | struct sysfs_dirent *sysfs_action; /* handle for 'sync_action' */ | ||
254 | |||
255 | struct work_struct del_work; /* used for delayed sysfs removal */ | ||
256 | |||
257 | spinlock_t write_lock; | ||
258 | wait_queue_head_t sb_wait; /* for waiting on superblock updates */ | ||
259 | atomic_t pending_writes; /* number of active superblock writes */ | ||
260 | |||
261 | unsigned int safemode; /* if set, update "clean" superblock | ||
262 | * when no writes pending. | ||
263 | */ | ||
264 | unsigned int safemode_delay; | ||
265 | struct timer_list safemode_timer; | ||
266 | atomic_t writes_pending; | ||
267 | struct request_queue *queue; /* for plugging ... */ | ||
268 | |||
269 | atomic_t write_behind; /* outstanding async IO */ | ||
270 | unsigned int max_write_behind; /* 0 = sync */ | ||
271 | |||
272 | struct bitmap *bitmap; /* the bitmap for the device */ | ||
273 | struct file *bitmap_file; /* the bitmap file */ | ||
274 | long bitmap_offset; /* offset from superblock of | ||
275 | * start of bitmap. May be | ||
276 | * negative, but not '0' | ||
277 | */ | ||
278 | long default_bitmap_offset; /* this is the offset to use when | ||
279 | * hot-adding a bitmap. It should | ||
280 | * eventually be settable by sysfs. | ||
281 | */ | ||
282 | |||
283 | struct list_head all_mddevs; | ||
284 | }; | ||
285 | |||
286 | |||
287 | static inline void rdev_dec_pending(mdk_rdev_t *rdev, mddev_t *mddev) | ||
288 | { | ||
289 | int faulty = test_bit(Faulty, &rdev->flags); | ||
290 | if (atomic_dec_and_test(&rdev->nr_pending) && faulty) | ||
291 | set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); | ||
292 | } | ||
293 | |||
294 | static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors) | ||
295 | { | ||
296 | atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io); | ||
297 | } | ||
298 | |||
299 | struct mdk_personality | ||
300 | { | ||
301 | char *name; | ||
302 | int level; | ||
303 | struct list_head list; | ||
304 | struct module *owner; | ||
305 | int (*make_request)(struct request_queue *q, struct bio *bio); | ||
306 | int (*run)(mddev_t *mddev); | ||
307 | int (*stop)(mddev_t *mddev); | ||
308 | void (*status)(struct seq_file *seq, mddev_t *mddev); | ||
309 | /* error_handler must set ->faulty and clear ->in_sync | ||
310 | * if appropriate, and should abort recovery if needed | ||
311 | */ | ||
312 | void (*error_handler)(mddev_t *mddev, mdk_rdev_t *rdev); | ||
313 | int (*hot_add_disk) (mddev_t *mddev, mdk_rdev_t *rdev); | ||
314 | int (*hot_remove_disk) (mddev_t *mddev, int number); | ||
315 | int (*spare_active) (mddev_t *mddev); | ||
316 | sector_t (*sync_request)(mddev_t *mddev, sector_t sector_nr, int *skipped, int go_faster); | ||
317 | int (*resize) (mddev_t *mddev, sector_t sectors); | ||
318 | int (*check_reshape) (mddev_t *mddev); | ||
319 | int (*start_reshape) (mddev_t *mddev); | ||
320 | int (*reconfig) (mddev_t *mddev, int layout, int chunk_size); | ||
321 | /* quiesce moves between quiescence states | ||
322 | * 0 - fully active | ||
323 | * 1 - no new requests allowed | ||
324 | * others - reserved | ||
325 | */ | ||
326 | void (*quiesce) (mddev_t *mddev, int state); | ||
327 | }; | ||
328 | |||
329 | |||
330 | struct md_sysfs_entry { | ||
331 | struct attribute attr; | ||
332 | ssize_t (*show)(mddev_t *, char *); | ||
333 | ssize_t (*store)(mddev_t *, const char *, size_t); | ||
334 | }; | ||
335 | |||
336 | |||
337 | static inline char * mdname (mddev_t * mddev) | ||
338 | { | ||
339 | return mddev->gendisk ? mddev->gendisk->disk_name : "mdX"; | ||
340 | } | ||
341 | |||
342 | /* | ||
343 | * iterates through some rdev ringlist. It's safe to remove the | ||
344 | * current 'rdev'. Dont touch 'tmp' though. | ||
345 | */ | ||
346 | #define rdev_for_each_list(rdev, tmp, head) \ | ||
347 | list_for_each_entry_safe(rdev, tmp, head, same_set) | ||
348 | |||
349 | /* | ||
350 | * iterates through the 'same array disks' ringlist | ||
351 | */ | ||
352 | #define rdev_for_each(rdev, tmp, mddev) \ | ||
353 | list_for_each_entry_safe(rdev, tmp, &((mddev)->disks), same_set) | ||
354 | |||
355 | #define rdev_for_each_rcu(rdev, mddev) \ | ||
356 | list_for_each_entry_rcu(rdev, &((mddev)->disks), same_set) | ||
357 | |||
358 | typedef struct mdk_thread_s { | ||
359 | void (*run) (mddev_t *mddev); | ||
360 | mddev_t *mddev; | ||
361 | wait_queue_head_t wqueue; | ||
362 | unsigned long flags; | ||
363 | struct task_struct *tsk; | ||
364 | unsigned long timeout; | ||
365 | } mdk_thread_t; | ||
366 | |||
367 | #define THREAD_WAKEUP 0 | ||
368 | |||
369 | #define __wait_event_lock_irq(wq, condition, lock, cmd) \ | ||
370 | do { \ | ||
371 | wait_queue_t __wait; \ | ||
372 | init_waitqueue_entry(&__wait, current); \ | ||
373 | \ | ||
374 | add_wait_queue(&wq, &__wait); \ | ||
375 | for (;;) { \ | ||
376 | set_current_state(TASK_UNINTERRUPTIBLE); \ | ||
377 | if (condition) \ | ||
378 | break; \ | ||
379 | spin_unlock_irq(&lock); \ | ||
380 | cmd; \ | ||
381 | schedule(); \ | ||
382 | spin_lock_irq(&lock); \ | ||
383 | } \ | ||
384 | current->state = TASK_RUNNING; \ | ||
385 | remove_wait_queue(&wq, &__wait); \ | ||
386 | } while (0) | ||
387 | |||
388 | #define wait_event_lock_irq(wq, condition, lock, cmd) \ | ||
389 | do { \ | ||
390 | if (condition) \ | ||
391 | break; \ | ||
392 | __wait_event_lock_irq(wq, condition, lock, cmd); \ | ||
393 | } while (0) | ||
394 | |||
395 | static inline void safe_put_page(struct page *p) | ||
396 | { | ||
397 | if (p) put_page(p); | ||
398 | } | ||
399 | |||
400 | #endif /* CONFIG_BLOCK */ | ||
401 | #endif | ||
402 | |||
diff --git a/include/linux/raid/md_u.h b/include/linux/raid/md_u.h index 7192035fc4b0..fb1abb3367e9 100644 --- a/include/linux/raid/md_u.h +++ b/include/linux/raid/md_u.h | |||
@@ -15,6 +15,24 @@ | |||
15 | #ifndef _MD_U_H | 15 | #ifndef _MD_U_H |
16 | #define _MD_U_H | 16 | #define _MD_U_H |
17 | 17 | ||
18 | /* | ||
19 | * Different major versions are not compatible. | ||
20 | * Different minor versions are only downward compatible. | ||
21 | * Different patchlevel versions are downward and upward compatible. | ||
22 | */ | ||
23 | #define MD_MAJOR_VERSION 0 | ||
24 | #define MD_MINOR_VERSION 90 | ||
25 | /* | ||
26 | * MD_PATCHLEVEL_VERSION indicates kernel functionality. | ||
27 | * >=1 means different superblock formats are selectable using SET_ARRAY_INFO | ||
28 | * and major_version/minor_version accordingly | ||
29 | * >=2 means that Internal bitmaps are supported by setting MD_SB_BITMAP_PRESENT | ||
30 | * in the super status byte | ||
31 | * >=3 means that bitmap superblock version 4 is supported, which uses | ||
32 | * little-ending representation rather than host-endian | ||
33 | */ | ||
34 | #define MD_PATCHLEVEL_VERSION 3 | ||
35 | |||
18 | /* ioctls */ | 36 | /* ioctls */ |
19 | 37 | ||
20 | /* status */ | 38 | /* status */ |
@@ -46,6 +64,12 @@ | |||
46 | #define STOP_ARRAY_RO _IO (MD_MAJOR, 0x33) | 64 | #define STOP_ARRAY_RO _IO (MD_MAJOR, 0x33) |
47 | #define RESTART_ARRAY_RW _IO (MD_MAJOR, 0x34) | 65 | #define RESTART_ARRAY_RW _IO (MD_MAJOR, 0x34) |
48 | 66 | ||
67 | /* 63 partitions with the alternate major number (mdp) */ | ||
68 | #define MdpMinorShift 6 | ||
69 | #ifdef __KERNEL__ | ||
70 | extern int mdp_major; | ||
71 | #endif | ||
72 | |||
49 | typedef struct mdu_version_s { | 73 | typedef struct mdu_version_s { |
50 | int major; | 74 | int major; |
51 | int minor; | 75 | int minor; |
@@ -85,6 +109,17 @@ typedef struct mdu_array_info_s { | |||
85 | 109 | ||
86 | } mdu_array_info_t; | 110 | } mdu_array_info_t; |
87 | 111 | ||
112 | /* non-obvious values for 'level' */ | ||
113 | #define LEVEL_MULTIPATH (-4) | ||
114 | #define LEVEL_LINEAR (-1) | ||
115 | #define LEVEL_FAULTY (-5) | ||
116 | |||
117 | /* we need a value for 'no level specified' and 0 | ||
118 | * means 'raid0', so we need something else. This is | ||
119 | * for internal use only | ||
120 | */ | ||
121 | #define LEVEL_NONE (-1000000) | ||
122 | |||
88 | typedef struct mdu_disk_info_s { | 123 | typedef struct mdu_disk_info_s { |
89 | /* | 124 | /* |
90 | * configuration/status of one particular disk | 125 | * configuration/status of one particular disk |
diff --git a/include/linux/raid/multipath.h b/include/linux/raid/multipath.h deleted file mode 100644 index 6f53fc177a47..000000000000 --- a/include/linux/raid/multipath.h +++ /dev/null | |||
@@ -1,42 +0,0 @@ | |||
1 | #ifndef _MULTIPATH_H | ||
2 | #define _MULTIPATH_H | ||
3 | |||
4 | #include <linux/raid/md.h> | ||
5 | |||
6 | struct multipath_info { | ||
7 | mdk_rdev_t *rdev; | ||
8 | }; | ||
9 | |||
10 | struct multipath_private_data { | ||
11 | mddev_t *mddev; | ||
12 | struct multipath_info *multipaths; | ||
13 | int raid_disks; | ||
14 | int working_disks; | ||
15 | spinlock_t device_lock; | ||
16 | struct list_head retry_list; | ||
17 | |||
18 | mempool_t *pool; | ||
19 | }; | ||
20 | |||
21 | typedef struct multipath_private_data multipath_conf_t; | ||
22 | |||
23 | /* | ||
24 | * this is the only point in the RAID code where we violate | ||
25 | * C type safety. mddev->private is an 'opaque' pointer. | ||
26 | */ | ||
27 | #define mddev_to_conf(mddev) ((multipath_conf_t *) mddev->private) | ||
28 | |||
29 | /* | ||
30 | * this is our 'private' 'collective' MULTIPATH buffer head. | ||
31 | * it contains information about what kind of IO operations were started | ||
32 | * for this MULTIPATH operation, and about their status: | ||
33 | */ | ||
34 | |||
35 | struct multipath_bh { | ||
36 | mddev_t *mddev; | ||
37 | struct bio *master_bio; | ||
38 | struct bio bio; | ||
39 | int path; | ||
40 | struct list_head retry_list; | ||
41 | }; | ||
42 | #endif | ||
diff --git a/include/linux/raid/pq.h b/include/linux/raid/pq.h new file mode 100644 index 000000000000..d92480f8285c --- /dev/null +++ b/include/linux/raid/pq.h | |||
@@ -0,0 +1,132 @@ | |||
1 | /* -*- linux-c -*- ------------------------------------------------------- * | ||
2 | * | ||
3 | * Copyright 2003 H. Peter Anvin - All Rights Reserved | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation, Inc., 53 Temple Place Ste 330, | ||
8 | * Boston MA 02111-1307, USA; either version 2 of the License, or | ||
9 | * (at your option) any later version; incorporated herein by reference. | ||
10 | * | ||
11 | * ----------------------------------------------------------------------- */ | ||
12 | |||
13 | #ifndef LINUX_RAID_RAID6_H | ||
14 | #define LINUX_RAID_RAID6_H | ||
15 | |||
16 | #ifdef __KERNEL__ | ||
17 | |||
18 | /* Set to 1 to use kernel-wide empty_zero_page */ | ||
19 | #define RAID6_USE_EMPTY_ZERO_PAGE 0 | ||
20 | #include <linux/blkdev.h> | ||
21 | |||
22 | /* We need a pre-zeroed page... if we don't want to use the kernel-provided | ||
23 | one define it here */ | ||
24 | #if RAID6_USE_EMPTY_ZERO_PAGE | ||
25 | # define raid6_empty_zero_page empty_zero_page | ||
26 | #else | ||
27 | extern const char raid6_empty_zero_page[PAGE_SIZE]; | ||
28 | #endif | ||
29 | |||
30 | #else /* ! __KERNEL__ */ | ||
31 | /* Used for testing in user space */ | ||
32 | |||
33 | #include <errno.h> | ||
34 | #include <inttypes.h> | ||
35 | #include <limits.h> | ||
36 | #include <stddef.h> | ||
37 | #include <sys/mman.h> | ||
38 | #include <sys/types.h> | ||
39 | |||
40 | /* Not standard, but glibc defines it */ | ||
41 | #define BITS_PER_LONG __WORDSIZE | ||
42 | |||
43 | typedef uint8_t u8; | ||
44 | typedef uint16_t u16; | ||
45 | typedef uint32_t u32; | ||
46 | typedef uint64_t u64; | ||
47 | |||
48 | #ifndef PAGE_SIZE | ||
49 | # define PAGE_SIZE 4096 | ||
50 | #endif | ||
51 | extern const char raid6_empty_zero_page[PAGE_SIZE]; | ||
52 | |||
53 | #define __init | ||
54 | #define __exit | ||
55 | #define __attribute_const__ __attribute__((const)) | ||
56 | #define noinline __attribute__((noinline)) | ||
57 | |||
58 | #define preempt_enable() | ||
59 | #define preempt_disable() | ||
60 | #define cpu_has_feature(x) 1 | ||
61 | #define enable_kernel_altivec() | ||
62 | #define disable_kernel_altivec() | ||
63 | |||
64 | #define EXPORT_SYMBOL(sym) | ||
65 | #define MODULE_LICENSE(licence) | ||
66 | #define subsys_initcall(x) | ||
67 | #define module_exit(x) | ||
68 | #endif /* __KERNEL__ */ | ||
69 | |||
70 | /* Routine choices */ | ||
71 | struct raid6_calls { | ||
72 | void (*gen_syndrome)(int, size_t, void **); | ||
73 | int (*valid)(void); /* Returns 1 if this routine set is usable */ | ||
74 | const char *name; /* Name of this routine set */ | ||
75 | int prefer; /* Has special performance attribute */ | ||
76 | }; | ||
77 | |||
78 | /* Selected algorithm */ | ||
79 | extern struct raid6_calls raid6_call; | ||
80 | |||
81 | /* Algorithm list */ | ||
82 | extern const struct raid6_calls * const raid6_algos[]; | ||
83 | int raid6_select_algo(void); | ||
84 | |||
85 | /* Return values from chk_syndrome */ | ||
86 | #define RAID6_OK 0 | ||
87 | #define RAID6_P_BAD 1 | ||
88 | #define RAID6_Q_BAD 2 | ||
89 | #define RAID6_PQ_BAD 3 | ||
90 | |||
91 | /* Galois field tables */ | ||
92 | extern const u8 raid6_gfmul[256][256] __attribute__((aligned(256))); | ||
93 | extern const u8 raid6_gfexp[256] __attribute__((aligned(256))); | ||
94 | extern const u8 raid6_gfinv[256] __attribute__((aligned(256))); | ||
95 | extern const u8 raid6_gfexi[256] __attribute__((aligned(256))); | ||
96 | |||
97 | /* Recovery routines */ | ||
98 | void raid6_2data_recov(int disks, size_t bytes, int faila, int failb, | ||
99 | void **ptrs); | ||
100 | void raid6_datap_recov(int disks, size_t bytes, int faila, void **ptrs); | ||
101 | void raid6_dual_recov(int disks, size_t bytes, int faila, int failb, | ||
102 | void **ptrs); | ||
103 | |||
104 | /* Some definitions to allow code to be compiled for testing in userspace */ | ||
105 | #ifndef __KERNEL__ | ||
106 | |||
107 | # define jiffies raid6_jiffies() | ||
108 | # define printk printf | ||
109 | # define GFP_KERNEL 0 | ||
110 | # define __get_free_pages(x, y) ((unsigned long)mmap(NULL, PAGE_SIZE << (y), \ | ||
111 | PROT_READ|PROT_WRITE, \ | ||
112 | MAP_PRIVATE|MAP_ANONYMOUS,\ | ||
113 | 0, 0)) | ||
114 | # define free_pages(x, y) munmap((void *)(x), (y)*PAGE_SIZE) | ||
115 | |||
116 | static inline void cpu_relax(void) | ||
117 | { | ||
118 | /* Nothing */ | ||
119 | } | ||
120 | |||
121 | #undef HZ | ||
122 | #define HZ 1000 | ||
123 | static inline uint32_t raid6_jiffies(void) | ||
124 | { | ||
125 | struct timeval tv; | ||
126 | gettimeofday(&tv, NULL); | ||
127 | return tv.tv_sec*1000 + tv.tv_usec/1000; | ||
128 | } | ||
129 | |||
130 | #endif /* ! __KERNEL__ */ | ||
131 | |||
132 | #endif /* LINUX_RAID_RAID6_H */ | ||
diff --git a/include/linux/raid/raid0.h b/include/linux/raid/raid0.h deleted file mode 100644 index fd42aa87c391..000000000000 --- a/include/linux/raid/raid0.h +++ /dev/null | |||
@@ -1,30 +0,0 @@ | |||
1 | #ifndef _RAID0_H | ||
2 | #define _RAID0_H | ||
3 | |||
4 | #include <linux/raid/md.h> | ||
5 | |||
6 | struct strip_zone | ||
7 | { | ||
8 | sector_t zone_start; /* Zone offset in md_dev (in sectors) */ | ||
9 | sector_t dev_start; /* Zone offset in real dev (in sectors) */ | ||
10 | sector_t sectors; /* Zone size in sectors */ | ||
11 | int nb_dev; /* # of devices attached to the zone */ | ||
12 | mdk_rdev_t **dev; /* Devices attached to the zone */ | ||
13 | }; | ||
14 | |||
15 | struct raid0_private_data | ||
16 | { | ||
17 | struct strip_zone **hash_table; /* Table of indexes into strip_zone */ | ||
18 | struct strip_zone *strip_zone; | ||
19 | mdk_rdev_t **devlist; /* lists of rdevs, pointed to by strip_zone->dev */ | ||
20 | int nr_strip_zones; | ||
21 | |||
22 | sector_t spacing; | ||
23 | int sector_shift; /* shift this before divide by spacing */ | ||
24 | }; | ||
25 | |||
26 | typedef struct raid0_private_data raid0_conf_t; | ||
27 | |||
28 | #define mddev_to_conf(mddev) ((raid0_conf_t *) mddev->private) | ||
29 | |||
30 | #endif | ||
diff --git a/include/linux/raid/raid1.h b/include/linux/raid/raid1.h deleted file mode 100644 index 0a9ba7c3302e..000000000000 --- a/include/linux/raid/raid1.h +++ /dev/null | |||
@@ -1,134 +0,0 @@ | |||
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 | /* | ||
14 | * memory pools need a pointer to the mddev, so they can force an unplug | ||
15 | * when memory is tight, and a count of the number of drives that the | ||
16 | * pool was allocated for, so they know how much to allocate and free. | ||
17 | * mddev->raid_disks cannot be used, as it can change while a pool is active | ||
18 | * These two datums are stored in a kmalloced struct. | ||
19 | */ | ||
20 | |||
21 | struct pool_info { | ||
22 | mddev_t *mddev; | ||
23 | int raid_disks; | ||
24 | }; | ||
25 | |||
26 | |||
27 | typedef struct r1bio_s r1bio_t; | ||
28 | |||
29 | struct r1_private_data_s { | ||
30 | mddev_t *mddev; | ||
31 | mirror_info_t *mirrors; | ||
32 | int raid_disks; | ||
33 | int last_used; | ||
34 | sector_t next_seq_sect; | ||
35 | spinlock_t device_lock; | ||
36 | |||
37 | struct list_head retry_list; | ||
38 | /* queue pending writes and submit them on unplug */ | ||
39 | struct bio_list pending_bio_list; | ||
40 | /* queue of writes that have been unplugged */ | ||
41 | struct bio_list flushing_bio_list; | ||
42 | |||
43 | /* for use when syncing mirrors: */ | ||
44 | |||
45 | spinlock_t resync_lock; | ||
46 | int nr_pending; | ||
47 | int nr_waiting; | ||
48 | int nr_queued; | ||
49 | int barrier; | ||
50 | sector_t next_resync; | ||
51 | int fullsync; /* set to 1 if a full sync is needed, | ||
52 | * (fresh device added). | ||
53 | * Cleared when a sync completes. | ||
54 | */ | ||
55 | |||
56 | wait_queue_head_t wait_barrier; | ||
57 | |||
58 | struct pool_info *poolinfo; | ||
59 | |||
60 | struct page *tmppage; | ||
61 | |||
62 | mempool_t *r1bio_pool; | ||
63 | mempool_t *r1buf_pool; | ||
64 | }; | ||
65 | |||
66 | typedef struct r1_private_data_s conf_t; | ||
67 | |||
68 | /* | ||
69 | * this is the only point in the RAID code where we violate | ||
70 | * C type safety. mddev->private is an 'opaque' pointer. | ||
71 | */ | ||
72 | #define mddev_to_conf(mddev) ((conf_t *) mddev->private) | ||
73 | |||
74 | /* | ||
75 | * this is our 'private' RAID1 bio. | ||
76 | * | ||
77 | * it contains information about what kind of IO operations were started | ||
78 | * for this RAID1 operation, and about their status: | ||
79 | */ | ||
80 | |||
81 | struct r1bio_s { | ||
82 | atomic_t remaining; /* 'have we finished' count, | ||
83 | * used from IRQ handlers | ||
84 | */ | ||
85 | atomic_t behind_remaining; /* number of write-behind ios remaining | ||
86 | * in this BehindIO request | ||
87 | */ | ||
88 | sector_t sector; | ||
89 | int sectors; | ||
90 | unsigned long state; | ||
91 | mddev_t *mddev; | ||
92 | /* | ||
93 | * original bio going to /dev/mdx | ||
94 | */ | ||
95 | struct bio *master_bio; | ||
96 | /* | ||
97 | * if the IO is in READ direction, then this is where we read | ||
98 | */ | ||
99 | int read_disk; | ||
100 | |||
101 | struct list_head retry_list; | ||
102 | struct bitmap_update *bitmap_update; | ||
103 | /* | ||
104 | * if the IO is in WRITE direction, then multiple bios are used. | ||
105 | * We choose the number when they are allocated. | ||
106 | */ | ||
107 | struct bio *bios[0]; | ||
108 | /* DO NOT PUT ANY NEW FIELDS HERE - bios array is contiguously alloced*/ | ||
109 | }; | ||
110 | |||
111 | /* when we get a read error on a read-only array, we redirect to another | ||
112 | * device without failing the first device, or trying to over-write to | ||
113 | * correct the read error. To keep track of bad blocks on a per-bio | ||
114 | * level, we store IO_BLOCKED in the appropriate 'bios' pointer | ||
115 | */ | ||
116 | #define IO_BLOCKED ((struct bio*)1) | ||
117 | |||
118 | /* bits for r1bio.state */ | ||
119 | #define R1BIO_Uptodate 0 | ||
120 | #define R1BIO_IsSync 1 | ||
121 | #define R1BIO_Degraded 2 | ||
122 | #define R1BIO_BehindIO 3 | ||
123 | #define R1BIO_Barrier 4 | ||
124 | #define R1BIO_BarrierRetry 5 | ||
125 | /* For write-behind requests, we call bi_end_io when | ||
126 | * the last non-write-behind device completes, providing | ||
127 | * any write was successful. Otherwise we call when | ||
128 | * any write-behind write succeeds, otherwise we call | ||
129 | * with failure when last write completes (and all failed). | ||
130 | * Record that bi_end_io was called with this flag... | ||
131 | */ | ||
132 | #define R1BIO_Returned 6 | ||
133 | |||
134 | #endif | ||
diff --git a/include/linux/raid/raid10.h b/include/linux/raid/raid10.h deleted file mode 100644 index e9091cfeb286..000000000000 --- a/include/linux/raid/raid10.h +++ /dev/null | |||
@@ -1,123 +0,0 @@ | |||
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 | spinlock_t device_lock; | ||
20 | |||
21 | /* geometry */ | ||
22 | int near_copies; /* number of copies layed out raid0 style */ | ||
23 | int far_copies; /* number of copies layed out | ||
24 | * at large strides across drives | ||
25 | */ | ||
26 | int far_offset; /* far_copies are offset by 1 stripe | ||
27 | * instead of many | ||
28 | */ | ||
29 | int copies; /* near_copies * far_copies. | ||
30 | * must be <= raid_disks | ||
31 | */ | ||
32 | sector_t stride; /* distance between far copies. | ||
33 | * This is size / far_copies unless | ||
34 | * far_offset, in which case it is | ||
35 | * 1 stripe. | ||
36 | */ | ||
37 | |||
38 | int chunk_shift; /* shift from chunks to sectors */ | ||
39 | sector_t chunk_mask; | ||
40 | |||
41 | struct list_head retry_list; | ||
42 | /* queue pending writes and submit them on unplug */ | ||
43 | struct bio_list pending_bio_list; | ||
44 | |||
45 | |||
46 | spinlock_t resync_lock; | ||
47 | int nr_pending; | ||
48 | int nr_waiting; | ||
49 | int nr_queued; | ||
50 | int barrier; | ||
51 | sector_t next_resync; | ||
52 | int fullsync; /* set to 1 if a full sync is needed, | ||
53 | * (fresh device added). | ||
54 | * Cleared when a sync completes. | ||
55 | */ | ||
56 | |||
57 | wait_queue_head_t wait_barrier; | ||
58 | |||
59 | mempool_t *r10bio_pool; | ||
60 | mempool_t *r10buf_pool; | ||
61 | struct page *tmppage; | ||
62 | }; | ||
63 | |||
64 | typedef struct r10_private_data_s conf_t; | ||
65 | |||
66 | /* | ||
67 | * this is the only point in the RAID code where we violate | ||
68 | * C type safety. mddev->private is an 'opaque' pointer. | ||
69 | */ | ||
70 | #define mddev_to_conf(mddev) ((conf_t *) mddev->private) | ||
71 | |||
72 | /* | ||
73 | * this is our 'private' RAID10 bio. | ||
74 | * | ||
75 | * it contains information about what kind of IO operations were started | ||
76 | * for this RAID10 operation, and about their status: | ||
77 | */ | ||
78 | |||
79 | struct r10bio_s { | ||
80 | atomic_t remaining; /* 'have we finished' count, | ||
81 | * used from IRQ handlers | ||
82 | */ | ||
83 | sector_t sector; /* virtual sector number */ | ||
84 | int sectors; | ||
85 | unsigned long state; | ||
86 | mddev_t *mddev; | ||
87 | /* | ||
88 | * original bio going to /dev/mdx | ||
89 | */ | ||
90 | struct bio *master_bio; | ||
91 | /* | ||
92 | * if the IO is in READ direction, then this is where we read | ||
93 | */ | ||
94 | int read_slot; | ||
95 | |||
96 | struct list_head retry_list; | ||
97 | /* | ||
98 | * if the IO is in WRITE direction, then multiple bios are used, | ||
99 | * one for each copy. | ||
100 | * When resyncing we also use one for each copy. | ||
101 | * When reconstructing, we use 2 bios, one for read, one for write. | ||
102 | * We choose the number when they are allocated. | ||
103 | */ | ||
104 | struct { | ||
105 | struct bio *bio; | ||
106 | sector_t addr; | ||
107 | int devnum; | ||
108 | } devs[0]; | ||
109 | }; | ||
110 | |||
111 | /* when we get a read error on a read-only array, we redirect to another | ||
112 | * device without failing the first device, or trying to over-write to | ||
113 | * correct the read error. To keep track of bad blocks on a per-bio | ||
114 | * level, we store IO_BLOCKED in the appropriate 'bios' pointer | ||
115 | */ | ||
116 | #define IO_BLOCKED ((struct bio*)1) | ||
117 | |||
118 | /* bits for r10bio.state */ | ||
119 | #define R10BIO_Uptodate 0 | ||
120 | #define R10BIO_IsSync 1 | ||
121 | #define R10BIO_IsRecover 2 | ||
122 | #define R10BIO_Degraded 3 | ||
123 | #endif | ||
diff --git a/include/linux/raid/raid5.h b/include/linux/raid/raid5.h deleted file mode 100644 index 3b2672792457..000000000000 --- a/include/linux/raid/raid5.h +++ /dev/null | |||
@@ -1,402 +0,0 @@ | |||
1 | #ifndef _RAID5_H | ||
2 | #define _RAID5_H | ||
3 | |||
4 | #include <linux/raid/md.h> | ||
5 | #include <linux/raid/xor.h> | ||
6 | |||
7 | /* | ||
8 | * | ||
9 | * Each stripe contains one buffer per disc. Each buffer can be in | ||
10 | * one of a number of states stored in "flags". Changes between | ||
11 | * these states happen *almost* exclusively under a per-stripe | ||
12 | * spinlock. Some very specific changes can happen in bi_end_io, and | ||
13 | * these are not protected by the spin lock. | ||
14 | * | ||
15 | * The flag bits that are used to represent these states are: | ||
16 | * R5_UPTODATE and R5_LOCKED | ||
17 | * | ||
18 | * State Empty == !UPTODATE, !LOCK | ||
19 | * We have no data, and there is no active request | ||
20 | * State Want == !UPTODATE, LOCK | ||
21 | * A read request is being submitted for this block | ||
22 | * State Dirty == UPTODATE, LOCK | ||
23 | * Some new data is in this buffer, and it is being written out | ||
24 | * State Clean == UPTODATE, !LOCK | ||
25 | * We have valid data which is the same as on disc | ||
26 | * | ||
27 | * The possible state transitions are: | ||
28 | * | ||
29 | * Empty -> Want - on read or write to get old data for parity calc | ||
30 | * Empty -> Dirty - on compute_parity to satisfy write/sync request.(RECONSTRUCT_WRITE) | ||
31 | * Empty -> Clean - on compute_block when computing a block for failed drive | ||
32 | * Want -> Empty - on failed read | ||
33 | * Want -> Clean - on successful completion of read request | ||
34 | * Dirty -> Clean - on successful completion of write request | ||
35 | * Dirty -> Clean - on failed write | ||
36 | * Clean -> Dirty - on compute_parity to satisfy write/sync (RECONSTRUCT or RMW) | ||
37 | * | ||
38 | * The Want->Empty, Want->Clean, Dirty->Clean, transitions | ||
39 | * all happen in b_end_io at interrupt time. | ||
40 | * Each sets the Uptodate bit before releasing the Lock bit. | ||
41 | * This leaves one multi-stage transition: | ||
42 | * Want->Dirty->Clean | ||
43 | * This is safe because thinking that a Clean buffer is actually dirty | ||
44 | * will at worst delay some action, and the stripe will be scheduled | ||
45 | * for attention after the transition is complete. | ||
46 | * | ||
47 | * There is one possibility that is not covered by these states. That | ||
48 | * is if one drive has failed and there is a spare being rebuilt. We | ||
49 | * can't distinguish between a clean block that has been generated | ||
50 | * from parity calculations, and a clean block that has been | ||
51 | * successfully written to the spare ( or to parity when resyncing). | ||
52 | * To distingush these states we have a stripe bit STRIPE_INSYNC that | ||
53 | * is set whenever a write is scheduled to the spare, or to the parity | ||
54 | * disc if there is no spare. A sync request clears this bit, and | ||
55 | * when we find it set with no buffers locked, we know the sync is | ||
56 | * complete. | ||
57 | * | ||
58 | * Buffers for the md device that arrive via make_request are attached | ||
59 | * to the appropriate stripe in one of two lists linked on b_reqnext. | ||
60 | * One list (bh_read) for read requests, one (bh_write) for write. | ||
61 | * There should never be more than one buffer on the two lists | ||
62 | * together, but we are not guaranteed of that so we allow for more. | ||
63 | * | ||
64 | * If a buffer is on the read list when the associated cache buffer is | ||
65 | * Uptodate, the data is copied into the read buffer and it's b_end_io | ||
66 | * routine is called. This may happen in the end_request routine only | ||
67 | * if the buffer has just successfully been read. end_request should | ||
68 | * remove the buffers from the list and then set the Uptodate bit on | ||
69 | * the buffer. Other threads may do this only if they first check | ||
70 | * that the Uptodate bit is set. Once they have checked that they may | ||
71 | * take buffers off the read queue. | ||
72 | * | ||
73 | * When a buffer on the write list is committed for write it is copied | ||
74 | * into the cache buffer, which is then marked dirty, and moved onto a | ||
75 | * third list, the written list (bh_written). Once both the parity | ||
76 | * block and the cached buffer are successfully written, any buffer on | ||
77 | * a written list can be returned with b_end_io. | ||
78 | * | ||
79 | * The write list and read list both act as fifos. The read list is | ||
80 | * protected by the device_lock. The write and written lists are | ||
81 | * protected by the stripe lock. The device_lock, which can be | ||
82 | * claimed while the stipe lock is held, is only for list | ||
83 | * manipulations and will only be held for a very short time. It can | ||
84 | * be claimed from interrupts. | ||
85 | * | ||
86 | * | ||
87 | * Stripes in the stripe cache can be on one of two lists (or on | ||
88 | * neither). The "inactive_list" contains stripes which are not | ||
89 | * currently being used for any request. They can freely be reused | ||
90 | * for another stripe. The "handle_list" contains stripes that need | ||
91 | * to be handled in some way. Both of these are fifo queues. Each | ||
92 | * stripe is also (potentially) linked to a hash bucket in the hash | ||
93 | * table so that it can be found by sector number. Stripes that are | ||
94 | * not hashed must be on the inactive_list, and will normally be at | ||
95 | * the front. All stripes start life this way. | ||
96 | * | ||
97 | * The inactive_list, handle_list and hash bucket lists are all protected by the | ||
98 | * device_lock. | ||
99 | * - stripes on the inactive_list never have their stripe_lock held. | ||
100 | * - stripes have a reference counter. If count==0, they are on a list. | ||
101 | * - If a stripe might need handling, STRIPE_HANDLE is set. | ||
102 | * - When refcount reaches zero, then if STRIPE_HANDLE it is put on | ||
103 | * handle_list else inactive_list | ||
104 | * | ||
105 | * This, combined with the fact that STRIPE_HANDLE is only ever | ||
106 | * cleared while a stripe has a non-zero count means that if the | ||
107 | * refcount is 0 and STRIPE_HANDLE is set, then it is on the | ||
108 | * handle_list and if recount is 0 and STRIPE_HANDLE is not set, then | ||
109 | * the stripe is on inactive_list. | ||
110 | * | ||
111 | * The possible transitions are: | ||
112 | * activate an unhashed/inactive stripe (get_active_stripe()) | ||
113 | * lockdev check-hash unlink-stripe cnt++ clean-stripe hash-stripe unlockdev | ||
114 | * activate a hashed, possibly active stripe (get_active_stripe()) | ||
115 | * lockdev check-hash if(!cnt++)unlink-stripe unlockdev | ||
116 | * attach a request to an active stripe (add_stripe_bh()) | ||
117 | * lockdev attach-buffer unlockdev | ||
118 | * handle a stripe (handle_stripe()) | ||
119 | * lockstripe clrSTRIPE_HANDLE ... | ||
120 | * (lockdev check-buffers unlockdev) .. | ||
121 | * change-state .. | ||
122 | * record io/ops needed unlockstripe schedule io/ops | ||
123 | * release an active stripe (release_stripe()) | ||
124 | * lockdev if (!--cnt) { if STRIPE_HANDLE, add to handle_list else add to inactive-list } unlockdev | ||
125 | * | ||
126 | * The refcount counts each thread that have activated the stripe, | ||
127 | * plus raid5d if it is handling it, plus one for each active request | ||
128 | * on a cached buffer, and plus one if the stripe is undergoing stripe | ||
129 | * operations. | ||
130 | * | ||
131 | * Stripe operations are performed outside the stripe lock, | ||
132 | * the stripe operations are: | ||
133 | * -copying data between the stripe cache and user application buffers | ||
134 | * -computing blocks to save a disk access, or to recover a missing block | ||
135 | * -updating the parity on a write operation (reconstruct write and | ||
136 | * read-modify-write) | ||
137 | * -checking parity correctness | ||
138 | * -running i/o to disk | ||
139 | * These operations are carried out by raid5_run_ops which uses the async_tx | ||
140 | * api to (optionally) offload operations to dedicated hardware engines. | ||
141 | * When requesting an operation handle_stripe sets the pending bit for the | ||
142 | * operation and increments the count. raid5_run_ops is then run whenever | ||
143 | * the count is non-zero. | ||
144 | * There are some critical dependencies between the operations that prevent some | ||
145 | * from being requested while another is in flight. | ||
146 | * 1/ Parity check operations destroy the in cache version of the parity block, | ||
147 | * so we prevent parity dependent operations like writes and compute_blocks | ||
148 | * from starting while a check is in progress. Some dma engines can perform | ||
149 | * the check without damaging the parity block, in these cases the parity | ||
150 | * block is re-marked up to date (assuming the check was successful) and is | ||
151 | * not re-read from disk. | ||
152 | * 2/ When a write operation is requested we immediately lock the affected | ||
153 | * blocks, and mark them as not up to date. This causes new read requests | ||
154 | * to be held off, as well as parity checks and compute block operations. | ||
155 | * 3/ Once a compute block operation has been requested handle_stripe treats | ||
156 | * that block as if it is up to date. raid5_run_ops guaruntees that any | ||
157 | * operation that is dependent on the compute block result is initiated after | ||
158 | * the compute block completes. | ||
159 | */ | ||
160 | |||
161 | /* | ||
162 | * Operations state - intermediate states that are visible outside of sh->lock | ||
163 | * In general _idle indicates nothing is running, _run indicates a data | ||
164 | * processing operation is active, and _result means the data processing result | ||
165 | * is stable and can be acted upon. For simple operations like biofill and | ||
166 | * compute that only have an _idle and _run state they are indicated with | ||
167 | * sh->state flags (STRIPE_BIOFILL_RUN and STRIPE_COMPUTE_RUN) | ||
168 | */ | ||
169 | /** | ||
170 | * enum check_states - handles syncing / repairing a stripe | ||
171 | * @check_state_idle - check operations are quiesced | ||
172 | * @check_state_run - check operation is running | ||
173 | * @check_state_result - set outside lock when check result is valid | ||
174 | * @check_state_compute_run - check failed and we are repairing | ||
175 | * @check_state_compute_result - set outside lock when compute result is valid | ||
176 | */ | ||
177 | enum check_states { | ||
178 | check_state_idle = 0, | ||
179 | check_state_run, /* parity check */ | ||
180 | check_state_check_result, | ||
181 | check_state_compute_run, /* parity repair */ | ||
182 | check_state_compute_result, | ||
183 | }; | ||
184 | |||
185 | /** | ||
186 | * enum reconstruct_states - handles writing or expanding a stripe | ||
187 | */ | ||
188 | enum reconstruct_states { | ||
189 | reconstruct_state_idle = 0, | ||
190 | reconstruct_state_prexor_drain_run, /* prexor-write */ | ||
191 | reconstruct_state_drain_run, /* write */ | ||
192 | reconstruct_state_run, /* expand */ | ||
193 | reconstruct_state_prexor_drain_result, | ||
194 | reconstruct_state_drain_result, | ||
195 | reconstruct_state_result, | ||
196 | }; | ||
197 | |||
198 | struct stripe_head { | ||
199 | struct hlist_node hash; | ||
200 | struct list_head lru; /* inactive_list or handle_list */ | ||
201 | struct raid5_private_data *raid_conf; | ||
202 | sector_t sector; /* sector of this row */ | ||
203 | int pd_idx; /* parity disk index */ | ||
204 | unsigned long state; /* state flags */ | ||
205 | atomic_t count; /* nr of active thread/requests */ | ||
206 | spinlock_t lock; | ||
207 | int bm_seq; /* sequence number for bitmap flushes */ | ||
208 | int disks; /* disks in stripe */ | ||
209 | enum check_states check_state; | ||
210 | enum reconstruct_states reconstruct_state; | ||
211 | /* stripe_operations | ||
212 | * @target - STRIPE_OP_COMPUTE_BLK target | ||
213 | */ | ||
214 | struct stripe_operations { | ||
215 | int target; | ||
216 | u32 zero_sum_result; | ||
217 | } ops; | ||
218 | struct r5dev { | ||
219 | struct bio req; | ||
220 | struct bio_vec vec; | ||
221 | struct page *page; | ||
222 | struct bio *toread, *read, *towrite, *written; | ||
223 | sector_t sector; /* sector of this page */ | ||
224 | unsigned long flags; | ||
225 | } dev[1]; /* allocated with extra space depending of RAID geometry */ | ||
226 | }; | ||
227 | |||
228 | /* stripe_head_state - collects and tracks the dynamic state of a stripe_head | ||
229 | * for handle_stripe. It is only valid under spin_lock(sh->lock); | ||
230 | */ | ||
231 | struct stripe_head_state { | ||
232 | int syncing, expanding, expanded; | ||
233 | int locked, uptodate, to_read, to_write, failed, written; | ||
234 | int to_fill, compute, req_compute, non_overwrite; | ||
235 | int failed_num; | ||
236 | unsigned long ops_request; | ||
237 | }; | ||
238 | |||
239 | /* r6_state - extra state data only relevant to r6 */ | ||
240 | struct r6_state { | ||
241 | int p_failed, q_failed, qd_idx, failed_num[2]; | ||
242 | }; | ||
243 | |||
244 | /* Flags */ | ||
245 | #define R5_UPTODATE 0 /* page contains current data */ | ||
246 | #define R5_LOCKED 1 /* IO has been submitted on "req" */ | ||
247 | #define R5_OVERWRITE 2 /* towrite covers whole page */ | ||
248 | /* and some that are internal to handle_stripe */ | ||
249 | #define R5_Insync 3 /* rdev && rdev->in_sync at start */ | ||
250 | #define R5_Wantread 4 /* want to schedule a read */ | ||
251 | #define R5_Wantwrite 5 | ||
252 | #define R5_Overlap 7 /* There is a pending overlapping request on this block */ | ||
253 | #define R5_ReadError 8 /* seen a read error here recently */ | ||
254 | #define R5_ReWrite 9 /* have tried to over-write the readerror */ | ||
255 | |||
256 | #define R5_Expanded 10 /* This block now has post-expand data */ | ||
257 | #define R5_Wantcompute 11 /* compute_block in progress treat as | ||
258 | * uptodate | ||
259 | */ | ||
260 | #define R5_Wantfill 12 /* dev->toread contains a bio that needs | ||
261 | * filling | ||
262 | */ | ||
263 | #define R5_Wantdrain 13 /* dev->towrite needs to be drained */ | ||
264 | /* | ||
265 | * Write method | ||
266 | */ | ||
267 | #define RECONSTRUCT_WRITE 1 | ||
268 | #define READ_MODIFY_WRITE 2 | ||
269 | /* not a write method, but a compute_parity mode */ | ||
270 | #define CHECK_PARITY 3 | ||
271 | |||
272 | /* | ||
273 | * Stripe state | ||
274 | */ | ||
275 | #define STRIPE_HANDLE 2 | ||
276 | #define STRIPE_SYNCING 3 | ||
277 | #define STRIPE_INSYNC 4 | ||
278 | #define STRIPE_PREREAD_ACTIVE 5 | ||
279 | #define STRIPE_DELAYED 6 | ||
280 | #define STRIPE_DEGRADED 7 | ||
281 | #define STRIPE_BIT_DELAY 8 | ||
282 | #define STRIPE_EXPANDING 9 | ||
283 | #define STRIPE_EXPAND_SOURCE 10 | ||
284 | #define STRIPE_EXPAND_READY 11 | ||
285 | #define STRIPE_IO_STARTED 12 /* do not count towards 'bypass_count' */ | ||
286 | #define STRIPE_FULL_WRITE 13 /* all blocks are set to be overwritten */ | ||
287 | #define STRIPE_BIOFILL_RUN 14 | ||
288 | #define STRIPE_COMPUTE_RUN 15 | ||
289 | /* | ||
290 | * Operation request flags | ||
291 | */ | ||
292 | #define STRIPE_OP_BIOFILL 0 | ||
293 | #define STRIPE_OP_COMPUTE_BLK 1 | ||
294 | #define STRIPE_OP_PREXOR 2 | ||
295 | #define STRIPE_OP_BIODRAIN 3 | ||
296 | #define STRIPE_OP_POSTXOR 4 | ||
297 | #define STRIPE_OP_CHECK 5 | ||
298 | |||
299 | /* | ||
300 | * Plugging: | ||
301 | * | ||
302 | * To improve write throughput, we need to delay the handling of some | ||
303 | * stripes until there has been a chance that several write requests | ||
304 | * for the one stripe have all been collected. | ||
305 | * In particular, any write request that would require pre-reading | ||
306 | * is put on a "delayed" queue until there are no stripes currently | ||
307 | * in a pre-read phase. Further, if the "delayed" queue is empty when | ||
308 | * a stripe is put on it then we "plug" the queue and do not process it | ||
309 | * until an unplug call is made. (the unplug_io_fn() is called). | ||
310 | * | ||
311 | * When preread is initiated on a stripe, we set PREREAD_ACTIVE and add | ||
312 | * it to the count of prereading stripes. | ||
313 | * When write is initiated, or the stripe refcnt == 0 (just in case) we | ||
314 | * clear the PREREAD_ACTIVE flag and decrement the count | ||
315 | * Whenever the 'handle' queue is empty and the device is not plugged, we | ||
316 | * move any strips from delayed to handle and clear the DELAYED flag and set | ||
317 | * PREREAD_ACTIVE. | ||
318 | * In stripe_handle, if we find pre-reading is necessary, we do it if | ||
319 | * PREREAD_ACTIVE is set, else we set DELAYED which will send it to the delayed queue. | ||
320 | * HANDLE gets cleared if stripe_handle leave nothing locked. | ||
321 | */ | ||
322 | |||
323 | |||
324 | struct disk_info { | ||
325 | mdk_rdev_t *rdev; | ||
326 | }; | ||
327 | |||
328 | struct raid5_private_data { | ||
329 | struct hlist_head *stripe_hashtbl; | ||
330 | mddev_t *mddev; | ||
331 | struct disk_info *spare; | ||
332 | int chunk_size, level, algorithm; | ||
333 | int max_degraded; | ||
334 | int raid_disks; | ||
335 | int max_nr_stripes; | ||
336 | |||
337 | /* used during an expand */ | ||
338 | sector_t expand_progress; /* MaxSector when no expand happening */ | ||
339 | sector_t expand_lo; /* from here up to expand_progress it out-of-bounds | ||
340 | * as we haven't flushed the metadata yet | ||
341 | */ | ||
342 | int previous_raid_disks; | ||
343 | |||
344 | struct list_head handle_list; /* stripes needing handling */ | ||
345 | struct list_head hold_list; /* preread ready stripes */ | ||
346 | struct list_head delayed_list; /* stripes that have plugged requests */ | ||
347 | struct list_head bitmap_list; /* stripes delaying awaiting bitmap update */ | ||
348 | struct bio *retry_read_aligned; /* currently retrying aligned bios */ | ||
349 | struct bio *retry_read_aligned_list; /* aligned bios retry list */ | ||
350 | atomic_t preread_active_stripes; /* stripes with scheduled io */ | ||
351 | atomic_t active_aligned_reads; | ||
352 | atomic_t pending_full_writes; /* full write backlog */ | ||
353 | int bypass_count; /* bypassed prereads */ | ||
354 | int bypass_threshold; /* preread nice */ | ||
355 | struct list_head *last_hold; /* detect hold_list promotions */ | ||
356 | |||
357 | atomic_t reshape_stripes; /* stripes with pending writes for reshape */ | ||
358 | /* unfortunately we need two cache names as we temporarily have | ||
359 | * two caches. | ||
360 | */ | ||
361 | int active_name; | ||
362 | char cache_name[2][20]; | ||
363 | struct kmem_cache *slab_cache; /* for allocating stripes */ | ||
364 | |||
365 | int seq_flush, seq_write; | ||
366 | int quiesce; | ||
367 | |||
368 | int fullsync; /* set to 1 if a full sync is needed, | ||
369 | * (fresh device added). | ||
370 | * Cleared when a sync completes. | ||
371 | */ | ||
372 | |||
373 | struct page *spare_page; /* Used when checking P/Q in raid6 */ | ||
374 | |||
375 | /* | ||
376 | * Free stripes pool | ||
377 | */ | ||
378 | atomic_t active_stripes; | ||
379 | struct list_head inactive_list; | ||
380 | wait_queue_head_t wait_for_stripe; | ||
381 | wait_queue_head_t wait_for_overlap; | ||
382 | int inactive_blocked; /* release of inactive stripes blocked, | ||
383 | * waiting for 25% to be free | ||
384 | */ | ||
385 | int pool_size; /* number of disks in stripeheads in pool */ | ||
386 | spinlock_t device_lock; | ||
387 | struct disk_info *disks; | ||
388 | }; | ||
389 | |||
390 | typedef struct raid5_private_data raid5_conf_t; | ||
391 | |||
392 | #define mddev_to_conf(mddev) ((raid5_conf_t *) mddev->private) | ||
393 | |||
394 | /* | ||
395 | * Our supported algorithms | ||
396 | */ | ||
397 | #define ALGORITHM_LEFT_ASYMMETRIC 0 | ||
398 | #define ALGORITHM_RIGHT_ASYMMETRIC 1 | ||
399 | #define ALGORITHM_LEFT_SYMMETRIC 2 | ||
400 | #define ALGORITHM_RIGHT_SYMMETRIC 3 | ||
401 | |||
402 | #endif | ||
diff --git a/include/linux/raid/xor.h b/include/linux/raid/xor.h index 3e120587eada..5a210959e3f8 100644 --- a/include/linux/raid/xor.h +++ b/include/linux/raid/xor.h | |||
@@ -1,8 +1,6 @@ | |||
1 | #ifndef _XOR_H | 1 | #ifndef _XOR_H |
2 | #define _XOR_H | 2 | #define _XOR_H |
3 | 3 | ||
4 | #include <linux/raid/md.h> | ||
5 | |||
6 | #define MAX_XOR_BLOCKS 4 | 4 | #define MAX_XOR_BLOCKS 4 |
7 | 5 | ||
8 | extern void xor_blocks(unsigned int count, unsigned int bytes, | 6 | extern void xor_blocks(unsigned int count, unsigned int bytes, |