Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/vfs_vnops.c
Show First 20 Lines • Show All 3,437 Lines • ▼ Show 20 Lines | #endif | ||||
maybe_yield(); | maybe_yield(); | ||||
} | } | ||||
return (error); | return (error); | ||||
} | } | ||||
static int | static int | ||||
vn_deallocate_impl(struct vnode *vp, off_t *offset, off_t *length, int flags, | vn_deallocate_impl(struct vnode *vp, off_t *offset, off_t *length, int flags, | ||||
int ioflg, struct ucred *active_cred, struct ucred *file_cred) | int ioflag, struct ucred *active_cred, struct ucred *file_cred) | ||||
{ | { | ||||
struct mount *mp; | struct mount *mp; | ||||
void *rl_cookie; | void *rl_cookie; | ||||
off_t off, len; | off_t off, len; | ||||
int error; | int error; | ||||
#ifdef AUDIT | #ifdef AUDIT | ||||
bool audited_vnode1 = false; | bool audited_vnode1 = false; | ||||
#endif | #endif | ||||
rl_cookie = NULL; | rl_cookie = NULL; | ||||
error = 0; | error = 0; | ||||
mp = NULL; | mp = NULL; | ||||
off = *offset; | off = *offset; | ||||
len = *length; | len = *length; | ||||
if ((ioflg & (IO_NODELOCKED|IO_RANGELOCKED)) == 0) | if ((ioflag & (IO_NODELOCKED|IO_RANGELOCKED)) == 0) | ||||
kib: And you left the style issue lingering. | |||||
khngAuthorUnsubmitted Done Inline ActionsThis was fixed on D31500 instead. khng: This was fixed on D31500 instead. | |||||
kibUnsubmitted Not Done Inline ActionsThis is purely a style change, while D31500 modifies the runtime behavior. kib: This is purely a style change, while D31500 modifies the runtime behavior. | |||||
rl_cookie = vn_rangelock_wlock(vp, off, off + len); | rl_cookie = vn_rangelock_wlock(vp, off, off + len); | ||||
while (len > 0 && error == 0) { | while (len > 0 && error == 0) { | ||||
/* | /* | ||||
* Try to deallocate the longest range in one pass. | * Try to deallocate the longest range in one pass. | ||||
* In case a pass takes too long to be executed, it returns | * In case a pass takes too long to be executed, it returns | ||||
* partial result. The residue will be proceeded in the next | * partial result. The residue will be proceeded in the next | ||||
* pass. | * pass. | ||||
*/ | */ | ||||
if ((ioflg & IO_NODELOCKED) == 0) { | if ((ioflag & IO_NODELOCKED) == 0) { | ||||
bwillwrite(); | bwillwrite(); | ||||
if ((error = vn_start_write(vp, &mp, | if ((error = vn_start_write(vp, &mp, | ||||
V_WAIT | PCATCH)) != 0) | V_WAIT | PCATCH)) != 0) | ||||
goto out; | goto out; | ||||
vn_lock(vp, vn_lktype_write(mp, vp) | LK_RETRY); | vn_lock(vp, vn_lktype_write(mp, vp) | LK_RETRY); | ||||
} | } | ||||
#ifdef AUDIT | #ifdef AUDIT | ||||
if (!audited_vnode1) { | if (!audited_vnode1) { | ||||
AUDIT_ARG_VNODE1(vp); | AUDIT_ARG_VNODE1(vp); | ||||
audited_vnode1 = true; | audited_vnode1 = true; | ||||
} | } | ||||
#endif | #endif | ||||
#ifdef MAC | #ifdef MAC | ||||
if ((ioflg & IO_NOMACCHECK) == 0) | if ((ioflag & IO_NOMACCHECK) == 0) | ||||
error = mac_vnode_check_write(active_cred, file_cred, | error = mac_vnode_check_write(active_cred, file_cred, | ||||
vp); | vp); | ||||
#endif | #endif | ||||
if (error == 0) | if (error == 0) | ||||
error = VOP_DEALLOCATE(vp, &off, &len, flags, | error = VOP_DEALLOCATE(vp, &off, &len, flags, | ||||
active_cred); | active_cred); | ||||
if ((ioflg & IO_NODELOCKED) == 0) { | if ((ioflag & IO_NODELOCKED) == 0) { | ||||
VOP_UNLOCK(vp); | VOP_UNLOCK(vp); | ||||
if (mp != NULL) { | if (mp != NULL) { | ||||
vn_finished_write(mp); | vn_finished_write(mp); | ||||
mp = NULL; | mp = NULL; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
out: | out: | ||||
if (rl_cookie != NULL) | if (rl_cookie != NULL) | ||||
vn_rangelock_unlock(vp, rl_cookie); | vn_rangelock_unlock(vp, rl_cookie); | ||||
*offset = off; | *offset = off; | ||||
*length = len; | *length = len; | ||||
return (error); | return (error); | ||||
} | } | ||||
int | int | ||||
vn_deallocate(struct vnode *vp, off_t *offset, off_t *length, int flags, | vn_deallocate(struct vnode *vp, off_t *offset, off_t *length, int flags, | ||||
int ioflg, struct ucred *active_cred, struct ucred *file_cred) | int ioflag, struct ucred *active_cred, struct ucred *file_cred) | ||||
{ | { | ||||
if (*offset < 0 || *length <= 0 || *length > OFF_MAX - *offset || | if (*offset < 0 || *length <= 0 || *length > OFF_MAX - *offset || | ||||
flags != 0) | flags != 0) | ||||
return (EINVAL); | return (EINVAL); | ||||
if (vp->v_type != VREG) | if (vp->v_type != VREG) | ||||
return (ENODEV); | return (ENODEV); | ||||
return (vn_deallocate_impl(vp, offset, length, flags, ioflg, | return (vn_deallocate_impl(vp, offset, length, flags, ioflag, | ||||
active_cred, file_cred)); | active_cred, file_cred)); | ||||
} | } | ||||
static int | static int | ||||
vn_fspacectl(struct file *fp, int cmd, off_t *offset, off_t *length, int flags, | vn_fspacectl(struct file *fp, int cmd, off_t *offset, off_t *length, int flags, | ||||
struct ucred *active_cred, struct thread *td) | struct ucred *active_cred, struct thread *td) | ||||
{ | { | ||||
int error; | int error; | ||||
▲ Show 20 Lines • Show All 123 Lines • Show Last 20 Lines |
And you left the style issue lingering.