Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/vfs_vnops.c
Show First 20 Lines • Show All 914 Lines • ▼ Show 20 Lines | get_advice(struct file *fp, struct uio *uio) | ||||
if (fp->f_advice != NULL && | if (fp->f_advice != NULL && | ||||
uio->uio_offset >= fp->f_advice->fa_start && | uio->uio_offset >= fp->f_advice->fa_start && | ||||
uio->uio_offset + uio->uio_resid <= fp->f_advice->fa_end) | uio->uio_offset + uio->uio_resid <= fp->f_advice->fa_end) | ||||
ret = fp->f_advice->fa_advice; | ret = fp->f_advice->fa_advice; | ||||
mtx_unlock(mtxp); | mtx_unlock(mtxp); | ||||
return (ret); | return (ret); | ||||
} | } | ||||
static int | |||||
get_write_ioflag(struct file *fp) | |||||
{ | |||||
int ioflag; | |||||
struct mount *mp; | |||||
struct vnode *vp; | |||||
ioflag = 0; | |||||
vp = fp->f_vnode; | |||||
mp = atomic_load_ptr(&vp->v_mount); | |||||
if ((fp->f_flag & O_DIRECT) != 0) | |||||
ioflag |= IO_DIRECT; | |||||
if ((fp->f_flag & O_FSYNC) != 0 || | |||||
(mp != NULL && (mp->mnt_flag & MNT_SYNCHRONOUS) != 0)) | |||||
ioflag |= IO_SYNC; | |||||
/* | |||||
* For O_DSYNC we set both IO_SYNC and IO_DATASYNC, so that VOP_WRITE() | |||||
* or VOP_DEALLOCATE() implementations that don't understand IO_DATASYNC | |||||
* fall back to full O_SYNC behavior. | |||||
*/ | |||||
if ((fp->f_flag & O_DSYNC) != 0) | |||||
ioflag |= IO_SYNC | IO_DATASYNC; | |||||
return (ioflag); | |||||
} | |||||
int | int | ||||
vn_read_from_obj(struct vnode *vp, struct uio *uio) | vn_read_from_obj(struct vnode *vp, struct uio *uio) | ||||
{ | { | ||||
vm_object_t obj; | vm_object_t obj; | ||||
vm_page_t ma[io_hold_cnt + 2]; | vm_page_t ma[io_hold_cnt + 2]; | ||||
off_t off, vsz; | off_t off, vsz; | ||||
ssize_t resid; | ssize_t resid; | ||||
int error, i, j; | int error, i, j; | ||||
▲ Show 20 Lines • Show All 183 Lines • ▼ Show 20 Lines | vn_write(struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, | ||||
KASSERT(uio->uio_td == td, ("uio_td %p is not td %p", | KASSERT(uio->uio_td == td, ("uio_td %p is not td %p", | ||||
uio->uio_td, td)); | uio->uio_td, td)); | ||||
KASSERT(flags & FOF_OFFSET, ("No FOF_OFFSET")); | KASSERT(flags & FOF_OFFSET, ("No FOF_OFFSET")); | ||||
vp = fp->f_vnode; | vp = fp->f_vnode; | ||||
if (vp->v_type == VREG) | if (vp->v_type == VREG) | ||||
bwillwrite(); | bwillwrite(); | ||||
ioflag = IO_UNIT; | ioflag = IO_UNIT; | ||||
if (vp->v_type == VREG && (fp->f_flag & O_APPEND)) | if (vp->v_type == VREG && (fp->f_flag & O_APPEND) != 0) | ||||
ioflag |= IO_APPEND; | ioflag |= IO_APPEND; | ||||
if (fp->f_flag & FNONBLOCK) | if ((fp->f_flag & FNONBLOCK) != 0) | ||||
ioflag |= IO_NDELAY; | ioflag |= IO_NDELAY; | ||||
if (fp->f_flag & O_DIRECT) | ioflag |= get_write_ioflag(fp); | ||||
ioflag |= IO_DIRECT; | |||||
mp = atomic_load_ptr(&vp->v_mount); | |||||
if ((fp->f_flag & O_FSYNC) || | |||||
(mp != NULL && (mp->mnt_flag & MNT_SYNCHRONOUS))) | |||||
ioflag |= IO_SYNC; | |||||
/* | |||||
* For O_DSYNC we set both IO_SYNC and IO_DATASYNC, so that VOP_WRITE() | |||||
* implementations that don't understand IO_DATASYNC fall back to full | |||||
* O_SYNC behavior. | |||||
*/ | |||||
if (fp->f_flag & O_DSYNC) | |||||
ioflag |= IO_SYNC | IO_DATASYNC; | |||||
mp = NULL; | mp = NULL; | ||||
need_finished_write = false; | need_finished_write = false; | ||||
if (vp->v_type != VCHR) { | if (vp->v_type != VCHR) { | ||||
error = vn_start_write(vp, &mp, V_WAIT | PCATCH); | error = vn_start_write(vp, &mp, V_WAIT | PCATCH); | ||||
if (error != 0) | if (error != 0) | ||||
goto unlock; | goto unlock; | ||||
need_finished_write = true; | need_finished_write = true; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 2,508 Lines • Show Last 20 Lines |