History log of /openbsd-current/sys/nfs/nfs_kq.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.37 01-May-2024 jsg

remove unneeded includes
ok miod@ mpi@


Revision tags: OPENBSD_7_4_BASE OPENBSD_7_5_BASE
# 1.36 08-Sep-2023 mvs

Remove the remnants of the leftover selinfo from vnode(9) layer. Just
mechanical 'selinfo' to 'klist' replacement in 'vnode' structure because
knote(9) API is already used.

<sys/selinfo.h> headers added where is was required.

ok bluhm


Revision tags: OPENBSD_7_3_BASE
# 1.35 08-Mar-2023 guenther

Delete obsolete /* ARGSUSED */ lint comments.

ok miod@ millert@


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.34 11-Dec-2021 visa

Clarify usage of __EV_POLL and __EV_SELECT

Make __EV_POLL specific to kqueue-based poll(2), to remove overlap
with __EV_SELECT that only select(2) uses.

OK millert@ mpi@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.33 25-Dec-2020 visa

Refactor klist insertion and removal

Rename klist_{insert,remove}() to klist_{insert,remove}_locked().
These functions assume that the caller has locked the klist. The current
state of locking remains intact because the kernel lock is still used
with all klists.

Add new functions klist_insert() and klist_remove() that lock the klist
internally. This allows some code simplification.

OK mpi@


Revision tags: OPENBSD_6_8_BASE
# 1.32 11-Jun-2020 mpi

Rename poll-compatibility flag to better reflect what it is.

While here prefix kernel-only EV flags with two underbars.

Suggested by kettenis@, ok visa@


# 1.31 08-Jun-2020 mpi

Use a new EV_OLDAPI flag to match the behavior of poll(2) and select(2).

Adapt FS kqfilters to always return true when the flag is set and bypass
the polling mechanism of the NFS thread.

While here implement a write filter for NFS.

ok visa@


Revision tags: OPENBSD_6_7_BASE
# 1.30 07-Apr-2020 visa

Abstract the head of knote lists. This allows extending the lists,
for example, with locking assertions.

OK mpi@, anton@


# 1.29 20-Feb-2020 visa

Replace field f_isfd with field f_flags in struct filterops to allow
adding more filter properties without cluttering the struct.

OK mpi@, anton@


# 1.28 21-Jan-2020 cheloha

sys/nfs: misc. tsleep(9) -> tsleep_nsec(9); ok mpi@


# 1.27 31-Dec-2019 visa

Use C99 designated initializers with struct filterops. In addition,
make the structs const so that the data are put in .rodata.

OK mpi@, deraadt@, anton@, bluhm@


# 1.26 05-Dec-2019 mpi

Convert infinite sleeps to tsleep_nsec(9).

ok jca@


Revision tags: OPENBSD_6_6_BASE
# 1.25 05-Aug-2019 anton

Allow concurrent reads of the f_offset field of struct file by
serializing both read/write operations using the existing file mutex.
The vnode lock still grants exclusive write access to the offset; the
mutex is only used to make the actual write atomic and prevent any
concurrent reader from observing intermediate values.

ok mpi@ visa@


# 1.24 12-Jul-2019 solene

Revert anton@ changes about read/write unlocking
https://marc.info/?l=openbsd-cvs&m=156277704122293&w=2

ok anton@


# 1.23 10-Jul-2019 anton

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@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.22 15-Nov-2014 tedu

add sizes for free(ptr, sizeof(*ptr)). use sizeof(*ptr) for malloc sizes.


Revision tags: OPENBSD_5_6_BASE
# 1.21 06-Aug-2014 guenther

Support NOTE_EOF for kqueue EVFILT_READ filters on NFS files.

committing for jsg@, ok reyk@ tedu@ guenther@


# 1.20 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.19 08-Jul-2014 deraadt

decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.h
don't need to be married.
ok guenther miod beck jsing kettenis


# 1.18 15-Jun-2014 sf

Fix a few format string bugs with -DDEBUG


# 1.17 28-Mar-2014 mpi

Reduce uvm include madness. Use <uvm/uvm_extern.h> instead of
<uvm/uvm.h> if possible and remove double inclusions.

ok beck@, mlarkin@, deraadt@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.16 05-Dec-2012 deraadt

Remove excessive sys/cdefs.h inclusion
ok guenther millert kettenis


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.15 19-Jan-2009 thib

Introduce a macro to invalidate the attribute
cache instead of setting n_attrstamp to 0 directly.

Lift the macro name from NetBSD.
prompted by and OK blambert@


# 1.14 11-Sep-2008 thib

issue a NOTE_TRUNCATE if the file size has shrinked

ok tedu@, blambert@, art@


# 1.13 20-Aug-2008 thib

Return EINVAL instead of '1' for invalid kq filters.

From NetBSD;
OK art@, blambert@


Revision tags: OPENBSD_4_4_BASE
# 1.12 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.11 11-Jun-2008 blambert

Canonical for() -> queue.h FOREACH macro conversions.
Also, it is historical practice to #include <sys/queue.h>
when using queue.h macros.

ok thib@ krw@

special thanks to krw@ for reminders vice violence


Revision tags: OPENBSD_4_3_BASE
# 1.10 20-Sep-2007 thib

MALLOC/FREE -> malloc/free + M_ZERO.
Uneeded includes and casts...

ok krw@


Revision tags: OPENBSD_4_2_BASE
# 1.9 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


# 1.8 31-May-2007 thib

kill some ifdef noyet code, de-static functions (makes my traces nicer),
some comments and style.

ok tedu@


# 1.7 29-May-2007 thib

Add a name argument to the RWLOCK_INITIALIZER macro.
Pick reasonble names for the locks involved..

ok tedu@, art@


# 1.6 28-May-2007 thib

zap annoying __KERNEL_RCSID().

ok krw@


# 1.5 17-May-2007 thib

Collapse struct v_selectinfo in struct vnode, remove the
simplelock and reuse the name for the selinfo member.
Clean-up accordingly.

ok tedu@,art@


# 1.4 19-Apr-2007 thib

Replace the nfskevq_lock lockmgr lock with rwlock.
Replace nfs_kqinit() wich just calls lockinit with
RWLOCK_INITALIZER. Assorted cleanup.

ok tedu@
"reads good" art@


# 1.3 12-Apr-2007 thib

If VOP_GETATTR() in the nfs_kqpoll() loop returns ESTALE, catch it.
Not doing so can lead to clients missing out if the file is for
example removed on the server and the client is doing a 'tail -f' on it.
If it returns ESTALE, mark the file deleted and proceed to handling the
next entry.

ok tedu@,art@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.2 19-Nov-2005 pedro

Remove unnecessary lockmgr() archaism that was costing too much in terms
of panics and bugfixes. Access curproc directly, do not expect a process
pointer as an argument. Should fix many "process context required" bugs.
Incentive and okay millert@, okay marc@. Various testing, thanks.


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.1 21-Jul-2004 marius

kqueue support for NFS, adapted from netbsd.

ok art@ pedro@, "get it in" deraadt@


# 1.36 08-Sep-2023 mvs

Remove the remnants of the leftover selinfo from vnode(9) layer. Just
mechanical 'selinfo' to 'klist' replacement in 'vnode' structure because
knote(9) API is already used.

<sys/selinfo.h> headers added where is was required.

ok bluhm


Revision tags: OPENBSD_7_3_BASE
# 1.35 08-Mar-2023 guenther

Delete obsolete /* ARGSUSED */ lint comments.

ok miod@ millert@


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.34 11-Dec-2021 visa

Clarify usage of __EV_POLL and __EV_SELECT

Make __EV_POLL specific to kqueue-based poll(2), to remove overlap
with __EV_SELECT that only select(2) uses.

OK millert@ mpi@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.33 25-Dec-2020 visa

Refactor klist insertion and removal

Rename klist_{insert,remove}() to klist_{insert,remove}_locked().
These functions assume that the caller has locked the klist. The current
state of locking remains intact because the kernel lock is still used
with all klists.

Add new functions klist_insert() and klist_remove() that lock the klist
internally. This allows some code simplification.

OK mpi@


Revision tags: OPENBSD_6_8_BASE
# 1.32 11-Jun-2020 mpi

Rename poll-compatibility flag to better reflect what it is.

While here prefix kernel-only EV flags with two underbars.

Suggested by kettenis@, ok visa@


# 1.31 08-Jun-2020 mpi

Use a new EV_OLDAPI flag to match the behavior of poll(2) and select(2).

Adapt FS kqfilters to always return true when the flag is set and bypass
the polling mechanism of the NFS thread.

While here implement a write filter for NFS.

ok visa@


Revision tags: OPENBSD_6_7_BASE
# 1.30 07-Apr-2020 visa

Abstract the head of knote lists. This allows extending the lists,
for example, with locking assertions.

OK mpi@, anton@


# 1.29 20-Feb-2020 visa

Replace field f_isfd with field f_flags in struct filterops to allow
adding more filter properties without cluttering the struct.

OK mpi@, anton@


# 1.28 21-Jan-2020 cheloha

sys/nfs: misc. tsleep(9) -> tsleep_nsec(9); ok mpi@


# 1.27 31-Dec-2019 visa

Use C99 designated initializers with struct filterops. In addition,
make the structs const so that the data are put in .rodata.

OK mpi@, deraadt@, anton@, bluhm@


# 1.26 05-Dec-2019 mpi

Convert infinite sleeps to tsleep_nsec(9).

ok jca@


Revision tags: OPENBSD_6_6_BASE
# 1.25 05-Aug-2019 anton

Allow concurrent reads of the f_offset field of struct file by
serializing both read/write operations using the existing file mutex.
The vnode lock still grants exclusive write access to the offset; the
mutex is only used to make the actual write atomic and prevent any
concurrent reader from observing intermediate values.

ok mpi@ visa@


# 1.24 12-Jul-2019 solene

Revert anton@ changes about read/write unlocking
https://marc.info/?l=openbsd-cvs&m=156277704122293&w=2

ok anton@


# 1.23 10-Jul-2019 anton

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@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.22 15-Nov-2014 tedu

add sizes for free(ptr, sizeof(*ptr)). use sizeof(*ptr) for malloc sizes.


Revision tags: OPENBSD_5_6_BASE
# 1.21 06-Aug-2014 guenther

Support NOTE_EOF for kqueue EVFILT_READ filters on NFS files.

