Commit Graph

1930 Commits

Author SHA1 Message Date
sommerfeld 140b1ee075 Housecleaning time:
Fix and document naming convention for vnode variables (always use
lvp/lvpp and uvp/uvpp instead of a hash of cvp, vpp, dvpp, pvp, pvpp).

Delete old stale #if 0'ed code at the end.

Change error path code in getcwd_getcache() slightly (merge common
cleanup code; shouldn't affect behavior any).
1999-07-04 20:16:57 +00:00
sommerfeld e303e2ee8b Fix kern/7906: race between unmount and getnewvnode()
mp->mnt_flags & MNT_MWAIT is replaced by mp->mnt_wcnt, and a new mount
flag MNT_GONE is created (reusing the same bit).

In insmntque(), add DIAGNOSTIC check to fail if the filesystem vnode
is being moved to is in the process of being unmounted.

getnewvnode() now protects the list of vnodes active on mp with
vfs_busy()/vfs_unbusy().

To avoid generating spurious errors during a doomed unmount, change
the "wait for unmount to finish" protocol between dounmount() and
vfs_busy().  In vfs_busy(), instead of only sleeping once, sleep until
either MNT_UNMOUNT is clear or MNT_GONE is set; also, maintain a count
of waiters in mp->mnt_wcnt so that dounmount() knows when it's safe to
free mp.

tested by running a "while :; do mount /d1; umount -f /d1; done" loop
against multiple find(1) processes.
1999-07-04 16:20:12 +00:00
sommerfeld 6f57fc7820 fix typo in previous 1999-07-04 06:17:52 +00:00
sommerfeld c7e5c39191 Don't permanently lose the async bit on an failed unmount 1999-07-04 06:16:29 +00:00
wrstuden b101a0685c Make fhopen use FILE_UNUSE, and don't leak file descriptors.
Patch from Jason Thorpe. Also should close PR 7889 from
Assar Westerlund <assar@sics.se> describing this problem.
1999-07-01 18:58:16 +00:00
itojun 118d2b1d4f IPv6 kernel code, based on KAME/NetBSD 1.4, SNAP kit 19990628.
(Sorry for a big commit, I can't separate this into several pieces...)
Pls check sys/netinet6/TODO and sys/netinet6/IMPLEMENTATION for details.

- sys/kern: do not assume single mbuf, accept chained mbuf on passing
  data from userland to kernel (or other way round).
- "midway" ATM card: ATM PVC pseudo device support, like those done in ALTQ
  package (ftp://ftp.csl.sony.co.jp/pub/kjc/).
- sys/netinet/tcp*: IPv4/v6 dual stack tcp support.
- sys/netinet/{ip6,icmp6}.h, sys/net/pfkeyv2.h: IETF document assumes those
  file to be there so we patch it up.
- sys/netinet: IPsec additions are here and there.
- sys/netinet6/*: most of IPv6 code sits here.
- sys/netkey: IPsec key management code
- dev/pci/pcidevs: regen

In my understanding no code here is subject to export control so it
should be safe.
1999-07-01 08:12:45 +00:00
itojun 9765602d90 add PR_LISTEN for UNIX domain socket, SOCK_STREAM case. 1999-07-01 07:59:57 +00:00
darrenr cd92b615fa fix sys_accept() to return EOPNOTSUPP for protocols which don't support
listen/accept (PR_LISTEN flag in protosw) and detect obvious faults in
parameters passed.  It is still possible for the address used for copying
the socket information to become invalid between that check and the copyout
so close the connection's allocated fd if the copyout fails so that we can
return EFAULT without allocating an fd and the application not knowing about
it.  Ideally we'd be able to queue the connection back up so a later accept
could retrieve it but unfortunately that's not possible.
1999-07-01 05:56:32 +00:00
is b4b3d042fd Only check for ETXTBSY if the access would otherwise be allowed.
Needed to fix pr4134.
1999-06-30 10:00:06 +00:00
fvdl 811a6162c3 Allow execution of shared objects. This is silly, but is allowed in,
for example, Solaris and Linux, and at least one Linux ldd implementation
even depends on it.
1999-06-29 23:39:06 +00:00
wrstuden 6e06666498 Add fhopen, fhstat, fhstatfs syscalls. Also move getfh in from the nfs
syscall code.
1999-06-29 22:18:47 +00:00
wrstuden a9e728797e regen. 1999-06-29 22:17:39 +00:00
wrstuden d55b282c54 Add fhopen, fhstat, fhstatfs. 1999-06-29 22:15:31 +00:00
ross d13c150e3b include <string.h> for memset(3) when compiling userland test setup 1999-06-27 06:18:33 +00:00
augustss 94b815050e Add powerhooks, i.e., the ability to register a function that will be
called when the machine does a suspend or resume.
XXX Will go away when Jason's kevents come to life.
1999-06-26 08:25:25 +00:00
kleink 7b67bca335 Add compile-time and run-time feature test knobs for the 1003.1 Mapped Files,
Process Memory Locking, Range Memory Locking and Memory Protection options.
1999-06-24 14:18:10 +00:00
sommerfeld c45e268d01 Fix PR7373 for real: Rearrange locking to avoid need for LOCKPARENT in lookup 1999-06-21 05:11:09 +00:00
sommerfeld 8d750c058f regen (no actual change, but comments in the master file changed) 1999-06-21 02:30:53 +00:00
sommerfeld 9bad197221 Correct comment about how LOCKPARENT affects VOP_LOOKUP 1999-06-21 02:28:46 +00:00
christos c029fe53c6 Fix umask inheritance problem introduced by the cwdi changes, whereby
children processes will not inherit the parent's umask but 022.
1999-06-20 08:54:13 +00:00
ragge 5ad2718e7c Add vax to user of device_register. 1999-06-20 00:51:37 +00:00
sommerfeld 1425b5931b Fix PR7761: clip overly large length rather than failing 1999-06-19 18:01:26 +00:00
thorpej bbf19ba181 Um, hi, let's initialize pointers before we use them. 1999-06-17 23:17:45 +00:00
thorpej 12347b2657 Make uvm_vslock() return the error code from uvm_fault_wire(). All places
which use uvm_vslock() should now test the return value.  If it's not
KERN_SUCCESS, wiring the pages failed, so the operation which is using
uvm_vslock() should error out.

XXX We currently just EFAULT a failed uvm_vslock().  We may want to do
more about translating error codes in the future.
1999-06-17 15:47:22 +00:00
thorpej ad528dfdf0 Regen. 1999-06-15 23:29:17 +00:00
thorpej 0cec533f77 Add mlockall at #242 and munlockall at #243. 1999-06-15 23:28:16 +00:00
christos e13d964178 Regen 1999-06-09 04:25:54 +00:00
christos 3f8f92f2b4 Add EXCL keyword as described in tech_kern, and fix comments. Make the
vtrace syscall UNIMPL because it is.
1999-06-09 04:25:30 +00:00
thorpej c146fe969e Regen. 1999-06-08 03:08:32 +00:00
thorpej 8b35c542b5 mincore: caddr_t -> void * 1999-06-08 03:07:39 +00:00
thorpej 84380f9fbe In sosend(), if so_error is set, clear it before returning the error to
the process (i.e. pre-Reno behavior).  The 4.4BSD behavior (introduced
in Reno) caused transient errors to stick incorrectly.

This is from PR #7640 (Havard Eidnes), cross-checked w/ FreeBSD, where
Bill Fenner committed the same fix (as described in a comment in the
Vat sources, by Van Jacobsen).
1999-06-08 02:39:57 +00:00
thorpej 1c5f2999b2 Make sure `olddelta' is a valid pointer before performing the guts of
the adjtime(2) system call.  Fixes PR #7721, Darren Reed.
1999-06-07 22:33:53 +00:00
thorpej d76e7b8c6d Don't pass a nam2blk around at all; just have setroot() and friends reference
dev_name2blk[] directly.  Addresses PR #7622 (ITOH Yasufumi), although
in a different way.
1999-06-07 20:16:08 +00:00
thorpej 4476366369 Make sure the regression test compiles. 1999-06-07 02:25:05 +00:00
pk 62cb666f4a Guard our global resource `phpool' against all interrupts. 1999-06-06 22:20:15 +00:00
pk 0e286f5c1f Guard our global resource `expool' against all interrupts. 1999-06-06 22:14:53 +00:00
thorpej 2c3dc83a64 Keep interrupt-safe maps on an additional queue. In uvm_fault(), if we're
looking up a kernel address, check to see if the address is on this
"interrupt-safe" list.  If so, return failure immediately.  This prevents
a locking screw if a page fault is taken on an interrupt-safe map in or
out of interrupt context.
1999-06-04 23:38:41 +00:00
lukem 5e76cbddfb in humanize_number(), when printing a u_int64_t, use '%qu' (unsigned long long)
instead of '%qd' (long long)
1999-06-02 05:53:56 +00:00
lukem 6a62a9cff3 sanity check bufcache before using it 1999-06-01 00:40:48 +00:00
thorpej e50ef977d1 Don't use a read lock on an intrsafe map; these maps can only use exclusive,
non-sleeping locks.
1999-05-28 19:40:09 +00:00
thorpej 2580d306ab Change the vm_map's "entries_pageable" member to a r/o flags member, which
has PAGEABLE and INTRSAFE flags.  PAGEABLE now really means "pageable",
not "allocate vm_map_entry's from non-static pool", so update all map
creations to reflect that.  INTRSAFE maps are maps that are used in
interrupt context (e.g. kmem_map, mb_map), and thus use the static
map entry pool (XXX as does kernel_map, for now).  This will eventually
change now these maps are locked, as well.
1999-05-26 19:16:28 +00:00
thorpej 701868a6c8 Pass the appropriate access_type to uvm_vslock() for the given physio
operation: B_READ == VM_PROT_READ|VM_PROT_WRITE, B_WRITE == VM_PROT_READ.
1999-05-26 01:08:03 +00:00
thorpej 497248ca55 XXX Pass VM_PROT_NONE to uvm_vslock() as access_type. Why are we even
vslocking here?!  copyout() on its own seems to suffice just about everwhere
else, and it's not like the process is going to exit; it's in a system
call!
1999-05-26 01:07:06 +00:00
tron bb5689beb3 Only attempt to remove symbol table from DDB's lists of symbol tables
if we really loaded one.
1999-05-25 00:16:08 +00:00
thorpej ba2bc023f7 Call the mdcallback immediately after computing bufpages; bufpages may
need to be clipped, and this needs to be done before computing nbuf.
1999-05-21 00:05:12 +00:00
thorpej 3aa41b1b36 Make this actually work if the BUFCACHE option is not specified, by falling
back on the traditional BSD formula of 10% of first 2MB and 5% of remaining.
1999-05-20 20:01:28 +00:00
lukem 091ffad669 MI implementation of allocsys() 1999-05-20 05:59:52 +00:00
lukem 03b1725220 rework format_bytes() into a more generic humanize_number().
implement the former with the latter.
1999-05-20 05:58:19 +00:00
sommerfeld 6c63af182f Delete test code. 1999-05-15 22:37:22 +00:00
sommerfeld c01c0d9453 Revise previous fix:
1) protect socket flags under splsoftnet()
	2) avoid leaking memory on an error
1999-05-15 22:36:34 +00:00
tv fc3f28c6bd Wow, that was much easier than I originally thought. Fix PR kern/7583:
serious race condition in sosend().  Upon closer inspection, the appropriate
flags are checked within splsoftnet() for soreceive(), so no change needed
there.  Also a little KNFing in sosend().
1999-05-15 16:42:48 +00:00
thorpej c10a926030 Allow the caller to specify a stack for the child process. If NULL,
the child inherits the stack pointer from the parent (traditional
behavior).  Like the signal stack, the stack area is secified as
a low address and a size; machine-dependent code accounts for stack
direction.

This is required for clone(2).
1999-05-13 21:58:32 +00:00
thorpej a6c810d72a Fix a (currently) harmless brian-o in last. 1999-05-13 17:28:30 +00:00
thorpej 5d97669cfe Allow an alternate exit signal (i.e. not SIGCHLD) to be delivered to the
parent, specified at fork time.  Specify a new flag to wait4(2), WALTSIG,
to wait for processes which use an alternate exit signal.

This is required for clone(2).
1999-05-13 00:59:03 +00:00
drochner 4a60ccd128 fix 2 problems with subregion allocation:
-a subregion start was ignored if all previous allocations were before
the subregion, reported by Lennart Augustsson in PR kern/7539
-an existing allocation which overlaps the beginning of the subregion
was ignored (ie overlapped) if is is not the last allocation
1999-05-11 11:02:54 +00:00
thorpej 6c37e2b392 Make sure page allocations are counted everywhere that they need to be. 1999-05-10 21:15:42 +00:00
thorpej 4b6d8943c2 Improve the pool allocator's diagnostic helpers, adding the ability to
log on a per-pool basis, reentrancy checking, and dumping various pool
information from DDB.
1999-05-10 21:13:05 +00:00
lukem 719cd63d24 Implement format_bytes(), which pretty prints a given u_int64_t into a
given buffer, and if necessary, reducing the display width of the
number to fit in the buffer by increasing the units (from kilobytes
(2^10) through to exabytes (2^60)).
1999-05-09 13:48:44 +00:00
tv 4c9c896cc8 FILE_UNUSE wasn't updated in the FDSCRIPTS block. 1999-05-07 17:38:41 +00:00
christos e649afd171 Add NTFS for the compat names. 1999-05-06 17:11:04 +00:00
thorpej e3669c3393 Add "use counting" to file entries. When closing a file, and it's reference
count is 0, wait for use count to drain before finishing the close.

This is necessary in order for multiple processes to safely share file
descriptor tables.
1999-05-05 20:01:01 +00:00
thorpej 4913e22a19 Fix alignment problem in the garbage-collection code path. 1999-05-05 19:05:43 +00:00
christos a32f7169fc Align struct timeval time to the same alignment requirements of a quad.
This broke the sparc elf kernel which in microtime uses ldd to load both
words at the same time. The a.out kernel, just got lucky.
1999-05-04 16:16:54 +00:00
sommerfe c0d15c5c7c Count lockmgr locks held by process if LOCKDEBUG || DIAGNOSTIC.
(previously, it was just under LOCKDEBUG).
1999-05-04 15:58:53 +00:00
cgd 1bce8c40fc ep_arglen is in units of 'sizeof (char *)', not in units of bytes. use
howmany(value, sizeof (char *)) to get the right value.
1999-04-30 23:02:06 +00:00
thorpej 645d5bd5f6 Share everything with proc0. 1999-04-30 21:40:30 +00:00
thorpej b699afcb5b Pay attention to FORK_SHARECWD, FORK_SHAREFILES, and FORK_SHARESIGS. 1999-04-30 21:39:51 +00:00
thorpej 2835fc6e46 Pull signal actions out of struct user, make them a separate proc
substructure, and allow them to be shared.

Required for clone(2).
1999-04-30 21:23:49 +00:00
thorpej 882d9195a3 Oops, forgot to commit this one. Free the cwdinfo on exit. 1999-04-30 20:54:04 +00:00
thorpej 16936c9565 Break cdir/rdir/cmask info out of struct filedesc, and put it in a new
substructure, `cwdinfo'.  Implement optional sharing of this substructure.

This is required for clone(2).
1999-04-30 18:42:58 +00:00
cgd ee94a4dacb add checks for COMPAT_OSF1 in the appropriate places 1999-04-30 05:29:20 +00:00
scottr 3d5c979e43 Pull in opt_poollog.h for POOL_LOGSIZE. 1999-04-29 17:47:19 +00:00
cgd e85db685e9 * don't have the [onz]magic setup functions set up the stack.
* add arguments describing the vnode and ecoff header of the executable
  being set up to the [onz]magic setup functions.
* export the stack setup function and the [onz]magic setup functions.
* call the MD ecoff hook _before_ the [onz]magic and stack setup
  functions, and bail out early if the MD hook sets up vmcmds.
1999-04-27 05:36:43 +00:00
cgd 5338149302 correct comment: turn off set-id if MNT_NOSUID is set, not MNT_NOEXEC. 1999-04-27 05:28:44 +00:00
thorpej 3d23eb3ce3 More improvements to mbuf and mbuf cluster allocation:
- Initialize mbpool and mclpool with msize and mclbytes, respectively,
so that those values may be patched and have an actual affect on the
next system reboot.

- Set low water marks on mbpool (default: 16) and mclpool (default: 8).
This should be of great help for diskless systems, which need to allocate
mbufs in order to clean dirty pages; the low water marks increase the
chances of this being possible to do in memory starvation situations.

- Add support for getting/setting some mbuf-related parameters via sysctl.
* msize and mclsize (read-only)
* nmbclusters (read-only unless the platform has direct-mapped pool pages,
in which case the value can be increased).
* mblowat and mcllowat (read/write)
1999-04-26 22:04:28 +00:00
thorpej 879070ef90 Add support for the kern.mbuf sysctl node. 1999-04-26 21:56:23 +00:00
is af3d525792 Fix adosfs's locking panic 1999-04-26 20:33:18 +00:00
simonb a560bdeeec Use the nmbclusters variable and not the NMBCLUSTERS constant when setting
the mclpool hardlimit.
1999-04-25 03:03:03 +00:00
simonb 5d8b1ef3e4 g/c REAL_CLISTS. 1999-04-25 02:56:26 +00:00
simonb 8ce41be7b0 Move inclusion of "opt_sb_max.h" from sys/socketvar.h to
conf/param.c, and move the initialisation of the sb_max
variable from kern/uipc_socket2.c to conf/param.c.  Now
everthing that includes sys/socketvar.h doesn't get
recompiled when SB_MAX's value changes.
1999-04-22 04:50:05 +00:00
mrg 48c12bfeed revert previous. oops. 1999-04-21 02:37:07 +00:00
mrg 58540a2274 properly test the msgsz as "msgsz - len". from PR#7386 1999-04-21 02:31:49 +00:00
gwr 9b055e8c43 minor nits -- replace vsprintf with vsnprinf 1999-04-12 00:24:17 +00:00
gwr 8946cf4be4 minor nits -- strncpy into p->p_comm 1999-04-12 00:22:08 +00:00
kleink bff1bef006 * Add a comment to ktrgetheader() mentioning that ktr_len and ktr_buf are
being left uninitialized intentionally; addresses PR kern/6987.
* In ktrsysret(), initialize the unused ktr_eosys to avoid writing random junk.
1999-04-11 18:44:00 +00:00
wrstuden 2e1fa90ecb Fix obscure bug in namei(), which was the cause of PR 7306.
The problem is that if "sl" is a symbolic link, a lookup on "sl/"
will be flagged as the last component. Thus VOP_LOOKUP will lock
the parent directory if LOCKPARENT is set. In order for the symbolic
link to be resolved, this lock needs to be released. namei() would
test for this by checking if ni_pathlen == 1, which it wouldn't as
"/" is left in the name, and namei() would not unlock the parent.
The next call to lookup() to resolve the symbolic link would fail
as the parent was still locked.
1999-04-07 05:47:37 +00:00
thorpej b2741be06e More locking protocol fixes. Protect pool_head with a spin lock (statically
initialized).  This lock also protects the "next drain candidate" pointer.

XXX There is still one locking protocol problem, which should not be
a problem in practice, but is still marked as an issue in the code anyhow.
1999-04-06 23:32:44 +00:00
sommerfe c97bb0650d Fix compile warning (not seen with egcs, but...) 1999-04-05 03:33:31 +00:00
chs c109816333 Undo the part of the last revision about pr_rmpage() referencing
a data structure after it was freed.  This wasn't actually a problem,
and the change caused the wrong pool_item_header to be freed
in the non-PR_PHINPAGE case.
1999-04-04 17:17:31 +00:00
thorpej 4fd2edfbe8 mbinit() can now allocate memory. Update a comment accordingly. 1999-04-01 00:23:25 +00:00
thorpej c431ebc42f Call cpu_startup() immediately after uvm_init(), but before mbinit().
Call configure() directly immediately after config_init().

This causes autoconfiguration to happen at the same time as before, but
creates some kernel submaps earlier, so that e.g. mbinit() can now
allocate memory.
1999-04-01 00:22:45 +00:00
thorpej 278e7ae222 Yet more fixes to the pool allocator:
- Protect userspace from unnecessary header inclusions (as noted on
current-users).

- Some const poisioning.

- GREATLY simplify the locking protocol, and fix potential deadlock
scenarios.  In particular, assume that the back-end page allocator
provides its own locking mechanism (this is currently true for all
such allocators in the NetBSD kernel).  Doing so allows us to simply
use one spin lock for serialized access to all r/w members of the pool
descriptor.  The spin lock is released before calling the back-end
allocator, and re-acquired upon return from it.

- Fix a problem in pr_rmpage() where a data structure was referenced
after it was freed.

- Minor tweak to page manaement.  Migrate both idle and empty pages
to the end of the page list.  As soon as a page becomes un-empty
(by a pool_put()), place it at the head of the page list, and set
curpage to point to it.  This reduces fragmentation as well as the
time required to find a non-empty page as soon as curpage becomes
empty again.

- Use mono_time throughout, and protect access to it w/ splclock().

- In pool_reclaim(), if freeing an idle page would reduce the number
of allocatable items to below the low water mark, don't.
1999-03-31 23:23:47 +00:00
mycroft f145c291bd If copyout() fails, make sure to unbusy the mount point before returning. 1999-03-31 19:18:45 +00:00
mycroft 0622545249 Previous change to vn_lock() was bogus. If we got EDEADLK, it was from
lockmgr(), and it already unlocked v_interlock.  So, just return in this case.
1999-03-31 18:30:13 +00:00
thorpej 98d006d2c6 Set a hard limit (rather than an advisory high water mark for pages) of
NMBCLUSTERS for the mbuf cluster pool.  On platforms which use direct-mapped
segments for pool pages (MIPS and Alpha), this makes NMBCLUSTERS actually
meaningful (such ports don't even allocate mb_map, as it is not used to
map mbuf cluster pages).

Improve the message logged at a maximum rate of once per second.  The
new message: "WARNING: mclpool limit reached; increase NMBCLUSTERS".

In the back-end pool page allocator, remove the message about mb_map
being full.  The message was not necessarily correct as the allocator
may have been starved for pages, rather than for space in the map.  Also,
the hard limit on the mbuf cluster pool will be reached before the map
fills (the last cluster will always fit into the map), so the message
is redundant.

Add a comment in mbinit() about considering setting low water marks on
the mbuf and mbuf cluster pools.
1999-03-31 01:26:40 +00:00
thorpej d4d4e314e9 Fix several bugs/deficiencies in the pool allocator:
- Add support for hard limits, with optional rate-limited logging of
a warning message when the pool limit is reached.  (This will be used
to fix a bug in mbuf cluster allocation on the MIPS and Alpha ports.)

- Fix some locking protocol errors.  This required splitting pr_flags
into pr_flags (which is protected by the spin lock) and pr_roflags (which
are `read only' flags, set when the pool is initialized, and never changed
again; these do not need to be protected by a mutex).

- Make the low water support actually mean something.  When a low water
mark is set, add free items to the pool until the low water mark is
reached.  When an item allocation causes the number of free items to
drop below the low water mark, make the pool catch up to it.  This can
make the pool allocator more useful for several applications (e.g.
pmap `pv entry' management) and more robust for others (for e.g. mbuf
and mbuf cluster allocation, so that the pagedaemon can use NFS to clean
pages on diskless systems without completely running dry on buffers to
receive packets in during extreme memory shoratages).

- Add a comment where we sleep waiting for more pages for the back-end
page allocator.  Specifically, instead of sleeping potentially forever,
perhaps we should just wake up once a second to try allocating a page
again.  XXX Revisit this soon.
1999-03-31 01:14:06 +00:00
wrstuden bd2d8363bc The mode for a node is a mode_t in both struct stat and struct vattr -
don't use a u_short for intermediate storage in vn_stat.
1999-03-30 00:16:44 +00:00
kleink 2304549e9f Sync __getlogin()'s namelen argument with the libc-internal declaration
(u_int vs. size_t).
1999-03-28 17:34:33 +00:00
kleink 1c35ac8f6b Regen. 1999-03-28 17:32:51 +00:00
kleink 38c7f65f0c Sync __getlogin()'s namelen argument with the libc-internal declaration
(u_int vs. size_t).
1999-03-28 17:29:52 +00:00