Date: Wed, 19 Nov 2014 05:46:28 +0000 (UTC) From: Gleb Smirnoff <glebius@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r274686 - in projects/sendfile/sys: kern sys Message-ID: <201411190546.sAJ5kS4m009883@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: glebius Date: Wed Nov 19 05:46:27 2014 New Revision: 274686 URL: https://svnweb.freebsd.org/changeset/base/274686 Log: Revert M_SBCUT changes, the flag isn't actually needed. If sf_iodone() does soisdisconnected() in case of I/O error, then PCB would be marked dropped and if any more I/Os are pending on this socket, they will free their mbufs in tcp_usr_ready(). Sponsored by: Netflix Sponsored by: Nginx, Inc. Modified: projects/sendfile/sys/kern/uipc_sockbuf.c projects/sendfile/sys/kern/uipc_syscalls.c projects/sendfile/sys/sys/sockbuf.h Modified: projects/sendfile/sys/kern/uipc_sockbuf.c ============================================================================== --- projects/sendfile/sys/kern/uipc_sockbuf.c Wed Nov 19 05:43:31 2014 (r274685) +++ projects/sendfile/sys/kern/uipc_sockbuf.c Wed Nov 19 05:46:27 2014 (r274686) @@ -77,21 +77,6 @@ sbready(struct sockbuf *sb, struct mbuf u_int blocker; SOCKBUF_LOCK_ASSERT(sb); - - if (m->m_flags & M_SBCUT) { - /* - * Oops, something bad happened to the socket buffer while - * we were working on the data. Our mbufs are detached from - * the sockbuf, and all what we can do is free them. - */ - for (int i = 0; i < count; i++) { - KASSERT(m->m_flags & M_SBCUT, - ("%s: m %p !M_SBCUT", __func__, m)); - m = m_free(m); - } - return (EPIPE); - } - KASSERT(sb->sb_fnrdy != NULL, ("%s: sb %p NULL fnrdy", __func__, sb)); blocker = (sb->sb_fnrdy == m) ? M_BLOCKED : 0; @@ -1032,7 +1017,7 @@ sbflush(struct sockbuf *sb) static struct mbuf * sbcut_internal(struct sockbuf *sb, int len) { - struct mbuf *m, *n, *next, *mfree; + struct mbuf *m, *next, *mfree; next = (m = sb->sb_mb) ? m->m_nextpkt : 0; mfree = NULL; @@ -1058,14 +1043,20 @@ sbcut_internal(struct sockbuf *sb, int l } len -= m->m_len; sbfree(sb, m); - n = m->m_next; + /* + * Do not put M_NOTREADY buffers to the free list, they + * are referenced from outside. + */ if (m->m_flags & M_NOTREADY) - m->m_flags |= M_SBCUT; + m = m->m_next; else { + struct mbuf *n; + + n = m->m_next; m->m_next = mfree; mfree = m; + m = n; } - m = n; } if (m) { sb->sb_mb = m; Modified: projects/sendfile/sys/kern/uipc_syscalls.c ============================================================================== --- projects/sendfile/sys/kern/uipc_syscalls.c Wed Nov 19 05:43:31 2014 (r274685) +++ projects/sendfile/sys/kern/uipc_syscalls.c Wed Nov 19 05:46:27 2014 (r274686) @@ -2092,10 +2092,8 @@ sf_iodone(void *arg, vm_page_t *pg, int * for read, so that application receives EIO on next * syscall and eventually closes the socket. */ - SOCKBUF_LOCK(&(so)->so_snd); - sbflush_locked(&so->so_snd); so->so_error = EIO; - sowakeup((so), &(so)->so_snd); + soisdisconnected(so); m = sfio->m; for (int i = 0; i < sfio->npages; i++) Modified: projects/sendfile/sys/sys/sockbuf.h ============================================================================== --- projects/sendfile/sys/sys/sockbuf.h Wed Nov 19 05:43:31 2014 (r274685) +++ projects/sendfile/sys/sys/sockbuf.h Wed Nov 19 05:46:27 2014 (r274686) @@ -128,7 +128,6 @@ struct sockbuf { #define M_NOTREADY M_PROTO1 /* m_data not populated yet */ #define M_BLOCKED M_PROTO2 /* M_NOTREADY in front of m */ #define M_NOTAVAIL (M_NOTREADY | M_BLOCKED) -#define M_SBCUT M_PROTO3 /* mbuf was sbcut out */ void sbappend(struct sockbuf *sb, struct mbuf *m); void sbappend_locked(struct sockbuf *sb, struct mbuf *m);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201411190546.sAJ5kS4m009883>