committing for jsg@, ok reyk@ tedu@ guenther@


# 1.20 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.19 08-Jul-2014 deraadt

decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.h
don't need to be married.
ok guenther miod beck jsing kettenis


# 1.18 15-Jun-2014 sf

Fix a few format string bugs with -DDEBUG


# 1.17 28-Mar-2014 mpi

Reduce uvm include madness. Use <uvm/uvm_extern.h> instead of
<uvm/uvm.h> if possible and remove double inclusions.

ok beck@, mlarkin@, deraadt@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.16 05-Dec-2012 deraadt

Remove excessive sys/cdefs.h inclusion
ok guenther millert kettenis


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.15 19-Jan-2009 thib

Introduce a macro to invalidate the attribute
cache instead of setting n_attrstamp to 0 directly.

Lift the macro name from NetBSD.
prompted by and OK blambert@


# 1.14 11-Sep-2008 thib

issue a NOTE_TRUNCATE if the file size has shrinked

ok tedu@, blambert@, art@


# 1.13 20-Aug-2008 thib

Return EINVAL instead of '1' for invalid kq filters.

From NetBSD;
OK art@, blambert@


Revision tags: OPENBSD_4_4_BASE
# 1.12 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.11 11-Jun-2008 blambert

Canonical for() -> queue.h FOREACH macro conversions.
Also, it is historical practice to #include <sys/queue.h>
when using queue.h macros.

ok thib@ krw@

special thanks to krw@ for reminders vice violence


Revision tags: OPENBSD_4_3_BASE
# 1.10 20-Sep-2007 thib

MALLOC/FREE -> malloc/free + M_ZERO.
Uneeded includes and casts...

ok krw@


Revision tags: OPENBSD_4_2_BASE
# 1.9 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


# 1.8 31-May-2007 thib

kill some ifdef noyet code, de-static functions (makes my traces nicer),
some comments and style.

ok tedu@


# 1.7 29-May-2007 thib

Add a name argument to the RWLOCK_INITIALIZER macro.
Pick reasonble names for the locks involved..

ok tedu@, art@


# 1.6 28-May-2007 thib

zap annoying __KERNEL_RCSID().

ok krw@


# 1.5 17-May-2007 thib

Collapse struct v_selectinfo in struct vnode, remove the
simplelock and reuse the name for the selinfo member.
Clean-up accordingly.

ok tedu@,art@


# 1.4 19-Apr-2007 thib

Replace the nfskevq_lock lockmgr lock with rwlock.
Replace nfs_kqinit() wich just calls lockinit with
RWLOCK_INITALIZER. Assorted cleanup.

ok tedu@
"reads good" art@


# 1.3 12-Apr-2007 thib

If VOP_GETATTR() in the nfs_kqpoll() loop returns ESTALE, catch it.
Not doing so can lead to clients missing out if the file is for
example removed on the server and the client is doing a 'tail -f' on it.
If it returns ESTALE, mark the file deleted and proceed to handling the
next entry.

ok tedu@,art@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.2 19-Nov-2005 pedro

Remove unnecessary lockmgr() archaism that was costing too much in terms
of panics and bugfixes. Access curproc directly, do not expect a process
pointer as an argument. Should fix many "process context required" bugs.
Incentive and okay millert@, okay marc@. Various testing, thanks.


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.1 21-Jul-2004 marius

kqueue support for NFS, adapted from netbsd.

ok art@ pedro@, "get it in" deraadt@


# 1.35 08-Mar-2023 guenther

Delete obsolete /* ARGSUSED */ lint comments.

ok miod@ millert@


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.34 11-Dec-2021 visa

Clarify usage of __EV_POLL and __EV_SELECT

Make __EV_POLL specific to kqueue-based poll(2), to remove overlap
with __EV_SELECT that only select(2) uses.

OK millert@ mpi@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.33 25-Dec-2020 visa

Refactor klist insertion and removal

Rename klist_{insert,remove}() to klist_{insert,remove}_locked().
These functions assume that the caller has locked the klist. The current
state of locking remains intact because the kernel lock is still used
with all klists.

Add new functions klist_insert() and klist_remove() that lock the klist
internally. This allows some code simplification.

OK mpi@


Revision tags: OPENBSD_6_8_BASE
# 1.32 11-Jun-2020 mpi

Rename poll-compatibility flag to better reflect what it is.

While here prefix kernel-only EV flags with two underbars.

Suggested by kettenis@, ok visa@


# 1.31 08-Jun-2020 mpi

Use a new EV_OLDAPI flag to match the behavior of poll(2) and select(2).

Adapt FS kqfilters to always return true when the flag is set and bypass
the polling mechanism of the NFS thread.

While here implement a write filter for NFS.

ok visa@


Revision tags: OPENBSD_6_7_BASE
# 1.30 07-Apr-2020 visa

Abstract the head of knote lists. This allows extending the lists,
for example, with locking assertions.

OK mpi@, anton@


# 1.29 20-Feb-2020 visa

Replace field f_isfd with field f_flags in struct filterops to allow
adding more filter properties without cluttering the struct.

OK mpi@, anton@


# 1.28 21-Jan-2020 cheloha

sys/nfs: misc. tsleep(9) -> tsleep_nsec(9); ok mpi@


# 1.27 31-Dec-2019 visa

Use C99 designated initializers with struct filterops. In addition,
make the structs const so that the data are put in .rodata.

OK mpi@, deraadt@, anton@, bluhm@


# 1.26 05-Dec-2019 mpi

Convert infinite sleeps to tsleep_nsec(9).

ok jca@


Revision tags: OPENBSD_6_6_BASE
# 1.25 05-Aug-2019 anton

Allow concurrent reads of the f_offset field of struct file by
serializing both read/write operations using the existing file mutex.
The vnode lock still grants exclusive write access to the offset; the
mutex is only used to make the actual write atomic and prevent any
concurrent reader from observing intermediate values.

ok mpi@ visa@


# 1.24 12-Jul-2019 solene

Revert anton@ changes about read/write unlocking
https://marc.info/?l=openbsd-cvs&m=156277704122293&w=2

ok anton@


# 1.23 10-Jul-2019 anton

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@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.22 15-Nov-2014 tedu

add sizes for free(ptr, sizeof(*ptr)). use sizeof(*ptr) for malloc sizes.


Revision tags: OPENBSD_5_6_BASE
# 1.21 06-Aug-2014 guenther

Support NOTE_EOF for kqueue EVFILT_READ filters on NFS files.

committing for jsg@, ok reyk@ tedu@ guenther@


# 1.20 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.19 08-Jul-2014 deraadt

decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.h
don't need to be married.
ok guenther miod beck jsing kettenis


# 1.18 15-Jun-2014 sf

Fix a few format string bugs with -DDEBUG


# 1.17 28-Mar-2014 mpi

Reduce uvm include madness. Use <uvm/uvm_extern.h> instead of
<uvm/uvm.h> if possible and remove double inclusions.

ok beck@, mlarkin@, deraadt@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.16 05-Dec-2012 deraadt

Remove excessive sys/cdefs.h inclusion
ok guenther millert kettenis


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.15 19-Jan-2009 thib

Introduce a macro to invalidate the attribute
cache instead of setting n_attrstamp to 0 directly.

Lift the macro name from NetBSD.
prompted by and OK blambert@


# 1.14 11-Sep-2008 thib

issue a NOTE_TRUNCATE if the file size has shrinked

ok tedu@, blambert@, art@


# 1.13 20-Aug-2008 thib

Return EINVAL instead of '1' for invalid kq filters.

From NetBSD;
OK art@, blambert@


Revision tags: OPENBSD_4_4_BASE
# 1.12 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.11 11-Jun-2008 blambert

Canonical for() -> queue.h FOREACH macro conversions.
Also, it is historical practice to #include <sys/queue.h>
when using queue.h macros.

ok thib@ krw@

special thanks to krw@ for reminders vice violence


Revision tags: OPENBSD_4_3_BASE
# 1.10 20-Sep-2007 thib

MALLOC/FREE -> malloc/free + M_ZERO.
Uneeded includes and casts...

ok krw@


Revision tags: OPENBSD_4_2_BASE
# 1.9 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


# 1.8 31-May-2007 thib

kill some ifdef noyet code, de-static functions (makes my traces nicer),
some comments and style.

ok tedu@


# 1.7 29-May-2007 thib

Add a name argument to the RWLOCK_INITIALIZER macro.
Pick reasonble names for the locks involved..

ok tedu@, art@


# 1.6 28-May-2007 thib

zap annoying __KERNEL_RCSID().

ok krw@


# 1.5 17-May-2007 thib

Collapse struct v_selectinfo in struct vnode, remove the
simplelock and reuse the name for the selinfo member.
Clean-up accordingly.

ok tedu@,art@


# 1.4 19-Apr-2007 thib

Replace the nfskevq_lock lockmgr lock with rwlock.
Replace nfs_kqinit() wich just calls lockinit with
RWLOCK_INITALIZER. Assorted cleanup.

ok tedu@
"reads good" art@


# 1.3 12-Apr-2007 thib

If VOP_GETATTR() in the nfs_kqpoll() loop returns ESTALE, catch it.
Not doing so can lead to clients missing out if the file is for
example removed on the server and the client is doing a 'tail -f' on it.
If it returns ESTALE, mark the file deleted and proceed to handling the
next entry.

ok tedu@,art@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.2 19-Nov-2005 pedro

Remove unnecessary lockmgr() archaism that was costing too much in terms
of panics and bugfixes. Access curproc directly, do not expect a process
pointer as an argument. Should fix many "process context required" bugs.
Incentive and okay millert@, okay marc@. Various testing, thanks.


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.1 21-Jul-2004 marius

kqueue support for NFS, adapted from netbsd.

ok art@ pedro@, "get it in" deraadt@


# 1.34 11-Dec-2021 visa

Clarify usage of __EV_POLL and __EV_SELECT

Make __EV_POLL specific to kqueue-based poll(2), to remove overlap
with __EV_SELECT that only select(2) uses.

OK millert@ mpi@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.33 25-Dec-2020 visa

Refactor klist insertion and removal

Rename klist_{insert,remove}() to klist_{insert,remove}_locked().
These functions assume that the caller has locked the klist. The current
state of locking remains intact because the kernel lock is still used
with all klists.

Add new functions klist_insert() and klist_remove() that lock the klist
internally. This allows some code simplification.

OK mpi@


