From owner-svn-src-all@FreeBSD.ORG Tue Nov 26 02:02:06 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 08CDBD58; Tue, 26 Nov 2013 02:02:06 +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)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id EBAC42956; Tue, 26 Nov 2013 02:02:05 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rAQ225WO042666; Tue, 26 Nov 2013 02:02:05 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id rAQ225Ux042665; Tue, 26 Nov 2013 02:02:05 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201311260202.rAQ225Ux042665@svn.freebsd.org> From: Adrian Chadd Date: Tue, 26 Nov 2013 02:02:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r258613 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Nov 2013 02:02:06 -0000 Author: adrian Date: Tue Nov 26 02:02:05 2013 New Revision: 258613 URL: http://svnweb.freebsd.org/changeset/base/258613 Log: Refactor out the sendfile copyout in order to make vn_sendfile() callable from the kernel. Right now vn_sendfile() can't be called from anything other than a syscall handler _and_ return the number of bytes queued. This simply moves the copyout() to do_sendfile() so that any kernel code can initiate vn_sendfile() outside of a syscall context. Tested: * tiny little sendfile program spitting things out a tcp socket Sponsored by: Netflix, Inc. Modified: head/sys/kern/uipc_syscalls.c Modified: head/sys/kern/uipc_syscalls.c ============================================================================== --- head/sys/kern/uipc_syscalls.c Tue Nov 26 01:30:10 2013 (r258612) +++ head/sys/kern/uipc_syscalls.c Tue Nov 26 02:02:05 2013 (r258613) @@ -1908,6 +1908,7 @@ do_sendfile(struct thread *td, struct se struct file *fp; cap_rights_t rights; int error; + off_t sbytes; /* * File offset must be positive. If it goes beyond EOF @@ -1947,9 +1948,11 @@ do_sendfile(struct thread *td, struct se } error = fo_sendfile(fp, uap->s, hdr_uio, trl_uio, uap->offset, - uap->nbytes, uap->sbytes, uap->flags, compat ? SFK_COMPAT : 0, td); + uap->nbytes, &sbytes, uap->flags, compat ? SFK_COMPAT : 0, td); fdrop(fp, td); - + if (uap->sbytes != NULL) { + copyout(&sbytes, uap->sbytes, sizeof(off_t)); + } out: free(hdr_uio, M_IOV); free(trl_uio, M_IOV); @@ -2546,7 +2549,7 @@ out: td->td_retval[0] = 0; } if (sent != NULL) { - copyout(&sbytes, sent, sizeof(off_t)); + (*sent) = sbytes; } if (obj != NULL) vm_object_deallocate(obj);