Rebase to OpenSolaris b103, in the process we are removing any code which did not originate from the OpenSolaris source. These changes will be reintroduced in topic branches for easier tracking

This commit is contained in:
Brian Behlendorf
2008-12-03 12:09:06 -08:00
parent b6097ae55a
commit b128c09fbe
339 changed files with 15459 additions and 60397 deletions
+17 -7
View File
@@ -19,12 +19,10 @@
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "@(#)translate.c 1.3 07/11/09 SMI"
#include <libzfs.h>
#undef verify /* both libzfs.h and zfs_context.h want to define this */
@@ -47,6 +45,7 @@
#include <sys/dmu.h>
#include <sys/dmu_objset.h>
#include <sys/dnode.h>
#include <sys/vdev_impl.h>
#include <sys/mkdev.h>
@@ -164,7 +163,7 @@ object_from_path(const char *dataset, const char *path, struct stat64 *statbuf,
sync();
if ((err = dmu_objset_open(dataset, DMU_OST_ZFS,
DS_MODE_STANDARD | DS_MODE_READONLY, &os)) != 0) {
DS_MODE_USER | DS_MODE_READONLY, &os)) != 0) {
(void) fprintf(stderr, "cannot open dataset '%s': %s\n",
dataset, strerror(err));
return (-1);
@@ -249,7 +248,7 @@ calculate_range(const char *dataset, err_type_t type, int level, char *range,
* size.
*/
if ((err = dmu_objset_open(dataset, DMU_OST_ANY,
DS_MODE_STANDARD | DS_MODE_READONLY, &os)) != 0) {
DS_MODE_USER | DS_MODE_READONLY, &os)) != 0) {
(void) fprintf(stderr, "cannot open dataset '%s': %s\n",
dataset, strerror(err));
goto out;
@@ -432,7 +431,8 @@ translate_raw(const char *str, zinject_record_t *record)
}
int
translate_device(const char *pool, const char *device, zinject_record_t *record)
translate_device(const char *pool, const char *device, err_type_t label_type,
zinject_record_t *record)
{
char *end;
zpool_handle_t *zhp;
@@ -448,7 +448,7 @@ translate_device(const char *pool, const char *device, zinject_record_t *record)
record->zi_guid = strtoull(device, &end, 16);
if (record->zi_guid == 0 || *end != '\0') {
tgt = zpool_find_vdev(zhp, device, &isspare, &iscache);
tgt = zpool_find_vdev(zhp, device, &isspare, &iscache, NULL);
if (tgt == NULL) {
(void) fprintf(stderr, "cannot find device '%s' in "
@@ -460,5 +460,15 @@ translate_device(const char *pool, const char *device, zinject_record_t *record)
&record->zi_guid) == 0);
}
switch (label_type) {
case TYPE_LABEL_UBERBLOCK:
record->zi_start = offsetof(vdev_label_t, vl_uberblock[0]);
record->zi_end = record->zi_start + VDEV_UBERBLOCK_RING - 1;
break;
case TYPE_LABEL_NVLIST:
record->zi_start = offsetof(vdev_label_t, vl_vdev_phys);
record->zi_end = record->zi_start + VDEV_PHYS_SIZE - 1;
break;
}
return (0);
}
+28 -11
View File
@@ -19,11 +19,11 @@
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "@(#)zinject.c 1.4 07/09/17 SMI"
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* ZFS Fault Injector
@@ -38,15 +38,18 @@
* Errors can be injected into a particular vdev using the '-d' option. This
* option takes a path or vdev GUID to uniquely identify the device within a
* pool. There are two types of errors that can be injected, EIO and ENXIO,
* that can be controlled through the '-t' option. The default is ENXIO. For
* that can be controlled through the '-e' option. The default is ENXIO. For
* EIO failures, any attempt to read data from the device will return EIO, but
* subsequent attempt to reopen the device will succeed. For ENXIO failures,
* any attempt to read from the device will return EIO, but any attempt to
* reopen the device will also return ENXIO.
* For label faults, the -L option must be specified. This allows faults
* to be injected into either the nvlist or uberblock region of all the labels
* for the specified device.
*
* This form of the command looks like:
*
* zinject -d device [-t type] pool
* zinject -d device [-e errno] [-L <uber | nvlist>] pool
*
*
* DATA FAULTS
@@ -165,7 +168,9 @@ static const char *errtable[TYPE_INVAL] = {
"config",
"bplist",
"spacemap",
"errlog"
"errlog",
"uber",
"nvlist"
};
static err_type_t
@@ -219,9 +224,10 @@ usage(void)
"\t\tClear the particular record (if given a numeric ID), or\n"
"\t\tall records if 'all' is specificed.\n"
"\n"
"\tzinject -d device [-e errno] pool\n"
"\t\tInject a fault into a particular device. 'errno' can either\n"
"\t\tbe 'nxio' (the default) or 'io'.\n"
"\tzinject -d device [-e errno] [-L <nvlist|uber>] pool\n"
"\t\tInject a fault into a particular device or the device's\n"
"\t\tlabel. Label injection can either be 'nvlist' or 'uber'.\n"
"\t\t'errno' can either be 'nxio' (the default) or 'io'.\n"
"\n"
"\tzinject -b objset:object:level:blkid pool\n"
"\n"
@@ -474,6 +480,7 @@ main(int argc, char **argv)
int error = 0;
int domount = 0;
err_type_t type = TYPE_INVAL;
err_type_t label = TYPE_INVAL;
zinject_record_t record = { 0 };
char pool[MAXNAMELEN];
char dataset[MAXNAMELEN];
@@ -509,7 +516,7 @@ main(int argc, char **argv)
return (0);
}
while ((c = getopt(argc, argv, ":ab:d:f:qhc:t:l:mr:e:u")) != -1) {
while ((c = getopt(argc, argv, ":ab:d:f:qhc:t:l:mr:e:uL:")) != -1) {
switch (c) {
case 'a':
flags |= ZINJECT_FLUSH_ARC;
@@ -568,7 +575,8 @@ main(int argc, char **argv)
range = optarg;
break;
case 't':
if ((type = name_to_type(optarg)) == TYPE_INVAL) {
if ((type = name_to_type(optarg)) == TYPE_INVAL &&
!MOS_TYPE(type)) {
(void) fprintf(stderr, "invalid type '%s'\n",
optarg);
usage();
@@ -578,6 +586,15 @@ main(int argc, char **argv)
case 'u':
flags |= ZINJECT_UNLOAD_SPA;
break;
case 'L':
if ((label = name_to_type(optarg)) == TYPE_INVAL &&
!LABEL_TYPE(type)) {
(void) fprintf(stderr, "invalid label type "
"'%s'\n", optarg);
usage();
return (1);
}
break;
case ':':
(void) fprintf(stderr, "option -%c requires an "
"operand\n", optopt);
@@ -654,7 +671,7 @@ main(int argc, char **argv)
return (1);
}
if (translate_device(pool, device, &record) != 0)
if (translate_device(pool, device, label, &record) != 0)
return (1);
if (!error)
error = ENXIO;
+9 -4
View File
@@ -19,14 +19,14 @@
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _ZINJECT_H
#define _ZINJECT_H
#pragma ident "@(#)zinject.h 1.2 06/05/24 SMI"
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/zfs_ioctl.h>
@@ -44,17 +44,22 @@ typedef enum {
TYPE_BPLIST, /* block pointer list */
TYPE_SPACEMAP, /* space map objects */
TYPE_ERRLOG, /* persistent error log */
TYPE_LABEL_UBERBLOCK, /* label specific uberblock */
TYPE_LABEL_NVLIST, /* label specific nvlist */
TYPE_INVAL
} err_type_t;
#define MOS_TYPE(t) \
((t) >= TYPE_MOS && (t) < TYPE_INVAL)
((t) >= TYPE_MOS && (t) < TYPE_LABEL_UBERBLOCK)
#define LABEL_TYPE(t) \
((t) >= TYPE_LABEL_UBERBLOCK && (t) < TYPE_INVAL)
int translate_record(err_type_t type, const char *object, const char *range,
int level, zinject_record_t *record, char *poolname, char *dataset);
int translate_raw(const char *raw, zinject_record_t *record);
int translate_device(const char *pool, const char *device,
zinject_record_t *record);
err_type_t label_type, zinject_record_t *record);
void usage(void);
extern libzfs_handle_t *g_zfs;