Revision tags: OPENBSD_6_8_BASE
# 1.32 11-Jun-2020 mpi

Rename poll-compatibility flag to better reflect what it is.

While here prefix kernel-only EV flags with two underbars.

Suggested by kettenis@, ok visa@


# 1.31 08-Jun-2020 mpi

Use a new EV_OLDAPI flag to match the behavior of poll(2) and select(2).

Adapt FS kqfilters to always return true when the flag is set and bypass
the polling mechanism of the NFS thread.

While here implement a write filter for NFS.

ok visa@


Revision tags: OPENBSD_6_7_BASE
# 1.30 07-Apr-2020 visa

Abstract the head of knote lists. This allows extending the lists,
for example, with locking assertions.

OK mpi@, anton@


# 1.29 20-Feb-2020 visa

Replace field f_isfd with field f_flags in struct filterops to allow
adding more filter properties without cluttering the struct.

OK mpi@, anton@


# 1.28 21-Jan-2020 cheloha

sys/nfs: misc. tsleep(9) -> tsleep_nsec(9); ok mpi@


# 1.27 31-Dec-2019 visa

Use C99 designated initializers with struct filterops. In addition,
make the structs const so that the data are put in .rodata.

OK mpi@, deraadt@, anton@, bluhm@


# 1.26 05-Dec-2019 mpi

Convert infinite sleeps to tsleep_nsec(9).

ok jca@


Revision tags: OPENBSD_6_6_BASE
# 1.25 05-Aug-2019 anton

Allow concurrent reads of the f_offset field of struct file by
serializing both read/write operations using the existing file mutex.
The vnode lock still grants exclusive write access to the offset; the
mutex is only used to make the actual write atomic and prevent any
concurrent reader from observing intermediate values.

ok mpi@ visa@


# 1.24 12-Jul-2019 solene

Revert anton@ changes about read/write unlocking
https://marc.info/?l=openbsd-cvs&m=156277704122293&w=2

ok anton@


# 1.23 10-Jul-2019 anton

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@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.22 15-Nov-2014 tedu

add sizes for free(ptr, sizeof(*ptr)). use sizeof(*ptr) for malloc sizes.


Revision tags: OPENBSD_5_6_BASE
# 1.21 06-Aug-2014 guenther

Support NOTE_EOF for kqueue EVFILT_READ filters on NFS files.

committing for jsg@, ok reyk@ tedu@ guenther@


# 1.20 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.19 08-Jul-2014 deraadt

decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.h
don't need to be married.
ok guenther miod beck jsing kettenis


# 1.18 15-Jun-2014 sf

Fix a few format string bugs with -DDEBUG


# 1.17 28-Mar-2014 mpi

Reduce uvm include madness. Use <uvm/uvm_extern.h> instead of
<uvm/uvm.h> if possible and remove double inclusions.

ok beck@, mlarkin@, deraadt@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.16 05-Dec-2012 deraadt

Remove excessive sys/cdefs.h inclusion
ok guenther millert kettenis


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.15 19-Jan-2009 thib

Introduce a macro to invalidate the attribute
cache instead of setting n_attrstamp to 0 directly.

Lift the macro name from NetBSD.
prompted by and OK blambert@


# 1.14 11-Sep-2008 thib

issue a NOTE_TRUNCATE if the file size has shrinked

ok tedu@, blambert@, art@


# 1.13 20-Aug-2008 thib

Return EINVAL instead of '1' for invalid kq filters.

From NetBSD;
OK art@, blambert@


Revision tags: OPENBSD_4_4_BASE
# 1.12 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.11 11-Jun-2008 blambert

Canonical for() -> queue.h FOREACH macro conversions.
Also, it is historical practice to #include <sys/queue.h>
when using queue.h macros.

ok thib@ krw@

special thanks to krw@ for reminders vice violence


Revision tags: OPENBSD_4_3_BASE
# 1.10 20-Sep-2007 thib

MALLOC/FREE -> malloc/free + M_ZERO.
Uneeded includes and casts...

ok krw@


Revision tags: OPENBSD_4_2_BASE
# 1.9 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


# 1.8 31-May-2007 thib

kill some ifdef noyet code, de-static functions (makes my traces nicer),
some comments and style.

ok tedu@


# 1.7 29-May-2007 thib

Add a name argument to the RWLOCK_INITIALIZER macro.
Pick reasonble names for the locks involved..

ok tedu@, art@


# 1.6 28-May-2007 thib

zap annoying __KERNEL_RCSID().

ok krw@


# 1.5 17-May-2007 thib

Collapse struct v_selectinfo in struct vnode, remove the
simplelock and reuse the name for the selinfo member.
Clean-up accordingly.

ok tedu@,art@


# 1.4 19-Apr-2007 thib

Replace the nfskevq_lock lockmgr lock with rwlock.
Replace nfs_kqinit() wich just calls lockinit with
RWLOCK_INITALIZER. Assorted cleanup.

ok tedu@
"reads good" art@


# 1.3 12-Apr-2007 thib

If VOP_GETATTR() in the nfs_kqpoll() loop returns ESTALE, catch it.
Not doing so can lead to clients missing out if the file is for
example removed on the server and the client is doing a 'tail -f' on it.
If it returns ESTALE, mark the file deleted and proceed to handling the
next entry.

ok tedu@,art@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.2 19-Nov-2005 pedro

Remove unnecessary lockmgr() archaism that was costing too much in terms
of panics and bugfixes. Access curproc directly, do not expect a process
pointer as an argument. Should fix many "process context required" bugs.
Incentive and okay millert@, okay marc@. Various testing, thanks.


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.1 21-Jul-2004 marius

kqueue support for NFS, adapted from netbsd.

ok art@ pedro@, "get it in" deraadt@


# 1.33 25-Dec-2020 visa

Refactor klist insertion and removal

Rename klist_{insert,remove}() to klist_{insert,remove}_locked().
These functions assume that the caller has locked the klist. The current
state of locking remains intact because the kernel lock is still used
with all klists.

Add new functions klist_insert() and klist_remove() that lock the klist
internally. This allows some code simplification.

OK mpi@


Revision tags: OPENBSD_6_8_BASE
# 1.32 11-Jun-2020 mpi

Rename poll-compatibility flag to better reflect what it is.

While here prefix kernel-only EV flags with two underbars.

Suggested by kettenis@, ok visa@


# 1.31 08-Jun-2020 mpi

Use a new EV_OLDAPI flag to match the behavior of poll(2) and select(2).

Adapt FS kqfilters to always return true when the flag is set and bypass
the polling mechanism of the NFS thread.

While here implement a write filter for NFS.

ok visa@


Revision tags: OPENBSD_6_7_BASE
# 1.30 07-Apr-2020 visa

Abstract the head of knote lists. This allows extending the lists,
for example, with locking assertions.

OK mpi@, anton@


# 1.29 20-Feb-2020 visa

Replace field f_isfd with field f_flags in struct filterops to allow
adding more filter properties without cluttering the struct.

OK mpi@, anton@


# 1.28 21-Jan-2020 cheloha

sys/nfs: misc. tsleep(9) -> tsleep_nsec(9); ok mpi@


# 1.27 31-Dec-2019 visa

Use C99 designated initializers with struct filterops. In addition,
make the structs const so that the data are put in .rodata.

OK mpi@, deraadt@, anton@, bluhm@


# 1.26 05-Dec-2019 mpi

Convert infinite sleeps to tsleep_nsec(9).

ok jca@


Revision tags: OPENBSD_6_6_BASE
# 1.25 05-Aug-2019 anton

Allow concurrent reads of the f_offset field of struct file by
serializing both read/write operations using the existing file mutex.
The vnode lock still grants exclusive write access to the offset; the
mutex is only used to make the actual write atomic and prevent any
concurrent reader from observing intermediate values.

ok mpi@ visa@


# 1.24 12-Jul-2019 solene

Revert anton@ changes about read/write unlocking
https://marc.info/?l=openbsd-cvs&m=156277704122293&w=2

ok anton@


# 1.23 10-Jul-2019 anton

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@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.22 15-Nov-2014 tedu

add sizes for free(ptr, sizeof(*ptr)). use sizeof(*ptr) for malloc sizes.


Revision tags: OPENBSD_5_6_BASE
# 1.21 06-Aug-2014 guenther

Support NOTE_EOF for kqueue EVFILT_READ filters on NFS files.

committing for jsg@, ok reyk@ tedu@ guenther@


# 1.20 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.19 08-Jul-2014 deraadt

decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.h
don't need to be married.
ok guenther miod beck jsing kettenis


# 1.18 15-Jun-2014 sf

Fix a few format string bugs with -DDEBUG


# 1.17 28-Mar-2014 mpi

Reduce uvm include madness. Use <uvm/uvm_extern.h> instead of
<uvm/uvm.h> if possible and remove double inclusions.

ok beck@, mlarkin@, deraadt@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.16 05-Dec-2012 deraadt

Remove excessive sys/cdefs.h inclusion
ok guenther millert kettenis


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.15 19-Jan-2009 thib

Introduce a macro to invalidate the attribute
cache instead of setting n_attrstamp to 0 directly.

Lift the macro name from NetBSD.
prompted by and OK blambert@


# 1.14 11-Sep-2008 thib

issue a NOTE_TRUNCATE if the file size has shrinked

ok tedu@, blambert@, art@


# 1.13 20-Aug-2008 thib

Return EINVAL instead of '1' for invalid kq filters.

From NetBSD;
OK art@, blambert@


Revision tags: OPENBSD_4_4_BASE
# 1.12 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.11 11-Jun-2008 blambert

Canonical for() -> queue.h FOREACH macro conversions.
Also, it is historical practice to #include <sys/queue.h>
when using queue.h macros.

ok thib@ krw@

special thanks to krw@ for reminders vice violence


Revision tags: OPENBSD_4_3_BASE
# 1.10 20-Sep-2007 thib

MALLOC/FREE -> malloc/free + M_ZERO.
Uneeded includes and casts...

ok krw@


Revision tags: OPENBSD_4_2_BASE
# 1.9 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


# 1.8 31-May-2007 thib

kill some ifdef noyet code, de-static functions (makes my traces nicer),
some comments and style.

ok tedu@


# 1.7 29-May-2007 thib

Add a name argument to the RWLOCK_INITIALIZER macro.
Pick reasonble names for the locks involved..

ok tedu@, art@


# 1.6 28-May-2007 thib

