loader ptblread() is broken with >512B sectors

The loader strategy() function is assuming 512B blocks, so we need to adjust
ptblread() for other sector sizes.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D12847
This commit is contained in:
Toomas Soome 2017-10-31 20:29:31 +00:00
parent 939d033cab
commit 24b4ce2fe0

View File

@ -88,6 +88,12 @@ ptblread(void *d, void *buf, size_t blocks, uint64_t offset)
dev = (struct disk_devdesc *)d;
od = (struct open_disk *)dev->d_opendata;
/*
* The strategy function assumes the offset is in units of 512 byte
* sectors. For larger sector sizes, we need to adjust the offset to
* match the actual sector size.
*/
offset *= (od->sectorsize / 512);
/*
* As the GPT backup partition is located at the end of the disk,
* to avoid reading past disk end, flag bcache not to use RA.