From owner-svn-src-projects@FreeBSD.ORG Wed Nov 19 05:46:29 2014 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DAA8DA5A; Wed, 19 Nov 2014 05:46:28 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C737BDF6; Wed, 19 Nov 2014 05:46:28 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sAJ5kSD6009886; Wed, 19 Nov 2014 05:46:28 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sAJ5kS4m009883; Wed, 19 Nov 2014 05:46:28 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201411190546.sAJ5kS4m009883@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Wed, 19 Nov 2014 05:46:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r274686 - in projects/sendfile/sys: kern sys X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Nov 2014 05:46:29 -0000 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);