1 /*
2 * raid1.c : Multiple Devices driver for Linux
3 *
4 * Copyright (C) 1999, 2000, 2001 Ingo Molnar, Red Hat
5 *
6 * Copyright (C) 1996, 1997, 1998 Ingo Molnar, Miguel de Icaza, Gadi Oxman
7 *
8 * RAID-1 management functions.
9 *
10 * Better read-balancing code written by Mika Kuoppala <miku@iki.fi>, 2000
11 *
12 * Fixes to reconstruction by Jakob Østergaard" <jakob@ostenfeld.dk>
13 * Various fixes by Neil Brown <neilb@cse.unsw.edu.au>
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2, or (at your option)
18 * any later version.
19 *
20 * You should have received a copy of the GNU General Public License
21 * (for example /usr/src/linux/COPYING); if not, write to the Free
22 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */
24
25 #include <linux/raid/raid1.h>
26
27 /*
28 * Number of guaranteed r1bios in case of extreme VM load:
29 */
30 #define NR_RAID1_BIOS 256
31
32 static mdk_personality_t raid1_personality;
33
34 static void unplug_slaves(mddev_t *mddev);
35
36
37 static void * r1bio_pool_alloc(int gfp_flags, void *data)
38 {
39 struct pool_info *pi = data;
40 r1bio_t *r1_bio;
41 int size = offsetof(r1bio_t, bios[pi->raid_disks]);
42
43 /* allocate a r1bio with room for raid_disks entries in the bios array */
44 r1_bio = kmalloc(size, gfp_flags);
45 if (r1_bio)
46 memset(r1_bio, 0, size);
47 else
48 unplug_slaves(pi->mddev);
49
50 return r1_bio;
51 }
52
53 static void r1bio_pool_free(void *r1_bio, void *data)
54 {
55 kfree(r1_bio);
56 }
57
58 #define RESYNC_BLOCK_SIZE (64*1024)
59 //#define RESYNC_BLOCK_SIZE PAGE_SIZE
60 #define RESYNC_SECTORS (RESYNC_BLOCK_SIZE >> 9)
61 #define RESYNC_PAGES ((RESYNC_BLOCK_SIZE + PAGE_SIZE-1) / PAGE_SIZE)
62 #define RESYNC_WINDOW (2048*1024)
63
64 static void * r1buf_pool_alloc(int gfp_flags, void *data)
65 {
66 struct pool_info *pi = data;
67 struct page *page;
68 r1bio_t *r1_bio;
69 struct bio *bio;
70 int i, j;
71
72 r1_bio = r1bio_pool_alloc(gfp_flags, pi);
73 if (!r1_bio) {
74 unplug_slaves(pi->mddev);
75 return NULL;
76 }
77
78 /*
79 * Allocate bios : 1 for reading, n-1 for writing
80 */
81 for (j = pi->raid_disks ; j-- ; ) {
82 bio = bio_alloc(gfp_flags, RESYNC_PAGES);
83 if (!bio)
84 goto out_free_bio;
85 r1_bio->bios[j] = bio;
86 }
87 /*
88 * Allocate RESYNC_PAGES data pages and attach them to
89 * the first bio;
90 */
91 bio = r1_bio->bios[0];
92 for (i = 0; i < RESYNC_PAGES; i++) {
93 page = alloc_page(gfp_flags);
94 if (unlikely(!page))
95 goto out_free_pages;
96
97 bio->bi_io_vec[i].bv_page = page;
98 }
99
100 r1_bio->master_bio = NULL;
101
102 return r1_bio;
103
104 out_free_pages:
105 for ( ; i > 0 ; i--)
106 __free_page(bio->bi_io_vec[i-1].bv_page);
107 out_free_bio:
108 while ( ++j < pi->raid_disks )
109 bio_put(r1_bio->bios[j]);
110 r1bio_pool_free(r1_bio, data);
111 return NULL;
112 }
113
114 static void r1buf_pool_free(void *__r1_bio, void *data)
115 {
116 struct pool_info *pi = data;
117 int i;
118 r1bio_t *r1bio = __r1_bio;
119 struct bio *bio = r1bio->bios[0];
120
121 for (i = 0; i < RESYNC_PAGES; i++) {
122 __free_page(bio->bi_io_vec[i].bv_page);
123 bio->bi_io_vec[i].bv_page = NULL;
124 }
125 for (i=0 ; i < pi->raid_disks; i++)
126 bio_put(r1bio->bios[i]);
127
128 r1bio_pool_free(r1bio, data);
129 }
130
131 static void put_all_bios(conf_t *conf, r1bio_t *r1_bio)
132 {
133 int i;
134
135 for (i = 0; i < conf->raid_disks; i++) {
136 struct bio **bio = r1_bio->bios + i;
137 if (*bio)
138 bio_put(*bio);
139 *bio = NULL;
140 }
141 }
142
143 static inline void free_r1bio(r1bio_t *r1_bio)
144 {
145 unsigned long flags;
146
147 conf_t *conf = mddev_to_conf(r1_bio->mddev);
148
149 /*
150 * Wake up any possible resync thread that waits for the device
151 * to go idle.
152 */
153 spin_lock_irqsave(&conf->resync_lock, flags);
154 if (!--conf->nr_pending) {
155 wake_up(&conf->wait_idle);
156 wake_up(&conf->wait_resume);
157 }
158 spin_unlock_irqrestore(&conf->resync_lock, flags);
159
160 put_all_bios(conf, r1_bio);
161 mempool_free(r1_bio, conf->r1bio_pool);
162 }
163
164 static inline void put_buf(r1bio_t *r1_bio)
165 {
166 conf_t *conf = mddev_to_conf(r1_bio->mddev);
167 unsigned long flags;
168
169 mempool_free(r1_bio, conf->r1buf_pool);
170
171 spin_lock_irqsave(&conf->resync_lock, flags);
172 if (!conf->barrier)
173 BUG();
174 --conf->barrier;
175 wake_up(&conf->wait_resume);
176 wake_up(&conf->wait_idle);
177
178 if (!--conf->nr_pending) {
179 wake_up(&conf->wait_idle);
180 wake_up(&conf->wait_resume);
181 }
182 spin_unlock_irqrestore(&conf->resync_lock, flags);
183 }
184
185 static void reschedule_retry(r1bio_t *r1_bio)
186 {
187 unsigned long flags;
188 mddev_t *mddev = r1_bio->mddev;
189 conf_t *conf = mddev_to_conf(mddev);
190
191 spin_lock_irqsave(&conf->device_lock, flags);
192 list_add(&r1_bio->retry_list, &conf->retry_list);
193 spin_unlock_irqrestore(&conf->device_lock, flags);
194
195 md_wakeup_thread(mddev->thread);
196 }
197
198 /*
199 * raid_end_bio_io() is called when we have finished servicing a mirrored
200 * operation and are ready to return a success/failure code to the buffer
201 * cache layer.
202 */
203 static void raid_end_bio_io(r1bio_t *r1_bio)
204 {
205 struct bio *bio = r1_bio->master_bio;
206
207 bio_endio(bio, bio->bi_size,
208 test_bit(R1BIO_Uptodate, &r1_bio->state) ? 0 : -EIO);
209 free_r1bio(r1_bio);
210 }
211
212 /*
213 * Update disk head position estimator based on IRQ completion info.
214 */
215 static inline void update_head_pos(int disk, r1bio_t *r1_bio)
216 {
217 conf_t *conf = mddev_to_conf(r1_bio->mddev);
218
219 conf->mirrors[disk].head_position =
220 r1_bio->sector + (r1_bio->sectors);
221 }
222
223 static int raid1_end_read_request(struct bio *bio, unsigned int bytes_done, int error)
224 {
225 int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
226 r1bio_t * r1_bio = (r1bio_t *)(bio->bi_private);
227 int mirror;
228 conf_t *conf = mddev_to_conf(r1_bio->mddev);
229
230 if (bio->bi_size)
231 return 1;
232
233 mirror = r1_bio->read_disk;
234 /*
235 * this branch is our 'one mirror IO has finished' event handler:
236 */
237 if (!uptodate)
238 md_error(r1_bio->mddev, conf->mirrors[mirror].rdev);
239 else
240 /*
241 * Set R1BIO_Uptodate in our master bio, so that
242 * we will return a good error code for to the higher
243 * levels even if IO on some other mirrored buffer fails.
244 *
245 * The 'master' represents the composite IO operation to
246 * user-side. So if something waits for IO, then it will
247 * wait for the 'master' bio.
248 */
249 set_bit(R1BIO_Uptodate, &r1_bio->state);
250
251 update_head_pos(mirror, r1_bio);
252
253 /*
254 * we have only one bio on the read side
255 */
256 if (uptodate)
257 raid_end_bio_io(r1_bio);
258 else {
259 /*
260 * oops, read error:
261 */
262 char b[BDEVNAME_SIZE];
263 if (printk_ratelimit())
264 printk(KERN_ERR "raid1: %s: rescheduling sector %llu\n",
265 bdevname(conf->mirrors[mirror].rdev->bdev,b), (unsigned long long)r1_bio->sector);
266 reschedule_retry(r1_bio);
267 }
268
269 rdev_dec_pending(conf->mirrors[mirror].rdev, conf->mddev);
270 return 0;
271 }
272
273 static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int error)
274 {
275 int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
276 r1bio_t * r1_bio = (r1bio_t *)(bio->bi_private);
277 int mirror;
278 conf_t *conf = mddev_to_conf(r1_bio->mddev);
279
280 if (bio->bi_size)
281 return 1;
282
283 for (mirror = 0; mirror < conf->raid_disks; mirror++)
284 if (r1_bio->bios[mirror] == bio)
285 break;
286
287 /*
288 * this branch is our 'one mirror IO has finished' event handler:
289 */
290 if (!uptodate)
291 md_error(r1_bio->mddev, conf->mirrors[mirror].rdev);
292 else
293 /*
294 * Set R1BIO_Uptodate in our master bio, so that
295 * we will return a good error code for to the higher
296 * levels even if IO on some other mirrored buffer fails.
297 *
298 * The 'master' represents the composite IO operation to
299 * user-side. So if something waits for IO, then it will
300 * wait for the 'master' bio.
301 */
302 set_bit(R1BIO_Uptodate, &r1_bio->state);
303
304 update_head_pos(mirror, r1_bio);
305
306 /*
307 *
308 * Let's see if all mirrored write operations have finished
309 * already.
310 */
311 if (atomic_dec_and_test(&r1_bio->remaining)) {
312 md_write_end(r1_bio->mddev);
313 raid_end_bio_io(r1_bio);
314 }
315
316 rdev_dec_pending(conf->mirrors[mirror].rdev, conf->mddev);
317 return 0;
318 }
319
320
321 /*
322 * This routine returns the disk from which the requested read should
323 * be done. There is a per-array 'next expected sequential IO' sector
324 * number - if this matches on the next IO then we use the last disk.
325 * There is also a per-disk 'last know head position' sector that is
326 * maintained from IRQ contexts, both the normal and the resync IO
327 * completion handlers update this position correctly. If there is no
328 * perfect sequential match then we pick the disk whose head is closest.
329 *
330 * If there are 2 mirrors in the same 2 devices, performance degrades
331 * because position is mirror, not device based.
332 *
333 * The rdev for the device selected will have nr_pending incremented.
334 */
335 static int read_balance(conf_t *conf, r1bio_t *r1_bio)
336 {
337 const unsigned long this_sector = r1_bio->sector;
338 int new_disk = conf->last_used, disk = new_disk;
339 const int sectors = r1_bio->sectors;
340 sector_t new_distance, current_distance;
341
342 rcu_read_lock();
343 /*
344 * Check if it if we can balance. We can balance on the whole
345 * device if no resync is going on, or below the resync window.
346 * We take the first readable disk when above the resync window.
347 */
348 if (conf->mddev->recovery_cp < MaxSector &&
349 (this_sector + sectors >= conf->next_resync)) {
350 /* Choose the first operation device, for consistancy */
351 new_disk = 0;
352
353 while (!conf->mirrors[new_disk].rdev ||
354 !conf->mirrors[new_disk].rdev->in_sync) {
355 new_disk++;
356 if (new_disk == conf->raid_disks) {
357 new_disk = -1;
358 break;
359 }
360 }
361 goto rb_out;
362 }
363
364
365 /* make sure the disk is operational */
366 while (!conf->mirrors[new_disk].rdev ||
367 !conf->mirrors[new_disk].rdev->in_sync) {
368 if (new_disk <= 0)
369 new_disk = conf->raid_disks;
370 new_disk--;
371 if (new_disk == disk) {
372 new_disk = -1;
373 goto rb_out;
374 }
375 }
376 disk = new_disk;
377 /* now disk == new_disk == starting point for search */
378
379 /*
380 * Don't change to another disk for sequential reads:
381 */
382 if (conf->next_seq_sect == this_sector)
383 goto rb_out;
384 if (this_sector == conf->mirrors[new_disk].head_position)
385 goto rb_out;
386
387 current_distance = abs(this_sector - conf->mirrors[disk].head_position);
388
389 /* Find the disk whose head is closest */
390
391 do {
392 if (disk <= 0)
393 disk = conf->raid_disks;
394 disk--;
395
396 if (!conf->mirrors[disk].rdev ||
397 !conf->mirrors[disk].rdev->in_sync)
398 continue;
399
400 if (!atomic_read(&conf->mirrors[disk].rdev->nr_pending)) {
401 new_disk = disk;
402 break;
403 }
404 new_distance = abs(this_sector - conf->mirrors[disk].head_position);
405 if (new_distance < current_distance) {
406 current_distance = new_distance;
407 new_disk = disk;
408 }
409 } while (disk != conf->last_used);
410
411 rb_out:
412
413
414 if (new_disk >= 0) {
415 conf->next_seq_sect = this_sector + sectors;
416 conf->last_used = new_disk;
417 atomic_inc(&conf->mirrors[new_disk].rdev->nr_pending);
418 }
419 rcu_read_unlock();
420
421 return new_disk;
422 }
423
424 static void unplug_slaves(mddev_t *mddev)
425 {
426 conf_t *conf = mddev_to_conf(mddev);
427 int i;
428
429 rcu_read_lock();
430 for (i=0; i<mddev->raid_disks; i++) {
431 mdk_rdev_t *rdev = conf->mirrors[i].rdev;
432 if (rdev && !rdev->faulty && atomic_read(&rdev->nr_pending)) {
433 request_queue_t *r_queue = bdev_get_queue(rdev->bdev);
434
435 atomic_inc(&rdev->nr_pending);
436 rcu_read_unlock();
437
438 if (r_queue->unplug_fn)
439 r_queue->unplug_fn(r_queue);
440
441 rdev_dec_pending(rdev, mddev);
442 rcu_read_lock();
443 }
444 }
445 rcu_read_unlock();
446 }
447
448 static void raid1_unplug(request_queue_t *q)
449 {
450 unplug_slaves(q->queuedata);
451 }
452
453 static int raid1_issue_flush(request_queue_t *q, struct gendisk *disk,
454 sector_t *error_sector)
455 {
456 mddev_t *mddev = q->queuedata;
457 conf_t *conf = mddev_to_conf(mddev);
458 int i, ret = 0;
459
460 rcu_read_lock();
461 for (i=0; i<mddev->raid_disks && ret == 0; i++) {
462 mdk_rdev_t *rdev = conf->mirrors[i].rdev;
463 if (rdev && !rdev->faulty) {
464 struct block_device *bdev = rdev->bdev;
465 request_queue_t *r_queue = bdev_get_queue(bdev);
466
467 if (!r_queue->issue_flush_fn)
468 ret = -EOPNOTSUPP;
469 else {
470 atomic_inc(&rdev->nr_pending);
471 rcu_read_unlock();
472 ret = r_queue->issue_flush_fn(r_queue, bdev->bd_disk,
473 error_sector);
474 rdev_dec_pending(rdev, mddev);
475 rcu_read_lock();
476 }
477 }
478 }
479 rcu_read_unlock();
480 return ret;
481 }
482
483 /*
484 * Throttle resync depth, so that we can both get proper overlapping of
485 * requests, but are still able to handle normal requests quickly.
486 */
487 #define RESYNC_DEPTH 32
488
489 static void device_barrier(conf_t *conf, sector_t sect)
490 {
491 spin_lock_irq(&conf->resync_lock);
492 wait_event_lock_irq(conf->wait_idle, !waitqueue_active(&conf->wait_resume),
493 conf->resync_lock, unplug_slaves(conf->mddev));
494
495 if (!conf->barrier++) {
496 wait_event_lock_irq(conf->wait_idle, !conf->nr_pending,
497 conf->resync_lock, unplug_slaves(conf->mddev));
498 if (conf->nr_pending)
499 BUG();
500 }
501 wait_event_lock_irq(conf->wait_resume, conf->barrier < RESYNC_DEPTH,
502 conf->resync_lock, unplug_slaves(conf->mddev));
503 conf->next_resync = sect;
504 spin_unlock_irq(&conf->resync_lock);
505 }
506
507 static int make_request(request_queue_t *q, struct bio * bio)
508 {
509 mddev_t *mddev = q->queuedata;
510 conf_t *conf = mddev_to_conf(mddev);
511 mirror_info_t *mirror;
512 r1bio_t *r1_bio;
513 struct bio *read_bio;
514 int i, disks;
515
516 /*
517 * Register the new request and wait if the reconstruction
518 * thread has put up a bar for new requests.
519 * Continue immediately if no resync is active currently.
520 */
521 spin_lock_irq(&conf->resync_lock);
522 wait_event_lock_irq(conf->wait_resume, !conf->barrier, conf->resync_lock, );
523 conf->nr_pending++;
524 spin_unlock_irq(&conf->resync_lock);
525
526 if (bio_data_dir(bio)==WRITE) {
527 disk_stat_inc(mddev->gendisk, writes);
528 disk_stat_add(mddev->gendisk, write_sectors, bio_sectors(bio));
529 } else {
530 disk_stat_inc(mddev->gendisk, reads);
531 disk_stat_add(mddev->gendisk, read_sectors, bio_sectors(bio));
532 }
533
534 /*
535 * make_request() can abort the operation when READA is being
536 * used and no empty request is available.
537 *
538 */
539 r1_bio = mempool_alloc(conf->r1bio_pool, GFP_NOIO);
540
541 r1_bio->master_bio = bio;
542 r1_bio->sectors = bio->bi_size >> 9;
543
544 r1_bio->mddev = mddev;
545 r1_bio->sector = bio->bi_sector;
546
547 r1_bio->state = 0;
548
549 if (bio_data_dir(bio) == READ) {
550 /*
551 * read balancing logic:
552 */
553 int rdisk = read_balance(conf, r1_bio);
554
555 if (rdisk < 0) {
556 /* couldn't find anywhere to read from */
557 raid_end_bio_io(r1_bio);
558 return 0;
559 }
560 mirror = conf->mirrors + rdisk;
561
562 r1_bio->read_disk = rdisk;
563
564 read_bio = bio_clone(bio, GFP_NOIO);
565
566 r1_bio->bios[rdisk] = read_bio;
567
568 read_bio->bi_sector = r1_bio->sector + mirror->rdev->data_offset;
569 read_bio->bi_bdev = mirror->rdev->bdev;
570 read_bio->bi_end_io = raid1_end_read_request;
571 read_bio->bi_rw = READ;
572 read_bio->bi_private = r1_bio;
573
574 generic_make_request(read_bio);
575 return 0;
576 }
577
578 /*
579 * WRITE:
580 */
581 /* first select target devices under spinlock and
582 * inc refcount on their rdev. Record them by setting
583 * bios[x] to bio
584 */
585 disks = conf->raid_disks;
586 rcu_read_lock();
587 for (i = 0; i < disks; i++) {
588 if (conf->mirrors[i].rdev &&
589 !conf->mirrors[i].rdev->faulty) {
590 atomic_inc(&conf->mirrors[i].rdev->nr_pending);
591 r1_bio->bios[i] = bio;
592 } else
593 r1_bio->bios[i] = NULL;
594 }
595 rcu_read_unlock();
596
597 atomic_set(&r1_bio->remaining, 1);
598 md_write_start(mddev);
599 for (i = 0; i < disks; i++) {
600 struct bio *mbio;
601 if (!r1_bio->bios[i])
602 continue;
603
604 mbio = bio_clone(bio, GFP_NOIO);
605 r1_bio->bios[i] = mbio;
606
607 mbio->bi_sector = r1_bio->sector + conf->mirrors[i].rdev->data_offset;
608 mbio->bi_bdev = conf->mirrors[i].rdev->bdev;
609 mbio->bi_end_io = raid1_end_write_request;
610 mbio->bi_rw = WRITE;
611 mbio->bi_private = r1_bio;
612
613 atomic_inc(&r1_bio->remaining);
614 generic_make_request(mbio);
615 }
616
617 if (atomic_dec_and_test(&r1_bio->remaining)) {
618 md_write_end(mddev);
619 raid_end_bio_io(r1_bio);
620 }
621
622 return 0;
623 }
624
625 static void status(struct seq_file *seq, mddev_t *mddev)
626 {
627 conf_t *conf = mddev_to_conf(mddev);
628 int i;
629
630 seq_printf(seq, " [%d/%d] [", conf->raid_disks,
631 conf->working_disks);
632 for (i = 0; i < conf->raid_disks; i++)
633 seq_printf(seq, "%s",
634 conf->mirrors[i].rdev &&
635 conf->mirrors[i].rdev->in_sync ? "U" : "_");
636 seq_printf(seq, "]");
637 }
638
639
640 static void error(mddev_t *mddev, mdk_rdev_t *rdev)
641 {
642 char b[BDEVNAME_SIZE];
643 conf_t *conf = mddev_to_conf(mddev);
644
645 /*
646 * If it is not operational, then we have already marked it as dead
647 * else if it is the last working disks, ignore the error, let the
648 * next level up know.
649 * else mark the drive as failed
650 */
651 if (rdev->in_sync
652 && conf->working_disks == 1)
653 /*
654 * Don't fail the drive, act as though we were just a
655 * normal single drive
656 */
657 return;
658 if (rdev->in_sync) {
659 mddev->degraded++;
660 conf->working_disks--;
661 /*
662 * if recovery is running, make sure it aborts.
663 */
664 set_bit(MD_RECOVERY_ERR, &mddev->recovery);
665 }
666 rdev->in_sync = 0;
667 rdev->faulty = 1;
668 mddev->sb_dirty = 1;
669 printk(KERN_ALERT "raid1: Disk failure on %s, disabling device. \n"
670 " Operation continuing on %d devices\n",
671 bdevname(rdev->bdev,b), conf->working_disks);
672 }
673
674 static void print_conf(conf_t *conf)
675 {
676 int i;
677 mirror_info_t *tmp;
678
679 printk("RAID1 conf printout:\n");
680 if (!conf) {
681 printk("(!conf)\n");
682 return;
683 }
684 printk(" --- wd:%d rd:%d\n", conf->working_disks,
685 conf->raid_disks);
686
687 for (i = 0; i < conf->raid_disks; i++) {
688 char b[BDEVNAME_SIZE];
689 tmp = conf->mirrors + i;
690 if (tmp->rdev)
691 printk(" disk %d, wo:%d, o:%d, dev:%s\n",
692 i, !tmp->rdev->in_sync, !tmp->rdev->faulty,
693 bdevname(tmp->rdev->bdev,b));
694 }
695 }
696
697 static void close_sync(conf_t *conf)
698 {
699 spin_lock_irq(&conf->resync_lock);
700 wait_event_lock_irq(conf->wait_resume, !conf->barrier,
701 conf->resync_lock, unplug_slaves(conf->mddev));
702 spin_unlock_irq(&conf->resync_lock);
703
704 if (conf->barrier) BUG();
705 if (waitqueue_active(&conf->wait_idle)) BUG();
706
707 mempool_destroy(conf->r1buf_pool);
708 conf->r1buf_pool = NULL;
709 }
710
711 static int raid1_spare_active(mddev_t *mddev)
712 {
713 int i;
714 conf_t *conf = mddev->private;
715 mirror_info_t *tmp;
716
717 /*
718 * Find all failed disks within the RAID1 configuration
719 * and mark them readable
720 */
721 for (i = 0; i < conf->raid_disks; i++) {
722 tmp = conf->mirrors + i;
723 if (tmp->rdev
724 && !tmp->rdev->faulty
725 && !tmp->rdev->in_sync) {
726 conf->working_disks++;
727 mddev->degraded--;
728 tmp->rdev->in_sync = 1;
729 }
730 }
731
732 print_conf(conf);
733 return 0;
734 }
735
736
737 static int raid1_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
738 {
739 conf_t *conf = mddev->private;
740 int found = 0;
741 int mirror;
742 mirror_info_t *p;
743
744 for (mirror=0; mirror < mddev->raid_disks; mirror++)
745 if ( !(p=conf->mirrors+mirror)->rdev) {
746
747 blk_queue_stack_limits(mddev->queue,
748 rdev->bdev->bd_disk->queue);
749 /* as we don't honour merge_bvec_fn, we must never risk
750 * violating it, so limit ->max_sector to one PAGE, as
751 * a one page request is never in violation.
752 */
753 if (rdev->bdev->bd_disk->queue->merge_bvec_fn &&
754 mddev->queue->max_sectors > (PAGE_SIZE>>9))
755 blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9);
756
757 p->head_position = 0;
758 rdev->raid_disk = mirror;
759 found = 1;
760 p->rdev = rdev;
761 break;
762 }
763
764 print_conf(conf);
765 return found;
766 }
767
768 static int raid1_remove_disk(mddev_t *mddev, int number)
769 {
770 conf_t *conf = mddev->private;
771 int err = 0;
772 mdk_rdev_t *rdev;
773 mirror_info_t *p = conf->mirrors+ number;
774
775 print_conf(conf);
776 rdev = p->rdev;
777 if (rdev) {
778 if (rdev->in_sync ||
779 atomic_read(&rdev->nr_pending)) {
780 err = -EBUSY;
781 goto abort;
782 }
783 p->rdev = NULL;
784 synchronize_kernel();
785 if (atomic_read(&rdev->nr_pending)) {
786 /* lost the race, try later */
787 err = -EBUSY;
788 p->rdev = rdev;
789 }
790 }
791 abort:
792
793 print_conf(conf);
794 return err;
795 }
796
797
798 static int end_sync_read(struct bio *bio, unsigned int bytes_done, int error)
799 {
800 int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
801 r1bio_t * r1_bio = (r1bio_t *)(bio->bi_private);
802 conf_t *conf = mddev_to_conf(r1_bio->mddev);
803
804 if (bio->bi_size)
805 return 1;
806
807 if (r1_bio->bios[r1_bio->read_disk] != bio)
808 BUG();
809 update_head_pos(r1_bio->read_disk, r1_bio);
810 /*
811 * we have read a block, now it needs to be re-written,
812 * or re-read if the read failed.
813 * We don't do much here, just schedule handling by raid1d
814 */
815 if (!uptodate)
816 md_error(r1_bio->mddev,
817 conf->mirrors[r1_bio->read_disk].rdev);
818 else
819 set_bit(R1BIO_Uptodate, &r1_bio->state);
820 rdev_dec_pending(conf->mirrors[r1_bio->read_disk].rdev, conf->mddev);
821 reschedule_retry(r1_bio);
822 return 0;
823 }
824
825 static int end_sync_write(struct bio *bio, unsigned int bytes_done, int error)
826 {
827 int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
828 r1bio_t * r1_bio = (r1bio_t *)(bio->bi_private);
829 mddev_t *mddev = r1_bio->mddev;
830 conf_t *conf = mddev_to_conf(mddev);
831 int i;
832 int mirror=0;
833
834 if (bio->bi_size)
835 return 1;
836
837 for (i = 0; i < conf->raid_disks; i++)
838 if (r1_bio->bios[i] == bio) {
839 mirror = i;
840 break;
841 }
842 if (!uptodate)
843 md_error(mddev, conf->mirrors[mirror].rdev);
844 update_head_pos(mirror, r1_bio);
845
846 if (atomic_dec_and_test(&r1_bio->remaining)) {
847 md_done_sync(mddev, r1_bio->sectors, uptodate);
848 put_buf(r1_bio);
849 }
850 rdev_dec_pending(conf->mirrors[mirror].rdev, mddev);
851 return 0;
852 }
853
854 static void sync_request_write(mddev_t *mddev, r1bio_t *r1_bio)
855 {
856 conf_t *conf = mddev_to_conf(mddev);
857 int i;
858 int disks = conf->raid_disks;
859 struct bio *bio, *wbio;
860
861 bio = r1_bio->bios[r1_bio->read_disk];
862
863 /*
864 * schedule writes
865 */
866 if (!test_bit(R1BIO_Uptodate, &r1_bio->state)) {
867 /*
868 * There is no point trying a read-for-reconstruct as
869 * reconstruct is about to be aborted
870 */
871 char b[BDEVNAME_SIZE];
872 printk(KERN_ALERT "raid1: %s: unrecoverable I/O read error"
873 " for block %llu\n",
874 bdevname(bio->bi_bdev,b),
875 (unsigned long long)r1_bio->sector);
876 md_done_sync(mddev, r1_bio->sectors, 0);
877 put_buf(r1_bio);
878 return;
879 }
880
881 atomic_set(&r1_bio->remaining, 1);
882 for (i = 0; i < disks ; i++) {
883 wbio = r1_bio->bios[i];
884 if (wbio->bi_end_io != end_sync_write)
885 continue;
886
887 atomic_inc(&conf->mirrors[i].rdev->nr_pending);
888 atomic_inc(&r1_bio->remaining);
889 md_sync_acct(conf->mirrors[i].rdev->bdev, wbio->bi_size >> 9);
890 generic_make_request(wbio);
891 }
892
893 if (atomic_dec_and_test(&r1_bio->remaining)) {
894 md_done_sync(mddev, r1_bio->sectors, 1);
895 put_buf(r1_bio);
896 }
897 }
898
899 /*
900 * This is a kernel thread which:
901 *
902 * 1. Retries failed read operations on working mirrors.
903 * 2. Updates the raid superblock when problems encounter.
904 * 3. Performs writes following reads for array syncronising.
905 */
906
907 static void raid1d(mddev_t *mddev)
908 {
909 r1bio_t *r1_bio;
910 struct bio *bio;
911 unsigned long flags;
912 conf_t *conf = mddev_to_conf(mddev);
913 struct list_head *head = &conf->retry_list;
914 int unplug=0;
915 mdk_rdev_t *rdev;
916
917 md_check_recovery(mddev);
918 md_handle_safemode(mddev);
919
920 for (;;) {
921 char b[BDEVNAME_SIZE];
922 spin_lock_irqsave(&conf->device_lock, flags);
923 if (list_empty(head))
924 break;
925 r1_bio = list_entry(head->prev, r1bio_t, retry_list);
926 list_del(head->prev);
927 spin_unlock_irqrestore(&conf->device_lock, flags);
928
929 mddev = r1_bio->mddev;
930 conf = mddev_to_conf(mddev);
931 if (test_bit(R1BIO_IsSync, &r1_bio->state)) {
932 sync_request_write(mddev, r1_bio);
933 unplug = 1;
934 } else {
935 int disk;
936 bio = r1_bio->bios[r1_bio->read_disk];
937 if ((disk=read_balance(conf, r1_bio)) == -1) {
938 printk(KERN_ALERT "raid1: %s: unrecoverable I/O"
939 " read error for block %llu\n",
940 bdevname(bio->bi_bdev,b),
941 (unsigned long long)r1_bio->sector);
942 raid_end_bio_io(r1_bio);
943 } else {
944 r1_bio->bios[r1_bio->read_disk] = NULL;
945 r1_bio->read_disk = disk;
946 bio_put(bio);
947 bio = bio_clone(r1_bio->master_bio, GFP_NOIO);
948 r1_bio->bios[r1_bio->read_disk] = bio;
949 rdev = conf->mirrors[disk].rdev;
950 if (printk_ratelimit())
951 printk(KERN_ERR "raid1: %s: redirecting sector %llu to"
952 " another mirror\n",
953 bdevname(rdev->bdev,b),
954 (unsigned long long)r1_bio->sector);
955 bio->bi_sector = r1_bio->sector + rdev->data_offset;
956 bio->bi_bdev = rdev->bdev;
957 bio->bi_end_io = raid1_end_read_request;
958 bio->bi_rw = READ;
959 bio->bi_private = r1_bio;
960 unplug = 1;
961 generic_make_request(bio);
962 }
963 }
964 }
965 spin_unlock_irqrestore(&conf->device_lock, flags);
966 if (unplug)
967 unplug_slaves(mddev);
968 }
969
970
971 static int init_resync(conf_t *conf)
972 {
973 int buffs;
974
975 buffs = RESYNC_WINDOW / RESYNC_BLOCK_SIZE;
976 if (conf->r1buf_pool)
977 BUG();
978 conf->r1buf_pool = mempool_create(buffs, r1buf_pool_alloc, r1buf_pool_free,
979 conf->poolinfo);
980 if (!conf->r1buf_pool)
981 return -ENOMEM;
982 conf->next_resync = 0;
983 return 0;
984 }
985
986 /*
987 * perform a "sync" on one "block"
988 *
989 * We need to make sure that no normal I/O request - particularly write
990 * requests - conflict with active sync requests.
991 *
992 * This is achieved by tracking pending requests and a 'barrier' concept
993 * that can be installed to exclude normal IO requests.
994 */
995
996 static int sync_request(mddev_t *mddev, sector_t sector_nr, int go_faster)
997 {
998 conf_t *conf = mddev_to_conf(mddev);
999 mirror_info_t *mirror;
1000 r1bio_t *r1_bio;
1001 struct bio *bio;
1002 sector_t max_sector, nr_sectors;
1003 int disk;
1004 int i;
1005 int write_targets = 0;
1006
1007 if (!conf->r1buf_pool)
1008 if (init_resync(conf))
1009 return -ENOMEM;
1010
1011 max_sector = mddev->size << 1;
1012 if (sector_nr >= max_sector) {
1013 close_sync(conf);
1014 return 0;
1015 }
1016
1017 /*
1018 * If there is non-resync activity waiting for us then
1019 * put in a delay to throttle resync.
1020 */
1021 if (!go_faster && waitqueue_active(&conf->wait_resume))
1022 msleep_interruptible(1000);
1023 device_barrier(conf, sector_nr + RESYNC_SECTORS);
1024
1025 /*
1026 * If reconstructing, and >1 working disc,
1027 * could dedicate one to rebuild and others to
1028 * service read requests ..
1029 */
1030 disk = conf->last_used;
1031 /* make sure disk is operational */
1032
1033 while (conf->mirrors[disk].rdev == NULL ||
1034 !conf->mirrors[disk].rdev->in_sync) {
1035 if (disk <= 0)
1036 disk = conf->raid_disks;
1037 disk--;
1038 if (disk == conf->last_used)
1039 break;
1040 }
1041 conf->last_used = disk;
1042 atomic_inc(&conf->mirrors[disk].rdev->nr_pending);
1043
1044
1045 mirror = conf->mirrors + disk;
1046
1047 r1_bio = mempool_alloc(conf->r1buf_pool, GFP_NOIO);
1048
1049 spin_lock_irq(&conf->resync_lock);
1050 conf->nr_pending++;
1051 spin_unlock_irq(&conf->resync_lock);
1052
1053 r1_bio->mddev = mddev;
1054 r1_bio->sector = sector_nr;
1055 set_bit(R1BIO_IsSync, &r1_bio->state);
1056 r1_bio->read_disk = disk;
1057
1058 for (i=0; i < conf->raid_disks; i++) {
1059 bio = r1_bio->bios[i];
1060
1061 /* take from bio_init */
1062 bio->bi_next = NULL;
1063 bio->bi_flags |= 1 << BIO_UPTODATE;
1064 bio->bi_rw = 0;
1065 bio->bi_vcnt = 0;
1066 bio->bi_idx = 0;
1067 bio->bi_phys_segments = 0;
1068 bio->bi_hw_segments = 0;
1069 bio->bi_size = 0;
1070 bio->bi_end_io = NULL;
1071 bio->bi_private = NULL;
1072
1073 if (i == disk) {
1074 bio->bi_rw = READ;
1075 bio->bi_end_io = end_sync_read;
1076 } else if (conf->mirrors[i].rdev &&
1077 !conf->mirrors[i].rdev->faulty &&
1078 (!conf->mirrors[i].rdev->in_sync ||
1079 sector_nr + RESYNC_SECTORS > mddev->recovery_cp)) {
1080 bio->bi_rw = WRITE;
1081 bio->bi_end_io = end_sync_write;
1082 write_targets ++;
1083 } else
1084 continue;
1085 bio->bi_sector = sector_nr + conf->mirrors[i].rdev->data_offset;
1086 bio->bi_bdev = conf->mirrors[i].rdev->bdev;
1087 bio->bi_private = r1_bio;
1088 }
1089 if (write_targets == 0) {
1090 /* There is nowhere to write, so all non-sync
1091 * drives must be failed - so we are finished
1092 */
1093 int rv = max_sector - sector_nr;
1094 md_done_sync(mddev, rv, 1);
1095 put_buf(r1_bio);
1096 rdev_dec_pending(conf->mirrors[disk].rdev, mddev);
1097 return rv;
1098 }
1099
1100 nr_sectors = 0;
1101 do {
1102 struct page *page;
1103 int len = PAGE_SIZE;
1104 if (sector_nr + (len>>9) > max_sector)
1105 len = (max_sector - sector_nr) << 9;
1106 if (len == 0)
1107 break;
1108 for (i=0 ; i < conf->raid_disks; i++) {
1109 bio = r1_bio->bios[i];
1110 if (bio->bi_end_io) {
1111 page = r1_bio->bios[0]->bi_io_vec[bio->bi_vcnt].bv_page;
1112 if (bio_add_page(bio, page, len, 0) == 0) {
1113 /* stop here */
1114 r1_bio->bios[0]->bi_io_vec[bio->bi_vcnt].bv_page = page;
1115 while (i > 0) {
1116 i--;
1117 bio = r1_bio->bios[i];
1118 if (bio->bi_end_io==NULL) continue;
1119 /* remove last page from this bio */
1120 bio->bi_vcnt--;
1121 bio->bi_size -= len;
1122 bio->bi_flags &= ~(1<< BIO_SEG_VALID);
1123 }
1124 goto bio_full;
1125 }
1126 }
1127 }
1128 nr_sectors += len>>9;
1129 sector_nr += len>>9;
1130 } while (r1_bio->bios[disk]->bi_vcnt < RESYNC_PAGES);
1131 bio_full:
1132 bio = r1_bio->bios[disk];
1133 r1_bio->sectors = nr_sectors;
1134
1135 md_sync_acct(mirror->rdev->bdev, nr_sectors);
1136
1137 generic_make_request(bio);
1138
1139 return nr_sectors;
1140 }
1141
1142 static int run(mddev_t *mddev)
1143 {
1144 conf_t *conf;
1145 int i, j, disk_idx;
1146 mirror_info_t *disk;
1147 mdk_rdev_t *rdev;
1148 struct list_head *tmp;
1149
1150 if (mddev->level != 1) {
1151 printk("raid1: %s: raid level not set to mirroring (%d)\n",
1152 mdname(mddev), mddev->level);
1153 goto out;
1154 }
1155 /*
1156 * copy the already verified devices into our private RAID1
1157 * bookkeeping area. [whatever we allocate in run(),
1158 * should be freed in stop()]
1159 */
1160 conf = kmalloc(sizeof(conf_t), GFP_KERNEL);
1161 mddev->private = conf;
1162 if (!conf)
1163 goto out_no_mem;
1164
1165 memset(conf, 0, sizeof(*conf));
1166 conf->mirrors = kmalloc(sizeof(struct mirror_info)*mddev->raid_disks,
1167 GFP_KERNEL);
1168 if (!conf->mirrors)
1169 goto out_no_mem;
1170
1171 memset(conf->mirrors, 0, sizeof(struct mirror_info)*mddev->raid_disks);
1172
1173 conf->poolinfo = kmalloc(sizeof(*conf->poolinfo), GFP_KERNEL);
1174 if (!conf->poolinfo)
1175 goto out_no_mem;
1176 conf->poolinfo->mddev = mddev;
1177 conf->poolinfo->raid_disks = mddev->raid_disks;
1178 conf->r1bio_pool = mempool_create(NR_RAID1_BIOS, r1bio_pool_alloc,
1179 r1bio_pool_free,
1180 conf->poolinfo);
1181 if (!conf->r1bio_pool)
1182 goto out_no_mem;
1183
1184 mddev->queue->unplug_fn = raid1_unplug;
1185
1186 mddev->queue->issue_flush_fn = raid1_issue_flush;
1187
1188 ITERATE_RDEV(mddev, rdev, tmp) {
1189 disk_idx = rdev->raid_disk;
1190 if (disk_idx >= mddev->raid_disks
1191 || disk_idx < 0)
1192 continue;
1193 disk = conf->mirrors + disk_idx;
1194
1195 disk->rdev = rdev;
1196
1197 blk_queue_stack_limits(mddev->queue,
1198 rdev->bdev->bd_disk->queue);
1199 /* as we don't honour merge_bvec_fn, we must never risk
1200 * violating it, so limit ->max_sector to one PAGE, as
1201 * a one page request is never in violation.
1202 */
1203 if (rdev->bdev->bd_disk->queue->merge_bvec_fn &&
1204 mddev->queue->max_sectors > (PAGE_SIZE>>9))
1205 blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9);
1206
1207 disk->head_position = 0;
1208 if (!rdev->faulty && rdev->in_sync)
1209 conf->working_disks++;
1210 }
1211 conf->raid_disks = mddev->raid_disks;
1212 conf->mddev = mddev;
1213 spin_lock_init(&conf->device_lock);
1214 INIT_LIST_HEAD(&conf->retry_list);
1215 if (conf->working_disks == 1)
1216 mddev->recovery_cp = MaxSector;
1217
1218 spin_lock_init(&conf->resync_lock);
1219 init_waitqueue_head(&conf->wait_idle);
1220 init_waitqueue_head(&conf->wait_resume);
1221
1222 if (!conf->working_disks) {
1223 printk(KERN_ERR "raid1: no operational mirrors for %s\n",
1224 mdname(mddev));
1225 goto out_free_conf;
1226 }
1227
1228 mddev->degraded = 0;
1229 for (i = 0; i < conf->raid_disks; i++) {
1230
1231 disk = conf->mirrors + i;
1232
1233 if (!disk->rdev) {
1234 disk->head_position = 0;
1235 mddev->degraded++;
1236 }
1237 }
1238
1239 /*
1240 * find the first working one and use it as a starting point
1241 * to read balancing.
1242 */
1243 for (j = 0; j < conf->raid_disks &&
1244 (!conf->mirrors[j].rdev ||
1245 !conf->mirrors[j].rdev->in_sync) ; j++)
1246 /* nothing */;
1247 conf->last_used = j;
1248
1249
1250
1251 {
1252 mddev->thread = md_register_thread(raid1d, mddev, "%s_raid1");
1253 if (!mddev->thread) {
1254 printk(KERN_ERR
1255 "raid1: couldn't allocate thread for %s\n",
1256 mdname(mddev));
1257 goto out_free_conf;
1258 }
1259 }
1260 printk(KERN_INFO
1261 "raid1: raid set %s active with %d out of %d mirrors\n",
1262 mdname(mddev), mddev->raid_disks - mddev->degraded,
1263 mddev->raid_disks);
1264 /*
1265 * Ok, everything is just fine now
1266 */
1267 mddev->array_size = mddev->size;
1268
1269 return 0;
1270
1271 out_no_mem:
1272 printk(KERN_ERR "raid1: couldn't allocate memory for %s\n",
1273 mdname(mddev));
1274
1275 out_free_conf:
1276 if (conf) {
1277 if (conf->r1bio_pool)
1278 mempool_destroy(conf->r1bio_pool);
1279 if (conf->mirrors)
1280 kfree(conf->mirrors);
1281 if (conf->poolinfo)
1282 kfree(conf->poolinfo);
1283 kfree(conf);
1284 mddev->private = NULL;
1285 }
1286 out:
1287 return -EIO;
1288 }
1289
1290 static int stop(mddev_t *mddev)
1291 {
1292 conf_t *conf = mddev_to_conf(mddev);
1293
1294 md_unregister_thread(mddev->thread);
1295 mddev->thread = NULL;
1296 blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
1297 if (conf->r1bio_pool)
1298 mempool_destroy(conf->r1bio_pool);
1299 if (conf->mirrors)
1300 kfree(conf->mirrors);
1301 if (conf->poolinfo)
1302 kfree(conf->poolinfo);
1303 kfree(conf);
1304 mddev->private = NULL;
1305 return 0;
1306 }
1307
1308 static int raid1_resize(mddev_t *mddev, sector_t sectors)
1309 {
1310 /* no resync is happening, and there is enough space
1311 * on all devices, so we can resize.
1312 * We need to make sure resync covers any new space.
1313 * If the array is shrinking we should possibly wait until
1314 * any io in the removed space completes, but it hardly seems
1315 * worth it.
1316 */
1317 mddev->array_size = sectors>>1;
1318 set_capacity(mddev->gendisk, mddev->array_size << 1);
1319 mddev->changed = 1;
1320 if (mddev->array_size > mddev->size && mddev->recovery_cp == MaxSector) {
1321 mddev->recovery_cp = mddev->size << 1;
1322 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
1323 }
1324 mddev->size = mddev->array_size;
1325 return 0;
1326 }
1327
1328 static int raid1_reshape(mddev_t *mddev, int raid_disks)
1329 {
1330 /* We need to:
1331 * 1/ resize the r1bio_pool
1332 * 2/ resize conf->mirrors
1333 *
1334 * We allocate a new r1bio_pool if we can.
1335 * Then raise a device barrier and wait until all IO stops.
1336 * Then resize conf->mirrors and swap in the new r1bio pool.
1337 */
1338 mempool_t *newpool, *oldpool;
1339 struct pool_info *newpoolinfo;
1340 mirror_info_t *newmirrors;
1341 conf_t *conf = mddev_to_conf(mddev);
1342
1343 int d;
1344
1345 for (d= raid_disks; d < conf->raid_disks; d++)
1346 if (conf->mirrors[d].rdev)
1347 return -EBUSY;
1348
1349 newpoolinfo = kmalloc(sizeof(newpoolinfo), GFP_KERNEL);
1350 if (!newpoolinfo)
1351 return -ENOMEM;
1352 newpoolinfo->mddev = mddev;
1353 newpoolinfo->raid_disks = raid_disks;
1354
1355 newpool = mempool_create(NR_RAID1_BIOS, r1bio_pool_alloc,
1356 r1bio_pool_free, newpoolinfo);
1357 if (!newpool) {
1358 kfree(newpoolinfo);
1359 return -ENOMEM;
1360 }
1361 newmirrors = kmalloc(sizeof(struct mirror_info) * raid_disks, GFP_KERNEL);
1362 if (!newmirrors) {
1363 kfree(newpoolinfo);
1364 mempool_destroy(newpool);
1365 return -ENOMEM;
1366 }
1367 memset(newmirrors, 0, sizeof(struct mirror_info)*raid_disks);
1368
1369 spin_lock_irq(&conf->resync_lock);
1370 conf->barrier++;
1371 wait_event_lock_irq(conf->wait_idle, !conf->nr_pending,
1372 conf->resync_lock, unplug_slaves(mddev));
1373 spin_unlock_irq(&conf->resync_lock);
1374
1375 /* ok, everything is stopped */
1376 oldpool = conf->r1bio_pool;
1377 conf->r1bio_pool = newpool;
1378 for (d=0; d < raid_disks && d < conf->raid_disks; d++)
1379 newmirrors[d] = conf->mirrors[d];
1380 kfree(conf->mirrors);
1381 conf->mirrors = newmirrors;
1382 kfree(conf->poolinfo);
1383 conf->poolinfo = newpoolinfo;
1384
1385 mddev->degraded += (raid_disks - conf->raid_disks);
1386 conf->raid_disks = mddev->raid_disks = raid_disks;
1387
1388 spin_lock_irq(&conf->resync_lock);
1389 conf->barrier--;
1390 spin_unlock_irq(&conf->resync_lock);
1391 wake_up(&conf->wait_resume);
1392 wake_up(&conf->wait_idle);
1393
1394
1395 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
1396 md_wakeup_thread(mddev->thread);
1397
1398 mempool_destroy(oldpool);
1399 return 0;
1400 }
1401
1402
1403 static mdk_personality_t raid1_personality =
1404 {
1405 .name = "raid1",
1406 .owner = THIS_MODULE,
1407 .make_request = make_request,
1408 .run = run,
1409 .stop = stop,
1410 .status = status,
1411 .error_handler = error,
1412 .hot_add_disk = raid1_add_disk,
1413 .hot_remove_disk= raid1_remove_disk,
1414 .spare_active = raid1_spare_active,
1415 .sync_request = sync_request,
1416 .resize = raid1_resize,
1417 .reshape = raid1_reshape,
1418 };
1419
1420 static int __init raid_init(void)
1421 {
1422 return register_md_personality(RAID1, &raid1_personality);
1423 }
1424
1425 static void raid_exit(void)
1426 {
1427 unregister_md_personality(RAID1);
1428 }
1429
1430 module_init(raid_init);
1431 module_exit(raid_exit);
1432 MODULE_LICENSE("GPL");
1433 MODULE_ALIAS("md-personality-3"); /* RAID1 */
1434
|
This page was automatically generated by the
LXR engine.
|