diff options
author | NeilBrown <neilb@cse.unsw.edu.au> | 2005-09-09 19:23:52 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-09-09 19:39:11 -0400 |
commit | ab904d634625ef8dc590240b7ee06c7b724e636b (patch) | |
tree | 3ecd6a17dd99f2f1879b3e1fed58f52e6d35633c /drivers/md/bitmap.c | |
parent | 71c0805cb48462c99fbe0e5fcc6c12d7b9929c09 (diff) |
[PATCH] md: fix bitmap/read_sb_page so that it handles errors properly.
read_sb_page() assumed that if sync_page_io fails, the device would be marked
faultly. However it isn't. So in the face of error, read_sb_page would loop
forever.
Redo the logic so that this cannot happen.
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/md/bitmap.c')
-rw-r--r-- | drivers/md/bitmap.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index c971d38f3a05..90fe70d76a31 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c | |||
@@ -270,19 +270,20 @@ static struct page *read_sb_page(mddev_t *mddev, long offset, unsigned long inde | |||
270 | 270 | ||
271 | if (!page) | 271 | if (!page) |
272 | return ERR_PTR(-ENOMEM); | 272 | return ERR_PTR(-ENOMEM); |
273 | do { | ||
274 | ITERATE_RDEV(mddev, rdev, tmp) | ||
275 | if (rdev->in_sync && !rdev->faulty) | ||
276 | goto found; | ||
277 | return ERR_PTR(-EIO); | ||
278 | 273 | ||
279 | found: | 274 | ITERATE_RDEV(mddev, rdev, tmp) { |
275 | if (! rdev->in_sync || rdev->faulty) | ||
276 | continue; | ||
277 | |||
280 | target = (rdev->sb_offset << 1) + offset + index * (PAGE_SIZE/512); | 278 | target = (rdev->sb_offset << 1) + offset + index * (PAGE_SIZE/512); |
281 | 279 | ||
282 | } while (!sync_page_io(rdev->bdev, target, PAGE_SIZE, page, READ)); | 280 | if (sync_page_io(rdev->bdev, target, PAGE_SIZE, page, READ)) { |
281 | page->index = index; | ||
282 | return page; | ||
283 | } | ||
284 | } | ||
285 | return ERR_PTR(-EIO); | ||
283 | 286 | ||
284 | page->index = index; | ||
285 | return page; | ||
286 | } | 287 | } |
287 | 288 | ||
288 | static int write_sb_page(mddev_t *mddev, long offset, struct page *page, int wait) | 289 | static int write_sb_page(mddev_t *mddev, long offset, struct page *page, int wait) |