Date: Tue, 24 Jan 2006 19:38:08 GMT From: Peter Wemm <peter@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 90297 for review Message-ID: <200601241938.k0OJc8k9047518@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=90297 Change 90297 by peter@peter_daintree on 2006/01/24 19:37:15 IFC @90295 Affected files ... .. //depot/projects/hammer/contrib/bc/bc/main.c#4 integrate .. //depot/projects/hammer/etc/rc.d/ipsec#10 integrate .. //depot/projects/hammer/sbin/dhclient/dhclient-script#7 integrate .. //depot/projects/hammer/sbin/mount/mount.c#24 integrate .. //depot/projects/hammer/sys/dev/ata/ata-pci.c#37 integrate .. //depot/projects/hammer/sys/dev/ath/if_ath.c#41 integrate .. //depot/projects/hammer/sys/dev/sound/pcm/channel.c#19 integrate .. //depot/projects/hammer/sys/dev/sound/pcm/feeder_rate.c#9 integrate .. //depot/projects/hammer/sys/kern/kern_ktrace.c#23 integrate .. //depot/projects/hammer/sys/kern/vfs_aio.c#41 integrate .. //depot/projects/hammer/sys/net80211/ieee80211.c#22 integrate .. //depot/projects/hammer/sys/net80211/ieee80211_input.c#29 integrate .. //depot/projects/hammer/sys/net80211/ieee80211_proto.c#22 integrate .. //depot/projects/hammer/sys/net80211/ieee80211_var.h#23 integrate .. //depot/projects/hammer/sys/netinet/in.c#22 integrate .. //depot/projects/hammer/sys/netinet/ip_fw2.c#73 integrate .. //depot/projects/hammer/sys/netinet/ip_icmp.c#29 integrate .. //depot/projects/hammer/sys/netinet/ip_input.c#58 integrate .. //depot/projects/hammer/sys/netinet/ip_mroute.c#32 integrate .. //depot/projects/hammer/sys/netinet/udp_usrreq.c#39 integrate .. //depot/projects/hammer/sys/nfsserver/nfs_serv.c#26 integrate .. //depot/projects/hammer/sys/vm/vm_page.c#48 integrate .. //depot/projects/hammer/sys/vm/vm_page.h#24 integrate .. //depot/projects/hammer/sys/vm/vm_pageq.c#13 integrate Differences ... ==== //depot/projects/hammer/contrib/bc/bc/main.c#4 (text+ko) ==== @@ -26,7 +26,7 @@ Western Washington University Bellingham, WA 98226-9062 -$FreeBSD: src/contrib/bc/bc/main.c,v 1.7 2005/09/27 18:52:17 brooks Exp $ +$FreeBSD: src/contrib/bc/bc/main.c,v 1.8 2006/01/24 06:38:35 brooks Exp $ *************************************************************************/ @@ -65,7 +65,7 @@ printf ("usage: %s [options] [file ...]\n%s%s%s%s%s%s%s", progname, " -h --help print this usage and exit\n", " -i --interactive force interactive mode\n", - " -l --mathlib use the predefine math routines\n", + " -l --mathlib use the predefined math routines\n", " -q --quiet don't print initial banner\n", " -s --standard non-standard bc constructs are errors\n", " -w --warn warn about non-standard bc constructs\n", ==== //depot/projects/hammer/etc/rc.d/ipsec#10 (text+ko) ==== @@ -1,7 +1,7 @@ #!/bin/sh # # $NetBSD: ipsec,v 1.7 2002/03/22 04:33:58 thorpej Exp $ -# $FreeBSD: src/etc/rc.d/ipsec,v 1.13 2005/10/12 22:14:44 pjd Exp $ +# $FreeBSD: src/etc/rc.d/ipsec,v 1.16 2006/01/24 15:16:55 pjd Exp $ # # PROVIDE: ipsec @@ -9,15 +9,13 @@ # BEFORE: DAEMON mountcritremote # KEYWORD: nojail -# it does not really require beforenetlkm. - . /etc/rc.subr name="ipsec" rcvar=`set_rcvar` start_precmd="ipsec_prestart" start_cmd="ipsec_start" -stop_precmd="test -f /etc/ipsec.conf" +stop_precmd="test -f $ipsec_file" stop_cmd="ipsec_stop" reload_cmd="ipsec_reload" extra_commands="reload" @@ -63,8 +61,6 @@ ipsec_reload() { echo "Reloading ipsec manual keys/policies." - ${ipsec_program} -F - ${ipsec_program} -FP ${ipsec_program} -f "$ipsec_file" } ==== //depot/projects/hammer/sbin/dhclient/dhclient-script#7 (text+ko) ==== @@ -1,7 +1,7 @@ #!/bin/sh # # $OpenBSD: dhclient-script,v 1.6 2004/05/06 18:22:41 claudio Exp $ -# $FreeBSD: src/sbin/dhclient/dhclient-script,v 1.12 2006/01/23 05:42:59 wes Exp $ +# $FreeBSD: src/sbin/dhclient/dhclient-script,v 1.13 2006/01/24 06:11:55 brooks Exp $ # # Copyright (c) 2003 Kenneth R Westerback <krw@openbsd.org> # @@ -276,7 +276,7 @@ if [ -n "$new_routers" ]; then $LOGGER "New Routers ($interface): $new_routers" set "$new_routers" - if ping -q -c 1 -w 1 "$1"; then + if ping -q -c 1 -t 1 "$1"; then if [ "$new_ip_address" != "$alias_ip_address" ]; then add_new_alias fi ==== //depot/projects/hammer/sbin/mount/mount.c#24 (text+ko) ==== @@ -38,7 +38,7 @@ static char sccsid[] = "@(#)mount.c 8.25 (Berkeley) 5/8/95"; #endif static const char rcsid[] = - "$FreeBSD: src/sbin/mount/mount.c,v 1.80 2006/01/18 11:00:34 pjd Exp $"; + "$FreeBSD: src/sbin/mount/mount.c,v 1.81 2006/01/24 15:26:36 pjd Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -717,7 +717,7 @@ void remopt(string, opt) char *string; - const char *opt; + const char *opt; { char *o, *p, *r; ==== //depot/projects/hammer/sys/dev/ata/ata-pci.c#37 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/ata/ata-pci.c,v 1.112 2006/01/18 13:10:17 sos Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/ata/ata-pci.c,v 1.113 2006/01/24 12:34:56 sos Exp $"); #include "opt_ata.h" #include <sys/param.h> @@ -439,7 +439,8 @@ { struct ata_channel *ch = device_get_softc(dev); - if (ch->dma && ((ch->flags & ATA_ALWAYS_DMASTAT) || + if (!ata_legacy(device_get_parent(dev)) && + ch->dma && ((ch->flags & ATA_ALWAYS_DMASTAT) || (ch->dma->flags & ATA_DMA_ACTIVE))) { int bmstat = ATA_IDX_INB(ch, ATA_BMSTAT_PORT) & ATA_BMSTAT_MASK; ==== //depot/projects/hammer/sys/dev/ath/if_ath.c#41 (text+ko) ==== @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/ath/if_ath.c,v 1.107 2006/01/09 17:13:20 sam Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/ath/if_ath.c,v 1.108 2006/01/23 20:58:05 sam Exp $"); /* * Driver for the Atheros Wireless LAN controller. @@ -2143,7 +2143,7 @@ * TU's and then calculate based on the beacon interval. * Note that we clamp the result to at most 10 beacons. */ - bs.bs_bmissthreshold = howmany(ic->ic_bmisstimeout, intval); + bs.bs_bmissthreshold = ic->ic_bmissthreshold; if (bs.bs_bmissthreshold > 10) bs.bs_bmissthreshold = 10; else if (bs.bs_bmissthreshold <= 0) ==== //depot/projects/hammer/sys/dev/sound/pcm/channel.c#19 (text+ko) ==== @@ -31,11 +31,14 @@ #include "feeder_if.h" -SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/pcm/channel.c,v 1.107 2006/01/22 15:06:49 ariff Exp $"); +SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/pcm/channel.c,v 1.108 2006/01/24 01:10:07 ariff Exp $"); #define MIN_CHUNK_SIZE 256 /* for uiomove etc. */ +#if 0 #define DMA_ALIGN_THRESHOLD 4 #define DMA_ALIGN_MASK (~(DMA_ALIGN_THRESHOLD - 1)) +#endif +#define DMA_ALIGN_MASK(bps) (~((bps) - 1)) #define CANCHANGE(c) (!(c->flags & CHN_F_TRIGGERED)) @@ -1253,7 +1256,10 @@ #if 1 hwptr &= ~a ; /* Apply channel align mask */ #endif +#if 0 hwptr &= DMA_ALIGN_MASK; /* Apply DMA align mask */ +#endif + hwptr &= DMA_ALIGN_MASK(sndbuf_getbps(c->bufhard)); return hwptr; } ==== //depot/projects/hammer/sys/dev/sound/pcm/feeder_rate.c#9 (text+ko) ==== @@ -66,7 +66,7 @@ #include <dev/sound/pcm/sound.h> #include "feeder_if.h" -SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/pcm/feeder_rate.c,v 1.15 2006/01/22 15:06:49 ariff Exp $"); +SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/pcm/feeder_rate.c,v 1.16 2006/01/24 01:10:07 ariff Exp $"); #define RATE_ASSERT(x, y) /* KASSERT(x,y) */ #define RATE_TEST(x, y) /* if (!(x)) printf y */ @@ -100,6 +100,7 @@ uint32_t alpha; /* interpolation distance */ uint32_t pos, bpos; /* current sample / buffer positions */ uint32_t bufsz; /* total buffer size */ + uint32_t stray; /* stray bytes */ int32_t scale, roll; /* scale / roll factor */ int16_t *buffer; uint32_t (*convert)(struct feed_rate_info *, int16_t *, uint32_t); @@ -350,6 +351,7 @@ info->pos = 2; info->bpos = 4; info->alpha = 0; + info->stray = 0; feed_rate_reset(info); if (info->src == info->dst) { /* @@ -710,12 +712,13 @@ slot = (((info->gx * (count >> 1)) + info->gy - info->alpha - 1) / info->gy) << 1; RATE_TEST((slot & 1) == 0, ("%s: Slot count not sample integral (%d)\n", __func__, slot)); - slot &= ~1; /* * Optimize buffer feeding aggresively to ensure calculated slot * can be fitted nicely into available buffer free space, hence * avoiding multiple feeding. */ + RATE_TEST(info->stray == 0, ("%s: [1] Stray bytes: %u\n", + __func__,info->stray)); if (info->pos != 2 && info->bpos - info->pos == 2 && info->bpos + slot > info->bufsz) { /* @@ -734,25 +737,31 @@ i = 0; for (;;) { for (;;) { - fetch = info->bufsz - info->bpos; + fetch = (info->bufsz - info->bpos) << 1; + fetch -= info->stray; RATE_ASSERT(fetch >= 0, ("%s: [1] Buffer overrun: %d > %d\n", __func__, info->bpos, info->bufsz)); - if (slot < fetch) - fetch = slot; - fetch &= ~1; + if ((slot << 1) < fetch) + fetch = slot << 1; if (fetch > 0) { - RATE_TEST((fetch & 1) == 0, - ("%s: Fetch size not sample integral (%d)\n", - __func__, fetch)); + RATE_ASSERT(((info->bpos << 1) - info->stray) >= 0 && + ((info->bpos << 1) - info->stray) < (info->bufsz << 1), + ("%s: DANGER - BUFFER OVERRUN! bufsz=%d, pos=%d\n", __func__, + info->bufsz << 1, (info->bpos << 1) - info->stray)); fetch = FEEDER_FEED(f->source, c, - (uint8_t *)(info->buffer + info->bpos), - fetch << 1, source); + (uint8_t *)(info->buffer) + (info->bpos << 1) - info->stray, + fetch, source); + info->stray = 0; if (fetch == 0) break; RATE_TEST((fetch & 3) == 0, ("%s: Fetch size not byte integral (%d)\n", __func__, fetch)); + info->stray += fetch & 3; + RATE_TEST(info->stray == 0, + ("%s: Stray bytes detected (%d)\n", + __func__, info->stray)); fetch >>= 1; fetch &= ~1; info->bpos += fetch; @@ -790,6 +799,7 @@ * to beginning of buffer so next cycle can * interpolate using it. */ + RATE_TEST(info->stray == 0, ("%s: [2] Stray bytes: %u\n", __func__, info->stray)); info->buffer[0] = info->buffer[info->pos - 2]; info->buffer[1] = info->buffer[info->pos - 1]; info->bpos = 2; @@ -798,7 +808,10 @@ if (i == count) break; } +#if 0 RATE_TEST(count == i, ("Expect: %u , Got: %u\n", count << 1, i << 1)); +#endif + RATE_TEST(info->stray == 0, ("%s: [3] Stray bytes: %u\n", __func__, info->stray)); return i << 1; } ==== //depot/projects/hammer/sys/kern/kern_ktrace.c#23 (text+ko) ==== @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/kern/kern_ktrace.c,v 1.105 2005/11/14 19:30:09 rwatson Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/kern_ktrace.c,v 1.106 2006/01/23 21:45:32 jhb Exp $"); #include "opt_ktrace.h" #include "opt_mac.h" @@ -952,6 +952,7 @@ error = VOP_WRITE(vp, &auio, IO_UNIT | IO_APPEND, cred); VOP_UNLOCK(vp, 0, td); vn_finished_write(mp); + vrele(vp); mtx_unlock(&Giant); if (!error) return; ==== //depot/projects/hammer/sys/kern/vfs_aio.c#41 (text+ko) ==== @@ -19,7 +19,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/kern/vfs_aio.c,v 1.211 2006/01/23 10:27:15 davidxu Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/vfs_aio.c,v 1.215 2006/01/24 07:24:24 davidxu Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -184,24 +184,50 @@ struct __aiocb_private _aiocb_private; } oaiocb_t; +/* + * Below is a key of locks used to protect each member of struct aiocblist + * aioliojob and kaioinfo and any backends. + * + * * - need not protected + * a - locked by proc mtx + * b - locked by backend lock, the backend lock can be null in some cases, + * for example, BIO belongs to this type, in this case, proc lock is + * reused. + * c - locked by aio_job_mtx, the lock for the generic file I/O backend. + */ + +/* + * Current, there is only two backends: BIO and generic file I/O. + * socket I/O is served by generic file I/O, this is not a good idea, since + * disk file I/O and any other types without O_NONBLOCK flag can block daemon + * threads, if there is no thread to serve socket I/O, the socket I/O will be + * delayed too long or starved, we should create some threads dedicated to + * sockets to do non-blocking I/O, same for pipe and fifo, for these I/O + * systems we really need non-blocking interface, fiddling O_NONBLOCK in file + * structure is not safe because there is race between userland and aio + * daemons. + */ + struct aiocblist { - TAILQ_ENTRY(aiocblist) list; /* List of jobs */ - TAILQ_ENTRY(aiocblist) plist; /* List of jobs for proc */ - TAILQ_ENTRY(aiocblist) allist; - int jobflags; - int jobstate; - int inputcharge; - int outputcharge; - struct buf *bp; /* Buffer pointer */ - struct proc *userproc; /* User process */ - struct ucred *cred; /* Active credential when created */ - struct file *fd_file; /* Pointer to file structure */ - struct aioliojob *lio; /* Optional lio job */ - struct aiocb *uuaiocb; /* Pointer in userspace of aiocb */ - struct knlist klist; /* list of knotes */ - struct aiocb uaiocb; /* Kernel I/O control block */ - ksiginfo_t ksi; /* Realtime signal info */ - struct task biotask; + TAILQ_ENTRY(aiocblist) list; /* (b) internal list of for backend */ + TAILQ_ENTRY(aiocblist) plist; /* (a) list of jobs for each backend */ + TAILQ_ENTRY(aiocblist) allist; /* (a) list of all jobs in proc */ + int jobflags; /* (a) job flags */ + int jobstate; /* (b) job state */ + int inputcharge; /* (*) input blockes */ + int outputcharge; /* (*) output blockes */ + struct buf *bp; /* (*) private to BIO backend, + * buffer pointer + */ + struct proc *userproc; /* (*) user process */ + struct ucred *cred; /* (*) active credential when created */ + struct file *fd_file; /* (*) pointer to file structure */ + struct aioliojob *lio; /* (*) optional lio job */ + struct aiocb *uuaiocb; /* (*) pointer in userspace of aiocb */ + struct knlist klist; /* (a) list of knotes */ + struct aiocb uaiocb; /* (*) kernel I/O control block */ + ksiginfo_t ksi; /* (a) realtime signal info */ + struct task biotask; /* (*) private to BIO backend */ }; /* jobflags */ @@ -215,22 +241,22 @@ #define AIOP_FREE 0x1 /* proc on free queue */ struct aiothreadlist { - int aiothreadflags; /* AIO proc flags */ - TAILQ_ENTRY(aiothreadlist) list; /* List of processes */ - struct thread *aiothread; /* The AIO thread */ + int aiothreadflags; /* (c) AIO proc flags */ + TAILQ_ENTRY(aiothreadlist) list; /* (c) list of processes */ + struct thread *aiothread; /* (*) the AIO thread */ }; /* * data-structure for lio signal management */ struct aioliojob { - int lioj_flags; - int lioj_count; - int lioj_finished_count; - struct sigevent lioj_signal; /* signal on all I/O done */ - TAILQ_ENTRY(aioliojob) lioj_list; - struct knlist klist; /* list of knotes */ - ksiginfo_t lioj_ksi; /* Realtime signal info */ + int lioj_flags; /* (a) listio flags */ + int lioj_count; /* (a) listio flags */ + int lioj_finished_count; /* (a) listio flags */ + struct sigevent lioj_signal; /* (a) signal on all I/O done */ + TAILQ_ENTRY(aioliojob) lioj_list; /* (a) lio list */ + struct knlist klist; /* (a) list of knotes */ + ksiginfo_t lioj_ksi; /* (a) Realtime signal info */ }; #define LIOJ_SIGNAL 0x1 /* signal on all done (lio) */ @@ -241,29 +267,31 @@ * per process aio data structure */ struct kaioinfo { - int kaio_flags; /* per process kaio flags */ - int kaio_maxactive_count; /* maximum number of AIOs */ - int kaio_active_count; /* number of currently used AIOs */ - int kaio_qallowed_count; /* maxiumu size of AIO queue */ - int kaio_count; /* size of AIO queue */ - int kaio_ballowed_count; /* maximum number of buffers */ - int kaio_buffer_count; /* number of physio buffers */ - TAILQ_HEAD(,aiocblist) kaio_all; /* all AIOs in the process */ - TAILQ_HEAD(,aiocblist) kaio_done; /* done queue for process */ - TAILQ_HEAD(,aioliojob) kaio_liojoblist; /* list of lio jobs */ - TAILQ_HEAD(,aiocblist) kaio_jobqueue; /* job queue for process */ - TAILQ_HEAD(,aiocblist) kaio_bufqueue; /* buffer job queue for process */ - TAILQ_HEAD(,aiocblist) kaio_sockqueue; /* queue for aios waiting on sockets */ + int kaio_flags; /* (a) per process kaio flags */ + int kaio_maxactive_count; /* (*) maximum number of AIOs */ + int kaio_active_count; /* (c) number of currently used AIOs */ + int kaio_qallowed_count; /* (*) maxiumu size of AIO queue */ + int kaio_count; /* (a) size of AIO queue */ + int kaio_ballowed_count; /* (*) maximum number of buffers */ + int kaio_buffer_count; /* (a) number of physio buffers */ + TAILQ_HEAD(,aiocblist) kaio_all; /* (a) all AIOs in the process */ + TAILQ_HEAD(,aiocblist) kaio_done; /* (a) done queue for process */ + TAILQ_HEAD(,aioliojob) kaio_liojoblist; /* (a) list of lio jobs */ + TAILQ_HEAD(,aiocblist) kaio_jobqueue; /* (a) job queue for process */ + TAILQ_HEAD(,aiocblist) kaio_bufqueue; /* (a) buffer job queue for process */ + TAILQ_HEAD(,aiocblist) kaio_sockqueue; /* (a) queue for aios waiting on sockets, + * not used yet. + */ }; #define KAIO_RUNDOWN 0x1 /* process is being run down */ #define KAIO_WAKEUP 0x2 /* wakeup process when there is a significant event */ -static TAILQ_HEAD(,aiothreadlist) aio_freeproc; /* Idle daemons */ +static TAILQ_HEAD(,aiothreadlist) aio_freeproc; /* (c) Idle daemons */ static struct sema aio_newproc_sem; static struct mtx aio_job_mtx; static struct mtx aio_sock_mtx; -static TAILQ_HEAD(,aiocblist) aio_jobs; /* Async job list */ +static TAILQ_HEAD(,aiocblist) aio_jobs; /* (c) Async job list */ static struct unrhdr *aiod_unr; static void aio_init_aioinfo(struct proc *p); @@ -420,10 +448,18 @@ error = kqueue_del_filteropts(EVFILT_AIO); if (error) return error; + error = kqueue_del_filteropts(EVFILT_LIO); + if (error) + return error; async_io_version = 0; aio_swake = NULL; taskqueue_free(taskqueue_aiod_bio); delete_unrhdr(aiod_unr); + uma_zdestroy(kaio_zone); + uma_zdestroy(aiop_zone); + uma_zdestroy(aiocb_zone); + uma_zdestroy(aiol_zone); + uma_zdestroy(aiolio_zone); EVENTHANDLER_DEREGISTER(process_exit, exit_tag); EVENTHANDLER_DEREGISTER(process_exec, exec_tag); mtx_destroy(&aio_job_mtx); @@ -579,6 +615,7 @@ struct aiocblist *cbe, *cbn; struct file *fp; struct socket *so; + int remove; KASSERT(curthread->td_proc == p, ("%s: called on non-curproc", __func__)); @@ -595,35 +632,30 @@ * Try to cancel all pending requests. This code simulates * aio_cancel on all pending I/O requests. */ - while ((cbe = TAILQ_FIRST(&ki->kaio_sockqueue))) { - fp = cbe->fd_file; - so = fp->f_data; - mtx_lock(&aio_sock_mtx); - TAILQ_REMOVE(&so->so_aiojobq, cbe, list); - mtx_unlock(&aio_sock_mtx); - TAILQ_REMOVE(&ki->kaio_sockqueue, cbe, plist); - TAILQ_INSERT_HEAD(&ki->kaio_jobqueue, cbe, plist); - cbe->jobstate = JOBST_JOBQGLOBAL; - } - TAILQ_FOREACH_SAFE(cbe, &ki->kaio_jobqueue, plist, cbn) { + remove = 0; mtx_lock(&aio_job_mtx); if (cbe->jobstate == JOBST_JOBQGLOBAL) { TAILQ_REMOVE(&aio_jobs, cbe, list); - mtx_unlock(&aio_job_mtx); + remove = 1; + } else if (cbe->jobstate == JOBST_JOBQSOCK) { + fp = cbe->fd_file; + MPASS(fp->f_type == DTYPE_SOCKET); + so = fp->f_data; + TAILQ_REMOVE(&so->so_aiojobq, cbe, list); + remove = 1; + } + mtx_unlock(&aio_job_mtx); + + if (remove) { cbe->jobstate = JOBST_JOBFINISHED; cbe->uaiocb._aiocb_private.status = -1; cbe->uaiocb._aiocb_private.error = ECANCELED; TAILQ_REMOVE(&ki->kaio_jobqueue, cbe, plist); aio_bio_done_notify(p, cbe, DONE_QUEUE); - } else { - mtx_unlock(&aio_job_mtx); } } - if (TAILQ_FIRST(&ki->kaio_sockqueue)) - goto restart; - /* Wait for all running I/O to be finished */ if (TAILQ_FIRST(&ki->kaio_bufqueue) || TAILQ_FIRST(&ki->kaio_jobqueue)) { @@ -685,14 +717,7 @@ * and this code should work in all instances for every type of file, including * pipes, sockets, fifos, and regular files. * - * XXX I don't think these code work well with pipes, sockets and fifo, the - * problem is the aiod threads can be blocked if there is not data or no - * buffer space, and file was not opened with O_NONBLOCK, all aiod threads - * will be blocked if there is couple of such processes. We need a FOF_OFFSET - * like flag to override f_flag to tell low level system to do non-blocking - * I/O, we can not muck O_NONBLOCK because there is full of race between - * userland and aiod threads, although there is a trigger mechanism for socket, - * but it also does not work well if userland is misbehaviored. + * XXX I don't think it works well for socket, pipe, and fifo. */ static void aio_process(struct aiocblist *aiocbe) @@ -833,8 +858,6 @@ struct proc *curcp, *mycp, *userp; struct vmspace *myvm, *tmpvm; struct thread *td = curthread; - struct pgrp *newpgrp; - struct session *newsess; int id = (intptr_t)_id; /* @@ -867,14 +890,7 @@ fdfree(td); /* The daemon resides in its own pgrp. */ - MALLOC(newpgrp, struct pgrp *, sizeof(struct pgrp), M_PGRP, - M_WAITOK | M_ZERO); - MALLOC(newsess, struct session *, sizeof(struct session), M_SESSION, - M_WAITOK | M_ZERO); - - sx_xlock(&proctree_lock); - enterpgrp(mycp, mycp->p_pid, newpgrp, newsess); - sx_xunlock(&proctree_lock); + setsid(td, NULL); /* * Wakeup parent process. (Parent sleeps to keep from blasting away @@ -1051,7 +1067,7 @@ mtx_lock(&aio_job_mtx); num_aio_procs++; if (start != NULL) - *start--; + (*start)--; mtx_unlock(&aio_job_mtx); } else { free_unr(aiod_unr, id); @@ -1187,47 +1203,33 @@ aio_swake_cb(struct socket *so, struct sockbuf *sb) { struct aiocblist *cb, *cbn; - struct proc *p; - struct kaioinfo *ki = NULL; int opcode, wakecount = 0; struct aiothreadlist *aiop; - if (sb == &so->so_snd) { + if (sb == &so->so_snd) opcode = LIO_WRITE; - SOCKBUF_LOCK(&so->so_snd); - so->so_snd.sb_flags &= ~SB_AIO; - SOCKBUF_UNLOCK(&so->so_snd); - } else { + else opcode = LIO_READ; - SOCKBUF_LOCK(&so->so_rcv); - so->so_rcv.sb_flags &= ~SB_AIO; - SOCKBUF_UNLOCK(&so->so_rcv); - } - mtx_lock(&aio_sock_mtx); + SOCKBUF_LOCK(sb); + sb->sb_flags &= ~SB_AIO; + mtx_lock(&aio_job_mtx); TAILQ_FOREACH_SAFE(cb, &so->so_aiojobq, list, cbn) { if (opcode == cb->uaiocb.aio_lio_opcode) { if (cb->jobstate != JOBST_JOBQSOCK) panic("invalid queue value"); - p = cb->userproc; - ki = p->p_aioinfo; + /* XXX + * We don't have actual sockets backend yet, + * so we simply move the requests to the generic + * file I/O backend. + */ TAILQ_REMOVE(&so->so_aiojobq, cb, list); - PROC_LOCK(p); - TAILQ_REMOVE(&ki->kaio_sockqueue, cb, plist); - /* - * XXX check AIO_RUNDOWN, and don't put on - * jobqueue if it was set. - */ - TAILQ_INSERT_TAIL(&ki->kaio_jobqueue, cb, plist); - cb->jobstate = JOBST_JOBQGLOBAL; - mtx_lock(&aio_job_mtx); TAILQ_INSERT_TAIL(&aio_jobs, cb, list); - mtx_unlock(&aio_job_mtx); - PROC_UNLOCK(p); wakecount++; } } - mtx_unlock(&aio_sock_mtx); + mtx_unlock(&aio_job_mtx); + SOCKBUF_UNLOCK(sb); while (wakecount--) { mtx_lock(&aio_job_mtx); @@ -1427,14 +1429,15 @@ SOCKBUF_LOCK(sb); if (((opcode == LIO_READ) && (!soreadable(so))) || ((opcode == LIO_WRITE) && (!sowriteable(so)))) { - mtx_lock(&aio_sock_mtx); + sb->sb_flags |= SB_AIO; + + mtx_lock(&aio_job_mtx); TAILQ_INSERT_TAIL(&so->so_aiojobq, aiocbe, list); - mtx_unlock(&aio_sock_mtx); + mtx_unlock(&aio_job_mtx); - sb->sb_flags |= SB_AIO; PROC_LOCK(p); - TAILQ_INSERT_TAIL(&ki->kaio_sockqueue, aiocbe, plist); TAILQ_INSERT_TAIL(&ki->kaio_all, aiocbe, allist); + TAILQ_INSERT_TAIL(&ki->kaio_jobqueue, aiocbe, plist); aiocbe->jobstate = JOBST_JOBQSOCK; ki->kaio_count++; if (lj) @@ -1652,6 +1655,7 @@ struct file *fp; struct socket *so; int error; + int remove; int cancelled = 0; int notcancelled = 0; struct vnode *vp; @@ -1672,32 +1676,6 @@ td->td_retval[0] = AIO_NOTCANCELED; return (0); } - } else if (fp->f_type == DTYPE_SOCKET) { - so = fp->f_data; - mtx_lock(&aio_sock_mtx); - TAILQ_FOREACH_SAFE(cbe, &so->so_aiojobq, list, cbn) { - if (cbe->userproc == p && - (uap->aiocbp == NULL || - uap->aiocbp == cbe->uuaiocb)) { - TAILQ_REMOVE(&so->so_aiojobq, cbe, list); - PROC_LOCK(p); - TAILQ_REMOVE(&ki->kaio_sockqueue, cbe, plist); - cbe->jobstate = JOBST_JOBRUNNING; - cbe->uaiocb._aiocb_private.status = -1; - cbe->uaiocb._aiocb_private.error = ECANCELED; - aio_bio_done_notify(p, cbe, DONE_QUEUE); - PROC_UNLOCK(p); - cancelled++; - if (uap->aiocbp != NULL) - break; - } - } - mtx_unlock(&aio_sock_mtx); - if (cancelled && uap->aiocbp != NULL) { - fdrop(fp, td); - td->td_retval[0] = AIO_CANCELED; - return (0); - } } PROC_LOCK(p); @@ -1705,33 +1683,55 @@ if ((uap->fd == cbe->uaiocb.aio_fildes) && ((uap->aiocbp == NULL) || (uap->aiocbp == cbe->uuaiocb))) { + remove = 0; + mtx_lock(&aio_job_mtx); if (cbe->jobstate == JOBST_JOBQGLOBAL) { TAILQ_REMOVE(&aio_jobs, cbe, list); - mtx_unlock(&aio_job_mtx); + remove = 1; + } else if (cbe->jobstate == JOBST_JOBQSOCK) { + MPASS(fp->f_type == DTYPE_SOCKET); + so = fp->f_data; + TAILQ_REMOVE(&so->so_aiojobq, cbe, list); + remove = 1; + } + mtx_unlock(&aio_job_mtx); + + if (remove) { TAILQ_REMOVE(&ki->kaio_jobqueue, cbe, plist); cbe->uaiocb._aiocb_private.status = -1; cbe->uaiocb._aiocb_private.error = ECANCELED; aio_bio_done_notify(p, cbe, DONE_QUEUE); cancelled++; } else { - mtx_unlock(&aio_job_mtx); notcancelled++; } + if (uap->aiocbp != NULL) + break; } } PROC_UNLOCK(p); done: fdrop(fp, td); + + if (uap->aiocbp != NULL) { + if (cancelled) { + td->td_retval[0] = AIO_CANCELED; + return (0); + } + } + if (notcancelled) { td->td_retval[0] = AIO_NOTCANCELED; return (0); } + if (cancelled) { td->td_retval[0] = AIO_CANCELED; return (0); } + td->td_retval[0] = AIO_ALLDONE; return (0); ==== //depot/projects/hammer/sys/net80211/ieee80211.c#22 (text+ko) ==== @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/net80211/ieee80211.c,v 1.26 2005/12/30 00:40:36 sam Exp $"); +__FBSDID("$FreeBSD: src/sys/net80211/ieee80211.c,v 1.27 2006/01/23 20:57:30 sam Exp $"); /* * IEEE 802.11 generic handler @@ -190,7 +190,7 @@ if (ic->ic_bintval == 0) ic->ic_bintval = IEEE80211_BINTVAL_DEFAULT; - ic->ic_bmisstimeout = 7*ic->ic_bintval; /* default 7 beacons */ + ic->ic_bmissthreshold = 7; /* default 7 beacons */ ic->ic_dtim_period = IEEE80211_DTIM_DEFAULT; IEEE80211_BEACON_LOCK_INIT(ic, "beacon"); ==== //depot/projects/hammer/sys/net80211/ieee80211_input.c#29 (text+ko) ==== @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_input.c,v 1.86 2006/01/23 19:31:00 sam Exp $"); +__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_input.c,v 1.87 2006/01/23 21:02:48 sam Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -1901,6 +1901,9 @@ /* record tsf of last beacon */ memcpy(ni->ni_tstamp.data, scan.tstamp, sizeof(ni->ni_tstamp)); + /* count beacon frame for s/w bmiss handling */ + ic->ic_swbmiss_count++; + ic->ic_bmiss_count = 0; if (ni->ni_erp != scan.erp) { IEEE80211_DPRINTF(ic, IEEE80211_MSG_ASSOC, "[%s] erp change: was 0x%x, now 0x%x\n", @@ -1944,7 +1947,6 @@ if (ic->ic_flags & IEEE80211_F_SCAN) ieee80211_add_scan(ic, &scan, wh, subtype, rssi, rstamp); - ic->ic_bmiss_count = 0; return; } /* ==== //depot/projects/hammer/sys/net80211/ieee80211_proto.c#22 (text+ko) ==== @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_proto.c,v 1.27 2006/01/02 17:16:27 sam Exp $"); +__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_proto.c,v 1.28 2006/01/23 21:02:49 sam Exp $"); /* * IEEE 802.11 protocol support. @@ -98,6 +98,7 @@ ic->ic_fragthreshold = IEEE80211_FRAG_DEFAULT; ic->ic_fixed_rate = IEEE80211_FIXED_RATE_NONE; ic->ic_bmiss_max = IEEE80211_BMISS_MAX; + callout_init(&ic->ic_swbmiss, CALLOUT_MPSAFE); ic->ic_mcast_rate = IEEE80211_MCAST_RATE_DEFAULT; ic->ic_protmode = IEEE80211_PROT_CTSONLY; ic->ic_roaming = IEEE80211_ROAMING_AUTO; @@ -855,7 +856,27 @@ ieee80211_new_state(ic, IEEE80211_S_SCAN, 0); } +/* + * Software beacon miss handling. Check if any beacons + * were received in the last period. If not post a + * beacon miss; otherwise reset the counter. + */ static void +ieee80211_swbmiss(void *arg) +{ + struct ieee80211com *ic = arg; + + if (ic->ic_swbmiss_count == 0) { + ieee80211_beacon_miss(ic); + if (ic->ic_bmiss_count == 0) /* don't re-arm timer */ + return; + } else + ic->ic_swbmiss_count = 0; + callout_reset(&ic->ic_swbmiss, ic->ic_swbmiss_period, + ieee80211_swbmiss, ic); +} + +static void sta_disassoc(void *arg, struct ieee80211_node *ni) { struct ieee80211com *ic = arg; @@ -888,6 +909,8 @@ ieee80211_state_name[ostate], ieee80211_state_name[nstate]); ic->ic_state = nstate; /* state transition */ ni = ic->ic_bss; /* NB: no reference held */ + if (ic->ic_flags_ext & IEEE80211_FEXT_SWBMISS) + callout_stop(&ic->ic_swbmiss); switch (nstate) { case IEEE80211_S_INIT: switch (ostate) { @@ -1093,6 +1116,20 @@ if_start(ifp); /* XXX not authorized yet */ break; } + if (ostate != IEEE80211_S_RUN && + ic->ic_opmode == IEEE80211_M_STA && + (ic->ic_flags_ext & IEEE80211_FEXT_SWBMISS)) { + /* + * Start s/w beacon miss timer for devices w/o + * hardware support. We fudge a bit here since + * we're doing this in software. + */ + ic->ic_swbmiss_period = IEEE80211_TU_TO_TICKS( + 2 * ic->ic_bmissthreshold * ni->ni_intval); + ic->ic_swbmiss_count = 0; + callout_reset(&ic->ic_swbmiss, ic->ic_swbmiss_period, + ieee80211_swbmiss, ic); + } /* * Start/stop the authenticator when operating as an * AP. We delay until here to allow configuration to ==== //depot/projects/hammer/sys/net80211/ieee80211_var.h#23 (text+ko) ==== @@ -29,7 +29,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/sys/net80211/ieee80211_var.h,v 1.36 2006/01/02 16:57:20 sam Exp $ + * $FreeBSD: src/sys/net80211/ieee80211_var.h,v 1.38 2006/01/23 21:02:49 sam Exp $ */ #ifndef _NET80211_IEEE80211_VAR_H_ #define _NET80211_IEEE80211_VAR_H_ @@ -71,6 +71,7 @@ #define IEEE80211_BINTVAL_DEFAULT 100 /* default beacon interval (TU's) */ #define IEEE80211_BMISS_MAX 2 /* maximum consecutive bmiss allowed */ +#define IEEE80211_SWBMISS_THRESHOLD 50 /* s/w bmiss threshold (TU's) */ #define IEEE80211_PS_SLEEP 0x1 /* STA is in power saving mode */ #define IEEE80211_PS_MAX_QUEUE 50 /* maximum saved packets */ @@ -83,6 +84,7 @@ #define IEEE80211_MS_TO_TU(x) (((x) * 1024) / 1000) #define IEEE80211_TU_TO_MS(x) (((x) * 1000) / 1024) +#define IEEE80211_TU_TO_TICKS(x)(((x) * hz) / 1024) struct ieee80211_aclator; struct sysctl_ctx_list; @@ -144,8 +146,12 @@ int ic_mcast_rate; /* rate for mcast frames */ u_int16_t ic_rtsthreshold; u_int16_t ic_fragthreshold; + u_int8_t ic_bmissthreshold; u_int8_t ic_bmiss_count; /* current beacon miss count */ int ic_bmiss_max; /* max bmiss before scan */ + u_int16_t ic_swbmiss_count;/* beacons in last period */ + u_int16_t ic_swbmiss_period;/* s/w bmiss period */ + struct callout ic_swbmiss; /* s/w beacon miss timer */ struct ieee80211_node *(*ic_node_alloc)(struct ieee80211_node_table*); void (*ic_node_free)(struct ieee80211_node *); void (*ic_node_cleanup)(struct ieee80211_node *); @@ -157,7 +163,6 @@ u_int16_t ic_txmax; /* max tx retry count */ u_int16_t ic_txlifetime; /* tx lifetime */ u_int16_t ic_txpowlimit; /* global tx power limit */ - u_int16_t ic_bmisstimeout;/* beacon miss threshold (ms) */ u_int16_t ic_nonerpsta; /* # non-ERP stations */ u_int16_t ic_longslotsta; /* # long slot time stations */ int ic_mgt_timer; /* mgmt timeout */ @@ -247,6 +252,7 @@ /* 0x00000006 reserved */ #define IEEE80211_FEXT_BGSCAN 0x00000008 /* STATUS: enable full bgscan completion */ #define IEEE80211_FEXT_ERPUPDATE 0x00000200 /* STATUS: update ERP element */ +#define IEEE80211_FEXT_SWBMISS 0x00000400 /* CONF: do bmiss in s/w */ /* ic_caps */ #define IEEE80211_C_WEP 0x00000001 /* CAPABILITY: WEP available */ ==== //depot/projects/hammer/sys/netinet/in.c#22 (text+ko) ==== @@ -28,7 +28,7 @@ * SUCH DAMAGE. * * @(#)in.c 8.4 (Berkeley) 1/9/95 - * $FreeBSD: src/sys/netinet/in.c,v 1.92 2005/10/28 20:29:42 glebius Exp $ + * $FreeBSD: src/sys/netinet/in.c,v 1.93 2006/01/24 16:19:31 andre Exp $ */ #include "opt_carp.h" @@ -479,7 +479,8 @@ s = splnet(); TAILQ_REMOVE(&ifp->if_addrhead, &ia->ia_ifa, ifa_link); TAILQ_REMOVE(&in_ifaddrhead, ia, ia_link); - LIST_REMOVE(ia, ia_hash); + if (ia->ia_addr.sin_family == AF_INET) + LIST_REMOVE(ia, ia_hash); IFAFREE(&ia->ia_ifa); splx(s); >>> TRUNCATED FOR MAIL (1000 lines) <<<
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200601241938.k0OJc8k9047518>
