Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/vfs_syscalls.c
| Show First 20 Lines • Show All 3,511 Lines • ▼ Show 20 Lines | |||||
| #endif | #endif | ||||
| int | int | ||||
| kern_fsync(struct thread *td, int fd, bool fullsync) | kern_fsync(struct thread *td, int fd, bool fullsync) | ||||
| { | { | ||||
| struct vnode *vp; | struct vnode *vp; | ||||
| struct mount *mp; | struct mount *mp; | ||||
| struct file *fp; | struct file *fp; | ||||
| int error, lock_flags; | int error; | ||||
| AUDIT_ARG_FD(fd); | AUDIT_ARG_FD(fd); | ||||
| error = getvnode(td, fd, &cap_fsync_rights, &fp); | error = getvnode(td, fd, &cap_fsync_rights, &fp); | ||||
| if (error != 0) | if (error != 0) | ||||
| return (error); | return (error); | ||||
| vp = fp->f_vnode; | vp = fp->f_vnode; | ||||
| #if 0 | #if 0 | ||||
| if (!fullsync) | if (!fullsync) | ||||
| /* XXXKIB: compete outstanding aio writes */; | /* XXXKIB: compete outstanding aio writes */; | ||||
| #endif | #endif | ||||
| retry: | retry: | ||||
| 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 drop; | goto drop; | ||||
| if (MNT_SHARED_WRITES(mp) || | vn_lock(vp, vn_lktype_write(mp, vp) | LK_RETRY); | ||||
| ((mp == NULL) && MNT_SHARED_WRITES(vp->v_mount))) { | |||||
| lock_flags = LK_SHARED; | |||||
| } else { | |||||
| lock_flags = LK_EXCLUSIVE; | |||||
| } | |||||
| vn_lock(vp, lock_flags | LK_RETRY); | |||||
| AUDIT_ARG_VNODE1(vp); | AUDIT_ARG_VNODE1(vp); | ||||
| if (vp->v_object != NULL) { | if (vp->v_object != NULL) { | ||||
| VM_OBJECT_WLOCK(vp->v_object); | VM_OBJECT_WLOCK(vp->v_object); | ||||
| vm_object_page_clean(vp->v_object, 0, 0, 0); | vm_object_page_clean(vp->v_object, 0, 0, 0); | ||||
| VM_OBJECT_WUNLOCK(vp->v_object); | VM_OBJECT_WUNLOCK(vp->v_object); | ||||
| } | } | ||||
| error = fullsync ? VOP_FSYNC(vp, MNT_WAIT, td) : VOP_FDATASYNC(vp, td); | error = fullsync ? VOP_FSYNC(vp, MNT_WAIT, td) : VOP_FDATASYNC(vp, td); | ||||
| VOP_UNLOCK(vp); | VOP_UNLOCK(vp); | ||||
| ▲ Show 20 Lines • Show All 1,459 Lines • Show Last 20 Lines | |||||