Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 04 Dec 2025 16:44:52 +0000
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 575efcfff22f - main - sendfile: remove SF_SYNC in FreeBSD 16.0
Message-ID:  <6931ba84.3a188.2d5227ac@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by glebius:

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

commit 575efcfff22f5d75fc3ac6201f11e5eae46ec9ce
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2025-12-04 16:37:10 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2025-12-04 16:44:21 +0000

    sendfile: remove SF_SYNC in FreeBSD 16.0
    
    See d17cbe46983c for details.
    
    PR:     287348
---
 sys/kern/kern_sendfile.c | 88 ------------------------------------------------
 sys/sys/socket.h         |  2 +-
 2 files changed, 1 insertion(+), 89 deletions(-)

diff --git a/sys/kern/kern_sendfile.c b/sys/kern/kern_sendfile.c
index 8438298afc0e..7ffb09c58b9c 100644
--- a/sys/kern/kern_sendfile.c
+++ b/sys/kern/kern_sendfile.c
@@ -68,7 +68,6 @@
 
 static MALLOC_DEFINE(M_SENDFILE, "sendfile", "sendfile dynamic memory");
 
-#define	EXT_FLAG_SYNC		EXT_FLAG_VENDOR1
 #define	EXT_FLAG_NOCACHE	EXT_FLAG_VENDOR2
 #define	EXT_FLAG_CACHE_LAST	EXT_FLAG_VENDOR3
 
@@ -100,43 +99,6 @@ struct sf_io {
 	vm_page_t	pa[];
 };
 
-/*
- * Structure used to track requests with SF_SYNC flag.
- */
-struct sendfile_sync {
-	struct mtx	mtx;
-	struct cv	cv;
-	unsigned	count;
-	bool		waiting;
-};
-
-static void
-sendfile_sync_destroy(struct sendfile_sync *sfs)
-{
-	KASSERT(sfs->count == 0, ("sendfile sync %p still busy", sfs));
-
-	cv_destroy(&sfs->cv);
-	mtx_destroy(&sfs->mtx);
-	free(sfs, M_SENDFILE);
-}
-
-static void
-sendfile_sync_signal(struct sendfile_sync *sfs)
-{
-	mtx_lock(&sfs->mtx);
-	KASSERT(sfs->count > 0, ("sendfile sync %p not busy", sfs));
-	if (--sfs->count == 0) {
-		if (!sfs->waiting) {
-			/* The sendfile() waiter was interrupted by a signal. */
-			sendfile_sync_destroy(sfs);
-			return;
-		} else {
-			cv_signal(&sfs->cv);
-		}
-	}
-	mtx_unlock(&sfs->mtx);
-}
-
 counter_u64_t sfstat[sizeof(struct sfstat) / sizeof(uint64_t)];
 
 static void
@@ -179,11 +141,6 @@ sendfile_free_mext(struct mbuf *m)
 
 	sf_buf_free(sf);
 	vm_page_release(pg, flags);
-
-	if (m->m_ext.ext_flags & EXT_FLAG_SYNC) {
-		struct sendfile_sync *sfs = m->m_ext.ext_arg2;
-		sendfile_sync_signal(sfs);
-	}
 }
 
 static void
@@ -204,11 +161,6 @@ sendfile_free_mext_pg(struct mbuf *m)
 		pg = PHYS_TO_VM_PAGE(m->m_epg_pa[i]);
 		vm_page_release(pg, flags);
 	}
-
-	if (m->m_ext.ext_flags & EXT_FLAG_SYNC) {
-		struct sendfile_sync *sfs = m->m_ext.ext_arg1;
-		sendfile_sync_signal(sfs);
-	}
 }
 
 /*
@@ -763,7 +715,6 @@ vn_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio,
 	struct mbuf *m, *mh, *mhtail;
 	struct sf_buf *sf;
 	struct shmfd *shmfd;
-	struct sendfile_sync *sfs;
 	struct vattr va;
 	off_t off, sbytes, rem, obj_size, nobj_size;
 	int bsize, error, ext_pgs_idx, hdrlen, max_pgs, softerr;
@@ -775,7 +726,6 @@ vn_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio,
 	obj = NULL;
 	so = NULL;
 	m = mh = NULL;
-	sfs = NULL;
 #ifdef KERN_TLS
 	tls = NULL;
 #endif
@@ -801,17 +751,6 @@ vn_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio,
 	SFSTAT_INC(sf_syscalls);
 	SFSTAT_ADD(sf_rhpages_requested, SF_READAHEAD(flags));
 
-	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");
-		sfs->waiting = true;
-	}
-
 	rem = nbytes ? omin(nbytes, obj_size - offset) : obj_size - offset;
 
 	/*
@@ -1042,14 +981,6 @@ vn_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio,
 							m0->m_ext.ext_flags |=
 							    EXT_FLAG_CACHE_LAST;
 					}
-					if (sfs != NULL) {
-						m0->m_ext.ext_flags |=
-						    EXT_FLAG_SYNC;
-						m0->m_ext.ext_arg1 = sfs;
-						mtx_lock(&sfs->mtx);
-						sfs->count++;
-						mtx_unlock(&sfs->mtx);
-					}
 					ext_pgs_idx = 0;
 
 					/* Append to mbuf chain. */
@@ -1120,13 +1051,6 @@ vn_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio,
 			    !((off + space) & PAGE_MASK) ||
 			    !(rem > space || rhpages > 0)))
 				m0->m_ext.ext_flags |= EXT_FLAG_NOCACHE;
-			if (sfs != NULL) {
-				m0->m_ext.ext_flags |= EXT_FLAG_SYNC;
-				m0->m_ext.ext_arg2 = sfs;
-				mtx_lock(&sfs->mtx);
-				sfs->count++;
-				mtx_unlock(&sfs->mtx);
-			}
 			m0->m_ext.ext_count = 1;
 			m0->m_flags |= (M_EXT | M_RDONLY);
 			if (nios)
@@ -1263,18 +1187,6 @@ out:
 		m_freem(m);
 	if (mh)
 		m_freem(mh);
-
-	if (sfs != NULL) {
-		mtx_lock(&sfs->mtx);
-		if (sfs->count != 0)
-			error = cv_wait_sig(&sfs->cv, &sfs->mtx);
-		if (sfs->count == 0) {
-			sendfile_sync_destroy(sfs);
-		} else {
-			sfs->waiting = false;
-			mtx_unlock(&sfs->mtx);
-		}
-	}
 #ifdef KERN_TLS
 	if (tls != NULL)
 		ktls_free(tls);
diff --git a/sys/sys/socket.h b/sys/sys/socket.h
index cf1d95da6168..76a1652644bd 100644
--- a/sys/sys/socket.h
+++ b/sys/sys/socket.h
@@ -662,7 +662,7 @@ struct sf_hdtr {
  */
 #define	SF_NODISKIO     0x00000001
 #define	SF_MNOWAIT	0x00000002	/* obsolete */
-#define	SF_SYNC		0x00000004
+/* was	SF_SYNC		0x00000004	*/
 #define	SF_USER_READAHEAD	0x00000008
 #define	SF_NOCACHE	0x00000010
 #define	SF_FLAGS(rh, flags)	(((rh) << 16) | (flags))


help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6931ba84.3a188.2d5227ac>