Btrfs: fix crash in scrub repair code when device is missing

Fix that when scrub tries to repair an I/O or checksum error and one of
the devices containing the mirror is missing, it crashes in bio_add_page
because the bdev is a NULL pointer for missing devices.

Reported-by: Marco L. Crociani <marco.crociani@gmail.com>
Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
Signed-off-by: Chris Mason <chris.mason@oracle.com>

authored by Stefan Behrens and committed by Chris Mason ea9947b4 d04b1deb

+7
+7
fs/btrfs/scrub.c
··· 998 page = sblock->pagev + page_index; 999 page->logical = logical; 1000 page->physical = bbio->stripes[mirror_index].physical; 1001 page->bdev = bbio->stripes[mirror_index].dev->bdev; 1002 page->mirror_num = mirror_index + 1; 1003 page->page = alloc_page(GFP_NOFS); ··· 1042 int ret; 1043 struct scrub_page *page = sblock->pagev + page_num; 1044 DECLARE_COMPLETION_ONSTACK(complete); 1045 1046 BUG_ON(!page->page); 1047 bio = bio_alloc(GFP_NOFS, 1);
··· 998 page = sblock->pagev + page_index; 999 page->logical = logical; 1000 page->physical = bbio->stripes[mirror_index].physical; 1001 + /* for missing devices, bdev is NULL */ 1002 page->bdev = bbio->stripes[mirror_index].dev->bdev; 1003 page->mirror_num = mirror_index + 1; 1004 page->page = alloc_page(GFP_NOFS); ··· 1041 int ret; 1042 struct scrub_page *page = sblock->pagev + page_num; 1043 DECLARE_COMPLETION_ONSTACK(complete); 1044 + 1045 + if (page->bdev == NULL) { 1046 + page->io_error = 1; 1047 + sblock->no_io_error_seen = 0; 1048 + continue; 1049 + } 1050 1051 BUG_ON(!page->page); 1052 bio = bio_alloc(GFP_NOFS, 1);