raid1.c (9134d02bc0af4a8747d448d1f811ec5f8eb96df6) raid1.c (1f98a13f623e0ef666690a18c1250335fc6d7ef1)
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.

--- 768 unchanged lines hidden (view full) ---

777 r1bio_t *r1_bio;
778 struct bio *read_bio;
779 int i, targets = 0, disks;
780 struct bitmap *bitmap;
781 unsigned long flags;
782 struct bio_list bl;
783 struct page **behind_pages = NULL;
784 const int rw = bio_data_dir(bio);
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.

--- 768 unchanged lines hidden (view full) ---

777 r1bio_t *r1_bio;
778 struct bio *read_bio;
779 int i, targets = 0, disks;
780 struct bitmap *bitmap;
781 unsigned long flags;
782 struct bio_list bl;
783 struct page **behind_pages = NULL;
784 const int rw = bio_data_dir(bio);
785 const int do_sync = bio_sync(bio);
786 int cpu, do_barriers;
785 const bool do_sync = bio_rw_flagged(bio, BIO_RW_SYNCIO);
786 int cpu;
787 bool do_barriers;
787 mdk_rdev_t *blocked_rdev;
788
789 /*
790 * Register the new request and wait if the reconstruction
791 * thread has put up a bar for new requests.
792 * Continue immediately if no resync is active currently.
793 * We test barriers_work *after* md_write_start as md_write_start
794 * may cause the first superblock write, and that will check out
795 * if barriers work.
796 */
797
798 md_write_start(mddev, bio); /* wait on superblock update early */
799
788 mdk_rdev_t *blocked_rdev;
789
790 /*
791 * Register the new request and wait if the reconstruction
792 * thread has put up a bar for new requests.
793 * Continue immediately if no resync is active currently.
794 * We test barriers_work *after* md_write_start as md_write_start
795 * may cause the first superblock write, and that will check out
796 * if barriers work.
797 */
798
799 md_write_start(mddev, bio); /* wait on superblock update early */
800
800 if (unlikely(!mddev->barriers_work && bio_barrier(bio))) {
801 if (unlikely(!mddev->barriers_work &&
802 bio_rw_flagged(bio, BIO_RW_BARRIER))) {
801 if (rw == WRITE)
802 md_write_end(mddev);
803 bio_endio(bio, -EOPNOTSUPP);
804 return 0;
805 }
806
807 wait_barrier(conf);
808

--- 111 unchanged lines hidden (view full) ---

920 if (bitmap &&
921 atomic_read(&bitmap->behind_writes) < bitmap->max_write_behind &&
922 (behind_pages = alloc_behind_pages(bio)) != NULL)
923 set_bit(R1BIO_BehindIO, &r1_bio->state);
924
925 atomic_set(&r1_bio->remaining, 0);
926 atomic_set(&r1_bio->behind_remaining, 0);
927
803 if (rw == WRITE)
804 md_write_end(mddev);
805 bio_endio(bio, -EOPNOTSUPP);
806 return 0;
807 }
808
809 wait_barrier(conf);
810

--- 111 unchanged lines hidden (view full) ---

