Commit Graph

404 Commits

Author SHA1 Message Date
hannken
62bfdd2b21 Change layered file systems to always pass the locking VOP's down to the
leaf file system.  Remove now unused member v_vnlock from struct vnode.
Welcome to 5.99.30

Discussed on tech-kern.
2010-06-06 08:01:30 +00:00
pooka
41bed623f4 .. except we need to check the flag while still clinging to iLock. 2010-05-27 23:58:38 +00:00
pooka
072ab7f0ce Assert that a VI_CLEAN vnode is not succesfully vget'd. 2010-05-27 23:54:35 +00:00
pgoyette
2c4465aaa0 Protect against attempting to load modules from the filesystem until we
have mounted the root file-system.  This allows us to load built-in and
boot-loader-provided modules much earlier during startup.
2010-05-24 03:50:25 +00:00
pooka
6e3fa8db54 Add translation from vtype to dirent type. Convert rumpfs now.
I'll convert the rest of the file servers in need after the next
version bump to avoid the coding module crisis.
2010-04-30 10:03:13 +00:00
ad
3f21f42490 - console spam.
- atomic_dec_uint -> vfs_destroy.
2010-04-25 15:56:00 +00:00
haad
aa8090778a Add vrele_async routine which asynchronously release vnodes in different contex
and in some time in the future.

Ok: ad@.
2010-02-11 23:16:35 +00:00
bouyer
85e9e8e2b4 Revert previous. The KASSERT() is right and my analysis is wrong,
as pointed out by pooka@.
2010-01-15 19:28:26 +00:00
bouyer
7ffaf66ccb Remove KASSERT(vp->v_usecount == 1) in getnewvnode() and ungetnewvnode().
Another process could be vget()ing the vnode and bump v_usecount while
getcleanvnode() is vclean()ing it (as vclean drops the interlock).
vget() will then wait for VI_XLOCK or VI_FREEING to clear; and we could test
this assertion while the other process is still slepping. We could even
end up in ungetnewvnode() before this other process got a chance to run.
2010-01-14 22:41:52 +00:00
pooka
113544b039 vcount() lost its purpose when opening multiple block devices was
made impossible, oh, two years ago.  nuke it (yes, the interface
name is overgeneric).
2010-01-08 13:07:26 +00:00
pooka
c3183f3251 The VATTR_NULL/VREF/VHOLD/HOLDRELE() macros lost their will to live
years ago when the kernel was modified to not alter ABI based on
DIAGNOSTIC, and now just call the respective function interfaces
(in lowercase).  Plenty of mix'n match upper/lowercase has creeped
into the tree since then.  Nuke the macros and convert all callsites
to lowercase.

no functional change
2010-01-08 11:35:07 +00:00
pooka
8797d86fd0 Make sure struct vattr contains no random bits of kernel memory
after vattr_null().  This is especially nice considering things
like puffs, where the contents are copied to userspace.
2010-01-07 19:54:40 +00:00
bouyer
8c392da154 Previous did cause a deadlock with layered FS: the vrele thread
can sleep on the vnode lock, while vget is sleeping on the
VI_INACTNOW flag (or the vget caller is looping on vget returning failure
because of the VI_INACTNOW flag). With layered FSes, the upper and lower
vnodes share the same lock, so the vget() caller above can be already
holding the vnode lock.

