obrien [Fri, 9 Mar 2001 12:29:08 +0000 (12:29 +0000)]
Warner gave a nice followup in email, and I thought it would be nice to
get it in the CVS logs. This pertains to rev 1.30 (and the MFC of it):
Space optimization forces the kernel to always use fragments to store
parts of file, rather than using an entire block when less than an
entire block has been written. This forces files to be as small as
they can be at the minor cost of time to do all the fussy stuff. The
cpio image that we put on the disk was so close to filling the disk
exactly that this minor minor difference made a big difference. The
system changed things to time optmization on the first write. When
the end of file was hit, it tried to allocate a full block (4k), but
there was only 3k left on the disk (since you get only 1407 blocks on
a 1.44 floppy) so it failed. So this change nails the space
optmiziation in place for the whole operation.
Make it possible to use IP_TTL and IP_TOS setsockopt(2) options
on certain types of SOCK_RAW sockets. Also, use the ip.ttl MIB
variable instead of MAXTTL constant as the default time-to-live
value for outgoing IP packets all over the place, as we already
do this for TCP and UDP.
jlemon [Fri, 9 Mar 2001 08:16:40 +0000 (08:16 +0000)]
Push the test for a disconnected socket when accept()ing down to the
protocol layer. Not all protocols behave identically. This fixes the
brokenness observed with unix-domain sockets (and postfix)
jhb [Fri, 9 Mar 2001 07:24:17 +0000 (07:24 +0000)]
Fix mtx_legal2block. The only time that it is bad to block on a mutex is
if we hold a spin mutex, since we can trivially get into deadlocks if we
start switching out of processes that hold spinlocks. Checking to see if
interrupts were disabled was a sort of cheap way of doing this since most
of the time interrupts were only disabled when holding a spin lock. At
least on the i386. To fix this properly, use a per-process counter
p_spinlocks that counts the number of spin locks currently held, and
instead of checking to see if interrupts are disabled in the witness code,
check to see if we hold any spin locks. Since child processes always
start up with the sched lock magically held in fork_exit(), we initialize
p_spinlocks to 1 for child processes. Note that proc0 doesn't go through
fork_exit(), so it starts with no spin locks held.
jhb [Fri, 9 Mar 2001 03:09:30 +0000 (03:09 +0000)]
- Add 2001 to copyright.
- Kthread functions return an error status, they don't set errno to an
error status.
- Remove the BUGS section as all the bugs listed have been fixed now.
obrien [Fri, 9 Mar 2001 01:03:15 +0000 (01:03 +0000)]
newfs with `-m 1'
This is needed even with `-o space' as the kernel decides to be "helpful"
and not really do space optimization. Looking at src/sys/ufs/ffs/ffs_alloc.c
we see why: if (fs->fs_minfree <= 5 ||
fs->fs_cstotal.cs_nffree >
(off_t)fs->fs_dsize * fs->fs_minfree / (2 * 100))
break;
log(LOG_NOTICE, "%s: optimization changed from SPACE to TIME\n"
I have picked `1' vs. `0' just incase some code somewhere has the assumption
the %free can never be `0'.
Helped with understanding why -m 1 made a different: imp
bmilekic [Thu, 8 Mar 2001 19:21:45 +0000 (19:21 +0000)]
Fix is a similar race condition as existed in the mbuf code. When we go
into an interruptable sleep and we increment a sleep count, we make sure
that we are the thread that will decrement the count when we wakeup.
Otherwise, what happens is that if we get interrupted (signal) and we
have to wake up, but before we get our mutex, some thread that wants
to wake us up detects that the count is non-zero and so enters wakeup_one(),
but there's nothing on the sleep queue and so we don't get woken up. The
thread will still decrement the sleep count, which is bad because we will
also decrement it again later (as we got interrupted) and are already off
the sleep queue.
iedowse [Thu, 8 Mar 2001 19:03:26 +0000 (19:03 +0000)]
It was possible for ip_forward() to supply to icmp_error()
an IP header with ip_len in network byte order. For certain
values of ip_len, this could cause icmp_error() to write
beyond the end of an mbuf, causing mbuf free-list corruption.
This problem was observed during generation of ICMP redirects.
We now make quite sure that the copy of the IP header kept
for icmp_error() is stored in a non-shared mbuf header so
that it will not be modified by ip_output().
Also:
- Calculate the correct number of bytes that need to be
retained for icmp_error(), instead of assuming that 64
is enough (it's not).
- In icmp_error(), use m_copydata instead of bcopy() to
copy from the supplied mbuf chain, in case the first 8
bytes of IP payload are not stored directly after the IP
header.
- Sanity-check ip_len in icmp_error(), and panic if it is
less than sizeof(struct ip). Incoming packets with bad
ip_len values are discarded in ip_input(), so this should
only be triggered by bugs in the code, not by bad packets.
This patch results from code and suggestions from Ruslan, Bosko,
Jonathan Lemon and Matt Dillon, with important testing by Mike
Tancsa, who could reproduce this problem at will.
gallatin [Thu, 8 Mar 2001 15:17:38 +0000 (15:17 +0000)]
Take the KINFO_PROC_SIZE back down to 912 on alpha.
Since the compiler lays out the stuct so that pointers are naturally
(8-byte) aligned aligned, adding the int ki_layout didn't change the size of
the stuct; it just converted the alignment padding to a usable struct
field.
dec [Thu, 8 Mar 2001 13:57:41 +0000 (13:57 +0000)]
Submitted by: Ian Dowse <iedowse@maths.tcd.ie>, David Cross <dec@freebsd.org>
Reviewed by: David Cross <dec@freebsd.org>, jkh <jkh@freebsd.org>
Approved by: jkh <jkh@freebsd.org>
Obtained from: Ian Dowse <iedowse@maths.tcd.ie>, David Cross <dec@freebsd.org>
We have been running this patch on a production NIS server for 2.5 weeks now.
Normally we would have ypserv die at least once a week, and often many times
a day.
This patch treats and error from select as zeroing out the FD_SET to indicate
that no fds are ready for reading. This is safe because the rpc code
always re-inits the FDSET before calling select.
tmm [Thu, 8 Mar 2001 01:20:43 +0000 (01:20 +0000)]
Make the SYSCTL_OUT handlers sysctl_old_user() and sysctl_old_kernel()
more robust. They would correctly return ENOMEM for the first time when
the buffer was exhausted, but subsequent calls in this case could cause
writes ouside of the buffer bounds.
tmm [Thu, 8 Mar 2001 00:55:08 +0000 (00:55 +0000)]
Fix two bugs in null suffix handling. Both occured only after the suffix
list was cleared.
Rules with null suffixes would not be rebuilt when the suffixes were
added again.
Adding null suffix rules would fail when a rule for the same source was
declared before the suffix list was cleared.
PR: 23328, 24102
Reviewed by: will
Approved by: rwatson
wpaul [Wed, 7 Mar 2001 18:52:22 +0000 (18:52 +0000)]
Remember to actually program the MAC address into the unicast filter
in vr_init(). The VIA Rhine chip happens to be able to automatically
read its station address from the EEPROM automatically when reset,
so you don't need to program the filter if you want to keep using the
factory default address, but if you want to change it with "ifconfig vr0
ether xx:xx:xx:xx:xx:xx" then we need to manually set it in the init
routine.
iwasaki [Wed, 7 Mar 2001 15:22:14 +0000 (15:22 +0000)]
Bring our local hack for wakeup back from
sys/contrib/dev/acpica/Subsystem/Hardware/Attic/hwxface.c to the proper
location after AcpiEnterSleepState().
- Wait for the WAK_STS bit
- Evaluate the _WAK method and check result code
peter [Wed, 7 Mar 2001 10:38:46 +0000 (10:38 +0000)]
Properly detach at startup. We could be passing revoked fd's to
child processes or starting children with no fd 0 (stdin) at all etc.
This is currently breaking on hub.freebsd.org.
scottl [Wed, 7 Mar 2001 08:37:49 +0000 (08:37 +0000)]
Set si_iosize_max to 64K, even though the adapter seems to be able to do more.
This puts us safely in line with Adaptec documentation and shouldn't really
affect anything.
mckusick [Wed, 7 Mar 2001 07:09:55 +0000 (07:09 +0000)]
Fixes to track snapshot copy-on-write checking in the specinfo
structure rather than assuming that the device vnode would reside
in the FFS filesystem (which is obviously a broken assumption with
the device filesystem).
mckusick [Wed, 7 Mar 2001 06:52:12 +0000 (06:52 +0000)]
Bitch more loudly when someone botches changes to kinfo_proc
in the hopes that they will actually *read* the comment above
it and *follow* the instructions so as to cause all the rest
of us less a lot less grief.
jhb [Wed, 7 Mar 2001 05:21:47 +0000 (05:21 +0000)]
- Don't hold the proc lock across VREF and the fd* functions to avoid lock
order reversals.
- Add some preliminary locking in the !RF_PROC case.
- Protect p_estcpu with sched_lock.
jhb [Wed, 7 Mar 2001 03:53:39 +0000 (03:53 +0000)]
- Release Giant a bit earlier on syscall exit.
- Don't try to grab Giant before postsig() in userret() as it is no longer
needed.
- Don't grab Giant before psignal() in ast() but get the proc lock instead.
jhb [Wed, 7 Mar 2001 03:09:40 +0000 (03:09 +0000)]
Proc locking. Lock around psignal() and also ensure both an exclusive
proctree lock and the process lock are held when updating p_pptr and
p_oppid. When we are just reaading p_pptr we only need the proc lock and
not a proctree lock as well.
jhb [Wed, 7 Mar 2001 02:59:54 +0000 (02:59 +0000)]
- Proc locking. Most of signal handling is now MP safe and doesn't require
Giant. The only exception is the CANSIGNAL() macro. Unlocking the proc
lock around sendsig() in trapsignal() is also questionable. Note that
the functions sigexit(), psignal(), and issignal() must be called with
the proc lock of the process in question held. postsig() and
trapsignal() should not be called with the proc lock held, but they
also do not require Giant anymore either.
- Remove spl's that are now no longer needed as they are fully replaced.
jhb [Wed, 7 Mar 2001 02:45:15 +0000 (02:45 +0000)]
- Add an extra check in priority_propagation() for UP systems to ensure we
don't end up back at ourselves which would indicate deadlock.
- Add the proc lock to the witness dup_list as we may hold more than one
process lock at a time.
- Don't assert a mutex is owned in _mtx_unlock_sleep() as that is too late.
We do the checks in the macros instead.
jhb [Wed, 7 Mar 2001 02:36:47 +0000 (02:36 +0000)]
- Use _PHOLD and move it before a PROC_UNLOCK to reduce the number of
mutex operations in kthread_create().
- Lock a kthread's proc before changing its parent via proc_reparent().
- Test P_KTHREAD not P_SYSTEM in kthread_suspend() and kthread_resume().
P_SYSTEM just means that the process shouldn't be swapped and is used
for vinum's daemon for example.
- Lock all the signal state used for suspending and resuming kthreads with
the proc lock.
jhb [Wed, 7 Mar 2001 02:30:39 +0000 (02:30 +0000)]
- Lock the forklist with an sx lock.
- Add proc locking to fork1(). Always lock the child procoess (new
process) first when both processes need to be locked at the same
time.
- Remove unneeded spl()'s as the data they protected is now locked.
- Ensure that the proctree is exclusively locked and the new process is
locked when setting up the parent process pointer.
- Lock the check for P_KTHREAD in p_flag in fork_exit().
jhb [Wed, 7 Mar 2001 02:25:13 +0000 (02:25 +0000)]
Check to see if p_fd is NULL before derferencing it in checkdirs(). It's
possible for us to see a process in the early stages of fork before p_fd
has been initialized. Ideally, we wouldn't stick a process on the allproc
list until it was fully created however.
jhb [Wed, 7 Mar 2001 02:22:31 +0000 (02:22 +0000)]
- Call proc_reparent() when handing a process off to init in exit rather
than dinking around in the process lists explicitly.
- Hold both the proctree lock and proc lock of the child process when
reparenting a process via proc_reparent.
- Lock processes while sending them signals.
- Miscellaenous proc locking.
- proc_reparent() now asserts that the child is locked in addition to an
exclusive proctree lock.
jhb [Wed, 7 Mar 2001 02:17:43 +0000 (02:17 +0000)]
- Hold both an exclusive proctree lock and the proc lock when reparenting
a traced process during exit.
- Lock the parent process while sending it SIGCHLD.
jhb [Wed, 7 Mar 2001 02:06:08 +0000 (02:06 +0000)]
- Include <sys/systm.h> for KASSERT().
- Move the _mtx_assert() prototype up to the top of the file with the rest
of the function prototypes.
- Define all the mtx_foo() macros in terms of mtx_foo_flags().
- Add a KASSERT() to check for invalid options in mtx_lock_flags().
- Move the mtx_assert() to ensure a mutex is owned before releasing it
in front of WITNESS_EXIT() in all the mtx_unlock_* macros.
- Change the MPASS* macros to be on #ifdef INVARIANTS, not just #ifdef
MUTEX_DEBUG since most of them check to see that the mutex functions are
called properly. Define MPASS4() in terms of KASSERT() to do this.
- Define MPASS{,[23]} in terms of MPASS4() to simplify things and avoid
code duplication.
jhb [Wed, 7 Mar 2001 01:51:34 +0000 (01:51 +0000)]
- In the locking key for struct proc, generalize the '+' symbol to mean
that write access to a member requires both locks and read access only
requires one of the given locks. Convert instances of '(c+)' to
'(c + k)' as a result.
- Change p_pptr from (e) to (c + e).
- Change p_oppid from (c) to (c + e).
- Change p_args from (b?) to (c + k).
- Move the actual work of STOPEVENT, PHOLD, and PRELE to _STOPEVENT,
_PHOLD, and _PRELE. The new macros do not acquire the proc lock and
simply assert that it is held. The non _ prefixed macros acquire the
proc lock and then call the _ prefixed macros.
- Add a PROC_LOCK_NOSWITCH() macro to be used when releasing the proc lock
while already holding a spin lock (usually sched_lock).
- Add a PROC_LOCK_ASSERT() macro to be used to make assertions about the
proc lock. It takes the usual mtx_assert() macro arguments as its
second argument.
jhb [Tue, 6 Mar 2001 23:13:15 +0000 (23:13 +0000)]
In order to avoid recursing on the backing mutex for sx locks in the
INVARIANTS case, define the actual KASSERT() in _SX_ASSERT_[SX]LOCKED
macros that are used in the sx code itself and convert the
SX_ASSERT_[SX]LOCKED macros to simple wrappers that grab the mutex for the
duration of the check.