Page MenuHomeFreeBSD

Fix sendfile over tmpfs
ClosedPublic

Authored by kib on Wed, Jan 14, 3:46 PM.
Tags
None
Referenced Files
F142349673: D54713.diff
Sun, Jan 18, 9:58 PM
F142324261: D54713.diff
Sun, Jan 18, 2:32 PM
Unknown Object (File)
Thu, Jan 15, 12:43 PM
Unknown Object (File)
Thu, Jan 15, 8:33 AM
Unknown Object (File)
Wed, Jan 14, 6:59 PM
Unknown Object (File)
Wed, Jan 14, 6:51 PM
Unknown Object (File)
Wed, Jan 14, 6:29 PM
Subscribers

Details

Summary
sendfile: remove calculation of unused bsize


swap_pager_getpages(): assert that bp->b_pages[] is accessed in bounds


swap_pager_getpages(): some pages from ma[] might be bogus

Same as vnode_pager_generic_getpages_async(), swap_pager_getpages() must
handle a possibility of the provided page run to include bogus_page on
some positions, when called from sendfile_swapin().  The swap pager is
used for tmpfs vnodes.

In particular, the bogus page must not be used for pindex calculation,
we better not update the flags on it or wait for the flag clearing, and
we must not call vm_page_valid() because the function expects busy page.

This was bisected down to 72ddb6de1028426 (unix: increase
net.local.(stream|seqpacket).(recv|send)space to 64 KiB),
which is somewhat surprising, but apparently reasonable because it
allowed the run of more than one page for page-in from the swap pager,
which now might include valid pages replaced by bogus one.

In collaboration with:    pho

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib requested review of this revision.Wed, Jan 14, 3:46 PM
This revision is now accepted and ready to land.Wed, Jan 14, 5:09 PM

I wonder why we bother with bogus page replacement in sendfile_swapin(). Why not pass valid pages to the pager and let it decide how to handle it?

I wonder why we bother with bogus page replacement in sendfile_swapin(). Why not pass valid pages to the pager and let it decide how to handle it?

We traditionally do it outside the pagers level. The bogus_page was added as a necessary hack to the buffer cache only. Then it appeared that sendfile must do the same.
I believe that we cannot eliminate bogus_page use from the buffer cache even if it is pushed into the pagers getpage() implementations.
So in the end we would get more places contaminated with the avoidance of the valid pages.

But technically it is possible to do.