Date: Thu, 28 Feb 2013 12:09:37 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r247462 - in projects/calloutng: . cddl/contrib/opensolaris/cmd/zdb contrib/openbsm/bin/auditdistd include lib/libc/stdio sbin/tunefs share/man/man4 sys/amd64/amd64 sys/arm/econa sys/ar... Message-ID: <201302281209.r1SC9bNH080728@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Thu Feb 28 12:09:36 2013 New Revision: 247462 URL: http://svnweb.freebsd.org/changeset/base/247462 Log: MFC @247459 and fix corresponding breakages. Added: projects/calloutng/lib/libc/stdio/open_memstream.3 - copied unchanged from r247459, head/lib/libc/stdio/open_memstream.3 projects/calloutng/lib/libc/stdio/open_memstream.c - copied unchanged from r247459, head/lib/libc/stdio/open_memstream.c projects/calloutng/lib/libc/stdio/open_wmemstream.c - copied unchanged from r247459, head/lib/libc/stdio/open_wmemstream.c projects/calloutng/tools/regression/lib/libc/stdio/test-open_memstream.c - copied unchanged from r247459, head/tools/regression/lib/libc/stdio/test-open_memstream.c projects/calloutng/tools/regression/lib/libc/stdio/test-open_memstream.t - copied unchanged from r247459, head/tools/regression/lib/libc/stdio/test-open_memstream.t projects/calloutng/tools/regression/lib/libc/stdio/test-open_wmemstream.c - copied unchanged from r247459, head/tools/regression/lib/libc/stdio/test-open_wmemstream.c projects/calloutng/tools/regression/lib/libc/stdio/test-open_wmemstream.t - copied unchanged from r247459, head/tools/regression/lib/libc/stdio/test-open_wmemstream.t Modified: projects/calloutng/UPDATING projects/calloutng/cddl/contrib/opensolaris/cmd/zdb/zdb.c projects/calloutng/contrib/openbsm/bin/auditdistd/sender.c projects/calloutng/include/stdio.h projects/calloutng/include/wchar.h projects/calloutng/lib/libc/stdio/Makefile.inc projects/calloutng/lib/libc/stdio/Symbol.map projects/calloutng/sbin/tunefs/tunefs.c projects/calloutng/share/man/man4/arcmsr.4 projects/calloutng/sys/amd64/amd64/pmap.c projects/calloutng/sys/arm/econa/econa_machdep.c projects/calloutng/sys/arm/s3c2xx0/s3c24x0_machdep.c projects/calloutng/sys/arm/xscale/i80321/ep80219_machdep.c projects/calloutng/sys/arm/xscale/i80321/iq31244_machdep.c projects/calloutng/sys/arm/xscale/i8134x/crb_machdep.c projects/calloutng/sys/arm/xscale/ixp425/avila_machdep.c projects/calloutng/sys/arm/xscale/pxa/pxa_machdep.c projects/calloutng/sys/boot/common/load_elf.c projects/calloutng/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c projects/calloutng/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/space_map.c projects/calloutng/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/metaslab_impl.h projects/calloutng/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/space_map.h projects/calloutng/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c projects/calloutng/sys/dev/arcmsr/arcmsr.c projects/calloutng/sys/dev/arcmsr/arcmsr.h projects/calloutng/sys/dev/mfi/mfi.c projects/calloutng/sys/dev/pci/pci.c projects/calloutng/sys/dev/watchdog/watchdog.c projects/calloutng/sys/i386/i386/pmap.c projects/calloutng/sys/i386/xen/pmap.c projects/calloutng/sys/kern/kern_clock.c projects/calloutng/sys/kern/kern_clocksource.c projects/calloutng/sys/kern/kern_event.c projects/calloutng/sys/kern/kern_tc.c projects/calloutng/sys/kern/kern_time.c projects/calloutng/sys/kern/kern_timeout.c projects/calloutng/sys/kern/subr_param.c projects/calloutng/sys/kern/sys_generic.c projects/calloutng/sys/netinet/sctputil.c projects/calloutng/sys/netinet/tcp_timer.c projects/calloutng/sys/powerpc/aim/mmu_oea.c projects/calloutng/sys/powerpc/aim/mmu_oea64.c projects/calloutng/sys/powerpc/booke/pmap.c projects/calloutng/sys/sparc64/sparc64/pmap.c projects/calloutng/sys/sys/proc.h projects/calloutng/sys/sys/systm.h projects/calloutng/sys/sys/time.h projects/calloutng/sys/sys/watchdog.h projects/calloutng/sys/vm/vm_object.h projects/calloutng/tools/regression/lib/libc/stdio/Makefile projects/calloutng/tools/test/iconv/tablegen/cmp.sh projects/calloutng/usr.bin/dc/dc.c projects/calloutng/usr.sbin/watchdogd/watchdogd.8 projects/calloutng/usr.sbin/watchdogd/watchdogd.c Directory Properties: projects/calloutng/ (props changed) projects/calloutng/cddl/contrib/opensolaris/ (props changed) projects/calloutng/contrib/openbsm/ (props changed) projects/calloutng/lib/libc/ (props changed) projects/calloutng/sbin/ (props changed) projects/calloutng/share/man/man4/ (props changed) projects/calloutng/sys/ (props changed) projects/calloutng/sys/boot/ (props changed) projects/calloutng/sys/cddl/contrib/opensolaris/ (props changed) Modified: projects/calloutng/UPDATING ============================================================================== --- projects/calloutng/UPDATING Thu Feb 28 12:03:17 2013 (r247461) +++ projects/calloutng/UPDATING Thu Feb 28 12:09:36 2013 (r247462) @@ -26,6 +26,13 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 10 disable the most expensive debugging functionality run "ln -s 'abort:false,junk:false' /etc/malloc.conf".) +20130208: + A new compression method (lz4) has been merged to -HEAD. Please + refer to zpool-features(7) for more information. + + Please refer to the "ZFS notes" section of this file for information + on upgrading boot ZFS pools. + 20130129: A BSD-licensed patch(1) variant has been added and is installed as bsdpatch, being the GNU version the default patch. Modified: projects/calloutng/cddl/contrib/opensolaris/cmd/zdb/zdb.c ============================================================================== --- projects/calloutng/cddl/contrib/opensolaris/cmd/zdb/zdb.c Thu Feb 28 12:03:17 2013 (r247461) +++ projects/calloutng/cddl/contrib/opensolaris/cmd/zdb/zdb.c Thu Feb 28 12:09:36 2013 (r247462) @@ -545,7 +545,7 @@ static void dump_metaslab_stats(metaslab_t *msp) { char maxbuf[32]; - space_map_t *sm = &msp->ms_map; + space_map_t *sm = msp->ms_map; avl_tree_t *t = sm->sm_pp_root; int free_pct = sm->sm_space * 100 / sm->sm_size; @@ -561,7 +561,7 @@ dump_metaslab(metaslab_t *msp) { vdev_t *vd = msp->ms_group->mg_vd; spa_t *spa = vd->vdev_spa; - space_map_t *sm = &msp->ms_map; + space_map_t *sm = msp->ms_map; space_map_obj_t *smo = &msp->ms_smo; char freebuf[32]; @@ -2160,11 +2160,11 @@ zdb_leak_init(spa_t *spa, zdb_cb_t *zcb) for (int m = 0; m < vd->vdev_ms_count; m++) { metaslab_t *msp = vd->vdev_ms[m]; mutex_enter(&msp->ms_lock); - space_map_unload(&msp->ms_map); - VERIFY(space_map_load(&msp->ms_map, + space_map_unload(msp->ms_map); + VERIFY(space_map_load(msp->ms_map, &zdb_space_map_ops, SM_ALLOC, &msp->ms_smo, spa->spa_meta_objset) == 0); - msp->ms_map.sm_ppd = vd; + msp->ms_map->sm_ppd = vd; mutex_exit(&msp->ms_lock); } } @@ -2187,7 +2187,7 @@ zdb_leak_fini(spa_t *spa) for (int m = 0; m < vd->vdev_ms_count; m++) { metaslab_t *msp = vd->vdev_ms[m]; mutex_enter(&msp->ms_lock); - space_map_unload(&msp->ms_map); + space_map_unload(msp->ms_map); mutex_exit(&msp->ms_lock); } } Modified: projects/calloutng/contrib/openbsm/bin/auditdistd/sender.c ============================================================================== --- projects/calloutng/contrib/openbsm/bin/auditdistd/sender.c Thu Feb 28 12:03:17 2013 (r247461) +++ projects/calloutng/contrib/openbsm/bin/auditdistd/sender.c Thu Feb 28 12:09:36 2013 (r247462) @@ -394,6 +394,7 @@ read_thread_wait(void) mtx_lock(&adist_remote_mtx); if (adhost->adh_reset) { +reset: adhost->adh_reset = false; if (trail_filefd(adist_trail) != -1) trail_close(adist_trail); @@ -408,6 +409,14 @@ read_thread_wait(void) while (trail_filefd(adist_trail) == -1) { newfile = true; wait_for_dir(); + /* + * We may have been disconnected and reconnected in the + * meantime, check if reset is set. + */ + mtx_lock(&adist_remote_mtx); + if (adhost->adh_reset) + goto reset; + mtx_unlock(&adist_remote_mtx); if (trail_filefd(adist_trail) == -1) trail_next(adist_trail); } Modified: projects/calloutng/include/stdio.h ============================================================================== --- projects/calloutng/include/stdio.h Thu Feb 28 12:03:17 2013 (r247461) +++ projects/calloutng/include/stdio.h Thu Feb 28 12:09:36 2013 (r247462) @@ -346,6 +346,7 @@ char *tempnam(const char *, const char * FILE *fmemopen(void * __restrict, size_t, const char * __restrict); ssize_t getdelim(char ** __restrict, size_t * __restrict, int, FILE * __restrict); +FILE *open_memstream(char **, size_t *); int renameat(int, const char *, int, const char *); int vdprintf(int, const char * __restrict, __va_list); Modified: projects/calloutng/include/wchar.h ============================================================================== --- projects/calloutng/include/wchar.h Thu Feb 28 12:03:17 2013 (r247461) +++ projects/calloutng/include/wchar.h Thu Feb 28 12:09:36 2013 (r247462) @@ -207,6 +207,7 @@ int wcwidth(wchar_t); #if __POSIX_VISIBLE >= 200809 || __BSD_VISIBLE size_t mbsnrtowcs(wchar_t * __restrict, const char ** __restrict, size_t, size_t, mbstate_t * __restrict); +FILE *open_wmemstream(wchar_t **, size_t *); wchar_t *wcpcpy(wchar_t * __restrict, const wchar_t * __restrict); wchar_t *wcpncpy(wchar_t * __restrict, const wchar_t * __restrict, size_t); wchar_t *wcsdup(const wchar_t *) __malloc_like; Modified: projects/calloutng/lib/libc/stdio/Makefile.inc ============================================================================== --- projects/calloutng/lib/libc/stdio/Makefile.inc Thu Feb 28 12:03:17 2013 (r247461) +++ projects/calloutng/lib/libc/stdio/Makefile.inc Thu Feb 28 12:09:36 2013 (r247462) @@ -14,6 +14,7 @@ SRCS+= _flock_stub.c asprintf.c clrerr.c ftell.c funopen.c fvwrite.c fwalk.c fwide.c fwprintf.c fwscanf.c \ fwrite.c getc.c getchar.c getdelim.c getline.c \ gets.c getw.c getwc.c getwchar.c makebuf.c mktemp.c \ + open_memstream.c open_wmemstream.c \ perror.c printf.c printf-pos.c putc.c putchar.c \ puts.c putw.c putwc.c putwchar.c \ refill.c remove.c rewind.c rget.c scanf.c setbuf.c setbuffer.c \ @@ -36,7 +37,7 @@ MAN+= fclose.3 ferror.3 fflush.3 fgetln. flockfile.3 \ fopen.3 fputs.3 \ fputws.3 fread.3 fseek.3 funopen.3 fwide.3 getc.3 \ - getline.3 getwc.3 mktemp.3 \ + getline.3 getwc.3 mktemp.3 open_memstream.3 \ printf.3 printf_l.3 putc.3 putwc.3 remove.3 scanf.3 scanf_l.3 setbuf.3 \ stdio.3 tmpnam.3 \ ungetc.3 ungetwc.3 wprintf.3 wscanf.3 @@ -60,6 +61,7 @@ MLINKS+=getc.3 fgetc.3 getc.3 getc_unloc MLINKS+=getline.3 getdelim.3 MLINKS+=getwc.3 fgetwc.3 getwc.3 getwchar.3 MLINKS+=mktemp.3 mkdtemp.3 mktemp.3 mkstemp.3 mktemp.3 mkstemps.3 +MLINKS+=open_memstream.3 open_wmemstream.3 MLINKS+=printf.3 asprintf.3 printf.3 dprintf.3 printf.3 fprintf.3 \ printf.3 snprintf.3 printf.3 sprintf.3 \ printf.3 vasprintf.3 printf.3 vdprintf.3 \ Modified: projects/calloutng/lib/libc/stdio/Symbol.map ============================================================================== --- projects/calloutng/lib/libc/stdio/Symbol.map Thu Feb 28 12:03:17 2013 (r247461) +++ projects/calloutng/lib/libc/stdio/Symbol.map Thu Feb 28 12:09:36 2013 (r247462) @@ -156,6 +156,8 @@ FBSD_1.3 { putwc_l; putwchar_l; fmemopen; + open_memstream; + open_wmemstream; }; FBSDprivate_1.0 { Copied: projects/calloutng/lib/libc/stdio/open_memstream.3 (from r247459, head/lib/libc/stdio/open_memstream.3) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/calloutng/lib/libc/stdio/open_memstream.3 Thu Feb 28 12:09:36 2013 (r247462, copy of r247459, head/lib/libc/stdio/open_memstream.3) @@ -0,0 +1,155 @@ +.\" Copyright (c) 2013 Advanced Computing Technologies LLC +.\" Written by: John H. Baldwin <jhb@FreeBSD.org> +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (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$ +.\" +.Dd February 27, 2013 +.Dt OPEN_MEMSTREAM 3 +.Os +.Sh NAME +.Nm open_memstream , +.Nm open_wmemstream +.Nd dynamic memory buffer stream open functions +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdio.h +.Ft FILE * +.Fn open_memstream "char **bufp" "size_t **sizep" +.In wchar.h +.Ft FILE * +.Fn open_wmemstream "wchar_t **bufp" "size_t **sizep" +.Sh DESCRIPTION +The +.Fn open_memstream +and +.Fn open_wmemstream +functions create a write-only, seekable stream backed by a dynamically +allocated memory buffer. +The +.Fn open_memstream +function creates a byte-oriented stream, +while the +.Fn open_wmemstream +function creates a wide-oriented stream. +.Pp +Each stream maintains a current position and size. +Initially, +the position and size are set to zero. +Each write begins at the current position and advances it the number of +successfully written bytes for +.Fn open_memstream +or wide characters for +.Fn open_wmemstream . +If a write moves the current position beyond the length of the buffer, +the length of the buffer is extended and a null character is appended to the +buffer. +.Pp +A stream's buffer always contains a null character at the end of the buffer +that is not included in the current length. +.Pp +If a stream's current position is moved beyond the current length via a +seek operation and a write is performed, +the characters between the current length and the current position are filled +with null characters before the write is performed. +.Pp +After a successful call to +.Xr fclose 3 +or +.Xr fflush 3 , +the pointer referenced by +.Fa bufp +will contain the start of the memory buffer and the variable referenced by +.Fa sizep +will contain the smaller of the current position and the current buffer length. +.Pp +After a successful call to +.Xr fflush 3, +the pointer referenced by +.Fa bufp +and the variable referenced by +.Fa sizep +are only valid until the next write operation or a call to +.Xr fclose 3. +.Pp +Once a stream is closed, +the allocated buffer referenced by +.Fa bufp +should be released via a call to +.Xr free 3 +when it is no longer needed. +.Sh IMPLEMENTATION NOTES +Internally all I/O streams are effectively byte-oriented, +so using wide-oriented operations to write to a stream opened via +.Fn open_wmemstream +results in wide characters being expanded to a stream of multibyte characters +in stdio's internal buffers. +These multibyte characters are then converted back to wide characters when +written into the stream. +As a result, +the wide-oriented streams maintain an internal multibyte character conversion +state that is cleared on any seek opertion that changes the current position. +This should have no effect as long as wide-oriented output operations are used +on a wide-oriented stream. +.Sh RETURN VALUES +Upon successful completion, +.Fn open_memstream +and +.Fn open_wmemstream +return a +.Tn FILE +pointer. +Otherwise, +.Dv NULL +is returned and the global variable +.Va errno +is set to indicate the error. +.Sh ERRORS +.Bl -tag -width Er +.It Bq Er EINVAL +The +.Fa bufp +or +.Fa sizep +argument was +.Dv NULL . +.It Bq Er ENOMEM +Memory for the stream or buffer could not be allocated. +.El +.Sh SEE ALSO +.Xr fclose 3 , +.Xr fflush 3 , +.Xr fopen 3 , +.Xr free 3 , +.Xr fseek 3 , +.Xr sbuf 3 , +.Xr stdio 3 +.Sh STANDARDS +The +.Fn open_memstream +and +.Fn open_wmemstream +functions conform to +.St -p1003.1-2008 . Copied: projects/calloutng/lib/libc/stdio/open_memstream.c (from r247459, head/lib/libc/stdio/open_memstream.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/calloutng/lib/libc/stdio/open_memstream.c Thu Feb 28 12:09:36 2013 (r247462, copy of r247459, head/lib/libc/stdio/open_memstream.c) @@ -0,0 +1,209 @@ +/*- + * Copyright (c) 2013 Advanced Computing Technologies LLC + * Written by: John H. Baldwin <jhb@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include "namespace.h" +#include <assert.h> +#include <errno.h> +#include <limits.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <wchar.h> +#include "un-namespace.h" + +/* XXX: There is no FPOS_MAX. This assumes fpos_t is an off_t. */ +#define FPOS_MAX OFF_MAX + +struct memstream { + char **bufp; + size_t *sizep; + ssize_t len; + fpos_t offset; +}; + +static int +memstream_grow(struct memstream *ms, fpos_t newoff) +{ + char *buf; + ssize_t newsize; + + if (newoff < 0 || newoff >= SSIZE_MAX) + newsize = SSIZE_MAX - 1; + else + newsize = newoff; + if (newsize > ms->len) { + buf = realloc(*ms->bufp, newsize + 1); + if (buf != NULL) { +#ifdef DEBUG + fprintf(stderr, "MS: %p growing from %zd to %zd\n", + ms, ms->len, newsize); +#endif + memset(buf + ms->len + 1, 0, newsize - ms->len); + *ms->bufp = buf; + ms->len = newsize; + return (1); + } + return (0); + } + return (1); +} + +static void +memstream_update(struct memstream *ms) +{ + + assert(ms->len >= 0 && ms->offset >= 0); + *ms->sizep = ms->len < ms->offset ? ms->len : ms->offset; +} + +static int +memstream_write(void *cookie, const char *buf, int len) +{ + struct memstream *ms; + ssize_t tocopy; + + ms = cookie; + if (!memstream_grow(ms, ms->offset + len)) + return (-1); + tocopy = ms->len - ms->offset; + if (len < tocopy) + tocopy = len; + memcpy(*ms->bufp + ms->offset, buf, tocopy); + ms->offset += tocopy; + memstream_update(ms); +#ifdef DEBUG + fprintf(stderr, "MS: write(%p, %d) = %zd\n", ms, len, tocopy); +#endif + return (tocopy); +} + +static fpos_t +memstream_seek(void *cookie, fpos_t pos, int whence) +{ + struct memstream *ms; +#ifdef DEBUG + fpos_t old; +#endif + + ms = cookie; +#ifdef DEBUG + old = ms->offset; +#endif + switch (whence) { + case SEEK_SET: + /* _fseeko() checks for negative offsets. */ + assert(pos >= 0); + ms->offset = pos; + break; + case SEEK_CUR: + /* This is only called by _ftello(). */ + assert(pos == 0); + break; + case SEEK_END: + if (pos < 0) { + if (pos + ms->len < 0) { +#ifdef DEBUG + fprintf(stderr, + "MS: bad SEEK_END: pos %jd, len %zd\n", + (intmax_t)pos, ms->len); +#endif + errno = EINVAL; + return (-1); + } + } else { + if (FPOS_MAX - ms->len < pos) { +#ifdef DEBUG + fprintf(stderr, + "MS: bad SEEK_END: pos %jd, len %zd\n", + (intmax_t)pos, ms->len); +#endif + errno = EOVERFLOW; + return (-1); + } + } + ms->offset = ms->len + pos; + break; + } + memstream_update(ms); +#ifdef DEBUG + fprintf(stderr, "MS: seek(%p, %jd, %d) %jd -> %jd\n", ms, (intmax_t)pos, + whence, (intmax_t)old, (intmax_t)ms->offset); +#endif + return (ms->offset); +} + +static int +memstream_close(void *cookie) +{ + + free(cookie); + return (0); +} + +FILE * +open_memstream(char **bufp, size_t *sizep) +{ + struct memstream *ms; + int save_errno; + FILE *fp; + + if (bufp == NULL || sizep == NULL) { + errno = EINVAL; + return (NULL); + } + *bufp = calloc(1, 1); + if (*bufp == NULL) + return (NULL); + ms = malloc(sizeof(*ms)); + if (ms == NULL) { + save_errno = errno; + free(*bufp); + *bufp = NULL; + errno = save_errno; + return (NULL); + } + ms->bufp = bufp; + ms->sizep = sizep; + ms->len = 0; + ms->offset = 0; + memstream_update(ms); + fp = funopen(ms, NULL, memstream_write, memstream_seek, + memstream_close); + if (fp == NULL) { + save_errno = errno; + free(ms); + free(*bufp); + *bufp = NULL; + errno = save_errno; + return (NULL); + } + fwide(fp, -1); + return (fp); +} Copied: projects/calloutng/lib/libc/stdio/open_wmemstream.c (from r247459, head/lib/libc/stdio/open_wmemstream.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/calloutng/lib/libc/stdio/open_wmemstream.c Thu Feb 28 12:09:36 2013 (r247462, copy of r247459, head/lib/libc/stdio/open_wmemstream.c) @@ -0,0 +1,271 @@ +/*- + * Copyright (c) 2013 Advanced Computing Technologies LLC + * Written by: John H. Baldwin <jhb@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include "namespace.h" +#include <assert.h> +#include <errno.h> +#include <limits.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <wchar.h> +#include "un-namespace.h" + +/* XXX: There is no FPOS_MAX. This assumes fpos_t is an off_t. */ +#define FPOS_MAX OFF_MAX + +struct wmemstream { + wchar_t **bufp; + size_t *sizep; + ssize_t len; + fpos_t offset; + mbstate_t mbstate; +}; + +static int +wmemstream_grow(struct wmemstream *ms, fpos_t newoff) +{ + wchar_t *buf; + ssize_t newsize; + + if (newoff < 0 || newoff >= SSIZE_MAX / sizeof(wchar_t)) + newsize = SSIZE_MAX / sizeof(wchar_t) - 1; + else + newsize = newoff; + if (newsize > ms->len) { + buf = realloc(*ms->bufp, (newsize + 1) * sizeof(wchar_t)); + if (buf != NULL) { +#ifdef DEBUG + fprintf(stderr, "WMS: %p growing from %zd to %zd\n", + ms, ms->len, newsize); +#endif + wmemset(buf + ms->len + 1, 0, newsize - ms->len); + *ms->bufp = buf; + ms->len = newsize; + return (1); + } + return (0); + } + return (1); +} + +static void +wmemstream_update(struct wmemstream *ms) +{ + + assert(ms->len >= 0 && ms->offset >= 0); + *ms->sizep = ms->len < ms->offset ? ms->len : ms->offset; +} + +/* + * Based on a starting multibyte state and an input buffer, determine + * how many wchar_t's would be output. This doesn't use mbsnrtowcs() + * so that it can handle embedded null characters. + */ +static size_t +wbuflen(const mbstate_t *state, const char *buf, int len) +{ + mbstate_t lenstate; + size_t charlen, count; + + count = 0; + lenstate = *state; + while (len > 0) { + charlen = mbrlen(buf, len, &lenstate); + if (charlen == (size_t)-1) + return (-1); + if (charlen == (size_t)-2) + break; + if (charlen == 0) + /* XXX: Not sure how else to handle this. */ + charlen = 1; + len -= charlen; + buf += charlen; + count++; + } + return (count); +} + +static int +wmemstream_write(void *cookie, const char *buf, int len) +{ + struct wmemstream *ms; + ssize_t consumed, wlen; + size_t charlen; + + ms = cookie; + wlen = wbuflen(&ms->mbstate, buf, len); + if (wlen < 0) { + errno = EILSEQ; + return (-1); + } + if (!wmemstream_grow(ms, ms->offset + wlen)) + return (-1); + + /* + * This copies characters one at a time rather than using + * mbsnrtowcs() so it can properly handle embedded null + * characters. + */ + consumed = 0; + while (len > 0 && ms->offset < ms->len) { + charlen = mbrtowc(*ms->bufp + ms->offset, buf, len, + &ms->mbstate); + if (charlen == (size_t)-1) { + if (consumed == 0) { + errno = EILSEQ; + return (-1); + } + /* Treat it as a successful short write. */ + break; + } + if (charlen == 0) + /* XXX: Not sure how else to handle this. */ + charlen = 1; + if (charlen == (size_t)-2) { + consumed += len; + len = 0; + } else { + consumed += charlen; + buf += charlen; + len -= charlen; + ms->offset++; + } + } + wmemstream_update(ms); +#ifdef DEBUG + fprintf(stderr, "WMS: write(%p, %d) = %zd\n", ms, len, consumed); +#endif + return (consumed); +} + +static fpos_t +wmemstream_seek(void *cookie, fpos_t pos, int whence) +{ + struct wmemstream *ms; + fpos_t old; + + ms = cookie; + old = ms->offset; + switch (whence) { + case SEEK_SET: + /* _fseeko() checks for negative offsets. */ + assert(pos >= 0); + ms->offset = pos; + break; + case SEEK_CUR: + /* This is only called by _ftello(). */ + assert(pos == 0); + break; + case SEEK_END: + if (pos < 0) { + if (pos + ms->len < 0) { +#ifdef DEBUG + fprintf(stderr, + "WMS: bad SEEK_END: pos %jd, len %zd\n", + (intmax_t)pos, ms->len); +#endif + errno = EINVAL; + return (-1); + } + } else { + if (FPOS_MAX - ms->len < pos) { +#ifdef DEBUG + fprintf(stderr, + "WMS: bad SEEK_END: pos %jd, len %zd\n", + (intmax_t)pos, ms->len); +#endif + errno = EOVERFLOW; + return (-1); + } + } + ms->offset = ms->len + pos; + break; + } + /* Reset the multibyte state if a seek changes the position. */ + if (ms->offset != old) + memset(&ms->mbstate, 0, sizeof(ms->mbstate)); + wmemstream_update(ms); +#ifdef DEBUG + fprintf(stderr, "WMS: seek(%p, %jd, %d) %jd -> %jd\n", ms, + (intmax_t)pos, whence, (intmax_t)old, (intmax_t)ms->offset); +#endif + return (ms->offset); +} + +static int +wmemstream_close(void *cookie) +{ + + free(cookie); + return (0); +} + +FILE * +open_wmemstream(wchar_t **bufp, size_t *sizep) +{ + struct wmemstream *ms; + int save_errno; + FILE *fp; + + if (bufp == NULL || sizep == NULL) { + errno = EINVAL; + return (NULL); + } + *bufp = calloc(1, sizeof(wchar_t)); + if (*bufp == NULL) + return (NULL); + ms = malloc(sizeof(*ms)); + if (ms == NULL) { + save_errno = errno; + free(*bufp); + *bufp = NULL; + errno = save_errno; + return (NULL); + } + ms->bufp = bufp; + ms->sizep = sizep; + ms->len = 0; + ms->offset = 0; + memset(&ms->mbstate, 0, sizeof(mbstate_t)); + wmemstream_update(ms); + fp = funopen(ms, NULL, wmemstream_write, wmemstream_seek, + wmemstream_close); + if (fp == NULL) { + save_errno = errno; + free(ms); + free(*bufp); + *bufp = NULL; + errno = save_errno; + return (NULL); + } + fwide(fp, 1); + return (fp); +} Modified: projects/calloutng/sbin/tunefs/tunefs.c ============================================================================== --- projects/calloutng/sbin/tunefs/tunefs.c Thu Feb 28 12:03:17 2013 (r247461) +++ projects/calloutng/sbin/tunefs/tunefs.c Thu Feb 28 12:09:36 2013 (r247462) @@ -671,7 +671,7 @@ journal_findfile(void) return (ino); } } else { - if ((off_t)dp1->di_size >= lblktosize(&sblock, NDADDR)) { + if ((off_t)dp2->di_size >= lblktosize(&sblock, NDADDR)) { warnx("ROOTINO extends beyond direct blocks."); return (-1); } Modified: projects/calloutng/share/man/man4/arcmsr.4 ============================================================================== --- projects/calloutng/share/man/man4/arcmsr.4 Thu Feb 28 12:03:17 2013 (r247461) +++ projects/calloutng/share/man/man4/arcmsr.4 Thu Feb 28 12:09:36 2013 (r247462) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 18, 2012 +.Dd February 27, 2013 .Dt ARCMSR 4 .Os .Sh NAME @@ -108,6 +108,8 @@ ARC-1222 .It ARC-1223 .It +ARC-1224 +.It ARC-1230 .It ARC-1231 Modified: projects/calloutng/sys/amd64/amd64/pmap.c ============================================================================== --- projects/calloutng/sys/amd64/amd64/pmap.c Thu Feb 28 12:03:17 2013 (r247461) +++ projects/calloutng/sys/amd64/amd64/pmap.c Thu Feb 28 12:09:36 2013 (r247462) @@ -3492,9 +3492,8 @@ pmap_enter(pmap_t pmap, vm_offset_t va, KASSERT((m->oflags & VPO_UNMANAGED) != 0 || va < kmi.clean_sva || va >= kmi.clean_eva, ("pmap_enter: managed mapping within the clean submap")); - KASSERT((m->oflags & (VPO_UNMANAGED | VPO_BUSY)) != 0 || - VM_OBJECT_LOCKED(m->object), - ("pmap_enter: page %p is not busy", m)); + if ((m->oflags & (VPO_UNMANAGED | VPO_BUSY)) == 0) + VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED); pa = VM_PAGE_TO_PHYS(m); newpte = (pt_entry_t)(pa | PG_A | PG_V); if ((access & VM_PROT_WRITE) != 0) Modified: projects/calloutng/sys/arm/econa/econa_machdep.c ============================================================================== --- projects/calloutng/sys/arm/econa/econa_machdep.c Thu Feb 28 12:03:17 2013 (r247461) +++ projects/calloutng/sys/arm/econa/econa_machdep.c Thu Feb 28 12:09:36 2013 (r247462) @@ -67,9 +67,7 @@ __FBSDID("$FreeBSD$"); #include <vm/pmap.h> #include <vm/vm_object.h> #include <vm/vm_page.h> -#include <vm/vm_pager.h> #include <vm/vm_map.h> -#include <vm/vnode_pager.h> #include <machine/pmap.h> #include <machine/vmparam.h> #include <machine/pcb.h> Modified: projects/calloutng/sys/arm/s3c2xx0/s3c24x0_machdep.c ============================================================================== --- projects/calloutng/sys/arm/s3c2xx0/s3c24x0_machdep.c Thu Feb 28 12:03:17 2013 (r247461) +++ projects/calloutng/sys/arm/s3c2xx0/s3c24x0_machdep.c Thu Feb 28 12:09:36 2013 (r247462) @@ -77,9 +77,7 @@ __FBSDID("$FreeBSD$"); #include <vm/pmap.h> #include <vm/vm_object.h> #include <vm/vm_page.h> -#include <vm/vm_pager.h> #include <vm/vm_map.h> -#include <vm/vnode_pager.h> #include <machine/pmap.h> #include <machine/vmparam.h> #include <machine/pcb.h> Modified: projects/calloutng/sys/arm/xscale/i80321/ep80219_machdep.c ============================================================================== --- projects/calloutng/sys/arm/xscale/i80321/ep80219_machdep.c Thu Feb 28 12:03:17 2013 (r247461) +++ projects/calloutng/sys/arm/xscale/i80321/ep80219_machdep.c Thu Feb 28 12:09:36 2013 (r247462) @@ -77,9 +77,7 @@ __FBSDID("$FreeBSD$"); #include <vm/pmap.h> #include <vm/vm_object.h> #include <vm/vm_page.h> -#include <vm/vm_pager.h> #include <vm/vm_map.h> -#include <vm/vnode_pager.h> #include <machine/pmap.h> #include <machine/vmparam.h> #include <machine/pcb.h> Modified: projects/calloutng/sys/arm/xscale/i80321/iq31244_machdep.c ============================================================================== --- projects/calloutng/sys/arm/xscale/i80321/iq31244_machdep.c Thu Feb 28 12:03:17 2013 (r247461) +++ projects/calloutng/sys/arm/xscale/i80321/iq31244_machdep.c Thu Feb 28 12:09:36 2013 (r247462) @@ -77,9 +77,7 @@ __FBSDID("$FreeBSD$"); #include <vm/pmap.h> #include <vm/vm_object.h> #include <vm/vm_page.h> -#include <vm/vm_pager.h> #include <vm/vm_map.h> -#include <vm/vnode_pager.h> #include <machine/pmap.h> #include <machine/vmparam.h> #include <machine/pcb.h> Modified: projects/calloutng/sys/arm/xscale/i8134x/crb_machdep.c ============================================================================== --- projects/calloutng/sys/arm/xscale/i8134x/crb_machdep.c Thu Feb 28 12:03:17 2013 (r247461) +++ projects/calloutng/sys/arm/xscale/i8134x/crb_machdep.c Thu Feb 28 12:09:36 2013 (r247462) @@ -77,9 +77,7 @@ __FBSDID("$FreeBSD$"); #include <vm/pmap.h> #include <vm/vm_object.h> #include <vm/vm_page.h> -#include <vm/vm_pager.h> #include <vm/vm_map.h> -#include <vm/vnode_pager.h> #include <machine/pmap.h> #include <machine/vmparam.h> #include <machine/pcb.h> Modified: projects/calloutng/sys/arm/xscale/ixp425/avila_machdep.c ============================================================================== --- projects/calloutng/sys/arm/xscale/ixp425/avila_machdep.c Thu Feb 28 12:03:17 2013 (r247461) +++ projects/calloutng/sys/arm/xscale/ixp425/avila_machdep.c Thu Feb 28 12:09:36 2013 (r247462) @@ -77,9 +77,7 @@ __FBSDID("$FreeBSD$"); #include <vm/pmap.h> #include <vm/vm_object.h> #include <vm/vm_page.h> -#include <vm/vm_pager.h> #include <vm/vm_map.h> -#include <vm/vnode_pager.h> #include <machine/pmap.h> #include <machine/vmparam.h> #include <machine/pcb.h> Modified: projects/calloutng/sys/arm/xscale/pxa/pxa_machdep.c ============================================================================== --- projects/calloutng/sys/arm/xscale/pxa/pxa_machdep.c Thu Feb 28 12:03:17 2013 (r247461) +++ projects/calloutng/sys/arm/xscale/pxa/pxa_machdep.c Thu Feb 28 12:09:36 2013 (r247462) @@ -79,9 +79,7 @@ __FBSDID("$FreeBSD$"); #include <vm/pmap.h> #include <vm/vm_object.h> #include <vm/vm_page.h> -#include <vm/vm_pager.h> #include <vm/vm_map.h> -#include <vm/vnode_pager.h> #include <machine/pmap.h> #include <machine/vmparam.h> #include <machine/pcb.h> Modified: projects/calloutng/sys/boot/common/load_elf.c ============================================================================== --- projects/calloutng/sys/boot/common/load_elf.c Thu Feb 28 12:03:17 2013 (r247461) +++ projects/calloutng/sys/boot/common/load_elf.c Thu Feb 28 12:09:36 2013 (r247462) @@ -304,7 +304,7 @@ __elfN(loadimage)(struct preloaded_file * only adjust the entry point if it's a virtual address to begin with. */ off = -0xc0000000u; - if ((ehdr->e_entry & 0xc0000000u) == 0xc000000u) + if ((ehdr->e_entry & 0xc0000000u) == 0xc0000000u) ehdr->e_entry += off; #ifdef ELF_VERBOSE printf("ehdr->e_entry 0x%08x, va<->pa off %llx\n", ehdr->e_entry, off); Modified: projects/calloutng/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c ============================================================================== --- projects/calloutng/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c Thu Feb 28 12:03:17 2013 (r247461) +++ projects/calloutng/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c Thu Feb 28 12:09:36 2013 (r247462) @@ -48,6 +48,14 @@ uint64_t metaslab_aliquot = 512ULL << 10 uint64_t metaslab_gang_bang = SPA_MAXBLOCKSIZE + 1; /* force gang blocks */ /* + * The in-core space map representation is more compact than its on-disk form. + * The zfs_condense_pct determines how much more compact the in-core + * space_map representation must be before we compact it on-disk. + * Values should be greater than or equal to 100. + */ +int zfs_condense_pct = 200; + +/* * This value defines the number of allowed allocation failures per vdev. * If a device reaches this threshold in a given txg then we consider skipping * allocations on that device. @@ -215,9 +223,9 @@ metaslab_compare(const void *x1, const v /* * If the weights are identical, use the offset to force uniqueness. */ - if (m1->ms_map.sm_start < m2->ms_map.sm_start) + if (m1->ms_map->sm_start < m2->ms_map->sm_start) return (-1); - if (m1->ms_map.sm_start > m2->ms_map.sm_start) + if (m1->ms_map->sm_start > m2->ms_map->sm_start) return (1); ASSERT3P(m1, ==, m2); @@ -732,14 +740,15 @@ metaslab_init(metaslab_group_t *mg, spac * addition of new space; and for debugging, it ensures that we'd * data fault on any attempt to use this metaslab before it's ready. */ - space_map_create(&msp->ms_map, start, size, + msp->ms_map = kmem_zalloc(sizeof (space_map_t), KM_SLEEP); + space_map_create(msp->ms_map, start, size, vd->vdev_ashift, &msp->ms_lock); metaslab_group_add(mg, msp); if (metaslab_debug && smo->smo_object != 0) { mutex_enter(&msp->ms_lock); - VERIFY(space_map_load(&msp->ms_map, mg->mg_class->mc_ops, + VERIFY(space_map_load(msp->ms_map, mg->mg_class->mc_ops, SM_FREE, smo, spa_meta_objset(vd->vdev_spa)) == 0); mutex_exit(&msp->ms_lock); } @@ -767,22 +776,27 @@ metaslab_fini(metaslab_t *msp) metaslab_group_t *mg = msp->ms_group; vdev_space_update(mg->mg_vd, - -msp->ms_smo.smo_alloc, 0, -msp->ms_map.sm_size); + -msp->ms_smo.smo_alloc, 0, -msp->ms_map->sm_size); metaslab_group_remove(mg, msp); mutex_enter(&msp->ms_lock); - space_map_unload(&msp->ms_map); - space_map_destroy(&msp->ms_map); + space_map_unload(msp->ms_map); + space_map_destroy(msp->ms_map); + kmem_free(msp->ms_map, sizeof (*msp->ms_map)); for (int t = 0; t < TXG_SIZE; t++) { - space_map_destroy(&msp->ms_allocmap[t]); - space_map_destroy(&msp->ms_freemap[t]); + space_map_destroy(msp->ms_allocmap[t]); + space_map_destroy(msp->ms_freemap[t]); + kmem_free(msp->ms_allocmap[t], sizeof (*msp->ms_allocmap[t])); + kmem_free(msp->ms_freemap[t], sizeof (*msp->ms_freemap[t])); } *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201302281209.r1SC9bNH080728>