922 if (bitmap &&
923 atomic_read(&bitmap->behind_writes) < bitmap->max_write_behind &&
924 (behind_pages = alloc_behind_pages(bio)) != NULL)
925 set_bit(R1BIO_BehindIO, &r1_bio->state);
926
927 atomic_set(&r1_bio->remaining, 0);
928 atomic_set(&r1_bio->behind_remaining, 0);
929
928 do_barriers = bio_barrier(bio);
930 do_barriers = bio_rw_flagged(bio, BIO_RW_BARRIER);
929 if (do_barriers)
930 set_bit(R1BIO_Barrier, &r1_bio->state);
931
932 bio_list_init(&bl);
933 for (i = 0; i < disks; i++) {
934 struct bio *mbio;
935 if (!r1_bio->bios[i])
936 continue;

--- 658 unchanged lines hidden (view full) ---

1595 /* some requests in the r1bio were BIO_RW_BARRIER
1596 * requests which failed with -EOPNOTSUPP. Hohumm..
1597 * Better resubmit without the barrier.
1598 * We know which devices to resubmit for, because
1599 * all others have had their bios[] entry cleared.
1600 * We already have a nr_pending reference on these rdevs.
1601 */
1602 int i;
931 if (do_barriers)
932 set_bit(R1BIO_Barrier, &r1_bio->state);
933
934 bio_list_init(&bl);
935 for (i = 0; i < disks; i++) {
936 struct bio *mbio;
937 if (!r1_bio->bios[i])
938 continue;

--- 658 unchanged lines hidden (view full) ---

1597 /* some requests in the r1bio were BIO_RW_BARRIER
1598 * requests which failed with -EOPNOTSUPP. Hohumm..
1599 * Better resubmit without the barrier.
1600 * We know which devices to resubmit for, because
1601 * all others have had their bios[] entry cleared.
1602 * We already have a nr_pending reference on these rdevs.
1603 */
1604 int i;
1603 const int do_sync = bio_sync(r1_bio->master_bio);
1605 const bool do_sync = bio_rw_flagged(r1_bio->master_bio, BIO_RW_SYNCIO);
1604 clear_bit(R1BIO_BarrierRetry, &r1_bio->state);
1605 clear_bit(R1BIO_Barrier, &r1_bio->state);
1606 for (i=0; i < conf->raid_disks; i++)
1607 if (r1_bio->bios[i])
1608 atomic_inc(&r1_bio->remaining);
1609 for (i=0; i < conf->raid_disks; i++)
1610 if (r1_bio->bios[i]) {
1611 struct bio_vec *bvec;

--- 37 unchanged lines hidden (view full) ---

1649 if ((disk=read_balance(conf, r1_bio)) == -1 ||
1650 disk == r1_bio->read_disk) {
1651 printk(KERN_ALERT "raid1: %s: unrecoverable I/O"
1652 " read error for block %llu\n",
1653 bdevname(bio->bi_bdev,b),
1654 (unsigned long long)r1_bio->sector);
1655 raid_end_bio_io(r1_bio);
1656 } else {
1606 clear_bit(R1BIO_BarrierRetry, &r1_bio->state);
1607 clear_bit(R1BIO_Barrier, &r1_bio->state);
1608 for (i=0; i < conf->raid_disks; i++)
1609 if (r1_bio->bios[i])
1610 atomic_inc(&r1_bio->remaining);
1611 for (i=0; i < conf->raid_disks; i++)
1612 if (r1_bio->bios[i]) {
1613 struct bio_vec *bvec;

--- 37 unchanged lines hidden (view full) ---

1651 if ((disk=read_balance(conf, r1_bio)) == -1 ||
1652 disk == r1_bio->read_disk) {
1653 printk(KERN_ALERT "raid1: %s: unrecoverable I/O"
1654 " read error for block %llu\n",
1655 bdevname(bio->bi_bdev,b),
1656 (unsigned long long)r1_bio->sector);
1657 raid_end_bio_io(r1_bio);
1658 } else {
1657 const int do_sync = bio_sync(r1_bio->master_bio);
1659 const bool do_sync = bio_rw_flagged(r1_bio->master_bio, BIO_RW_SYNCIO);
1658 r1_bio->bios[r1_bio->read_disk] =
1659 mddev->ro ? IO_BLOCKED : NULL;
1660 r1_bio->read_disk = disk;
1661 bio_put(bio);
1662 bio = bio_clone(r1_bio->master_bio, GFP_NOIO);
1663 r1_bio->bios[r1_bio->read_disk] = bio;
1664 rdev = conf->mirrors[disk].rdev;
1665 if (printk_ratelimit())

--- 644 unchanged lines hidden ---
1660 r1_bio->bios[r1_bio->read_disk] =
1661 mddev->ro ? IO_BLOCKED : NULL;
1662 r1_bio->read_disk = disk;
1663 bio_put(bio);
1664 bio = bio_clone(r1_bio->master_bio, GFP_NOIO);
1665 r1_bio->bios[r1_bio->read_disk] = bio;
1666 rdev = conf->mirrors[disk].rdev;
1667 if (printk_ratelimit())

--- 644 unchanged lines hidden ---