History log of /netbsd-current/sys/kern/vfs_trans.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.70 04-Nov-2022 hannken

Add a helper to set or clear lower mount and use it.
Always add a reference to the lower mount.

Ride 9.99.105


# 1.69 26-Oct-2022 riastradh

miscfs/deadfs/deadfs.h: New home for deadfs-related externs.

XXX regen sys/kern/vnode_if.c and the others


Revision tags: bouyer-sunxi-drm-base
# 1.68 22-Aug-2022 hannken

Don't allocate lwp info for fstrans_held() and fstrans_is_owner().
If it doesn't exist we cannot hold a transaction or suspension.


# 1.67 11-Aug-2022 hannken

Finish previous, evaluate the lowest mount on first access
to "struct mount_info" and store it here so we no longer
derefence the "struct mount" from fstrans_alloc_lwp_info().

Reported-by: syzbot+5a79214d043395b550d8@syzkaller.appspotmail.com


# 1.66 08-Jul-2022 hannken

While one thread runs vgone() it is possible for another thread to grab
a "v_mount" that will be freed before it uses this mount for fstrans_start().

Add a hashtab to lookup our private mount data "fstrans_mount_info" and
use "mp" as an opaque key for lookup.

Reported-by: syzbot+54dc9ac0804a97b59bc6@syzkaller.appspotmail.com


# 1.65 08-Jul-2022 hannken

Handle IMNT_GONE on the file system we want suspended not its
lowest mount we really suspend.


# 1.64 28-Jun-2022 riastradh

fstrans(9): KASSERT(a && b) => KASSERT(a); KASSERT(b)

No functional change intended except better diagnostics in case of
crash.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base
# 1.63 17-May-2020 ad

Reorganise the locking and allocation of fstrans_lwp_info slightly, to
reduce contention. "please go ahead" hannken@.


# 1.62 13-May-2020 hannken

Add operation fstrans_held(struct mount *), true if the current thread
holds a fstrans lock.

Ride 9.99.61


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.61 17-Jun-2019 hannken

Add an owner field to fstrans mount info and use it to hold
the thread currently suspending this mount.

Remove now unneeded state FSTRANS_EXCL.

It is now possible to suspend a file system from a thread
already holding fstrans locks. Use with care ...


Revision tags: phil-wifi-20190609
# 1.60 13-May-2019 hannken

Walk down to the lowest mount for "fli_alias".

Address PR kern/54195 (null mounts: panic: ...).


Revision tags: isaki-audio2-base
# 1.59 15-Apr-2019 hannken

Add reference counting to alias states to prevent them disappearing
while still in use.


# 1.58 07-Mar-2019 hannken

Change "fli_alias" to point to the corresponding "fstrans_lwp_info".

Fix fstrans_clear_lwp_info() list traversal, remove already advanced
the list pointer.


# 1.57 01-Mar-2019 hannken

Move pointer to fstrans private data into "struct lwp".

Ride NetBSD 8.99.35


# 1.56 24-Feb-2019 hannken

Clear per-lwp entries whose mount is gone before the first return
from fstrans_done().

No longer leaks "struct mount" forever.


# 1.55 21-Feb-2019 hannken

Fix bad assertion: vfs_suspend(dead_rootmount) may happen and
must return EOPNOTSUPP.


# 1.54 20-Feb-2019 hannken

- Make the fstrans mount info part of the per-lwp state and replace
most accesses to the mount with fstrans mount info.

- Add "fmi_gone" to be true after unmount and add a counter of
outstanding mount infos so fstrans_clear_lwp_info() only runs
if there may be something to do.

- Move lookup of base mounts into per-lwp state.

- Keep a list of valid mounts for DIAGNOSTIC checks.


# 1.53 20-Feb-2019 hannken

Move fstrans_unmount() to vfs_rele(), just before it would free the mount.
Don't take a mount reference for fstrans as it gets notified about the release.

Defer the final free of the mount to fstrans_mount_dtor() when fstrans
has released all references to this mount. Prevents the mount's memory
to be reused as a new mount before fstrans released all references.

Address PR kern/53928 modules/t_builtin:disable test case randomly fails.


# 1.52 20-Feb-2019 hannken

Attach "mnt_transinfo" to "dead_rootmount" so every mount has a
valid "mnt_transinfo" and remove now unneeded flag IMNT_HAS_TRANS.

Run fstrans_start()/fstrans_done() on dead_rootmount if FSTRANS_DEAD_ENABLED.
Should become the default for DIAGNOSTIC in the future.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.51 05-Oct-2018 hannken

Bring back three state file system suspension:

NORMAL -> SUSPENDING -> SUSPENDED

and add operation fstrans_start_lazy() that only blocks while SUSPENDED.

Change vndthread() support operation handle_with_rdwr() to bracket
its file system operations by fstrans_start_lazy() and fstrans_done().

PR kern/53624 (dom0 freeze on domU exit)


# 1.50 05-Oct-2018 manu

Back out sftchg/fstcnt deadlock workaround

The change did prevent some system freeze, but caused spurious
unmount failures reporter by bouyer@.

hannken@ is working on the right fix, see kern/53624


Revision tags: pgoyette-compat-0930
# 1.49 27-Sep-2018 manu

Work around deadlock between fstchg and fstcnt

When suspending a filesystem in fstrans_setstate(), we wait on
fstcnt for threads to finish transactions. While we do this, any
thread trying to start a filesystem transaction will wait on fstchg
in fstrans_start(), a situation which can deadlock.

The wait for fstcnt in fstrans_setstate() can be interrupted by
a signal, but the wait for fstchg in fstrans_start() cannot. Once
most processes are stuck in fstchg, it is impossible to send a
signal to the thread that waits on fstcnt, because no process
respond anymore to user input.

We fix that by adding a timeout to the wait on fstcnt in
fstrans_setstate(). This means suspending a filesystem may fail,
but it was already the case when the sleep was interupted by
a signal, hence calling function must already handle a possible
failure.

Fixes kern/53624


Revision tags: pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.48 18-Jun-2017 hannken

branches: 1.48.4; 1.48.6;
Make the fast path of fstrans_get_lwp_info() "static inline".


# 1.47 18-Jun-2017 hannken

Clear fstrans entries whose mount is gone from the last fstrans_done() only.


# 1.46 04-Jun-2017 hannken

Operations fstrans_start() and fstrans_start_nowait() now always
use FSTRANS_SHARED as lock type so remove the lock type argument.

File system state FSTRANS_SUSPENDING is now unused so remove it.

Regen vnode_if files.

Ride 8.99.1 less than a hour ago.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.45 07-May-2017 hannken

branches: 1.45.2;
Move fstrans initialization to vfs_mountalloc().


# 1.44 07-May-2017 hannken

Handle the case where the mount is gone and its mnt_transinfo is NULL.


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1
# 1.43 17-Apr-2017 hannken

branches: 1.43.2;
Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.


# 1.42 17-Apr-2017 hannken

Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount. Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).


# 1.41 12-Apr-2017 hannken

Switch fstrans_dump() to _mountlist_next().


Revision tags: jdolecek-ncq-base
# 1.40 30-Mar-2017 hannken

Change _fstrans_start() to allocate per lwp info for layered file
systems to get a reference on the mount.

Set mnt_lower on successfull mount only.


Revision tags: pgoyette-localcount-20170320
# 1.39 06-Mar-2017 hannken

Always use the lowest mount for fstrans and suspend. This way we
enter/leave or suspend/resume the stack of layered file systems as a unit.


# 1.38 02-Mar-2017 hannken

Add an operation to test a mount for fstrans support and use it for
_fstrans_start(), fstrans_done(), fstrans_is_owner(), vfs_suspend()
and vfs_resume().

Test for fstrans support before ASSERT_SLEEPABLE().


# 1.37 23-Feb-2017 hannken

Test for fstrans support before trying to allocate per-thread info.

PR kern/51996 (kmem_alloc called from intr context in fstrans_get_lwp_info)


# 1.36 17-Feb-2017 hannken

Let syncer try fstrans_start() before running VFS_SYNC() to get rid
of the syncer lock/unlock from vfs_suspend().


# 1.35 17-Feb-2017 hannken

Protect attaching and detaching lwp_info to mount with a mutex.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.34 24-Aug-2015 pooka

branches: 1.34.2; 1.34.4;
to garnish, dust with _KERNEL_OPT


Revision tags: nick-nhusb-base-20150606
# 1.33 06-May-2015 hannken

Remove miscfs/syncfs and

- move the syncer into kern/vfs_subr.c.

- change the syncer to process the mountlist and VFS_SYNC as appropriate.

- use an API for mount points similiar to the API for vnodes:
- vfs_syncer_add_to_worklist(struct mount *mp) to add
- vfs_syncer_remove_from_worklist(struct mount *mp) to remove a mount.

No objections on tech-kern@


# 1.32 21-Apr-2015 pooka

Don't check if constant-sized KM_SLEEP allocations succeeded.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.31 05-Sep-2014 matt

branches: 1.31.2;
Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.30 15-Apr-2014 hannken

Fix a deadlock where one thread exits, enters fstrans_lwp_dtor()
and wants fstrans_lock. This thread holds the proc_lock.
Another thread holds fstrans_lock and runs pserialize_perform().
As the first thread holds the proc_lock, timeouts are blocked and
the second thread blocks forever in kpause().

Change fstrans_lwp_dtor() to invalidate, but not free its info
structs. No need to take fstrans_lock.

Change fstrans_get_lwp_info() to reuse invalidated info before
trying to allocate a new one.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.29 23-Nov-2013 christos

branches: 1.29.2;
change the mountlist CIRCLEQ into a TAILQ


# 1.28 25-Oct-2013 martin

Mark diagnostic-only variables


# 1.27 30-Sep-2013 hannken

Replace macro v_specmountpoint with two functions spec_node_getmountedfs()
and spec_node_setmountedfs() to manage the file system mounted on a device.
Assert the device is a block device.

Welcome to 6.99.24

Discussed on tech-kern@ some time ago.

Reviewed by: David Holland <dholland@netbsd.org>


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.26 21-Jan-2013 hannken

branches: 1.26.2;
Replace the rwlock based implementation with passive serialization
from pserialize(9) and mutex / condvar.

The fast paths (fstrans_start/fstrans_done on a file system not
suspended or suspending and fscow_run with no change pending) now
run without locks or other atomic operations. Suspension and cow
handler insertion and removal is done with mutex / condvars.

The API remains unchanged.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 1.25 12-May-2009 yamt

branches: 1.25.12; 1.25.22;
don't forget to skip marker processes.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.24 16-Nov-2008 pooka

branches: 1.24.4;
more <sys/buf.h> police


Revision tags: netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3
# 1.23 17-Sep-2008 hannken

branches: 1.23.2; 1.23.4; 1.23.6;
Replace the fss unmount hook with a vfs_hook.

fssvar.h: struct device * -> device_t.
fss.c: establish unmount hook on first attach, remove on last detach.
vfs_syscalls.c: remove the call of fss_umount_hook().
vfs_trans.c: destroy cow handlers on unmount as fstrans_unmount() will be
called before vfs_hooks.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.22 24-Jun-2008 ad

branches: 1.22.2;
Use pool_cache.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 16-May-2008 hannken

branches: 1.21.2;
Remove a bad assertion from last commit.
Non bufcache buffers may have BC_BUSY unset.


# 1.20 16-May-2008 hannken

Fscow_run() may recurse into itself.
Take care by adding a per-lwp recursion counter.


Revision tags: yamt-nfs-mp-base2
# 1.19 28-Apr-2008 martin

branches: 1.19.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.18 17-Mar-2008 yamt

branches: 1.18.2; 1.18.4;
- simplify ASSERT_SLEEPABLE.
- move it from proc.h to systm.h.
- add some more checks.
- make it a little more lkm friendly.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 1.17 02-Feb-2008 hannken

branches: 1.17.2; 1.17.6;
BO_COWDONE -> B_COWDONE: this flag is tested/modified from the thread owning
the buffer and therefore needs no protection by a mutex.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.16 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.15 02-Dec-2007 hannken

branches: 1.15.2; 1.15.6;
Fscow_run(): add a flag "bool data_valid" to note still valid data.
Buffers run through copy-on-write are marked B_COWDONE. This condition
is valid until the buffer has run through bwrite() and gets cleared from
biodone().

Welcome to 4.99.39.

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.14 08-Oct-2007 hannken

branches: 1.14.4;
fscow_run(): Check for NULL mount and don't run the cow handler in this case.


# 1.13 07-Oct-2007 hannken

Remove an include committed by accident.

From Chris Ross via current-users.


# 1.12 07-Oct-2007 hannken

Update the file system copy-on-write handler.

- Instead of hooking the handler on the specdev of a mounted file system
hook directly on the `struct mount'.

- Rename from `vn_cow_*' to `fscow_*' and move to `kern/vfs_trans.c'. Use
`mount_*specific' instead of clobbering `struct mount' or `struct specinfo'.

- Replace the hand-made reader/writer lock with a krwlock.

- Keep `vn_cow_*' functions and mark as obsolete.

- Welcome to NetBSD 4.99.32 - `struct specinfo' changed size.

Reviewed by: Jason Thorpe <thorpej@netbsd.org>


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.11 26-Jul-2007 pooka

branches: 1.11.4; 1.11.6; 1.11.8; 1.11.10;
Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.10 09-Jul-2007 ad

branches: 1.10.2;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8
# 1.9 17-May-2007 hannken

Fstrans_start() always returns zero, so change its type to void.


# 1.8 16-May-2007 hannken

Use rwlock for fmi_shared_lock and fmi_lazy_lock.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: thorpej-atomic-base
# 1.7 12-Mar-2007 ad

Use mutexes/condvars.


# 1.6 12-Mar-2007 ad

branches: 1.6.2;
Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.


Revision tags: ad-audiomp-base
# 1.5 16-Feb-2007 hannken

branches: 1.5.2; 1.5.4; 1.5.8;
Make fstrans(9) the default helper for file system suspension.
Replaces the now obsolete vn_start_write()/vn_finished_write().


# 1.4 15-Feb-2007 ad

Replace some uses of lockmgr() / simplelocks.


# 1.3 10-Feb-2007 hannken

newlock2: syncer_lock is now a mutex.


Revision tags: post-newlock2-merge newlock2-base newlock2-nbase
# 1.2 29-Jan-2007 hannken

branches: 1.2.2;
Change fstrans enum types to upper case.
No functional change.

From Antti Kantee <pooka@netbsd.org>


# 1.1 19-Jan-2007 hannken

New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

The new API is enabled on a kernel option NEWVNGATE. This option is
not enabled by default in any kernel config.

Presented and discussed on tech-kern with much input from
Bill Studenmund <wrstuden@netbsd.org> and YAMAMOTO Takashi <yamt@netbsd.org>.

Welcome to 4.99.9 (new vfs op vfs_suspendctl).


# 1.69 26-Oct-2022 riastradh

miscfs/deadfs/deadfs.h: New home for deadfs-related externs.

XXX regen sys/kern/vnode_if.c and the others


Revision tags: bouyer-sunxi-drm-base
# 1.68 22-Aug-2022 hannken

Don't allocate lwp info for fstrans_held() and fstrans_is_owner().
If it doesn't exist we cannot hold a transaction or suspension.


# 1.67 11-Aug-2022 hannken

Finish previous, evaluate the lowest mount on first access
to "struct mount_info" and store it here so we no longer
derefence the "struct mount" from fstrans_alloc_lwp_info().

Reported-by: syzbot+5a79214d043395b550d8@syzkaller.appspotmail.com


# 1.66 08-Jul-2022 hannken

While one thread runs vgone() it is possible for another thread to grab
a "v_mount" that will be freed before it uses this mount for fstrans_start().

Add a hashtab to lookup our private mount data "fstrans_mount_info" and
use "mp" as an opaque key for lookup.

Reported-by: syzbot+54dc9ac0804a97b59bc6@syzkaller.appspotmail.com


# 1.65 08-Jul-2022 hannken

Handle IMNT_GONE on the file system we want suspended not its
lowest mount we really suspend.


# 1.64 28-Jun-2022 riastradh

fstrans(9): KASSERT(a && b) => KASSERT(a); KASSERT(b)

No functional change intended except better diagnostics in case of
crash.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base
# 1.63 17-May-2020 ad

Reorganise the locking and allocation of fstrans_lwp_info slightly, to
reduce contention. "please go ahead" hannken@.


# 1.62 13-May-2020 hannken

Add operation fstrans_held(struct mount *), true if the current thread
holds a fstrans lock.

Ride 9.99.61


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.61 17-Jun-2019 hannken

Add an owner field to fstrans mount info and use it to hold
the thread currently suspending this mount.

Remove now unneeded state FSTRANS_EXCL.

It is now possible to suspend a file system from a thread
already holding fstrans locks. Use with care ...


Revision tags: phil-wifi-20190609
# 1.60 13-May-2019 hannken

Walk down to the lowest mount for "fli_alias".

Address PR kern/54195 (null mounts: panic: ...).


Revision tags: isaki-audio2-base
# 1.59 15-Apr-2019 hannken

Add reference counting to alias states to prevent them disappearing
while still in use.


# 1.58 07-Mar-2019 hannken

Change "fli_alias" to point to the corresponding "fstrans_lwp_info".

Fix fstrans_clear_lwp_info() list traversal, remove already advanced
the list pointer.


# 1.57 01-Mar-2019 hannken

Move pointer to fstrans private data into "struct lwp".

Ride NetBSD 8.99.35


# 1.56 24-Feb-2019 hannken

Clear per-lwp entries whose mount is gone before the first return
from fstrans_done().

No longer leaks "struct mount" forever.


# 1.55 21-Feb-2019 hannken

Fix bad assertion: vfs_suspend(dead_rootmount) may happen and
must return EOPNOTSUPP.


# 1.54 20-Feb-2019 hannken

- Make the fstrans mount info part of the per-lwp state and replace
most accesses to the mount with fstrans mount info.

- Add "fmi_gone" to be true after unmount and add a counter of
outstanding mount infos so fstrans_clear_lwp_info() only runs
if there may be something to do.

- Move lookup of base mounts into per-lwp state.

- Keep a list of valid mounts for DIAGNOSTIC checks.


# 1.53 20-Feb-2019 hannken

Move fstrans_unmount() to vfs_rele(), just before it would free the mount.
Don't take a mount reference for fstrans as it gets notified about the release.

Defer the final free of the mount to fstrans_mount_dtor() when fstrans
has released all references to this mount. Prevents the mount's memory
to be reused as a new mount before fstrans released all references.

Address PR kern/53928 modules/t_builtin:disable test case randomly fails.


# 1.52 20-Feb-2019 hannken

Attach "mnt_transinfo" to "dead_rootmount" so every mount has a
valid "mnt_transinfo" and remove now unneeded flag IMNT_HAS_TRANS.

Run fstrans_start()/fstrans_done() on dead_rootmount if FSTRANS_DEAD_ENABLED.
Should become the default for DIAGNOSTIC in the future.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.51 05-Oct-2018 hannken

Bring back three state file system suspension:

NORMAL -> SUSPENDING -> SUSPENDED

and add operation fstrans_start_lazy() that only blocks while SUSPENDED.

Change vndthread() support operation handle_with_rdwr() to bracket
its file system operations by fstrans_start_lazy() and fstrans_done().

PR kern/53624 (dom0 freeze on domU exit)


# 1.50 05-Oct-2018 manu

Back out sftchg/fstcnt deadlock workaround

The change did prevent some system freeze, but caused spurious
unmount failures reporter by bouyer@.

hannken@ is working on the right fix, see kern/53624


Revision tags: pgoyette-compat-0930
# 1.49 27-Sep-2018 manu

Work around deadlock between fstchg and fstcnt

When suspending a filesystem in fstrans_setstate(), we wait on
fstcnt for threads to finish transactions. While we do this, any
thread trying to start a filesystem transaction will wait on fstchg
in fstrans_start(), a situation which can deadlock.

The wait for fstcnt in fstrans_setstate() can be interrupted by
a signal, but the wait for fstchg in fstrans_start() cannot. Once
most processes are stuck in fstchg, it is impossible to send a
signal to the thread that waits on fstcnt, because no process
respond anymore to user input.

We fix that by adding a timeout to the wait on fstcnt in
fstrans_setstate(). This means suspending a filesystem may fail,
but it was already the case when the sleep was interupted by
a signal, hence calling function must already handle a possible
failure.

Fixes kern/53624


Revision tags: pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.48 18-Jun-2017 hannken

branches: 1.48.4; 1.48.6;
Make the fast path of fstrans_get_lwp_info() "static inline".


# 1.47 18-Jun-2017 hannken

Clear fstrans entries whose mount is gone from the last fstrans_done() only.


# 1.46 04-Jun-2017 hannken

Operations fstrans_start() and fstrans_start_nowait() now always
use FSTRANS_SHARED as lock type so remove the lock type argument.

File system state FSTRANS_SUSPENDING is now unused so remove it.

Regen vnode_if files.

Ride 8.99.1 less than a hour ago.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.45 07-May-2017 hannken

branches: 1.45.2;
Move fstrans initialization to vfs_mountalloc().


# 1.44 07-May-2017 hannken

Handle the case where the mount is gone and its mnt_transinfo is NULL.


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1
# 1.43 17-Apr-2017 hannken

branches: 1.43.2;
Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.


# 1.42 17-Apr-2017 hannken

Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount. Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).


# 1.41 12-Apr-2017 hannken

Switch fstrans_dump() to _mountlist_next().


Revision tags: jdolecek-ncq-base
# 1.40 30-Mar-2017 hannken

Change _fstrans_start() to allocate per lwp info for layered file
systems to get a reference on the mount.

Set mnt_lower on successfull mount only.


Revision tags: pgoyette-localcount-20170320
# 1.39 06-Mar-2017 hannken

Always use the lowest mount for fstrans and suspend. This way we
enter/leave or suspend/resume the stack of layered file systems as a unit.


# 1.38 02-Mar-2017 hannken

Add an operation to test a mount for fstrans support and use it for
_fstrans_start(), fstrans_done(), fstrans_is_owner(), vfs_suspend()
and vfs_resume().

Test for fstrans support before ASSERT_SLEEPABLE().


# 1.37 23-Feb-2017 hannken

Test for fstrans support before trying to allocate per-thread info.

PR kern/51996 (kmem_alloc called from intr context in fstrans_get_lwp_info)


# 1.36 17-Feb-2017 hannken

Let syncer try fstrans_start() before running VFS_SYNC() to get rid
of the syncer lock/unlock from vfs_suspend().


# 1.35 17-Feb-2017 hannken

Protect attaching and detaching lwp_info to mount with a mutex.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.34 24-Aug-2015 pooka

branches: 1.34.2; 1.34.4;
to garnish, dust with _KERNEL_OPT


Revision tags: nick-nhusb-base-20150606
# 1.33 06-May-2015 hannken

Remove miscfs/syncfs and

- move the syncer into kern/vfs_subr.c.

- change the syncer to process the mountlist and VFS_SYNC as appropriate.

- use an API for mount points similiar to the API for vnodes:
- vfs_syncer_add_to_worklist(struct mount *mp) to add
- vfs_syncer_remove_from_worklist(struct mount *mp) to remove a mount.

No objections on tech-kern@


# 1.32 21-Apr-2015 pooka

Don't check if constant-sized KM_SLEEP allocations succeeded.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.31 05-Sep-2014 matt

branches: 1.31.2;
Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.30 15-Apr-2014 hannken

Fix a deadlock where one thread exits, enters fstrans_lwp_dtor()
and wants fstrans_lock. This thread holds the proc_lock.
Another thread holds fstrans_lock and runs pserialize_perform().
As the first thread holds the proc_lock, timeouts are blocked and
the second thread blocks forever in kpause().

Change fstrans_lwp_dtor() to invalidate, but not free its info
structs. No need to take fstrans_lock.

Change fstrans_get_lwp_info() to reuse invalidated info before
trying to allocate a new one.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.29 23-Nov-2013 christos

branches: 1.29.2;
change the mountlist CIRCLEQ into a TAILQ


# 1.28 25-Oct-2013 martin

Mark diagnostic-only variables


# 1.27 30-Sep-2013 hannken

Replace macro v_specmountpoint with two functions spec_node_getmountedfs()
and spec_node_setmountedfs() to manage the file system mounted on a device.
Assert the device is a block device.

Welcome to 6.99.24

Discussed on tech-kern@ some time ago.

Reviewed by: David Holland <dholland@netbsd.org>


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.26 21-Jan-2013 hannken

branches: 1.26.2;
Replace the rwlock based implementation with passive serialization
from pserialize(9) and mutex / condvar.

The fast paths (fstrans_start/fstrans_done on a file system not
suspended or suspending and fscow_run with no change pending) now
run without locks or other atomic operations. Suspension and cow
handler insertion and removal is done with mutex / condvars.

The API remains unchanged.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 1.25 12-May-2009 yamt

branches: 1.25.12; 1.25.22;
don't forget to skip marker processes.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.24 16-Nov-2008 pooka

branches: 1.24.4;
more <sys/buf.h> police


Revision tags: netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3
# 1.23 17-Sep-2008 hannken

branches: 1.23.2; 1.23.4; 1.23.6;
Replace the fss unmount hook with a vfs_hook.

fssvar.h: struct device * -> device_t.
fss.c: establish unmount hook on first attach, remove on last detach.
vfs_syscalls.c: remove the call of fss_umount_hook().
vfs_trans.c: destroy cow handlers on unmount as fstrans_unmount() will be
called before vfs_hooks.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.22 24-Jun-2008 ad

branches: 1.22.2;
Use pool_cache.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 16-May-2008 hannken

branches: 1.21.2;
Remove a bad assertion from last commit.
Non bufcache buffers may have BC_BUSY unset.


# 1.20 16-May-2008 hannken

Fscow_run() may recurse into itself.
Take care by adding a per-lwp recursion counter.


Revision tags: yamt-nfs-mp-base2
# 1.19 28-Apr-2008 martin

branches: 1.19.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.18 17-Mar-2008 yamt

branches: 1.18.2; 1.18.4;
- simplify ASSERT_SLEEPABLE.
- move it from proc.h to systm.h.
- add some more checks.
- make it a little more lkm friendly.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 1.17 02-Feb-2008 hannken

branches: 1.17.2; 1.17.6;
BO_COWDONE -> B_COWDONE: this flag is tested/modified from the thread owning
the buffer and therefore needs no protection by a mutex.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.16 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.15 02-Dec-2007 hannken

branches: 1.15.2; 1.15.6;
Fscow_run(): add a flag "bool data_valid" to note still valid data.
Buffers run through copy-on-write are marked B_COWDONE. This condition
is valid until the buffer has run through bwrite() and gets cleared from
biodone().

Welcome to 4.99.39.

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.14 08-Oct-2007 hannken

branches: 1.14.4;
fscow_run(): Check for NULL mount and don't run the cow handler in this case.


# 1.13 07-Oct-2007 hannken

Remove an include committed by accident.

From Chris Ross via current-users.


# 1.12 07-Oct-2007 hannken

Update the file system copy-on-write handler.

- Instead of hooking the handler on the specdev of a mounted file system
hook directly on the `struct mount'.

