Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Nov 2013 07:36:41 +0000 (UTC)
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r258616 - projects/sendfile/sys/kern
Message-ID:  <201311260736.rAQ7af23056342@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201311260736.rAQ7af23056342>