diff options
Diffstat (limited to 'drivers/block/drbd/drbd_actlog.c')
-rw-r--r-- | drivers/block/drbd/drbd_actlog.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/drivers/block/drbd/drbd_actlog.c b/drivers/block/drbd/drbd_actlog.c index 4271352dd72b..aee599fad960 100644 --- a/drivers/block/drbd/drbd_actlog.c +++ b/drivers/block/drbd/drbd_actlog.c | |||
@@ -82,6 +82,17 @@ void drbd_md_put_buffer(struct drbd_conf *mdev) | |||
82 | wake_up(&mdev->misc_wait); | 82 | wake_up(&mdev->misc_wait); |
83 | } | 83 | } |
84 | 84 | ||
85 | static bool md_io_allowed(struct drbd_conf *mdev) | ||
86 | { | ||
87 | enum drbd_disk_state ds = mdev->state.disk; | ||
88 | return ds >= D_NEGOTIATING || ds == D_ATTACHING; | ||
89 | } | ||
90 | |||
91 | void wait_until_done_or_disk_failure(struct drbd_conf *mdev, unsigned int *done) | ||
92 | { | ||
93 | wait_event(mdev->misc_wait, *done || !md_io_allowed(mdev)); | ||
94 | } | ||
95 | |||
85 | static int _drbd_md_sync_page_io(struct drbd_conf *mdev, | 96 | static int _drbd_md_sync_page_io(struct drbd_conf *mdev, |
86 | struct drbd_backing_dev *bdev, | 97 | struct drbd_backing_dev *bdev, |
87 | struct page *page, sector_t sector, | 98 | struct page *page, sector_t sector, |
@@ -90,8 +101,8 @@ static int _drbd_md_sync_page_io(struct drbd_conf *mdev, | |||
90 | struct bio *bio; | 101 | struct bio *bio; |
91 | int ok; | 102 | int ok; |
92 | 103 | ||
93 | init_completion(&mdev->md_io.event); | 104 | mdev->md_io.done = 0; |
94 | mdev->md_io.error = 0; | 105 | mdev->md_io.error = -ENODEV; |
95 | 106 | ||
96 | if ((rw & WRITE) && !test_bit(MD_NO_FUA, &mdev->flags)) | 107 | if ((rw & WRITE) && !test_bit(MD_NO_FUA, &mdev->flags)) |
97 | rw |= REQ_FUA | REQ_FLUSH; | 108 | rw |= REQ_FUA | REQ_FLUSH; |
@@ -112,7 +123,7 @@ static int _drbd_md_sync_page_io(struct drbd_conf *mdev, | |||
112 | bio_endio(bio, -EIO); | 123 | bio_endio(bio, -EIO); |
113 | else | 124 | else |
114 | submit_bio(rw, bio); | 125 | submit_bio(rw, bio); |
115 | wait_for_completion(&mdev->md_io.event); | 126 | wait_until_done_or_disk_failure(mdev, &mdev->md_io.done); |
116 | ok = bio_flagged(bio, BIO_UPTODATE) && mdev->md_io.error == 0; | 127 | ok = bio_flagged(bio, BIO_UPTODATE) && mdev->md_io.error == 0; |
117 | 128 | ||
118 | out: | 129 | out: |