zap annoying __KERNEL_RCSID().

ok krw@


# 1.5 17-May-2007 thib

Collapse struct v_selectinfo in struct vnode, remove the
simplelock and reuse the name for the selinfo member.
Clean-up accordingly.

ok tedu@,art@


# 1.4 19-Apr-2007 thib

Replace the nfskevq_lock lockmgr lock with rwlock.
Replace nfs_kqinit() wich just calls lockinit with
RWLOCK_INITALIZER. Assorted cleanup.

ok tedu@
"reads good" art@


# 1.3 12-Apr-2007 thib

If VOP_GETATTR() in the nfs_kqpoll() loop returns ESTALE, catch it.
Not doing so can lead to clients missing out if the file is for
example removed on the server and the client is doing a 'tail -f' on it.
If it returns ESTALE, mark the file deleted and proceed to handling the
next entry.

ok tedu@,art@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.2 19-Nov-2005 pedro

Remove unnecessary lockmgr() archaism that was costing too much in terms
of panics and bugfixes. Access curproc directly, do not expect a process
pointer as an argument. Should fix many "process context required" bugs.
Incentive and okay millert@, okay marc@. Various testing, thanks.


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.1 21-Jul-2004 marius

kqueue support for NFS, adapted from netbsd.

ok art@ pedro@, "get it in" deraadt@


# 1.32 11-Jun-2020 mpi

Rename poll-compatibility flag to better reflect what it is.

While here prefix kernel-only EV flags with two underbars.

Suggested by kettenis@, ok visa@


# 1.31 08-Jun-2020 mpi

Use a new EV_OLDAPI flag to match the behavior of poll(2) and select(2).

Adapt FS kqfilters to always return true when the flag is set and bypass
the polling mechanism of the NFS thread.

While here implement a write filter for NFS.

ok visa@


Revision tags: OPENBSD_6_7_BASE
# 1.30 07-Apr-2020 visa

Abstract the head of knote lists. This allows extending the lists,
for example, with locking assertions.

OK mpi@, anton@


# 1.29 20-Feb-2020 visa

Replace field f_isfd with field f_flags in struct filterops to allow
adding more filter properties without cluttering the struct.

OK mpi@, anton@


# 1.28 21-Jan-2020 cheloha

sys/nfs: misc. tsleep(9) -> tsleep_nsec(9); ok mpi@


# 1.27 31-Dec-2019 visa

Use C99 designated initializers with struct filterops. In addition,
make the structs const so that the data are put in .rodata.

OK mpi@, deraadt@, anton@, bluhm@


# 1.26 05-Dec-2019 mpi

Convert infinite sleeps to tsleep_nsec(9).

ok jca@


Revision tags: OPENBSD_6_6_BASE
# 1.25 05-Aug-2019 anton

Allow concurrent reads of the f_offset field of struct file by
serializing both read/write operations using the existing file mutex.
The vnode lock still grants exclusive write access to the offset; the
mutex is only used to make the actual write atomic and prevent any
concurrent reader from observing intermediate values.

ok mpi@ visa@


# 1.24 12-Jul-2019 solene

Revert anton@ changes about read/write unlocking
https://marc.info/?l=openbsd-cvs&m=156277704122293&w=2

ok anton@


# 1.23 10-Jul-2019 anton

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@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.22 15-Nov-2014 tedu

add sizes for free(ptr, sizeof(*ptr)). use sizeof(*ptr) for malloc sizes.


Revision tags: OPENBSD_5_6_BASE
# 1.21 06-Aug-2014 guenther

Support NOTE_EOF for kqueue EVFILT_READ filters on NFS files.

committing for jsg@, ok reyk@ tedu@ guenther@


# 1.20 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.19 08-Jul-2014 deraadt

decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.h
don't need to be married.
ok guenther miod beck jsing kettenis


# 1.18 15-Jun-2014 sf

Fix a few format string bugs with -DDEBUG


# 1.17 28-Mar-2014 mpi

Reduce uvm include madness. Use <uvm/uvm_extern.h> instead of
<uvm/uvm.h> if possible and remove double inclusions.

ok beck@, mlarkin@, deraadt@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.16 05-Dec-2012 deraadt

Remove excessive sys/cdefs.h inclusion
ok guenther millert kettenis


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.15 19-Jan-2009 thib

Introduce a macro to invalidate the attribute
cache instead of setting n_attrstamp to 0 directly.

Lift the macro name from NetBSD.
prompted by and OK blambert@


# 1.14 11-Sep-2008 thib

issue a NOTE_TRUNCATE if the file size has shrinked

ok tedu@, blambert@, art@


# 1.13 20-Aug-2008 thib

Return EINVAL instead of '1' for invalid kq filters.

From NetBSD;
OK art@, blambert@


Revision tags: OPENBSD_4_4_BASE
# 1.12 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.11 11-Jun-2008 blambert

Canonical for() -> queue.h FOREACH macro conversions.
Also, it is historical practice to #include <sys/queue.h>
when using queue.h macros.

ok thib@ krw@

special thanks to krw@ for reminders vice violence


Revision tags: OPENBSD_4_3_BASE
# 1.10 20-Sep-2007 thib

MALLOC/FREE -> malloc/free + M_ZERO.
Uneeded includes and casts...

ok krw@


Revision tags: OPENBSD_4_2_BASE
# 1.9 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


# 1.8 31-May-2007 thib

kill some ifdef noyet code, de-static functions (makes my traces nicer),
some comments and style.

ok tedu@


# 1.7 29-May-2007 thib

Add a name argument to the RWLOCK_INITIALIZER macro.
Pick reasonble names for the locks involved..

ok tedu@, art@


# 1.6 28-May-2007 thib

zap annoying __KERNEL_RCSID().

ok krw@


# 1.5 17-May-2007 thib

Collapse struct v_selectinfo in struct vnode, remove the
simplelock and reuse the name for the selinfo member.
Clean-up accordingly.

ok tedu@,art@


# 1.4 19-Apr-2007 thib

Replace the nfskevq_lock lockmgr lock with rwlock.
Replace nfs_kqinit() wich just calls lockinit with
RWLOCK_INITALIZER. Assorted cleanup.

ok tedu@
"reads good" art@


# 1.3 12-Apr-2007 thib

If VOP_GETATTR() in the nfs_kqpoll() loop returns ESTALE, catch it.
Not doing so can lead to clients missing out if the file is for
example removed on the server and the client is doing a 'tail -f' on it.
If it returns ESTALE, mark the file deleted and proceed to handling the
next entry.

ok tedu@,art@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.2 19-Nov-2005 pedro

Remove unnecessary lockmgr() archaism that was costing too much in terms
of panics and bugfixes. Access curproc directly, do not expect a process
pointer as an argument. Should fix many "process context required" bugs.
Incentive and okay millert@, okay marc@. Various testing, thanks.


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.1 21-Jul-2004 marius

kqueue support for NFS, adapted from netbsd.

ok art@ pedro@, "get it in" deraadt@


# 1.31 08-Jun-2020 mpi

Use a new EV_OLDAPI flag to match the behavior of poll(2) and select(2).

Adapt FS kqfilters to always return true when the flag is set and bypass
the polling mechanism of the NFS thread.

While here implement a write filter for NFS.

ok visa@


Revision tags: OPENBSD_6_7_BASE
# 1.30 07-Apr-2020 visa

Abstract the head of knote lists. This allows extending the lists,
for example, with locking assertions.

OK mpi@, anton@


# 1.29 20-Feb-2020 visa

Replace field f_isfd with field f_flags in struct filterops to allow
adding more filter properties without cluttering the struct.

OK mpi@, anton@


# 1.28 21-Jan-2020 cheloha

sys/nfs: misc. tsleep(9) -> tsleep_nsec(9); ok mpi@


# 1.27 31-Dec-2019 visa

Use C99 designated initializers with struct filterops. In addition,
make the structs const so that the data are put in .rodata.

OK mpi@, deraadt@, anton@, bluhm@


# 1.26 05-Dec-2019 mpi

Convert infinite sleeps to tsleep_nsec(9).

ok jca@


Revision tags: OPENBSD_6_6_BASE
# 1.25 05-Aug-2019 anton

Allow concurrent reads of the f_offset field of struct file by
serializing both read/write operations using the existing file mutex.
The vnode lock still grants exclusive write access to the offset; the
mutex is only used to make the actual write atomic and prevent any
concurrent reader from observing intermediate values.

ok mpi@ visa@


# 1.24 12-Jul-2019 solene

Revert anton@ changes about read/write unlocking
https://marc.info/?l=openbsd-cvs&m=156277704122293&w=2

ok anton@


# 1.23 10-Jul-2019 anton

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@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.22 15-Nov-2014 tedu

add sizes for free(ptr, sizeof(*ptr)). use sizeof(*ptr) for malloc sizes.


Revision tags: OPENBSD_5_6_BASE
# 1.21 06-Aug-2014 guenther

Support NOTE_EOF for kqueue EVFILT_READ filters on NFS files.

committing for jsg@, ok reyk@ tedu@ guenther@


# 1.20 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.19 08-Jul-2014 deraadt

decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.h
don't need to be married.
ok guenther miod beck jsing kettenis


# 1.18 15-Jun-2014 sf

Fix a few format string bugs with -DDEBUG


# 1.17 28-Mar-2014 mpi

Reduce uvm include madness. Use <uvm/uvm_extern.h> instead of
<uvm/uvm.h> if possible and remove double inclusions.

ok beck@, mlarkin@, deraadt@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.16 05-Dec-2012 deraadt

Remove excessive sys/cdefs.h inclusion
ok guenther millert kettenis


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.15 19-Jan-2009 thib

Introduce a macro to invalidate the attribute
cache instead of setting n_attrstamp to 0 directly.

Lift the macro name from NetBSD.
prompted by and OK blambert@


# 1.14 11-Sep-2008 thib

issue a NOTE_TRUNCATE if the file size has shrinked

ok tedu@, blambert@, art@


# 1.13 20-Aug-2008 thib

Return EINVAL instead of '1' for invalid kq filters.

From NetBSD;
OK art@, blambert@


Revision tags: OPENBSD_4_4_BASE
# 1.12 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.11 11-Jun-2008 blambert

Canonical for() -> queue.h FOREACH macro conversions.
Also, it is historical practice to #include <sys/queue.h>
when using queue.h macros.

ok thib@ krw@

special thanks to krw@ for reminders vice violence


Revision tags: OPENBSD_4_3_BASE
# 1.10 20-Sep-2007 thib

MALLOC/FREE -> malloc/free + M_ZERO.
Uneeded includes and casts...

ok krw@


Revision tags: OPENBSD_4_2_BASE
# 1.9 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


# 1.8 31-May-2007 thib

kill some ifdef noyet code, de-static functions (makes my traces nicer),
some comments and style.

ok tedu@


# 1.7 29-May-2007 thib

Add a name argument to the RWLOCK_INITIALIZER macro.
Pick reasonble names for the locks involved..

ok tedu@, art@


# 1.6 28-May-2007 thib

zap annoying __KERNEL_RCSID().

ok krw@


# 1.5 17-May-2007 thib

Collapse struct v_selectinfo in struct vnode, remove the
simplelock and reuse the name for the selinfo member.
Clean-up accordingly.

ok tedu@,art@


# 1.4 19-Apr-2007 thib

Replace the nfskevq_lock lockmgr lock with rwlock.
Replace nfs_kqinit() wich just calls lockinit with
RWLOCK_INITALIZER. Assorted cleanup.

ok tedu@
"reads good" art@


# 1.3 12-Apr-2007 thib

If VOP_GETATTR() in the nfs_kqpoll() loop returns ESTALE, catch it.
Not doing so can lead to clients missing out if the file is for
example removed on the server and the client is doing a 'tail -f' on it.
If it returns ESTALE, mark the file deleted and proceed to handling the
next entry.

ok tedu@,art@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.2 19-Nov-2005 pedro

Remove unnecessary lockmgr() archaism that was costing too much in terms
of panics and bugfixes. Access curproc directly, do not expect a process
pointer as an argument. Should fix many "process context required" bugs.
Incentive and okay millert@, okay marc@. Various testing, thanks.


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.1 21-Jul-2004 marius

kqueue support for NFS, adapted from netbsd.

ok art@ pedro@, "get it in" deraadt@


# 1.30 07-Apr-2020 visa

Abstract the head of knote lists. This allows extending the lists,
for example, with locking assertions.

OK mpi@, anton@


# 1.29 20-Feb-2020 visa

Replace field f_isfd with field f_flags in struct filterops to allow
adding more filter properties without cluttering the struct.

OK mpi@, anton@


# 1.28 21-Jan-2020 cheloha

sys/nfs: misc. tsleep(9) -> tsleep_nsec(9); ok mpi@


# 1.27 31-Dec-2019 visa

Use C99 designated initializers with struct filterops. In addition,
make the structs const so that the data are put in .rodata.

OK mpi@, deraadt@, anton@, bluhm@


# 1.26 05-Dec-2019 mpi

Convert infinite sleeps to tsleep_nsec(9).

ok jca@


Revision tags: OPENBSD_6_6_BASE
# 1.25 05-Aug-2019 anton

Allow concurrent reads of the f_offset field of struct file by
serializing both read/write operations using the existing file mutex.
The vnode lock still grants exclusive write access to the offset; the
mutex is only used to make the actual write atomic and prevent any
concurrent reader from observing intermediate values.

ok mpi@ visa@


# 1.24 12-Jul-2019 solene

Revert anton@ changes about read/write unlocking
https://marc.info/?l=openbsd-cvs&m=156277704122293&w=2

ok anton@


# 1.23 10-Jul-2019 anton

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@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.22 15-Nov-2014 tedu

add sizes for free(ptr, sizeof(*ptr)). use sizeof(*ptr) for malloc sizes.


Revision tags: OPENBSD_5_6_BASE
# 1.21 06-Aug-2014 guenther

Support NOTE_EOF for kqueue EVFILT_READ filters on NFS files.

committing for jsg@, ok reyk@ tedu@ guenther@


# 1.20 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.19 08-Jul-2014 deraadt

decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.h
don't need to be married.
ok guenther miod beck jsing kettenis


# 1.18 15-Jun-2014 sf

Fix a few format string bugs with -DDEBUG


# 1.17 28-Mar-2014 mpi

Reduce uvm include madness. Use <uvm/uvm_extern.h> instead of
<uvm/uvm.h> if possible and remove double inclusions.

ok beck@, mlarkin@, deraadt@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.16 05-Dec-2012 deraadt

Remove excessive sys/cdefs.h inclusion
ok guenther millert kettenis


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.15 19-Jan-2009 thib

Introduce a macro to invalidate the attribute
cache instead of setting n_attrstamp to 0 directly.

Lift the macro name from NetBSD.
prompted by and OK blambert@


# 1.14 11-Sep-2008 thib

issue a NOTE_TRUNCATE if the file size has shrinked

ok tedu@, blambert@, art@


# 1.13 20-Aug-2008 thib

Return EINVAL instead of '1' for invalid kq filters.

From NetBSD;
OK art@, blambert@


Revision tags: OPENBSD_4_4_BASE
# 1.12 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.11 11-Jun-2008 blambert

Canonical for() -> queue.h FOREACH macro conversions.
Also, it is historical practice to #include <sys/queue.h>
when using queue.h macros.

ok thib@ krw@

special thanks to krw@ for reminders vice violence


Revision tags: OPENBSD_4_3_BASE
# 1.10 20-Sep-2007 thib

MALLOC/FREE -> malloc/free + M_ZERO.
Uneeded includes and casts...

ok krw@


Revision tags: OPENBSD_4_2_BASE
# 1.9 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


# 1.8 31-May-2007 thib

kill some ifdef noyet code, de-static functions (makes my traces nicer),
some comments and style.

ok tedu@


# 1.7 29-May-2007 thib

Add a name argument to the RWLOCK_INITIALIZER macro.
Pick reasonble names for the locks involved..

ok tedu@, art@


# 1.6 28-May-2007 thib

zap annoying __KERNEL_RCSID().

ok krw@


# 1.5 17-May-2007 thib

Collapse struct v_selectinfo in struct vnode, remove the
simplelock and reuse the name for the selinfo member.
Clean-up accordingly.

ok tedu@,art@


# 1.4 19-Apr-2007 thib

Replace the nfskevq_lock lockmgr lock with rwlock.
Replace nfs_kqinit() wich just calls lockinit with
RWLOCK_INITALIZER. Assorted cleanup.

ok tedu@
"reads good" art@


# 1.3 12-Apr-2007 thib

If VOP_GETATTR() in the nfs_kqpoll() loop returns ESTALE, catch it.
Not doing so can lead to clients missing out if the file is for
example removed on the server and the client is doing a 'tail -f' on it.
If it returns ESTALE, mark the file deleted and proceed to handling the
next entry.

ok tedu@,art@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.2 19-Nov-2005 pedro

Remove unnecessary lockmgr() archaism that was costing too much in terms
of panics and bugfixes. Access curproc directly, do not expect a process
pointer as an argument. Should fix many "process context required" bugs.
Incentive and okay millert@, okay marc@. Various testing, thanks.


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.1 21-Jul-2004 marius

kqueue support for NFS, adapted from netbsd.

ok art@ pedro@, "get it in" deraadt@


# 1.29 20-Feb-2020 visa

Replace field f_isfd with field f_flags in struct filterops to allow
adding more filter properties without cluttering the struct.

OK mpi@, anton@


# 1.28 21-Jan-2020 cheloha

sys/nfs: misc. tsleep(9) -> tsleep_nsec(9); ok mpi@


# 1.27 31-Dec-2019 visa

Use C99 designated initializers with struct filterops. In addition,
make the structs const so that the data are put in .rodata.

OK mpi@, deraadt@, anton@, bluhm@


# 1.26 05-Dec-2019 mpi

Convert infinite sleeps to tsleep_nsec(9).

ok jca@


Revision tags: OPENBSD_6_6_BASE
# 1.25 05-Aug-2019 anton

Allow concurrent reads of the f_offset field of struct file by
serializing both read/write operations using the existing file mutex.
The vnode lock still grants exclusive write access to the offset; the
mutex is only used to make the actual write atomic and prevent any
concurrent reader from observing intermediate values.

ok mpi@ visa@


# 1.24 12-Jul-2019 solene

Revert anton@ changes about read/write unlocking
https://marc.info/?l=openbsd-cvs&m=156277704122293&w=2

ok anton@


# 1.23 10-Jul-2019 anton

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@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.22 15-Nov-2014 tedu

add sizes for free(ptr, sizeof(*ptr)). use sizeof(*ptr) for malloc sizes.


Revision tags: OPENBSD_5_6_BASE
# 1.21 06-Aug-2014 guenther

Support NOTE_EOF for kqueue EVFILT_READ filters on NFS files.

committing for jsg@, ok reyk@ tedu@ guenther@


# 1.20 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.19 08-Jul-2014 deraadt

decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.h
don't need to be married.
ok guenther miod beck jsing kettenis


# 1.18 15-Jun-2014 sf

Fix a few format string bugs with -DDEBUG


# 1.17 28-Mar-2014 mpi

Reduce uvm include madness. Use <uvm/uvm_extern.h> instead of
<uvm/uvm.h> if possible and remove double inclusions.

ok beck@, mlarkin@, deraadt@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.16 05-Dec-2012 deraadt

Remove excessive sys/cdefs.h inclusion
ok guenther millert kettenis


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.15 19-Jan-2009 thib

Introduce a macro to invalidate the attribute
cache instead of setting n_attrstamp to 0 directly.

Lift the macro name from NetBSD.
prompted by and OK blambert@


# 1.14 11-Sep-2008 thib

issue a NOTE_TRUNCATE if the file size has shrinked

ok tedu@, blambert@, art@


# 1.13 20-Aug-2008 thib

Return EINVAL instead of '1' for invalid kq filters.

From NetBSD;
OK art@, blambert@


Revision tags: OPENBSD_4_4_BASE
# 1.12 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.11 11-Jun-2008 blambert

Canonical for() -> queue.h FOREACH macro conversions.
Also, it is historical practice to #include <sys/queue.h>
when using queue.h macros.

ok thib@ krw@

special thanks to krw@ for reminders vice violence


Revision tags: OPENBSD_4_3_BASE
# 1.10 20-Sep-2007 thib

MALLOC/FREE -> malloc/free + M_ZERO.
Uneeded includes and casts...

ok krw@


Revision tags: OPENBSD_4_2_BASE
# 1.9 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


# 1.8 31-May-2007 thib

kill some ifdef noyet code, de-static functions (makes my traces nicer),
some comments and style.

ok tedu@


# 1.7 29-May-2007 thib

Add a name argument to the RWLOCK_INITIALIZER macro.
Pick reasonble names for the locks involved..

ok tedu@, art@


# 1.6 28-May-2007 thib

zap annoying __KERNEL_RCSID().

ok krw@


# 1.5 17-May-2007 thib

Collapse struct v_selectinfo in struct vnode, remove the
simplelock and reuse the name for the selinfo member.
Clean-up accordingly.

ok tedu@,art@


# 1.4 19-Apr-2007 thib

Replace the nfskevq_lock lockmgr lock with rwlock.
Replace nfs_kqinit() wich just calls lockinit with
RWLOCK_INITALIZER. Assorted cleanup.

ok tedu@
"reads good" art@


# 1.3 12-Apr-2007 thib

If VOP_GETATTR() in the nfs_kqpoll() loop returns ESTALE, catch it.
Not doing so can lead to clients missing out if the file is for
example removed on the server and the client is doing a 'tail -f' on it.
If it returns ESTALE, mark the file deleted and proceed to handling the
next entry.

ok tedu@,art@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.2 19-Nov-2005 pedro

Remove unnecessary lockmgr() archaism that was costing too much in terms
of panics and bugfixes. Access curproc directly, do not expect a process
pointer as an argument. Should fix many "process context required" bugs.
Incentive and okay millert@, okay marc@. Various testing, thanks.


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.1 21-Jul-2004 marius

kqueue support for NFS, adapted from netbsd.

ok art@ pedro@, "get it in" deraadt@


# 1.28 21-Jan-2020 cheloha

sys/nfs: misc. tsleep(9) -> tsleep_nsec(9); ok mpi@


# 1.27 31-Dec-2019 visa

Use C99 designated initializers with struct filterops. In addition,
make the structs const so that the data are put in .rodata.

OK mpi@, deraadt@, anton@, bluhm@


# 1.26 05-Dec-2019 mpi

Convert infinite sleeps to tsleep_nsec(9).

ok jca@


Revision tags: OPENBSD_6_6_BASE
# 1.25 05-Aug-2019 anton

Allow concurrent reads of the f_offset field of struct file by
serializing both read/write operations using the existing file mutex.
The vnode lock still grants exclusive write access to the offset; the
mutex is only used to make the actual write atomic and prevent any
concurrent reader from observing intermediate values.

ok mpi@ visa@


# 1.24 12-Jul-2019 solene

Revert anton@ changes about read/write unlocking
https://marc.info/?l=openbsd-cvs&m=156277704122293&w=2

ok anton@


# 1.23 10-Jul-2019 anton

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@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.22 15-Nov-2014 tedu

add sizes for free(ptr, sizeof(*ptr)). use sizeof(*ptr) for malloc sizes.


Revision tags: OPENBSD_5_6_BASE
# 1.21 06-Aug-2014 guenther

Support NOTE_EOF for kqueue EVFILT_READ filters on NFS files.

committing for jsg@, ok reyk@ tedu@ guenther@


# 1.20 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.19 08-Jul-2014 deraadt

decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.h
don't need to be married.
ok guenther miod beck jsing kettenis


# 1.18 15-Jun-2014 sf

Fix a few format string bugs with -DDEBUG


# 1.17 28-Mar-2014 mpi

Reduce uvm include madness. Use <uvm/uvm_extern.h> instead of
<uvm/uvm.h> if possible and remove double inclusions.

ok beck@, mlarkin@, deraadt@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.16 05-Dec-2012 deraadt

Remove excessive sys/cdefs.h inclusion
ok guenther millert kettenis


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.15 19-Jan-2009 thib

Introduce a macro to invalidate the attribute
cache instead of setting n_attrstamp to 0 directly.

Lift the macro name from NetBSD.
prompted by and OK blambert@


# 1.14 11-Sep-2008 thib

issue a NOTE_TRUNCATE if the file size has shrinked

ok tedu@, blambert@, art@


# 1.13 20-Aug-2008 thib

Return EINVAL instead of '1' for invalid kq filters.

From NetBSD;
OK art@, blambert@


Revision tags: OPENBSD_4_4_BASE
# 1.12 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.11 11-Jun-2008 blambert

Canonical for() -> queue.h FOREACH macro conversions.
Also, it is historical practice to #include <sys/queue.h>
when using queue.h macros.

ok thib@ krw@

special thanks to krw@ for reminders vice violence


Revision tags: OPENBSD_4_3_BASE
# 1.10 20-Sep-2007 thib

MALLOC/FREE -> malloc/free + M_ZERO.
Uneeded includes and casts...

ok krw@


Revision tags: OPENBSD_4_2_BASE
# 1.9 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


# 1.8 31-May-2007 thib

kill some ifdef noyet code, de-static functions (makes my traces nicer),
some comments and style.

ok tedu@


# 1.7 29-May-2007 thib

Add a name argument to the RWLOCK_INITIALIZER macro.
Pick reasonble names for the locks involved..

ok tedu@, art@


# 1.6 28-May-2007 thib

zap annoying __KERNEL_RCSID().

ok krw@


# 1.5 17-May-2007 thib

Collapse struct v_selectinfo in struct vnode, remove the
simplelock and reuse the name for the selinfo member.
Clean-up accordingly.

ok tedu@,art@


# 1.4 19-Apr-2007 thib

Replace the nfskevq_lock lockmgr lock with rwlock.
Replace nfs_kqinit() wich just calls lockinit with
RWLOCK_INITALIZER. Assorted cleanup.

ok tedu@
"reads good" art@


# 1.3 12-Apr-2007 thib

If VOP_GETATTR() in the nfs_kqpoll() loop returns ESTALE, catch it.
Not doing so can lead to clients missing out if the file is for
example removed on the server and the client is doing a 'tail -f' on it.
If it returns ESTALE, mark the file deleted and proceed to handling the
next entry.

ok tedu@,art@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.2 19-Nov-2005 pedro

Remove unnecessary lockmgr() archaism that was costing too much in terms
of panics and bugfixes. Access curproc directly, do not expect a process
pointer as an argument. Should fix many "process context required" bugs.
Incentive and okay millert@, okay marc@. Various testing, thanks.


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.1 21-Jul-2004 marius

kqueue support for NFS, adapted from netbsd.

ok art@ pedro@, "get it in" deraadt@


# 1.27 31-Dec-2019 visa

Use C99 designated initializers with struct filterops. In addition,
make the structs const so that the data are put in .rodata.

OK mpi@, deraadt@, anton@, bluhm@


# 1.26 05-Dec-2019 mpi

Convert infinite sleeps to tsleep_nsec(9).

ok jca@


Revision tags: OPENBSD_6_6_BASE
# 1.25 05-Aug-2019 anton

Allow concurrent reads of the f_offset field of struct file by
serializing both read/write operations using the existing file mutex.
The vnode lock still grants exclusive write access to the offset; the
mutex is only used to make the actual write atomic and prevent any
concurrent reader from observing intermediate values.

ok mpi@ visa@


# 1.24 12-Jul-2019 solene

Revert anton@ changes about read/write unlocking
https://marc.info/?l=openbsd-cvs&m=156277704122293&w=2

ok anton@


# 1.23 10-Jul-2019 anton

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@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.22 15-Nov-2014 tedu

add sizes for free(ptr, sizeof(*ptr)). use sizeof(*ptr) for malloc sizes.


Revision tags: OPENBSD_5_6_BASE
# 1.21 06-Aug-2014 guenther

Support NOTE_EOF for kqueue EVFILT_READ filters on NFS files.

committing for jsg@, ok reyk@ tedu@ guenther@


# 1.20 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.19 08-Jul-2014 deraadt

decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.h
don't need to be married.
ok guenther miod beck jsing kettenis


# 1.18 15-Jun-2014 sf

Fix a few format string bugs with -DDEBUG


# 1.17 28-Mar-2014 mpi

Reduce uvm include madness. Use <uvm/uvm_extern.h> instead of
<uvm/uvm.h> if possible and remove double inclusions.

ok beck@, mlarkin@, deraadt@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.16 05-Dec-2012 deraadt

Remove excessive sys/cdefs.h inclusion
ok guenther millert kettenis


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.15 19-Jan-2009 thib

Introduce a macro to invalidate the attribute
cache instead of setting n_attrstamp to 0 directly.

Lift the macro name from NetBSD.
prompted by and OK blambert@


# 1.14 11-Sep-2008 thib

issue a NOTE_TRUNCATE if the file size has shrinked

ok tedu@, blambert@, art@


# 1.13 20-Aug-2008 thib

Return EINVAL instead of '1' for invalid kq filters.

From NetBSD;
OK art@, blambert@


Revision tags: OPENBSD_4_4_BASE
# 1.12 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.11 11-Jun-2008 blambert

Canonical for() -> queue.h FOREACH macro conversions.
Also, it is historical practice to #include <sys/queue.h>
when using queue.h macros.

ok thib@ krw@

special thanks to krw@ for reminders vice violence


Revision tags: OPENBSD_4_3_BASE
# 1.10 20-Sep-2007 thib

MALLOC/FREE -> malloc/free + M_ZERO.
Uneeded includes and casts...

ok krw@


Revision tags: OPENBSD_4_2_BASE
# 1.9 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


# 1.8 31-May-2007 thib

kill some ifdef noyet code, de-static functions (makes my traces nicer),
some comments and style.

ok tedu@


# 1.7 29-May-2007 thib

Add a name argument to the RWLOCK_INITIALIZER macro.
Pick reasonble names for the locks involved..

ok tedu@, art@


# 1.6 28-May-2007 thib

zap annoying __KERNEL_RCSID().

ok krw@


# 1.5 17-May-2007 thib

Collapse struct v_selectinfo in struct vnode, remove the
simplelock and reuse the name for the selinfo member.
Clean-up accordingly.

ok tedu@,art@


# 1.4 19-Apr-2007 thib

Replace the nfskevq_lock lockmgr lock with rwlock.
Replace nfs_kqinit() wich just calls lockinit with
RWLOCK_INITALIZER. Assorted cleanup.

ok tedu@
"reads good" art@


# 1.3 12-Apr-2007 thib

If VOP_GETATTR() in the nfs_kqpoll() loop returns ESTALE, catch it.
Not doing so can lead to clients missing out if the file is for
example removed on the server and the client is doing a 'tail -f' on it.
If it returns ESTALE, mark the file deleted and proceed to handling the
next entry.

