diff options
author | anton <anton@cvs.openbsd.org> | 2019-07-10 16:43:21 +0000 |
---|---|---|
committer | anton <anton@cvs.openbsd.org> | 2019-07-10 16:43:21 +0000 |
commit | d8bf193ec09f26b570daa057ab9961744de1794d (patch) | |
tree | fb42455d3d5d0bb3236d5a9551cade60758d5ad7 /sys/tmpfs/tmpfs_vnops.c | |
parent | cfb2b7e76d2d97505ffb3e2ac6a43561e980f07a (diff) |
Make read/write of the f_offset field belonging to struct file MP-safe;
as part of the effort to unlock the kernel. Instead of relying on the
vnode lock, introduce a dedicated lock per file. Exclusive write access
is granted using the new foffset_enter and foffset_leave API. A
convenience function foffset_get is also available for threads that only
need to read the current offset.
The lock acquisition order in vn_write has been changed to match the one
in vn_read in order to avoid a potential deadlock. This change also gets
rid of a documented race in vn_read().
Inspired by the FreeBSD implementation.
With help and ok mpi@ visa@
Diffstat (limited to 'sys/tmpfs/tmpfs_vnops.c')
-rw-r--r-- | sys/tmpfs/tmpfs_vnops.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/tmpfs/tmpfs_vnops.c b/sys/tmpfs/tmpfs_vnops.c index 8b5c7a76b46..69a814ae26a 100644 --- a/sys/tmpfs/tmpfs_vnops.c +++ b/sys/tmpfs/tmpfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tmpfs_vnops.c,v 1.33 2018/10/22 17:31:25 krw Exp $ */ +/* $OpenBSD: tmpfs_vnops.c,v 1.34 2019/07/10 16:43:20 anton Exp $ */ /* $NetBSD: tmpfs_vnops.c,v 1.100 2012/11/05 17:27:39 dholland Exp $ */ /* @@ -2645,7 +2645,7 @@ filt_tmpfsread(struct knote *kn, long hint) return (1); } - kn->kn_data = node->tn_size - kn->kn_fp->f_offset; + kn->kn_data = node->tn_size - foffset_get(kn->kn_fp); if (kn->kn_data == 0 && kn->kn_sfflags & NOTE_EOF) { kn->kn_fflags |= NOTE_EOF; return (1); |