- Rename from `vn_cow_*' to `fscow_*' and move to `kern/vfs_trans.c'. Use
`mount_*specific' instead of clobbering `struct mount' or `struct specinfo'.

- Replace the hand-made reader/writer lock with a krwlock.

- Keep `vn_cow_*' functions and mark as obsolete.

- Welcome to NetBSD 4.99.32 - `struct specinfo' changed size.

Reviewed by: Jason Thorpe <thorpej@netbsd.org>


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.11 26-Jul-2007 pooka

branches: 1.11.4; 1.11.6; 1.11.8; 1.11.10;
Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.10 09-Jul-2007 ad

branches: 1.10.2;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8
# 1.9 17-May-2007 hannken

Fstrans_start() always returns zero, so change its type to void.


# 1.8 16-May-2007 hannken

Use rwlock for fmi_shared_lock and fmi_lazy_lock.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: thorpej-atomic-base
# 1.7 12-Mar-2007 ad

Use mutexes/condvars.


# 1.6 12-Mar-2007 ad

branches: 1.6.2;
Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.


Revision tags: ad-audiomp-base
# 1.5 16-Feb-2007 hannken

branches: 1.5.2; 1.5.4; 1.5.8;
Make fstrans(9) the default helper for file system suspension.
Replaces the now obsolete vn_start_write()/vn_finished_write().


# 1.4 15-Feb-2007 ad

Replace some uses of lockmgr() / simplelocks.


# 1.3 10-Feb-2007 hannken

newlock2: syncer_lock is now a mutex.


Revision tags: post-newlock2-merge newlock2-base newlock2-nbase
# 1.2 29-Jan-2007 hannken

branches: 1.2.2;
Change fstrans enum types to upper case.
No functional change.

From Antti Kantee <pooka@netbsd.org>


# 1.1 19-Jan-2007 hannken

New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

The new API is enabled on a kernel option NEWVNGATE. This option is
not enabled by default in any kernel config.

Presented and discussed on tech-kern with much input from
Bill Studenmund <wrstuden@netbsd.org> and YAMAMOTO Takashi <yamt@netbsd.org>.

Welcome to 4.99.9 (new vfs op vfs_suspendctl).


# 1.68 22-Aug-2022 hannken

Don't allocate lwp info for fstrans_held() and fstrans_is_owner().
If it doesn't exist we cannot hold a transaction or suspension.


# 1.67 11-Aug-2022 hannken

Finish previous, evaluate the lowest mount on first access
to "struct mount_info" and store it here so we no longer
derefence the "struct mount" from fstrans_alloc_lwp_info().

Reported-by: syzbot+5a79214d043395b550d8@syzkaller.appspotmail.com


# 1.66 08-Jul-2022 hannken

While one thread runs vgone() it is possible for another thread to grab
a "v_mount" that will be freed before it uses this mount for fstrans_start().

Add a hashtab to lookup our private mount data "fstrans_mount_info" and
use "mp" as an opaque key for lookup.

Reported-by: syzbot+54dc9ac0804a97b59bc6@syzkaller.appspotmail.com


# 1.65 08-Jul-2022 hannken

Handle IMNT_GONE on the file system we want suspended not its
lowest mount we really suspend.


# 1.64 28-Jun-2022 riastradh

fstrans(9): KASSERT(a && b) => KASSERT(a); KASSERT(b)

No functional change intended except better diagnostics in case of
crash.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base
# 1.63 17-May-2020 ad

Reorganise the locking and allocation of fstrans_lwp_info slightly, to
reduce contention. "please go ahead" hannken@.


# 1.62 13-May-2020 hannken

Add operation fstrans_held(struct mount *), true if the current thread
holds a fstrans lock.

Ride 9.99.61


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.61 17-Jun-2019 hannken

Add an owner field to fstrans mount info and use it to hold
the thread currently suspending this mount.

Remove now unneeded state FSTRANS_EXCL.

It is now possible to suspend a file system from a thread
already holding fstrans locks. Use with care ...


Revision tags: phil-wifi-20190609
# 1.60 13-May-2019 hannken

Walk down to the lowest mount for "fli_alias".

Address PR kern/54195 (null mounts: panic: ...).


Revision tags: isaki-audio2-base
# 1.59 15-Apr-2019 hannken

Add reference counting to alias states to prevent them disappearing
while still in use.


# 1.58 07-Mar-2019 hannken

Change "fli_alias" to point to the corresponding "fstrans_lwp_info".

Fix fstrans_clear_lwp_info() list traversal, remove already advanced
the list pointer.


# 1.57 01-Mar-2019 hannken

Move pointer to fstrans private data into "struct lwp".

Ride NetBSD 8.99.35


# 1.56 24-Feb-2019 hannken

Clear per-lwp entries whose mount is gone before the first return
from fstrans_done().

No longer leaks "struct mount" forever.


# 1.55 21-Feb-2019 hannken

Fix bad assertion: vfs_suspend(dead_rootmount) may happen and
must return EOPNOTSUPP.


# 1.54 20-Feb-2019 hannken

- Make the fstrans mount info part of the per-lwp state and replace
most accesses to the mount with fstrans mount info.

- Add "fmi_gone" to be true after unmount and add a counter of
outstanding mount infos so fstrans_clear_lwp_info() only runs
if there may be something to do.

- Move lookup of base mounts into per-lwp state.

- Keep a list of valid mounts for DIAGNOSTIC checks.


# 1.53 20-Feb-2019 hannken

Move fstrans_unmount() to vfs_rele(), just before it would free the mount.
Don't take a mount reference for fstrans as it gets notified about the release.

Defer the final free of the mount to fstrans_mount_dtor() when fstrans
has released all references to this mount. Prevents the mount's memory
to be reused as a new mount before fstrans released all references.

Address PR kern/53928 modules/t_builtin:disable test case randomly fails.


# 1.52 20-Feb-2019 hannken

Attach "mnt_transinfo" to "dead_rootmount" so every mount has a
valid "mnt_transinfo" and remove now unneeded flag IMNT_HAS_TRANS.

Run fstrans_start()/fstrans_done() on dead_rootmount if FSTRANS_DEAD_ENABLED.
Should become the default for DIAGNOSTIC in the future.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.51 05-Oct-2018 hannken

Bring back three state file system suspension:

NORMAL -> SUSPENDING -> SUSPENDED

and add operation fstrans_start_lazy() that only blocks while SUSPENDED.

Change vndthread() support operation handle_with_rdwr() to bracket
its file system operations by fstrans_start_lazy() and fstrans_done().

PR kern/53624 (dom0 freeze on domU exit)


# 1.50 05-Oct-2018 manu

Back out sftchg/fstcnt deadlock workaround

The change did prevent some system freeze, but caused spurious
unmount failures reporter by bouyer@.

hannken@ is working on the right fix, see kern/53624


Revision tags: pgoyette-compat-0930
# 1.49 27-Sep-2018 manu

Work around deadlock between fstchg and fstcnt

When suspending a filesystem in fstrans_setstate(), we wait on
fstcnt for threads to finish transactions. While we do this, any
thread trying to start a filesystem transaction will wait on fstchg
in fstrans_start(), a situation which can deadlock.

The wait for fstcnt in fstrans_setstate() can be interrupted by
a signal, but the wait for fstchg in fstrans_start() cannot. Once
most processes are stuck in fstchg, it is impossible to send a
signal to the thread that waits on fstcnt, because no process
respond anymore to user input.

We fix that by adding a timeout to the wait on fstcnt in
fstrans_setstate(). This means suspending a filesystem may fail,
but it was already the case when the sleep was interupted by
a signal, hence calling function must already handle a possible
failure.

Fixes kern/53624


Revision tags: pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.48 18-Jun-2017 hannken

branches: 1.48.4; 1.48.6;
Make the fast path of fstrans_get_lwp_info() "static inline".


# 1.47 18-Jun-2017 hannken

Clear fstrans entries whose mount is gone from the last fstrans_done() only.


# 1.46 04-Jun-2017 hannken

Operations fstrans_start() and fstrans_start_nowait() now always
use FSTRANS_SHARED as lock type so remove the lock type argument.

File system state FSTRANS_SUSPENDING is now unused so remove it.

Regen vnode_if files.

Ride 8.99.1 less than a hour ago.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.45 07-May-2017 hannken

branches: 1.45.2;
Move fstrans initialization to vfs_mountalloc().


# 1.44 07-May-2017 hannken

Handle the case where the mount is gone and its mnt_transinfo is NULL.


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1
# 1.43 17-Apr-2017 hannken

branches: 1.43.2;
Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.


# 1.42 17-Apr-2017 hannken

Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount. Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).


# 1.41 12-Apr-2017 hannken

Switch fstrans_dump() to _mountlist_next().


Revision tags: jdolecek-ncq-base
# 1.40 30-Mar-2017 hannken

Change _fstrans_start() to allocate per lwp info for layered file
systems to get a reference on the mount.

Set mnt_lower on successfull mount only.


Revision tags: pgoyette-localcount-20170320
# 1.39 06-Mar-2017 hannken

Always use the lowest mount for fstrans and suspend. This way we
enter/leave or suspend/resume the stack of layered file systems as a unit.


# 1.38 02-Mar-2017 hannken

Add an operation to test a mount for fstrans support and use it for
_fstrans_start(), fstrans_done(), fstrans_is_owner(), vfs_suspend()
and vfs_resume().

Test for fstrans support before ASSERT_SLEEPABLE().


# 1.37 23-Feb-2017 hannken

Test for fstrans support before trying to allocate per-thread info.

PR kern/51996 (kmem_alloc called from intr context in fstrans_get_lwp_info)


# 1.36 17-Feb-2017 hannken

Let syncer try fstrans_start() before running VFS_SYNC() to get rid
of the syncer lock/unlock from vfs_suspend().


# 1.35 17-Feb-2017 hannken

Protect attaching and detaching lwp_info to mount with a mutex.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.34 24-Aug-2015 pooka

branches: 1.34.2; 1.34.4;
to garnish, dust with _KERNEL_OPT


Revision tags: nick-nhusb-base-20150606
# 1.33 06-May-2015 hannken

Remove miscfs/syncfs and

- move the syncer into kern/vfs_subr.c.

- change the syncer to process the mountlist and VFS_SYNC as appropriate.

- use an API for mount points similiar to the API for vnodes:
- vfs_syncer_add_to_worklist(struct mount *mp) to add
- vfs_syncer_remove_from_worklist(struct mount *mp) to remove a mount.

No objections on tech-kern@


# 1.32 21-Apr-2015 pooka

Don't check if constant-sized KM_SLEEP allocations succeeded.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.31 05-Sep-2014 matt

branches: 1.31.2;
Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.30 15-Apr-2014 hannken

Fix a deadlock where one thread exits, enters fstrans_lwp_dtor()
and wants fstrans_lock. This thread holds the proc_lock.
Another thread holds fstrans_lock and runs pserialize_perform().
As the first thread holds the proc_lock, timeouts are blocked and
the second thread blocks forever in kpause().

Change fstrans_lwp_dtor() to invalidate, but not free its info
structs. No need to take fstrans_lock.

Change fstrans_get_lwp_info() to reuse invalidated info before
trying to allocate a new one.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.29 23-Nov-2013 christos

branches: 1.29.2;
change the mountlist CIRCLEQ into a TAILQ


# 1.28 25-Oct-2013 martin

Mark diagnostic-only variables


# 1.27 30-Sep-2013 hannken

Replace macro v_specmountpoint with two functions spec_node_getmountedfs()
and spec_node_setmountedfs() to manage the file system mounted on a device.
Assert the device is a block device.

Welcome to 6.99.24

Discussed on tech-kern@ some time ago.

Reviewed by: David Holland <dholland@netbsd.org>


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.26 21-Jan-2013 hannken

branches: 1.26.2;
Replace the rwlock based implementation with passive serialization
from pserialize(9) and mutex / condvar.

The fast paths (fstrans_start/fstrans_done on a file system not
suspended or suspending and fscow_run with no change pending) now
run without locks or other atomic operations. Suspension and cow
handler insertion and removal is done with mutex / condvars.

The API remains unchanged.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 1.25 12-May-2009 yamt

branches: 1.25.12; 1.25.22;
don't forget to skip marker processes.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.24 16-Nov-2008 pooka

branches: 1.24.4;
more <sys/buf.h> police


Revision tags: netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3
# 1.23 17-Sep-2008 hannken

branches: 1.23.2; 1.23.4; 1.23.6;
Replace the fss unmount hook with a vfs_hook.

fssvar.h: struct device * -> device_t.
fss.c: establish unmount hook on first attach, remove on last detach.
vfs_syscalls.c: remove the call of fss_umount_hook().
vfs_trans.c: destroy cow handlers on unmount as fstrans_unmount() will be
called before vfs_hooks.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.22 24-Jun-2008 ad

branches: 1.22.2;
Use pool_cache.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 16-May-2008 hannken

branches: 1.21.2;
Remove a bad assertion from last commit.
Non bufcache buffers may have BC_BUSY unset.


# 1.20 16-May-2008 hannken

Fscow_run() may recurse into itself.
Take care by adding a per-lwp recursion counter.


Revision tags: yamt-nfs-mp-base2
# 1.19 28-Apr-2008 martin

branches: 1.19.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.18 17-Mar-2008 yamt

branches: 1.18.2; 1.18.4;
- simplify ASSERT_SLEEPABLE.
- move it from proc.h to systm.h.
- add some more checks.
- make it a little more lkm friendly.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 1.17 02-Feb-2008 hannken

branches: 1.17.2; 1.17.6;
BO_COWDONE -> B_COWDONE: this flag is tested/modified from the thread owning
the buffer and therefore needs no protection by a mutex.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.16 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.15 02-Dec-2007 hannken

branches: 1.15.2; 1.15.6;
Fscow_run(): add a flag "bool data_valid" to note still valid data.
Buffers run through copy-on-write are marked B_COWDONE. This condition
is valid until the buffer has run through bwrite() and gets cleared from
biodone().

Welcome to 4.99.39.

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.14 08-Oct-2007 hannken

branches: 1.14.4;
fscow_run(): Check for NULL mount and don't run the cow handler in this case.


# 1.13 07-Oct-2007 hannken

Remove an include committed by accident.

From Chris Ross via current-users.


# 1.12 07-Oct-2007 hannken

Update the file system copy-on-write handler.

- Instead of hooking the handler on the specdev of a mounted file system
hook directly on the `struct mount'.

- Rename from `vn_cow_*' to `fscow_*' and move to `kern/vfs_trans.c'. Use
`mount_*specific' instead of clobbering `struct mount' or `struct specinfo'.

- Replace the hand-made reader/writer lock with a krwlock.

- Keep `vn_cow_*' functions and mark as obsolete.

- Welcome to NetBSD 4.99.32 - `struct specinfo' changed size.

Reviewed by: Jason Thorpe <thorpej@netbsd.org>


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.11 26-Jul-2007 pooka

branches: 1.11.4; 1.11.6; 1.11.8; 1.11.10;
Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.10 09-Jul-2007 ad

branches: 1.10.2;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8
# 1.9 17-May-2007 hannken

Fstrans_start() always returns zero, so change its type to void.


# 1.8 16-May-2007 hannken

Use rwlock for fmi_shared_lock and fmi_lazy_lock.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: thorpej-atomic-base
# 1.7 12-Mar-2007 ad

Use mutexes/condvars.


# 1.6 12-Mar-2007 ad

branches: 1.6.2;
Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.


Revision tags: ad-audiomp-base
# 1.5 16-Feb-2007 hannken

branches: 1.5.2; 1.5.4; 1.5.8;
Make fstrans(9) the default helper for file system suspension.
Replaces the now obsolete vn_start_write()/vn_finished_write().


# 1.4 15-Feb-2007 ad

Replace some uses of lockmgr() / simplelocks.


# 1.3 10-Feb-2007 hannken

newlock2: syncer_lock is now a mutex.


Revision tags: post-newlock2-merge newlock2-base newlock2-nbase
# 1.2 29-Jan-2007 hannken

branches: 1.2.2;
Change fstrans enum types to upper case.
No functional change.

From Antti Kantee <pooka@netbsd.org>


# 1.1 19-Jan-2007 hannken

New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

The new API is enabled on a kernel option NEWVNGATE. This option is
not enabled by default in any kernel config.

Presented and discussed on tech-kern with much input from
Bill Studenmund <wrstuden@netbsd.org> and YAMAMOTO Takashi <yamt@netbsd.org>.

Welcome to 4.99.9 (new vfs op vfs_suspendctl).


# 1.67 11-Aug-2022 hannken

Finish previous, evaluate the lowest mount on first access
to "struct mount_info" and store it here so we no longer
derefence the "struct mount" from fstrans_alloc_lwp_info().

Reported-by: syzbot+5a79214d043395b550d8@syzkaller.appspotmail.com


# 1.66 08-Jul-2022 hannken

While one thread runs vgone() it is possible for another thread to grab
a "v_mount" that will be freed before it uses this mount for fstrans_start().

Add a hashtab to lookup our private mount data "fstrans_mount_info" and
use "mp" as an opaque key for lookup.

Reported-by: syzbot+54dc9ac0804a97b59bc6@syzkaller.appspotmail.com


# 1.65 08-Jul-2022 hannken

Handle IMNT_GONE on the file system we want suspended not its
lowest mount we really suspend.


# 1.64 28-Jun-2022 riastradh

fstrans(9): KASSERT(a && b) => KASSERT(a); KASSERT(b)

No functional change intended except better diagnostics in case of
crash.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base
# 1.63 17-May-2020 ad

Reorganise the locking and allocation of fstrans_lwp_info slightly, to
reduce contention. "please go ahead" hannken@.


# 1.62 13-May-2020 hannken

Add operation fstrans_held(struct mount *), true if the current thread
holds a fstrans lock.

Ride 9.99.61


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.61 17-Jun-2019 hannken

Add an owner field to fstrans mount info and use it to hold
the thread currently suspending this mount.

Remove now unneeded state FSTRANS_EXCL.

It is now possible to suspend a file system from a thread
already holding fstrans locks. Use with care ...


Revision tags: phil-wifi-20190609
# 1.60 13-May-2019 hannken

Walk down to the lowest mount for "fli_alias".

Address PR kern/54195 (null mounts: panic: ...).


Revision tags: isaki-audio2-base
# 1.59 15-Apr-2019 hannken

Add reference counting to alias states to prevent them disappearing
while still in use.


# 1.58 07-Mar-2019 hannken

Change "fli_alias" to point to the corresponding "fstrans_lwp_info".

Fix fstrans_clear_lwp_info() list traversal, remove already advanced
the list pointer.


# 1.57 01-Mar-2019 hannken

Move pointer to fstrans private data into "struct lwp".

Ride NetBSD 8.99.35


# 1.56 24-Feb-2019 hannken

Clear per-lwp entries whose mount is gone before the first return
from fstrans_done().

No longer leaks "struct mount" forever.


# 1.55 21-Feb-2019 hannken

Fix bad assertion: vfs_suspend(dead_rootmount) may happen and
must return EOPNOTSUPP.


# 1.54 20-Feb-2019 hannken

- Make the fstrans mount info part of the per-lwp state and replace
most accesses to the mount with fstrans mount info.

- Add "fmi_gone" to be true after unmount and add a counter of
outstanding mount infos so fstrans_clear_lwp_info() only runs
if there may be something to do.

- Move lookup of base mounts into per-lwp state.

- Keep a list of valid mounts for DIAGNOSTIC checks.


# 1.53 20-Feb-2019 hannken

Move fstrans_unmount() to vfs_rele(), just before it would free the mount.
Don't take a mount reference for fstrans as it gets notified about the release.

Defer the final free of the mount to fstrans_mount_dtor() when fstrans
has released all references to this mount. Prevents the mount's memory
to be reused as a new mount before fstrans released all references.

Address PR kern/53928 modules/t_builtin:disable test case randomly fails.


# 1.52 20-Feb-2019 hannken

Attach "mnt_transinfo" to "dead_rootmount" so every mount has a
valid "mnt_transinfo" and remove now unneeded flag IMNT_HAS_TRANS.

Run fstrans_start()/fstrans_done() on dead_rootmount if FSTRANS_DEAD_ENABLED.
Should become the default for DIAGNOSTIC in the future.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.51 05-Oct-2018 hannken

Bring back three state file system suspension:

NORMAL -> SUSPENDING -> SUSPENDED

and add operation fstrans_start_lazy() that only blocks while SUSPENDED.

Change vndthread() support operation handle_with_rdwr() to bracket
its file system operations by fstrans_start_lazy() and fstrans_done().

PR kern/53624 (dom0 freeze on domU exit)


# 1.50 05-Oct-2018 manu

Back out sftchg/fstcnt deadlock workaround

The change did prevent some system freeze, but caused spurious
unmount failures reporter by bouyer@.

hannken@ is working on the right fix, see kern/53624


Revision tags: pgoyette-compat-0930
# 1.49 27-Sep-2018 manu

Work around deadlock between fstchg and fstcnt

When suspending a filesystem in fstrans_setstate(), we wait on
fstcnt for threads to finish transactions. While we do this, any
thread trying to start a filesystem transaction will wait on fstchg
in fstrans_start(), a situation which can deadlock.

The wait for fstcnt in fstrans_setstate() can be interrupted by
a signal, but the wait for fstchg in fstrans_start() cannot. Once
most processes are stuck in fstchg, it is impossible to send a
signal to the thread that waits on fstcnt, because no process
respond anymore to user input.

We fix that by adding a timeout to the wait on fstcnt in
fstrans_setstate(). This means suspending a filesystem may fail,
but it was already the case when the sleep was interupted by
a signal, hence calling function must already handle a possible
failure.

Fixes kern/53624


Revision tags: pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.48 18-Jun-2017 hannken

branches: 1.48.4; 1.48.6;
Make the fast path of fstrans_get_lwp_info() "static inline".


# 1.47 18-Jun-2017 hannken

Clear fstrans entries whose mount is gone from the last fstrans_done() only.


# 1.46 04-Jun-2017 hannken

Operations fstrans_start() and fstrans_start_nowait() now always
use FSTRANS_SHARED as lock type so remove the lock type argument.

File system state FSTRANS_SUSPENDING is now unused so remove it.

Regen vnode_if files.

Ride 8.99.1 less than a hour ago.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.45 07-May-2017 hannken

branches: 1.45.2;
Move fstrans initialization to vfs_mountalloc().


# 1.44 07-May-2017 hannken

Handle the case where the mount is gone and its mnt_transinfo is NULL.


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1
# 1.43 17-Apr-2017 hannken

branches: 1.43.2;
Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.


# 1.42 17-Apr-2017 hannken

Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount. Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).


# 1.41 12-Apr-2017 hannken

Switch fstrans_dump() to _mountlist_next().


Revision tags: jdolecek-ncq-base
# 1.40 30-Mar-2017 hannken

Change _fstrans_start() to allocate per lwp info for layered file
systems to get a reference on the mount.

Set mnt_lower on successfull mount only.


Revision tags: pgoyette-localcount-20170320
# 1.39 06-Mar-2017 hannken

Always use the lowest mount for fstrans and suspend. This way we
enter/leave or suspend/resume the stack of layered file systems as a unit.


# 1.38 02-Mar-2017 hannken

Add an operation to test a mount for fstrans support and use it for
_fstrans_start(), fstrans_done(), fstrans_is_owner(), vfs_suspend()
and vfs_resume().

Test for fstrans support before ASSERT_SLEEPABLE().


# 1.37 23-Feb-2017 hannken

Test for fstrans support before trying to allocate per-thread info.

PR kern/51996 (kmem_alloc called from intr context in fstrans_get_lwp_info)


# 1.36 17-Feb-2017 hannken

Let syncer try fstrans_start() before running VFS_SYNC() to get rid
of the syncer lock/unlock from vfs_suspend().


# 1.35 17-Feb-2017 hannken

Protect attaching and detaching lwp_info to mount with a mutex.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.34 24-Aug-2015 pooka

branches: 1.34.2; 1.34.4;
to garnish, dust with _KERNEL_OPT


Revision tags: nick-nhusb-base-20150606
# 1.33 06-May-2015 hannken

Remove miscfs/syncfs and

- move the syncer into kern/vfs_subr.c.

- change the syncer to process the mountlist and VFS_SYNC as appropriate.

- use an API for mount points similiar to the API for vnodes:
- vfs_syncer_add_to_worklist(struct mount *mp) to add
- vfs_syncer_remove_from_worklist(struct mount *mp) to remove a mount.

No objections on tech-kern@


# 1.32 21-Apr-2015 pooka

Don't check if constant-sized KM_SLEEP allocations succeeded.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.31 05-Sep-2014 matt

branches: 1.31.2;
Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.30 15-Apr-2014 hannken

Fix a deadlock where one thread exits, enters fstrans_lwp_dtor()
and wants fstrans_lock. This thread holds the proc_lock.
Another thread holds fstrans_lock and runs pserialize_perform().
As the first thread holds the proc_lock, timeouts are blocked and
the second thread blocks forever in kpause().

Change fstrans_lwp_dtor() to invalidate, but not free its info
structs. No need to take fstrans_lock.

Change fstrans_get_lwp_info() to reuse invalidated info before
trying to allocate a new one.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.29 23-Nov-2013 christos

branches: 1.29.2;
change the mountlist CIRCLEQ into a TAILQ


# 1.28 25-Oct-2013 martin

Mark diagnostic-only variables


# 1.27 30-Sep-2013 hannken

Replace macro v_specmountpoint with two functions spec_node_getmountedfs()
and spec_node_setmountedfs() to manage the file system mounted on a device.
Assert the device is a block device.

Welcome to 6.99.24

Discussed on tech-kern@ some time ago.

Reviewed by: David Holland <dholland@netbsd.org>


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.26 21-Jan-2013 hannken

branches: 1.26.2;
Replace the rwlock based implementation with passive serialization
from pserialize(9) and mutex / condvar.

The fast paths (fstrans_start/fstrans_done on a file system not
suspended or suspending and fscow_run with no change pending) now
run without locks or other atomic operations. Suspension and cow
handler insertion and removal is done with mutex / condvars.

The API remains unchanged.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 1.25 12-May-2009 yamt

branches: 1.25.12; 1.25.22;
don't forget to skip marker processes.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.24 16-Nov-2008 pooka

branches: 1.24.4;
more <sys/buf.h> police


Revision tags: netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3
# 1.23 17-Sep-2008 hannken

branches: 1.23.2; 1.23.4; 1.23.6;
Replace the fss unmount hook with a vfs_hook.

fssvar.h: struct device * -> device_t.
fss.c: establish unmount hook on first attach, remove on last detach.
vfs_syscalls.c: remove the call of fss_umount_hook().
vfs_trans.c: destroy cow handlers on unmount as fstrans_unmount() will be
called before vfs_hooks.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.22 24-Jun-2008 ad

branches: 1.22.2;
Use pool_cache.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 16-May-2008 hannken

branches: 1.21.2;
Remove a bad assertion from last commit.
Non bufcache buffers may have BC_BUSY unset.


# 1.20 16-May-2008 hannken

Fscow_run() may recurse into itself.
Take care by adding a per-lwp recursion counter.


Revision tags: yamt-nfs-mp-base2
# 1.19 28-Apr-2008 martin

branches: 1.19.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.18 17-Mar-2008 yamt

branches: 1.18.2; 1.18.4;
- simplify ASSERT_SLEEPABLE.
- move it from proc.h to systm.h.
- add some more checks.
- make it a little more lkm friendly.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 1.17 02-Feb-2008 hannken

branches: 1.17.2; 1.17.6;
BO_COWDONE -> B_COWDONE: this flag is tested/modified from the thread owning
the buffer and therefore needs no protection by a mutex.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.16 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.15 02-Dec-2007 hannken

branches: 1.15.2; 1.15.6;
Fscow_run(): add a flag "bool data_valid" to note still valid data.
Buffers run through copy-on-write are marked B_COWDONE. This condition
is valid until the buffer has run through bwrite() and gets cleared from
biodone().

Welcome to 4.99.39.

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.14 08-Oct-2007 hannken

branches: 1.14.4;
fscow_run(): Check for NULL mount and don't run the cow handler in this case.


# 1.13 07-Oct-2007 hannken

Remove an include committed by accident.

From Chris Ross via current-users.


# 1.12 07-Oct-2007 hannken

Update the file system copy-on-write handler.

- Instead of hooking the handler on the specdev of a mounted file system
hook directly on the `struct mount'.

