Change a rounding operation that had missing braces into a roundup2()
macro. Adjust the buffer clipping code to work as expected. This prevented a number of machines in the FreeBSD.org cluster from booting due to "ZFS: i/o error - all block copies unavailable" after an unclean shutdown.
This commit is contained in:
parent
d546e47aa0
commit
d8818fce69
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=298949
@ -224,21 +224,18 @@ vdev_read(vdev_t *vdev, void *priv, off_t off, void *buf, size_t bytes)
|
|||||||
|
|
||||||
while (bytes > 0) {
|
while (bytes > 0) {
|
||||||
nb = bytes / DEV_BSIZE;
|
nb = bytes / DEV_BSIZE;
|
||||||
if (nb > READ_BUF_SIZE / DEV_BSIZE)
|
|
||||||
nb = READ_BUF_SIZE / DEV_BSIZE;
|
|
||||||
/*
|
/*
|
||||||
* Ensure that the read size plus the leading offset does not
|
* Ensure that the read size plus the leading offset does not
|
||||||
* exceed the size of the read buffer.
|
* exceed the size of the read buffer.
|
||||||
*/
|
*/
|
||||||
if (nb * DEV_BSIZE + diff > READ_BUF_SIZE)
|
if (nb > (READ_BUF_SIZE - diff) / DEV_BSIZE)
|
||||||
nb -= diff / DEV_BSIZE;
|
nb = (READ_BUF_SIZE - diff) / DEV_BSIZE;
|
||||||
/*
|
/*
|
||||||
* Round the number of blocks to read up to the nearest multiple
|
* Round the number of blocks to read up to the nearest multiple
|
||||||
* of DEV_GELIBOOT_BSIZE.
|
* of DEV_GELIBOOT_BSIZE.
|
||||||
*/
|
*/
|
||||||
alignnb = nb + (diff / DEV_BSIZE) +
|
alignnb = roundup2(nb * DEV_BSIZE + diff, DEV_GELIBOOT_BSIZE)
|
||||||
(DEV_GELIBOOT_BSIZE / DEV_BSIZE - 1) & ~
|
/ DEV_BSIZE;
|
||||||
(unsigned int)(DEV_GELIBOOT_BSIZE / DEV_BSIZE - 1);
|
|
||||||
|
|
||||||
if (drvread(dsk, dmadat->rdbuf, alignlba, alignnb))
|
if (drvread(dsk, dmadat->rdbuf, alignlba, alignnb))
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user