summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2002-04-19 13:46:24 +0000
committerrwatson <rwatson@FreeBSD.org>2002-04-19 13:46:24 +0000
commit4d39491e7e33d322000e9be9d34efe77e4c0b080 (patch)
treee275a8db8c380fc55be579c4f41c0ea9e9b755f1
parent63ab78794ef71a08d97b6d4a56e5031a29e86e95 (diff)
downloadFreeBSD-src-4d39491e7e33d322000e9be9d34efe77e4c0b080.zip
FreeBSD-src-4d39491e7e33d322000e9be9d34efe77e4c0b080.tar.gz
In sendfile(), use the vn_rdwr() helper function, rather than manually
constructing a struct aio and invoking VOP_READ() directly. This cleans up the code a little, but also has the advantage of making sure almost all vnode read/write access in the kernel goes through the helper function, meaning that instrumentation of that helper function can impact almost all relevant read/write operations. In this case, it permits us to put MAC hooks into vn_rdwr() and not modify uipc_syscalls.c (yet). In general, if helper vn_*() functions exist, they should be used in preference to direct VOP's in system call service code. Submitted by: green Obtained from: TrustedBSD Project Sponsored by: DARPA, NAI Labs
-rw-r--r--sys/kern/uipc_syscalls.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index 56b8fee..f80dcc9 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -1779,8 +1779,6 @@ retry_lookup:
*/
if (!pg->valid || !vm_page_is_valid(pg, pgoff, xfsize)) {
- struct uio auio;
- struct iovec aiov;
int bsize;
/*
@@ -1793,18 +1791,11 @@ retry_lookup:
* Get the page from backing store.
*/
bsize = vp->v_mount->mnt_stat.f_iosize;
- auio.uio_iov = &aiov;
- auio.uio_iovcnt = 1;
- aiov.iov_base = 0;
- aiov.iov_len = MAXBSIZE;
- auio.uio_resid = MAXBSIZE;
- auio.uio_offset = trunc_page(off);
- auio.uio_segflg = UIO_NOCOPY;
- auio.uio_rw = UIO_READ;
- auio.uio_td = td;
vn_lock(vp, LK_SHARED | LK_NOPAUSE | LK_RETRY, td);
- error = VOP_READ(vp, &auio, IO_VMIO | ((MAXBSIZE / bsize) << 16),
- td->td_ucred);
+ error = vn_rdwr(UIO_READ, vp, NULL, MAXBSIZE,
+ trunc_page(off), UIO_NOCOPY, IO_NODELOCKED |
+ IO_VMIO | ((MAXBSIZE / bsize) << 16),
+ td->td_ucred, NULL, td);
VOP_UNLOCK(vp, 0, td);
vm_page_flag_clear(pg, PG_ZERO);
vm_page_io_finish(pg);
OpenPOWER on IntegriCloud