The branch main has been updated by glebius:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=d17cbe46983c08ba0567b0ffd71434abd35aa205

commit d17cbe46983c08ba0567b0ffd71434abd35aa205
Author:     Gleb Smirnoff <gleb...@freebsd.org>
AuthorDate: 2025-06-24 21:26:10 +0000
Commit:     Gleb Smirnoff <gleb...@freebsd.org>
CommitDate: 2025-06-24 22:24:04 +0000

    sendfile: retire SF_SYNC
    
    The flag was added in b75a1171d8ba4 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
---
 lib/libsys/sendfile.2    | 8 +-------
 sys/kern/kern_sendfile.c | 6 +++++-
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/lib/libsys/sendfile.2 b/lib/libsys/sendfile.2
index 07a563d5ef82..6000e3e9828f 100644
--- a/lib/libsys/sendfile.2
+++ b/lib/libsys/sendfile.2
@@ -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.
diff --git a/sys/kern/kern_sendfile.c b/sys/kern/kern_sendfile.c
index 25c1f357dfd4..17b53208157a 100644
--- a/sys/kern/kern_sendfile.c
+++ b/sys/kern/kern_sendfile.c
@@ -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");

Reply via email to