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/nfs | |
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/nfs')
-rw-r--r-- | sys/nfs/nfs_kq.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/nfs/nfs_kq.c b/sys/nfs/nfs_kq.c index b6b227c52a7..459e40907a7 100644 --- a/sys/nfs/nfs_kq.c +++ b/sys/nfs/nfs_kq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_kq.c,v 1.22 2014/11/15 00:03:12 tedu Exp $ */ +/* $OpenBSD: nfs_kq.c,v 1.23 2019/07/10 16:43:20 anton Exp $ */ /* $NetBSD: nfs_kq.c,v 1.7 2003/10/30 01:43:10 simonb Exp $ */ /*- @@ -226,7 +226,7 @@ filt_nfsread(struct knote *kn, long hint) return (1); } - kn->kn_data = np->n_size - kn->kn_fp->f_offset; + kn->kn_data = np->n_size - foffset_get(kn->kn_fp); #ifdef DEBUG printf("nfsread event. %lld\n", kn->kn_data); #endif |