ifnet: Make ifnet and ifindex2ifnet MPSAFE - Accessing to these two global variables from non-netisr threads uses ifnet lock. This kind of accessing is from - Accessing to ifindex2ifnet from netisrs are lockless MPSAFE. - Netisrs no longer access ifnet, instead they access ifnet array as of this commit, which is lockless MPSAFE. Rules for accessing ifnet and ifindex2ifnet is commented near the declaration of the related global variables/functions in net/if_var.h.
kernel - Change time_second to time_uptime for all expiration calculations * Vet the entire kernel and change use cases for expiration calculations using time_second to use time_uptime instead. * Protects these expiration calculations from step changes in the wall time, particularly needed for route table entries. * Probably requires further variable type adjustments but the use of time_uptime instead if time_second is highly unlikely to ever overrun any demotions to int still present.
NFS - Fix numerous issues with NFS root mounts, primarily for vkernels vkernels do not inherit BOOTP data from PXE and because of this a number of code paths are run which are not run in non-vkernel NFS mounts. * Fix a kernel memory check that was failing for vkernels and causing a panic. * Change the default BOOTP socket type from UDP to TCP. * Adjust the default vfs.nfs.maxasyncbio value based on available mbuf clusters. The value will be adjusted down for systems with small memory footprints. Otherwise NFS can trivially run the system out of mbufs. * Fix bugs in the NFS BIO queueing code related to values of vfs.nfs.maxasyncbio lower then the maximum. * Remove the BOOTP_NFSV3 option when probing for the type of NFS mount (V2 or V3). The BOOTP_NFSV3 kernel option is no longer required for root mounts to default to NFSv3. This also works around a bug related to large write()s with NFSv2 which has not yet been found. Reported-by: Rumko <rumcic@gmail.com>
Parallelize ifnet.if_addrhead accessing by duplicating the list itself on each CPU, each list element points to ifaddr: - Add SI_SUB_PRE_DRIVERS before SI_SUB_DRIVERS, so action could be taken before drivers' initialization (mainly before NIC driver's if_attach()) - Move netisr_init() to the FIRST of SI_SUB_PRE_DRIVERS, so that netmsg_service_port_init() could be called in earlier stage of system initialization. - Create one thread on each CPU to propagate changes to ifnet.if_addrhead. Their thread ports are registered with netmsg_service_port_init() for port syncing operation. - Change to ifnet.if_addrhead begins in netisr0, i.e. serial of changes to ifnet.if_addrhead are serialized by netisr0 - ifaddr's refcnt is moved to its list elements, i.e. per-CPU refcnt. They are initialized to 1 instead of 0. - A magic field is added to ifaddr list element to make sure that IFAREF and IFAFREE are called on valid ifaddr list element. This field is initialized to a magic value and is wiped out once the list element's refcnt drops to 0 - To close the gap between testing and freeing, once the ifaddr list element's refcnt drops to 0, ifa_portfn(0) (a thread's port on CPU0) is poked to check whether ifaddr is referenced on other CPUs, if not, then ifaddr is freed on ifa_portfn(0) Reviewed-by: dillon@ (earlier version)
Add kernel syscall support for explicit blocking and non-blocking I/O regardless of the setting applied to the file pointer. send/sendmsg/sendto/recv/recvmsg/recfrom: New MSG_ flags defined in sys/socket.h may be passed to these functions to override the settings applied to the file pointer on a per-I/O basis. MSG_FBLOCKING - Force the operation to be blocking MSG_FNONBLOCKING- Force the operation to be non-blocking pread/preadv/pwrite/pwritev: These system calls have been renamed and wrappers will be added to libc. The new system calls are prefixed with a double underscore (like getcwd vs __getcwd) and include an additional flags argument. The new flags are defined in sys/fcntl.h and may be used to override settings applied to the file pointer on a per-I/O basis. Additionally, the internal __ versions of these functions now accept an offset of -1 to mean 'degenerate into a read/readv/write/writev' (i.e. use the offset in the file pointer and update it on completion). O_FBLOCKING - Force the operation to be blocking O_FNONBLOCKING - Force the operation to be non-blocking O_FAPPEND - Force the write operation to append (to a regular file) O_FOFFSET - (implied of the offset != -1) - offset is valid O_FSYNCWRITE - Force a synchronous write O_FASYNCWRITE - Force an asynchronous write O_FUNBUFFERED - Force an unbuffered operation (O_DIRECT) O_FBUFFERED - Force a buffered operation (negate O_DIRECT) If the flags do not specify an operation (e.g. neither FBLOCKING or FNONBLOCKING are set), then the settings in the file pointer are used. The original system calls will become wrappers in libc, without the flags arguments. The new system calls will be made available to libc_r to allow it to perform non-blocking I/O without having to mess with a descriptor's file flags. NOTE: the new __pread and __pwrite system calls are backwards compatible with the originals due to a pad byte that libc always set to 0. The new __preadv and __pwritev system calls are NOT backwards compatible, but since they were added to HEAD just two months ago I have decided to not renumber them either. NOTE: The subrev has been bumped to 1.5.4 and installworld will refuse to install if you are not running at least a 1.5.4 kernel.