Commit Graph

339 Commits

Author SHA1 Message Date
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 928a6b2096 PR kern/38135 vfs_busy/vfs_trybusy confusion
The previous fix worked, but it opened a window where mounts could have
disappeared from mountlist while the caller was traversing it using
vfs_trybusy(). Fix that.
2008-04-30 12:49:16 +00:00
jmmv b8f1187ff1 Fix build of these files after the vfs_trybusy change. Apply the same
modification done in compat/common/vfs_syscalls_20.c:1.27.
2008-04-30 06:49:23 +00:00
ad 284c2b9aef Merge proc::p_mutex and proc::p_smutex into a single adaptive mutex, since
we no longer need to guard against access from hardware interrupt handlers.

Additionally, if cloning a process with CLONE_SIGHAND, arrange to have the
child process share the parent's lock so that signal state may be kept in
sync. Partially addresses PR kern/37437.
2008-04-24 18:39:20 +00:00
ad 624dcd9102 Sprinkle locking. 2008-04-22 21:33:13 +00:00
ad dce30353aa Add a comment. 2008-04-22 21:29:21 +00:00
ad be04ac4896 Make rusage collection per-LWP and collate in the appropriate places.
cloned threads need a little bit more work but the locking needs to
be fixed first.
2008-03-27 19:06:51 +00:00
ad a9ca7a3734 Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
2008-03-21 21:54:58 +00:00
dsl 6fb2884c3a regen 2007-12-20 23:07:25 +00:00
dsl 7e2790cf6f Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
    int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
2007-12-20 23:02:38 +00:00
dogcow 9ad45b39e6 more NDINIT fallout. not completely compile-tested. 2007-12-09 13:34:23 +00:00
pooka db06a930e6 Remove cn_lwp from struct componentname. curlwp should be used
from on.  The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.
2007-12-08 19:29:36 +00:00
dsl 28bae79b27 ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
2007-12-08 18:35:53 +00:00
dsl f2af9174b9 Remove all the __P 2007-12-04 18:40:07 +00:00
dogcow 6c09f19fb4 and one more lwp removal victim 2007-11-27 11:25:29 +00:00
dogcow 3465a006e9 more VFS_STATVFS(x,y,z) fallout; change them to VFS_STATVFS(x,y). (hi, pooka!) 2007-11-27 09:47:15 +00:00
he 167a62205a Follow up the removal of the lwp_t* argument to do_filereadv() and
do_filewritev().
2007-10-11 13:51:12 +00:00
he 2eb0397ad6 Fix three identical typos in the previous (fs_fstypename -> f_fstypename). 2007-07-20 13:48:24 +00:00
christos 35cb28e6eb kill MFSNAMELEN 2007-07-17 20:41:23 +00:00
dsl 758f9f5cde Change compat mount code to pass do_sys_mount() kernel resident buffers.
Possibly the standard nfs code needs teaching how to set the length and
address family in order to support non-netbsd sockaddr.
There are now no active stackgap() calls in the compat tree.
2007-07-12 19:41:57 +00:00
dsl 53e0243f27 Changes to sompat socket function to avoid the dreaded stackgap. 2007-06-30 15:31:49 +00:00
dsl 049a22a9db These now need sys/prot.h 2007-06-23 09:09:56 +00:00
dsl 6111df536a Remove stackgap use:
osf1_sys_select() calls selcommon().
osf1_sys_readv() and writev() read the iov into kernel memory then call
  do_filereadv/writev().
KNF.
2007-06-17 19:50:01 +00:00
dsl ec918d6dc6 Modify the (recently added) compat_sigaltstack() #define to take the
values of the SS_ONSTACK and SS_DISABLE constants.
Use it to shorten the source files when this action is replicated.
Actually, given the monstrous complexity of sigaltstack1() there is
probably a much better way to do this...
2007-06-16 20:04:27 +00:00
dsl e12ac31b52 Remove an unsed call to stackgap_init() 2007-06-02 10:09:05 +00:00
dsl 9e2165cbd3 Time functions have had wrappers for ~ages, no need for the stackgap gere. 2007-05-13 14:47:54 +00:00
dsl d4540f5b2a Call sigaltstack1() directly instead of using the stackgap to call
sys___sigaltstack14().
Prototype up some code under #if 0 to use sigaction1().
2007-05-13 09:07:25 +00:00
dsl 701496b5c6 Split the fcntl locking code out from its copyin/out.
Use to avoid all the stackgap stuff in compat code.
2007-05-12 23:02:49 +00:00
dsl ef3fdc4a07 Change interface to settimeofday1() so that it can also be used from
compat code in order to avoid the stackgap.
2007-05-12 20:27:13 +00:00
dsl c0ac33ed01 Remember to call calcru() before using the rusage values. 2007-05-12 18:10:20 +00:00
dsl c83f8a10ad Change the compat sys_[fl]utime code to not use the stackgap. 2007-05-12 17:28:19 +00:00
dsl 76bef02b3a Remove some more uses of the 'stackgap' - the code is a lot simpler if
we just access stuff like l->l_proc->p_stats->p_ru instead of copying it
to and from userspace.
2007-05-12 14:09:34 +00:00
dogcow 01b74015fe fixes from dsl for compile errors 2007-05-07 21:18:26 +00:00
dsl 1844147fa9 Split sys_wait4() so that compat code can fiddle with the returned 'status'
and 'rusage' without having to copy data to/from stackgap buffers.
The old split (find_stopped_child) could be removed.
amd64 seems to run netbsd32, linux and linux32 emulations. sparc64 compiles.
2007-05-07 16:53:17 +00:00
dsl 8932ebd238 Remove some unused calls to stackgap_init() 2007-04-30 09:20:18 +00:00
dogcow b4fa94e8ef fix unused variable fallout b0rkenness 2007-04-27 23:53:15 +00:00
dsl b8fbaf8c4b Change the way that emulations locate files within the emulation root to
avoid having to allocate space in the 'stackgap'
  - which is very LWP unfriendly.
The additional code for non-emulation namei() is trivial, the reduction for
  the emulations is massive.
The vnode for a processes emulation root is saved in the cwdi structure
  during process exec.
If the emulation root the TRYEMULROOT flag are set, namei() will do an initial
  search for absolute pathnames in the emulation root, if that fails it will
  retry from the normal root.
".." at the emulation root will always go to the real root, even in the middle
  of paths and when expanding symlinks.
Absolute symlinks found using absolute paths in the emulation root will be
  relative to the emulation root (so /usr/lib/xxx.so -> /lib/xxx.so links
  inside the emulation root don't need changing).
If the root of the emulation would be returned (for an emulation lookup), then
  the real root is returned instead (matching the behaviour of emul_lookup,
  but being a cheap comparison here) so that programs that scan "../.."
  looking for the root dircetory don't loop forever.
The target for symbolic links is no longer mangled (it used to get the
  CHECK_ALT_xxx() treatment, so could get /emul/xxx prepended).
CHECK_ALT_xxx() are no more. Most of the change is deleting them, and adding
  TRYEMULROOT to the flags to NDINIT().
A lot of the emulation system call stubs could now be deleted.
2007-04-22 08:29:55 +00:00
dsl 893faeae9e Update all the compat stuff to not use the 'stackgap' for processing
sys_stat() and friends, instead use do_sys_stat() and do_sys_fstat()
that write the answer into a kernel buffer (on stack) that can be
converted to the correct form and written the userspace.
I've test compiled a few kernels, and tested i386 netbsd1.6 ls.
Given I think I've fixed some bugs, it might be 50-50 with new ones.
2007-03-10 21:40:23 +00:00
yamt 18e17bd568 fix fallout from caddr_t changes. 2007-03-04 15:46:18 +00:00
christos 53524e44ef Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
tsutsui 4007519959 Make this timecounter(9) ready. From kardel@. 2007-03-04 02:49:12 +00:00
pavel 934634a18c Change the process/lwp flags seen by userland via sysctl back to the
P_*/L_* naming convention, and rename the in-kernel flags to avoid
conflict. (P_ -> PK_, L_ -> LW_ ). Add back the (now unused) LSDEAD
constant.

Restores source compatibility with pre-newlock2 tools like ps or top.

Reviewed by Andrew Doran.
2007-02-17 22:31:36 +00:00
ad b07ec3fc38 Merge newlock2 to head. 2007-02-09 21:55:00 +00:00
ad f474dceb13 Use the LWP cached credentials where sane. 2006-07-23 22:06:03 +00:00
mrg e2eb31d3a3 version the socket(2) syscall. for compat30 socket, we use
EPROTONOSUPPORT instead of EAFNOSUPPORT.

from pavel@ with a little bit of clean up from myself.

XXX: netbsd32 (and perhaps other emulations) should be able
XXX: to call the standard socket calls for this i think, but
XXX: revisit this at another time.
2006-06-26 21:23:56 +00:00
elad 874fef3711 integrate kauth. 2006-05-14 21:19:33 +00:00
drochner 9242c10539 in sysinfo(), force NUL termination of truncated
strings if the buffer was too small, as OSF1 does
2006-04-06 15:45:20 +00:00
drochner 61f5f2c87d -Consistently check the buffer length in getsysinfo(),
and require one additional byte for string termination
 in the GSI_PLATFORM_NAME case.
 This should fix PR kern/33198 by Nicolas Joly.
-Make sysinfo() behave more like the original: return
 the length needed and copy out as much as possible.
2006-04-05 15:30:48 +00:00
christos 95e1ffb156 merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
he c6c2d9e696 Suddenly these need explicit inclusion of <sys/socket.h>; they use
the MSG_OOB and AF_LINK symbols (among others).  Fixes build problem.
2005-09-28 06:40:15 +00:00