Commit Graph

4001 Commits

Author SHA1 Message Date
pk a7c40722d8 Call inittodr() from main(). Let file system code set the recorded `last
update' time (if any) through the new function setrootfstime().
2004-07-05 07:28:45 +00:00
manu 26200ee754 In MacOS X.3, the kernel maps tw opages of memory in every user process.
This areas is called the comm pages. It is used to provide fast access to
several data and functions.

The comm pages are mapped starting at 0xffff800 (address chosed so that
absolute branch can be used, so it can be accessed even when dynamic linking
is not ready). NetBSD has the user stack here, so we need to provide a
Darwin-specific stack setup routine which sets the top of the stack at
0xbfff0000.

This implementation is not complete but it does enough to get MacOS X.3
starting again (static binaries run, dynamic binaries still have an issue).
in the comm pages functions, we only implement bcopy, pthread_self and
memcpy.

TODO:
- clean up the powerpc specific code from MD parts
- for now we map only one page to avoid a crash, we want two pages.
- write all the comm functions.
2004-07-03 00:14:30 +00:00
yamt fb277865d7 bump sb_timeo from short to int to allow longer timeouts.
especially when hz is high.

while i'm here, bump sb_flags to int, as suggested by
Jason Thorpe and Bill Studenmund.

ride on 2.0G.
2004-07-01 12:42:57 +00:00
yamt 0f3ce64ad4 statclock: don't assume hz==100 when determining frequency to call schedclock. 2004-07-01 12:36:57 +00:00
hannken f59f039ea5 Keep a pointer to the leaf mount. Needed for write gating where a
file system gets suspended and has layered mounts above it.

Welcome to 2.0G

Reviewed by: Bill Studenmund <wrstuden@netbsd.org>
2004-07-01 10:03:29 +00:00
fredb 430f0ecf15 Multiply before divide, correcting a mistake introduced by revision 1.7.
The loss of precision could be significant in some cases.
2004-06-27 15:21:30 +00:00
yamt ce02ffbc68 introduce a new function, cache_lookup_raw(), for filesystems which
want more flexible namecache handling.
it just looks up a dnlc entry and vget() the result vnode.
ie. no automatic entry removal, no automatic vnode locking.

discussed on tech-kern@.
2004-06-27 08:50:44 +00:00
fredb ca3c6f824f Partly back out the last, to avoid a deadlock when microtime() is called
from levels below IPL_CLOCK (pointed out by thorpej). Just take the lock
before reading the time and cycle counter.
2004-06-27 01:36:04 +00:00
chs a4bbde95f7 add a workaround for PR 25664 (failure to map sigcode for Tru64 binaries). 2004-06-27 00:55:08 +00:00
chs a77ca34b8a rearrange the handling of p_textvp so that the ref-counting is correct.
fixes PR 25663.
2004-06-27 00:41:03 +00:00
fredb f17b436426 Take the lock earlier, before reading the cycle counter, so that it
doesn't advance while we're waiting on the lock. In fact, try to take
the lock even before blocking interrupts: the lock is locking "lasttime"
against other callers of cc_microtime(), not against the clock routines,
and if we take a clock interrupt while waiting for the lock, that's one
we don't have to take after the computations, but before returning to
the caller, and that makes the data a little fresher to the caller.

Moreover, inverting the order of splXXX() and simple_lock() permits us
to unblock interrupts before doing the long division.

With this, finally, performance of "ntpd" on my MP i386 seems to be no
worse than on non-MP i386, so this may fix PR kern/24207.
2004-06-26 16:31:33 +00:00
christos 39e498b419 Explain why the comment is a lie. 2004-06-24 15:06:35 +00:00
jonathan 5249b5a2a5 Rename MBUFTRACE helper function m_claim() to m_claimm(),
for consistency with M_FREE() and m_freem().  Affected files:

sys/mbuf.h
kern/uipc_socket2.c
kern/uipc_mbuf.c
net/if_ethersubr.c
netatalk/ddp_input.c
nfs/nfs_socket.c
2004-06-24 04:15:50 +00:00
christos 7e8ca29827 Fix a panic induced by forcing ktrace to inject an emul record on
a ktraced file descriptor that has already been invalidated. Change
all ktrace functions to propagate the error from ktrwrite() and
check for it. Thanks to Pavel Cahyna for finding this and giving
a perfect bug report.

[should be pulled up for 2.0]
2004-06-23 23:05:48 +00:00
christos 0fe4a0b07a Don't check for negative offset in the memory case. 64 bit addresses can
have the high bit set, and thus be interpreted as negative offsets. This
is not a problem because uvm_io() does all the range checks.
2004-06-22 02:06:55 +00:00
hannken 7a5be5a9ff - Add flag L_COWINPROGRESS to struct lwp to avoid recursion when
doing copy-on-write.

- Change VFS_SNAPSHOT() to return the snapshot vnode locked.

- Make the IO path for copy-on-write and snapshot-read more lightweight.
  Avoids deadlocks where vn_rdwr(...READ...) has a shared lock and needs
  to copy-on-write.
  Avoids deadlocks/panics where to clean pages the copy-on-write needs
  to allocate pages for its VOP_PUTPAGES().

L_COWINPROGRESS part approved by: Jason R. Thorpe <thorpej@netbsd.org>
2004-06-20 18:55:58 +00:00
thorpej 3183ea47c2 When initializing the buffer cache memory pools where the size <= PAGE_SIZE,
also use the standard allocator on systems that use a direct-mapped memory
segment for mapping pool pages.
2004-06-20 18:29:47 +00:00
thorpej 3cd310ba0f Remove PR_IMMEDRELEASE, since setting the high water mark will achieve
the same thing.

Pointed out back in January by YAMAMOTO Takashi.
2004-06-20 18:19:27 +00:00
thorpej bbbb3183d6 Don't use PR_IMMEDRELEASE on buffer cache pools. Instead, set a high
water mark of 1, which will have the same effect.

Pointed out back in January by YAMAMOTO Takashi.
2004-06-20 18:17:09 +00:00
fredb c6f9967d69 Introduce a variable "cc" to hold the cpu counter delta, rather than
overloading "usec". The counter isn't counting micro-seconds, and using
the same variable to mean two different things is false economy: with
this change, the compiled object is 72 bytes smaller on i386, and the
code is easier to understand, to boot.
2004-06-19 20:02:38 +00:00
yamt 8a2c13021f cache_lookup: avoid to grab two vnode's v_interlock.
just hold a reference (usecount) to a vnode instead.
2004-06-19 18:49:47 +00:00
fredb e89e654031 Fix a typo in the comments. 2004-06-19 18:12:55 +00:00
yamt 79dd9743cd getcleanvnode: fix spurious ENFILE.
try vnode_hold_list if none of vnodes on vnode_free_list are re-usable.
2004-06-19 06:20:02 +00:00
christos c22e4ed8cd ptm is now mandatory, depends on pty, and can be disabled with -DNO_DEV_PTM 2004-06-18 15:02:29 +00:00
yamt b3384c452e getcleanvnode: don't try to reclaim a vnode marked as VXLOCK.
fix crashes with VOP_RECLAIM implementations which might block.
(eg. layered filesystems)
2004-06-16 12:35:51 +00:00
yamt a0d352ca6d getcleanvnode: add a comment on a VLAYER hack. 2004-06-16 12:32:51 +00:00
jonathan d907e82ddc Fix potential memory leak in sbappendaddrchain():
We do an MGETHDR)() for each mbuf "packet" of the input chain, to hold
the socket address prepended to that "packet".  If those MGETHDR()s
ever failed, we would leak all the successfully-allocated mbuf
headers.  Leak noted by Yamamoto-san (yamt@NetBSD.org); thanks for catching it!

Add socketbuf invariant-checking macros to sbappendaddrchain(), and
replace a stray bcopy() with memcpy(), also as suggested by Yamamoto-san.
2004-06-11 03:46:01 +00:00
he 32381a5299 PAGE_SIZE is apparently not a constant on the sparc port, so don't
use it in a static initializer.  Instead, initialize in signal_init().
2004-06-08 19:35:30 +00:00
lha a9970d44c9 Return directly when pty_alloc_master failes in ptmioctl,
bug-report on current users from Denis Lagno  dlagno at smtp dot ru.
Make debug message in pty_alloc_master to match the code.
2004-06-05 11:23:15 +00:00
skrll b00b102b41 Allow for struct sigacts being greater than PAGE_SIZE on sun2. sun2
-current kernels now work again.

Reviewed by Matt Thomas. Thanks.
2004-06-04 12:23:50 +00:00
nathanw 956448b619 Initialize simple_lock in struct cwd; otherwise, one gets an
uninitialized lock panic at the first use of cwdshare().
2004-06-03 20:35:30 +00:00
pk 69211c6484 cwdfree() signature has been changed to accomodate fine-grained locking. 2004-05-31 15:33:38 +00:00
pk 2560fefc23 Implement mutexes for file descriptor and current working directory access.
Fix a potential race condition when reallocating storage for file descriptors
(even for non-SMP kernels).
Add missing locks for `struct file' ref count updates.
2004-05-31 15:30:55 +00:00
yamt 2fd3d08b3d lockmgr: add a comment about LK_RETRY. 2004-05-31 09:05:10 +00:00
yamt bd2a784b57 vn_lock: add an assertion about usecount. 2004-05-31 09:02:51 +00:00
yamt 59ba83d898 lockmgr: assert that LK_RETRY is not specified. 2004-05-30 20:49:04 +00:00
yamt c2f93eb91f vn_lock: don't pass LK_RETRY to VOP_LOCK. 2004-05-30 20:48:04 +00:00
jonathan d25d3eb263 Rework to make FAST_IPSEC PF_KEY dumps unicast and reliable:
Introduce new socket-layer function sbappendaddrchain() to
sys/kern/uipc_socket2.c: like sbappendaddr(), only takes a chain of
records and appends the entire chain in one pass. sbappendaddrchain()
also takes an `sbprio' argument, which indicates the caller requires
special `reliable' handling of the socket-buffer.  `sbprio' is
described in sys/sys/socketvar.h, although (for now) the different
levels are not yet implemented.