- Rename from `vn_cow_*' to `fscow_*' and move to `kern/vfs_trans.c'. Use
`mount_*specific' instead of clobbering `struct mount' or `struct specinfo'.

- Replace the hand-made reader/writer lock with a krwlock.

- Keep `vn_cow_*' functions and mark as obsolete.

- Welcome to NetBSD 4.99.32 - `struct specinfo' changed size.

Reviewed by: Jason Thorpe <thorpej@netbsd.org>


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.11 26-Jul-2007 pooka

branches: 1.11.4; 1.11.6; 1.11.8; 1.11.10;
Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.10 09-Jul-2007 ad

branches: 1.10.2;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8
# 1.9 17-May-2007 hannken

Fstrans_start() always returns zero, so change its type to void.


# 1.8 16-May-2007 hannken

Use rwlock for fmi_shared_lock and fmi_lazy_lock.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: thorpej-atomic-base
# 1.7 12-Mar-2007 ad

Use mutexes/condvars.


# 1.6 12-Mar-2007 ad

branches: 1.6.2;
Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.


Revision tags: ad-audiomp-base
# 1.5 16-Feb-2007 hannken

branches: 1.5.2; 1.5.4; 1.5.8;
Make fstrans(9) the default helper for file system suspension.
Replaces the now obsolete vn_start_write()/vn_finished_write().


# 1.4 15-Feb-2007 ad

Replace some uses of lockmgr() / simplelocks.


# 1.3 10-Feb-2007 hannken

newlock2: syncer_lock is now a mutex.


Revision tags: post-newlock2-merge newlock2-base newlock2-nbase
# 1.2 29-Jan-2007 hannken

branches: 1.2.2;
Change fstrans enum types to upper case.
No functional change.

From Antti Kantee <pooka@netbsd.org>


# 1.1 19-Jan-2007 hannken

New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

The new API is enabled on a kernel option NEWVNGATE. This option is
not enabled by default in any kernel config.

Presented and discussed on tech-kern with much input from
Bill Studenmund <wrstuden@netbsd.org> and YAMAMOTO Takashi <yamt@netbsd.org>.

Welcome to 4.99.9 (new vfs op vfs_suspendctl).


# 1.66 08-Jul-2022 hannken

While one thread runs vgone() it is possible for another thread to grab
a "v_mount" that will be freed before it uses this mount for fstrans_start().

Add a hashtab to lookup our private mount data "fstrans_mount_info" and
use "mp" as an opaque key for lookup.

Reported-by: syzbot+54dc9ac0804a97b59bc6@syzkaller.appspotmail.com


# 1.65 08-Jul-2022 hannken

Handle IMNT_GONE on the file system we want suspended not its
lowest mount we really suspend.


# 1.64 28-Jun-2022 riastradh

fstrans(9): KASSERT(a && b) => KASSERT(a); KASSERT(b)

No functional change intended except better diagnostics in case of
crash.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base
# 1.63 17-May-2020 ad

Reorganise the locking and allocation of fstrans_lwp_info slightly, to
reduce contention. "please go ahead" hannken@.


# 1.62 13-May-2020 hannken

Add operation fstrans_held(struct mount *), true if the current thread
holds a fstrans lock.

Ride 9.99.61


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.61 17-Jun-2019 hannken

Add an owner field to fstrans mount info and use it to hold
the thread currently suspending this mount.

Remove now unneeded state FSTRANS_EXCL.

It is now possible to suspend a file system from a thread
already holding fstrans locks. Use with care ...


Revision tags: phil-wifi-20190609
# 1.60 13-May-2019 hannken

Walk down to the lowest mount for "fli_alias".

Address PR kern/54195 (null mounts: panic: ...).


Revision tags: isaki-audio2-base
# 1.59 15-Apr-2019 hannken

Add reference counting to alias states to prevent them disappearing
while still in use.


# 1.58 07-Mar-2019 hannken

Change "fli_alias" to point to the corresponding "fstrans_lwp_info".

Fix fstrans_clear_lwp_info() list traversal, remove already advanced
the list pointer.


# 1.57 01-Mar-2019 hannken

Move pointer to fstrans private data into "struct lwp".

Ride NetBSD 8.99.35


# 1.56 24-Feb-2019 hannken

Clear per-lwp entries whose mount is gone before the first return
from fstrans_done().

No longer leaks "struct mount" forever.


# 1.55 21-Feb-2019 hannken

Fix bad assertion: vfs_suspend(dead_rootmount) may happen and
must return EOPNOTSUPP.


# 1.54 20-Feb-2019 hannken

- Make the fstrans mount info part of the per-lwp state and replace
most accesses to the mount with fstrans mount info.

- Add "fmi_gone" to be true after unmount and add a counter of
outstanding mount infos so fstrans_clear_lwp_info() only runs
if there may be something to do.

- Move lookup of base mounts into per-lwp state.

- Keep a list of valid mounts for DIAGNOSTIC checks.


# 1.53 20-Feb-2019 hannken

Move fstrans_unmount() to vfs_rele(), just before it would free the mount.
Don't take a mount reference for fstrans as it gets notified about the release.

Defer the final free of the mount to fstrans_mount_dtor() when fstrans
has released all references to this mount. Prevents the mount's memory
to be reused as a new mount before fstrans released all references.

Address PR kern/53928 modules/t_builtin:disable test case randomly fails.


# 1.52 20-Feb-2019 hannken

Attach "mnt_transinfo" to "dead_rootmount" so every mount has a
valid "mnt_transinfo" and remove now unneeded flag IMNT_HAS_TRANS.

Run fstrans_start()/fstrans_done() on dead_rootmount if FSTRANS_DEAD_ENABLED.
Should become the default for DIAGNOSTIC in the future.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.51 05-Oct-2018 hannken

Bring back three state file system suspension:

NORMAL -> SUSPENDING -> SUSPENDED

and add operation fstrans_start_lazy() that only blocks while SUSPENDED.

Change vndthread() support operation handle_with_rdwr() to bracket
its file system operations by fstrans_start_lazy() and fstrans_done().

PR kern/53624 (dom0 freeze on domU exit)


# 1.50 05-Oct-2018 manu

Back out sftchg/fstcnt deadlock workaround

The change did prevent some system freeze, but caused spurious
unmount failures reporter by bouyer@.

hannken@ is working on the right fix, see kern/53624


Revision tags: pgoyette-compat-0930
# 1.49 27-Sep-2018 manu

Work around deadlock between fstchg and fstcnt

When suspending a filesystem in fstrans_setstate(), we wait on
fstcnt for threads to finish transactions. While we do this, any
thread trying to start a filesystem transaction will wait on fstchg
in fstrans_start(), a situation which can deadlock.

The wait for fstcnt in fstrans_setstate() can be interrupted by
a signal, but the wait for fstchg in fstrans_start() cannot. Once
most processes are stuck in fstchg, it is impossible to send a
signal to the thread that waits on fstcnt, because no process
respond anymore to user input.

We fix that by adding a timeout to the wait on fstcnt in
fstrans_setstate(). This means suspending a filesystem may fail,
but it was already the case when the sleep was interupted by
a signal, hence calling function must already handle a possible
failure.

Fixes kern/53624


Revision tags: pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.48 18-Jun-2017 hannken

branches: 1.48.4; 1.48.6;
Make the fast path of fstrans_get_lwp_info() "static inline".


# 1.47 18-Jun-2017 hannken

Clear fstrans entries whose mount is gone from the last fstrans_done() only.


# 1.46 04-Jun-2017 hannken

Operations fstrans_start() and fstrans_start_nowait() now always
use FSTRANS_SHARED as lock type so remove the lock type argument.

File system state FSTRANS_SUSPENDING is now unused so remove it.

Regen vnode_if files.

Ride 8.99.1 less than a hour ago.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.45 07-May-2017 hannken

branches: 1.45.2;
Move fstrans initialization to vfs_mountalloc().


# 1.44 07-May-2017 hannken

Handle the case where the mount is gone and its mnt_transinfo is NULL.


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1
# 1.43 17-Apr-2017 hannken

branches: 1.43.2;
Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.


# 1.42 17-Apr-2017 hannken

Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount. Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).


# 1.41 12-Apr-2017 hannken

Switch fstrans_dump() to _mountlist_next().


Revision tags: jdolecek-ncq-base
# 1.40 30-Mar-2017 hannken

Change _fstrans_start() to allocate per lwp info for layered file
systems to get a reference on the mount.

Set mnt_lower on successfull mount only.


Revision tags: pgoyette-localcount-20170320
# 1.39 06-Mar-2017 hannken

Always use the lowest mount for fstrans and suspend. This way we
enter/leave or suspend/resume the stack of layered file systems as a unit.


# 1.38 02-Mar-2017 hannken

Add an operation to test a mount for fstrans support and use it for
_fstrans_start(), fstrans_done(), fstrans_is_owner(), vfs_suspend()
and vfs_resume().

Test for fstrans support before ASSERT_SLEEPABLE().


# 1.37 23-Feb-2017 hannken

Test for fstrans support before trying to allocate per-thread info.

PR kern/51996 (kmem_alloc called from intr context in fstrans_get_lwp_info)


# 1.36 17-Feb-2017 hannken

Let syncer try fstrans_start() before running VFS_SYNC() to get rid
of the syncer lock/unlock from vfs_suspend().


# 1.35 17-Feb-2017 hannken

Protect attaching and detaching lwp_info to mount with a mutex.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.34 24-Aug-2015 pooka

branches: 1.34.2; 1.34.4;
to garnish, dust with _KERNEL_OPT


Revision tags: nick-nhusb-base-20150606
# 1.33 06-May-2015 hannken

Remove miscfs/syncfs and

- move the syncer into kern/vfs_subr.c.

- change the syncer to process the mountlist and VFS_SYNC as appropriate.

- use an API for mount points similiar to the API for vnodes:
- vfs_syncer_add_to_worklist(struct mount *mp) to add
- vfs_syncer_remove_from_worklist(struct mount *mp) to remove a mount.

No objections on tech-kern@


# 1.32 21-Apr-2015 pooka

Don't check if constant-sized KM_SLEEP allocations succeeded.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.31 05-Sep-2014 matt

branches: 1.31.2;
Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.30 15-Apr-2014 hannken

Fix a deadlock where one thread exits, enters fstrans_lwp_dtor()
and wants fstrans_lock. This thread holds the proc_lock.
Another thread holds fstrans_lock and runs pserialize_perform().
As the first thread holds the proc_lock, timeouts are blocked and
the second thread blocks forever in kpause().

Change fstrans_lwp_dtor() to invalidate, but not free its info
structs. No need to take fstrans_lock.

Change fstrans_get_lwp_info() to reuse invalidated info before
trying to allocate a new one.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.29 23-Nov-2013 christos

branches: 1.29.2;
change the mountlist CIRCLEQ into a TAILQ


# 1.28 25-Oct-2013 martin

Mark diagnostic-only variables


# 1.27 30-Sep-2013 hannken

Replace macro v_specmountpoint with two functions spec_node_getmountedfs()
and spec_node_setmountedfs() to manage the file system mounted on a device.
Assert the device is a block device.

Welcome to 6.99.24

Discussed on tech-kern@ some time ago.

Reviewed by: David Holland <dholland@netbsd.org>


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.26 21-Jan-2013 hannken

branches: 1.26.2;
Replace the rwlock based implementation with passive serialization
from pserialize(9) and mutex / condvar.

The fast paths (fstrans_start/fstrans_done on a file system not
suspended or suspending and fscow_run with no change pending) now
run without locks or other atomic operations. Suspension and cow
handler insertion and removal is done with mutex / condvars.

The API remains unchanged.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 1.25 12-May-2009 yamt

branches: 1.25.12; 1.25.22;
don't forget to skip marker processes.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.24 16-Nov-2008 pooka

branches: 1.24.4;
more <sys/buf.h> police


Revision tags: netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3
# 1.23 17-Sep-2008 hannken

branches: 1.23.2; 1.23.4; 1.23.6;
Replace the fss unmount hook with a vfs_hook.

fssvar.h: struct device * -> device_t.
fss.c: establish unmount hook on first attach, remove on last detach.
vfs_syscalls.c: remove the call of fss_umount_hook().
vfs_trans.c: destroy cow handlers on unmount as fstrans_unmount() will be
called before vfs_hooks.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.22 24-Jun-2008 ad

branches: 1.22.2;
Use pool_cache.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 16-May-2008 hannken

branches: 1.21.2;
Remove a bad assertion from last commit.
Non bufcache buffers may have BC_BUSY unset.


# 1.20 16-May-2008 hannken

Fscow_run() may recurse into itself.
Take care by adding a per-lwp recursion counter.


Revision tags: yamt-nfs-mp-base2
# 1.19 28-Apr-2008 martin

branches: 1.19.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.18 17-Mar-2008 yamt

branches: 1.18.2; 1.18.4;
- simplify ASSERT_SLEEPABLE.
- move it from proc.h to systm.h.
- add some more checks.
- make it a little more lkm friendly.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 1.17 02-Feb-2008 hannken

branches: 1.17.2; 1.17.6;
BO_COWDONE -> B_COWDONE: this flag is tested/modified from the thread owning
the buffer and therefore needs no protection by a mutex.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.16 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.15 02-Dec-2007 hannken

branches: 1.15.2; 1.15.6;
Fscow_run(): add a flag "bool data_valid" to note still valid data.
Buffers run through copy-on-write are marked B_COWDONE. This condition
is valid until the buffer has run through bwrite() and gets cleared from
biodone().

Welcome to 4.99.39.

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.14 08-Oct-2007 hannken

branches: 1.14.4;
fscow_run(): Check for NULL mount and don't run the cow handler in this case.


# 1.13 07-Oct-2007 hannken

Remove an include committed by accident.

From Chris Ross via current-users.


# 1.12 07-Oct-2007 hannken

Update the file system copy-on-write handler.

- Instead of hooking the handler on the specdev of a mounted file system
hook directly on the `struct mount'.

- Rename from `vn_cow_*' to `fscow_*' and move to `kern/vfs_trans.c'. Use
`mount_*specific' instead of clobbering `struct mount' or `struct specinfo'.

- Replace the hand-made reader/writer lock with a krwlock.

- Keep `vn_cow_*' functions and mark as obsolete.

- Welcome to NetBSD 4.99.32 - `struct specinfo' changed size.

Reviewed by: Jason Thorpe <thorpej@netbsd.org>


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.11 26-Jul-2007 pooka

branches: 1.11.4; 1.11.6; 1.11.8; 1.11.10;
Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.10 09-Jul-2007 ad

branches: 1.10.2;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8
# 1.9 17-May-2007 hannken

Fstrans_start() always returns zero, so change its type to void.


# 1.8 16-May-2007 hannken

Use rwlock for fmi_shared_lock and fmi_lazy_lock.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: thorpej-atomic-base
# 1.7 12-Mar-2007 ad

Use mutexes/condvars.


# 1.6 12-Mar-2007 ad

branches: 1.6.2;
Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.


Revision tags: ad-audiomp-base
# 1.5 16-Feb-2007 hannken

branches: 1.5.2; 1.5.4; 1.5.8;
Make fstrans(9) the default helper for file system suspension.
Replaces the now obsolete vn_start_write()/vn_finished_write().


# 1.4 15-Feb-2007 ad

Replace some uses of lockmgr() / simplelocks.


# 1.3 10-Feb-2007 hannken

newlock2: syncer_lock is now a mutex.


Revision tags: post-newlock2-merge newlock2-base newlock2-nbase
# 1.2 29-Jan-2007 hannken

branches: 1.2.2;
Change fstrans enum types to upper case.
No functional change.

From Antti Kantee <pooka@netbsd.org>


# 1.1 19-Jan-2007 hannken

New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

The new API is enabled on a kernel option NEWVNGATE. This option is
not enabled by default in any kernel config.

Presented and discussed on tech-kern with much input from
Bill Studenmund <wrstuden@netbsd.org> and YAMAMOTO Takashi <yamt@netbsd.org>.

Welcome to 4.99.9 (new vfs op vfs_suspendctl).


# 1.64 28-Jun-2022 riastradh

fstrans(9): KASSERT(a && b) => KASSERT(a); KASSERT(b)

No functional change intended except better diagnostics in case of
crash.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base
# 1.63 17-May-2020 ad

Reorganise the locking and allocation of fstrans_lwp_info slightly, to
reduce contention. "please go ahead" hannken@.


# 1.62 13-May-2020 hannken

Add operation fstrans_held(struct mount *), true if the current thread
holds a fstrans lock.

Ride 9.99.61


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.61 17-Jun-2019 hannken

Add an owner field to fstrans mount info and use it to hold
the thread currently suspending this mount.

Remove now unneeded state FSTRANS_EXCL.

It is now possible to suspend a file system from a thread
already holding fstrans locks. Use with care ...


Revision tags: phil-wifi-20190609
# 1.60 13-May-2019 hannken

Walk down to the lowest mount for "fli_alias".

Address PR kern/54195 (null mounts: panic: ...).


Revision tags: isaki-audio2-base
# 1.59 15-Apr-2019 hannken

Add reference counting to alias states to prevent them disappearing
while still in use.


# 1.58 07-Mar-2019 hannken

Change "fli_alias" to point to the corresponding "fstrans_lwp_info".

Fix fstrans_clear_lwp_info() list traversal, remove already advanced
the list pointer.


# 1.57 01-Mar-2019 hannken

Move pointer to fstrans private data into "struct lwp".

Ride NetBSD 8.99.35


# 1.56 24-Feb-2019 hannken

Clear per-lwp entries whose mount is gone before the first return
from fstrans_done().

No longer leaks "struct mount" forever.


# 1.55 21-Feb-2019 hannken

Fix bad assertion: vfs_suspend(dead_rootmount) may happen and
must return EOPNOTSUPP.


# 1.54 20-Feb-2019 hannken

- Make the fstrans mount info part of the per-lwp state and replace
most accesses to the mount with fstrans mount info.

- Add "fmi_gone" to be true after unmount and add a counter of
outstanding mount infos so fstrans_clear_lwp_info() only runs
if there may be something to do.

- Move lookup of base mounts into per-lwp state.

- Keep a list of valid mounts for DIAGNOSTIC checks.


# 1.53 20-Feb-2019 hannken

Move fstrans_unmount() to vfs_rele(), just before it would free the mount.
Don't take a mount reference for fstrans as it gets notified about the release.

Defer the final free of the mount to fstrans_mount_dtor() when fstrans
has released all references to this mount. Prevents the mount's memory
to be reused as a new mount before fstrans released all references.

Address PR kern/53928 modules/t_builtin:disable test case randomly fails.


# 1.52 20-Feb-2019 hannken

Attach "mnt_transinfo" to "dead_rootmount" so every mount has a
valid "mnt_transinfo" and remove now unneeded flag IMNT_HAS_TRANS.

Run fstrans_start()/fstrans_done() on dead_rootmount if FSTRANS_DEAD_ENABLED.
Should become the default for DIAGNOSTIC in the future.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.51 05-Oct-2018 hannken

Bring back three state file system suspension:

NORMAL -> SUSPENDING -> SUSPENDED

and add operation fstrans_start_lazy() that only blocks while SUSPENDED.

Change vndthread() support operation handle_with_rdwr() to bracket
its file system operations by fstrans_start_lazy() and fstrans_done().

PR kern/53624 (dom0 freeze on domU exit)


# 1.50 05-Oct-2018 manu

Back out sftchg/fstcnt deadlock workaround

The change did prevent some system freeze, but caused spurious
unmount failures reporter by bouyer@.

hannken@ is working on the right fix, see kern/53624


Revision tags: pgoyette-compat-0930
# 1.49 27-Sep-2018 manu

Work around deadlock between fstchg and fstcnt

When suspending a filesystem in fstrans_setstate(), we wait on
fstcnt for threads to finish transactions. While we do this, any
thread trying to start a filesystem transaction will wait on fstchg
in fstrans_start(), a situation which can deadlock.

The wait for fstcnt in fstrans_setstate() can be interrupted by
a signal, but the wait for fstchg in fstrans_start() cannot. Once
most processes are stuck in fstchg, it is impossible to send a
signal to the thread that waits on fstcnt, because no process
respond anymore to user input.

We fix that by adding a timeout to the wait on fstcnt in
fstrans_setstate(). This means suspending a filesystem may fail,
but it was already the case when the sleep was interupted by
a signal, hence calling function must already handle a possible
failure.

Fixes kern/53624


Revision tags: pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.48 18-Jun-2017 hannken

branches: 1.48.4; 1.48.6;
Make the fast path of fstrans_get_lwp_info() "static inline".


# 1.47 18-Jun-2017 hannken

Clear fstrans entries whose mount is gone from the last fstrans_done() only.


# 1.46 04-Jun-2017 hannken

Operations fstrans_start() and fstrans_start_nowait() now always
use FSTRANS_SHARED as lock type so remove the lock type argument.

File system state FSTRANS_SUSPENDING is now unused so remove it.

Regen vnode_if files.

Ride 8.99.1 less than a hour ago.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.45 07-May-2017 hannken

branches: 1.45.2;
Move fstrans initialization to vfs_mountalloc().


# 1.44 07-May-2017 hannken

Handle the case where the mount is gone and its mnt_transinfo is NULL.


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1
# 1.43 17-Apr-2017 hannken

branches: 1.43.2;
Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.


# 1.42 17-Apr-2017 hannken

Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount. Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).


# 1.41 12-Apr-2017 hannken

Switch fstrans_dump() to _mountlist_next().


Revision tags: jdolecek-ncq-base
# 1.40 30-Mar-2017 hannken

Change _fstrans_start() to allocate per lwp info for layered file
systems to get a reference on the mount.

Set mnt_lower on successfull mount only.


Revision tags: pgoyette-localcount-20170320
# 1.39 06-Mar-2017 hannken

Always use the lowest mount for fstrans and suspend. This way we
enter/leave or suspend/resume the stack of layered file systems as a unit.


# 1.38 02-Mar-2017 hannken

Add an operation to test a mount for fstrans support and use it for
_fstrans_start(), fstrans_done(), fstrans_is_owner(), vfs_suspend()
and vfs_resume().

Test for fstrans support before ASSERT_SLEEPABLE().


# 1.37 23-Feb-2017 hannken

Test for fstrans support before trying to allocate per-thread info.

PR kern/51996 (kmem_alloc called from intr context in fstrans_get_lwp_info)


# 1.36 17-Feb-2017 hannken

Let syncer try fstrans_start() before running VFS_SYNC() to get rid
of the syncer lock/unlock from vfs_suspend().


# 1.35 17-Feb-2017 hannken

Protect attaching and detaching lwp_info to mount with a mutex.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.34 24-Aug-2015 pooka

branches: 1.34.2; 1.34.4;
to garnish, dust with _KERNEL_OPT


Revision tags: nick-nhusb-base-20150606
# 1.33 06-May-2015 hannken

Remove miscfs/syncfs and

- move the syncer into kern/vfs_subr.c.

- change the syncer to process the mountlist and VFS_SYNC as appropriate.

- use an API for mount points similiar to the API for vnodes:
- vfs_syncer_add_to_worklist(struct mount *mp) to add
- vfs_syncer_remove_from_worklist(struct mount *mp) to remove a mount.

No objections on tech-kern@


# 1.32 21-Apr-2015 pooka

Don't check if constant-sized KM_SLEEP allocations succeeded.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.31 05-Sep-2014 matt

branches: 1.31.2;
Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.30 15-Apr-2014 hannken

Fix a deadlock where one thread exits, enters fstrans_lwp_dtor()
and wants fstrans_lock. This thread holds the proc_lock.
Another thread holds fstrans_lock and runs pserialize_perform().
As the first thread holds the proc_lock, timeouts are blocked and
the second thread blocks forever in kpause().

Change fstrans_lwp_dtor() to invalidate, but not free its info
structs. No need to take fstrans_lock.

Change fstrans_get_lwp_info() to reuse invalidated info before
trying to allocate a new one.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.29 23-Nov-2013 christos

branches: 1.29.2;
change the mountlist CIRCLEQ into a TAILQ


# 1.28 25-Oct-2013 martin

Mark diagnostic-only variables


# 1.27 30-Sep-2013 hannken

Replace macro v_specmountpoint with two functions spec_node_getmountedfs()
and spec_node_setmountedfs() to manage the file system mounted on a device.
Assert the device is a block device.

Welcome to 6.99.24

Discussed on tech-kern@ some time ago.

Reviewed by: David Holland <dholland@netbsd.org>


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.26 21-Jan-2013 hannken

branches: 1.26.2;
Replace the rwlock based implementation with passive serialization
from pserialize(9) and mutex / condvar.

The fast paths (fstrans_start/fstrans_done on a file system not
suspended or suspending and fscow_run with no change pending) now
run without locks or other atomic operations. Suspension and cow
handler insertion and removal is done with mutex / condvars.

The API remains unchanged.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 1.25 12-May-2009 yamt

branches: 1.25.12; 1.25.22;
don't forget to skip marker processes.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.24 16-Nov-2008 pooka

branches: 1.24.4;
more <sys/buf.h> police


Revision tags: netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3
# 1.23 17-Sep-2008 hannken

branches: 1.23.2; 1.23.4; 1.23.6;
Replace the fss unmount hook with a vfs_hook.

fssvar.h: struct device * -> device_t.
fss.c: establish unmount hook on first attach, remove on last detach.
vfs_syscalls.c: remove the call of fss_umount_hook().
vfs_trans.c: destroy cow handlers on unmount as fstrans_unmount() will be
called before vfs_hooks.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.22 24-Jun-2008 ad

branches: 1.22.2;
Use pool_cache.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 16-May-2008 hannken

branches: 1.21.2;
Remove a bad assertion from last commit.
Non bufcache buffers may have BC_BUSY unset.


# 1.20 16-May-2008 hannken

Fscow_run() may recurse into itself.
Take care by adding a per-lwp recursion counter.


Revision tags: yamt-nfs-mp-base2
# 1.19 28-Apr-2008 martin

branches: 1.19.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.18 17-Mar-2008 yamt

branches: 1.18.2; 1.18.4;
- simplify ASSERT_SLEEPABLE.
- move it from proc.h to systm.h.
- add some more checks.
- make it a little more lkm friendly.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 1.17 02-Feb-2008 hannken

branches: 1.17.2; 1.17.6;
BO_COWDONE -> B_COWDONE: this flag is tested/modified from the thread owning
the buffer and therefore needs no protection by a mutex.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.16 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.15 02-Dec-2007 hannken

branches: 1.15.2; 1.15.6;
Fscow_run(): add a flag "bool data_valid" to note still valid data.
Buffers run through copy-on-write are marked B_COWDONE. This condition
is valid until the buffer has run through bwrite() and gets cleared from
biodone().

Welcome to 4.99.39.

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.14 08-Oct-2007 hannken

branches: 1.14.4;
fscow_run(): Check for NULL mount and don't run the cow handler in this case.


# 1.13 07-Oct-2007 hannken

Remove an include committed by accident.

From Chris Ross via current-users.


# 1.12 07-Oct-2007 hannken

Update the file system copy-on-write handler.

- Instead of hooking the handler on the specdev of a mounted file system
hook directly on the `struct mount'.

