From: David Zeuthen Date: Mon, 22 May 2017 21:49:40 +0000 (-0400) Subject: ANDROID: AVB: Fix invalidate_vbmeta_submit(). X-Git-Tag: release-20171130_firefly~4^2~100^2~99 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=babfac7507b39b2544785771bbdd202b602bd2a1;p=firefly-linux-kernel-4.4.55.git ANDROID: AVB: Fix invalidate_vbmeta_submit(). On some boards with newer kernels the invalidate_vbmeta_submit() function failed likely because it's using a hard-coded size of 512. Use PAGE_SIZE and also use bio_add_page(). Also print out if the I/O actually fails. Additionally, print major:minor of the device we're acting on since another subset of boards get this wrong by passing the wrong GUID to libavb in the bootloader. Having this information printed out makes it a lot easier to pinpoint such mistakes. Test: Manually tested. Bug: 38451312 Change-Id: Ib58548953a3375a3c79acf74aa745be9420b8216 Signed-off-by: David Zeuthen --- diff --git a/drivers/md/dm-verity-avb.c b/drivers/md/dm-verity-avb.c index a0ee31e0dd09..7486dd7fb16d 100644 --- a/drivers/md/dm-verity-avb.c +++ b/drivers/md/dm-verity-avb.c @@ -18,6 +18,8 @@ static char avb_invalidate_on_error[4]; static void invalidate_vbmeta_endio(struct bio *bio) { + if (bio->bi_error) + DMERR("invalidate_vbmeta_endio: error %d", bio->bi_error); complete(bio->bi_private); } @@ -31,20 +33,17 @@ static int invalidate_vbmeta_submit(struct bio *bio, bio->bi_private = &wait; bio->bi_end_io = invalidate_vbmeta_endio; bio->bi_bdev = bdev; + bio->bi_rw = rw; bio->bi_iter.bi_sector = 0; if (access_last_sector) { sector_t last_sector = (i_size_read(bdev->bd_inode)>>SECTOR_SHIFT) - 1; bio->bi_iter.bi_sector = last_sector; } - bio->bi_vcnt = 1; - bio->bi_iter.bi_idx = 0; - bio->bi_iter.bi_size = 512; - bio->bi_iter.bi_bvec_done = 0; - bio->bi_rw = rw; - bio->bi_io_vec[0].bv_page = page; - bio->bi_io_vec[0].bv_len = 512; - bio->bi_io_vec[0].bv_offset = 0; + if (!bio_add_page(bio, page, PAGE_SIZE, 0)) { + DMERR("invalidate_vbmeta_submit: bio_add_page error"); + return -EIO; + } submit_bio(rw, bio); /* Wait up to 2 seconds for completion or fail. */ @@ -66,6 +65,9 @@ static int invalidate_vbmeta(dev_t vbmeta_devt) int rw = REQ_SYNC | REQ_SOFTBARRIER | REQ_NOIDLE; int access_last_sector = 0; + DMINFO("invalidate_vbmeta: acting on device %d:%d", + MAJOR(vbmeta_devt), MINOR(vbmeta_devt)); + /* First we open the device for reading. */ dev_mode = FMODE_READ | FMODE_EXCL; bdev = blkdev_get_by_dev(vbmeta_devt, dev_mode,