Commit Graph

245 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
christos f6889916d7 Make this compile again, from Jan-Benedict Glaw jbglaw at lug-owl dot de 2008-04-23 23:34:11 +00:00
ad dd55791531 Regen. 2008-04-23 14:10:03 +00:00
ad 7cb840338e -SYCALL_MPSAFE 2008-04-23 14:07:49 +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
ad 25153c3ec9 PR kern/37706 (forced unmount of file systems is unsafe):
- Do reference counting for 'struct mount'. Each vnode associated with a
  mount takes a reference, and in turn the mount takes a reference to the
  vfsops.
- Now that mounts are reference counted, replace the overcomplicated mount
  locking inherited from 4.4BSD with a recursable rwlock.
2008-01-30 11:46:59 +00:00
dsl 95a195791a Use FILE_LOCK() and FILE_UNLOCK().
Attempt to fix all the code paths so that the 'fp' returned by fd_getfile()
isn't left locked, and is always unlocked (and ref-counted) before
doing anything that might sleep.
2008-01-05 19:14:07 +00:00
christos c9a64311d7 make this compile again. 2007-12-27 17:18:11 +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
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
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
pooka ea84bd1c76 vfs_getopsbyname("ngs") -> vfs_getopsbyname("nfs"). 'nuff said 2007-10-23 15:21:31 +00:00
ad 7dad9f7391 Merge from vmlocking:
- Split vnode::v_flag into three fields, depending on field locking.
- simple_lock -> kmutex in a few places.
- Fix some simple locking problems.
2007-10-10 20:42:20 +00:00
christos f25f73fe50 include <compat/sys/mount.h> for MFSNAMELEN 2007-07-17 20:54:45 +00:00
ad 3fc1741f68 <dsl> I suspect my set of test build kernels is longer than ad's :-)
tsk!
2007-07-14 17:11:28 +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
he 8f77cc1c43 Fallout from the interface ioctl changes:
OSIOCGIFADDR -> OOSIOCGIFADDR
OSIOCGIFDSTADDR -> OOSIOCGIFDSTADDR
OSIOCGIFNETMASK -> OOSIOCGIFNETMASK

Also, one instance of needing to include <net/if.h> before
<compat/sys/sockio.h> due to use of IFNAMSIZ in the latter.

Discussed with christos.
2007-06-01 11:36:35 +00:00
christos 20bfd9898e Add a sockaddr_storage member to "struct ifreq" maintaining backwards
compatibility with the older ioctls. This avoids stack smashing and
abuse of "struct sockaddr" when ioctls placed "struct sockaddr_foo's" that
were longer than "struct sockaddr".
XXX: Some of the emulations might be broken; I tried to add code for
them but I did not test them.
2007-05-29 21:32:27 +00:00
dsl b8cecbd5b3 Delete fom stackgap lines that seem to have got left in. 2007-05-13 11:06:41 +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
matt 3af169362e Make this compile again (after stackgap removal) 2007-04-25 12:54:26 +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
he 1564bbc49c Need a char* for doing pointer arithmetic. 2007-03-05 13:56:24 +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
ad b07ec3fc38 Merge newlock2 to head. 2007-02-09 21:55:00 +00:00
pavel 336e41ffa7 regen (sys_getfh -> compat_30_sys_getfh) 2006-07-13 23:48:08 +00:00
pavel 50a6eaa646 use the COMPAT_30 getfh. 2006-07-13 23:47:17 +00:00
mrg 1b7ff51599 regenerate. 2006-06-26 21:30:50 +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
christos 95e1ffb156 merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
jmmv 20ac358c50 Instead of trying to clear ufs_args' export member, zero the whole
structure so that we don't rely on that (renamed) field.  Should fix
the build.  Found by he@.
2005-09-24 21:44:15 +00:00
christos 29f3692018 add <compat/sys/signal*.h> 2005-09-16 17:09:52 +00:00
he eb89cd94e9 Now that <ufs/ufsmount.h> includes <ufs/extattr.h>, we also need
<sys/vnode.h> and <sys/vnode_if.h> to bring the definition of struct
vop_getextattr_args into scope.  Fixes build problem for arc.
2005-08-31 16:01:56 +00:00
christos 758a209d23 64 bit inode changes. 2005-08-19 02:03:49 +00:00
christos ecc4f71237 define syscall again. 2005-07-10 04:23:30 +00:00
christos f1461c7e8a No point in declaring syscall_intern and syscall in a zillion places. 2005-07-10 00:45:52 +00:00
drochner 8aa146cea7 avoid shadow warnings 2005-06-01 15:29:41 +00:00
drochner 5a09c73a94 fix const'ification fallout 2005-06-01 15:28:56 +00:00
fvdl c487efe4a7 Fix some things regarding COMPAT_NETBSD32 and limits/VM addresses.
* For sparc64 and amd64, define *SIZ32 VM constants.
* Add a new function pointer to struct emul, pointing at a function
  that will return the default VM map address. The default function
  is uvm_map_defaultaddr, which just uses the VM_DEFAULT_ADDRESS
  macro. This gives emulations control over the default map address,
  and allows things to be mapped at the right address (in 32bit range)
  for COMPAT_NETBSD32.
* Add code to adjust the data and stack limits when a COMPAT_NETBSD32
  or COMPAT_SVR4_32 binary is executed.
* Don't use USRSTACK in kern_resource.c, use p_vmspace->vm_minsaddr
  instead (emulations might have set it differently)
* Since this changes struct emul, bump kernel version to 3.99.2

Tested on amd64, compile-tested on sparc64.
2005-03-26 05:12:34 +00:00
perry 77f2a006d0 regen 2005-02-26 23:58:19 +00:00
perry ed10d3c508 make this rebuild generated files by default 2005-02-26 23:50:14 +00:00
perry a7f74206ba regen 2005-02-26 23:20:00 +00:00
perry 477853c351 nuke trailing whitespace 2005-02-26 22:58:54 +00:00
drochner 613f1d9cdb Hmm - vax is different. sendsig_sigcontext() is for __mips only.
Should fix build error found by Havard Eidnes.
2005-01-25 14:56:09 +00:00
drochner 7c10815d09 use sendsig_sigcontext() directly instead of the generic sendsig() 2005-01-24 10:08:02 +00:00
david d7d15131bb Bounds check syscall arguments where appropriate 2004-10-27 19:29:57 +00:00
matt 22120ad628 Constify the speedtab arrays 2004-04-25 06:23:40 +00:00