- Rename from `vn_cow_*' to `fscow_*' and move to `kern/vfs_trans.c'. Use
`mount_*specific' instead of clobbering `struct mount' or `struct specinfo'.

- Replace the hand-made reader/writer lock with a krwlock.

- Keep `vn_cow_*' functions and mark as obsolete.

- Welcome to NetBSD 4.99.32 - `struct specinfo' changed size.

Reviewed by: Jason Thorpe <thorpej@netbsd.org>


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.11 26-Jul-2007 pooka

branches: 1.11.4; 1.11.6; 1.11.8; 1.11.10;
Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.10 09-Jul-2007 ad

branches: 1.10.2;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8
# 1.9 17-May-2007 hannken

Fstrans_start() always returns zero, so change its type to void.


# 1.8 16-May-2007 hannken

Use rwlock for fmi_shared_lock and fmi_lazy_lock.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: thorpej-atomic-base
# 1.7 12-Mar-2007 ad

Use mutexes/condvars.


# 1.6 12-Mar-2007 ad

branches: 1.6.2;
Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.


Revision tags: ad-audiomp-base
# 1.5 16-Feb-2007 hannken

branches: 1.5.2; 1.5.4; 1.5.8;
Make fstrans(9) the default helper for file system suspension.
Replaces the now obsolete vn_start_write()/vn_finished_write().


# 1.4 15-Feb-2007 ad

Replace some uses of lockmgr() / simplelocks.


# 1.3 10-Feb-2007 hannken

newlock2: syncer_lock is now a mutex.


Revision tags: post-newlock2-merge newlock2-base newlock2-nbase
# 1.2 29-Jan-2007 hannken

branches: 1.2.2;
Change fstrans enum types to upper case.
No functional change.

From Antti Kantee <pooka@netbsd.org>


# 1.1 19-Jan-2007 hannken

New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

The new API is enabled on a kernel option NEWVNGATE. This option is
not enabled by default in any kernel config.

Presented and discussed on tech-kern with much input from
Bill Studenmund <wrstuden@netbsd.org> and YAMAMOTO Takashi <yamt@netbsd.org>.

Welcome to 4.99.9 (new vfs op vfs_suspendctl).


# 1.63 17-May-2020 ad

Reorganise the locking and allocation of fstrans_lwp_info slightly, to
reduce contention. "please go ahead" hannken@.


# 1.62 13-May-2020 hannken

Add operation fstrans_held(struct mount *), true if the current thread
holds a fstrans lock.

Ride 9.99.61


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.61 17-Jun-2019 hannken

Add an owner field to fstrans mount info and use it to hold
the thread currently suspending this mount.

Remove now unneeded state FSTRANS_EXCL.

It is now possible to suspend a file system from a thread
already holding fstrans locks. Use with care ...


Revision tags: phil-wifi-20190609
# 1.60 13-May-2019 hannken

Walk down to the lowest mount for "fli_alias".

Address PR kern/54195 (null mounts: panic: ...).


Revision tags: isaki-audio2-base
# 1.59 15-Apr-2019 hannken

Add reference counting to alias states to prevent them disappearing
while still in use.


# 1.58 07-Mar-2019 hannken

Change "fli_alias" to point to the corresponding "fstrans_lwp_info".

Fix fstrans_clear_lwp_info() list traversal, remove already advanced
the list pointer.


# 1.57 01-Mar-2019 hannken

Move pointer to fstrans private data into "struct lwp".

Ride NetBSD 8.99.35


# 1.56 24-Feb-2019 hannken

Clear per-lwp entries whose mount is gone before the first return
from fstrans_done().

No longer leaks "struct mount" forever.


# 1.55 21-Feb-2019 hannken

Fix bad assertion: vfs_suspend(dead_rootmount) may happen and
must return EOPNOTSUPP.


# 1.54 20-Feb-2019 hannken

- Make the fstrans mount info part of the per-lwp state and replace
most accesses to the mount with fstrans mount info.

- Add "fmi_gone" to be true after unmount and add a counter of
outstanding mount infos so fstrans_clear_lwp_info() only runs
if there may be something to do.

- Move lookup of base mounts into per-lwp state.

- Keep a list of valid mounts for DIAGNOSTIC checks.


# 1.53 20-Feb-2019 hannken

Move fstrans_unmount() to vfs_rele(), just before it would free the mount.
Don't take a mount reference for fstrans as it gets notified about the release.

Defer the final free of the mount to fstrans_mount_dtor() when fstrans
has released all references to this mount. Prevents the mount's memory
to be reused as a new mount before fstrans released all references.

Address PR kern/53928 modules/t_builtin:disable test case randomly fails.


# 1.52 20-Feb-2019 hannken

Attach "mnt_transinfo" to "dead_rootmount" so every mount has a
valid "mnt_transinfo" and remove now unneeded flag IMNT_HAS_TRANS.

Run fstrans_start()/fstrans_done() on dead_rootmount if FSTRANS_DEAD_ENABLED.
Should become the default for DIAGNOSTIC in the future.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.51 05-Oct-2018 hannken

Bring back three state file system suspension:

NORMAL -> SUSPENDING -> SUSPENDED

and add operation fstrans_start_lazy() that only blocks while SUSPENDED.

Change vndthread() support operation handle_with_rdwr() to bracket
its file system operations by fstrans_start_lazy() and fstrans_done().

PR kern/53624 (dom0 freeze on domU exit)


# 1.50 05-Oct-2018 manu

Back out sftchg/fstcnt deadlock workaround

The change did prevent some system freeze, but caused spurious
unmount failures reporter by bouyer@.

hannken@ is working on the right fix, see kern/53624


Revision tags: pgoyette-compat-0930
# 1.49 27-Sep-2018 manu

Work around deadlock between fstchg and fstcnt

When suspending a filesystem in fstrans_setstate(), we wait on
fstcnt for threads to finish transactions. While we do this, any
thread trying to start a filesystem transaction will wait on fstchg
in fstrans_start(), a situation which can deadlock.

The wait for fstcnt in fstrans_setstate() can be interrupted by
a signal, but the wait for fstchg in fstrans_start() cannot. Once
most processes are stuck in fstchg, it is impossible to send a
signal to the thread that waits on fstcnt, because no process
respond anymore to user input.

We fix that by adding a timeout to the wait on fstcnt in
fstrans_setstate(). This means suspending a filesystem may fail,
but it was already the case when the sleep was interupted by
a signal, hence calling function must already handle a possible
failure.

Fixes kern/53624


Revision tags: pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.48 18-Jun-2017 hannken

branches: 1.48.4; 1.48.6;
Make the fast path of fstrans_get_lwp_info() "static inline".


# 1.47 18-Jun-2017 hannken

Clear fstrans entries whose mount is gone from the last fstrans_done() only.


# 1.46 04-Jun-2017 hannken

Operations fstrans_start() and fstrans_start_nowait() now always
use FSTRANS_SHARED as lock type so remove the lock type argument.

File system state FSTRANS_SUSPENDING is now unused so remove it.

Regen vnode_if files.

Ride 8.99.1 less than a hour ago.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.45 07-May-2017 hannken

branches: 1.45.2;
Move fstrans initialization to vfs_mountalloc().


# 1.44 07-May-2017 hannken

Handle the case where the mount is gone and its mnt_transinfo is NULL.


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1
# 1.43 17-Apr-2017 hannken

branches: 1.43.2;
Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.


# 1.42 17-Apr-2017 hannken

Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount. Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).


# 1.41 12-Apr-2017 hannken

Switch fstrans_dump() to _mountlist_next().


Revision tags: jdolecek-ncq-base
# 1.40 30-Mar-2017 hannken

Change _fstrans_start() to allocate per lwp info for layered file
systems to get a reference on the mount.

Set mnt_lower on successfull mount only.


Revision tags: pgoyette-localcount-20170320
# 1.39 06-Mar-2017 hannken

Always use the lowest mount for fstrans and suspend. This way we
enter/leave or suspend/resume the stack of layered file systems as a unit.


# 1.38 02-Mar-2017 hannken

Add an operation to test a mount for fstrans support and use it for
_fstrans_start(), fstrans_done(), fstrans_is_owner(), vfs_suspend()
and vfs_resume().

Test for fstrans support before ASSERT_SLEEPABLE().


# 1.37 23-Feb-2017 hannken

Test for fstrans support before trying to allocate per-thread info.

PR kern/51996 (kmem_alloc called from intr context in fstrans_get_lwp_info)


# 1.36 17-Feb-2017 hannken

Let syncer try fstrans_start() before running VFS_SYNC() to get rid
of the syncer lock/unlock from vfs_suspend().


# 1.35 17-Feb-2017 hannken

Protect attaching and detaching lwp_info to mount with a mutex.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.34 24-Aug-2015 pooka

branches: 1.34.2; 1.34.4;
to garnish, dust with _KERNEL_OPT


Revision tags: nick-nhusb-base-20150606
# 1.33 06-May-2015 hannken

Remove miscfs/syncfs and

- move the syncer into kern/vfs_subr.c.

- change the syncer to process the mountlist and VFS_SYNC as appropriate.

- use an API for mount points similiar to the API for vnodes:
- vfs_syncer_add_to_worklist(struct mount *mp) to add
- vfs_syncer_remove_from_worklist(struct mount *mp) to remove a mount.

No objections on tech-kern@


# 1.32 21-Apr-2015 pooka

Don't check if constant-sized KM_SLEEP allocations succeeded.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.31 05-Sep-2014 matt

branches: 1.31.2;
Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.30 15-Apr-2014 hannken

Fix a deadlock where one thread exits, enters fstrans_lwp_dtor()
and wants fstrans_lock. This thread holds the proc_lock.
Another thread holds fstrans_lock and runs pserialize_perform().
As the first thread holds the proc_lock, timeouts are blocked and
the second thread blocks forever in kpause().

Change fstrans_lwp_dtor() to invalidate, but not free its info
structs. No need to take fstrans_lock.

Change fstrans_get_lwp_info() to reuse invalidated info before
trying to allocate a new one.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.29 23-Nov-2013 christos

branches: 1.29.2;
change the mountlist CIRCLEQ into a TAILQ


# 1.28 25-Oct-2013 martin

Mark diagnostic-only variables


# 1.27 30-Sep-2013 hannken

Replace macro v_specmountpoint with two functions spec_node_getmountedfs()
and spec_node_setmountedfs() to manage the file system mounted on a device.
Assert the device is a block device.

Welcome to 6.99.24

Discussed on tech-kern@ some time ago.

Reviewed by: David Holland <dholland@netbsd.org>


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.26 21-Jan-2013 hannken

branches: 1.26.2;
Replace the rwlock based implementation with passive serialization
from pserialize(9) and mutex / condvar.

The fast paths (fstrans_start/fstrans_done on a file system not
suspended or suspending and fscow_run with no change pending) now
run without locks or other atomic operations. Suspension and cow
handler insertion and removal is done with mutex / condvars.

The API remains unchanged.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 1.25 12-May-2009 yamt

branches: 1.25.12; 1.25.22;
don't forget to skip marker processes.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.24 16-Nov-2008 pooka

branches: 1.24.4;
more <sys/buf.h> police


Revision tags: netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3
# 1.23 17-Sep-2008 hannken

branches: 1.23.2; 1.23.4; 1.23.6;
Replace the fss unmount hook with a vfs_hook.

fssvar.h: struct device * -> device_t.
fss.c: establish unmount hook on first attach, remove on last detach.
vfs_syscalls.c: remove the call of fss_umount_hook().
vfs_trans.c: destroy cow handlers on unmount as fstrans_unmount() will be
called before vfs_hooks.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.22 24-Jun-2008 ad

branches: 1.22.2;
Use pool_cache.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 16-May-2008 hannken

branches: 1.21.2;
Remove a bad assertion from last commit.
Non bufcache buffers may have BC_BUSY unset.


# 1.20 16-May-2008 hannken

Fscow_run() may recurse into itself.
Take care by adding a per-lwp recursion counter.


Revision tags: yamt-nfs-mp-base2
# 1.19 28-Apr-2008 martin

branches: 1.19.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.18 17-Mar-2008 yamt

branches: 1.18.2; 1.18.4;
- simplify ASSERT_SLEEPABLE.
- move it from proc.h to systm.h.
- add some more checks.
- make it a little more lkm friendly.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 1.17 02-Feb-2008 hannken

branches: 1.17.2; 1.17.6;
BO_COWDONE -> B_COWDONE: this flag is tested/modified from the thread owning
the buffer and therefore needs no protection by a mutex.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.16 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.15 02-Dec-2007 hannken

branches: 1.15.2; 1.15.6;
Fscow_run(): add a flag "bool data_valid" to note still valid data.
Buffers run through copy-on-write are marked B_COWDONE. This condition
is valid until the buffer has run through bwrite() and gets cleared from
biodone().

Welcome to 4.99.39.

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.14 08-Oct-2007 hannken

branches: 1.14.4;
fscow_run(): Check for NULL mount and don't run the cow handler in this case.


# 1.13 07-Oct-2007 hannken

Remove an include committed by accident.

From Chris Ross via current-users.


# 1.12 07-Oct-2007 hannken

Update the file system copy-on-write handler.

- Instead of hooking the handler on the specdev of a mounted file system
hook directly on the `struct mount'.

- Rename from `vn_cow_*' to `fscow_*' and move to `kern/vfs_trans.c'. Use
`mount_*specific' instead of clobbering `struct mount' or `struct specinfo'.

- Replace the hand-made reader/writer lock with a krwlock.

- Keep `vn_cow_*' functions and mark as obsolete.

