sendfile: retire SF_SYNC

The flag was added in b75a1171d8 for the sake of Varnish.  However, that
idea didn't work.  Quoting email from Poul-Henning:

"We had to give up sendfile(), the overhead of keeping track of everything
between the network stack and VM system made ate any gain we saw. ... I
dont think we ever shipped a version where sendfile was enabled by
default."

PR:	287348
This commit is contained in:
Gleb Smirnoff 2025-06-24 14:26:10 -07:00
parent eabb9f6000
commit d17cbe4698
2 changed files with 6 additions and 8 deletions

View file

@ -23,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd March 30, 2020
.Dd June 24, 2025
.Dt SENDFILE 2
.Os
.Sh NAME
@ -147,12 +147,6 @@ in a different context.
.It Dv SF_NOCACHE
The data sent to socket will not be cached by the virtual memory system,
and will be freed directly to the pool of free pages.
.It Dv SF_SYNC
.Nm
sleeps until the network stack no longer references the VM pages
of the file, making subsequent modifications to it safe.
Please note that this is not a guarantee that the data has actually
been sent.
.It Dv SF_USER_READAHEAD
.Nm
has some internal heuristics to do readahead when sending data.

View file

@ -798,7 +798,11 @@ vn_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio,
SFSTAT_INC(sf_syscalls);
SFSTAT_ADD(sf_rhpages_requested, SF_READAHEAD(flags));
if (flags & SF_SYNC) {
if (__predict_false(flags & SF_SYNC)) {
gone_in(16, "Warning! %s[%u] uses SF_SYNC sendfile(2) flag. "
"Please follow up to https://bugs.freebsd.org/"
"bugzilla/show_bug.cgi?id=287348. ",
td->td_proc->p_comm, td->td_proc->p_pid);
sfs = malloc(sizeof(*sfs), M_SENDFILE, M_WAITOK | M_ZERO);
mtx_init(&sfs->mtx, "sendfile", NULL, MTX_DEF);
cv_init(&sfs->cv, "sendfile");