Commit Graph

6746 Commits

Author SHA1 Message Date
pooka
b9a8d2f75a hardclock() itself doesn't schedule callout softintrs any more,
so update comment - less is more.
2008-10-05 21:57:20 +00:00
njoly
ab896e4008 Small fix to make setpriority(2) with PRIO_PROCESS return ESRCH when
no valid process can be found.
2008-09-30 17:28:47 +00:00
rmind
ae626d791a - Schedule bound threads even if CPU is offline. Might be revisited later,
when decision what to do with already bound threads will be made.
- Do not allow to assign offline CPU to the processor-set.

Quick fix for PR/39349.
2008-09-30 16:28:45 +00:00
njoly
6d60715500 Make setpriority(2) return EINVAL for incorrect which values. 2008-09-29 21:30:12 +00:00
rmind
03fe669395 - Fix message queue permissions problems.
- Rake into account umask when creating mqueue.
- Restore DDB command, which was accidentally lost (hi martin).
- Misc.
2008-09-29 10:27:53 +00:00
pooka
a709cdbf1f RCS Id polizei 2008-09-27 16:58:03 +00:00
reinoud
fec4bb5bba Add generic FS agnostic directory hashing support. Currently only in use by
UDF. Future users could be msdosfs, ufs, nilfs2 (when ready), cd9660 etc.

Note that its not the same as UFS's DIRHASH support; UFS would need a good
cleanup/splitout of directory operations to adopt to this new directory
hashing support since most directory operations are interweaved with the
vnops itself. This is a TODO.
2008-09-27 13:01:07 +00:00
wrstuden
53908c9c0a Pull in a fix from wrstuden-revivesa:
Let's look for threads in the TARGET process, not in the
debugger process (gdb). Noticed when a KASSERT fired while
running gdb on a threaded app.

I will adjust wrstuden-revivesa-base-3 to include this change.
2008-09-27 03:52:24 +00:00
pooka
44367b7199 Split rate-checking routines into their own module for easier reuse. 2008-09-25 17:17:10 +00:00
pooka
dd1721fa8d Move global malloc types from kern_malloc into a separate module. 2008-09-25 16:23:45 +00:00
wiz
43a9cced05 Fix typo in comment. 2008-09-25 14:37:30 +00:00
ad
43f2119341 PR kern/39307 (mfs will sometimes panic at umount time)
Change dounmount() so that it never drops the caller provided reference.
Garbage collecting 'struct mount' is up to the caller.
2008-09-25 14:17:29 +00:00
ad
c63b8853fe PR kern/30525 remounting ffs read-only (mount -ur) does not sync metadata
Prevent r/w to r/o downgrade until such time as someone has verified all
the relevant file system code.
2008-09-24 10:07:19 +00:00
ad
b72735bab2 PR kern/39307 mfs will sometimes panic at umount time
Don't drop reference to the mount if VFS_START() fails - that's for unmount
to do.
2008-09-24 09:44:09 +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
hannken
bc62834f44 Resolve a race when physio_done signals completion before it tries to
free a buffer.  This will fail if the buffer owner has a chance to
modify the BC_DONTFREE flag before putphysbuf() examines it.

Fix by removing get/putphysbuf() and BC_DONTFREE.  Physio_done() now
has an explicit test for a buffer coming from the call of physio().

Observed by Lars Nordlund when writing a DVD with growisofs, see PR kern/39536.

Reviewed by: Jason Thorpe <thorpej@netbsd.org>
2008-09-24 08:19:19 +00:00
pooka
2134732d08 Move [hH][eE][xX][dD][iI][gG][iI][tT][sS](*) from subr_prf to subr_prf2
for use with rumps.

*) yes, I just had to.  Notably though, there were only two
   symbols instead of 128.
2008-09-23 22:20:24 +00:00
christos
93aed8f8e3 fix half-assed change usec -> nsec that broke non-real timers. 2008-09-23 16:44:49 +00:00
rmind
ea71ae9284 Fix the aligning of memory blocks again, finally...
Tested by <martin> on his sparc64 box.
2008-09-19 11:21:33 +00:00
hannken
8de1a273e1 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.
2008-09-17 14:49:25 +00:00
pooka
66523e99f5 remove M_PIPE (hi rmind!) 2008-09-17 14:00:41 +00:00
rmind
ffb8ec88e1 Replace intptr_t with uintptr_t in few more places.
OK by <matt>.
2008-09-15 18:12:56 +00:00
rmind
38d7b7ba2e Replace intptr_t in few places to uintptr_t. 2008-09-15 10:43:29 +00:00
christos
0ff103ebea - remove dup code
- make sure that sigput always initializes ksi
- initialize si_code with SI_NOINFO instead of lying (SI_USER)
- if a process is being ktraced, make siginfo available
- always pass the available siginfo to ktrace, even if it has SI_NOINFO
2008-09-12 21:33:39 +00:00
hannken
3034f37f42 nestiobuf_setup(): Initialize b_dev from master buffer. 2008-09-11 09:14:46 +00:00
blymn
6a3775d153 * Fix from Elad to correct a couple of places where functions exited
without releasing locks.
* Corrected a panic caused by veriexec_file_verify() not setting the
  returned struct veriexec_file_entry **vfep in all cases.

Thanks to Stathis Kamperis for finding the issues and testing the fixes.
2008-09-10 16:36:54 +00:00
cube
1e807cbeed Remove what seems to be a debug printf committed by accident. 2008-09-07 22:36:36 +00:00
pooka
23bef54996 For rumpsyscalls, properly return -1 in case of error. 2008-09-07 19:27:58 +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
rmind
b37999b4b5 Add few KASSERTs. 2008-09-06 23:08:54 +00:00
rmind
7e456140b3 Replace malloc with kmem. 2008-09-06 23:05:52 +00:00
drochner
6d1cbe3695 Make ioctl(FIONREAD) on the master side of a pty return the amount of
data which can be read, as expected. Before, the call fell through a
"case" statement and was forwarded to the slave side, returning the
data which can be read by the slave.
The new behaviour also matches Linux and OSF/1.
2008-09-03 16:47:34 +00:00
drochner
0fd378606e fix the logics of device memory deallocation
(non-split devices paniced a diagnostic kernel)
2008-09-01 19:44:05 +00:00
njoly
1215ed4c88 Make dup(2) return the correct error value, not 0. 2008-08-31 20:55:55 +00:00
reinoud
031c718bd6 Revert previous change and clarify meaning of RNG 2008-08-30 09:20:13 +00:00
reinoud
bd424bd73b Accidental commit, but asserts buffer cache lock held 2008-08-30 08:55:53 +00:00
reinoud
c68a9bd2ec Fix simple typo:
-       rnd_init();             /* initialize RNG */
+       rnd_init();             /* initialize RND */
2008-08-30 08:55:52 +00:00
yamt
75734d288f process_stoptrace: fix a locking botch. 2008-08-28 06:23:42 +00:00
yamt
52bfe81965 cpu_xc_offline: fix races with eg. sleepq_remove. 2008-08-28 06:18:26 +00:00
christos
f4f1ff39a4 Writing 0 bytes on an O_APPEND file should not affect the offset 2008-08-27 06:28:09 +00:00
christos
520c3612c2 better debugging messages. 2008-08-27 05:40:25 +00:00
pooka
3e7c7228f4 Release vnode in cache_lookup() error branch if locking fails. 2008-08-20 15:34:59 +00:00
pooka
0f85a5be83 Remove my development ifdefs. (hi simon!) 2008-08-20 14:06:35 +00:00
matt
6ba7748097 Don't call null handlers 2008-08-15 03:14:20 +00:00
matt
78ab21fced Change subr_autoconf.c to use kmem_{*alloc,free}.
in pmf_deregister, don't constantly realloc.  just shift everything closer
to the front.  and then if empty, free.  When adding, add space for 4 more
entries.
Instead of n * sizeof(type) use C99 sizeof(type [n]).
2008-08-15 03:08:26 +00:00
matt
726d1181a8 Use __arraycount when appropriate 2008-08-15 01:31:02 +00:00
matt
e79910d9d4 Only deallocate dv_private if we had allocated it. 2008-08-14 21:51:08 +00:00
thorpej
8d9a49fc0e turnstile_block(): When an LWP puts its turnstile onto a sync object's
turnstile chain, assert that its turnstile's free list pointer is NULL.
2008-08-12 14:13:34 +00:00
yamt
a5cd2e50c6 make pcg_dummy const to catch bugs earlier. 2008-08-11 02:48:42 +00:00
yamt
53d1c25e34 add some KASSERTs. 2008-08-11 02:46:40 +00:00
yamt
ae231875d3 fix a comment. 2008-08-11 02:45:27 +00:00
yamt
eee9e229a0 lf_setlock: g/c dead code. 2008-08-11 02:44:28 +00:00
yamt
6198e821cb sleepq_block: fix a bug to lose biglocks in the case of recursive calls.
this fixes pf rb-tree corruption on my box.
2008-08-11 02:36:25 +00:00
skrll
e7901782b3 Comment whitespace. 2008-08-08 16:58:01 +00:00
christos
f6e1114503 Fix broken setitimer(). (Sverre Froyen) 2008-08-08 16:44:52 +00:00
uebayasi
714c16bc3e ttywrite: g/c an unused variable (cnt). 2008-08-08 07:18:03 +00:00
skrll
371a852414 memcpy'ing a sleepq (TAILQ) doesn't work.
Re-init the condvar after memcpy'ing so that the TAILQ is valid.

regress/sys/kern/lockf now completes rather than failing in cv_wait_sig
with KASSERT(cv_has_waiters()).
2008-08-07 07:42:06 +00:00
matt
13d044e16f Pages mapped by debug_malloc are PMAP_KMPAGE so tell the pmap that. 2008-08-07 01:40:21 +00:00
plunky
fd7356a917 Convert socket options code to use a sockopt structure
instead of laying everything into an mbuf.

approved by core
2008-08-06 15:01:23 +00:00
tls
717f903a98 Add accept filters, ported from FreeBSD by Coyote Point Systems. Add inetd
support for specifying an accept filter for a service (mostly as a usage
example, but it can be handy for other things).  Manual pages to follow
in a day or so.

OK core@.
2008-08-04 03:55:47 +00:00
pooka
bcfb021366 rumpify sys___sysctl 2008-08-01 19:32:35 +00:00
pooka
b629cd421b expose module_compatible() 2008-08-01 14:05:15 +00:00
skrll
6fd21ccbbf Improve the debug output ever so slightly. 2008-08-01 07:11:24 +00:00
simonb
2a3d67b697 Remove needless white-space change that crept in through wapbl branch
merge.
2008-07-31 08:42:01 +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
uebayasi
d1dfd4fec7 Display t_outcv* channels as "ttyout*", not "ttycan*". 2008-07-31 01:46:40 +00:00
thorpej
261002c777 rw_vector_exit(): When doing direct hand-off to a writer, only set
RW_WRITE_WANTED if there are additional writers waiting.
2008-07-29 16:13:39 +00:00
drochner
a17262c3e3 Avoid NULL pointer dereference on power handler deregistration if
it was not registered before. I assume that a lot of drivers do not
proper bookkeeping in the case the attach() exits early due to
errors. This is hard to fix and to test, so just be generous here.
2008-07-28 14:22:14 +00:00
pooka
f06b295c56 Adjust comment location to make it make sense.
no functional change
2008-07-27 15:08:37 +00:00
dsl
c43281ec80 Remove all the pending connections in soclose().
'continue' in 'do .. while (0)' doesn't do what ad@ intended.
2008-07-25 22:45:58 +00:00
uwe
4691dacd78 Declare lwp_exit_switchaway() __dead. Add infinite loop at the end of
lwp_exit_switchaway() to convince gcc that cpu_switchto(NULL, ...) is
really not going to return in that case.  Exposed by gcc4.3.

Reported on tech-kern by Alexander Shishkin.
2008-07-25 00:48:59 +00:00
apb
7cb9e72bbb Avoid using \$ in an awk script. Instead, store '$NetBSD$'
in an awk variable and interpolate it where needed.

Based on the patch by Martin Husemann in PR 38766.
2008-07-23 21:17:25 +00:00
christos
0f5d35d8d1 report local symbols too. 2008-07-22 21:18:35 +00:00
blymn
762e875434 Add locking around veriexec operations to prevent all sorts of badness
happening.  This fixes kern/38646.
2008-07-20 08:50:20 +00:00
kardel
ccab995bc6 Initialize timecounter_lock at IPL_HIGH. Prevents a "locking against myself"
when com.c (options PPS_SYNC) delivers a PPS time stamp during clock
interupt processing.
2008-07-19 10:33:58 +00:00
christos
dac1180a87 fix debugging printf 2008-07-18 21:29:48 +00:00
rmind
a7fc471680 PR/39155: Wolfgang Solfrank: Invalid parameter to turnstile_exit in rw_downgrade. 2008-07-17 23:00:01 +00:00
pooka
cc7d901591 vfs_subr2 has lost its will to live. vfs_subr was originally split
into two parts so that some of the routines could be used by rump.
Now that rump uses both vfs_subr and vfs_subr2 and there is no
reason to keep two files lying around, re-unite them.
2008-07-16 20:06:19 +00:00
drochner
8b720093a8 wipe out tty buffer contents after read, to avoid keeping possibly
sensitive information in memory longer than necessary
(We could make this depend on ~ECHO or so, but this would be an API
change and I don't think it is worth the effort.)
2008-07-16 18:27:49 +00:00
pooka
b09210ace9 rumpalooza sys_fsync 2008-07-16 15:42:54 +00:00
christos
460ae70d0a make l_flags contain more stuff. Fixes top thread display where system processes
were always displayed.
2008-07-15 22:25:30 +00:00
christos
aa389c698d Use more timespecs internally. From Alexander Shishkin and me.
Welcome to 4.99.70, 30 more to go for 100.
2008-07-15 16:18:08 +00:00
hannken
0d6dbadf45 bdwrite(): The COWDONE check may fire for special vnodes with mounted
non-ffs file system.  Remove VBLK vnodes from the check.

Should fix PR kern/38892
2008-07-14 16:22:42 +00:00
rmind
7c330ba82f Fix the locking against oneself, migrate LWPs only from runqueue.
Part of the fix for PR/38882.
2008-07-14 01:27:15 +00:00
rmind
4f91cff093 - Disallow setting of affinity for zombie LWPs.
- Fix the possible NULL dereference when LWP exiting.
- Fix the inhertance of affinity.
2008-07-14 01:19:37 +00:00
rmind
d489642431 sched_migratable: add KASSERT since this function cannot be called
without lock held now.  Few cosmetic changes, while here.
2008-07-14 01:18:10 +00:00
yamt
e4fb48bcaf pool_do_put: fix a pool corruption bug discovered by
the recent exec_pool changes.
2008-07-09 02:43:53 +00:00
christos
7f6e74c46e Fix to bug reported and tested by Alexander Shishkin. struct ptimer has
a union that contains either a callout [for CLOCK_REALTIME] or a flag
and a list [for other clock types]. Make sure we perform the right actions
on the right union member depending on the clock type. Otherwise this would
result in crashes.
2008-07-08 20:53:02 +00:00
pooka
fc6faa2baf Force vrele_thread to run in vflush() only if there is vrele_pending.
Makes unmounting a file system in a forcibly singlethreaded rump
invocation work.
2008-07-07 14:15:41 +00:00
yamt
03bb7555b4 fix pool corruption bugs in subr_pool.c 1.162. 2008-07-07 12:27:19 +00:00
pooka
21730363f8 Expose utimes() and lutimes() to rump.
from Arnaud Ysmal
2008-07-07 09:01:40 +00:00
bouyer
52346627a5 kern/39052: fix broken assertion. We can have a BC_BUSY buffer in the LRU
queue, if it's being flushed. But in this case, we'll also have B_VFLUSH.

While there fix checkfreelist() so that it can be used to check that a
buffer is not in the free lists.
2008-07-06 15:00:45 +00:00
ad
6c6c91b240 Move an assignment later. 2008-07-04 16:41:00 +00:00
ad
46587f3717 - Keep cache locked while allocating a cache group - later we might want
to automatically tune the group sizes at run time.
- Fix broken assertion.
- Avoid another test+branch.
2008-07-04 16:38:59 +00:00
ad
9d573e640e Remove a bunch of conditional branches from the pool_cache fast path. 2008-07-04 13:28:08 +00:00
ad
2526653044 vinvalbuf: broken assertion. 2008-07-03 12:37:09 +00:00
rmind
b7cdc71cd2 mq_open: fix confusion of FREAD/FWRITE and VREAD/VWRITE. 2008-07-02 20:06:09 +00:00
rmind
30dfdb2897 lwp_migrate: if LWP is still on the CPU (LP_RUNNING), it must be handled
like LSONPROC.  Should fix PR/38588.  OK by <ad>.
2008-07-02 19:53:12 +00:00
rmind
160268aca6 Remove proc_representative_lwp(), use a simple LIST_FIRST() instead.
OK by <ad>.
2008-07-02 19:49:58 +00:00
rmind
73f3b7bb31 Remove outdated comments, and historical CCPU_SHIFT. Make resched_cpu static,
const-ify ccpu.  Note: resched_cpu is not correct, should be revisited.

OK by <ad>.
2008-07-02 19:44:10 +00:00
rmind
61fc86b29b Remove locking of p_stmutex from sched_pstats(), protect l_pctcpu with p_lock,
and make l_cpticks lock-less.  Should fix PR/38296.

Reviewed (slightly different version) by <ad>.
2008-07-02 19:38:37 +00:00
ad
b94f79f0e8 Replce exec_map with a pool. Proposed on tech-kern@, reviewed by chs@. 2008-07-02 17:28:54 +00:00
matt
7408df1239 Change {ff,fd}_exclose and ff_allocated to bool. Change exclose arg to
fd_dup to bool.  Switch assignments from 1/0 to true/false.

This make alpha kernels compile.  Bump kern to 4.99.69 since structure
changed.
2008-07-02 16:45:19 +00:00
matt
1906aa3e59 Switch from KASSERT to CTASSERT for those asserts testing sizes of types. 2008-07-02 14:47:34 +00:00
pooka
1805817468 Adjust rump syscalls: remove a few pointless ones and add a few
missing ones.
2008-07-01 13:03:08 +00:00
matt
5a4f0c6b2b Change tree op members/typedefs to rbto_compare_* from rb_compare_* 2008-06-30 20:14:09 +00:00
pooka
d496f014ff Don't compile kern_lock for rump any more, it's no longer required.
Allows us to get rid of the incorrect _RUMPKERNEL ifdefs outside sys/rump.
2008-06-25 13:16:58 +00:00
ad
40818746b1 Use pool_cache. 2008-06-25 11:05:46 +00:00
ad
d23ae8da8d sigpending1: don't subtract the sigmask (!!). 2008-06-25 11:04:24 +00:00
ad
80892cd092 Use pool_cache. 2008-06-24 18:50:30 +00:00
ad
8c5bcce4b9 execve1:
- Properly terminate the fake argument list.
- Fix two double-frees.
2008-06-24 18:04:52 +00:00
ad
9993bc6d33 Nothing uses getsock/getvnode any more. 2008-06-24 11:21:46 +00:00
gmcgarry
8cead24f2a The conversion to c99-style designated initialisers brought in the gcc
extension of specifying an array range.  Revert to runtime initialization
of limit0.

See here for details: http://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html
2008-06-24 10:31:05 +00:00
gmcgarry
a7edd5ccdd Replace gcc-style designated initialisers with c99-style. 2008-06-24 10:27:35 +00:00
gmcgarry
8b957c9d45 ioctl commands are unsigned long. Changes ABI for fsetown() and fgetown() on 64-bit architectures. 2008-06-24 10:26:26 +00:00
gmcgarry
fb6bc48511 ioctl commands are unsigned long. 2008-06-24 10:24:21 +00:00
rmind
59a180ac8f sysctl_proc_stop: fix a lock-leak when kauth returns an error.
From <kefren>.
2008-06-23 20:04:36 +00:00
ad
aed68d2d63 getvnode -> fd_getvnode 2008-06-23 11:30:41 +00:00
ad
29957bec2e sys_fcntl: use l_fd, not p_fd. 2008-06-23 11:26:53 +00:00
ad
7756789d3a PR kern/38990: Unmounting a disk fails the first time
vflush: process vrele_list at least once before looking at the mount.
2008-06-23 11:23:39 +00:00
ad
bce675d015 When offlining a CPU, ensure that at least one other CPU within the same
processor set remains online, otherwise the system can deadlock.
2008-06-22 13:59:06 +00:00
ad
53db9954a3 - Ensure that at least one cpu stays in the default pset, otherwise the
system will lock up.
- Use cpu_lock, there's no need for a seperate psets_lock.
- Add a sysctl to return the list of psets as a string.
2008-06-22 12:59:18 +00:00
christos
1d875fc75f Adjust to separate kcpuset_t and cpuset_t. 2008-06-22 00:06:36 +00:00
christos
5e865a2f1b Also enforce that cm->cmsg_len >= CMSG_ALIGN(sizeof cmsghdr), from
Michael van Elst
2008-06-20 15:27:50 +00:00
christos
db982eb35b Don't require cm->cmsg_len == control->m_len, just that the cm->cmsg_len
<= control->m_len, like FreeBSD does. Idea from Taylor R Campbell.
2008-06-20 15:18:38 +00:00
mlelstv
8b80c3645f reassignbuf() is called by bdirty() from within biodone processing.
It can have waiters.
2008-06-18 18:11:25 +00:00
yamt
fff57c5525 merge yamt-pf42 branch.
(import newer pf from OpenBSD 4.2)

ok'ed by peter@.  requested by core@
2008-06-18 09:06:25 +00:00
christos
ffabbaf7c6 set mtime/atime properly, not backwards. 2008-06-17 21:02:08 +00:00
mlelstv
76a664c61a Drop !cv_has_waiters assertion.
bdirty() is called from within biodone() processing before
waiters have been woken up and removed.

N.B. it is also used by smbfs.
2008-06-17 19:14:14 +00:00
christos
f5be32608a PR/38942: Pedro F. Giffuni: no support for birthtime in utimes(2). 2008-06-17 16:18:01 +00:00
tsutsui
d7d2a525b1 Include <sys/sched.h> before <sys/syscallargs.h> for cpuset_t. 2008-06-17 16:17:21 +00:00
tsutsui
2bc3b0c694 Regen from syscalls.master rev 1.204:
> Include <sys/sched.h> before <sys/syscallargs.h> for cpuset_t.
2008-06-17 16:07:57 +00:00
tsutsui
33dfc34006 Include <sys/sched.h> before <sys/syscallargs.h> for cpuset_t. 2008-06-17 16:05:23 +00:00
reinoud
f6a70673ba Mark a buffer busy in getnewbuf() when it came from the pool_cache since
its not on a free list.

Also change buf_init() to not automatically mark buffers `busy' since this
only makes sense for bufcache buffers.

Mark all buf_init'd buffers 'busy' on the places where they ought to be
flagged as such to not confuse the buffer cache.

Fixes PR 38923.
2008-06-17 14:53:10 +00:00
ad
4810cbe2bf sleepq_block: add a comment. 2008-06-17 09:11:25 +00:00
ad
cad3a145a3 PR kern/38761: new (?) race in buffer cache code
Back out the workaround from cv_has_waiters(), which is not longer needed.
Removal was missed earlier.
2008-06-16 12:03:01 +00:00
ad
a9c4cefebd PR kern/38927: processes getting stuck in uvm_map (cv_timedwait), hanging
machine

Assume that a vnode (and associated data structures) costs 2kB in the
worst imaginable case. Don't allow sysctl to set desiredvnodes to a
value that would use more than 75% of KVA or 75% of physical memory.
2008-06-16 11:26:28 +00:00
ad
45850c3df9 PPWAIT need only be locked by proc_lock, so move it to proc::p_lflag. 2008-06-16 10:15:57 +00:00
ad
672f91757e PR kern/38761: new (?) race in buffer cache code
- Back out the previous workaround now that the sleep queue code has
  been changed to never let the queue become empty if there are valid
  waiters.
- Use sleepq_hashlock() to improve clarity.
- Sprinkle some assertions.
2008-06-16 10:03:47 +00:00
ad
461a5fb24b PR kern/38761: new (?) race in buffer cache code
sleepq_changepri, sleepq_lendpri: don't let an active sleep queue head become
empty. The condvar code inspects the queue head without holding the sleep
queue lock and needs to see a non-empty queue if there are waiters.
2008-06-16 10:02:15 +00:00
ad
5adf7333fd - PPWAIT is need only be locked by proc_lock, so move it to proc::p_lflag.
- Remove a few needless lock acquires from exec/fork/exit.
- Sprinkle branch hints.

No functional change.
2008-06-16 09:51:14 +00:00
ad
b0ac1133c6 Sprinkle some assertions. 2008-06-16 09:48:13 +00:00
ad
5bfa865311 Sprinkle more assertions. 2008-06-16 09:47:55 +00:00
ad
b7f5063255 lwp_lock_retry: return a pointer to the lock acquired. No functional change. 2008-06-16 09:45:20 +00:00
rmind
481ae1556f - Add general cpuset macros.
- Use kcpuset name for kernel-only functions.
- Use cpuid_t to specify CPU ID.
- Unify all cpuset users.

API is expected to be stable now.
2008-06-16 01:41:20 +00:00
christos
09e715922e regen 2008-06-16 01:00:21 +00:00
uebayasi
9d4479f7e9 Typo. 2008-06-16 00:54:53 +00:00
christos
20d8fbfbe4 typo 2008-06-16 00:54:10 +00:00
christos
88c08e3b98 regen 2008-06-16 00:32:23 +00:00
christos
5c45905c42 adjust prototypes for the affinity calls. 2008-06-16 00:31:17 +00:00
rmind
a6092d3c4a gencpuset: avoid returning of unitialized error.
sched_setaffinity: instead of E2BIG, return EINVAL in a case of invalid
CPU, which is more consistent.
2008-06-15 23:29:09 +00:00
christos
f30b5785d5 Don't expose struct cpuset, share the l_affinity flag and only allocate it
if we need to. This is not a compatible change, but the syscalls are new
enough and they don't need to be versioned. Approved by rmind.
2008-06-15 20:32:57 +00:00
chris
44d939d150 Fix for biowait hangs, and possibly other condvar hangs. Also should fix
PR kern/38761.

The condvar must access the sleepq with the sleepq lock held, doing so
is causing inconsistent sleepq state to be read.

This is because some accesses to the sleepq don't come via the cv code,
but are call directly into sleepq_changepri and sleepq_lendpri, which take
the sleepq lock, and removes then re-inserts lwps into the sleepq.

Running a build.sh with -j8 now completes on my quad-core, also tested by
Simon@ on a 8-core server and matt@ on a quad-core.

I believe there is room to be more efficient with this, as we now take the
sleepq lock for all cv_broadcast and cv_signal calls. I'll look into this
and post a diff to tech-kern.
2008-06-15 09:56:18 +00:00
drochner
a748803de9 tighten type checking: use device_t instead of void* at some places 2008-06-11 15:56:11 +00:00
ad
62c877a460 Don't call uvm_pageidlezero() if the CPU is marked offline. 2008-06-11 13:42:02 +00:00
drochner
520a61068b remove the hacks around fakemdrootdev[] which should be unnecessary now
that "md" devices show up in the "alldevs" list
2008-06-11 10:40:21 +00:00
dyoung
1e479b72f8 In device_pmf_driver_deregister, postpone deleting a device_t's
reference to the PMF private data until the private data has no
more waiters.  This protects against a NULL dereference.

In device_pmf_lock1(), test a device_t for PMF registration before
dereferencing its PMF private data.
2008-06-11 06:26:32 +00:00
simonb
a0f8ee25d3 In mount_domount() there is no need to initialise "mp" if the first time
we use it we set it.
2008-06-10 14:14:01 +00:00
ad
06da5288fa There can be existing waiters on a socket's condition variables when we
change socket::so_lock, and they rely on the old lock to synchronize.
Wake them up whenever we change so_lock so they can restart their waits.
2008-06-10 11:49:11 +00:00
ad
f77c704577 Fix error in previous. 2008-06-09 11:49:40 +00:00
ad
c862aeca6f ras_purgeall: avoid taking p_auxlock. 2008-06-09 11:46:34 +00:00
ad
5ab3329550 Correct previous. 2008-06-08 12:23:18 +00:00
ad
7304342b50 cdev_tty: don't acquire kernel lock, as we may need to call this with
tty_lock already held (and it would reverse the usual lock order).
2008-06-08 12:22:39 +00:00
ad
d78b3bf8f2 PR kern/38881 execve(2) panic: lock error, with path argument > PATH_MAX 2008-06-06 22:21:11 +00:00
drochner
598d615d27 add a KASSERT to catch missing locators 2008-06-06 17:52:40 +00:00
ad
6a33531fe1 - Make getiobuf() return buffers marked BUSY.
- Sprinkle more assertions.
2008-06-06 12:49:15 +00:00
cegger
6e390579fc make this build 2008-06-05 21:55:51 +00:00
ad
b91062326d Avoid "free vnode isn't" assertion. 2008-06-05 12:32:57 +00:00
ad
13c7f6ff40 Move lib/libkern/rb.h to sys/rb.h, so it can be used by kernel header
files.
2008-06-04 14:31:15 +00:00
rmind
af4e8e9ea7 Check the result of allocation in the cases where size is passed by user. 2008-06-04 13:02:41 +00:00
ad
cbbf514e2c - vm_page: put listq, pageq into a union alongside a LIST_ENTRY, so we can
use both types of list.

- Make page coloring and idle zero state per-CPU.

- Maintain per-CPU page freelists. When freeing, put pages onto the local
  CPU's lists and the global lists. When allocating, prefer to take pages
  from the local CPU. If none are available take from the global list as
  done now. Proposed on tech-kern@.
2008-06-04 12:45:28 +00:00
ad
621389e8b2 Fix broken enable test; fixes random coredumps. 2008-06-04 12:26:20 +00:00
ad
65b594ff61 Make sure the PAX flags are copied/zeroed correctly. 2008-06-04 12:16:06 +00:00
ad
8dd7771d61 Disable the wakeup assertion for the time being because the tty code
triggers it.
2008-06-04 11:22:55 +00:00
ad
cee82bbafa Don't use proc specificdata for the PAX stuff. Speeds up mmap() and others. 2008-06-03 22:15:14 +00:00
ad
d191ae6b1b Don't use proc specificdata. Speeds up mmap() and others. 2008-06-03 22:14:24 +00:00
ad
1b23b70818 vfs_cache:
- Don't use goto in critical paths, it can confuse the compiler.
- Sprinkle some branch hints.
- Make namecache stats per-CPU and collate once per second.
- Use vtryget().
2008-06-03 15:50:22 +00:00
ad
457a3f8942 vtryget: try to get an initial reference to a vnode without taking its
interlock. Only works if v_usecount is already non-zero, which is nearly
always true for busy files like libc.so or ld_elf.so.
2008-06-03 14:54:12 +00:00
dyoung
b5bf86befb Before freeing a ktr_desc, destroy its condition variables. 2008-06-03 05:53:09 +00:00
ad
a51fec9810 Avoid assertion failures. From drochner@. 2008-06-02 22:56:09 +00:00
drochner
99cb76cad6 adjust a KASSERT to reality after atomic vnode usecount changes 2008-06-02 19:20:22 +00:00
ad
3a8db3158e Use atomics to maintain v_usecount. 2008-06-02 16:25:34 +00:00
ad
30115e937a Most contention on proc_lock is from getppid(), so cache the parent's PID. 2008-06-02 16:18:09 +00:00
ad
fb8c6fcc83 Don't needlessly acquire v_interlock. 2008-06-02 16:16:27 +00:00
ad
0d151db6c9 Don't needlessly acquire v_interlock. 2008-06-02 16:00:33 +00:00
ad
8ad974fae5 vn_marktext, vn_lock: don't needlessly acquire v_interlock. 2008-06-02 15:29:18 +00:00
ad
ea8a92578d If vfork(), we want the LWP to run fast and on the same CPU
as its parent, so that it can reuse the VM context and cache
footprint on the local CPU.
2008-06-02 13:58:07 +00:00
ad
c3e93e738f Make trap counters per-cpu, like syscalls. 2008-06-01 21:24:15 +00:00
ad
736a4d9b78 Kill devsw_lock and just use specfs_lock. The two would need merging
in order to prevent unload of modules when a device that they provide
is still open.
2008-05-31 21:34:42 +00:00
ad
2feabc3836 PR kern/38812 race between lwp_exit_switchaway and exit1/coredump
Move the LWP RUNNING and TIMEINTR flags into the thread-private flag word.
2008-05-31 21:26:01 +00:00
dyoung
8f34c216d0 Add printf_tolog(), which writes to the kernel message buffer,
only.  I believe this is the safest way to log serious conditions
indicated by NMI.
2008-05-31 20:27:24 +00:00
ad
4c57df4a3c - Put in place module compatibility check against __NetBSD_Version__,
as discussed on tech-kern.

- Remove unused module_jettison().
2008-05-31 20:14:38 +00:00
ad
bda19becba Fix wmesg for !LOCKDEBUG. 2008-05-31 16:25:23 +00:00
ad
506130b087 biodone2: if the buffer is async or has a callback method, assert that
there are no waiters on b_done (threads in biowait()).
2008-05-31 13:41:44 +00:00
ad
7442154bd9 - Give each condition variable its own sleep queue head. Helps the system
to scale more gracefully when there are thousands of active threads.
  Proposed on tech-kern@.

- Use LOCKDEBUG to catch some errors in the use of condition variables:

  freeing an active CV
  re-initializing an active CV
  using multiple distinct mutexes during concurrent waits
  not holding the interlocking mutex when calling cv_broadcast/cv_signal
  waking waiters and destroying the CV before they run and exit it
2008-05-31 13:36:25 +00:00
ad
e10320350c Use __noinline. 2008-05-31 13:31:25 +00:00
ad
a6f1414cd1 tsleep -> kpause 2008-05-31 13:26:29 +00:00
ad
7b8f512433 LOCKDEBUG:
- Tweak it so it can also catch common errors with condition variables.
  The change to kern_condvar.c is not included in this commit and will
  come later.

- Don't call kmem_alloc() if operating in interrupt context, just fail
  the allocation and disable debugging for the object. Makes it safe
  to do mutex_init/rw_init/cv_init in interrupt context, when running
  a LOCKDEBUG kernel.
2008-05-31 13:15:21 +00:00
ad
10d96b47b0 shmrealloc: destroy condition variables before freeing them. 2008-05-31 13:11:14 +00:00
ad
deda5b9d55 Hold proc_lock when sleeping on p_waitcv, not proc::p_lock. 2008-05-31 13:04:14 +00:00
ad
5b4d14b9f1 Add a comment to turnstile_block:
* NOTE: if you get a panic in this code block, it is likely that
        * a lock has been destroyed or corrupted while still in use.  Try
        * compiling a kernel with LOCKDEBUG to pinpoint the problem.
2008-05-31 12:03:15 +00:00
freza
1531f6d32e Any time we remove event from the queue make sure we 1. release the
event plist and 2. free the drvctl_event struct.

Discussed with jmcneill@.
2008-05-30 15:30:37 +00:00
ad
13cf4bcc55 PR kern/38663 Kernel preemption can't be enabled on x86 because of amd64
FPU handling

Remove ifdef(i386), kernel preemption works on amd64 now.
2008-05-30 12:18:14 +00:00
rmind
1be38c90d8 do_sys_accept: release the reference to sock in few error paths.
Should fix PR/38790, report and test-case by Nicolas Joly.
2008-05-30 09:49:01 +00:00
rmind
a68758f8bd sched_idle: initialise 'tci' to NULL, avoids compiler warning. 2008-05-30 08:31:42 +00:00
ad
e98d2c1016 lwp_exit_switchaway: set l_lwpctl->lc_curcpu = EXITED, not NONE. 2008-05-29 23:29:59 +00:00
rmind
29170d3854 Simplifcation for running LWP migration. Removes double-locking in
mi_switch(), migration for LSONPROC is now performed via idle loop.
Handles/fixes on-CPU case in lwp_migrate(), misc.

Closes PR/38169, idea of migration via idle loop by Andrew Doran.
2008-05-29 22:33:27 +00:00
rmind
15e36ef766 sys_shmget: use the correct size variable for uobj_wirepages().
Adjust shm_memlock() for consistency too.

Fixes PR/38782, reported by Adam Hoka.
2008-05-29 21:38:18 +00:00
joerg
157262cae8 Explicitly compute the next interval using 64bit arithmetic, if the time
was either stepped backwards or the timer has overflown. This fixes
PR 26470.
2008-05-29 15:27:51 +00:00
pooka
de98844194 Mark pread/pwrite rump syscalls.
from Arnaud Ysmal
2008-05-29 12:01:37 +00:00
ad
79d0501e52 Disable zero copy if MULTIPROCESSOR, until it is fixed:
- The TLB coherency overhead on MP systems is really expensive.
- It triggers a race in the VM system (grep kpause uvm/*).
2008-05-28 21:01:42 +00:00
dyoung
801c395b47 Run shutdown hooks whether or not the kernel has panicked. Restores
NetBSD's shutdown behavior of more than 6 years before rev 1.176.
Ok joerg@.

It is essential that we restore some hardware to initial conditions
before rebooting, in order to avoid interfering with the BIOS
bootstrap.  For example, if NetBSD gives control back to the Soekris
comBIOS while the kernel text is write-protected, the BIOS bootstrap
hangs during the power-on self-test, "POST: 0123456789bcefghip".
In principle, bus masters can also interfere with BIOS boot.
2008-05-28 15:40:58 +00:00
ad
b5d8351e8e PR kern/38355 lockf deadlock detection is broken after vmlocking
- Fix it; tested with Sun's libMicro.
- Use pool_cache.
- Use a global lock, so the deadlock detection code is safer.
2008-05-28 13:35:32 +00:00
ad
5831c8ac63 Pull in sys/evcnt.h. 2008-05-27 22:05:50 +00:00
ad
f79b59f700 #ifdef strikes again 2008-05-27 21:36:03 +00:00
ad
4c634c7155 Sigh. The previous change did bad things to MySQL sysbench. Continue stealing
jobs from sched_nextlwp, but also do it in the idle loop. In sched_nextlwp
use trylock, in the idle LWP try harder.
2008-05-27 19:05:52 +00:00
ad
208df81d99 Move lwp_exit_switchaway() into kern_synch.c. Instead of always switching
to the idle loop, pick a new LWP from the run queue.
2008-05-27 17:51:17 +00:00
ad
aa7e99c693 Replace a couple of tsleep calls with cv_wait. 2008-05-27 17:50:03 +00:00
ad
234470c22e tsleep -> kpause 2008-05-27 17:49:07 +00:00
ad
ec32985f61 Use pool_cache. 2008-05-27 17:48:27 +00:00
ad
f90f3a01ea Use kmem_alloc/free. 2008-05-27 17:42:14 +00:00
ad
81fa379a0b PR kern/38707 scheduler related deadlock during build.sh
- Fix performance regression inroduced by the workaround by making job
  stealing a lot simpler: if the local run queue is empty, let the CPU enter
  the idle loop. In the idle loop, try to steal a job from another CPU's run
  queue if we are idle. If we succeed, re-enter mi_switch() immediatley to
  dispatch the job.

- When stealing jobs, consider a remote CPU to have one less job in its
  queue if it's currently in the idle loop. It will dispatch the job soon,
  so there's no point sloshing it about.

- Introduce a few event counters to monitor what's happening with the run
  queues.

- Revert the idle CPU bitmap change. It's pointless considering NUMA.
2008-05-27 14:48:52 +00:00
ad
f985e88f2b Start profiling clock on new process before setting it running, in case
there is a preemption.
2008-05-27 14:18:51 +00:00
christos
b51f45d9e6 More fixes needed in the error paths for the chroot code to work. 2008-05-26 18:20:36 +00:00
rmind
06171502fc Adjust and thus unify my license. 2008-05-26 17:45:51 +00:00
ad
c9ac92b592 Use pool_cache for sockets. 2008-05-26 17:21:18 +00:00
ad
46540aaf0e brelse: always wakeup on b_busy, in case BC_WANTED is not set. 2008-05-26 14:56:55 +00:00
ad
95488a6b7b Broken assertion. 2008-05-26 12:58:24 +00:00
ad
93e0e98369 Take the mutex pointer and waiters count out of sleepq_t: the values can
be or are maintained elsewhere. Now a sleepq_t is just a TAILQ_HEAD.
2008-05-26 12:08:38 +00:00
christos
0d264cffef PR/38745: Kouichirou Hiratsuka: chroot(8) can leak information of outside of
chrooted directory
2008-05-26 02:29:13 +00:00
christos
0e41ecf58b use PNBUF_* instead of malloc 2008-05-26 02:27:36 +00:00
ad
c7615c48c8 PR kern/38707 scheduler related deadlock during build.sh
Fail sched_catchlwp() if mutex_tryenter() on the remote CPU's state fails.
Seems to work around the issue described in this PR.

XXX Stealing jobs from remote CPUs could probably be moved into the idle
loop, making the locking quite a bit simpler.
2008-05-25 23:46:55 +00:00
ad
1cc9a3ae7e If converting a process/thread from SCHED_OTHER to a realtime thread,
ignore the existing priority. If no priority is specified, give threads
the minimum user RT priority.
2008-05-25 23:34:24 +00:00
ad
90035a10c9 sched_tick:
- Do timeslicing for SCHED_RR threads. At ~16Hz it's too slow but better
  than nothing. XXX

- If a SCHED_OTHER thread has hogged the CPU for 1/8s without taking a
  trip through mi_switch(), try to force a kernel preemption to give other
  threads a chance.
2008-05-25 22:04:50 +00:00
christos
6e0baf783e don't forget to fill in the emulation. 2008-05-25 20:18:33 +00:00
ad
5e4b324300 Properly fix the "hanging in tty" bug that was worked around with cv_wakeup()
some time again.
2008-05-25 19:22:21 +00:00
jmcneill
1e2888bbbd Export device-driver and device-unit properties via drvctl 2008-05-25 15:03:01 +00:00
jmcneill
3a8a32076d Add DRVGETEVENT support for /dev/drvctl, based on devmon support by
Jachym Holecek for Google Summer of Code. DRVGETEVENT plist is currently
limited to event type, device name, and device parent name.
2008-05-25 12:30:40 +00:00
christos
934b677fde Coverity CID 5015: Remove unnecessary test; if l was null we would have
crashed before when p = l->l_proc.
2008-05-24 18:43:02 +00:00
christos
2847938186 Coverity CID 5019: Check before deref. 2008-05-24 16:49:30 +00:00
christos
a2c63c0004 Coverity CID 5025: sbreserve is never called with a null socket. 2008-05-24 16:35:28 +00:00
ad
25866fbff7 Set cpu_onproc on entry to the idle loop. 2008-05-24 12:59:06 +00:00
njoly
12da67c77e Make msgsnd return EINVAL instead of 0, when the value of mtype is
less than 1.
2008-05-22 11:25:54 +00:00
ad
697d5e2cd4 PR kern/38663 Kernel preemption can't be enabled on x86 because of amd64
FPU handling

Ugly hack until the amd64 fpu handling is working (which should be soon):
enable kernel preemption on i386.
2008-05-21 15:41:03 +00:00
ad
d88444761b Ignore return from module_load() and just try vfsop lookup again. 2008-05-20 19:30:03 +00:00
ad
ce7cbbfb63 Back out unintentional change. 2008-05-20 19:21:23 +00:00
ad
61270d54f1 If autoloading a module, don't consider the current working directory. 2008-05-20 19:20:38 +00:00
ad
88435c0e48 Remove stale comment. 2008-05-20 19:16:07 +00:00
ad
a72f5a57fb Don't try to load a module while holding a vnode lock. 2008-05-20 17:28:59 +00:00
ad
7bf8432671 If mount fails because the needed file system code isn't in kernel, try
to autoload with the needed vfsops.
2008-05-20 17:25:49 +00:00
ad
67280de1f2 Allow module class to be passed to module_load(), as a basic sanity check
that we are loading the right kind of module.
2008-05-20 17:24:56 +00:00
martin
bd3d112a87 fix !MODULAR compiles 2008-05-20 16:18:51 +00:00
ad
e69aa3297c Take $MACHINE into account when looking for modules. 2008-05-20 16:04:08 +00:00
ad
ef621e3353 Remove pointless COMPAT ifdef. 2008-05-20 16:03:31 +00:00
ad
7a3561a8dc PR kern/38694 module dependencies do not work as expected
Autoload modules from the correct path based on kernel version.
2008-05-20 14:11:55 +00:00
ad
d0bd9aa452 - Do local relocs before loading requisite modules, and all others only
after requisite modules have been loaded. For PR kern/38697.
- Simplify kobj interface slightly to make error handling easier.
2008-05-20 13:34:44 +00:00
jmcneill
3ea8229871 If we see a non-loadable BSS section in a pre-loaded module, make sure we
don't return success from kobj_load or nasty things will happen.
2008-05-19 17:33:42 +00:00
ad
b0f6f924e3 Give devsw_detach() a dummy error return. 2008-05-19 17:15:00 +00:00
ad
245f0726ac Reduce ifdefs due to MULTIPROCESSOR slightly. 2008-05-19 17:06:02 +00:00
rmind
5f701aa0a3 - Make periodical balancing mandatory.
- Fix priority raising in M2 (broken after making runqueues mandatory).
2008-05-19 12:48:54 +00:00
hannken
940992e2c0 Remove a bad assertion from last commit.
Non bufcache buffers may have BC_BUSY unset.
2008-05-16 14:08:56 +00:00
hannken
5d2bff060a Make sure all cached buffers with valid, not yet written data have been
run through copy-on-write.  Call fscow_run() with valid data where possible.

The LP_UFSCOW hack is no longer needed to protect ffs_copyonwrite() against
endless recursion.

- Add a flag B_MODIFY to bread(), breada() and breadn().  If set the caller
  intends to modify the buffer returned.

- Always run copy-on-write on buffers returned from ffs_balloc().

- Add new function ffs_getblk() that gets a buffer, assigns a new blkno,
  may clear the buffer and runs copy-on-write.  Process possible errors
  from getblk() or fscow_run().  Part of PR kern/38664.

Welcome to 4.99.63

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>
2008-05-16 09:21:59 +00:00
hannken
961a5d4bcb Fscow_run() may recurse into itself.
Take care by adding a per-lwp recursion counter.
2008-05-16 09:01:56 +00:00
ad
cefdd6012a In panic, we busy wait if another CPU is already panicking. Don't spl0(),
because we could recurse and run off the end of the stack. Pointed out by
chs@.
2008-05-13 11:54:45 +00:00
yamt
c27d8958e0 sys_ptrace: fix a locking botch. PR/38649 from Martin Husemann. 2008-05-13 09:16:11 +00:00
ad
a9ee17c54d Use cpu_index(), not ci_cpuid. 2008-05-12 14:28:22 +00:00
rmind
76db3ec4cd sys_shmget: fix an object leak in case of error. 2008-05-11 18:48:00 +00:00
ad
32c5d76875 Fix locking botch. Pointed out by kardel@. 2008-05-11 14:42:18 +00:00
wrstuden
97003b024b Oops. These are supposed to come alive on the branch, not the head. 2008-05-11 00:18:09 +00:00
wrstuden
dbbab92bc9 Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
2008-05-10 23:48:44 +00:00
rumble
a1221b6d4a Convert file systems to dynamically attach with the new module interface.
Make VFS hooks dynamic while we're here and say farewell to VFS_ATTACH and
VFS_HOOKS_ATTACH linksets.

As a consequence, most of the file systems can now be loaded as new style
modules.

Quick sanity check by ad@.
2008-05-10 02:26:09 +00:00
ad
541e4662f9 - Add tc_gonebad(): allows timecounter to be flagged as bad and removed at
the next clock tick.
- Remove time_lock, which is no longer required.
2008-05-08 18:56:58 +00:00
njoly
24cbc2830b - Make semctl SETVAL/SETALL commands validate the semaphore value to
be set, which needs to be in the range [0,SEMVMX].
- Adjust the man page.
2008-05-06 20:25:09 +00:00
ad
82f138617e sys_unmount: drop ref to root dir before dounmount(), otherwise we'll
always get EBUSY.
2008-05-06 19:14:32 +00:00
ad
42d0626726 PR kern/38141 lookup/vfs_busy acquire rwlock recursively
Simplify the mount locking. Remove all the crud to deal with recursion on
the mount lock, and crud to deal with unmount as another weirdo lock.

Hopefully this will once and for all fix the deadlocks with this. With this
commit there are two locks on each mount:

- krwlock_t mnt_unmounting. This is used to prevent unmount across critical
  sections like getnewvnode(). It's only ever read locked with rw_tryenter(),
  and is only ever write locked in dounmount(). A write hold can't be taken
  on this lock if the current LWP could hold a vnode lock.

- kmutex_t mnt_updating. This is taken by threads updating the mount, for
  example when going r/o -> r/w, and is only present to serialize updates.
  In order to take this lock, a read hold must first be taken on
  mnt_unmounting, and the two need to be held across the operation.

One effect of this change: previously if an unmount failed, we would make a
half hearted attempt to back out of it gracefully, but that was unlikely to
work in a lot of cases. Now while an unmount that will be aborted is in
progress, new file operations within the mount will fail instead of being
delayed. That is unlikely to be a problem though, because if the admin
requests unmount of a file system then s(he) has made a decision to deny
access to the resource.
2008-05-06 18:43:44 +00:00
ad
a4e0004be3 LOCKDEBUG: try to speed it up a bit by not using so much global state.
This will break the build briefly but will be followed by another commit
to fix that..
2008-05-06 18:40:57 +00:00
ad
81194e34f1 Allow rw_tryenter(&lock, RW_READER) to recurse, for vfs_busy(). 2008-05-06 17:11:45 +00:00
ad
d63f54a366 lookup: Do a vfs_trybusy(). If the file system is being unmounted, then
just fail the operation.
2008-05-06 15:04:00 +00:00
xtraeme
f5b5967c0e Make this build again. 2008-05-06 13:31:02 +00:00
ad
39d40db63f PR kern/38141 lookup/vfs_busy acquire rwlock recursively
- sys_sync: acquire a write lock on the mount since the operation modifies
  the mount structure.
- sys_fchdir: use vfs_trybusy(). If an unmount is in progress, just fail it.
2008-05-06 12:54:25 +00:00
ad
8384d709ae Fix a couple of problems with checkdirs():
- vnode and cwd locks were being taken with proc_lock held, which is bad
  because proc_lock can only be held for a short period of time.

- Processes could have continually forked and escaped notice, keeping
  a reference to the old directory on top of which a new mount exists.
2008-05-06 12:51:22 +00:00
ad
bdaf7ef5fc PR kern/38141 lookup/vfs_busy acquire rwlock recursively
vfs_busy: don't deadlock if curlwp is unmounting.
2008-05-06 12:39:32 +00:00
ad
f4d5a72c7b PR kern/38141 lookup/vfs_busy acquire rwlock recursively
getvnode: Use vfs_trybusy, not vfs_busy. If unmount is in progress we
could deadlock, because vnode locks can be held during getnewvnode().
dounmount() locks in the reverse order (vfs_busy -> vnode).
2008-05-06 12:37:04 +00:00
ad
e071d39c84 - Convert hashinit() to use kmem_alloc(). The hash tables can be large
and it's better to not have them in kmem_map.
- Convert a couple of minor items along the way to kmem_alloc().
- Fix some memory leaks.
2008-05-05 17:11:16 +00:00
ad
e7d7e96395 vfs_dobusy: add assertions. 2008-05-05 17:08:54 +00:00
ad
2bbb14eaa4 Back out previous. It broke the build. 2008-05-05 13:41:29 +00:00
jmcneill
729313d52c Use 2-clause license. 2008-05-05 00:12:49 +00:00
ad
e724ef3c86 Provide zcalloc()/zcfree() so that uncompress() works. 2008-05-04 23:48:05 +00:00
ad
b407147f14 Move zlib out of net/ and into kern/. It would probably be better to use
the reachover Makefiles and libz, but this is already here and it works.
2008-05-04 23:07:09 +00:00
rumble
7846a18697 Fix an error path that previously panicked when module_fetch_info failed. 2008-05-04 21:35:12 +00:00
ad
517f9684fe Make it compile as part of librump. 2008-05-04 12:51:44 +00:00
ad
0915c596fe Ensure that there is always a link_set_vfsops, until we kill VFS_ATTACH(). 2008-05-04 12:43:58 +00:00
ad
5982e60c2b Broken assertions. 2008-05-03 15:57:17 +00:00
yamt
839080f755 lockdebug: try to detect recursive acquirements of read-write locks. 2008-05-03 06:24:55 +00:00
yamt
59547f3b9f enterpgrp: 0 -> NULL for pointers. no functional changes. 2008-05-03 05:36:02 +00:00
yamt
63c2ef6a53 use sigismasked. no functional change. 2008-05-03 05:34:23 +00:00
yamt
6d3b5bc3c9 - encrypt/decrypt offsets if DIAGNOSTIC.
- add an assertion.
these changes allow to detect a use of uninitialized percpu_t *.
2008-05-03 05:31:56 +00:00
yamt
cf71e3c4fb add a comment. 2008-05-03 05:18:36 +00:00
ad
04feebca3b PR kern/38141 lookup/vfs_busy acquire rwlock recursively
Until the code paths are fixed properly, put in place an ugly workaround
to make it safe to recursively acquire a read lock on a mount.
2008-05-02 17:40:30 +00:00
ad
1253c2cad4 Allow md_root_setconf() to set in a miniroot as the root file system
even if MEMORY_DISK_IS_ROOT is not defined (a runtime override).
2008-05-02 13:02:31 +00:00