ok tedu@,art@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.2 19-Nov-2005 pedro

Remove unnecessary lockmgr() archaism that was costing too much in terms
of panics and bugfixes. Access curproc directly, do not expect a process
pointer as an argument. Should fix many "process context required" bugs.
Incentive and okay millert@, okay marc@. Various testing, thanks.


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.1 21-Jul-2004 marius

kqueue support for NFS, adapted from netbsd.

ok art@ pedro@, "get it in" deraadt@


# 1.26 05-Dec-2019 mpi

Convert infinite sleeps to tsleep_nsec(9).

ok jca@


Revision tags: OPENBSD_6_6_BASE
# 1.25 05-Aug-2019 anton

Allow concurrent reads of the f_offset field of struct file by
serializing both read/write operations using the existing file mutex.
The vnode lock still grants exclusive write access to the offset; the
mutex is only used to make the actual write atomic and prevent any
concurrent reader from observing intermediate values.

ok mpi@ visa@


# 1.24 12-Jul-2019 solene

Revert anton@ changes about read/write unlocking
https://marc.info/?l=openbsd-cvs&m=156277704122293&w=2

ok anton@


# 1.23 10-Jul-2019 anton

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@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.22 15-Nov-2014 tedu

add sizes for free(ptr, sizeof(*ptr)). use sizeof(*ptr) for malloc sizes.


Revision tags: OPENBSD_5_6_BASE
# 1.21 06-Aug-2014 guenther

Support NOTE_EOF for kqueue EVFILT_READ filters on NFS files.

committing for jsg@, ok reyk@ tedu@ guenther@


# 1.20 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.19 08-Jul-2014 deraadt

decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.h
don't need to be married.
ok guenther miod beck jsing kettenis


# 1.18 15-Jun-2014 sf

Fix a few format string bugs with -DDEBUG


# 1.17 28-Mar-2014 mpi

Reduce uvm include madness. Use <uvm/uvm_extern.h> instead of
<uvm/uvm.h> if possible and remove double inclusions.

ok beck@, mlarkin@, deraadt@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.16 05-Dec-2012 deraadt

Remove excessive sys/cdefs.h inclusion
ok guenther millert kettenis


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.15 19-Jan-2009 thib

Introduce a macro to invalidate the attribute
cache instead of setting n_attrstamp to 0 directly.

Lift the macro name from NetBSD.
prompted by and OK blambert@


# 1.14 11-Sep-2008 thib

issue a NOTE_TRUNCATE if the file size has shrinked

ok tedu@, blambert@, art@


# 1.13 20-Aug-2008 thib

Return EINVAL instead of '1' for invalid kq filters.

From NetBSD;
OK art@, blambert@


Revision tags: OPENBSD_4_4_BASE
# 1.12 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.11 11-Jun-2008 blambert

Canonical for() -> queue.h FOREACH macro conversions.
Also, it is historical practice to #include <sys/queue.h>
when using queue.h macros.

ok thib@ krw@

special thanks to krw@ for reminders vice violence


Revision tags: OPENBSD_4_3_BASE
# 1.10 20-Sep-2007 thib

MALLOC/FREE -> malloc/free + M_ZERO.
Uneeded includes and casts...

ok krw@


Revision tags: OPENBSD_4_2_BASE
# 1.9 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


# 1.8 31-May-2007 thib

kill some ifdef noyet code, de-static functions (makes my traces nicer),
some comments and style.

ok tedu@


# 1.7 29-May-2007 thib

Add a name argument to the RWLOCK_INITIALIZER macro.
Pick reasonble names for the locks involved..

ok tedu@, art@


# 1.6 28-May-2007 thib

zap annoying __KERNEL_RCSID().

ok krw@


# 1.5 17-May-2007 thib

Collapse struct v_selectinfo in struct vnode, remove the
simplelock and reuse the name for the selinfo member.
Clean-up accordingly.

ok tedu@,art@


# 1.4 19-Apr-2007 thib

Replace the nfskevq_lock lockmgr lock with rwlock.
Replace nfs_kqinit() wich just calls lockinit with
RWLOCK_INITALIZER. Assorted cleanup.

ok tedu@
"reads good" art@


# 1.3 12-Apr-2007 thib

If VOP_GETATTR() in the nfs_kqpoll() loop returns ESTALE, catch it.
Not doing so can lead to clients missing out if the file is for
example removed on the server and the client is doing a 'tail -f' on it.
If it returns ESTALE, mark the file deleted and proceed to handling the
next entry.

ok tedu@,art@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.2 19-Nov-2005 pedro

Remove unnecessary lockmgr() archaism that was costing too much in terms
of panics and bugfixes. Access curproc directly, do not expect a process
pointer as an argument. Should fix many "process context required" bugs.
Incentive and okay millert@, okay marc@. Various testing, thanks.


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.1 21-Jul-2004 marius

kqueue support for NFS, adapted from netbsd.

ok art@ pedro@, "get it in" deraadt@


# 1.25 05-Aug-2019 anton

Allow concurrent reads of the f_offset field of struct file by
serializing both read/write operations using the existing file mutex.
The vnode lock still grants exclusive write access to the offset; the
mutex is only used to make the actual write atomic and prevent any
concurrent reader from observing intermediate values.

ok mpi@ visa@


# 1.24 12-Jul-2019 solene

Revert anton@ changes about read/write unlocking
https://marc.info/?l=openbsd-cvs&m=156277704122293&w=2

ok anton@


# 1.23 10-Jul-2019 anton

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@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.22 15-Nov-2014 tedu

add sizes for free(ptr, sizeof(*ptr)). use sizeof(*ptr) for malloc sizes.


Revision tags: OPENBSD_5_6_BASE
# 1.21 06-Aug-2014 guenther

Support NOTE_EOF for kqueue EVFILT_READ filters on NFS files.

committing for jsg@, ok reyk@ tedu@ guenther@


# 1.20 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.19 08-Jul-2014 deraadt

decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.h
don't need to be married.
ok guenther miod beck jsing kettenis


# 1.18 15-Jun-2014 sf

Fix a few format string bugs with -DDEBUG


# 1.17 28-Mar-2014 mpi

Reduce uvm include madness. Use <uvm/uvm_extern.h> instead of
<uvm/uvm.h> if possible and remove double inclusions.

ok beck@, mlarkin@, deraadt@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.16 05-Dec-2012 deraadt

Remove excessive sys/cdefs.h inclusion
ok guenther millert kettenis


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.15 19-Jan-2009 thib

Introduce a macro to invalidate the attribute
cache instead of setting n_attrstamp to 0 directly.

Lift the macro name from NetBSD.
prompted by and OK blambert@


# 1.14 11-Sep-2008 thib

issue a NOTE_TRUNCATE if the file size has shrinked

ok tedu@, blambert@, art@


# 1.13 20-Aug-2008 thib

Return EINVAL instead of '1' for invalid kq filters.

From NetBSD;
OK art@, blambert@


Revision tags: OPENBSD_4_4_BASE
# 1.12 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.11 11-Jun-2008 blambert

Canonical for() -> queue.h FOREACH macro conversions.
Also, it is historical practice to #include <sys/queue.h>
when using queue.h macros.

ok thib@ krw@

special thanks to krw@ for reminders vice violence


Revision tags: OPENBSD_4_3_BASE
# 1.10 20-Sep-2007 thib

MALLOC/FREE -> malloc/free + M_ZERO.
Uneeded includes and casts...

ok krw@


Revision tags: OPENBSD_4_2_BASE
# 1.9 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


# 1.8 31-May-2007 thib

kill some ifdef noyet code, de-static functions (makes my traces nicer),
some comments and style.

ok tedu@


# 1.7 29-May-2007 thib

Add a name argument to the RWLOCK_INITIALIZER macro.
Pick reasonble names for the locks involved..

ok tedu@, art@


# 1.6 28-May-2007 thib

zap annoying __KERNEL_RCSID().

ok krw@


# 1.5 17-May-2007 thib

Collapse struct v_selectinfo in struct vnode, remove the
simplelock and reuse the name for the selinfo member.
Clean-up accordingly.

ok tedu@,art@


# 1.4 19-Apr-2007 thib

Replace the nfskevq_lock lockmgr lock with rwlock.
Replace nfs_kqinit() wich just calls lockinit with
RWLOCK_INITALIZER. Assorted cleanup.

ok tedu@
"reads good" art@


# 1.3 12-Apr-2007 thib

If VOP_GETATTR() in the nfs_kqpoll() loop returns ESTALE, catch it.
Not doing so can lead to clients missing out if the file is for
example removed on the server and the client is doing a 'tail -f' on it.
If it returns ESTALE, mark the file deleted and proceed to handling the
next entry.

ok tedu@,art@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.2 19-Nov-2005 pedro

Remove unnecessary lockmgr() archaism that was costing too much in terms
of panics and bugfixes. Access curproc directly, do not expect a process
pointer as an argument. Should fix many "process context required" bugs.
Incentive and okay millert@, okay marc@. Various testing, thanks.


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.1 21-Jul-2004 marius

kqueue support for NFS, adapted from netbsd.

ok art@ pedro@, "get it in" deraadt@


# 1.24 12-Jul-2019 solene

Revert anton@ changes about read/write unlocking
https://marc.info/?l=openbsd-cvs&m=156277704122293&w=2

ok anton@


# 1.23 10-Jul-2019 anton

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@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.22 15-Nov-2014 tedu

add sizes for free(ptr, sizeof(*ptr)). use sizeof(*ptr) for malloc sizes.


Revision tags: OPENBSD_5_6_BASE
# 1.21 06-Aug-2014 guenther

Support NOTE_EOF for kqueue EVFILT_READ filters on NFS files.

committing for jsg@, ok reyk@ tedu@ guenther@


# 1.20 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.19 08-Jul-2014 deraadt

decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.h
don't need to be married.
ok guenther miod beck jsing kettenis


# 1.18 15-Jun-2014 sf

Fix a few format string bugs with -DDEBUG


# 1.17 28-Mar-2014 mpi

Reduce uvm include madness. Use <uvm/uvm_extern.h> instead of
<uvm/uvm.h> if possible and remove double inclusions.

ok beck@, mlarkin@, deraadt@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.16 05-Dec-2012 deraadt