Rework sys/netipsec/key.c PF_KEY DUMP responses to build a chain of
mbuf records, one record per dump response. Unicast the entire chain
to the requestor, with all-or-none semantics.

Changed files;
 	sys/socketvar.h kern/uipc_socket2.c netipsec/key.c
Reviewed by:
	Jason Thorpe, Thor Lancelot Simon, post to tech-kern.

Todo: request pullup to 2.0 branch.  Post-2.0, rework sysctl() API for
dumps to use new record-chain constructors. Actually implement
the distinct service levels in sbappendaddrchain() so we can use them
to make PF_KEY ACQUIRE messages more reliable.
2004-05-27 19:19:00 +00:00
yamt a08da7645d regen. 2004-05-27 12:50:35 +00:00
yamt 9ae9b45731 update to match with the recent reality: getpages doesn't care about
vnode locks.
2004-05-27 12:49:09 +00:00
christos 3d4ca09443 turn off debugging. 2004-05-27 03:56:49 +00:00
christos 917cdbbd9e Unix 98 pty multiplexor device; original code from OpenBSD. 2004-05-27 02:56:38 +00:00
christos 19c4641ff8 (off_t)(long) is wrong when it comes to kernel addresses [because on a 32 bit
machine if the high bit is set they turn negative]. Make an intermediate cast
to unsigned long.
2004-05-26 16:28:05 +00:00
hannken 8c21bc6224 Add ffs internal snapshots. Written by Marshall Kirk McKusick for FreeBSD.
- Not enabled by default. Needs kernel option FFS_SNAPSHOT.
- Change parameters of ffs_blkfree.
- Let the copy-on-write functions return an error so spec_strategy
    may fail if the copy-on-write fails.