- Welcome to NetBSD 4.99.32 - `struct specinfo' changed size.

Reviewed by: Jason Thorpe <thorpej@netbsd.org>


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.11 26-Jul-2007 pooka

branches: 1.11.4; 1.11.6; 1.11.8; 1.11.10;
Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.10 09-Jul-2007 ad

branches: 1.10.2;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8
# 1.9 17-May-2007 hannken

Fstrans_start() always returns zero, so change its type to void.


# 1.8 16-May-2007 hannken

Use rwlock for fmi_shared_lock and fmi_lazy_lock.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: thorpej-atomic-base
# 1.7 12-Mar-2007 ad

Use mutexes/condvars.


# 1.6 12-Mar-2007 ad

branches: 1.6.2;
Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.


Revision tags: ad-audiomp-base
# 1.5 16-Feb-2007 hannken

branches: 1.5.2; 1.5.4; 1.5.8;
Make fstrans(9) the default helper for file system suspension.
Replaces the now obsolete vn_start_write()/vn_finished_write().


# 1.4 15-Feb-2007 ad

Replace some uses of lockmgr() / simplelocks.


# 1.3 10-Feb-2007 hannken

newlock2: syncer_lock is now a mutex.


Revision tags: post-newlock2-merge newlock2-base newlock2-nbase
# 1.2 29-Jan-2007 hannken

branches: 1.2.2;
Change fstrans enum types to upper case.
No functional change.

From Antti Kantee <pooka@netbsd.org>


# 1.1 19-Jan-2007 hannken

New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

The new API is enabled on a kernel option NEWVNGATE. This option is
not enabled by default in any kernel config.

Presented and discussed on tech-kern with much input from
Bill Studenmund <wrstuden@netbsd.org> and YAMAMOTO Takashi <yamt@netbsd.org>.

Welcome to 4.99.9 (new vfs op vfs_suspendctl).


# 1.62 13-May-2020 hannken

Add operation fstrans_held(struct mount *), true if the current thread
holds a fstrans lock.

Ride 9.99.61


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.61 17-Jun-2019 hannken

Add an owner field to fstrans mount info and use it to hold
the thread currently suspending this mount.

Remove now unneeded state FSTRANS_EXCL.

It is now possible to suspend a file system from a thread
already holding fstrans locks. Use with care ...


Revision tags: phil-wifi-20190609
# 1.60 13-May-2019 hannken

Walk down to the lowest mount for "fli_alias".

Address PR kern/54195 (null mounts: panic: ...).


Revision tags: isaki-audio2-base
# 1.59 15-Apr-2019 hannken

Add reference counting to alias states to prevent them disappearing
while still in use.


# 1.58 07-Mar-2019 hannken

Change "fli_alias" to point to the corresponding "fstrans_lwp_info".

Fix fstrans_clear_lwp_info() list traversal, remove already advanced
the list pointer.


# 1.57 01-Mar-2019 hannken

Move pointer to fstrans private data into "struct lwp".

Ride NetBSD 8.99.35


# 1.56 24-Feb-2019 hannken

Clear per-lwp entries whose mount is gone before the first return
from fstrans_done().

No longer leaks "struct mount" forever.


# 1.55 21-Feb-2019 hannken

Fix bad assertion: vfs_suspend(dead_rootmount) may happen and
must return EOPNOTSUPP.


# 1.54 20-Feb-2019 hannken

- Make the fstrans mount info part of the per-lwp state and replace
most accesses to the mount with fstrans mount info.

- Add "fmi_gone" to be true after unmount and add a counter of
outstanding mount infos so fstrans_clear_lwp_info() only runs
if there may be something to do.

- Move lookup of base mounts into per-lwp state.

- Keep a list of valid mounts for DIAGNOSTIC checks.


# 1.53 20-Feb-2019 hannken

Move fstrans_unmount() to vfs_rele(), just before it would free the mount.
Don't take a mount reference for fstrans as it gets notified about the release.

Defer the final free of the mount to fstrans_mount_dtor() when fstrans
has released all references to this mount. Prevents the mount's memory
to be reused as a new mount before fstrans released all references.

Address PR kern/53928 modules/t_builtin:disable test case randomly fails.


# 1.52 20-Feb-2019 hannken

Attach "mnt_transinfo" to "dead_rootmount" so every mount has a
valid "mnt_transinfo" and remove now unneeded flag IMNT_HAS_TRANS.

Run fstrans_start()/fstrans_done() on dead_rootmount if FSTRANS_DEAD_ENABLED.
Should become the default for DIAGNOSTIC in the future.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.51 05-Oct-2018 hannken

Bring back three state file system suspension:

NORMAL -> SUSPENDING -> SUSPENDED

and add operation fstrans_start_lazy() that only blocks while SUSPENDED.

Change vndthread() support operation handle_with_rdwr() to bracket
its file system operations by fstrans_start_lazy() and fstrans_done().

PR kern/53624 (dom0 freeze on domU exit)


# 1.50 05-Oct-2018 manu

Back out sftchg/fstcnt deadlock workaround

The change did prevent some system freeze, but caused spurious
unmount failures reporter by bouyer@.

hannken@ is working on the right fix, see kern/53624


Revision tags: pgoyette-compat-0930
# 1.49 27-Sep-2018 manu

Work around deadlock between fstchg and fstcnt

When suspending a filesystem in fstrans_setstate(), we wait on
fstcnt for threads to finish transactions. While we do this, any
thread trying to start a filesystem transaction will wait on fstchg
in fstrans_start(), a situation which can deadlock.

The wait for fstcnt in fstrans_setstate() can be interrupted by
a signal, but the wait for fstchg in fstrans_start() cannot. Once
most processes are stuck in fstchg, it is impossible to send a
signal to the thread that waits on fstcnt, because no process
respond anymore to user input.

We fix that by adding a timeout to the wait on fstcnt in
fstrans_setstate(). This means suspending a filesystem may fail,
but it was already the case when the sleep was interupted by
a signal, hence calling function must already handle a possible
failure.

Fixes kern/53624


Revision tags: pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.48 18-Jun-2017 hannken

branches: 1.48.4; 1.48.6;
Make the fast path of fstrans_get_lwp_info() "static inline".


# 1.47 18-Jun-2017 hannken

Clear fstrans entries whose mount is gone from the last fstrans_done() only.


# 1.46 04-Jun-2017 hannken

Operations fstrans_start() and fstrans_start_nowait() now always
use FSTRANS_SHARED as lock type so remove the lock type argument.

File system state FSTRANS_SUSPENDING is now unused so remove it.

Regen vnode_if files.

Ride 8.99.1 less than a hour ago.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.45 07-May-2017 hannken

branches: 1.45.2;
Move fstrans initialization to vfs_mountalloc().


# 1.44 07-May-2017 hannken

Handle the case where the mount is gone and its mnt_transinfo is NULL.


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1
# 1.43 17-Apr-2017 hannken

branches: 1.43.2;
Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.


# 1.42 17-Apr-2017 hannken

Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount. Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).


# 1.41 12-Apr-2017 hannken

Switch fstrans_dump() to _mountlist_next().


Revision tags: jdolecek-ncq-base
# 1.40 30-Mar-2017 hannken

Change _fstrans_start() to allocate per lwp info for layered file
systems to get a reference on the mount.

Set mnt_lower on successfull mount only.


Revision tags: pgoyette-localcount-20170320
# 1.39 06-Mar-2017 hannken

Always use the lowest mount for fstrans and suspend. This way we
enter/leave or suspend/resume the stack of layered file systems as a unit.


# 1.38 02-Mar-2017 hannken

Add an operation to test a mount for fstrans support and use it for
_fstrans_start(), fstrans_done(), fstrans_is_owner(), vfs_suspend()
and vfs_resume().

Test for fstrans support before ASSERT_SLEEPABLE().


# 1.37 23-Feb-2017 hannken

Test for fstrans support before trying to allocate per-thread info.

PR kern/51996 (kmem_alloc called from intr context in fstrans_get_lwp_info)


# 1.36 17-Feb-2017 hannken

Let syncer try fstrans_start() before running VFS_SYNC() to get rid
of the syncer lock/unlock from vfs_suspend().


# 1.35 17-Feb-2017 hannken

Protect attaching and detaching lwp_info to mount with a mutex.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.34 24-Aug-2015 pooka

branches: 1.34.2; 1.34.4;
to garnish, dust with _KERNEL_OPT


Revision tags: nick-nhusb-base-20150606
# 1.33 06-May-2015 hannken

Remove miscfs/syncfs and

- move the syncer into kern/vfs_subr.c.

- change the syncer to process the mountlist and VFS_SYNC as appropriate.

- use an API for mount points similiar to the API for vnodes:
- vfs_syncer_add_to_worklist(struct mount *mp) to add
- vfs_syncer_remove_from_worklist(struct mount *mp) to remove a mount.

No objections on tech-kern@


# 1.32 21-Apr-2015 pooka

Don't check if constant-sized KM_SLEEP allocations succeeded.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.31 05-Sep-2014 matt

branches: 1.31.2;
Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.30 15-Apr-2014 hannken

Fix a deadlock where one thread exits, enters fstrans_lwp_dtor()
and wants fstrans_lock. This thread holds the proc_lock.
Another thread holds fstrans_lock and runs pserialize_perform().
As the first thread holds the proc_lock, timeouts are blocked and
the second thread blocks forever in kpause().

Change fstrans_lwp_dtor() to invalidate, but not free its info
structs. No need to take fstrans_lock.

Change fstrans_get_lwp_info() to reuse invalidated info before
trying to allocate a new one.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.29 23-Nov-2013 christos

branches: 1.29.2;
change the mountlist CIRCLEQ into a TAILQ


# 1.28 25-Oct-2013 martin

Mark diagnostic-only variables


# 1.27 30-Sep-2013 hannken

Replace macro v_specmountpoint with two functions spec_node_getmountedfs()
and spec_node_setmountedfs() to manage the file system mounted on a device.
Assert the device is a block device.

Welcome to 6.99.24

Discussed on tech-kern@ some time ago.

Reviewed by: David Holland <dholland@netbsd.org>


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.26 21-Jan-2013 hannken

branches: 1.26.2;
Replace the rwlock based implementation with passive serialization
from pserialize(9) and mutex / condvar.

The fast paths (fstrans_start/fstrans_done on a file system not
suspended or suspending and fscow_run with no change pending) now
run without locks or other atomic operations. Suspension and cow
handler insertion and removal is done with mutex / condvars.

The API remains unchanged.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 1.25 12-May-2009 yamt

branches: 1.25.12; 1.25.22;
don't forget to skip marker processes.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.24 16-Nov-2008 pooka

branches: 1.24.4;
more <sys/buf.h> police


Revision tags: netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3
# 1.23 17-Sep-2008 hannken

branches: 1.23.2; 1.23.4; 1.23.6;
Replace the fss unmount hook with a vfs_hook.

fssvar.h: struct device * -> device_t.
fss.c: establish unmount hook on first attach, remove on last detach.
vfs_syscalls.c: remove the call of fss_umount_hook().
vfs_trans.c: destroy cow handlers on unmount as fstrans_unmount() will be
called before vfs_hooks.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.22 24-Jun-2008 ad

branches: 1.22.2;
Use pool_cache.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 16-May-2008 hannken

branches: 1.21.2;
Remove a bad assertion from last commit.
Non bufcache buffers may have BC_BUSY unset.


# 1.20 16-May-2008 hannken

Fscow_run() may recurse into itself.
Take care by adding a per-lwp recursion counter.


Revision tags: yamt-nfs-mp-base2
# 1.19 28-Apr-2008 martin

branches: 1.19.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.18 17-Mar-2008 yamt

branches: 1.18.2; 1.18.4;
- simplify ASSERT_SLEEPABLE.
- move it from proc.h to systm.h.
- add some more checks.
- make it a little more lkm friendly.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 1.17 02-Feb-2008 hannken

branches: 1.17.2; 1.17.6;
BO_COWDONE -> B_COWDONE: this flag is tested/modified from the thread owning
the buffer and therefore needs no protection by a mutex.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.16 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.15 02-Dec-2007 hannken

branches: 1.15.2; 1.15.6;
Fscow_run(): add a flag "bool data_valid" to note still valid data.
Buffers run through copy-on-write are marked B_COWDONE. This condition
is valid until the buffer has run through bwrite() and gets cleared from
biodone().

Welcome to 4.99.39.

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.14 08-Oct-2007 hannken

branches: 1.14.4;
fscow_run(): Check for NULL mount and don't run the cow handler in this case.


# 1.13 07-Oct-2007 hannken

Remove an include committed by accident.

From Chris Ross via current-users.


# 1.12 07-Oct-2007 hannken

Update the file system copy-on-write handler.

- Instead of hooking the handler on the specdev of a mounted file system
hook directly on the `struct mount'.

- Rename from `vn_cow_*' to `fscow_*' and move to `kern/vfs_trans.c'. Use
`mount_*specific' instead of clobbering `struct mount' or `struct specinfo'.

- Replace the hand-made reader/writer lock with a krwlock.

- Keep `vn_cow_*' functions and mark as obsolete.

- Welcome to NetBSD 4.99.32 - `struct specinfo' changed size.

Reviewed by: Jason Thorpe <thorpej@netbsd.org>


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.11 26-Jul-2007 pooka

branches: 1.11.4; 1.11.6; 1.11.8; 1.11.10;
Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.10 09-Jul-2007 ad

branches: 1.10.2;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8
# 1.9 17-May-2007 hannken

Fstrans_start() always returns zero, so change its type to void.


# 1.8 16-May-2007 hannken

Use rwlock for fmi_shared_lock and fmi_lazy_lock.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: thorpej-atomic-base
# 1.7 12-Mar-2007 ad

Use mutexes/condvars.


# 1.6 12-Mar-2007 ad

branches: 1.6.2;
Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.


Revision tags: ad-audiomp-base
# 1.5 16-Feb-2007 hannken

branches: 1.5.2; 1.5.4; 1.5.8;
Make fstrans(9) the default helper for file system suspension.
Replaces the now obsolete vn_start_write()/vn_finished_write().


# 1.4 15-Feb-2007 ad

Replace some uses of lockmgr() / simplelocks.


# 1.3 10-Feb-2007 hannken

newlock2: syncer_lock is now a mutex.


Revision tags: post-newlock2-merge newlock2-base newlock2-nbase
# 1.2 29-Jan-2007 hannken

branches: 1.2.2;
Change fstrans enum types to upper case.
No functional change.

From Antti Kantee <pooka@netbsd.org>


# 1.1 19-Jan-2007 hannken

New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

The new API is enabled on a kernel option NEWVNGATE. This option is
not enabled by default in any kernel config.

Presented and discussed on tech-kern with much input from
Bill Studenmund <wrstuden@netbsd.org> and YAMAMOTO Takashi <yamt@netbsd.org>.

Welcome to 4.99.9 (new vfs op vfs_suspendctl).


# 1.61 17-Jun-2019 hannken

Add an owner field to fstrans mount info and use it to hold
the thread currently suspending this mount.

Remove now unneeded state FSTRANS_EXCL.

It is now possible to suspend a file system from a thread
already holding fstrans locks. Use with care ...


Revision tags: phil-wifi-20190609
# 1.60 13-May-2019 hannken

Walk down to the lowest mount for "fli_alias".

Address PR kern/54195 (null mounts: panic: ...).


Revision tags: isaki-audio2-base
# 1.59 15-Apr-2019 hannken

Add reference counting to alias states to prevent them disappearing
while still in use.


# 1.58 07-Mar-2019 hannken

Change "fli_alias" to point to the corresponding "fstrans_lwp_info".

Fix fstrans_clear_lwp_info() list traversal, remove already advanced
the list pointer.


# 1.57 01-Mar-2019 hannken

Move pointer to fstrans private data into "struct lwp".

Ride NetBSD 8.99.35


# 1.56 24-Feb-2019 hannken

Clear per-lwp entries whose mount is gone before the first return
from fstrans_done().

No longer leaks "struct mount" forever.


# 1.55 21-Feb-2019 hannken

Fix bad assertion: vfs_suspend(dead_rootmount) may happen and
must return EOPNOTSUPP.


# 1.54 20-Feb-2019 hannken

- Make the fstrans mount info part of the per-lwp state and replace
most accesses to the mount with fstrans mount info.

- Add "fmi_gone" to be true after unmount and add a counter of
outstanding mount infos so fstrans_clear_lwp_info() only runs
if there may be something to do.

- Move lookup of base mounts into per-lwp state.

- Keep a list of valid mounts for DIAGNOSTIC checks.


# 1.53 20-Feb-2019 hannken

Move fstrans_unmount() to vfs_rele(), just before it would free the mount.
Don't take a mount reference for fstrans as it gets notified about the release.

Defer the final free of the mount to fstrans_mount_dtor() when fstrans
has released all references to this mount. Prevents the mount's memory
to be reused as a new mount before fstrans released all references.

Address PR kern/53928 modules/t_builtin:disable test case randomly fails.


# 1.52 20-Feb-2019 hannken

Attach "mnt_transinfo" to "dead_rootmount" so every mount has a
valid "mnt_transinfo" and remove now unneeded flag IMNT_HAS_TRANS.

Run fstrans_start()/fstrans_done() on dead_rootmount if FSTRANS_DEAD_ENABLED.
Should become the default for DIAGNOSTIC in the future.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.51 05-Oct-2018 hannken

Bring back three state file system suspension:

NORMAL -> SUSPENDING -> SUSPENDED

and add operation fstrans_start_lazy() that only blocks while SUSPENDED.

Change vndthread() support operation handle_with_rdwr() to bracket
its file system operations by fstrans_start_lazy() and fstrans_done().

PR kern/53624 (dom0 freeze on domU exit)


# 1.50 05-Oct-2018 manu

Back out sftchg/fstcnt deadlock workaround

The change did prevent some system freeze, but caused spurious
unmount failures reporter by bouyer@.

hannken@ is working on the right fix, see kern/53624


Revision tags: pgoyette-compat-0930
# 1.49 27-Sep-2018 manu

Work around deadlock between fstchg and fstcnt

When suspending a filesystem in fstrans_setstate(), we wait on
fstcnt for threads to finish transactions. While we do this, any
thread trying to start a filesystem transaction will wait on fstchg
in fstrans_start(), a situation which can deadlock.

The wait for fstcnt in fstrans_setstate() can be interrupted by
a signal, but the wait for fstchg in fstrans_start() cannot. Once
most processes are stuck in fstchg, it is impossible to send a
signal to the thread that waits on fstcnt, because no process
respond anymore to user input.

We fix that by adding a timeout to the wait on fstcnt in
fstrans_setstate(). This means suspending a filesystem may fail,
but it was already the case when the sleep was interupted by
a signal, hence calling function must already handle a possible
failure.

Fixes kern/53624


Revision tags: pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.48 18-Jun-2017 hannken

branches: 1.48.4; 1.48.6;
Make the fast path of fstrans_get_lwp_info() "static inline".


# 1.47 18-Jun-2017 hannken

Clear fstrans entries whose mount is gone from the last fstrans_done() only.


# 1.46 04-Jun-2017 hannken

Operations fstrans_start() and fstrans_start_nowait() now always
use FSTRANS_SHARED as lock type so remove the lock type argument.

File system state FSTRANS_SUSPENDING is now unused so remove it.

Regen vnode_if files.

Ride 8.99.1 less than a hour ago.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.45 07-May-2017 hannken

branches: 1.45.2;
Move fstrans initialization to vfs_mountalloc().


# 1.44 07-May-2017 hannken

Handle the case where the mount is gone and its mnt_transinfo is NULL.


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1
# 1.43 17-Apr-2017 hannken

branches: 1.43.2;
Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.


# 1.42 17-Apr-2017 hannken

Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount. Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).


# 1.41 12-Apr-2017 hannken

Switch fstrans_dump() to _mountlist_next().


Revision tags: jdolecek-ncq-base
# 1.40 30-Mar-2017 hannken

Change _fstrans_start() to allocate per lwp info for layered file
systems to get a reference on the mount.

Set mnt_lower on successfull mount only.


Revision tags: pgoyette-localcount-20170320
# 1.39 06-Mar-2017 hannken

Always use the lowest mount for fstrans and suspend. This way we
enter/leave or suspend/resume the stack of layered file systems as a unit.


# 1.38 02-Mar-2017 hannken

Add an operation to test a mount for fstrans support and use it for
_fstrans_start(), fstrans_done(), fstrans_is_owner(), vfs_suspend()
and vfs_resume().

Test for fstrans support before ASSERT_SLEEPABLE().


# 1.37 23-Feb-2017 hannken

Test for fstrans support before trying to allocate per-thread info.

PR kern/51996 (kmem_alloc called from intr context in fstrans_get_lwp_info)


# 1.36 17-Feb-2017 hannken

Let syncer try fstrans_start() before running VFS_SYNC() to get rid
of the syncer lock/unlock from vfs_suspend().


# 1.35 17-Feb-2017 hannken

Protect attaching and detaching lwp_info to mount with a mutex.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.34 24-Aug-2015 pooka

branches: 1.34.2; 1.34.4;
to garnish, dust with _KERNEL_OPT


Revision tags: nick-nhusb-base-20150606
# 1.33 06-May-2015 hannken

Remove miscfs/syncfs and

- move the syncer into kern/vfs_subr.c.

- change the syncer to process the mountlist and VFS_SYNC as appropriate.

- use an API for mount points similiar to the API for vnodes:
- vfs_syncer_add_to_worklist(struct mount *mp) to add
- vfs_syncer_remove_from_worklist(struct mount *mp) to remove a mount.

No objections on tech-kern@


# 1.32 21-Apr-2015 pooka

Don't check if constant-sized KM_SLEEP allocations succeeded.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.31 05-Sep-2014 matt

branches: 1.31.2;
Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.30 15-Apr-2014 hannken

Fix a deadlock where one thread exits, enters fstrans_lwp_dtor()
and wants fstrans_lock. This thread holds the proc_lock.
Another thread holds fstrans_lock and runs pserialize_perform().
As the first thread holds the proc_lock, timeouts are blocked and
the second thread blocks forever in kpause().

Change fstrans_lwp_dtor() to invalidate, but not free its info
structs. No need to take fstrans_lock.

Change fstrans_get_lwp_info() to reuse invalidated info before
trying to allocate a new one.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.29 23-Nov-2013 christos

branches: 1.29.2;
change the mountlist CIRCLEQ into a TAILQ


# 1.28 25-Oct-2013 martin

Mark diagnostic-only variables


# 1.27 30-Sep-2013 hannken

Replace macro v_specmountpoint with two functions spec_node_getmountedfs()
and spec_node_setmountedfs() to manage the file system mounted on a device.
Assert the device is a block device.

Welcome to 6.99.24

Discussed on tech-kern@ some time ago.

Reviewed by: David Holland <dholland@netbsd.org>


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.26 21-Jan-2013 hannken

branches: 1.26.2;
Replace the rwlock based implementation with passive serialization
from pserialize(9) and mutex / condvar.

The fast paths (fstrans_start/fstrans_done on a file system not
suspended or suspending and fscow_run with no change pending) now
run without locks or other atomic operations. Suspension and cow
handler insertion and removal is done with mutex / condvars.

The API remains unchanged.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 1.25 12-May-2009 yamt

branches: 1.25.12; 1.25.22;
don't forget to skip marker processes.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.24 16-Nov-2008 pooka

branches: 1.24.4;
more <sys/buf.h> police


Revision tags: netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3
# 1.23 17-Sep-2008 hannken

branches: 1.23.2; 1.23.4; 1.23.6;
Replace the fss unmount hook with a vfs_hook.

fssvar.h: struct device * -> device_t.
fss.c: establish unmount hook on first attach, remove on last detach.
vfs_syscalls.c: remove the call of fss_umount_hook().
vfs_trans.c: destroy cow handlers on unmount as fstrans_unmount() will be
called before vfs_hooks.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.22 24-Jun-2008 ad

branches: 1.22.2;
Use pool_cache.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 16-May-2008 hannken

branches: 1.21.2;
Remove a bad assertion from last commit.
Non bufcache buffers may have BC_BUSY unset.


# 1.20 16-May-2008 hannken

Fscow_run() may recurse into itself.
Take care by adding a per-lwp recursion counter.


Revision tags: yamt-nfs-mp-base2
# 1.19 28-Apr-2008 martin

branches: 1.19.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.18 17-Mar-2008 yamt

branches: 1.18.2; 1.18.4;
- simplify ASSERT_SLEEPABLE.
- move it from proc.h to systm.h.
- add some more checks.
- make it a little more lkm friendly.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 1.17 02-Feb-2008 hannken

branches: 1.17.2; 1.17.6;
BO_COWDONE -> B_COWDONE: this flag is tested/modified from the thread owning
the buffer and therefore needs no protection by a mutex.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.16 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.15 02-Dec-2007 hannken

branches: 1.15.2; 1.15.6;
Fscow_run(): add a flag "bool data_valid" to note still valid data.
Buffers run through copy-on-write are marked B_COWDONE. This condition
is valid until the buffer has run through bwrite() and gets cleared from
biodone().

Welcome to 4.99.39.

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.14 08-Oct-2007 hannken

branches: 1.14.4;
fscow_run(): Check for NULL mount and don't run the cow handler in this case.


# 1.13 07-Oct-2007 hannken

Remove an include committed by accident.

From Chris Ross via current-users.


# 1.12 07-Oct-2007 hannken

Update the file system copy-on-write handler.

- Instead of hooking the handler on the specdev of a mounted file system
hook directly on the `struct mount'.

- Rename from `vn_cow_*' to `fscow_*' and move to `kern/vfs_trans.c'. Use
`mount_*specific' instead of clobbering `struct mount' or `struct specinfo'.

- Replace the hand-made reader/writer lock with a krwlock.

- Keep `vn_cow_*' functions and mark as obsolete.

