Commit 0c67dd64 authored by Johannes Thumshirn's avatar Johannes Thumshirn Committed by Jens Axboe

md: raid1: check if adding pages to resync bio fails

Check if adding pages to resync bio fails and if bail out.

As the comment above suggests this cannot happen, WARN if it actually
happens. Technically __bio_add_pages() would be sufficient here, but
asserting the pages actually get added to the bio is preferred.

This way we can mark bio_add_pages as __must_check.
Reviewed-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
Acked-by: default avatarSong Liu <song@kernel.org>
Signed-off-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Link: https://lore.kernel.org/r/33aea4c271220dc9bcab58c4b7bec478c1511142.1685532726.git.johannes.thumshirn@wdc.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent f8312322
...@@ -101,11 +101,12 @@ static void md_bio_reset_resync_pages(struct bio *bio, struct resync_pages *rp, ...@@ -101,11 +101,12 @@ static void md_bio_reset_resync_pages(struct bio *bio, struct resync_pages *rp,
struct page *page = resync_fetch_page(rp, idx); struct page *page = resync_fetch_page(rp, idx);
int len = min_t(int, size, PAGE_SIZE); int len = min_t(int, size, PAGE_SIZE);
/* if (WARN_ON(!bio_add_page(bio, page, len, 0))) {
* won't fail because the vec table is big bio->bi_status = BLK_STS_RESOURCE;
* enough to hold all these pages bio_endio(bio);
*/ return;
bio_add_page(bio, page, len, 0); }
size -= len; size -= len;
} while (idx++ < RESYNC_PAGES && size > 0); } while (idx++ < RESYNC_PAGES && size > 0);
} }
...@@ -3819,11 +3819,11 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr, ...@@ -3819,11 +3819,11 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
for (bio= biolist ; bio ; bio=bio->bi_next) { for (bio= biolist ; bio ; bio=bio->bi_next) {
struct resync_pages *rp = get_resync_pages(bio); struct resync_pages *rp = get_resync_pages(bio);
page = resync_fetch_page(rp, page_idx); page = resync_fetch_page(rp, page_idx);
/* if (WARN_ON(!bio_add_page(bio, page, len, 0))) {
* won't fail because the vec table is big enough bio->bi_status = BLK_STS_RESOURCE;
* to hold all these pages bio_endio(bio);
*/ goto giveup;
bio_add_page(bio, page, len, 0); }
} }
nr_sectors += len>>9; nr_sectors += len>>9;
sector_nr += len>>9; sector_nr += len>>9;
...@@ -4997,11 +4997,11 @@ static sector_t reshape_request(struct mddev *mddev, sector_t sector_nr, ...@@ -4997,11 +4997,11 @@ static sector_t reshape_request(struct mddev *mddev, sector_t sector_nr,
if (len > PAGE_SIZE) if (len > PAGE_SIZE)
len = PAGE_SIZE; len = PAGE_SIZE;
for (bio = blist; bio ; bio = bio->bi_next) { for (bio = blist; bio ; bio = bio->bi_next) {
/* if (WARN_ON(!bio_add_page(bio, page, len, 0))) {
* won't fail because the vec table is big enough bio->bi_status = BLK_STS_RESOURCE;
* to hold all these pages bio_endio(bio);
*/ return sectors_done;
bio_add_page(bio, page, len, 0); }
} }
sector_nr += len >> 9; sector_nr += len >> 9;
nr_sectors += len >> 9; nr_sectors += len >> 9;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment