From owner-p4-projects@FreeBSD.ORG Sat Jul 10 16:23:30 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id B329A16A4D0; Sat, 10 Jul 2004 16:23:29 +0000 (GMT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 74E3116A4CE for ; Sat, 10 Jul 2004 16:23:29 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6E06243D39 for ; Sat, 10 Jul 2004 16:23:29 +0000 (GMT) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.11/8.12.11) with ESMTP id i6AGNTZx031086 for ; Sat, 10 Jul 2004 16:23:29 GMT (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.11/8.12.11/Submit) id i6AGNTA2031083 for perforce@freebsd.org; Sat, 10 Jul 2004 16:23:29 GMT (envelope-from marcel@freebsd.org) Date: Sat, 10 Jul 2004 16:23:29 GMT Message-Id: <200407101623.i6AGNTA2031083@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to marcel@freebsd.org using -f From: Marcel Moolenaar To: Perforce Change Reviews Subject: PERFORCE change 56968 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Jul 2004 16:23:30 -0000 http://perforce.freebsd.org/chv.cgi?CH=56968 Change 56968 by marcel@marcel_nfs on 2004/07/10 16:23:06 IFC @56967 Affected files ... .. //depot/projects/gdb/share/man/man9/physio.9#2 integrate .. //depot/projects/gdb/sys/compat/linux/linux_socket.c#3 integrate .. //depot/projects/gdb/sys/compat/svr4/svr4_stream.c#4 integrate .. //depot/projects/gdb/sys/dev/led/led.c#8 integrate .. //depot/projects/gdb/sys/kern/kern_ktrace.c#5 integrate .. //depot/projects/gdb/sys/kern/kern_subr.c#6 integrate .. //depot/projects/gdb/sys/kern/subr_prf.c#6 integrate .. //depot/projects/gdb/sys/kern/sys_generic.c#6 integrate .. //depot/projects/gdb/sys/kern/uipc_socket.c#19 integrate .. //depot/projects/gdb/sys/kern/uipc_syscalls.c#19 integrate .. //depot/projects/gdb/sys/kern/vfs_mount.c#11 integrate .. //depot/projects/gdb/sys/sys/uio.h#5 integrate .. //depot/projects/gdb/usr.bin/hexdump/hexdump.1#3 integrate .. //depot/projects/gdb/usr.bin/tr/cset.c#2 integrate .. //depot/projects/gdb/usr.bin/truss/syscall.h#3 integrate .. //depot/projects/gdb/usr.bin/truss/syscalls.c#4 integrate Differences ... ==== //depot/projects/gdb/share/man/man9/physio.9#2 (text+ko) ==== @@ -34,9 +34,9 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.\" $FreeBSD: src/share/man/man9/physio.9,v 1.14 2003/09/12 19:20:05 hmp Exp $ +.\" $FreeBSD: src/share/man/man9/physio.9,v 1.15 2004/07/10 01:10:17 imp Exp $ .\" -.Dd June 15, 1996 +.Dd July 8, 2004 .Dt PHYSIO 9 .Os .Sh NAME @@ -60,15 +60,22 @@ The maximum amount of data to transfer with each call is determined by .Fa dev->si_iosize_max . +The +.Fn physio +call converts the I/O request into a +.Fn strategy +request and passes the new request to the driver's +.Fn strategy +routine for processing. .Pp Since .Fa uio normally describes user space addresses, .Fn physio -needs to lock the process into memory. -This is done by setting the -.Dv P_PHYSIO -flag on the process. +needs to lock the those pages into memory. +This is done by calling +.Fn vmapbuf +for the appropriate pages. .Fn physio always awaits the completion of the entire requested transfer before returning, unless an error condition is detected earlier. @@ -86,6 +93,13 @@ set to anything other than .Dv UIO_USERSPACE are undefined. +.It Fa ioflag +The ioflag argument from the +.Fn read +or +.Fn write +function calling +.Fn physio . .El .Sh RETURN VALUES If successful ==== //depot/projects/gdb/sys/compat/linux/linux_socket.c#3 (text+ko) ==== @@ -27,7 +27,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/compat/linux/linux_socket.c,v 1.46 2004/07/08 10:18:07 phk Exp $"); +__FBSDID("$FreeBSD: src/sys/compat/linux/linux_socket.c,v 1.47 2004/07/10 15:42:16 phk Exp $"); /* XXX we use functions that might not exist. */ #include "opt_compat.h" @@ -993,35 +993,22 @@ { struct linux_sendmsg_args linux_args; struct msghdr msg; - struct iovec aiov[UIO_SMALLIOV], *iov; + struct iovec *iov; int error; - if ((error = copyin(args, &linux_args, sizeof(linux_args)))) + error = copyin(args, &linux_args, sizeof(linux_args)); + if (error) return (error); - error = copyin(linux_args.msg, &msg, sizeof(msg)); if (error) return (error); - if ((u_int)msg.msg_iovlen >= UIO_SMALLIOV) { - if ((u_int)msg.msg_iovlen >= UIO_MAXIOV) - return (EMSGSIZE); - MALLOC(iov, struct iovec *, - sizeof(struct iovec) * (u_int)msg.msg_iovlen, M_IOV, - M_WAITOK); - } else { - iov = aiov; - } - if (msg.msg_iovlen && - (error = copyin(msg.msg_iov, iov, - (unsigned)(msg.msg_iovlen * sizeof (struct iovec))))) - goto done; + error = copyiniov(msg.msg_iov, msg.msg_iovlen, &iov, EMSGSIZE); + if (error) + return (error); msg.msg_iov = iov; msg.msg_flags = 0; - error = linux_sendit(td, linux_args.s, &msg, linux_args.flags); -done: - if (iov != aiov) - FREE(iov, M_IOV); + free(iov, M_IOV); return (error); } ==== //depot/projects/gdb/sys/compat/svr4/svr4_stream.c#4 (text+ko) ==== @@ -36,7 +36,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/compat/svr4/svr4_stream.c,v 1.48 2004/06/17 17:16:41 phk Exp $"); +__FBSDID("$FreeBSD: src/sys/compat/svr4/svr4_stream.c,v 1.49 2004/07/10 15:42:16 phk Exp $"); #define COMPAT_43 1 @@ -163,8 +163,7 @@ int len, error; struct socket *so; #ifdef KTRACE - struct iovec *ktriov = NULL; - struct uio ktruio; + struct uio *ktruio = NULL; #endif if ((error = fgetsock(td, s, &so, NULL)) != 0) @@ -212,13 +211,8 @@ control = 0; } #ifdef KTRACE - if (KTRPOINT(td, KTR_GENIO)) { - int iovlen = auio.uio_iovcnt * sizeof (struct iovec); - - MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK); - bcopy((caddr_t)auio.uio_iov, (caddr_t)ktriov, iovlen); - ktruio = auio; - } + if (KTRPOINT(td, KTR_GENIO)) + ktruio = cloneuio(&auio); #endif len = auio.uio_resid; error = so->so_proto->pr_usrreqs->pru_sosend(so, to, &auio, 0, control, @@ -236,13 +230,9 @@ if (error == 0) td->td_retval[0] = len - auio.uio_resid; #ifdef KTRACE - if (ktriov != NULL) { - if (error == 0) { - ktruio.uio_iov = ktriov; - ktruio.uio_resid = td->td_retval[0]; - ktrgenio(s, UIO_WRITE, &ktruio, error); - } - FREE(ktriov, M_TEMP); + if (ktruio != NULL) { + ktruio->uio_resid = td->td_retval[0]; + ktrgenio(s, UIO_WRITE, ktruio, error); } #endif bad: @@ -269,8 +259,7 @@ struct socket *so; struct sockaddr *fromsa = 0; #ifdef KTRACE - struct iovec *ktriov = NULL; - struct uio ktruio; + struct uio *ktruio = NULL; #endif if ((error = fgetsock(td, s, &so, NULL)) != 0) @@ -299,13 +288,8 @@ } } #ifdef KTRACE - if (KTRPOINT(td, KTR_GENIO)) { - int iovlen = auio.uio_iovcnt * sizeof (struct iovec); - - MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK); - bcopy((caddr_t)auio.uio_iov, (caddr_t)ktriov, iovlen); - ktruio = auio; - } + if (KTRPOINT(td, KTR_GENIO)) + ktruio = cloneuio(&auio); #endif len = auio.uio_resid; error = so->so_proto->pr_usrreqs->pru_soreceive(so, &fromsa, &auio, @@ -317,13 +301,9 @@ error = 0; } #ifdef KTRACE - if (ktriov != NULL) { - if (error == 0) { - ktruio.uio_iov = ktriov; - ktruio.uio_resid = len - auio.uio_resid; - ktrgenio(s, UIO_READ, &ktruio, error); - } - FREE(ktriov, M_TEMP); + if (ktruio != NULL) { + ktruio->uio_resid = len - auio.uio_resid; + ktrgenio(s, UIO_READ, ktruio, error); } #endif if (error) ==== //depot/projects/gdb/sys/dev/led/led.c#8 (text+ko) ==== @@ -9,7 +9,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/led/led.c,v 1.12 2004/06/17 17:16:44 phk Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/led/led.c,v 1.13 2004/07/10 15:38:27 phk Exp $"); #include #include @@ -86,8 +86,6 @@ if (uio->uio_resid > 512) return (EINVAL); s2 = s = malloc(uio->uio_resid + 1, M_DEVBUF, M_WAITOK); - if (s == NULL) - return (ENOMEM); s[uio->uio_resid] = '\0'; error = uiomove(s, uio->uio_resid, uio); if (error) { ==== //depot/projects/gdb/sys/kern/kern_ktrace.c#5 (text+ko) ==== @@ -30,7 +30,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/kern/kern_ktrace.c,v 1.94 2004/04/05 21:03:34 imp Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/kern_ktrace.c,v 1.95 2004/07/10 15:42:16 phk Exp $"); #include "opt_ktrace.h" #include "opt_mac.h" @@ -413,13 +413,17 @@ int datalen; char *buf; - if (error) + if (error) { + free(uio, M_IOV); return; + } uio->uio_offset = 0; uio->uio_rw = UIO_WRITE; datalen = imin(uio->uio_resid, ktr_geniosize); buf = malloc(datalen, M_KTRACE, M_WAITOK); - if (uiomove(buf, datalen, uio)) { + error = uiomove(buf, datalen, uio); + free(uio, M_IOV); + if (error) { free(buf, M_KTRACE); return; } ==== //depot/projects/gdb/sys/kern/kern_subr.c#6 (text+ko) ==== @@ -35,7 +35,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/kern/kern_subr.c,v 1.87 2004/07/02 19:09:49 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/kern_subr.c,v 1.88 2004/07/10 15:42:16 phk Exp $"); #include "opt_zero.h" @@ -474,40 +474,69 @@ } int -uiofromiov(struct iovec *iovp, u_int iovcnt, struct uio *uio) +copyiniov(struct iovec *iovp, u_int iovcnt, struct iovec **iov, int error) +{ + u_int iovlen; + + *iov = NULL; + if (iovcnt > UIO_MAXIOV) + return (error); + iovlen = iovcnt * sizeof (struct iovec); + *iov = malloc(iovlen, M_IOV, M_WAITOK); + error = copyin(iovp, *iov, iovlen); + if (error) { + free(*iov, M_IOV); + *iov = NULL; + } + return (error); +} + +int +copyinuio(struct iovec *iovp, u_int iovcnt, struct uio **uiop) { struct iovec *iov; + struct uio *uio; u_int iovlen; int error, i; - /* note: can't use iovlen until iovcnt is validated */ + *uiop = NULL; + if (iovcnt > UIO_MAXIOV) + return (EINVAL); iovlen = iovcnt * sizeof (struct iovec); - if (iovcnt > UIO_MAXIOV) { - error = EINVAL; - goto done; + uio = malloc(iovlen + sizeof *uio, M_IOV, M_WAITOK); + iov = (struct iovec *)(uio + 1); + error = copyin(iovp, iov, iovlen); + if (error) { + free(uio, M_IOV); + return (error); } - MALLOC(iov, struct iovec *, iovlen, M_IOV, M_WAITOK); uio->uio_iov = iov; uio->uio_iovcnt = iovcnt; uio->uio_segflg = UIO_USERSPACE; uio->uio_offset = -1; - if ((error = copyin(iovp, iov, iovlen))) - goto done; uio->uio_resid = 0; for (i = 0; i < iovcnt; i++) { if (iov->iov_len > INT_MAX - uio->uio_resid) { - error = EINVAL; - goto done; + free(uio, M_IOV); + return (EINVAL); } uio->uio_resid += iov->iov_len; iov++; } + *uiop = uio; + return (0); +} -done: - if (error && uio->uio_iov) { - FREE(uio->uio_iov, M_IOV); - uio->uio_iov = NULL; - } - return (error); +struct uio * +cloneuio(struct uio *uiop) +{ + struct uio *uio; + int iovlen; + iovlen = uiop->uio_iovcnt * sizeof (struct iovec); + uio = malloc(iovlen + sizeof *uio, M_IOV, M_WAITOK); + *uio = *uiop; + uio->uio_iov = (struct iovec *)(uio + 1); + bcopy(uiop->uio_iov, uio->uio_iov, iovlen); + return (uio); } ==== //depot/projects/gdb/sys/kern/subr_prf.c#6 (text+ko) ==== @@ -35,7 +35,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/kern/subr_prf.c,v 1.111 2004/06/18 20:12:42 green Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/subr_prf.c,v 1.112 2004/07/10 15:42:16 phk Exp $"); #include "opt_ddb.h" @@ -244,9 +244,7 @@ void log_console(struct uio *uio) { - int c, i, error, iovlen, nl; - struct uio muio; - struct iovec *miov = NULL; + int c, i, error, nl; char *consbuffer; int pri; @@ -254,13 +252,8 @@ return; pri = LOG_INFO | LOG_CONSOLE; - muio = *uio; - iovlen = uio->uio_iovcnt * sizeof (struct iovec); - MALLOC(miov, struct iovec *, iovlen, M_TEMP, M_WAITOK); - MALLOC(consbuffer, char *, CONSCHUNK, M_TEMP, M_WAITOK); - bcopy(muio.uio_iov, miov, iovlen); - muio.uio_iov = miov; - uio = &muio; + uio = cloneuio(uio); + consbuffer = malloc(CONSCHUNK, M_TEMP, M_WAITOK); nl = 0; while (uio->uio_resid > 0) { @@ -279,8 +272,8 @@ if (!nl) msglogchar('\n', pri); msgbuftrigger = 1; - FREE(miov, M_TEMP); - FREE(consbuffer, M_TEMP); + free(uio, M_IOV); + free(consbuffer, M_TEMP); return; } ==== //depot/projects/gdb/sys/kern/sys_generic.c#6 (text+ko) ==== @@ -35,7 +35,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/kern/sys_generic.c,v 1.131 2004/04/05 21:03:35 imp Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/sys_generic.c,v 1.132 2004/07/10 15:42:16 phk Exp $"); #include "opt_ktrace.h" @@ -164,9 +164,7 @@ struct iovec aiov; long cnt, error = 0; #ifdef KTRACE - struct iovec ktriov; - struct uio ktruio; - int didktr = 0; + struct uio *ktruio = NULL; #endif aiov.iov_base = buf; @@ -181,14 +179,8 @@ auio.uio_segflg = UIO_USERSPACE; auio.uio_td = td; #ifdef KTRACE - /* - * if tracing, save a copy of iovec - */ - if (KTRPOINT(td, KTR_GENIO)) { - ktriov = aiov; - ktruio = auio; - didktr = 1; - } + if (KTRPOINT(td, KTR_GENIO)) + ktruio = cloneuio(&auio); #endif cnt = nbyte; @@ -199,10 +191,9 @@ } cnt -= auio.uio_resid; #ifdef KTRACE - if (didktr && error == 0) { - ktruio.uio_iov = &ktriov; - ktruio.uio_resid = cnt; - ktrgenio(fd, UIO_READ, &ktruio, error); + if (ktruio != NULL) { + ktruio->uio_resid = cnt; + ktrgenio(fd, UIO_READ, ktruio, error); } #endif td->td_retval[0] = cnt; @@ -223,86 +214,46 @@ * MPSAFE */ int -readv(td, uap) - struct thread *td; - struct readv_args *uap; +readv(struct thread *td, struct readv_args *uap) { struct file *fp; - struct uio auio; - struct iovec *iov; - struct iovec *needfree; - struct iovec aiov[UIO_SMALLIOV]; - long i, cnt; + struct uio *auio = NULL; + long cnt; int error; - u_int iovlen; #ifdef KTRACE - struct iovec *ktriov = NULL; - struct uio ktruio; + struct uio *ktruio = NULL; #endif - if ((error = fget_read(td, uap->fd, &fp)) != 0) + error = fget_read(td, uap->fd, &fp); + if (error) + return (error); + error = copyinuio(uap->iovp, uap->iovcnt, &auio); + if (error) { + fdrop(fp, td); return (error); - needfree = NULL; - /* note: can't use iovlen until iovcnt is validated */ - iovlen = uap->iovcnt * sizeof (struct iovec); - if (uap->iovcnt > UIO_SMALLIOV) { - if (uap->iovcnt > UIO_MAXIOV) { - error = EINVAL; - goto done; - } - MALLOC(iov, struct iovec *, iovlen, M_IOV, M_WAITOK); - needfree = iov; - } else - iov = aiov; - auio.uio_iov = iov; - auio.uio_iovcnt = uap->iovcnt; - auio.uio_rw = UIO_READ; - auio.uio_segflg = UIO_USERSPACE; - auio.uio_td = td; - auio.uio_offset = -1; - if ((error = copyin(uap->iovp, iov, iovlen))) - goto done; - auio.uio_resid = 0; - for (i = 0; i < uap->iovcnt; i++) { - if (iov->iov_len > INT_MAX - auio.uio_resid) { - error = EINVAL; - goto done; - } - auio.uio_resid += iov->iov_len; - iov++; } + auio->uio_rw = UIO_READ; + auio->uio_td = td; #ifdef KTRACE - /* - * if tracing, save a copy of iovec - */ - if (KTRPOINT(td, KTR_GENIO)) { - MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK); - bcopy(auio.uio_iov, ktriov, iovlen); - ktruio = auio; - } + if (KTRPOINT(td, KTR_GENIO)) + ktruio = cloneuio(auio); #endif - cnt = auio.uio_resid; - if ((error = fo_read(fp, &auio, td->td_ucred, 0, td))) { - if (auio.uio_resid != cnt && (error == ERESTART || + cnt = auio->uio_resid; + if ((error = fo_read(fp, auio, td->td_ucred, 0, td))) { + if (auio->uio_resid != cnt && (error == ERESTART || error == EINTR || error == EWOULDBLOCK)) error = 0; } - cnt -= auio.uio_resid; + cnt -= auio->uio_resid; #ifdef KTRACE - if (ktriov != NULL) { - if (error == 0) { - ktruio.uio_iov = ktriov; - ktruio.uio_resid = cnt; - ktrgenio(uap->fd, UIO_READ, &ktruio, error); - } - FREE(ktriov, M_TEMP); + if (ktruio != NULL) { + ktruio->uio_resid = cnt; + ktrgenio(uap->fd, UIO_READ, ktruio, error); } #endif td->td_retval[0] = cnt; -done: + free(auio, M_IOV); fdrop(fp, td); - if (needfree) - FREE(needfree, M_IOV); return (error); } @@ -389,9 +340,7 @@ struct iovec aiov; long cnt, error = 0; #ifdef KTRACE - struct iovec ktriov; - struct uio ktruio; - int didktr = 0; + struct uio *ktruio = NULL; #endif aiov.iov_base = (void *)(uintptr_t)buf; @@ -406,14 +355,8 @@ auio.uio_segflg = UIO_USERSPACE; auio.uio_td = td; #ifdef KTRACE - /* - * if tracing, save a copy of iovec and uio - */ - if (KTRPOINT(td, KTR_GENIO)) { - ktriov = aiov; - ktruio = auio; - didktr = 1; - } + if (KTRPOINT(td, KTR_GENIO)) + ktruio = cloneuio(&auio); #endif cnt = nbyte; if (fp->f_type == DTYPE_VNODE) @@ -431,10 +374,9 @@ } cnt -= auio.uio_resid; #ifdef KTRACE - if (didktr && error == 0) { - ktruio.uio_iov = &ktriov; - ktruio.uio_resid = cnt; - ktrgenio(fd, UIO_WRITE, &ktruio, error); + if (ktruio != NULL) { + ktruio->uio_resid = cnt; + ktrgenio(fd, UIO_WRITE, ktruio, error); } #endif td->td_retval[0] = cnt; @@ -455,68 +397,35 @@ * MPSAFE */ int -writev(td, uap) - struct thread *td; - register struct writev_args *uap; +writev(struct thread *td, struct writev_args *uap) { struct file *fp; - struct uio auio; - register struct iovec *iov; - struct iovec *needfree; - struct iovec aiov[UIO_SMALLIOV]; - long i, cnt, error = 0; - u_int iovlen; + struct uio *auio = NULL; + long cnt; + int error; #ifdef KTRACE - struct iovec *ktriov = NULL; - struct uio ktruio; + struct uio *ktruio = NULL; #endif - if ((error = fget_write(td, uap->fd, &fp)) != 0) + error = fget_write(td, uap->fd, &fp); + if (error) return (EBADF); - needfree = NULL; - /* note: can't use iovlen until iovcnt is validated */ - iovlen = uap->iovcnt * sizeof (struct iovec); - if (uap->iovcnt > UIO_SMALLIOV) { - if (uap->iovcnt > UIO_MAXIOV) { - error = EINVAL; - goto done; - } - MALLOC(iov, struct iovec *, iovlen, M_IOV, M_WAITOK); - needfree = iov; - } else - iov = aiov; - auio.uio_iov = iov; - auio.uio_iovcnt = uap->iovcnt; - auio.uio_rw = UIO_WRITE; - auio.uio_segflg = UIO_USERSPACE; - auio.uio_td = td; - auio.uio_offset = -1; - if ((error = copyin(uap->iovp, iov, iovlen))) - goto done; - auio.uio_resid = 0; - for (i = 0; i < uap->iovcnt; i++) { - if (iov->iov_len > INT_MAX - auio.uio_resid) { - error = EINVAL; - goto done; - } - auio.uio_resid += iov->iov_len; - iov++; + error = copyinuio(uap->iovp, uap->iovcnt, &auio); + if (error) { + fdrop(fp, td); + return (error); } + auio->uio_rw = UIO_WRITE; + auio->uio_td = td; #ifdef KTRACE - /* - * if tracing, save a copy of iovec and uio - */ - if (KTRPOINT(td, KTR_GENIO)) { - MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK); - bcopy(auio.uio_iov, ktriov, iovlen); - ktruio = auio; - } + if (KTRPOINT(td, KTR_GENIO)) + ktruio = cloneuio(auio); #endif - cnt = auio.uio_resid; + cnt = auio->uio_resid; if (fp->f_type == DTYPE_VNODE) bwillwrite(); - if ((error = fo_write(fp, &auio, td->td_ucred, 0, td))) { - if (auio.uio_resid != cnt && (error == ERESTART || + if ((error = fo_write(fp, auio, td->td_ucred, 0, td))) { + if (auio->uio_resid != cnt && (error == ERESTART || error == EINTR || error == EWOULDBLOCK)) error = 0; if (error == EPIPE) { @@ -525,22 +434,16 @@ PROC_UNLOCK(td->td_proc); } } - cnt -= auio.uio_resid; + cnt -= auio->uio_resid; #ifdef KTRACE - if (ktriov != NULL) { - if (error == 0) { - ktruio.uio_iov = ktriov; - ktruio.uio_resid = cnt; - ktrgenio(uap->fd, UIO_WRITE, &ktruio, error); - } - FREE(ktriov, M_TEMP); + if (ktruio != NULL) { + ktruio->uio_resid = cnt; + ktrgenio(uap->fd, UIO_WRITE, ktruio, error); } #endif td->td_retval[0] = cnt; -done: fdrop(fp, td); - if (needfree) - FREE(needfree, M_IOV); + free(auio, M_IOV); return (error); } ==== //depot/projects/gdb/sys/kern/uipc_socket.c#19 (text+ko) ==== @@ -30,7 +30,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/kern/uipc_socket.c,v 1.192 2004/07/05 19:29:33 rwatson Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/uipc_socket.c,v 1.194 2004/07/10 04:38:06 rwatson Exp $"); #include "opt_inet.h" #include "opt_mac.h" @@ -949,6 +949,7 @@ so->so_error = 0; goto release; } + SOCKBUF_LOCK_ASSERT(&so->so_rcv); if (so->so_rcv.sb_state & SBS_CANTRCVMORE) { if (m) goto dontblock; @@ -1115,6 +1116,7 @@ goto release; } else uio->uio_resid -= len; + SOCKBUF_LOCK_ASSERT(&so->so_rcv); if (len == m->m_len - moff) { if (m->m_flags & M_EOR) flags |= MSG_EOR; @@ -1158,11 +1160,11 @@ so->so_rcv.sb_cc -= len; } } + SOCKBUF_LOCK_ASSERT(&so->so_rcv); if (so->so_oobmark) { if ((flags & MSG_PEEK) == 0) { so->so_oobmark -= len; if (so->so_oobmark == 0) { - SOCKBUF_LOCK_ASSERT(&so->so_rcv); so->so_rcv.sb_state |= SBS_RCVATMARK; break; } @@ -1206,12 +1208,11 @@ } } + SOCKBUF_LOCK_ASSERT(&so->so_rcv); if (m != NULL && pr->pr_flags & PR_ATOMIC) { flags |= MSG_TRUNC; - if ((flags & MSG_PEEK) == 0) { - SOCKBUF_LOCK_ASSERT(&so->so_rcv); + if ((flags & MSG_PEEK) == 0) (void) sbdroprecord_locked(&so->so_rcv); - } } if ((flags & MSG_PEEK) == 0) { if (m == NULL) { @@ -1248,6 +1249,7 @@ SOCKBUF_LOCK_ASSERT(&so->so_rcv); sbunlock(&so->so_rcv); out: + SOCKBUF_LOCK_ASSERT(&so->so_rcv); SOCKBUF_UNLOCK(&so->so_rcv); return (error); } ==== //depot/projects/gdb/sys/kern/uipc_syscalls.c#19 (text+ko) ==== @@ -33,7 +33,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/kern/uipc_syscalls.c,v 1.197 2004/07/09 01:46:03 rwatson Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/uipc_syscalls.c,v 1.198 2004/07/10 15:42:16 phk Exp $"); #include "opt_compat.h" #include "opt_ktrace.h" @@ -701,9 +701,7 @@ int i; int len, error; #ifdef KTRACE - struct iovec *ktriov = NULL; - struct uio ktruio; - int iovlen; + struct uio *ktruio = NULL; #endif NET_LOCK_GIANT(); @@ -733,12 +731,8 @@ } } #ifdef KTRACE - if (KTRPOINT(td, KTR_GENIO)) { - iovlen = auio.uio_iovcnt * sizeof (struct iovec); - MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK); - bcopy(auio.uio_iov, ktriov, iovlen); - ktruio = auio; - } + if (KTRPOINT(td, KTR_GENIO)) + ktruio = cloneuio(&auio); #endif len = auio.uio_resid; error = so->so_proto->pr_usrreqs->pru_sosend(so, mp->msg_name, &auio, @@ -757,13 +751,9 @@ if (error == 0) td->td_retval[0] = len - auio.uio_resid; #ifdef KTRACE - if (ktriov != NULL) { - if (error == 0) { - ktruio.uio_iov = ktriov; - ktruio.uio_resid = td->td_retval[0]; - ktrgenio(s, UIO_WRITE, &ktruio, error); - } - FREE(ktriov, M_TEMP); + if (ktruio != NULL) { + ktruio->uio_resid = td->td_retval[0]; + ktrgenio(s, UIO_WRITE, ktruio, error); } #endif bad: @@ -842,41 +832,26 @@ int osendmsg(td, uap) struct thread *td; - register struct osendmsg_args /* { + struct osendmsg_args /* { int s; caddr_t msg; int flags; } */ *uap; { struct msghdr msg; - struct iovec aiov[UIO_SMALLIOV], *iov; + struct iovec *iov; int error; error = copyin(uap->msg, &msg, sizeof (struct omsghdr)); if (error) - goto done2; - if ((u_int)msg.msg_iovlen >= UIO_SMALLIOV) { - if ((u_int)msg.msg_iovlen >= UIO_MAXIOV) { - error = EMSGSIZE; - goto done2; - } - MALLOC(iov, struct iovec *, - sizeof(struct iovec) * (u_int)msg.msg_iovlen, M_IOV, - M_WAITOK); - } else { - iov = aiov; - } - error = copyin(msg.msg_iov, iov, - (unsigned)(msg.msg_iovlen * sizeof (struct iovec))); + return (error); + error = copyiniov(msg.msg_iov, msg.msg_iovlen, &iov, EMSGSIZE); if (error) - goto done; + return (error); + msg.msg_iov = iov; msg.msg_flags = MSG_COMPAT; - msg.msg_iov = iov; error = sendit(td, uap->s, &msg, uap->flags); -done: - if (iov != aiov) - FREE(iov, M_IOV); -done2: + free(iov, M_IOV); return (error); } #endif @@ -887,56 +862,41 @@ int sendmsg(td, uap) struct thread *td; - register struct sendmsg_args /* { + struct sendmsg_args /* { int s; caddr_t msg; int flags; } */ *uap; { struct msghdr msg; - struct iovec aiov[UIO_SMALLIOV], *iov; + struct iovec *iov; int error; error = copyin(uap->msg, &msg, sizeof (msg)); if (error) - goto done2; - if ((u_int)msg.msg_iovlen >= UIO_SMALLIOV) { - if ((u_int)msg.msg_iovlen >= UIO_MAXIOV) { - error = EMSGSIZE; - goto done2; - } - MALLOC(iov, struct iovec *, - sizeof(struct iovec) * (u_int)msg.msg_iovlen, M_IOV, - M_WAITOK); - } else { - iov = aiov; - } - if (msg.msg_iovlen && - (error = copyin(msg.msg_iov, iov, - (unsigned)(msg.msg_iovlen * sizeof (struct iovec))))) - goto done; + return (error); + error = copyiniov(msg.msg_iov, msg.msg_iovlen, &iov, EMSGSIZE); + if (error) + return (error); msg.msg_iov = iov; #ifdef COMPAT_OLDSOCK msg.msg_flags = 0; #endif error = sendit(td, uap->s, &msg, uap->flags); -done: - if (iov != aiov) - FREE(iov, M_IOV); -done2: + free(iov, M_IOV); return (error); } static int recvit(td, s, mp, namelenp) - register struct thread *td; + struct thread *td; int s; - register struct msghdr *mp; + struct msghdr *mp; void *namelenp; { struct uio auio; - register struct iovec *iov; - register int i; + struct iovec *iov; + int i; socklen_t len; int error; struct mbuf *m, *control = 0; @@ -944,9 +904,7 @@ struct socket *so; struct sockaddr *fromsa = 0; #ifdef KTRACE - struct iovec *ktriov = NULL; - struct uio ktruio; - int iovlen; + struct uio *ktruio = NULL; #endif >>> TRUNCATED FOR MAIL (1000 lines) <<<