Fix by dropping VI_INACTNOW before sleeping on the vnode lock in
vrelel(), and check the ref count again once we have the lock. If the
vnode has more than one reference, donc VOP_INACTIVE it.
Fix PR kern/42318 and PR kern/42377
patch tested by Hisashi T Fujinaka, Joachim König, Stephen Borrill and
Matthias Scheler.
2009-11-28 10:10:17 +00:00
pooka
8102fe7341 Move rootfs-related init from init_main() to vfs_mountroot().
Reduces code re-written in rump.
2009-11-27 16:43:51 +00:00
pooka
1798957738 Add DV_VIRTUAL for non-backed virtual devices and allow to mount
root from a DV_VIRTUAL device.
2009-11-26 20:52:19 +00:00
enami
07ab814664 Fix indentation, wrap long line and remove unused variable. 2009-11-19 03:01:05 +00:00
enami
9f91c09ebc Add missing vfs_unbusy() call in error path of sysctl_kern_vnode().
This allows us to reboot machine successfully even if pstat -v fails once.
2009-11-19 02:59:33 +00:00
bouyer
e3c6fd050a Fix getcleanvnode() in previous: in the if (vp->v_usecount != 0)
case we didn't bump the refcount, so don't decrease it through vrelel().
call mutex_exit() on v_interlock directly instead.
2009-11-17 22:20:14 +00:00
bouyer
6b8161200e getcleanvnode(): don't vclean() the vnode if it has gained another
reference while we were getting the v_interlock.
vget(): attempt prevent it from returning a clean vnode:
  if the vnode is being inactivated (by vrelel()), wait for
  vrelel() to complete (or return EBUSY if we can't wait), and return
  ENOENT if the vnode has been vclean'ed by vrelel()
Fix kern/41147 in a better way, hopefully fix other related race conditions.
2009-11-05 08:18:02 +00:00
elad
756638cf95 Factor out a block of code that appears in three places (Veriexec, keylock,
and securelevel) so that others can use it as well.
2009-10-06 04:28:10 +00:00
jmcneill
ae17b8bef2 If vfs_mountroot fails, print a list of supported file systems. If no
file systems are supported by the kernel, print a big fat warning instead.
2009-09-19 16:20:41 +00:00
dyoung
57a3ffeae7 Cosmetic: remove #if 1 / #endif. 2009-06-26 18:58:14 +00:00
dyoung
0b429bf76a Keep a generation number, mountgen, that increases every time a
filesystem is mounted.  Synchronize access to the number with a
mutex.  When a struct mount, mp, is allocated, assign the current
generation number to mp->mnt_gen.  Introduce vfs_unmount_forceone()
that forcefully unmounts the most recently mounted filesystem.

Refactor: extract vfs_shutdown1() from vfs_shutdown().  Extract
vfs_sync_all() from vfs_shutdown1().

Print more progress indications while we're unmounting all of the
filesystems during shutdown.

We increase the reference count on mp before calling dounmount(mp),
but we do not decrease it if dounmount(mp) fails, and neither does
dounmount(mp).  So decrease the reference count if dounmount(mp)
fails.

Change the loop terminating condition in vfs_unmountall1() to (mp
!= (void *)&mountlist) from !CIRCLEQ_EMPTY(&mountlist), because we
may not ever empty the list, especially if we're not forcing the
filesystems to unmount.
2009-06-26 18:53:07 +00:00
elad
55f182207a Wow... too much Python.
Fix DIAGNOSTIC build breakage: print -> printf.

Pointed out by Kurt Schreiner on current-users@:

    http://mail-index.netbsd.org/current-users/2009/06/23/msg009815.html
2009-06-23 23:04:11 +00:00
elad
870920260d Move the implementation of vaccess() to genfs_can_access(), in line with
the other routines of the same spirit.

Adjust file-system code to use it.

Keep vaccess() for KPI compatibility and to keep element of least
surprise. A "diagnostic" message warning that vaccess() is deprecated will
be printed when it's used (obviously, only in DIAGNOSTIC kernels).

No objections on tech-kern@:

	http://mail-index.netbsd.org/tech-kern/2009/06/21/msg005310.html
2009-06-23 19:36:38 +00:00
yamt
513f4955a7 put a flag bit into v_usecount to prevent vtryget during getcleanvnode.
this fixes the following deadlock.

	a thread doing getcleanvnode:
	pick a vnode
	acqure v_interlock
	v_usecount++
	call vclean

		now, another thread doing cache_lookup:
		picks the vnode
		vtryget succeed
		vn_lock succeed

	now in vclean:
	set VI_XLOCK (too late to be noticed by the competing thread)
	wait on the vnode lock (this might violate locking order)

the use of a flag bit was suggested by Andrew Doran.  PR/41374.
2009-05-16 08:29:53 +00:00
pooka
ec3ee0abf9 Include some debug print routines if DEBUGPRINT is defined. This
way they can be included without having to include DDB.
(arguably all print routines should be behind #ifdef DEBUGPRINT
and options DDB should define that macro, but I'll tackle that later)
2009-05-03 16:52:54 +00:00
dyoung
dfec23a174 Extract vfs_unmountall1() from vfs_unmountall() for reuse. 2009-04-29 15:44:55 +00:00
dyoung
3e0a641f96 Extract common code from vfs_rootmountalloc(9) and mount_domount() into
a new struct mount-allocation routine, vfs_mountalloc(9).  Documentation
updates will follow.

Attention: Synchronization Oversight Committee!  In mount_domount(),
I postpone the call mutex_enter(&mp->mnt_updating) until right before
the VFS_MOUNT(9) call because (1) that looks to me like the earliest
possible opportunity for mp to become visible to any other LWP, because
it was just kmem_zalloc(9)'d and (2) it made extracting the common code
much easier.  Tell me if my reasoning is faulty.
2009-04-29 01:03:43 +00:00
elad
bab57db991 Replace a NULL check that can never fire with a KASSERT().
Okay ad@.

(this change was originally part of the following commit:
    http://mail-index.netbsd.org/source-changes/2009/04/25/msg220346.html)
2009-04-25 18:53:43 +00:00
elad
f68b0219b0 Per discussion on tech-kern@:
- Replace use of label/goto with returns

  - Rename, change prototype of, and move functions from vfs_subr.c to
    genfs_vnops.c
2009-04-22 22:57:08 +00:00
yamt
091b54f602 fix an indentation error. no functional change. 2009-04-21 00:02:37 +00:00
elad
386808d4a0 Refactor some duplicated file-system code.
Proposed and received no objections on tech-kern@:

	http://mail-index.netbsd.org/tech-kern/2009/04/18/msg004843.html
2009-04-20 18:06:26 +00:00
dyoung
b29e491b07 Make vfs_unmountall() return true if it was able to unmount any
filesystem at all, false otherwise.  This will support tearing down
stacks of filesystems, ccd(4), raid(4), and vnd(4).

Change the misleading variable name 'allerror' to 'any_error'.  Make it
a bool.
2009-04-17 20:22:52 +00:00
yamt
197e2d1b30 ARRAY_PRINT: 0 is a valid index. 2009-03-30 16:38:05 +00:00
ad
59fcf21389 PR kern/26878 FFSv2 + softdep = livelock (no free ram)
PR kern/16942 panic with softdep and quotas
PR kern/19565 panic: softdep_write_inodeblock: indirect pointer #1 mismatch
PR kern/26274 softdep panic: allocdirect_merge: ...
PR kern/26374 Long delay before non-root users can write to softdep partitions
PR kern/28621 1.6.x "vp != NULL" panic in ffs_softdep.c:4653 while unmounting a softdep (+quota) filesystem
PR kern/29513 FFS+Softdep panic with unfsck-able file-corruption
PR kern/31544 The ffs softdep code appears to fail to write dirty bits to disk
PR kern/31981 stopping scsi disk can cause panic (softdep)
PR kern/32116 kernel panic in softdep (assertion failure)
PR kern/32532 softdep_trackbufs deadlock
PR kern/37191 softdep: locking against myself
PR kern/40474 Kernel panic after remounting raid root with softdep

Retire softdep, pass 2. As discussed and later formally announced on the
mailing lists.
2009-02-22 20:28:05 +00:00
enami
e6aec5115a Make revoke(2) works as before:
- vfs_syscalls.c rev. 1.342 fails to invert condition correcly when
  then-clause and else-clause is swapped.  Since then, revoke(2) fails
  if it is issued by file owner.
- Probably since rev. 1.160 of genfs_vnops.c, revoke(2) fails if it is
  applied to non-device file and drops kernel into ddb.
2009-02-05 13:37:24 +00:00
enami
3d21969dbd Fix a bug introduced by rev. 1.311. Make the kern.vnode sysctl to expose
correct address of each vnode to userland again.
2009-01-21 00:54:05 +00:00
yamt
cea19a4d14 malloc -> kmem_alloc. 2009-01-17 07:02:35 +00:00
christos
461a86f9bd merge christos-time_t 2009-01-11 02:45:45 +00:00
yamt
68b6d8786e remove extra semicolons. 2009-01-03 03:31:23 +00:00
pooka
8583cae233 Rename specfs_lock as device_lock and move it from specfs to devsw.
Relaxes kernel dependency on vfs.
2008-12-29 17:41:18 +00:00
pgoyette
9c68331911 Store config(1)'s root filesystem type as a text string rather than
embedding the address of its xxx_mountroot() in swapnetbsd.c.  This
permits booting of kernels with hard-wired filesystem type even if the
filesystem is in a loadable module (ie, not linked into the kernel
image).

Discussed on current-users.  Tested on amd64 and i386 with both hard-
wired and '?' filesystem times, and on both modular and monolithic
kernels.

Thanks to pooka@ for code review and suggestions.

Addresses my PR kern/40167
2008-12-19 17:11:57 +00:00
christos
9a5d3f2817 replace bitmask_snprintf(9) with snprintb(3) 2008-12-16 22:35:21 +00:00
ad
024c36f64b vclean: be paranoid and set v_tag, v_op while holding v_interlock.
FS code could check their values while scrolling through mnt_vnodelist.
2008-12-14 11:15:59 +00:00
ad
31420e7959 - vrelel: fix broken "dead but not clean" assertion. The vnode can be
dead and dirty if cleaning is in progress.
- Add an assertion, fix some text.
2008-12-14 11:13:36 +00:00
pooka
54b9426187 Move some sysctl node creations away from linksets and into the
constructors for subsystems.

XXX: CTLFLAG_PERMANENT is non-sensible.
2008-12-07 20:58:46 +00:00
ad
edd4d8eda9 PR kern/39307 mfs will sometimes panic at umount time
In vfs_destroy, assert that the refcount is not dropping below zero.
2008-09-24 09:33:40 +00:00
tron
b7cced0000 Remove duplicate definition of "specfs_lock".
Patch provided by Juan RP in PR kern/39493.
2008-09-07 13:09:36 +00:00
simonb
36d65f1138 Merge the simonb-wapbl branch. From the original branch commit:
Add Wasabi System's WAPBL (Write Ahead Physical Block Logging)
   journaling code.  Originally written by Darrin B. Jewell while
   at Wasabi and updated to -current by Antti Kantee, Andy Doran,
   Greg Oster and Simon Burge.

OK'd by core@, releng@.
2008-07-31 05:38:04 +00:00