- Change genfs_*lock*() to use vp->v_vnlock instead of &vp->v_lock.
- Add flag B_METAONLY to VOP_BALLOC to return indirect block buffer.
- Add a function ffs_checkfreefile needed for snapshot creation.
- Add special handling of snapshot files:
    Snapshots may not be opened for writing and the attributes are read-only.
    Use the mtime as the time this snapshot was taken.
    Deny mtime updates for snapshot files.
- Add function transferlockers to transfer any waiting processes from
  one lock to another.
- Add vfsop VFS_SNAPSHOT to take a snapshot and make it accessible through
  a vnode.
- Add snapshot support to ls, fsck_ffs and dump.

Welcome to 2.0F.

Approved by: Jason R. Thorpe <thorpej@netbsd.org>
2004-05-25 14:54:55 +00:00
atatat 53c625655c Sysctl descriptions under vfs subtree 2004-05-25 04:44:43 +00:00
atatat 4de3747b89 Sysctl descriptions under net subtree (net.key not done) 2004-05-25 04:33:59 +00:00
atatat 5b22e79ada Remaining sysctl descriptions under kern subtree 2004-05-25 04:30:32 +00:00
jonathan 230fb9b8ab Eliminate several uses of `curproc' from the socket-layer code and from NFS.
Add a new explicit `struct proc *p' argument to socreate(), sosend().
Use that argument instead of curproc. Follow-on changes to pass that
argument to socreate(), sosend(), and (*so->so_send)() calls.
These changes reviewed and independently recoded  by Matt Thomas.