- Welcome to NetBSD 4.99.32 - `struct specinfo' changed size.

Reviewed by: Jason Thorpe <thorpej@netbsd.org>


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.11 26-Jul-2007 pooka

branches: 1.11.4; 1.11.6; 1.11.8; 1.11.10;
Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.10 09-Jul-2007 ad

branches: 1.10.2;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8
# 1.9 17-May-2007 hannken

Fstrans_start() always returns zero, so change its type to void.


# 1.8 16-May-2007 hannken

Use rwlock for fmi_shared_lock and fmi_lazy_lock.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: thorpej-atomic-base
# 1.7 12-Mar-2007 ad

Use mutexes/condvars.


# 1.6 12-Mar-2007 ad

branches: 1.6.2;
Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.


Revision tags: ad-audiomp-base
# 1.5 16-Feb-2007 hannken

branches: 1.5.2; 1.5.4; 1.5.8;
Make fstrans(9) the default helper for file system suspension.
Replaces the now obsolete vn_start_write()/vn_finished_write().


# 1.4 15-Feb-2007 ad

Replace some uses of lockmgr() / simplelocks.


# 1.3 10-Feb-2007 hannken

newlock2: syncer_lock is now a mutex.


Revision tags: post-newlock2-merge newlock2-base newlock2-nbase
# 1.2 29-Jan-2007 hannken

branches: 1.2.2;
Change fstrans enum types to upper case.
No functional change.

From Antti Kantee <pooka@netbsd.org>


# 1.1 19-Jan-2007 hannken

New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

The new API is enabled on a kernel option NEWVNGATE. This option is
not enabled by default in any kernel config.

Presented and discussed on tech-kern with much input from
Bill Studenmund <wrstuden@netbsd.org> and YAMAMOTO Takashi <yamt@netbsd.org>.

Welcome to 4.99.9 (new vfs op vfs_suspendctl).


# 1.60 13-May-2019 hannken

Walk down to the lowest mount for "fli_alias".

Address PR kern/54195 (null mounts: panic: ...).


Revision tags: isaki-audio2-base
# 1.59 15-Apr-2019 hannken

Add reference counting to alias states to prevent them disappearing
while still in use.


# 1.58 07-Mar-2019 hannken

Change "fli_alias" to point to the corresponding "fstrans_lwp_info".

Fix fstrans_clear_lwp_info() list traversal, remove already advanced
the list pointer.


# 1.57 01-Mar-2019 hannken

Move pointer to fstrans private data into "struct lwp".

Ride NetBSD 8.99.35


# 1.56 24-Feb-2019 hannken

Clear per-lwp entries whose mount is gone before the first return
from fstrans_done().

No longer leaks "struct mount" forever.


# 1.55 21-Feb-2019 hannken

Fix bad assertion: vfs_suspend(dead_rootmount) may happen and
must return EOPNOTSUPP.


# 1.54 20-Feb-2019 hannken

- Make the fstrans mount info part of the per-lwp state and replace
most accesses to the mount with fstrans mount info.

- Add "fmi_gone" to be true after unmount and add a counter of
outstanding mount infos so fstrans_clear_lwp_info() only runs
if there may be something to do.

- Move lookup of base mounts into per-lwp state.

- Keep a list of valid mounts for DIAGNOSTIC checks.


# 1.53 20-Feb-2019 hannken

Move fstrans_unmount() to vfs_rele(), just before it would free the mount.
Don't take a mount reference for fstrans as it gets notified about the release.

Defer the final free of the mount to fstrans_mount_dtor() when fstrans
has released all references to this mount. Prevents the mount's memory
to be reused as a new mount before fstrans released all references.

Address PR kern/53928 modules/t_builtin:disable test case randomly fails.


# 1.52 20-Feb-2019 hannken

Attach "mnt_transinfo" to "dead_rootmount" so every mount has a
valid "mnt_transinfo" and remove now unneeded flag IMNT_HAS_TRANS.

Run fstrans_start()/fstrans_done() on dead_rootmount if FSTRANS_DEAD_ENABLED.
Should become the default for DIAGNOSTIC in the future.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.51 05-Oct-2018 hannken

Bring back three state file system suspension:

NORMAL -> SUSPENDING -> SUSPENDED

and add operation fstrans_start_lazy() that only blocks while SUSPENDED.

Change vndthread() support operation handle_with_rdwr() to bracket
its file system operations by fstrans_start_lazy() and fstrans_done().

PR kern/53624 (dom0 freeze on domU exit)


# 1.50 05-Oct-2018 manu

Back out sftchg/fstcnt deadlock workaround

The change did prevent some system freeze, but caused spurious
unmount failures reporter by bouyer@.

hannken@ is working on the right fix, see kern/53624


Revision tags: pgoyette-compat-0930
# 1.49 27-Sep-2018 manu

Work around deadlock between fstchg and fstcnt

When suspending a filesystem in fstrans_setstate(), we wait on
fstcnt for threads to finish transactions. While we do this, any
thread trying to start a filesystem transaction will wait on fstchg
in fstrans_start(), a situation which can deadlock.

The wait for fstcnt in fstrans_setstate() can be interrupted by
a signal, but the wait for fstchg in fstrans_start() cannot. Once
most processes are stuck in fstchg, it is impossible to send a
signal to the thread that waits on fstcnt, because no process
respond anymore to user input.

We fix that by adding a timeout to the wait on fstcnt in
fstrans_setstate(). This means suspending a filesystem may fail,
but it was already the case when the sleep was interupted by
a signal, hence calling function must already handle a possible
failure.

Fixes kern/53624


Revision tags: pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.48 18-Jun-2017 hannken

branches: 1.48.4;
Make the fast path of fstrans_get_lwp_info() "static inline".


# 1.47 18-Jun-2017 hannken

Clear fstrans entries whose mount is gone from the last fstrans_done() only.


# 1.46 04-Jun-2017 hannken

Operations fstrans_start() and fstrans_start_nowait() now always
use FSTRANS_SHARED as lock type so remove the lock type argument.

File system state FSTRANS_SUSPENDING is now unused so remove it.

Regen vnode_if files.

Ride 8.99.1 less than a hour ago.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.45 07-May-2017 hannken

branches: 1.45.2;
Move fstrans initialization to vfs_mountalloc().


# 1.44 07-May-2017 hannken

Handle the case where the mount is gone and its mnt_transinfo is NULL.


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1
# 1.43 17-Apr-2017 hannken

branches: 1.43.2;
Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.


# 1.42 17-Apr-2017 hannken

Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount. Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).


# 1.41 12-Apr-2017 hannken

Switch fstrans_dump() to _mountlist_next().


Revision tags: jdolecek-ncq-base
# 1.40 30-Mar-2017 hannken

Change _fstrans_start() to allocate per lwp info for layered file
systems to get a reference on the mount.

Set mnt_lower on successfull mount only.


Revision tags: pgoyette-localcount-20170320
# 1.39 06-Mar-2017 hannken

Always use the lowest mount for fstrans and suspend. This way we
enter/leave or suspend/resume the stack of layered file systems as a unit.


# 1.38 02-Mar-2017 hannken

Add an operation to test a mount for fstrans support and use it for
_fstrans_start(), fstrans_done(), fstrans_is_owner(), vfs_suspend()
and vfs_resume().

Test for fstrans support before ASSERT_SLEEPABLE().


# 1.37 23-Feb-2017 hannken

Test for fstrans support before trying to allocate per-thread info.

PR kern/51996 (kmem_alloc called from intr context in fstrans_get_lwp_info)


# 1.36 17-Feb-2017 hannken

Let syncer try fstrans_start() before running VFS_SYNC() to get rid
of the syncer lock/unlock from vfs_suspend().


# 1.35 17-Feb-2017 hannken

Protect attaching and detaching lwp_info to mount with a mutex.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.34 24-Aug-2015 pooka

branches: 1.34.2; 1.34.4;
to garnish, dust with _KERNEL_OPT


Revision tags: nick-nhusb-base-20150606
# 1.33 06-May-2015 hannken

Remove miscfs/syncfs and

- move the syncer into kern/vfs_subr.c.

- change the syncer to process the mountlist and VFS_SYNC as appropriate.

- use an API for mount points similiar to the API for vnodes:
- vfs_syncer_add_to_worklist(struct mount *mp) to add
- vfs_syncer_remove_from_worklist(struct mount *mp) to remove a mount.

No objections on tech-kern@


# 1.32 21-Apr-2015 pooka

Don't check if constant-sized KM_SLEEP allocations succeeded.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.31 05-Sep-2014 matt

branches: 1.31.2;
Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.30 15-Apr-2014 hannken

Fix a deadlock where one thread exits, enters fstrans_lwp_dtor()
and wants fstrans_lock. This thread holds the proc_lock.
Another thread holds fstrans_lock and runs pserialize_perform().
As the first thread holds the proc_lock, timeouts are blocked and
the second thread blocks forever in kpause().

Change fstrans_lwp_dtor() to invalidate, but not free its info
structs. No need to take fstrans_lock.

Change fstrans_get_lwp_info() to reuse invalidated info before
trying to allocate a new one.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.29 23-Nov-2013 christos

branches: 1.29.2;
change the mountlist CIRCLEQ into a TAILQ


# 1.28 25-Oct-2013 martin

Mark diagnostic-only variables


# 1.27 30-Sep-2013 hannken

Replace macro v_specmountpoint with two functions spec_node_getmountedfs()
and spec_node_setmountedfs() to manage the file system mounted on a device.
Assert the device is a block device.

Welcome to 6.99.24

Discussed on tech-kern@ some time ago.

Reviewed by: David Holland <dholland@netbsd.org>


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.26 21-Jan-2013 hannken

branches: 1.26.2;
Replace the rwlock based implementation with passive serialization
from pserialize(9) and mutex / condvar.

The fast paths (fstrans_start/fstrans_done on a file system not
suspended or suspending and fscow_run with no change pending) now
run without locks or other atomic operations. Suspension and cow
handler insertion and removal is done with mutex / condvars.

The API remains unchanged.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 1.25 12-May-2009 yamt

branches: 1.25.12; 1.25.22;
don't forget to skip marker processes.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.24 16-Nov-2008 pooka

branches: 1.24.4;
more <sys/buf.h> police


Revision tags: netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3
# 1.23 17-Sep-2008 hannken

branches: 1.23.2; 1.23.4; 1.23.6;
Replace the fss unmount hook with a vfs_hook.

fssvar.h: struct device * -> device_t.
fss.c: establish unmount hook on first attach, remove on last detach.
vfs_syscalls.c: remove the call of fss_umount_hook().
vfs_trans.c: destroy cow handlers on unmount as fstrans_unmount() will be
called before vfs_hooks.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.22 24-Jun-2008 ad

branches: 1.22.2;
Use pool_cache.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 16-May-2008 hannken

branches: 1.21.2;
Remove a bad assertion from last commit.
Non bufcache buffers may have BC_BUSY unset.


# 1.20 16-May-2008 hannken

Fscow_run() may recurse into itself.
Take care by adding a per-lwp recursion counter.


Revision tags: yamt-nfs-mp-base2
# 1.19 28-Apr-2008 martin

branches: 1.19.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.18 17-Mar-2008 yamt

branches: 1.18.2; 1.18.4;
- simplify ASSERT_SLEEPABLE.
- move it from proc.h to systm.h.
- add some more checks.
- make it a little more lkm friendly.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 1.17 02-Feb-2008 hannken

branches: 1.17.2; 1.17.6;
BO_COWDONE -> B_COWDONE: this flag is tested/modified from the thread owning
the buffer and therefore needs no protection by a mutex.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.16 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.15 02-Dec-2007 hannken

branches: 1.15.2; 1.15.6;
Fscow_run(): add a flag "bool data_valid" to note still valid data.
Buffers run through copy-on-write are marked B_COWDONE. This condition
is valid until the buffer has run through bwrite() and gets cleared from
biodone().

Welcome to 4.99.39.

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.14 08-Oct-2007 hannken

branches: 1.14.4;
fscow_run(): Check for NULL mount and don't run the cow handler in this case.


# 1.13 07-Oct-2007 hannken

Remove an include committed by accident.

From Chris Ross via current-users.


# 1.12 07-Oct-2007 hannken

Update the file system copy-on-write handler.

- Instead of hooking the handler on the specdev of a mounted file system
hook directly on the `struct mount'.

- Rename from `vn_cow_*' to `fscow_*' and move to `kern/vfs_trans.c'. Use
`mount_*specific' instead of clobbering `struct mount' or `struct specinfo'.

- Replace the hand-made reader/writer lock with a krwlock.

- Keep `vn_cow_*' functions and mark as obsolete.

- Welcome to NetBSD 4.99.32 - `struct specinfo' changed size.

Reviewed by: Jason Thorpe <thorpej@netbsd.org>


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.11 26-Jul-2007 pooka

branches: 1.11.4; 1.11.6; 1.11.8; 1.11.10;
Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.10 09-Jul-2007 ad

branches: 1.10.2;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8
# 1.9 17-May-2007 hannken

Fstrans_start() always returns zero, so change its type to void.


# 1.8 16-May-2007 hannken

Use rwlock for fmi_shared_lock and fmi_lazy_lock.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: thorpej-atomic-base
# 1.7 12-Mar-2007 ad

Use mutexes/condvars.


# 1.6 12-Mar-2007 ad

branches: 1.6.2;
Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.


Revision tags: ad-audiomp-base
# 1.5 16-Feb-2007 hannken

branches: 1.5.2; 1.5.4; 1.5.8;
Make fstrans(9) the default helper for file system suspension.
Replaces the now obsolete vn_start_write()/vn_finished_write().


# 1.4 15-Feb-2007 ad

Replace some uses of lockmgr() / simplelocks.


# 1.3 10-Feb-2007 hannken

newlock2: syncer_lock is now a mutex.


Revision tags: post-newlock2-merge newlock2-base newlock2-nbase
# 1.2 29-Jan-2007 hannken

branches: 1.2.2;
Change fstrans enum types to upper case.
No functional change.

From Antti Kantee <pooka@netbsd.org>


# 1.1 19-Jan-2007 hannken

New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

The new API is enabled on a kernel option NEWVNGATE. This option is
not enabled by default in any kernel config.

Presented and discussed on tech-kern with much input from
Bill Studenmund <wrstuden@netbsd.org> and YAMAMOTO Takashi <yamt@netbsd.org>.

Welcome to 4.99.9 (new vfs op vfs_suspendctl).


Revision tags: isaki-audio2-base
# 1.59 15-Apr-2019 hannken

Add reference counting to alias states to prevent them disappearing
while still in use.


# 1.58 07-Mar-2019 hannken

Change "fli_alias" to point to the corresponding "fstrans_lwp_info".

Fix fstrans_clear_lwp_info() list traversal, remove already advanced
the list pointer.


# 1.57 01-Mar-2019 hannken

Move pointer to fstrans private data into "struct lwp".

Ride NetBSD 8.99.35


# 1.56 24-Feb-2019 hannken

Clear per-lwp entries whose mount is gone before the first return
from fstrans_done().

No longer leaks "struct mount" forever.


# 1.55 21-Feb-2019 hannken

Fix bad assertion: vfs_suspend(dead_rootmount) may happen and
must return EOPNOTSUPP.


# 1.54 20-Feb-2019 hannken

- Make the fstrans mount info part of the per-lwp state and replace
most accesses to the mount with fstrans mount info.

- Add "fmi_gone" to be true after unmount and add a counter of
outstanding mount infos so fstrans_clear_lwp_info() only runs
if there may be something to do.

- Move lookup of base mounts into per-lwp state.

- Keep a list of valid mounts for DIAGNOSTIC checks.


# 1.53 20-Feb-2019 hannken

Move fstrans_unmount() to vfs_rele(), just before it would free the mount.
Don't take a mount reference for fstrans as it gets notified about the release.

Defer the final free of the mount to fstrans_mount_dtor() when fstrans
has released all references to this mount. Prevents the mount's memory
to be reused as a new mount before fstrans released all references.

Address PR kern/53928 modules/t_builtin:disable test case randomly fails.


# 1.52 20-Feb-2019 hannken

Attach "mnt_transinfo" to "dead_rootmount" so every mount has a
valid "mnt_transinfo" and remove now unneeded flag IMNT_HAS_TRANS.

Run fstrans_start()/fstrans_done() on dead_rootmount if FSTRANS_DEAD_ENABLED.
Should become the default for DIAGNOSTIC in the future.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.51 05-Oct-2018 hannken

Bring back three state file system suspension:

NORMAL -> SUSPENDING -> SUSPENDED

and add operation fstrans_start_lazy() that only blocks while SUSPENDED.

Change vndthread() support operation handle_with_rdwr() to bracket
its file system operations by fstrans_start_lazy() and fstrans_done().

PR kern/53624 (dom0 freeze on domU exit)


# 1.50 05-Oct-2018 manu

Back out sftchg/fstcnt deadlock workaround

The change did prevent some system freeze, but caused spurious
unmount failures reporter by bouyer@.

hannken@ is working on the right fix, see kern/53624


Revision tags: pgoyette-compat-0930
# 1.49 27-Sep-2018 manu

Work around deadlock between fstchg and fstcnt

When suspending a filesystem in fstrans_setstate(), we wait on
fstcnt for threads to finish transactions. While we do this, any
thread trying to start a filesystem transaction will wait on fstchg
in fstrans_start(), a situation which can deadlock.

The wait for fstcnt in fstrans_setstate() can be interrupted by
a signal, but the wait for fstchg in fstrans_start() cannot. Once
most processes are stuck in fstchg, it is impossible to send a
signal to the thread that waits on fstcnt, because no process
respond anymore to user input.

We fix that by adding a timeout to the wait on fstcnt in
fstrans_setstate(). This means suspending a filesystem may fail,
but it was already the case when the sleep was interupted by
a signal, hence calling function must already handle a possible
failure.

Fixes kern/53624


Revision tags: pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.48 18-Jun-2017 hannken

branches: 1.48.4;
Make the fast path of fstrans_get_lwp_info() "static inline".


# 1.47 18-Jun-2017 hannken

Clear fstrans entries whose mount is gone from the last fstrans_done() only.


# 1.46 04-Jun-2017 hannken

Operations fstrans_start() and fstrans_start_nowait() now always
use FSTRANS_SHARED as lock type so remove the lock type argument.

File system state FSTRANS_SUSPENDING is now unused so remove it.

Regen vnode_if files.

Ride 8.99.1 less than a hour ago.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.45 07-May-2017 hannken

branches: 1.45.2;
Move fstrans initialization to vfs_mountalloc().


# 1.44 07-May-2017 hannken

Handle the case where the mount is gone and its mnt_transinfo is NULL.


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1
# 1.43 17-Apr-2017 hannken

branches: 1.43.2;
Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.


# 1.42 17-Apr-2017 hannken

Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount. Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).


# 1.41 12-Apr-2017 hannken

Switch fstrans_dump() to _mountlist_next().


Revision tags: jdolecek-ncq-base
# 1.40 30-Mar-2017 hannken

Change _fstrans_start() to allocate per lwp info for layered file
systems to get a reference on the mount.

Set mnt_lower on successfull mount only.


Revision tags: pgoyette-localcount-20170320
# 1.39 06-Mar-2017 hannken

Always use the lowest mount for fstrans and suspend. This way we
enter/leave or suspend/resume the stack of layered file systems as a unit.


# 1.38 02-Mar-2017 hannken

Add an operation to test a mount for fstrans support and use it for
_fstrans_start(), fstrans_done(), fstrans_is_owner(), vfs_suspend()
and vfs_resume().

Test for fstrans support before ASSERT_SLEEPABLE().


# 1.37 23-Feb-2017 hannken

Test for fstrans support before trying to allocate per-thread info.

PR kern/51996 (kmem_alloc called from intr context in fstrans_get_lwp_info)


# 1.36 17-Feb-2017 hannken

Let syncer try fstrans_start() before running VFS_SYNC() to get rid
of the syncer lock/unlock from vfs_suspend().


# 1.35 17-Feb-2017 hannken

Protect attaching and detaching lwp_info to mount with a mutex.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.34 24-Aug-2015 pooka

branches: 1.34.2; 1.34.4;
to garnish, dust with _KERNEL_OPT


Revision tags: nick-nhusb-base-20150606
# 1.33 06-May-2015 hannken

Remove miscfs/syncfs and

- move the syncer into kern/vfs_subr.c.

- change the syncer to process the mountlist and VFS_SYNC as appropriate.

- use an API for mount points similiar to the API for vnodes:
- vfs_syncer_add_to_worklist(struct mount *mp) to add
- vfs_syncer_remove_from_worklist(struct mount *mp) to remove a mount.

No objections on tech-kern@


# 1.32 21-Apr-2015 pooka

Don't check if constant-sized KM_SLEEP allocations succeeded.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.31 05-Sep-2014 matt

branches: 1.31.2;
Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.30 15-Apr-2014 hannken

Fix a deadlock where one thread exits, enters fstrans_lwp_dtor()
and wants fstrans_lock. This thread holds the proc_lock.
Another thread holds fstrans_lock and runs pserialize_perform().
As the first thread holds the proc_lock, timeouts are blocked and
the second thread blocks forever in kpause().

Change fstrans_lwp_dtor() to invalidate, but not free its info
structs. No need to take fstrans_lock.

Change fstrans_get_lwp_info() to reuse invalidated info before
trying to allocate a new one.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.29 23-Nov-2013 christos

branches: 1.29.2;
change the mountlist CIRCLEQ into a TAILQ


# 1.28 25-Oct-2013 martin

Mark diagnostic-only variables


# 1.27 30-Sep-2013 hannken

Replace macro v_specmountpoint with two functions spec_node_getmountedfs()
and spec_node_setmountedfs() to manage the file system mounted on a device.
Assert the device is a block device.

Welcome to 6.99.24

Discussed on tech-kern@ some time ago.

Reviewed by: David Holland <dholland@netbsd.org>


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.26 21-Jan-2013 hannken

branches: 1.26.2;
Replace the rwlock based implementation with passive serialization
from pserialize(9) and mutex / condvar.

The fast paths (fstrans_start/fstrans_done on a file system not
suspended or suspending and fscow_run with no change pending) now
run without locks or other atomic operations. Suspension and cow
handler insertion and removal is done with mutex / condvars.

The API remains unchanged.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 1.25 12-May-2009 yamt

branches: 1.25.12; 1.25.22;
don't forget to skip marker processes.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.24 16-Nov-2008 pooka

branches: 1.24.4;
more <sys/buf.h> police


Revision tags: netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3
# 1.23 17-Sep-2008 hannken

branches: 1.23.2; 1.23.4; 1.23.6;
Replace the fss unmount hook with a vfs_hook.

fssvar.h: struct device * -> device_t.
fss.c: establish unmount hook on first attach, remove on last detach.
vfs_syscalls.c: remove the call of fss_umount_hook().
vfs_trans.c: destroy cow handlers on unmount as fstrans_unmount() will be
called before vfs_hooks.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.22 24-Jun-2008 ad

branches: 1.22.2;
Use pool_cache.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 16-May-2008 hannken

branches: 1.21.2;
Remove a bad assertion from last commit.
Non bufcache buffers may have BC_BUSY unset.


# 1.20 16-May-2008 hannken

Fscow_run() may recurse into itself.
Take care by adding a per-lwp recursion counter.


Revision tags: yamt-nfs-mp-base2
# 1.19 28-Apr-2008 martin

branches: 1.19.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.18 17-Mar-2008 yamt

branches: 1.18.2; 1.18.4;
- simplify ASSERT_SLEEPABLE.
- move it from proc.h to systm.h.
- add some more checks.
- make it a little more lkm friendly.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 1.17 02-Feb-2008 hannken

branches: 1.17.2; 1.17.6;
BO_COWDONE -> B_COWDONE: this flag is tested/modified from the thread owning
the buffer and therefore needs no protection by a mutex.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.16 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.15 02-Dec-2007 hannken

branches: 1.15.2; 1.15.6;
Fscow_run(): add a flag "bool data_valid" to note still valid data.
Buffers run through copy-on-write are marked B_COWDONE. This condition
is valid until the buffer has run through bwrite() and gets cleared from
biodone().

Welcome to 4.99.39.

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.14 08-Oct-2007 hannken

branches: 1.14.4;
fscow_run(): Check for NULL mount and don't run the cow handler in this case.


# 1.13 07-Oct-2007 hannken

Remove an include committed by accident.

From Chris Ross via current-users.


# 1.12 07-Oct-2007 hannken

Update the file system copy-on-write handler.

- Instead of hooking the handler on the specdev of a mounted file system
hook directly on the `struct mount'.

- Rename from `vn_cow_*' to `fscow_*' and move to `kern/vfs_trans.c'. Use
`mount_*specific' instead of clobbering `struct mount' or `struct specinfo'.

- Replace the hand-made reader/writer lock with a krwlock.

- Keep `vn_cow_*' functions and mark as obsolete.

- Welcome to NetBSD 4.99.32 - `struct specinfo' changed size.

Reviewed by: Jason Thorpe <thorpej@netbsd.org>


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.11 26-Jul-2007 pooka

branches: 1.11.4; 1.11.6; 1.11.8; 1.11.10;
Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.10 09-Jul-2007 ad

branches: 1.10.2;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8
# 1.9 17-May-2007 hannken

Fstrans_start() always returns zero, so change its type to void.


# 1.8 16-May-2007 hannken

Use rwlock for fmi_shared_lock and fmi_lazy_lock.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: thorpej-atomic-base
# 1.7 12-Mar-2007 ad

Use mutexes/condvars.


# 1.6 12-Mar-2007 ad

branches: 1.6.2;
Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.


Revision tags: ad-audiomp-base
# 1.5 16-Feb-2007 hannken

branches: 1.5.2; 1.5.4; 1.5.8;
Make fstrans(9) the default helper for file system suspension.
Replaces the now obsolete vn_start_write()/vn_finished_write().


# 1.4 15-Feb-2007 ad

Replace some uses of lockmgr() / simplelocks.


# 1.3 10-Feb-2007 hannken

newlock2: syncer_lock is now a mutex.


Revision tags: post-newlock2-merge newlock2-base newlock2-nbase
# 1.2 29-Jan-2007 hannken

branches: 1.2.2;
Change fstrans enum types to upper case.
No functional change.

From Antti Kantee <pooka@netbsd.org>


# 1.1 19-Jan-2007 hannken

New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

The new API is enabled on a kernel option NEWVNGATE. This option is
not enabled by default in any kernel config.

Presented and discussed on tech-kern with much input from
Bill Studenmund <wrstuden@netbsd.org> and YAMAMOTO Takashi <yamt@netbsd.org>.

Welcome to 4.99.9 (new vfs op vfs_suspendctl).


# 1.48 18-Jun-2017 hannken

Make the fast path of fstrans_get_lwp_info() "static inline".


# 1.47 18-Jun-2017 hannken

Clear fstrans entries whose mount is gone from the last fstrans_done() only.


# 1.46 04-Jun-2017 hannken

Operations fstrans_start() and fstrans_start_nowait() now always
use FSTRANS_SHARED as lock type so remove the lock type argument.

File system state FSTRANS_SUSPENDING is now unused so remove it.

Regen vnode_if files.

Ride 8.99.1 less than a hour ago.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.45 07-May-2017 hannken

branches: 1.45.2;
Move fstrans initialization to vfs_mountalloc().


# 1.44 07-May-2017 hannken

Handle the case where the mount is gone and its mnt_transinfo is NULL.


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1
# 1.43 17-Apr-2017 hannken

branches: 1.43.2;
Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.


# 1.42 17-Apr-2017 hannken

Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount. Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).


# 1.41 12-Apr-2017 hannken

Switch fstrans_dump() to _mountlist_next().


Revision tags: jdolecek-ncq-base
# 1.40 30-Mar-2017 hannken

Change _fstrans_start() to allocate per lwp info for layered file
systems to get a reference on the mount.

Set mnt_lower on successfull mount only.


Revision tags: pgoyette-localcount-20170320
# 1.39 06-Mar-2017 hannken

Always use the lowest mount for fstrans and suspend. This way we
enter/leave or suspend/resume the stack of layered file systems as a unit.


# 1.38 02-Mar-2017 hannken

Add an operation to test a mount for fstrans support and use it for
_fstrans_start(), fstrans_done(), fstrans_is_owner(), vfs_suspend()
and vfs_resume().

Test for fstrans support before ASSERT_SLEEPABLE().


# 1.37 23-Feb-2017 hannken

Test for fstrans support before trying to allocate per-thread info.

PR kern/51996 (kmem_alloc called from intr context in fstrans_get_lwp_info)


# 1.36 17-Feb-2017 hannken

Let syncer try fstrans_start() before running VFS_SYNC() to get rid
of the syncer lock/unlock from vfs_suspend().


# 1.35 17-Feb-2017 hannken

Protect attaching and detaching lwp_info to mount with a mutex.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.34 24-Aug-2015 pooka

branches: 1.34.2; 1.34.4;
to garnish, dust with _KERNEL_OPT


Revision tags: nick-nhusb-base-20150606
# 1.33 06-May-2015 hannken

Remove miscfs/syncfs and

- move the syncer into kern/vfs_subr.c.

- change the syncer to process the mountlist and VFS_SYNC as appropriate.

- use an API for mount points similiar to the API for vnodes:
- vfs_syncer_add_to_worklist(struct mount *mp) to add
- vfs_syncer_remove_from_worklist(struct mount *mp) to remove a mount.

No objections on tech-kern@


# 1.32 21-Apr-2015 pooka

Don't check if constant-sized KM_SLEEP allocations succeeded.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.31 05-Sep-2014 matt

branches: 1.31.2;
Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.


Revision tags: netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.30 15-Apr-2014 hannken

Fix a deadlock where one thread exits, enters fstrans_lwp_dtor()
and wants fstrans_lock. This thread holds the proc_lock.
Another thread holds fstrans_lock and runs pserialize_perform().
As the first thread holds the proc_lock, timeouts are blocked and
the second thread blocks forever in kpause().

Change fstrans_lwp_dtor() to invalidate, but not free its info
structs. No need to take fstrans_lock.

Change fstrans_get_lwp_info() to reuse invalidated info before
trying to allocate a new one.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.29 23-Nov-2013 christos

branches: 1.29.2;
change the mountlist CIRCLEQ into a TAILQ


# 1.28 25-Oct-2013 martin

Mark diagnostic-only variables


# 1.27 30-Sep-2013 hannken

Replace macro v_specmountpoint with two functions spec_node_getmountedfs()
and spec_node_setmountedfs() to manage the file system mounted on a device.
Assert the device is a block device.

Welcome to 6.99.24

Discussed on tech-kern@ some time ago.

Reviewed by: David Holland <dholland@netbsd.org>


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.26 21-Jan-2013 hannken

branches: 1.26.2;
Replace the rwlock based implementation with passive serialization
from pserialize(9) and mutex / condvar.

The fast paths (fstrans_start/fstrans_done on a file system not
suspended or suspending and fscow_run with no change pending) now
run without locks or other atomic operations. Suspension and cow
handler insertion and removal is done with mutex / condvars.

The API remains unchanged.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 1.25 12-May-2009 yamt

branches: 1.25.12; 1.25.22;
don't forget to skip marker processes.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.24 16-Nov-2008 pooka

branches: 1.24.4;
more <sys/buf.h> police


Revision tags: netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3
# 1.23 17-Sep-2008 hannken

branches: 1.23.2; 1.23.4; 1.23.6;
Replace the fss unmount hook with a vfs_hook.

fssvar.h: struct device * -> device_t.
fss.c: establish unmount hook on first attach, remove on last detach.
vfs_syscalls.c: remove the call of fss_umount_hook().
vfs_trans.c: destroy cow handlers on unmount as fstrans_unmount() will be
called before vfs_hooks.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.22 24-Jun-2008 ad

branches: 1.22.2;
Use pool_cache.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 16-May-2008 hannken

branches: 1.21.2;
Remove a bad assertion from last commit.
Non bufcache buffers may have BC_BUSY unset.


# 1.20 16-May-2008 hannken

Fscow_run() may recurse into itself.
Take care by adding a per-lwp recursion counter.


Revision tags: yamt-nfs-mp-base2
# 1.19 28-Apr-2008 martin

branches: 1.19.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.18 17-Mar-2008 yamt

branches: 1.18.2; 1.18.4;
- simplify ASSERT_SLEEPABLE.
- move it from proc.h to systm.h.
- add some more checks.
- make it a little more lkm friendly.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 1.17 02-Feb-2008 hannken

branches: 1.17.2; 1.17.6;
BO_COWDONE -> B_COWDONE: this flag is tested/modified from the thread owning
the buffer and therefore needs no protection by a mutex.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.16 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.15 02-Dec-2007 hannken

branches: 1.15.2; 1.15.6;
Fscow_run(): add a flag "bool data_valid" to note still valid data.
Buffers run through copy-on-write are marked B_COWDONE. This condition
is valid until the buffer has run through bwrite() and gets cleared from
biodone().

Welcome to 4.99.39.

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.14 08-Oct-2007 hannken

branches: 1.14.4;
fscow_run(): Check for NULL mount and don't run the cow handler in this case.


# 1.13 07-Oct-2007 hannken

Remove an include committed by accident.

From Chris Ross via current-users.


# 1.12 07-Oct-2007 hannken

Update the file system copy-on-write handler.

- Instead of hooking the handler on the specdev of a mounted file system
hook directly on the `struct mount'.

