diff options
Diffstat (limited to 'usr/src/cmd/zinject/zinject.c')
-rw-r--r-- | usr/src/cmd/zinject/zinject.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/usr/src/cmd/zinject/zinject.c b/usr/src/cmd/zinject/zinject.c index 1c0b3199bd..fc836f11e5 100644 --- a/usr/src/cmd/zinject/zinject.c +++ b/usr/src/cmd/zinject/zinject.c @@ -112,9 +112,9 @@ * specified. * * The '-e' option takes a string describing the errno to simulate. This must - * be either 'io' or 'checksum'. In most cases this will result in the same - * behavior, but RAID-Z will produce a different set of ereports for this - * situation. + * be one of 'io', 'checksum', or 'decrypt'. In most cases this will result + * in the same behavior, but RAID-Z will produce a different set of ereports + * for this situation. * * The '-a', '-u', and '-m' flags toggle internal flush behavior. If '-a' is * specified, then the ARC cache is flushed appropriately. If '-u' is @@ -296,8 +296,9 @@ usage(void) "\t\tinterperted depending on the '-t' option.\n" "\n" "\t\t-q\tQuiet mode. Only print out the handler number added.\n" - "\t\t-e\tInject a specific error. Must be either 'io' or\n" - "\t\t\t'checksum', or 'decompress'. Default is 'io'.\n" + "\t\t-e\tInject a specific error. Must be one of 'io', " + "'checksum',\n" + "\t\t\t'decompress', or decrypt. Default is 'io'.\n" "\t\t-C\tInject the given error only into specific DVAs. The\n" "\t\t\tDVAs should be specified as a list of 0-indexed DVAs\n" "\t\t\tseparated by commas (ex. '0,2').\n" @@ -817,6 +818,8 @@ main(int argc, char **argv) error = EIO; } else if (strcasecmp(optarg, "checksum") == 0) { error = ECKSUM; + } else if (strcasecmp(optarg, "decrypt") == 0) { + error = EACCES; } else if (strcasecmp(optarg, "nxio") == 0) { error = ENXIO; } else if (strcasecmp(optarg, "dtl") == 0) { @@ -1144,14 +1147,29 @@ main(int argc, char **argv) (void) fprintf(stderr, "the '-C' option may " "not be used with logical data errors " "'decrypt' and 'decompress'\n"); + record.zi_dvas = dvas; + } + } + + record.zi_cmd = ZINJECT_DATA_FAULT; + + if (error == EACCES) { + if (type != TYPE_DATA) { + (void) fprintf(stderr, "decryption errors " + "may only be injected for 'data' types\n"); libzfs_fini(g_zfs); return (1); } - record.zi_dvas = dvas; + record.zi_cmd = ZINJECT_DECRYPT_FAULT; + /* + * Internally, ZFS actually uses ECKSUM for decryption + * errors since EACCES is used to indicate the key was + * not found. + */ + error = ECKSUM; } - record.zi_cmd = ZINJECT_DATA_FAULT; if (translate_record(type, argv[0], range, level, &record, pool, dataset) != 0) return (1); |