Remove excessive sys/cdefs.h inclusion
ok guenther millert kettenis


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.15 19-Jan-2009 thib

Introduce a macro to invalidate the attribute
cache instead of setting n_attrstamp to 0 directly.

Lift the macro name from NetBSD.
prompted by and OK blambert@


# 1.14 11-Sep-2008 thib

issue a NOTE_TRUNCATE if the file size has shrinked

ok tedu@, blambert@, art@


# 1.13 20-Aug-2008 thib

Return EINVAL instead of '1' for invalid kq filters.

From NetBSD;
OK art@, blambert@


Revision tags: OPENBSD_4_4_BASE
# 1.12 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.11 11-Jun-2008 blambert

Canonical for() -> queue.h FOREACH macro conversions.
Also, it is historical practice to #include <sys/queue.h>
when using queue.h macros.

ok thib@ krw@

special thanks to krw@ for reminders vice violence


Revision tags: OPENBSD_4_3_BASE
# 1.10 20-Sep-2007 thib

MALLOC/FREE -> malloc/free + M_ZERO.
Uneeded includes and casts...

ok krw@


Revision tags: OPENBSD_4_2_BASE
# 1.9 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


# 1.8 31-May-2007 thib

kill some ifdef noyet code, de-static functions (makes my traces nicer),
some comments and style.

ok tedu@


# 1.7 29-May-2007 thib

Add a name argument to the RWLOCK_INITIALIZER macro.
Pick reasonble names for the locks involved..

ok tedu@, art@


# 1.6 28-May-2007 thib

zap annoying __KERNEL_RCSID().

ok krw@


# 1.5 17-May-2007 thib

Collapse struct v_selectinfo in struct vnode, remove the
simplelock and reuse the name for the selinfo member.
Clean-up accordingly.

ok tedu@,art@


# 1.4 19-Apr-2007 thib

Replace the nfskevq_lock lockmgr lock with rwlock.
Replace nfs_kqinit() wich just calls lockinit with
RWLOCK_INITALIZER. Assorted cleanup.

ok tedu@
"reads good" art@


# 1.3 12-Apr-2007 thib

If VOP_GETATTR() in the nfs_kqpoll() loop returns ESTALE, catch it.
Not doing so can lead to clients missing out if the file is for
example removed on the server and the client is doing a 'tail -f' on it.
If it returns ESTALE, mark the file deleted and proceed to handling the
next entry.

ok tedu@,art@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.2 19-Nov-2005 pedro

Remove unnecessary lockmgr() archaism that was costing too much in terms
of panics and bugfixes. Access curproc directly, do not expect a process
pointer as an argument. Should fix many "process context required" bugs.
Incentive and okay millert@, okay marc@. Various testing, thanks.


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.1 21-Jul-2004 marius

kqueue support for NFS, adapted from netbsd.

ok art@ pedro@, "get it in" deraadt@


# 1.23 10-Jul-2019 anton

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@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.22 15-Nov-2014 tedu

add sizes for free(ptr, sizeof(*ptr)). use sizeof(*ptr) for malloc sizes.


Revision tags: OPENBSD_5_6_BASE
# 1.21 06-Aug-2014 guenther

Support NOTE_EOF for kqueue EVFILT_READ filters on NFS files.

committing for jsg@, ok reyk@ tedu@ guenther@


# 1.20 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.19 08-Jul-2014 deraadt

decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.h
don't need to be married.
ok guenther miod beck jsing kettenis


# 1.18 15-Jun-2014 sf

Fix a few format string bugs with -DDEBUG


# 1.17 28-Mar-2014 mpi

Reduce uvm include madness. Use <uvm/uvm_extern.h> instead of
<uvm/uvm.h> if possible and remove double inclusions.

ok beck@, mlarkin@, deraadt@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.16 05-Dec-2012 deraadt

Remove excessive sys/cdefs.h inclusion
ok guenther millert kettenis


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.15 19-Jan-2009 thib

Introduce a macro to invalidate the attribute
cache instead of setting n_attrstamp to 0 directly.

Lift the macro name from NetBSD.
prompted by and OK blambert@


# 1.14 11-Sep-2008 thib

issue a NOTE_TRUNCATE if the file size has shrinked

ok tedu@, blambert@, art@


# 1.13 20-Aug-2008 thib

Return EINVAL instead of '1' for invalid kq filters.

From NetBSD;
OK art@, blambert@


Revision tags: OPENBSD_4_4_BASE
# 1.12 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.11 11-Jun-2008 blambert

Canonical for() -> queue.h FOREACH macro conversions.
Also, it is historical practice to #include <sys/queue.h>
when using queue.h macros.

ok thib@ krw@

special thanks to krw@ for reminders vice violence


Revision tags: OPENBSD_4_3_BASE
# 1.10 20-Sep-2007 thib

MALLOC/FREE -> malloc/free + M_ZERO.
Uneeded includes and casts...

ok krw@


Revision tags: OPENBSD_4_2_BASE
# 1.9 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


# 1.8 31-May-2007 thib

kill some ifdef noyet code, de-static functions (makes my traces nicer),
some comments and style.

ok tedu@


# 1.7 29-May-2007 thib

Add a name argument to the RWLOCK_INITIALIZER macro.
Pick reasonble names for the locks involved..

ok tedu@, art@


# 1.6 28-May-2007 thib

zap annoying __KERNEL_RCSID().

ok krw@


# 1.5 17-May-2007 thib

Collapse struct v_selectinfo in struct vnode, remove the
simplelock and reuse the name for the selinfo member.
Clean-up accordingly.

ok tedu@,art@


# 1.4 19-Apr-2007 thib

Replace the nfskevq_lock lockmgr lock with rwlock.
Replace nfs_kqinit() wich just calls lockinit with
RWLOCK_INITALIZER. Assorted cleanup.

ok tedu@
"reads good" art@


# 1.3 12-Apr-2007 thib

If VOP_GETATTR() in the nfs_kqpoll() loop returns ESTALE, catch it.
Not doing so can lead to clients missing out if the file is for
example removed on the server and the client is doing a 'tail -f' on it.
If it returns ESTALE, mark the file deleted and proceed to handling the
next entry.

ok tedu@,art@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.2 19-Nov-2005 pedro

Remove unnecessary lockmgr() archaism that was costing too much in terms
of panics and bugfixes. Access curproc directly, do not expect a process
pointer as an argument. Should fix many "process context required" bugs.
Incentive and okay millert@, okay marc@. Various testing, thanks.


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.1 21-Jul-2004 marius

kqueue support for NFS, adapted from netbsd.

ok art@ pedro@, "get it in" deraadt@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.22 15-Nov-2014 tedu

add sizes for free(ptr, sizeof(*ptr)). use sizeof(*ptr) for malloc sizes.


Revision tags: OPENBSD_5_6_BASE
# 1.21 06-Aug-2014 guenther

Support NOTE_EOF for kqueue EVFILT_READ filters on NFS files.

committing for jsg@, ok reyk@ tedu@ guenther@


# 1.20 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.19 08-Jul-2014 deraadt

decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.h
don't need to be married.
ok guenther miod beck jsing kettenis


# 1.18 15-Jun-2014 sf

Fix a few format string bugs with -DDEBUG


# 1.17 28-Mar-2014 mpi

Reduce uvm include madness. Use <uvm/uvm_extern.h> instead of
<uvm/uvm.h> if possible and remove double inclusions.

ok beck@, mlarkin@, deraadt@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.16 05-Dec-2012 deraadt

Remove excessive sys/cdefs.h inclusion
ok guenther millert kettenis


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.15 19-Jan-2009 thib

Introduce a macro to invalidate the attribute
cache instead of setting n_attrstamp to 0 directly.

Lift the macro name from NetBSD.
prompted by and OK blambert@


# 1.14 11-Sep-2008 thib

issue a NOTE_TRUNCATE if the file size has shrinked

ok tedu@, blambert@, art@


# 1.13 20-Aug-2008 thib

Return EINVAL instead of '1' for invalid kq filters.

From NetBSD;
OK art@, blambert@


Revision tags: OPENBSD_4_4_BASE
# 1.12 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.11 11-Jun-2008 blambert

Canonical for() -> queue.h FOREACH macro conversions.
Also, it is historical practice to #include <sys/queue.h>
when using queue.h macros.

ok thib@ krw@

special thanks to krw@ for reminders vice violence


Revision tags: OPENBSD_4_3_BASE
# 1.10 20-Sep-2007 thib

MALLOC/FREE -> malloc/free + M_ZERO.
Uneeded includes and casts...

ok krw@


Revision tags: OPENBSD_4_2_BASE
# 1.9 01-Jun-2007 deraadt

pedro ok'd this ~3500 line diff which removes the vop argument
"ap = v" comments in under 8 seconds, so it must be ok. and it compiles
too.


# 1.8 31-May-2007 thib

kill some ifdef noyet code, de-static functions (makes my traces nicer),
some comments and style.

ok tedu@


# 1.7 29-May-2007 thib

Add a name argument to the RWLOCK_INITIALIZER macro.
Pick reasonble names for the locks involved..

ok tedu@, art@


# 1.6 28-May-2007 thib

zap annoying __KERNEL_RCSID().

ok krw@


# 1.5 17-May-2007 thib

Collapse struct v_selectinfo in struct vnode, remove the
simplelock and reuse the name for the selinfo member.
Clean-up accordingly.

ok tedu@,art@


# 1.4 19-Apr-2007 thib

Replace the nfskevq_lock lockmgr lock with rwlock.
Replace nfs_kqinit() wich just calls lockinit with
RWLOCK_INITALIZER. Assorted cleanup.

ok tedu@
"reads good" art@


# 1.3 12-Apr-2007 thib

If VOP_GETATTR() in the nfs_kqpoll() loop returns ESTALE, catch it.
Not doing so can lead to clients missing out if the file is for
example removed on the server and the client is doing a 'tail -f' on it.
If it returns ESTALE, mark the file deleted and proceed to handling the
next entry.

ok tedu@,art@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.2 19-Nov-2005 pedro

Remove unnecessary lockmgr() archaism that was costing too much in terms
of panics and bugfixes. Access curproc directly, do not expect a process
pointer as an argument. Should fix many "process context required" bugs.
Incentive and okay millert@, okay marc@. Various testing, thanks.


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.1 21-Jul-2004 marius

kqueue support for NFS, adapted from netbsd.

ok art@ pedro@, "get it in" deraadt@