From owner-svn-src-projects@FreeBSD.ORG Tue Nov 26 07:36:41 2013 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 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B44554A8; Tue, 26 Nov 2013 07:36:41 +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 899E32828; Tue, 26 Nov 2013 07:36:41 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rAQ7afZ7056343; Tue, 26 Nov 2013 07:36:41 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id rAQ7af23056342; Tue, 26 Nov 2013 07:36:41 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201311260736.rAQ7af23056342@svn.freebsd.org> From: Gleb Smirnoff Date: Tue, 26 Nov 2013 07:36:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r258616 - projects/sendfile/sys/kern 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.16 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: Tue, 26 Nov 2013 07:36:41 -0000 Author: glebius Date: Tue Nov 26 07:36:41 2013 New Revision: 258616 URL: http://svnweb.freebsd.org/changeset/base/258616 Log: Use VOP_READ() instead of vn_rdwr(). The plan is to use other special VOP later. Sponsored by: Netflix Sponsored by: Nginx, Inc. Modified: projects/sendfile/sys/kern/uipc_syscalls.c Modified: projects/sendfile/sys/kern/uipc_syscalls.c ============================================================================== --- projects/sendfile/sys/kern/uipc_syscalls.c Tue Nov 26 05:26:10 2013 (r258615) +++ projects/sendfile/sys/kern/uipc_syscalls.c Tue Nov 26 07:36:41 2013 (r258616) @@ -1981,7 +1981,7 @@ sendfile_readpage(vm_object_t obj, struc vm_page_t m; vm_pindex_t pindex; ssize_t resid; - int error, readahead, rv; + int error, rv; pindex = OFF_TO_IDX(off); VM_OBJECT_WLOCK(obj); @@ -2015,20 +2015,43 @@ sendfile_readpage(vm_object_t obj, struc */ error = 0; if (vp != NULL) { + struct uio auio; + struct iovec aiov; + int readahead; + VM_OBJECT_WUNLOCK(obj); +#ifdef MAC + /* + * XXX: Because we don't have fp->f_cred here, we + * pass in NOCRED. This is probably wrong, but is + * consistent with our original implementation. + */ + error = mac_vnode_check_read(td->td_ucred, NOCRED, vp); + if (error) + goto free_page; +#endif + readahead = sfreadahead * MAXBSIZE; + auio.uio_iov = &aiov; + auio.uio_iovcnt = 1; + aiov.iov_base = NULL; + aiov.iov_len = readahead; + auio.uio_resid = readahead; + auio.uio_offset = trunc_page(off); + auio.uio_segflg = UIO_NOCOPY; + auio.uio_rw = UIO_READ; + auio.uio_td = td; + /* - * Use vn_rdwr() instead of the pager interface for + * Use VOP_READ() instead of the pager interface for * the vnode, to allow the read-ahead. - * - * XXXMAC: Because we don't have fp->f_cred here, we - * pass in NOCRED. This is probably wrong, but is - * consistent with our original implementation. */ - error = vn_rdwr(UIO_READ, vp, NULL, readahead, trunc_page(off), - UIO_NOCOPY, IO_NODELOCKED | IO_VMIO | ((readahead / - bsize) << IO_SEQSHIFT), td->td_ucred, NOCRED, &resid, td); + error = VOP_READ(vp, &auio, IO_NODELOCKED | IO_VMIO | + ((readahead / bsize) << IO_SEQSHIFT), td->td_ucred); + + resid = auio.uio_resid; + SFSTAT_INC(sf_iocnt); VM_OBJECT_WLOCK(obj); } else {