aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/md.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r--drivers/md/md.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index cb20d0b0555a..700c96edf9b2 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -36,6 +36,7 @@
36#include <linux/blkdev.h> 36#include <linux/blkdev.h>
37#include <linux/sysctl.h> 37#include <linux/sysctl.h>
38#include <linux/seq_file.h> 38#include <linux/seq_file.h>
39#include <linux/smp_lock.h>
39#include <linux/buffer_head.h> /* for invalidate_bdev */ 40#include <linux/buffer_head.h> /* for invalidate_bdev */
40#include <linux/poll.h> 41#include <linux/poll.h>
41#include <linux/ctype.h> 42#include <linux/ctype.h>
@@ -353,7 +354,7 @@ static void md_submit_barrier(struct work_struct *ws)
353 /* an empty barrier - all done */ 354 /* an empty barrier - all done */
354 bio_endio(bio, 0); 355 bio_endio(bio, 0);
355 else { 356 else {
356 bio->bi_rw &= ~(1<<BIO_RW_BARRIER); 357 bio->bi_rw &= ~REQ_HARDBARRIER;
357 if (mddev->pers->make_request(mddev, bio)) 358 if (mddev->pers->make_request(mddev, bio))
358 generic_make_request(bio); 359 generic_make_request(bio);
359 mddev->barrier = POST_REQUEST_BARRIER; 360 mddev->barrier = POST_REQUEST_BARRIER;
@@ -675,11 +676,11 @@ void md_super_write(mddev_t *mddev, mdk_rdev_t *rdev,
675 * if zero is reached. 676 * if zero is reached.
676 * If an error occurred, call md_error 677 * If an error occurred, call md_error
677 * 678 *
678 * As we might need to resubmit the request if BIO_RW_BARRIER 679 * As we might need to resubmit the request if REQ_HARDBARRIER
679 * causes ENOTSUPP, we allocate a spare bio... 680 * causes ENOTSUPP, we allocate a spare bio...
680 */ 681 */
681 struct bio *bio = bio_alloc(GFP_NOIO, 1); 682 struct bio *bio = bio_alloc(GFP_NOIO, 1);
682 int rw = (1<<BIO_RW) | (1<<BIO_RW_SYNCIO) | (1<<BIO_RW_UNPLUG); 683 int rw = REQ_WRITE | REQ_SYNC | REQ_UNPLUG;
683 684
684 bio->bi_bdev = rdev->bdev; 685 bio->bi_bdev = rdev->bdev;
685 bio->bi_sector = sector; 686 bio->bi_sector = sector;
@@ -691,7 +692,7 @@ void md_super_write(mddev_t *mddev, mdk_rdev_t *rdev,
691 atomic_inc(&mddev->pending_writes); 692 atomic_inc(&mddev->pending_writes);
692 if (!test_bit(BarriersNotsupp, &rdev->flags)) { 693 if (!test_bit(BarriersNotsupp, &rdev->flags)) {
693 struct bio *rbio; 694 struct bio *rbio;
694 rw |= (1<<BIO_RW_BARRIER); 695 rw |= REQ_HARDBARRIER;
695 rbio = bio_clone(bio, GFP_NOIO); 696 rbio = bio_clone(bio, GFP_NOIO);
696 rbio->bi_private = bio; 697 rbio->bi_private = bio;
697 rbio->bi_end_io = super_written_barrier; 698 rbio->bi_end_io = super_written_barrier;
@@ -736,7 +737,7 @@ int sync_page_io(struct block_device *bdev, sector_t sector, int size,
736 struct completion event; 737 struct completion event;
737 int ret; 738 int ret;
738 739
739 rw |= (1 << BIO_RW_SYNCIO) | (1 << BIO_RW_UNPLUG); 740 rw |= REQ_SYNC | REQ_UNPLUG;
740 741
741 bio->bi_bdev = bdev; 742 bio->bi_bdev = bdev;
742 bio->bi_sector = sector; 743 bio->bi_sector = sector;
@@ -5902,6 +5903,7 @@ static int md_open(struct block_device *bdev, fmode_t mode)
5902 mddev_t *mddev = mddev_find(bdev->bd_dev); 5903 mddev_t *mddev = mddev_find(bdev->bd_dev);
5903 int err; 5904 int err;
5904 5905
5906 lock_kernel();
5905 if (mddev->gendisk != bdev->bd_disk) { 5907 if (mddev->gendisk != bdev->bd_disk) {
5906 /* we are racing with mddev_put which is discarding this 5908 /* we are racing with mddev_put which is discarding this
5907 * bd_disk. 5909 * bd_disk.
@@ -5910,6 +5912,7 @@ static int md_open(struct block_device *bdev, fmode_t mode)
5910 /* Wait until bdev->bd_disk is definitely gone */ 5912 /* Wait until bdev->bd_disk is definitely gone */
5911 flush_scheduled_work(); 5913 flush_scheduled_work();
5912 /* Then retry the open from the top */ 5914 /* Then retry the open from the top */
5915 unlock_kernel();
5913 return -ERESTARTSYS; 5916 return -ERESTARTSYS;
5914 } 5917 }
5915 BUG_ON(mddev != bdev->bd_disk->private_data); 5918 BUG_ON(mddev != bdev->bd_disk->private_data);
@@ -5923,6 +5926,7 @@ static int md_open(struct block_device *bdev, fmode_t mode)
5923 5926
5924 check_disk_size_change(mddev->gendisk, bdev); 5927 check_disk_size_change(mddev->gendisk, bdev);
5925 out: 5928 out:
5929 unlock_kernel();
5926 return err; 5930 return err;
5927} 5931}
5928 5932
@@ -5931,8 +5935,10 @@ static int md_release(struct gendisk *disk, fmode_t mode)
5931 mddev_t *mddev = disk->private_data; 5935 mddev_t *mddev = disk->private_data;
5932 5936
5933 BUG_ON(!mddev); 5937 BUG_ON(!mddev);
5938 lock_kernel();
5934 atomic_dec(&mddev->openers); 5939 atomic_dec(&mddev->openers);
5935 mddev_put(mddev); 5940 mddev_put(mddev);
5941 unlock_kernel();
5936 5942
5937 return 0; 5943 return 0;
5938} 5944}