The pa argument for sendfile_iodone() is not necessary a slice of sfio->pa.

It is true for zfs, but it is not for e.g. vnode or buffer pagers.
When fixing bogus pages, fix them in both places.  Rely on the fact
that pa[0] must have been invalid so it cannot be bogus.

Reported and tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
This commit is contained in:
Konstantin Belousov 2020-04-18 03:07:18 +00:00
parent 5c68be59c8
commit e795a04083
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=360065

View File

@ -295,10 +295,12 @@ sendfile_iodone(void *arg, vm_page_t *pa, int count, int error)
* unbusied the swapped-in pages, they can become
* invalid under us.
*/
MPASS(count == 0 || pa[0] != bogus_page);
for (i = 0; i < count; i++) {
if (pa[i] == bogus_page) {
pa[i] = vm_page_relookup(sfio->obj,
sfio->pindex0 + i + (pa - sfio->pa));
sfio->pa[(pa[0]->pindex - sfio->pindex0) + i] =
pa[i] = vm_page_relookup(sfio->obj,
pa[0]->pindex + i);
KASSERT(pa[i] != NULL,
("%s: page %p[%d] disappeared",
__func__, pa, i));