aboutsummaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2023-07-23 15:55:50 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2023-07-24 22:02:59 +0000
commit5b353925ff61b9ddb97bb453ba75278b578ed7d9 (patch)
treeb27d4fa6f897f5a0f870150590af73a33987424f /sys/kern
parent4a07c778632bddb86a82f3e1fe144d889dae69c5 (diff)
downloadsrc-5b353925ff61b9ddb97bb453ba75278b578ed7d9.tar.gz
src-5b353925ff61b9ddb97bb453ba75278b578ed7d9.zip
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/vfs_vnops.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index 83e95731d7c4..306840ff0357 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -1443,6 +1443,7 @@ vn_io_fault(struct file *fp, struct uio *uio, struct ucred *active_cred,
void *rl_cookie;
struct vn_io_fault_args args;
int error;
+ bool rl_locked;
doio = uio->uio_rw == UIO_READ ? vn_read : vn_write;
vp = fp->f_vnode;
@@ -1465,12 +1466,7 @@ vn_io_fault(struct file *fp, struct uio *uio, struct ucred *active_cred,
}
foffset_lock_uio(fp, uio, flags);
- if (do_vn_io_fault(vp, uio)) {
- args.kind = VN_IO_FAULT_FOP;
- args.args.fop_args.fp = fp;
- args.args.fop_args.doio = doio;
- args.cred = active_cred;
- args.flags = flags | FOF_OFFSET;
+ if (vp->v_type == VREG) {
if (uio->uio_rw == UIO_READ) {
rl_cookie = vn_rangelock_rlock(vp, uio->uio_offset,
uio->uio_offset + uio->uio_resid);
@@ -1482,11 +1478,22 @@ vn_io_fault(struct file *fp, struct uio *uio, struct ucred *active_cred,
rl_cookie = vn_rangelock_wlock(vp, uio->uio_offset,
uio->uio_offset + uio->uio_resid);
}
+ rl_locked = true;
+ } else {
+ rl_locked = false;
+ }
+ if (do_vn_io_fault(vp, uio)) {
+ args.kind = VN_IO_FAULT_FOP;
+ args.args.fop_args.fp = fp;
+ args.args.fop_args.doio = doio;
+ args.cred = active_cred;
+ args.flags = flags | FOF_OFFSET;
error = vn_io_fault1(vp, uio, &args, td);
- vn_rangelock_unlock(vp, rl_cookie);
} else {
error = doio(fp, uio, active_cred, flags | FOF_OFFSET, td);
}
+ if (rl_locked)
+ vn_rangelock_unlock(vp, rl_cookie);
foffset_unlock_uio(fp, uio, flags);
return (error);
}