Lines Matching +full:fault +full:- +full:inject
9 * or https://opensource.org/licenses/CDDL-1.0.
25 * Copyright (c) 2023-2024, Klara Inc.
29 * ZFS Fault Injector
32 * from a user-visible object type and name to an internal representation.
38 * Errors can be injected into a particular vdev using the '-d' option. This
41 * ECHILD, and EILSEQ. These can be controlled through the '-e' option and the
46 * only apply to read operations (-T read) and will flip a bit after the device
49 * For label faults, the -L option must be specified. This allows faults
55 * zinject -d device [-e errno] [-L <uber | nvlist | pad1 | pad2>] pool
72 * errors on a particular object or blkid, we inject errors across
98 * These types should be self-explanatory. This tuple is then passed to the
99 * kernel via a special ioctl() to initiate fault injection for the given
100 * object. Note that 'type' is not strictly necessary for fault injection, but
101 * is used when translating existing faults into a human-readable string.
107 * zinject <-a | -u pool>
108 * zinject -c <id|all>
109 * zinject [-q] <-t type> [-f freq] [-u] [-a] [-m] [-e errno] [-l level]
110 * [-r range] <object>
111 * zinject [-f freq] [-a] [-m] [-u] -b objset:object:level:start:end pool
116 * The '-c' option will clear the given handler, or all handlers if 'all' is
119 * The '-e' option takes a string describing the errno to simulate. This must
121 * will result in the same behavior, but RAID-Z will produce a different set of
124 * The '-a', '-u', and '-m' flags toggle internal flush behavior. If '-a' is
125 * specified, then the ARC cache is flushed appropriately. If '-u' is
127 * specified independently of any other handlers. The '-m' flag automatically
131 * The '-f' flag controls the frequency of errors injected, expressed as a
140 * human-readable interface has been designed. It allows developers to specify
208 return ("-");
234 return (-1);
258 "\tzinject -c <id|all>\n"
263 "\tzinject -p <function name> pool\n"
264 "\t\tInject a panic fault at the specified function. Only \n"
268 "\tzinject -d device [-e errno] [-L <nvlist|uber|pad1|pad2>] [-F]\n"
269 "\t\t[-T <read|write|free|claim|flush|all>] [-f frequency] pool\n\n"
270 "\t\tInject a fault into a particular device or the device's\n"
278 "\tzinject -d device -A <degrade|fault> -D <delay secs> pool\n"
281 "\tzinject -d device -D latency:lanes pool\n"
289 "\t\tFor example, with a single lane delay of 10 ms (-D 10:1),\n"
298 "\t\tlanes (-D 10:2), then the device will be able to service\n"
306 "\t\tof '-D 10:1', is roughly equivalent to a single invocation\n"
307 "\t\tof '-D 10:2'. This also means, one can specify multiple\n"
309 "\t\tinvocation of '-D 10:1' followed by '-D 25:2' will\n"
313 "\tzinject -P import|export -s <seconds> pool\n"
318 "\tzinject -I [-s <seconds> | -g <txgs>] pool\n"
325 "\tzinject -b objset:object:level:blkid pool\n"
331 "\tzinject [-q] <-t type> [-C dvas] [-e errno] [-l level]\n"
332 "\t\t[-r range] [-a] [-m] [-u] [-f freq] <object>\n"
334 "\t\tInject an error into the object specified by the '-t' option\n"
336 "\t\tinterpreted depending on the '-t' option.\n"
338 "\t\t-q\tQuiet mode. Only print out the handler number added.\n"
339 "\t\t-e\tInject a specific error. Must be one of 'io',\n"
341 "\t\t-C\tInject the given error only into specific DVAs. The\n"
342 "\t\t\tDVAs should be specified as a list of 0-indexed DVAs\n"
344 "\t\t-l\tInject error at a particular block level. Default is "
346 "\t\t-m\tAutomatically remount underlying filesystem.\n"
347 "\t\t-r\tInject error over a particular logical range of an\n"
350 "\t\t-a\tFlush the ARC cache. Can be specified without any\n"
352 "\t\t-u\tUnload the associated pool. Can be specified with only\n"
354 "\t\t-f\tOnly inject errors a fraction of the time. Expressed as\n"
357 "\t-t data\t\tInject an error into the plain file contents of a\n"
361 "\t-t dnode\tInject an error into the metadnode in the block\n"
363 "\t\t\t'-r' option is incompatible with this mode. The object\n"
367 "\t-t <mos>\tInject errors into the MOS for objects of the given\n"
388 return (-1);
400 if (record->zi_guid != 0 || record->zi_func[0] != '\0' ||
401 record->zi_duration != 0) {
406 (void) printf("%3s %-15s %-6s %-6s %-8s %3s %-4s "
407 "%-15s\n", "ID", "POOL", "OBJSET", "OBJECT", "TYPE",
409 (void) printf("--- --------------- ------ "
410 "------ -------- --- ---- ---------------\n");
415 (void) printf("%3d %-15s %-6llu %-6llu %-8s %-3d 0x%02x ",
416 id, pool, (u_longlong_t)record->zi_objset,
417 (u_longlong_t)record->zi_object, type_to_name(record->zi_type),
418 record->zi_level, record->zi_dvas);
421 if (record->zi_start == 0 &&
422 record->zi_end == -1ULL)
425 (void) printf("[%llu, %llu]\n", (u_longlong_t)record->zi_start,
426 (u_longlong_t)record->zi_end);
441 if (record->zi_guid == 0 || record->zi_func[0] != '\0')
444 if (record->zi_cmd == ZINJECT_DELAY_IO)
448 (void) printf("%3s %-15s %-16s %-5s %-10s %-9s\n",
451 "--- --------------- ---------------- "
452 "----- ---------- ---------\n");
457 double freq = record->zi_freq == 0 ? 100.0f :
458 (((double)record->zi_freq) / ZI_PERCENTAGE_MAX) * 100.0f;
460 (void) printf("%3d %-15s %llx %-5s %-10s %8.4f%%\n", id, pool,
461 (u_longlong_t)record->zi_guid, iotypestr[record->zi_iotype],
462 err_to_str(record->zi_error), freq);
473 if (record->zi_guid == 0 || record->zi_func[0] != '\0')
476 if (record->zi_cmd != ZINJECT_DELAY_IO)
480 (void) printf("%3s %-15s %-15s %-15s %s\n",
482 (void) printf("--- --------------- --------------- "
483 "--------------- ----------------\n");
488 (void) printf("%3d %-15s %-15llu %-15llu %llx\n", id, pool,
489 (u_longlong_t)NSEC2MSEC(record->zi_timer),
490 (u_longlong_t)record->zi_nlanes,
491 (u_longlong_t)record->zi_guid);
502 if (record->zi_func[0] == '\0')
506 (void) printf("%3s %-15s %s\n", "ID", "POOL", "FUNCTION");
507 (void) printf("--- --------------- ----------------\n");
512 (void) printf("%3d %-15s %s\n", id, pool, record->zi_func);
523 if (record->zi_cmd != ZINJECT_DELAY_IMPORT &&
524 record->zi_cmd != ZINJECT_DELAY_EXPORT) {
529 (void) printf("%3s %-19s %-11s %s\n",
531 (void) printf("--- ------------------- -----------"
532 " -------\n");
537 (void) printf("%3d %-19s %-11llu %s\n",
538 id, pool, (u_longlong_t)record->zi_duration,
539 record->zi_cmd == ZINJECT_DELAY_IMPORT ? "import": "export");
605 * Remove all fault injection handlers.
619 * Remove a specific fault injection handler.
640 * Register a new fault injection handler.
660 if (record->zi_cmd == ZINJECT_DELAY_IMPORT)
662 if (record->zi_cmd == ZINJECT_DELAY_EXPORT)
667 if (record->zi_cmd == ZINJECT_DELAY_IMPORT)
686 if (record->zi_guid) {
688 (u_longlong_t)record->zi_guid);
689 } else if (record->zi_func[0] != '\0') {
691 record->zi_func);
692 } else if (record->zi_duration > 0) {
694 (u_longlong_t)record->zi_duration);
695 } else if (record->zi_duration < 0) {
697 (u_longlong_t)-record->zi_duration);
698 } else if (record->zi_timer > 0) {
700 (u_longlong_t)NSEC2MSEC(record->zi_timer));
703 (u_longlong_t)record->zi_objset);
705 (u_longlong_t)record->zi_object);
707 (u_longlong_t)record->zi_type);
708 (void) printf(" level: %d\n", record->zi_level);
709 if (record->zi_start == 0 &&
710 record->zi_end == -1ULL)
714 (u_longlong_t)record->zi_start,
715 (u_longlong_t)record->zi_end);
716 (void) printf(" dvas: 0x%x\n", record->zi_dvas);
730 zc.zc_guid = record->zi_guid;
750 * off this value being non-zero in translate_device(), to
751 * determine if the fault is a ZINJECT_DELAY_IO fault or not.
793 * "1" -> 0b0010 (0x2)
794 * "0,1" -> 0b0011 (0x3)
795 * "0,1,2" -> 0b0111 (0x7)
818 if (mask & (1 << ((*c) - '0')))
821 mask |= (1 << ((*c) - '0'));
886 * available handlers, direct the user to '-h' for help
891 (void) printf("Run 'zinject -h' for usage "
899 ":aA:b:C:d:D:f:Fg:qhIc:t:T:l:mr:s:e:uL:p:P:")) != -1) {
907 } else if (strcasecmp(optarg, "fault") == 0) {
911 "must be 'degrade' or 'fault'\n", optarg);
987 record.zi_duration *= -1;
1094 (void) fprintf(stderr, "option -%c requires an "
1108 argc -= optind;
1116 * '-c' is invalid with any other options.
1121 (void) fprintf(stderr, "cancel (-c) incompatible with "
1128 (void) fprintf(stderr, "extraneous argument to '-c'\n");
1151 * Device (-d) injection uses a completely different mechanism
1157 (void) fprintf(stderr, "device (-d) incompatible with "
1165 (void) fprintf(stderr, "device (-d) injection requires "
1221 (void) fprintf(stderr, "raw (-b) format with "
1229 (void) fprintf(stderr, "raw (-b) format expects a "
1258 "options\n", "import|export delay (-P)");
1265 (void) fprintf(stderr, "panic (-p) injection requires "
1282 "options\n", "import|export delay (-P)");
1289 (void) fprintf(stderr, "import|export delay (-P) "
1290 "injection requires a duration (-s) and a single "
1301 (void) fprintf(stderr, "hardware failure (-I) "
1309 (void) fprintf(stderr, "-s or -g meaningless "
1310 "without -I (ignore writes)\n");
1316 "in seconds (-s) or a number of txgs (-g) "
1322 (void) fprintf(stderr, "ignore writes (-I) "
1333 (void) fprintf(stderr, "at least one of '-b', '-d', "
1334 "'-t', '-a', '-p', '-I' or '-u' "
1346 "'-f'\n");
1370 (void) fprintf(stderr, "the '-C' option may "
1409 * If this is pool-wide metadata, unmount everything. The ioctl() will
1410 * unload the pool, so that we trigger spa-wide reopen of metadata next