Date: Mon, 9 Apr 2007 13:45:18 GMT From: Paolo Pisati <piso@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 117738 for review Message-ID: <200704091345.l39DjIsH061094@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=117738 Change 117738 by piso@piso_newluxor on 2007/04/09 13:45:01 IFC@117737 Affected files ... .. //depot/projects/soc2005/libalias/contrib/opensolaris/cmd/zpool/zpool_main.c#2 integrate .. //depot/projects/soc2005/libalias/contrib/opensolaris/cmd/ztest/ztest.c#2 integrate .. //depot/projects/soc2005/libalias/contrib/opensolaris/lib/libzfs/common/libzfs.h#2 integrate .. //depot/projects/soc2005/libalias/contrib/opensolaris/lib/libzfs/common/libzfs_import.c#2 integrate .. //depot/projects/soc2005/libalias/contrib/opensolaris/lib/libzfs/common/libzfs_status.c#2 integrate .. //depot/projects/soc2005/libalias/contrib/opensolaris/lib/libzfs/common/libzfs_util.c#2 integrate .. //depot/projects/soc2005/libalias/contrib/opensolaris/lib/libzpool/common/kernel.c#2 integrate .. //depot/projects/soc2005/libalias/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h#2 integrate .. //depot/projects/soc2005/libalias/etc/devd.conf#3 integrate .. //depot/projects/soc2005/libalias/sys/boot/forth/loader.conf#9 integrate .. //depot/projects/soc2005/libalias/sys/cam/scsi/scsi_sg.c#2 integrate .. //depot/projects/soc2005/libalias/sys/compat/opensolaris/kern/opensolaris_kobj.c#2 integrate .. //depot/projects/soc2005/libalias/sys/compat/opensolaris/kern/opensolaris_misc.c#1 branch .. //depot/projects/soc2005/libalias/sys/compat/opensolaris/sys/kobj.h#2 integrate .. //depot/projects/soc2005/libalias/sys/compat/opensolaris/sys/lock.h#1 branch .. //depot/projects/soc2005/libalias/sys/compat/opensolaris/sys/misc.h#1 branch .. //depot/projects/soc2005/libalias/sys/compat/opensolaris/sys/mutex.h#2 integrate .. //depot/projects/soc2005/libalias/sys/compat/opensolaris/sys/rwlock.h#2 integrate .. //depot/projects/soc2005/libalias/sys/conf/files#25 integrate .. //depot/projects/soc2005/libalias/sys/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c#2 integrate .. //depot/projects/soc2005/libalias/sys/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c#2 integrate .. //depot/projects/soc2005/libalias/sys/contrib/opensolaris/uts/common/fs/zfs/dsl_dir.c#2 integrate .. //depot/projects/soc2005/libalias/sys/contrib/opensolaris/uts/common/fs/zfs/spa.c#2 integrate .. //depot/projects/soc2005/libalias/sys/contrib/opensolaris/uts/common/fs/zfs/spa_config.c#2 integrate .. //depot/projects/soc2005/libalias/sys/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dir.h#2 integrate .. //depot/projects/soc2005/libalias/sys/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_context.h#2 integrate .. //depot/projects/soc2005/libalias/sys/contrib/opensolaris/uts/common/fs/zfs/zfs_fm.c#2 integrate .. //depot/projects/soc2005/libalias/sys/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c#2 integrate .. //depot/projects/soc2005/libalias/sys/contrib/opensolaris/uts/common/sys/fs/zfs.h#2 integrate .. //depot/projects/soc2005/libalias/sys/dev/ata/ata-all.h#5 integrate .. //depot/projects/soc2005/libalias/sys/dev/ata/ata-chipset.c#14 integrate .. //depot/projects/soc2005/libalias/sys/dev/ata/ata-dma.c#4 integrate .. //depot/projects/soc2005/libalias/sys/dev/cxgb/cxgb_adapter.h#2 integrate .. //depot/projects/soc2005/libalias/sys/dev/cxgb/cxgb_lro.c#2 integrate .. //depot/projects/soc2005/libalias/sys/dev/cxgb/cxgb_osdep.h#2 integrate .. //depot/projects/soc2005/libalias/sys/dev/cxgb/cxgb_sge.c#2 integrate .. //depot/projects/soc2005/libalias/sys/dev/cxgb/sys/mvec.h#1 branch .. //depot/projects/soc2005/libalias/sys/dev/cxgb/sys/uipc_mvec.c#1 branch .. //depot/projects/soc2005/libalias/sys/geom/eli/g_eli.c#9 integrate .. //depot/projects/soc2005/libalias/sys/kern/vfs_mount.c#12 integrate .. //depot/projects/soc2005/libalias/sys/modules/cxgb/Makefile#2 integrate .. //depot/projects/soc2005/libalias/sys/modules/zfs/Makefile#2 integrate .. //depot/projects/soc2005/libalias/sys/sys/param.h#15 integrate .. //depot/projects/soc2005/libalias/sys/sys/systm.h#12 integrate Differences ... ==== //depot/projects/soc2005/libalias/contrib/opensolaris/cmd/zpool/zpool_main.c#2 (text+ko) ==== @@ -1082,6 +1082,10 @@ "incompatible version.\n")); break; + case ZPOOL_STATUS_HOSTID_MISMATCH: + (void) printf(gettext("status: The pool was last accessed by " + "another system.\n")); + break; default: /* * No other status can be seen when importing pools. @@ -1098,6 +1102,10 @@ "imported using its name or numeric identifier, " "though\n\tsome features will not be available " "without an explicit 'zpool upgrade'.\n")); + else if (reason == ZPOOL_STATUS_HOSTID_MISMATCH) + (void) printf(gettext("action: The pool can be " + "imported using its name or numeric " + "identifier and\n\tthe '-f' flag.\n")); else (void) printf(gettext("action: The pool can be " "imported using its name or numeric " @@ -1187,10 +1195,37 @@ "is formatted using a newer ZFS version\n"), name); return (1); } else if (state != POOL_STATE_EXPORTED && !force) { - (void) fprintf(stderr, gettext("cannot import '%s': pool " - "may be in use from other system\n"), name); - (void) fprintf(stderr, gettext("use '-f' to import anyway\n")); - return (1); + uint64_t hostid; + + if (nvlist_lookup_uint64(config, ZPOOL_CONFIG_HOSTID, + &hostid) == 0) { + if ((unsigned long)hostid != gethostid()) { + char *hostname; + uint64_t timestamp; + time_t t; + + verify(nvlist_lookup_string(config, + ZPOOL_CONFIG_HOSTNAME, &hostname) == 0); + verify(nvlist_lookup_uint64(config, + ZPOOL_CONFIG_TIMESTAMP, ×tamp) == 0); + t = timestamp; + (void) fprintf(stderr, gettext("cannot import " + "'%s': pool may be in use from other " + "system, it was last accessed by %s " + "(hostid: 0x%lx) on %s"), name, hostname, + (unsigned long)hostid, + asctime(localtime(&t))); + (void) fprintf(stderr, gettext("use '-f' to " + "import anyway\n")); + return (1); + } + } else { + (void) fprintf(stderr, gettext("cannot import '%s': " + "pool may be in use from other system\n"), name); + (void) fprintf(stderr, gettext("use '-f' to import " + "anyway\n")); + return (1); + } } if (zpool_import(g_zfs, config, newname, altroot) != 0) ==== //depot/projects/soc2005/libalias/contrib/opensolaris/cmd/ztest/ztest.c#2 (text+ko) ==== @@ -246,6 +246,8 @@ #define ZTEST_DIROBJ_BLOCKSIZE (1 << 10) #define ZTEST_DIRSIZE 256 +static void usage(boolean_t); + /* * These libumem hooks provide a reasonable set of defaults for the allocator's * debugging facilities. @@ -303,13 +305,17 @@ if (toupper(buf[0]) == ends[i]) break; } - if (i == strlen(ends)) - fatal(0, "invalid bytes suffix: %s", buf); + if (i == strlen(ends)) { + (void) fprintf(stderr, "ztest: invalid bytes suffix: %s\n", + buf); + usage(B_FALSE); + } if (buf[1] == '\0' || (toupper(buf[1]) == 'B' && buf[2] == '\0')) { return (10*i); } - fatal(0, "invalid bytes suffix: %s", buf); - return (-1); + (void) fprintf(stderr, "ztest: invalid bytes suffix: %s\n", buf); + usage(B_FALSE); + /* NOTREACHED */ } static uint64_t @@ -320,32 +326,40 @@ val = strtoull(buf, &end, 0); if (end == buf) { - fatal(0, "bad numeric value: %s", buf); + (void) fprintf(stderr, "ztest: bad numeric value: %s\n", buf); + usage(B_FALSE); } else if (end[0] == '.') { double fval = strtod(buf, &end); fval *= pow(2, str2shift(end)); - if (fval > UINT64_MAX) - fatal(0, "value too large: %s", buf); + if (fval > UINT64_MAX) { + (void) fprintf(stderr, "ztest: value too large: %s\n", + buf); + usage(B_FALSE); + } val = (uint64_t)fval; } else { int shift = str2shift(end); - if (shift >= 64 || (val << shift) >> shift != val) - fatal(0, "value too large: %s", buf); + if (shift >= 64 || (val << shift) >> shift != val) { + (void) fprintf(stderr, "ztest: value too large: %s\n", + buf); + usage(B_FALSE); + } val <<= shift; } return (val); } static void -usage(void) +usage(boolean_t requested) { char nice_vdev_size[10]; char nice_gang_bang[10]; + FILE *fp = requested ? stdout : stderr; nicenum(zopt_vdev_size, nice_vdev_size); nicenum(zio_gang_bang, nice_gang_bang); - (void) printf("Usage: %s\n" + (void) fprintf(fp, "Usage: %s\n" "\t[-v vdevs (default: %llu)]\n" "\t[-s size_of_each_vdev (default: %s)]\n" "\t[-a alignment_shift (default: %d) (use 0 for random)]\n" @@ -364,6 +378,7 @@ "\t[-T time] total run time (default: %llu sec)\n" "\t[-P passtime] time per pass (default: %llu sec)\n" "\t[-z zil failure rate (default: fail every 2^%llu allocs)]\n" + "\t[-h] (print help)\n" "", cmdname, (u_longlong_t)zopt_vdevs, /* -v */ @@ -382,7 +397,7 @@ (u_longlong_t)zopt_time, /* -T */ (u_longlong_t)zopt_passtime, /* -P */ (u_longlong_t)zio_zil_fail_shift); /* -z */ - exit(1); + exit(requested ? 0 : 1); } static uint64_t @@ -422,7 +437,7 @@ zio_zil_fail_shift = 5; while ((opt = getopt(argc, argv, - "v:s:a:m:r:R:d:t:g:i:k:p:f:VET:P:z:")) != EOF) { + "v:s:a:m:r:R:d:t:g:i:k:p:f:VET:P:z:h")) != EOF) { value = 0; switch (opt) { case 'v': @@ -496,9 +511,12 @@ case 'z': zio_zil_fail_shift = MIN(value, 16); break; + case 'h': + usage(B_TRUE); + break; case '?': default: - usage(); + usage(B_FALSE); break; } } ==== //depot/projects/soc2005/libalias/contrib/opensolaris/lib/libzfs/common/libzfs.h#2 (text+ko) ==== @@ -98,6 +98,7 @@ EZFS_POOLPROPS, /* couldn't retrieve pool props */ EZFS_POOL_NOTSUP, /* ops not supported for this type of pool */ EZFS_POOL_INVALARG, /* invalid argument for this pool operation */ + EZFS_NAMETOOLONG, /* dataset name is too long */ EZFS_UNKNOWN }; @@ -192,6 +193,7 @@ ZPOOL_STATUS_CORRUPT_DATA, /* data errors in user (meta)data */ ZPOOL_STATUS_FAILING_DEV, /* device experiencing errors */ ZPOOL_STATUS_VERSION_NEWER, /* newer on-disk version */ + ZPOOL_STATUS_HOSTID_MISMATCH, /* last accessed by another system */ /* * The following are not faults per se, but still an error possibly ==== //depot/projects/soc2005/libalias/contrib/opensolaris/lib/libzfs/common/libzfs_import.c#2 (text+ko) ==== @@ -379,7 +379,7 @@ uint_t i, nspares; boolean_t config_seen; uint64_t best_txg; - char *name; + char *name, *hostname; zfs_cmd_t zc = { 0 }; uint64_t version, guid; size_t len; @@ -388,6 +388,7 @@ nvlist_t **child = NULL; uint_t c; boolean_t isactive; + uint64_t hostid; if (nvlist_alloc(&ret, 0, 0) != 0) goto nomem; @@ -430,6 +431,8 @@ * pool guid * name * pool state + * hostid (if available) + * hostname (if available) */ uint64_t state; @@ -453,6 +456,20 @@ if (nvlist_add_uint64(config, ZPOOL_CONFIG_POOL_STATE, state) != 0) goto nomem; + hostid = 0; + if (nvlist_lookup_uint64(tmp, + ZPOOL_CONFIG_HOSTID, &hostid) == 0) { + if (nvlist_add_uint64(config, + ZPOOL_CONFIG_HOSTID, hostid) != 0) + goto nomem; + verify(nvlist_lookup_string(tmp, + ZPOOL_CONFIG_HOSTNAME, + &hostname) == 0); + if (nvlist_add_string(config, + ZPOOL_CONFIG_HOSTNAME, + hostname) != 0) + goto nomem; + } config_seen = B_TRUE; } @@ -622,6 +639,20 @@ } /* + * Restore the original information read from the actual label. + */ + (void) nvlist_remove(config, ZPOOL_CONFIG_HOSTID, + DATA_TYPE_UINT64); + (void) nvlist_remove(config, ZPOOL_CONFIG_HOSTNAME, + DATA_TYPE_STRING); + if (hostid != 0) { + verify(nvlist_add_uint64(config, ZPOOL_CONFIG_HOSTID, + hostid) == 0); + verify(nvlist_add_string(config, ZPOOL_CONFIG_HOSTNAME, + hostname) == 0); + } + + /* * Add this pool to the list of configs. */ verify(nvlist_lookup_string(config, ZPOOL_CONFIG_POOL_NAME, ==== //depot/projects/soc2005/libalias/contrib/opensolaris/lib/libzfs/common/libzfs_status.c#2 (text+ko) ==== @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -43,6 +43,7 @@ #include <libzfs.h> #include <string.h> +#include <unistd.h> #include "libzfs_impl.h" /* @@ -50,7 +51,7 @@ * in libzfs.h. Note that there are some status results which go past the end * of this table, and hence have no associated message ID. */ -static char *msgid_table[] = { +static char *zfs_msgid_table[] = { "ZFS-8000-14", "ZFS-8000-2Q", "ZFS-8000-3C", @@ -60,7 +61,8 @@ "ZFS-8000-72", "ZFS-8000-8A", "ZFS-8000-9P", - "ZFS-8000-A5" + "ZFS-8000-A5", + "ZFS-8000-EY" }; /* @@ -69,7 +71,7 @@ * and the article referred to by 'zpool status' must match that indicated by * the syslog error message. We override missing data as well as corrupt pool. */ -static char *msgid_table_active[] = { +static char *zfs_msgid_table_active[] = { "ZFS-8000-14", "ZFS-8000-D3", /* overridden */ "ZFS-8000-D3", /* overridden */ @@ -82,7 +84,7 @@ "ZFS-8000-CS", /* overridden */ }; -#define NMSGID (sizeof (msgid_table) / sizeof (msgid_table[0])) +#define NMSGID (sizeof (zfs_msgid_table) / sizeof (zfs_msgid_table[0])) /* ARGSUSED */ static int @@ -178,6 +180,8 @@ uint_t vsc; uint64_t nerr; uint64_t version; + uint64_t stateval; + uint64_t hostid = 0; verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_VERSION, &version) == 0); @@ -185,6 +189,16 @@ &nvroot) == 0); verify(nvlist_lookup_uint64_array(nvroot, ZPOOL_CONFIG_STATS, (uint64_t **)&vs, &vsc) == 0); + verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_STATE, + &stateval) == 0); + (void) nvlist_lookup_uint64(config, ZPOOL_CONFIG_HOSTID, &hostid); + + /* + * Pool last accessed by another system. + */ + if (hostid != 0 && (unsigned long)hostid != gethostid() && + stateval == POOL_STATE_ACTIVE) + return (ZPOOL_STATUS_HOSTID_MISMATCH); /* * Newer on-disk version. @@ -270,7 +284,7 @@ if (ret >= NMSGID) *msgid = NULL; else - *msgid = msgid_table_active[ret]; + *msgid = zfs_msgid_table_active[ret]; return (ret); } @@ -283,7 +297,7 @@ if (ret >= NMSGID) *msgid = NULL; else - *msgid = msgid_table[ret]; + *msgid = zfs_msgid_table[ret]; return (ret); } ==== //depot/projects/soc2005/libalias/contrib/opensolaris/lib/libzfs/common/libzfs_util.c#2 (text+ko) ==== @@ -167,6 +167,8 @@ case EZFS_POOL_INVALARG: return (dgettext(TEXT_DOMAIN, "invalid argument for " "this pool operation")); + case EZFS_NAMETOOLONG: + return (dgettext(TEXT_DOMAIN, "dataset name is too long")); case EZFS_UNKNOWN: return (dgettext(TEXT_DOMAIN, "unknown error")); default: @@ -306,6 +308,11 @@ "dataset is busy")); zfs_verror(hdl, EZFS_BUSY, fmt, ap); break; + + case ENAMETOOLONG: + zfs_verror(hdl, EZFS_NAMETOOLONG, fmt, ap); + break; + default: zfs_error_aux(hdl, strerror(errno)); zfs_verror(hdl, EZFS_UNKNOWN, fmt, ap); ==== //depot/projects/soc2005/libalias/contrib/opensolaris/lib/libzpool/common/kernel.c#2 (text+ko) ==== @@ -37,6 +37,7 @@ #include <sys/processor.h> #include <sys/zfs_context.h> #include <sys/zmod.h> +#include <sys/utsname.h> /* * Emulation of kernel services in userland. @@ -45,6 +46,11 @@ int hz = 119; /* frequency when using gethrtime() >> 23 for lbolt */ uint64_t physmem; vnode_t *rootdir = (vnode_t *)0xabcd1234; +char hw_serial[11]; + +struct utsname utsname = { + "userland", "libzpool", "1", "1", "na" +}; /* * ========================================================================= @@ -770,6 +776,17 @@ return (random_get_bytes_common(ptr, len, "/dev/urandom")); } +int +ddi_strtoul(const char *hw_serial, char **nptr, int base, unsigned long *result) +{ + char *end; + + *result = strtoul(hw_serial, &end, base); + if (*result == 0) + return (errno); + return (0); +} + /* * ========================================================================= * kernel emulation setup & teardown @@ -795,6 +812,8 @@ dprintf("physmem = %llu pages (%.2f GB)\n", physmem, (double)physmem * sysconf(_SC_PAGE_SIZE) / (1ULL << 30)); + snprintf(hw_serial, sizeof (hw_serial), "%ld", gethostid()); + spa_init(mode); } ==== //depot/projects/soc2005/libalias/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h#2 (text+ko) ==== @@ -436,6 +436,14 @@ #define zone_dataset_visible(x, y) (1) #define INGLOBALZONE(z) (1) +/* + * Hostname information + */ +extern struct utsname utsname; +extern char hw_serial[]; +extern int ddi_strtoul(const char *str, char **nptr, int base, + unsigned long *result); + #ifdef __cplusplus } #endif ==== //depot/projects/soc2005/libalias/etc/devd.conf#3 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/etc/devd.conf,v 1.35 2007/02/15 16:38:10 imp Exp $ +# $FreeBSD: src/etc/devd.conf,v 1.37 2007/04/08 16:05:23 pjd Exp $ # # Refer to devd.conf(5) and devd(8) man pages for the details on how to # run and configure devd. @@ -208,6 +208,37 @@ action "logger -p kern.emerg 'WARNING: system temperature too high, shutting down soon!'"; }; +# Sample ZFS problem reports handling. +notify 10 { + match "system" "ZFS"; + match "type" "zpool"; + action "logger -p kern.err 'ZFS: failed to load zpool $pool'"; +}; + +notify 10 { + match "system" "ZFS"; + match "type" "vdev"; + action "logger -p kern.err 'ZFS: vdev failure, zpool=$pool type=$type'"; +}; + +notify 10 { + match "system" "ZFS"; + match "type" "data"; + action "logger -p kern.warn 'ZFS: zpool I/O failure, zpool=$pool error=$zio_err'"; +}; + +notify 10 { + match "system" "ZFS"; + match "type" "io"; + action "logger -p kern.warn 'ZFS: vdev I/O failure, zpool=$pool path=$vdev_path offset=$zio_offset size=$zio_size error=$zio_err'"; +}; + +notify 10 { + match "system" "ZFS"; + match "type" "checksum"; + action "logger -p kern.warn 'ZFS: checksum mismatch, zpool=$pool path=$vdev_path offset=$zio_offset size=$zio_size'"; +}; + /* EXAMPLES TO END OF FILE # The following might be an example of something that a vendor might ==== //depot/projects/soc2005/libalias/sys/boot/forth/loader.conf#9 (text+ko) ==== @@ -6,7 +6,7 @@ # # All arguments must be in double quotes. # -# $FreeBSD: src/sys/boot/forth/loader.conf,v 1.118 2007/02/04 06:35:10 imp Exp $ +# $FreeBSD: src/sys/boot/forth/loader.conf,v 1.119 2007/04/09 00:04:54 pjd Exp $ ############################################################## ### Basic configuration options ############################ @@ -418,3 +418,10 @@ #module_after="cmd" # executes "cmd" after loading the module #module_error="cmd" # executes "cmd" if load fails +############################################################## +### Always try to load ZFS pool cache file ################# +############################################################## + +zpool_cache_load="YES" +zpool_cache_type="/boot/zfs/zpool.cache" +zpool_cache_name="/boot/zfs/zpool.cache" ==== //depot/projects/soc2005/libalias/sys/cam/scsi/scsi_sg.c#2 (text+ko) ==== @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/cam/scsi/scsi_sg.c,v 1.1 2007/04/07 19:40:57 scottl Exp $"); +__FBSDID("$FreeBSD: src/sys/cam/scsi/scsi_sg.c,v 1.3 2007/04/09 05:47:32 scottl Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -71,8 +71,8 @@ } sg_state; typedef enum { + SG_RDWR_FREE, SG_RDWR_INPROG, - SG_RDWR_WAITING, SG_RDWR_DONE } sg_rdwr_state; @@ -289,13 +289,12 @@ return (CAM_REQ_CMP_ERR); } - softc = (struct sg_softc *)malloc(sizeof(*softc), M_DEVBUF, M_NOWAIT); + softc = malloc(sizeof(*softc), M_DEVBUF, M_ZERO | M_NOWAIT); if (softc == NULL) { printf("sgregister: Unable to allocate softc\n"); return (CAM_REQ_CMP_ERR); } - bzero(softc, sizeof(*softc)); softc->state = SG_STATE_NORMAL; softc->pd_type = SID_TYPE(&cgd->inq_data); TAILQ_INIT(&softc->rdwr_done); @@ -388,8 +387,7 @@ rdwr = done_ccb->ccb_h.ccb_rdwr; state = rdwr->state; rdwr->state = SG_RDWR_DONE; - if (state == SG_RDWR_WAITING) - wakeup(rdwr); + wakeup(rdwr); break; } default: @@ -507,6 +505,7 @@ * The linuxolator seems to have a hard time with this, * so just return 0 and hope that apps can cope. */ + td->td_retval[0] = 60*hz; error = 0; break; case SG_IO: @@ -679,7 +678,7 @@ periph = dev->si_drv1; sc = periph->softc; - rdwr = malloc(sizeof(*rdwr), M_DEVBUF, M_WAITOK); + rdwr = malloc(sizeof(*rdwr), M_DEVBUF, M_WAITOK | M_ZERO); hdr = &rdwr->hdr.hdr; /* Copy in the header block and sanity check it */ @@ -728,13 +727,13 @@ */ buf_len = uio->uio_resid; if (buf_len != 0) { - buf = malloc(buf_len, M_DEVBUF, M_WAITOK); + buf = malloc(buf_len, M_DEVBUF, M_WAITOK | M_ZERO); error = uiomove(buf, buf_len, uio); if (error) goto out_buf; dir = CAM_DIR_OUT; } else if (hdr->reply_len != 0) { - buf = malloc(hdr->reply_len, M_DEVBUF, M_WAITOK); + buf = malloc(hdr->reply_len, M_DEVBUF, M_WAITOK | M_ZERO); buf_len = hdr->reply_len; dir = CAM_DIR_IN; } else { @@ -809,7 +808,6 @@ break; } if ((rdwr == NULL) || (rdwr->state != SG_RDWR_DONE)) { - rdwr->state = SG_RDWR_WAITING; if (tsleep(rdwr, PCATCH, "sgread", 0) == ERESTART) return (EAGAIN); goto search; ==== //depot/projects/soc2005/libalias/sys/compat/opensolaris/kern/opensolaris_kobj.c#2 (text+ko) ==== @@ -25,17 +25,18 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/compat/opensolaris/kern/opensolaris_kobj.c,v 1.1 2007/04/06 01:09:06 pjd Exp $"); +__FBSDID("$FreeBSD: src/sys/compat/opensolaris/kern/opensolaris_kobj.c,v 1.2 2007/04/08 23:57:08 pjd Exp $"); #include <sys/types.h> #include <sys/systm.h> #include <sys/kernel.h> +#include <sys/systm.h> #include <sys/kthread.h> #include <sys/namei.h> #include <sys/proc.h> #include <sys/filedesc.h> -#include <sys/vnode.h> #include <sys/fcntl.h> +#include <sys/linker.h> #include <sys/kobj.h> void @@ -62,8 +63,8 @@ return (p); } -struct _buf * -kobj_open_file(const char *file) +static void * +kobj_open_file_vnode(const char *file) { struct thread *td = curthread; struct nameidata nd; @@ -79,16 +80,45 @@ error = vn_open_cred(&nd, &flags, 0, td->td_ucred, -1); NDFREE(&nd, NDF_ONLY_PNBUF); if (error != 0) - return ((struct _buf *)-1); + return (NULL); /* We just unlock so we hold a reference. */ VOP_UNLOCK(nd.ni_vp, 0, td); - return ((struct _buf *)nd.ni_vp); + return (nd.ni_vp); +} + +static void * +kobj_open_file_loader(const char *file) +{ + + return (preload_search_by_name(file)); +} + +struct _buf * +kobj_open_file(const char *file) +{ + struct _buf *out; + + out = kmem_alloc(sizeof(*out), KM_SLEEP); + out->mounted = root_mounted(); + /* + * If root is already mounted we read file using file system, + * if not, we use loader. + */ + if (out->mounted) + out->ptr = kobj_open_file_vnode(file); + else + out->ptr = kobj_open_file_loader(file); + if (out->ptr == NULL) { + kmem_free(out, sizeof(*out)); + return ((struct _buf *)-1); + } + return (out); } -int -kobj_get_filesize(struct _buf *file, uint64_t *size) +static int +kobj_get_filesize_vnode(struct _buf *file, uint64_t *size) { - struct vnode *vp = (struct vnode *)file; + struct vnode *vp = file->ptr; struct thread *td = curthread; struct vattr va; int error; @@ -101,10 +131,32 @@ return (error); } +static int +kobj_get_filesize_loader(struct _buf *file, uint64_t *size) +{ + void *ptr; + + ptr = preload_search_info(file->ptr, MODINFO_SIZE); + if (ptr == NULL) + return (ENOENT); + *size = (uint64_t)*(size_t *)ptr; + return (0); +} + +int +kobj_get_filesize(struct _buf *file, uint64_t *size) +{ + + if (file->mounted) + return (kobj_get_filesize_vnode(file, size)); + else + return (kobj_get_filesize_loader(file, size)); +} + int -kobj_read_file(struct _buf *file, char *buf, unsigned size, unsigned off) +kobj_read_file_vnode(struct _buf *file, char *buf, unsigned size, unsigned off) { - struct vnode *vp = (struct vnode *)file; + struct vnode *vp = file->ptr; struct thread *td = curthread; struct uio auio; struct iovec aiov; @@ -130,13 +182,39 @@ return (error != 0 ? -1 : size - auio.uio_resid); } +int +kobj_read_file_loader(struct _buf *file, char *buf, unsigned size, unsigned off) +{ + char *ptr; + + ptr = preload_search_info(file->ptr, MODINFO_ADDR); + if (ptr == NULL) + return (ENOENT); + ptr = *(void **)ptr; + bcopy(ptr + off, buf, size); + return (0); +} + +int +kobj_read_file(struct _buf *file, char *buf, unsigned size, unsigned off) +{ + + if (file->mounted) + return (kobj_read_file_vnode(file, buf, size, off)); + else + return (kobj_read_file_loader(file, buf, size, off)); +} + void kobj_close_file(struct _buf *file) { - struct vnode *vp = (struct vnode *)file; - struct thread *td = curthread; - int flags; + + if (file->mounted) { + struct vnode *vp = file->ptr; + struct thread *td = curthread; + int flags = FREAD; - flags = FREAD; - vn_close(vp, flags, td->td_ucred, td); + vn_close(vp, flags, td->td_ucred, td); + } + kmem_free(file, sizeof(*file)); } ==== //depot/projects/soc2005/libalias/sys/compat/opensolaris/sys/kobj.h#2 (text+ko) ==== @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/compat/opensolaris/sys/kobj.h,v 1.1 2007/04/06 01:09:06 pjd Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/kobj.h,v 1.2 2007/04/08 23:57:08 pjd Exp $ */ #ifndef _OPENSOLARIS_SYS_KOBJ_H_ @@ -31,6 +31,13 @@ #include <sys/types.h> #include <sys/kmem.h> +#include_next <sys/kobj.h> +#ifdef AT_UID +#undef AT_UID +#endif +#ifdef AT_GID +#undef AT_GID +#endif #include <sys/vnode.h> #define KM_NOWAIT 0x01 @@ -41,7 +48,8 @@ void *kobj_zalloc(size_t size, int flag); struct _buf { - void *dummy; + void *ptr; + int mounted; }; struct _buf *kobj_open_file(const char *path); ==== //depot/projects/soc2005/libalias/sys/compat/opensolaris/sys/mutex.h#2 (text+ko) ==== @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/compat/opensolaris/sys/mutex.h,v 1.1 2007/04/06 01:09:06 pjd Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/mutex.h,v 1.2 2007/04/09 01:05:31 pjd Exp $ */ #ifndef _OPENSOLARIS_SYS_MUTEX_H_ @@ -48,6 +48,9 @@ #define mutex_init(lock, desc, type, arg) do { \ ASSERT((type) == MUTEX_DEFAULT); \ + KASSERT(((lock)->lock_object.lo_flags & LO_ALLMASK) != \ + LO_EXPECTED, ("lock %s already initialized", #lock)); \ + bzero((lock), sizeof(struct sx)); \ sx_init_flags((lock), "zfs:" #lock, SX_DUPOK); \ } while (0) #define mutex_destroy(lock) sx_destroy(lock) ==== //depot/projects/soc2005/libalias/sys/compat/opensolaris/sys/rwlock.h#2 (text+ko) ==== @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/compat/opensolaris/sys/rwlock.h,v 1.1 2007/04/06 01:09:06 pjd Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/rwlock.h,v 1.2 2007/04/09 01:05:31 pjd Exp $ */ #ifndef _OPENSOLARIS_SYS_RWLOCK_H_ @@ -53,8 +53,12 @@ #define RW_LOCK_HELD(x) (rw_lock_held((x))) #define RW_ISWRITER(x) (rw_iswriter(x)) -#define rw_init(lock, desc, type, arg) \ - sx_init_flags((lock), "zfs:" #lock, SX_DUPOK) +#define rw_init(lock, desc, type, arg) do { \ + KASSERT(((lock)->lock_object.lo_flags & LO_ALLMASK) != \ + LO_EXPECTED, ("lock %s already initialized", #lock)); \ + bzero((lock), sizeof(struct sx)); \ + sx_init_flags((lock), "zfs:" #lock, SX_DUPOK); \ +} while (0) #define rw_destroy(lock) sx_destroy(lock) #define rw_enter(lock, how) do { \ if ((how) == RW_READER) \ ==== //depot/projects/soc2005/libalias/sys/conf/files#25 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/conf/files,v 1.1191 2007/04/07 19:40:57 scottl Exp $ +# $FreeBSD: src/sys/conf/files,v 1.1193 2007/04/09 12:51:29 andre Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and @@ -520,6 +520,7 @@ dev/cxgb/common/cxgb_mv88e1xxx.c optional cxgb pci dev/cxgb/common/cxgb_xgmac.c optional cxgb pci dev/cxgb/common/cxgb_t3_hw.c optional cxgb pci +dev/cxgb/sys/uipc_mvec.c optional cxgb pci dev/cy/cy.c optional cy dev/cy/cy_isa.c optional cy isa dev/cy/cy_pci.c optional cy pci @@ -1774,19 +1775,19 @@ netinet/ip_options.c optional inet netinet/ip_output.c optional inet netinet/raw_ip.c optional inet -netinet/sctp_usrreq.c optional inet inet6 sctp -netinet/sctp_pcb.c optional inet inet6 sctp -netinet/sctputil.c optional inet inet6 sctp +netinet/sctp_asconf.c optional inet inet6 sctp +netinet/sctp_auth.c optional inet inet6 sctp netinet/sctp_bsd_addr.c optional inet inet6 sctp -netinet/sctp_timer.c optional inet inet6 sctp +netinet/sctp_crc32.c optional inet inet6 sctp +netinet/sctp_indata.c optional inet inet6 sctp netinet/sctp_input.c optional inet inet6 sctp netinet/sctp_output.c optional inet inet6 sctp -netinet/sctp_indata.c optional inet inet6 sctp -netinet/sctp_asconf.c optional inet inet6 sctp +netinet/sctp_pcb.c optional inet inet6 sctp netinet/sctp_peeloff.c optional inet inet6 sctp -netinet/sctp_crc32.c optional inet inet6 sctp -netinet/sctp_auth.c optional inet inet6 sctp netinet/sctp_sysctl.c optional inet inet6 sctp +netinet/sctp_timer.c optional inet inet6 sctp +netinet/sctp_usrreq.c optional inet inet6 sctp +netinet/sctputil.c optional inet inet6 sctp netinet/tcp_debug.c optional tcpdebug netinet/tcp_hostcache.c optional inet netinet/tcp_input.c optional inet ==== //depot/projects/soc2005/libalias/sys/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c#2 (text+ko) ==== @@ -948,7 +948,7 @@ objset_t *os; uint64_t snapobj; zap_cursor_t zc; - zap_attribute_t attr; + zap_attribute_t *attr; char *child; int do_self, err; @@ -958,6 +958,7 @@ /* NB: the $MOS dir doesn't have a head dataset */ do_self = (dd->dd_phys->dd_head_dataset_obj != 0); + attr = kmem_alloc(sizeof (zap_attribute_t), KM_SLEEP); /* * Iterate over all children. @@ -965,10 +966,10 @@ if (flags & DS_FIND_CHILDREN) { >>> TRUNCATED FOR MAIL (1000 lines) <<<
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200704091345.l39DjIsH061094>