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
This commit is contained in:
parent
5a06cb0ca6
commit
89e9e6e7c5
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=95051
@ -1779,8 +1779,6 @@ sendfile(struct thread *td, struct sendfile_args *uap)
|
||||
*/
|
||||
|
||||
if (!pg->valid || !vm_page_is_valid(pg, pgoff, xfsize)) {
|
||||
struct uio auio;
|
||||
struct iovec aiov;
|
||||
int bsize;
|
||||
|
||||
/*
|
||||
@ -1793,18 +1791,11 @@ sendfile(struct thread *td, struct sendfile_args *uap)
|
||||
* 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);
|
||||
|
Loading…
Reference in New Issue
Block a user