- Rename from `vn_cow_*' to `fscow_*' and move to `kern/vfs_trans.c'. Use
`mount_*specific' instead of clobbering `struct mount' or `struct specinfo'.

- Replace the hand-made reader/writer lock with a krwlock.

- Keep `vn_cow_*' functions and mark as obsolete.

- Welcome to NetBSD 4.99.32 - `struct specinfo' changed size.

Reviewed by: Jason Thorpe <thorpej@netbsd.org>


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.11 26-Jul-2007 pooka

branches: 1.11.4; 1.11.6; 1.11.8; 1.11.10;
Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.10 09-Jul-2007 ad

branches: 1.10.2;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8
# 1.9 17-May-2007 hannken

Fstrans_start() always returns zero, so change its type to void.


# 1.8 16-May-2007 hannken

Use rwlock for fmi_shared_lock and fmi_lazy_lock.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: thorpej-atomic-base
# 1.7 12-Mar-2007 ad

Use mutexes/condvars.


# 1.6 12-Mar-2007 ad

branches: 1.6.2;
Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.


Revision tags: ad-audiomp-base
# 1.5 16-Feb-2007 hannken

branches: 1.5.2; 1.5.4; 1.5.8;
Make fstrans(9) the default helper for file system suspension.
Replaces the now obsolete vn_start_write()/vn_finished_write().


# 1.4 15-Feb-2007 ad

Replace some uses of lockmgr() / simplelocks.


# 1.3 10-Feb-2007 hannken

newlock2: syncer_lock is now a mutex.


Revision tags: post-newlock2-merge newlock2-base newlock2-nbase
# 1.2 29-Jan-2007 hannken

branches: 1.2.2;
Change fstrans enum types to upper case.
No functional change.

From Antti Kantee <pooka@netbsd.org>


# 1.1 19-Jan-2007 hannken

New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

The new API is enabled on a kernel option NEWVNGATE. This option is
not enabled by default in any kernel config.

Presented and discussed on tech-kern with much input from
Bill Studenmund <wrstuden@netbsd.org> and YAMAMOTO Takashi <yamt@netbsd.org>.

Welcome to 4.99.9 (new vfs op vfs_suspendctl).


# 1.46 04-Jun-2017 hannken

Operations fstrans_start() and fstrans_start_nowait() now always
use FSTRANS_SHARED as lock type so remove the lock type argument.

File system state FSTRANS_SUSPENDING is now unused so remove it.

Regen vnode_if files.

Ride 8.99.1 less than a hour ago.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.45 07-May-2017 hannken

branches: 1.45.2;
Move fstrans initialization to vfs_mountalloc().


# 1.44 07-May-2017 hannken

Handle the case where the mount is gone and its mnt_transinfo is NULL.


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1
# 1.43 17-Apr-2017 hannken

branches: 1.43.2;
Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.


# 1.42 17-Apr-2017 hannken

Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount. Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).


# 1.41 12-Apr-2017 hannken

Switch fstrans_dump() to _mountlist_next().


Revision tags: jdolecek-ncq-base
# 1.40 30-Mar-2017 hannken

Change _fstrans_start() to allocate per lwp info for layered file
systems to get a reference on the mount.

Set mnt_lower on successfull mount only.


Revision tags: pgoyette-localcount-20170320
# 1.39 06-Mar-2017 hannken

Always use the lowest mount for fstrans and suspend. This way we
enter/leave or suspend/resume the stack of layered file systems as a unit.


# 1.38 02-Mar-2017 hannken

Add an operation to test a mount for fstrans support and use it for
_fstrans_start(), fstrans_done(), fstrans_is_owner(), vfs_suspend()
and vfs_resume().

Test for fstrans support before ASSERT_SLEEPABLE().


# 1.37 23-Feb-2017 hannken

Test for fstrans support before trying to allocate per-thread info.

PR kern/51996 (kmem_alloc called from intr context in fstrans_get_lwp_info)


# 1.36 17-Feb-2017 hannken

Let syncer try fstrans_start() before running VFS_SYNC() to get rid
of the syncer lock/unlock from vfs_suspend().


# 1.35 17-Feb-2017 hannken

Protect attaching and detaching lwp_info to mount with a mutex.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.34 24-Aug-2015 pooka

branches: 1.34.2; 1.34.4;
to garnish, dust with _KERNEL_OPT


Revision tags: nick-nhusb-base-20150606
# 1.33 06-May-2015 hannken

Remove miscfs/syncfs and

- move the syncer into kern/vfs_subr.c.

- change the syncer to process the mountlist and VFS_SYNC as appropriate.

- use an API for mount points similiar to the API for vnodes:
- vfs_syncer_add_to_worklist(struct mount *mp) to add
- vfs_syncer_remove_from_worklist(struct mount *mp) to remove a mount.

No objections on tech-kern@


# 1.32 21-Apr-2015 pooka

Don't check if constant-sized KM_SLEEP allocations succeeded.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.31 05-Sep-2014 matt

branches: 1.31.2;
Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.


Revision tags: netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.30 15-Apr-2014 hannken

Fix a deadlock where one thread exits, enters fstrans_lwp_dtor()
and wants fstrans_lock. This thread holds the proc_lock.
Another thread holds fstrans_lock and runs pserialize_perform().
As the first thread holds the proc_lock, timeouts are blocked and
the second thread blocks forever in kpause().

Change fstrans_lwp_dtor() to invalidate, but not free its info
structs. No need to take fstrans_lock.

Change fstrans_get_lwp_info() to reuse invalidated info before
trying to allocate a new one.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.29 23-Nov-2013 christos

branches: 1.29.2;
change the mountlist CIRCLEQ into a TAILQ


# 1.28 25-Oct-2013 martin

Mark diagnostic-only variables


# 1.27 30-Sep-2013 hannken

Replace macro v_specmountpoint with two functions spec_node_getmountedfs()
and spec_node_setmountedfs() to manage the file system mounted on a device.
Assert the device is a block device.

Welcome to 6.99.24

Discussed on tech-kern@ some time ago.

Reviewed by: David Holland <dholland@netbsd.org>


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.26 21-Jan-2013 hannken

branches: 1.26.2;
Replace the rwlock based implementation with passive serialization
from pserialize(9) and mutex / condvar.

The fast paths (fstrans_start/fstrans_done on a file system not
suspended or suspending and fscow_run with no change pending) now
run without locks or other atomic operations. Suspension and cow
handler insertion and removal is done with mutex / condvars.

The API remains unchanged.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 1.25 12-May-2009 yamt

branches: 1.25.12; 1.25.22;
don't forget to skip marker processes.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.24 16-Nov-2008 pooka

branches: 1.24.4;
more <sys/buf.h> police


Revision tags: netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3
# 1.23 17-Sep-2008 hannken

branches: 1.23.2; 1.23.4; 1.23.6;
Replace the fss unmount hook with a vfs_hook.

fssvar.h: struct device * -> device_t.
fss.c: establish unmount hook on first attach, remove on last detach.
vfs_syscalls.c: remove the call of fss_umount_hook().
vfs_trans.c: destroy cow handlers on unmount as fstrans_unmount() will be
called before vfs_hooks.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.22 24-Jun-2008 ad

branches: 1.22.2;
Use pool_cache.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 16-May-2008 hannken

branches: 1.21.2;
Remove a bad assertion from last commit.
Non bufcache buffers may have BC_BUSY unset.


# 1.20 16-May-2008 hannken

Fscow_run() may recurse into itself.
Take care by adding a per-lwp recursion counter.


Revision tags: yamt-nfs-mp-base2
# 1.19 28-Apr-2008 martin

branches: 1.19.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.18 17-Mar-2008 yamt

branches: 1.18.2; 1.18.4;
- simplify ASSERT_SLEEPABLE.
- move it from proc.h to systm.h.
- add some more checks.
- make it a little more lkm friendly.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 1.17 02-Feb-2008 hannken

branches: 1.17.2; 1.17.6;
BO_COWDONE -> B_COWDONE: this flag is tested/modified from the thread owning
the buffer and therefore needs no protection by a mutex.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.16 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.15 02-Dec-2007 hannken

branches: 1.15.2; 1.15.6;
Fscow_run(): add a flag "bool data_valid" to note still valid data.
Buffers run through copy-on-write are marked B_COWDONE. This condition
is valid until the buffer has run through bwrite() and gets cleared from
biodone().

Welcome to 4.99.39.

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.14 08-Oct-2007 hannken

branches: 1.14.4;
fscow_run(): Check for NULL mount and don't run the cow handler in this case.


# 1.13 07-Oct-2007 hannken

Remove an include committed by accident.

From Chris Ross via current-users.


# 1.12 07-Oct-2007 hannken

Update the file system copy-on-write handler.

- Instead of hooking the handler on the specdev of a mounted file system
hook directly on the `struct mount'.

- Rename from `vn_cow_*' to `fscow_*' and move to `kern/vfs_trans.c'. Use
`mount_*specific' instead of clobbering `struct mount' or `struct specinfo'.

- Replace the hand-made reader/writer lock with a krwlock.

- Keep `vn_cow_*' functions and mark as obsolete.

- Welcome to NetBSD 4.99.32 - `struct specinfo' changed size.

Reviewed by: Jason Thorpe <thorpej@netbsd.org>


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.11 26-Jul-2007 pooka

branches: 1.11.4; 1.11.6; 1.11.8; 1.11.10;
Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.10 09-Jul-2007 ad

branches: 1.10.2;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8
# 1.9 17-May-2007 hannken

Fstrans_start() always returns zero, so change its type to void.


# 1.8 16-May-2007 hannken

Use rwlock for fmi_shared_lock and fmi_lazy_lock.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: thorpej-atomic-base
# 1.7 12-Mar-2007 ad

Use mutexes/condvars.


# 1.6 12-Mar-2007 ad

branches: 1.6.2;
Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.


Revision tags: ad-audiomp-base
# 1.5 16-Feb-2007 hannken

branches: 1.5.2; 1.5.4; 1.5.8;
Make fstrans(9) the default helper for file system suspension.
Replaces the now obsolete vn_start_write()/vn_finished_write().


# 1.4 15-Feb-2007 ad

Replace some uses of lockmgr() / simplelocks.


# 1.3 10-Feb-2007 hannken

newlock2: syncer_lock is now a mutex.


Revision tags: post-newlock2-merge newlock2-base newlock2-nbase
# 1.2 29-Jan-2007 hannken

branches: 1.2.2;
Change fstrans enum types to upper case.
No functional change.

From Antti Kantee <pooka@netbsd.org>


# 1.1 19-Jan-2007 hannken

New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

The new API is enabled on a kernel option NEWVNGATE. This option is
not enabled by default in any kernel config.

Presented and discussed on tech-kern with much input from
Bill Studenmund <wrstuden@netbsd.org> and YAMAMOTO Takashi <yamt@netbsd.org>.

Welcome to 4.99.9 (new vfs op vfs_suspendctl).


# 1.45 07-May-2017 hannken

Move fstrans initialization to vfs_mountalloc().


# 1.44 07-May-2017 hannken

Handle the case where the mount is gone and its mnt_transinfo is NULL.


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1
# 1.43 17-Apr-2017 hannken

Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.


# 1.42 17-Apr-2017 hannken

Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount. Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).


# 1.41 12-Apr-2017 hannken

Switch fstrans_dump() to _mountlist_next().


Revision tags: jdolecek-ncq-base
# 1.40 30-Mar-2017 hannken

Change _fstrans_start() to allocate per lwp info for layered file
systems to get a reference on the mount.

Set mnt_lower on successfull mount only.


Revision tags: pgoyette-localcount-20170320
# 1.39 06-Mar-2017 hannken

Always use the lowest mount for fstrans and suspend. This way we
enter/leave or suspend/resume the stack of layered file systems as a unit.


# 1.38 02-Mar-2017 hannken

Add an operation to test a mount for fstrans support and use it for
_fstrans_start(), fstrans_done(), fstrans_is_owner(), vfs_suspend()
and vfs_resume().

Test for fstrans support before ASSERT_SLEEPABLE().


# 1.37 23-Feb-2017 hannken

Test for fstrans support before trying to allocate per-thread info.

PR kern/51996 (kmem_alloc called from intr context in fstrans_get_lwp_info)


# 1.36 17-Feb-2017 hannken

Let syncer try fstrans_start() before running VFS_SYNC() to get rid
of the syncer lock/unlock from vfs_suspend().


# 1.35 17-Feb-2017 hannken

Protect attaching and detaching lwp_info to mount with a mutex.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.34 24-Aug-2015 pooka

branches: 1.34.2; 1.34.4;
to garnish, dust with _KERNEL_OPT


Revision tags: nick-nhusb-base-20150606
# 1.33 06-May-2015 hannken

Remove miscfs/syncfs and

- move the syncer into kern/vfs_subr.c.

- change the syncer to process the mountlist and VFS_SYNC as appropriate.

- use an API for mount points similiar to the API for vnodes:
- vfs_syncer_add_to_worklist(struct mount *mp) to add
- vfs_syncer_remove_from_worklist(struct mount *mp) to remove a mount.

No objections on tech-kern@


# 1.32 21-Apr-2015 pooka

Don't check if constant-sized KM_SLEEP allocations succeeded.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.31 05-Sep-2014 matt

branches: 1.31.2;
Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.


Revision tags: netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.30 15-Apr-2014 hannken

Fix a deadlock where one thread exits, enters fstrans_lwp_dtor()
and wants fstrans_lock. This thread holds the proc_lock.
Another thread holds fstrans_lock and runs pserialize_perform().
As the first thread holds the proc_lock, timeouts are blocked and
the second thread blocks forever in kpause().

Change fstrans_lwp_dtor() to invalidate, but not free its info
structs. No need to take fstrans_lock.

Change fstrans_get_lwp_info() to reuse invalidated info before
trying to allocate a new one.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.29 23-Nov-2013 christos

branches: 1.29.2;
change the mountlist CIRCLEQ into a TAILQ


# 1.28 25-Oct-2013 martin

Mark diagnostic-only variables


# 1.27 30-Sep-2013 hannken

Replace macro v_specmountpoint with two functions spec_node_getmountedfs()
and spec_node_setmountedfs() to manage the file system mounted on a device.
Assert the device is a block device.

Welcome to 6.99.24

Discussed on tech-kern@ some time ago.

Reviewed by: David Holland <dholland@netbsd.org>


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.26 21-Jan-2013 hannken

branches: 1.26.2;
Replace the rwlock based implementation with passive serialization
from pserialize(9) and mutex / condvar.

The fast paths (fstrans_start/fstrans_done on a file system not
suspended or suspending and fscow_run with no change pending) now
run without locks or other atomic operations. Suspension and cow
handler insertion and removal is done with mutex / condvars.

The API remains unchanged.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 1.25 12-May-2009 yamt

branches: 1.25.12; 1.25.22;
don't forget to skip marker processes.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.24 16-Nov-2008 pooka

branches: 1.24.4;
more <sys/buf.h> police


Revision tags: netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3
# 1.23 17-Sep-2008 hannken

branches: 1.23.2; 1.23.4; 1.23.6;
Replace the fss unmount hook with a vfs_hook.

fssvar.h: struct device * -> device_t.
fss.c: establish unmount hook on first attach, remove on last detach.
vfs_syscalls.c: remove the call of fss_umount_hook().
vfs_trans.c: destroy cow handlers on unmount as fstrans_unmount() will be
called before vfs_hooks.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.22 24-Jun-2008 ad

branches: 1.22.2;
Use pool_cache.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 16-May-2008 hannken

branches: 1.21.2;
Remove a bad assertion from last commit.
Non bufcache buffers may have BC_BUSY unset.


# 1.20 16-May-2008 hannken

Fscow_run() may recurse into itself.
Take care by adding a per-lwp recursion counter.


Revision tags: yamt-nfs-mp-base2
# 1.19 28-Apr-2008 martin

branches: 1.19.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.18 17-Mar-2008 yamt

branches: 1.18.2; 1.18.4;
- simplify ASSERT_SLEEPABLE.
- move it from proc.h to systm.h.
- add some more checks.
- make it a little more lkm friendly.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 1.17 02-Feb-2008 hannken

branches: 1.17.2; 1.17.6;
BO_COWDONE -> B_COWDONE: this flag is tested/modified from the thread owning
the buffer and therefore needs no protection by a mutex.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.16 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.15 02-Dec-2007 hannken

branches: 1.15.2; 1.15.6;
Fscow_run(): add a flag "bool data_valid" to note still valid data.
Buffers run through copy-on-write are marked B_COWDONE. This condition
is valid until the buffer has run through bwrite() and gets cleared from
biodone().

Welcome to 4.99.39.

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.14 08-Oct-2007 hannken

branches: 1.14.4;
fscow_run(): Check for NULL mount and don't run the cow handler in this case.


# 1.13 07-Oct-2007 hannken

Remove an include committed by accident.

From Chris Ross via current-users.


# 1.12 07-Oct-2007 hannken

Update the file system copy-on-write handler.

- Instead of hooking the handler on the specdev of a mounted file system
hook directly on the `struct mount'.

- Rename from `vn_cow_*' to `fscow_*' and move to `kern/vfs_trans.c'. Use
`mount_*specific' instead of clobbering `struct mount' or `struct specinfo'.

- Replace the hand-made reader/writer lock with a krwlock.

- Keep `vn_cow_*' functions and mark as obsolete.

- Welcome to NetBSD 4.99.32 - `struct specinfo' changed size.

Reviewed by: Jason Thorpe <thorpej@netbsd.org>


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.11 26-Jul-2007 pooka

branches: 1.11.4; 1.11.6; 1.11.8; 1.11.10;
Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.10 09-Jul-2007 ad

branches: 1.10.2;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8
# 1.9 17-May-2007 hannken

Fstrans_start() always returns zero, so change its type to void.


# 1.8 16-May-2007 hannken

Use rwlock for fmi_shared_lock and fmi_lazy_lock.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: thorpej-atomic-base
# 1.7 12-Mar-2007 ad

Use mutexes/condvars.


# 1.6 12-Mar-2007 ad

branches: 1.6.2;
Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.


Revision tags: ad-audiomp-base
# 1.5 16-Feb-2007 hannken

branches: 1.5.2; 1.5.4; 1.5.8;
Make fstrans(9) the default helper for file system suspension.
Replaces the now obsolete vn_start_write()/vn_finished_write().


# 1.4 15-Feb-2007 ad

Replace some uses of lockmgr() / simplelocks.


# 1.3 10-Feb-2007 hannken

newlock2: syncer_lock is now a mutex.


Revision tags: post-newlock2-merge newlock2-base newlock2-nbase
# 1.2 29-Jan-2007 hannken

branches: 1.2.2;
Change fstrans enum types to upper case.
No functional change.

From Antti Kantee <pooka@netbsd.org>


# 1.1 19-Jan-2007 hannken

New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

The new API is enabled on a kernel option NEWVNGATE. This option is
not enabled by default in any kernel config.

Presented and discussed on tech-kern with much input from
Bill Studenmund <wrstuden@netbsd.org> and YAMAMOTO Takashi <yamt@netbsd.org>.

Welcome to 4.99.9 (new vfs op vfs_suspendctl).


Revision tags: prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1
# 1.43 17-Apr-2017 hannken

Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.


# 1.42 17-Apr-2017 hannken

Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount. Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).


# 1.41 12-Apr-2017 hannken

Switch fstrans_dump() to _mountlist_next().


Revision tags: jdolecek-ncq-base
# 1.40 30-Mar-2017 hannken

Change _fstrans_start() to allocate per lwp info for layered file
systems to get a reference on the mount.

Set mnt_lower on successfull mount only.


Revision tags: pgoyette-localcount-20170320
# 1.39 06-Mar-2017 hannken

Always use the lowest mount for fstrans and suspend. This way we
enter/leave or suspend/resume the stack of layered file systems as a unit.


# 1.38 02-Mar-2017 hannken

Add an operation to test a mount for fstrans support and use it for
_fstrans_start(), fstrans_done(), fstrans_is_owner(), vfs_suspend()
and vfs_resume().

Test for fstrans support before ASSERT_SLEEPABLE().


# 1.37 23-Feb-2017 hannken

Test for fstrans support before trying to allocate per-thread info.

PR kern/51996 (kmem_alloc called from intr context in fstrans_get_lwp_info)


# 1.36 17-Feb-2017 hannken

Let syncer try fstrans_start() before running VFS_SYNC() to get rid
of the syncer lock/unlock from vfs_suspend().


# 1.35 17-Feb-2017 hannken

Protect attaching and detaching lwp_info to mount with a mutex.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.34 24-Aug-2015 pooka

branches: 1.34.2; 1.34.4;
to garnish, dust with _KERNEL_OPT


Revision tags: nick-nhusb-base-20150606
# 1.33 06-May-2015 hannken

Remove miscfs/syncfs and

- move the syncer into kern/vfs_subr.c.

- change the syncer to process the mountlist and VFS_SYNC as appropriate.

- use an API for mount points similiar to the API for vnodes:
- vfs_syncer_add_to_worklist(struct mount *mp) to add
- vfs_syncer_remove_from_worklist(struct mount *mp) to remove a mount.

No objections on tech-kern@


# 1.32 21-Apr-2015 pooka

Don't check if constant-sized KM_SLEEP allocations succeeded.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.31 05-Sep-2014 matt

branches: 1.31.2;
Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.


Revision tags: netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.30 15-Apr-2014 hannken

Fix a deadlock where one thread exits, enters fstrans_lwp_dtor()
and wants fstrans_lock. This thread holds the proc_lock.
Another thread holds fstrans_lock and runs pserialize_perform().
As the first thread holds the proc_lock, timeouts are blocked and
the second thread blocks forever in kpause().

Change fstrans_lwp_dtor() to invalidate, but not free its info
structs. No need to take fstrans_lock.

Change fstrans_get_lwp_info() to reuse invalidated info before
trying to allocate a new one.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.29 23-Nov-2013 christos

branches: 1.29.2;
change the mountlist CIRCLEQ into a TAILQ


# 1.28 25-Oct-2013 martin

Mark diagnostic-only variables


# 1.27 30-Sep-2013 hannken

Replace macro v_specmountpoint with two functions spec_node_getmountedfs()
and spec_node_setmountedfs() to manage the file system mounted on a device.
Assert the device is a block device.

Welcome to 6.99.24

Discussed on tech-kern@ some time ago.

Reviewed by: David Holland <dholland@netbsd.org>


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.26 21-Jan-2013 hannken

branches: 1.26.2;
Replace the rwlock based implementation with passive serialization
from pserialize(9) and mutex / condvar.

The fast paths (fstrans_start/fstrans_done on a file system not
suspended or suspending and fscow_run with no change pending) now
run without locks or other atomic operations. Suspension and cow
handler insertion and removal is done with mutex / condvars.

The API remains unchanged.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 1.25 12-May-2009 yamt

branches: 1.25.12; 1.25.22;
don't forget to skip marker processes.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.24 16-Nov-2008 pooka

branches: 1.24.4;
more <sys/buf.h> police


Revision tags: netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3
# 1.23 17-Sep-2008 hannken

branches: 1.23.2; 1.23.4; 1.23.6;
Replace the fss unmount hook with a vfs_hook.

fssvar.h: struct device * -> device_t.
fss.c: establish unmount hook on first attach, remove on last detach.
vfs_syscalls.c: remove the call of fss_umount_hook().
vfs_trans.c: destroy cow handlers on unmount as fstrans_unmount() will be
called before vfs_hooks.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.22 24-Jun-2008 ad

branches: 1.22.2;
Use pool_cache.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 16-May-2008 hannken

branches: 1.21.2;
Remove a bad assertion from last commit.
Non bufcache buffers may have BC_BUSY unset.


# 1.20 16-May-2008 hannken

Fscow_run() may recurse into itself.
Take care by adding a per-lwp recursion counter.


Revision tags: yamt-nfs-mp-base2
# 1.19 28-Apr-2008 martin