Changes to soreceive() and (*dom->dom_exernalize() from Matt Thomas:
pass soreceive()'s struct uio* uio->uio_procp to unp_externalize().
Eliminate curproc from unp_externalize.   Also, now soreceive() uses
its uio->uio_procp value, pass that same value downward to
((pr->pru_usrreq)() calls for consistency, instead of (struct proc * )0.

Similar changes in sys/nfs to eliminate (most) uses of curproc,
either via the req-> r_procp field of a struct nfsreq *req argument,
or by passing down new explicit struct proc * arguments.

Reviewed by: Matt Thomas, posted to tech-kern.
NB: The (*pr->pru_usrreq)() change should be tested on more (all!) protocols.
2004-05-22 22:52:13 +00:00
atatat dcf1a79f46 Add a DIAGNOSTIC check to detect un-initialized pools. 2004-05-20 05:08:29 +00:00
nathanw 78c16ce8ed Adjust code that tries to prevent cc_microtime() from going backwards
so that it doesn't fire when called twice in the same microsecond,
which can lead to large error accumulation.

Appears to fix "repeated gettimeofday() goes backwards" on a fast
alpha and i386 box.
2004-05-18 16:09:07 +00:00
yamt efc80878d1 use lockstatus() instead of L_BIGLOCK to check if we're holding a biglock.
fix PR/25595.
2004-05-18 11:59:11 +00:00
yamt b4831906b2 introduce LK_EXCLOTHER for lockstatus().
from FreeBSD, but a little differently.  instead of letting lockstatus()
take an additional thread argument, always use curlwp/curcpu.
2004-05-18 11:55:59 +00:00
ragge ac1e5c0888 Fix connect() "bug": If connect() is interrupted by a signal, the connection
attempt is terminated,  so if a process needs frequent timer interrupts
it can't ever connect() to a machine far away.

Bug found by Erik Lundgren, bugfix (for the same problem) is similar to
the way FreeBSD solved the same problem.

As a side effect, the new connect() behaviour conformes to Posix.
2004-05-18 11:31:49 +00:00
christos d3f7c2a23c Check for bad offsets at the beginning of the functions to save processing.
Idea from OpenBSD.
2004-05-14 16:36:33 +00:00
kleink 71b3883248 KNF previous. 2004-05-13 17:56:14 +00:00
christos 6033f15f86 Disable chgsbsize. It is not MPSAFE 2004-05-13 17:43:11 +00:00
matt 617ba1df60 In proc_representative_lwp, if there is an outstanding trap signal, return
the lwp that had the trap.
2004-05-12 21:10:09 +00:00
yamt 054ed3afcb use callout_schedule() for schedcpu(). 2004-05-12 20:13:58 +00:00
cube 8a0e3b4be1 In sysctl_destroyv, the newly created dnode structure must have its
version set to the correct value to prevent later failure of
sysctl_cvt_in.
2004-05-12 12:21:39 +00:00
kleink 90c0c343b0 Regen from syscalls.master rev. 1.142:
POSIX-2001: Change readlink(2)'s return type from int to ssize_t.
2004-05-10 22:30:41 +00:00
kleink 43b7ae77fa POSIX-2001: Change readlink(2)'s return type from int to ssize_t. 2004-05-10 22:28:23 +00:00
yamt 68b4772ef6 redo the previous (rev.1.58; overwrite a duplicate entry rather than leave it)
differently so that entries entered during we're doing pool_get() are
checked as well.  pointed by Paul Kranenburg on source-changes@.
2004-05-07 12:05:41 +00:00
pk fba1aa540d Provide a mutex for the process limits data structure. 2004-05-06 22:20:30 +00:00
yamt 8d615f3e18 cache_enter: when we found a duplicate entry,
simply overwrite it rather than leaving a stale entry.
2004-05-06 22:02:02 +00:00
yamt f573d83f7a no need to cache_purge() in getnewvnode().
it should be already done by vclean().
2004-05-06 22:01:14 +00:00
atatat 778eadaf46 Add a printf() to the other case in sysctl_createv() where a node did
not get attached for what should be an extremely unusual case.
2004-05-06 07:06:46 +00:00
pk b2260877bf proc_reparent() must be called with proclist write lock held. Make it so. 2004-05-04 21:58:47 +00:00
pk 2fb3dac280 Since a `vmspace' always includes a `vm_map' we can re-use vm_map's
reference count lock to also protect the vmspace's reference count.
2004-05-04 21:33:40 +00:00
pk 3ec3f724be crcopy: no need to lock if we're only reading the structure's reference count. 2004-05-04 21:27:28 +00:00
pk f3f1104ed8 Change sigactsfree() to take a `struct sigacts' pointer, to fit the needs
of exit1 (its only client).
2004-05-04 21:25:47 +00:00
pk d190ac352d exit1: if !BIGLOCK, once the exiting process has been placed on the zombie
list and the proclist lock is released, we shouldn't touch the process
structure anymore, since it may be collected immediately by a waiting
parent.
2004-05-04 21:23:39 +00:00
martin efe61cce0d Fix a comment.
Approved by Andrew Brown.
2004-05-03 13:39:50 +00:00
pk 7d0afa7f41 Add mutex to protect the ucred reference counter. 2004-05-02 12:36:55 +00:00
pk 2834786715 Add a mutex for mount point I/O and wait counters (i.e. the `mnt_wcnt',
`mnt_writeopcountupper' and `mnt_writeopcountlower' members).
2004-05-02 12:21:02 +00:00
pk 5c36071518 cache_enter: concurrent lookups in the same directory may race for a
cache entry. Upon detection, free our tentative entry and return.
2004-05-02 12:00:34 +00:00
pk 1bc2407362 sys_access: use crdup(). 2004-05-02 11:13:29 +00:00
matt d1fcd75db0 Define link_sets start/stop as ptype * const [] since they are in a
readonly section.
2004-05-01 07:16:55 +00:00
matt a029630354 Commons are not allowed in header files. extern them and declare them in
the appropriate .c file.
2004-05-01 06:17:26 +00:00
matt a035030007 Use EVCNT_ATTACH_STATIC 2004-05-01 02:24:38 +00:00
enami a874187808 ANSI'fy the rest of functions. 2004-04-30 07:51:59 +00:00
simonb 01837603b0 Fix "comments within comments" problem pointed out by Geoff Wing on
source-changes.
2004-04-27 05:25:33 +00:00
kleink 3925dc263a Regen from syscalls.master 1.141: [gs]ettimeofday(2) argument declaration
change.
2004-04-27 01:15:38 +00:00
kleink 681b62c2ce POSIX-2001: Add restrict keywords to gettimeofday(2) and setitimer(2);
further deprecate struct timezone usage by changing `tzp' argument to
gettimeofday() to void *; align utimes(2) declaration by changing `times`
argument from struct timeval * to struct timeval[2].  From Murray
Armfield in PR standards/25331.

In due curse, reflect these changes in futimes(2), lutimes(2), and
settimeofday(2).
2004-04-27 01:12:44 +00:00
kleink 679cb3e5a5 Regen from rev. 1.140:
POSIX-2001: Change the `who' argument to [gs]etpriority(2) from int
to id_t.  Partially addressing PR standards/25216 from Murray Armfield.
2004-04-25 22:21:17 +00:00
kleink 3e7f30c118 POSIX-2001: Change the `who' argument to [gs]etpriority(2) from int
to id_t.  Partially addressing PR standards/25216 from Murray Armfield.
2004-04-25 22:18:08 +00:00
simonb b5d0e6bf06 Initialise (most) pools from a link set instead of explicit calls
to pool_init.  Untouched pools are ones that either in arch-specific
code, or aren't initialiased during initial system startup.

 Convert struct session, ucred and lockf to pools.
2004-04-25 16:42:40 +00:00
yamt ab195ed32f bio_doread: vp is always non-NULL here. 2004-04-25 12:41:12 +00:00
matt f86644a808 Constify the table argument to ttspeedtab. 2004-04-25 06:13:38 +00:00
atatat 3f800573aa Be consistent about using sysc_init_field() 2004-04-25 05:54:38 +00:00
atatat 990f278f7a Remove dynamic sysctl node version 0 from the tree. It seemed okay at
first, but quickly showed its shortcomings.  The version 1 node we're
now using should be good for a while.
2004-04-25 05:47:52 +00:00
simonb 9bc855a931 s/the the/the/ (only in sources that aren't regularly imported from
elsewhere).
2004-04-23 02:58:27 +00:00
yamt 05076bfbb9 chgsbsize: correct limit check and ui_sbsize calculation.
ok'ed by Christos Zoulas.
2004-04-23 02:13:29 +00:00
enami 45a4841ce9 Copy fsidx so that not to break binary compatibility of mountd etc. 2004-04-22 03:47:58 +00:00
matt e50668c7fa Constify protosw arrays. This can reduce the kernel .data section by
over 4K (if all the network protocols) are loaded.
2004-04-22 01:01:40 +00:00
matt fde909e1a1 Add prototype for uiomove_frombuf. Change uiomove_frombuf to use size_t
for its length argument (to be the same as uiomove).  Remove code that
dealt with length being negative.
2004-04-21 20:31:50 +00:00
itojun d2f1c029b9 kill sprintf, use snprintf 2004-04-21 18:40:37 +00:00
christos 6bd1d6d4db Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
2004-04-21 01:05:31 +00:00
christos ed95f3e980 Charge root for socket buffers without a socket pointer. 2004-04-19 03:44:46 +00:00
lukem fad77af2ac Add "vfs.generic.fstypes" sysctl, which contains a space separate
list of file system types currently supported by the kernel.
Previously there wasn't an easy way to determine this.
(Code shamelessly cribbed from subr_disk.c::sysctl_hw_disknames().)

Use LIST_FOREACH() appropriately.
2004-04-19 00:15:55 +00:00
matt ac57eb9d5b Constify sun_noname. 2004-04-18 22:20:32 +00:00