sendfile: remove SF_SYNC in FreeBSD 16.0
See d17cbe4698 for details.
PR: 287348
This commit is contained in:
@@ -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 @@ vn_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio,
|
||||
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);
|
||||
|
||||
+1
-1
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user