branches: 1.19.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.18 17-Mar-2008 yamt

branches: 1.18.2; 1.18.4;
- simplify ASSERT_SLEEPABLE.
- move it from proc.h to systm.h.
- add some more checks.
- make it a little more lkm friendly.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 1.17 02-Feb-2008 hannken

branches: 1.17.2; 1.17.6;
BO_COWDONE -> B_COWDONE: this flag is tested/modified from the thread owning
the buffer and therefore needs no protection by a mutex.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.16 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.15 02-Dec-2007 hannken

branches: 1.15.2; 1.15.6;
Fscow_run(): add a flag "bool data_valid" to note still valid data.
Buffers run through copy-on-write are marked B_COWDONE. This condition
is valid until the buffer has run through bwrite() and gets cleared from
biodone().

Welcome to 4.99.39.

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.14 08-Oct-2007 hannken

branches: 1.14.4;
fscow_run(): Check for NULL mount and don't run the cow handler in this case.


# 1.13 07-Oct-2007 hannken

Remove an include committed by accident.

From Chris Ross via current-users.


# 1.12 07-Oct-2007 hannken

Update the file system copy-on-write handler.

- Instead of hooking the handler on the specdev of a mounted file system
hook directly on the `struct mount'.

- Rename from `vn_cow_*' to `fscow_*' and move to `kern/vfs_trans.c'. Use
`mount_*specific' instead of clobbering `struct mount' or `struct specinfo'.

- Replace the hand-made reader/writer lock with a krwlock.

- Keep `vn_cow_*' functions and mark as obsolete.

- Welcome to NetBSD 4.99.32 - `struct specinfo' changed size.

Reviewed by: Jason Thorpe <thorpej@netbsd.org>


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.11 26-Jul-2007 pooka

branches: 1.11.4; 1.11.6; 1.11.8; 1.11.10;
Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.10 09-Jul-2007 ad

branches: 1.10.2;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8
# 1.9 17-May-2007 hannken

Fstrans_start() always returns zero, so change its type to void.


# 1.8 16-May-2007 hannken

Use rwlock for fmi_shared_lock and fmi_lazy_lock.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: thorpej-atomic-base
# 1.7 12-Mar-2007 ad

Use mutexes/condvars.


# 1.6 12-Mar-2007 ad

branches: 1.6.2;
Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.


Revision tags: ad-audiomp-base
# 1.5 16-Feb-2007 hannken

branches: 1.5.2; 1.5.4; 1.5.8;
Make fstrans(9) the default helper for file system suspension.
Replaces the now obsolete vn_start_write()/vn_finished_write().


# 1.4 15-Feb-2007 ad

Replace some uses of lockmgr() / simplelocks.


# 1.3 10-Feb-2007 hannken

newlock2: syncer_lock is now a mutex.


Revision tags: post-newlock2-merge newlock2-base newlock2-nbase
# 1.2 29-Jan-2007 hannken

branches: 1.2.2;
Change fstrans enum types to upper case.
No functional change.

From Antti Kantee <pooka@netbsd.org>


# 1.1 19-Jan-2007 hannken

New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

The new API is enabled on a kernel option NEWVNGATE. This option is
not enabled by default in any kernel config.

Presented and discussed on tech-kern with much input from
Bill Studenmund <wrstuden@netbsd.org> and YAMAMOTO Takashi <yamt@netbsd.org>.

Welcome to 4.99.9 (new vfs op vfs_suspendctl).


# 1.39 06-Mar-2017 hannken

Always use the lowest mount for fstrans and suspend. This way we
enter/leave or suspend/resume the stack of layered file systems as a unit.


# 1.38 02-Mar-2017 hannken

Add an operation to test a mount for fstrans support and use it for
_fstrans_start(), fstrans_done(), fstrans_is_owner(), vfs_suspend()
and vfs_resume().

Test for fstrans support before ASSERT_SLEEPABLE().


# 1.37 23-Feb-2017 hannken

Test for fstrans support before trying to allocate per-thread info.

PR kern/51996 (kmem_alloc called from intr context in fstrans_get_lwp_info)


# 1.36 17-Feb-2017 hannken

Let syncer try fstrans_start() before running VFS_SYNC() to get rid
of the syncer lock/unlock from vfs_suspend().


# 1.35 17-Feb-2017 hannken

Protect attaching and detaching lwp_info to mount with a mutex.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.34 24-Aug-2015 pooka

to garnish, dust with _KERNEL_OPT


Revision tags: nick-nhusb-base-20150606
# 1.33 06-May-2015 hannken

Remove miscfs/syncfs and

- move the syncer into kern/vfs_subr.c.

- change the syncer to process the mountlist and VFS_SYNC as appropriate.

- use an API for mount points similiar to the API for vnodes:
- vfs_syncer_add_to_worklist(struct mount *mp) to add
- vfs_syncer_remove_from_worklist(struct mount *mp) to remove a mount.

No objections on tech-kern@


# 1.32 21-Apr-2015 pooka

Don't check if constant-sized KM_SLEEP allocations succeeded.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.31 05-Sep-2014 matt

branches: 1.31.2;
Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.


Revision tags: netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.30 15-Apr-2014 hannken

Fix a deadlock where one thread exits, enters fstrans_lwp_dtor()
and wants fstrans_lock. This thread holds the proc_lock.
Another thread holds fstrans_lock and runs pserialize_perform().
As the first thread holds the proc_lock, timeouts are blocked and
the second thread blocks forever in kpause().

Change fstrans_lwp_dtor() to invalidate, but not free its info
structs. No need to take fstrans_lock.

Change fstrans_get_lwp_info() to reuse invalidated info before
trying to allocate a new one.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.29 23-Nov-2013 christos

branches: 1.29.2;
change the mountlist CIRCLEQ into a TAILQ


# 1.28 25-Oct-2013 martin

Mark diagnostic-only variables


# 1.27 30-Sep-2013 hannken

Replace macro v_specmountpoint with two functions spec_node_getmountedfs()
and spec_node_setmountedfs() to manage the file system mounted on a device.
Assert the device is a block device.

Welcome to 6.99.24

Discussed on tech-kern@ some time ago.

Reviewed by: David Holland <dholland@netbsd.org>


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.26 21-Jan-2013 hannken

branches: 1.26.2;
Replace the rwlock based implementation with passive serialization
from pserialize(9) and mutex / condvar.

The fast paths (fstrans_start/fstrans_done on a file system not
suspended or suspending and fscow_run with no change pending) now
run without locks or other atomic operations. Suspension and cow
handler insertion and removal is done with mutex / condvars.

The API remains unchanged.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 1.25 12-May-2009 yamt

branches: 1.25.12; 1.25.22;
don't forget to skip marker processes.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.24 16-Nov-2008 pooka

branches: 1.24.4;
more <sys/buf.h> police


Revision tags: netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3
# 1.23 17-Sep-2008 hannken

branches: 1.23.2; 1.23.4; 1.23.6;
Replace the fss unmount hook with a vfs_hook.

fssvar.h: struct device * -> device_t.
fss.c: establish unmount hook on first attach, remove on last detach.
vfs_syscalls.c: remove the call of fss_umount_hook().
vfs_trans.c: destroy cow handlers on unmount as fstrans_unmount() will be
called before vfs_hooks.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.22 24-Jun-2008 ad

branches: 1.22.2;
Use pool_cache.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 16-May-2008 hannken

branches: 1.21.2;
Remove a bad assertion from last commit.
Non bufcache buffers may have BC_BUSY unset.


# 1.20 16-May-2008 hannken

Fscow_run() may recurse into itself.
Take care by adding a per-lwp recursion counter.


Revision tags: yamt-nfs-mp-base2
# 1.19 28-Apr-2008 martin

branches: 1.19.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.18 17-Mar-2008 yamt

branches: 1.18.2; 1.18.4;
- simplify ASSERT_SLEEPABLE.
- move it from proc.h to systm.h.
- add some more checks.
- make it a little more lkm friendly.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 1.17 02-Feb-2008 hannken

branches: 1.17.2; 1.17.6;
BO_COWDONE -> B_COWDONE: this flag is tested/modified from the thread owning
the buffer and therefore needs no protection by a mutex.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.16 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.15 02-Dec-2007 hannken

branches: 1.15.2; 1.15.6;
Fscow_run(): add a flag "bool data_valid" to note still valid data.
Buffers run through copy-on-write are marked B_COWDONE. This condition
is valid until the buffer has run through bwrite() and gets cleared from
biodone().

Welcome to 4.99.39.

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.14 08-Oct-2007 hannken

branches: 1.14.4;
fscow_run(): Check for NULL mount and don't run the cow handler in this case.


# 1.13 07-Oct-2007 hannken

Remove an include committed by accident.

From Chris Ross via current-users.


# 1.12 07-Oct-2007 hannken

Update the file system copy-on-write handler.

- Instead of hooking the handler on the specdev of a mounted file system
hook directly on the `struct mount'.

- Rename from `vn_cow_*' to `fscow_*' and move to `kern/vfs_trans.c'. Use
`mount_*specific' instead of clobbering `struct mount' or `struct specinfo'.

- Replace the hand-made reader/writer lock with a krwlock.

- Keep `vn_cow_*' functions and mark as obsolete.

- Welcome to NetBSD 4.99.32 - `struct specinfo' changed size.

Reviewed by: Jason Thorpe <thorpej@netbsd.org>


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.11 26-Jul-2007 pooka

branches: 1.11.4; 1.11.6; 1.11.8; 1.11.10;
Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.10 09-Jul-2007 ad

branches: 1.10.2;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8
# 1.9 17-May-2007 hannken

Fstrans_start() always returns zero, so change its type to void.


# 1.8 16-May-2007 hannken

Use rwlock for fmi_shared_lock and fmi_lazy_lock.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: thorpej-atomic-base
# 1.7 12-Mar-2007 ad

Use mutexes/condvars.


# 1.6 12-Mar-2007 ad

branches: 1.6.2;
Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.


Revision tags: ad-audiomp-base
# 1.5 16-Feb-2007 hannken

branches: 1.5.2; 1.5.4; 1.5.8;
Make fstrans(9) the default helper for file system suspension.
Replaces the now obsolete vn_start_write()/vn_finished_write().


# 1.4 15-Feb-2007 ad

Replace some uses of lockmgr() / simplelocks.


# 1.3 10-Feb-2007 hannken

newlock2: syncer_lock is now a mutex.


Revision tags: post-newlock2-merge newlock2-base newlock2-nbase
# 1.2 29-Jan-2007 hannken

branches: 1.2.2;
Change fstrans enum types to upper case.
No functional change.

From Antti Kantee <pooka@netbsd.org>


# 1.1 19-Jan-2007 hannken

New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

The new API is enabled on a kernel option NEWVNGATE. This option is
not enabled by default in any kernel config.

Presented and discussed on tech-kern with much input from
Bill Studenmund <wrstuden@netbsd.org> and YAMAMOTO Takashi <yamt@netbsd.org>.

Welcome to 4.99.9 (new vfs op vfs_suspendctl).


# 1.38 02-Mar-2017 hannken

Add an operation to test a mount for fstrans support and use it for
_fstrans_start(), fstrans_done(), fstrans_is_owner(), vfs_suspend()
and vfs_resume().

Test for fstrans support before ASSERT_SLEEPABLE().


# 1.37 23-Feb-2017 hannken

Test for fstrans support before trying to allocate per-thread info.

PR kern/51996 (kmem_alloc called from intr context in fstrans_get_lwp_info)


# 1.36 17-Feb-2017 hannken

Let syncer try fstrans_start() before running VFS_SYNC() to get rid
of the syncer lock/unlock from vfs_suspend().


# 1.35 17-Feb-2017 hannken

Protect attaching and detaching lwp_info to mount with a mutex.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.34 24-Aug-2015 pooka

to garnish, dust with _KERNEL_OPT


Revision tags: nick-nhusb-base-20150606
# 1.33 06-May-2015 hannken

Remove miscfs/syncfs and

- move the syncer into kern/vfs_subr.c.

- change the syncer to process the mountlist and VFS_SYNC as appropriate.

- use an API for mount points similiar to the API for vnodes:
- vfs_syncer_add_to_worklist(struct mount *mp) to add
- vfs_syncer_remove_from_worklist(struct mount *mp) to remove a mount.

No objections on tech-kern@


# 1.32 21-Apr-2015 pooka

Don't check if constant-sized KM_SLEEP allocations succeeded.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.31 05-Sep-2014 matt

branches: 1.31.2;
Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.


Revision tags: netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.30 15-Apr-2014 hannken

Fix a deadlock where one thread exits, enters fstrans_lwp_dtor()
and wants fstrans_lock. This thread holds the proc_lock.
Another thread holds fstrans_lock and runs pserialize_perform().
As the first thread holds the proc_lock, timeouts are blocked and
the second thread blocks forever in kpause().

Change fstrans_lwp_dtor() to invalidate, but not free its info
structs. No need to take fstrans_lock.

Change fstrans_get_lwp_info() to reuse invalidated info before
trying to allocate a new one.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.29 23-Nov-2013 christos

branches: 1.29.2;
change the mountlist CIRCLEQ into a TAILQ


# 1.28 25-Oct-2013 martin

Mark diagnostic-only variables


# 1.27 30-Sep-2013 hannken

Replace macro v_specmountpoint with two functions spec_node_getmountedfs()
and spec_node_setmountedfs() to manage the file system mounted on a device.
Assert the device is a block device.

Welcome to 6.99.24

Discussed on tech-kern@ some time ago.

Reviewed by: David Holland <dholland@netbsd.org>


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.26 21-Jan-2013 hannken

branches: 1.26.2;
Replace the rwlock based implementation with passive serialization
from pserialize(9) and mutex / condvar.

The fast paths (fstrans_start/fstrans_done on a file system not
suspended or suspending and fscow_run with no change pending) now
run without locks or other atomic operations. Suspension and cow
handler insertion and removal is done with mutex / condvars.

The API remains unchanged.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 1.25 12-May-2009 yamt

branches: 1.25.12; 1.25.22;
don't forget to skip marker processes.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.24 16-Nov-2008 pooka

branches: 1.24.4;
more <sys/buf.h> police


Revision tags: netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3
# 1.23 17-Sep-2008 hannken

branches: 1.23.2; 1.23.4; 1.23.6;
Replace the fss unmount hook with a vfs_hook.

fssvar.h: struct device * -> device_t.
fss.c: establish unmount hook on first attach, remove on last detach.
vfs_syscalls.c: remove the call of fss_umount_hook().
vfs_trans.c: destroy cow handlers on unmount as fstrans_unmount() will be
called before vfs_hooks.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.22 24-Jun-2008 ad

branches: 1.22.2;
Use pool_cache.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 16-May-2008 hannken

branches: 1.21.2;
Remove a bad assertion from last commit.
Non bufcache buffers may have BC_BUSY unset.


# 1.20 16-May-2008 hannken

Fscow_run() may recurse into itself.
Take care by adding a per-lwp recursion counter.


Revision tags: yamt-nfs-mp-base2
# 1.19 28-Apr-2008 martin

branches: 1.19.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.18 17-Mar-2008 yamt

branches: 1.18.2; 1.18.4;
- simplify ASSERT_SLEEPABLE.
- move it from proc.h to systm.h.
- add some more checks.
- make it a little more lkm friendly.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 1.17 02-Feb-2008 hannken

branches: 1.17.2; 1.17.6;
BO_COWDONE -> B_COWDONE: this flag is tested/modified from the thread owning
the buffer and therefore needs no protection by a mutex.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.16 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.15 02-Dec-2007 hannken

branches: 1.15.2; 1.15.6;
Fscow_run(): add a flag "bool data_valid" to note still valid data.
Buffers run through copy-on-write are marked B_COWDONE. This condition
is valid until the buffer has run through bwrite() and gets cleared from
biodone().

Welcome to 4.99.39.

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.14 08-Oct-2007 hannken

branches: 1.14.4;
fscow_run(): Check for NULL mount and don't run the cow handler in this case.


# 1.13 07-Oct-2007 hannken

Remove an include committed by accident.

From Chris Ross via current-users.


# 1.12 07-Oct-2007 hannken

Update the file system copy-on-write handler.

- Instead of hooking the handler on the specdev of a mounted file system
hook directly on the `struct mount'.

- Rename from `vn_cow_*' to `fscow_*' and move to `kern/vfs_trans.c'. Use
`mount_*specific' instead of clobbering `struct mount' or `struct specinfo'.

- Replace the hand-made reader/writer lock with a krwlock.

- Keep `vn_cow_*' functions and mark as obsolete.

- Welcome to NetBSD 4.99.32 - `struct specinfo' changed size.

Reviewed by: Jason Thorpe <thorpej@netbsd.org>


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.11 26-Jul-2007 pooka

branches: 1.11.4; 1.11.6; 1.11.8; 1.11.10;
Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.10 09-Jul-2007 ad

branches: 1.10.2;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8
# 1.9 17-May-2007 hannken

Fstrans_start() always returns zero, so change its type to void.


# 1.8 16-May-2007 hannken

Use rwlock for fmi_shared_lock and fmi_lazy_lock.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: thorpej-atomic-base
# 1.7 12-Mar-2007 ad

Use mutexes/condvars.


# 1.6 12-Mar-2007 ad

branches: 1.6.2;
Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.


Revision tags: ad-audiomp-base
# 1.5 16-Feb-2007 hannken

branches: 1.5.2; 1.5.4; 1.5.8;
Make fstrans(9) the default helper for file system suspension.
Replaces the now obsolete vn_start_write()/vn_finished_write().


# 1.4 15-Feb-2007 ad

Replace some uses of lockmgr() / simplelocks.


# 1.3 10-Feb-2007 hannken

newlock2: syncer_lock is now a mutex.


Revision tags: post-newlock2-merge newlock2-base newlock2-nbase
# 1.2 29-Jan-2007 hannken

branches: 1.2.2;
Change fstrans enum types to upper case.
No functional change.

From Antti Kantee <pooka@netbsd.org>


# 1.1 19-Jan-2007 hannken

New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

The new API is enabled on a kernel option NEWVNGATE. This option is
not enabled by default in any kernel config.

Presented and discussed on tech-kern with much input from
Bill Studenmund <wrstuden@netbsd.org> and YAMAMOTO Takashi <yamt@netbsd.org>.

Welcome to 4.99.9 (new vfs op vfs_suspendctl).


# 1.37 23-Feb-2017 hannken

Test for fstrans support before trying to allocate per-thread info.

PR kern/51996 (kmem_alloc called from intr context in fstrans_get_lwp_info)


# 1.36 17-Feb-2017 hannken

Let syncer try fstrans_start() before running VFS_SYNC() to get rid
of the syncer lock/unlock from vfs_suspend().


# 1.35 17-Feb-2017 hannken

Protect attaching and detaching lwp_info to mount with a mutex.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.34 24-Aug-2015 pooka

to garnish, dust with _KERNEL_OPT


Revision tags: nick-nhusb-base-20150606
# 1.33 06-May-2015 hannken

Remove miscfs/syncfs and

- move the syncer into kern/vfs_subr.c.

- change the syncer to process the mountlist and VFS_SYNC as appropriate.

- use an API for mount points similiar to the API for vnodes:
- vfs_syncer_add_to_worklist(struct mount *mp) to add
- vfs_syncer_remove_from_worklist(struct mount *mp) to remove a mount.

No objections on tech-kern@


# 1.32 21-Apr-2015 pooka

Don't check if constant-sized KM_SLEEP allocations succeeded.


Revision tags: nick-nhusb-base-20150406 nick-nhusb-base
# 1.31 05-Sep-2014 matt

branches: 1.31.2;
Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.


Revision tags: netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.30 15-Apr-2014 hannken

Fix a deadlock where one thread exits, enters fstrans_lwp_dtor()
and wants fstrans_lock. This thread holds the proc_lock.
Another thread holds fstrans_lock and runs pserialize_perform().
As the first thread holds the proc_lock, timeouts are blocked and
the second thread blocks forever in kpause().

Change fstrans_lwp_dtor() to invalidate, but not free its info
structs. No need to take fstrans_lock.

Change fstrans_get_lwp_info() to reuse invalidated info before
trying to allocate a new one.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.29 23-Nov-2013 christos

branches: 1.29.2;
change the mountlist CIRCLEQ into a TAILQ


# 1.28 25-Oct-2013 martin

Mark diagnostic-only variables


# 1.27 30-Sep-2013 hannken

Replace macro v_specmountpoint with two functions spec_node_getmountedfs()
and spec_node_setmountedfs() to manage the file system mounted on a device.
Assert the device is a block device.

Welcome to 6.99.24

Discussed on tech-kern@ some time ago.

Reviewed by: David Holland <dholland@netbsd.org>


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.26 21-Jan-2013 hannken

branches: 1.26.2;
Replace the rwlock based implementation with passive serialization
from pserialize(9) and mutex / condvar.

The fast paths (fstrans_start/fstrans_done on a file system not
suspended or suspending and fscow_run with no change pending) now
run without locks or other atomic operations. Suspension and cow
handler insertion and removal is done with mutex / condvars.

The API remains unchanged.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 1.25 12-May-2009 yamt

branches: 1.25.12; 1.25.22;
don't forget to skip marker processes.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.24 16-Nov-2008 pooka

branches: 1.24.4;
more <sys/buf.h> police


Revision tags: netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3
# 1.23 17-Sep-2008 hannken

branches: 1.23.2; 1.23.4; 1.23.6;
Replace the fss unmount hook with a vfs_hook.

fssvar.h: struct device * -> device_t.
fss.c: establish unmount hook on first attach, remove on last detach.
vfs_syscalls.c: remove the call of fss_umount_hook().
vfs_trans.c: destroy cow handlers on unmount as fstrans_unmount() will be
called before vfs_hooks.


Revision tags: wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.22 24-Jun-2008 ad

branches: 1.22.2;
Use pool_cache.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 16-May-2008 hannken

branches: 1.21.2;
Remove a bad assertion from last commit.
Non bufcache buffers may have BC_BUSY unset.


# 1.20 16-May-2008 hannken

Fscow_run() may recurse into itself.
Take care by adding a per-lwp recursion counter.


Revision tags: yamt-nfs-mp-base2
# 1.19 28-Apr-2008 martin

branches: 1.19.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.18 17-Mar-2008 yamt

branches: 1.18.2; 1.18.4;
- simplify ASSERT_SLEEPABLE.
- move it from proc.h to systm.h.
- add some more checks.
- make it a little more lkm friendly.


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 1.17 02-Feb-2008 hannken

branches: 1.17.2; 1.17.6;
BO_COWDONE -> B_COWDONE: this flag is tested/modified from the thread owning
the buffer and therefore needs no protection by a mutex.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.16 02-Jan-2008 ad

Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.15 02-Dec-2007 hannken

branches: 1.15.2; 1.15.6;
Fscow_run(): add a flag "bool data_valid" to note still valid data.
Buffers run through copy-on-write are marked B_COWDONE. This condition
is valid until the buffer has run through bwrite() and gets cleared from
biodone().

Welcome to 4.99.39.

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.14 08-Oct-2007 hannken

branches: 1.14.4;
fscow_run(): Check for NULL mount and don't run the cow handler in this case.


# 1.13 07-Oct-2007 hannken

Remove an include committed by accident.

From Chris Ross via current-users.


# 1.12 07-Oct-2007 hannken

Update the file system copy-on-write handler.

- Instead of hooking the handler on the specdev of a mounted file system
hook directly on the `struct mount'.

- Rename from `vn_cow_*' to `fscow_*' and move to `kern/vfs_trans.c'. Use
`mount_*specific' instead of clobbering `struct mount' or `struct specinfo'.

- Replace the hand-made reader/writer lock with a krwlock.

- Keep `vn_cow_*' functions and mark as obsolete.

- Welcome to NetBSD 4.99.32 - `struct specinfo' changed size.

Reviewed by: Jason Thorpe <thorpej@netbsd.org>


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.11 26-Jul-2007 pooka

branches: 1.11.4; 1.11.6; 1.11.8; 1.11.10;
Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.10 09-Jul-2007 ad

branches: 1.10.2;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8
# 1.9 17-May-2007 hannken

Fstrans_start() always returns zero, so change its type to void.


# 1.8 16-May-2007 hannken

Use rwlock for fmi_shared_lock and fmi_lazy_lock.

Ok: Andrew Doran <ad@netbsd.org>


Revision tags: thorpej-atomic-base
# 1.7 12-Mar-2007 ad

Use mutexes/condvars.


# 1.6 12-Mar-2007 ad

branches: 1.6.2;
Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.


Revision tags: ad-audiomp-base
# 1.5 16-Feb-2007 hannken

branches: 1.5.2; 1.5.4; 1.5.8;
Make fstrans(9) the default helper for file system suspension.
Replaces the now obsolete vn_start_write()/vn_finished_write().


# 1.4 15-Feb-2007 ad

Replace some uses of lockmgr() / simplelocks.


# 1.3 10-Feb-2007 hannken

newlock2: syncer_lock is now a mutex.


Revision tags: post-newlock2-merge newlock2-base newlock2-nbase
# 1.2 29-Jan-2007 hannken

branches: 1.2.2;
Change fstrans enum types to upper case.
No functional change.

From Antti Kantee <pooka@netbsd.org>


# 1.1 19-Jan-2007 hannken

New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

The new API is enabled on a kernel option NEWVNGATE. This option is
not enabled by default in any kernel config.

Presented and discussed on tech-kern with much input from
Bill Studenmund <wrstuden@netbsd.org> and YAMAMOTO Takashi <yamt@netbsd.org>.

Welcome to 4.99.9 (new vfs op vfs_suspendctl).