Lines Matching full:handler

56  * Data describing each zinject handler registered on the system, and
57 * contains the list node linking the handler in the global zinject
58 * handler list.
77 * This protects insertion into, and traversal of, the inject handler
79 * handler is inserted or removed from the list, this lock should be
101 * Used to assign unique identifying numbers to each new zinject handler.
181 inject_handler_t *handler;
185 for (handler = list_head(&inject_handlers); handler != NULL;
186 handler = list_next(&inject_handlers, handler)) {
188 if (spa != handler->zi_spa)
191 if (handler->zi_record.zi_type == type &&
192 strcmp(tag, handler->zi_record.zi_func) == 0) {
193 handler->zi_record.zi_match_count++;
194 handler->zi_record.zi_inject_count++;
211 inject_handler_t *handler;
215 for (handler = list_head(&inject_handlers); handler != NULL;
216 handler = list_next(&inject_handlers, handler)) {
218 if (spa != handler->zi_spa ||
219 handler->zi_record.zi_cmd != ZINJECT_DECRYPT_FAULT)
223 &handler->zi_record, error)) {
272 inject_handler_t *handler;
294 for (handler = list_head(&inject_handlers); handler != NULL;
295 handler = list_next(&inject_handlers, handler)) {
296 if (zio->io_spa != handler->zi_spa ||
297 handler->zi_record.zi_cmd != ZINJECT_DATA_FAULT)
300 /* If this handler matches, return the specified error */
303 zio_match_dva(zio), &handler->zi_record, error)) {
316 * handler associated with that portion of the label. Currently, we
323 inject_handler_t *handler;
335 for (handler = list_head(&inject_handlers); handler != NULL;
336 handler = list_next(&inject_handlers, handler)) {
337 uint64_t start = handler->zi_record.zi_start;
338 uint64_t end = handler->zi_record.zi_end;
340 if (handler->zi_record.zi_cmd != ZINJECT_LABEL_FAULT)
352 if (zio->io_vd->vdev_guid == handler->zi_record.zi_guid &&
354 handler->zi_record.zi_match_count++;
355 handler->zi_record.zi_inject_count++;
407 inject_handler_t *handler;
426 for (handler = list_head(&inject_handlers); handler != NULL;
427 handler = list_next(&inject_handlers, handler)) {
429 if (handler->zi_record.zi_cmd != ZINJECT_DEVICE_FAULT)
432 if (vd->vdev_guid == handler->zi_record.zi_guid) {
433 if (handler->zi_record.zi_failfast &&
441 handler->zi_record.zi_iotype))
444 if (handler->zi_record.zi_error == err1 ||
445 handler->zi_record.zi_error == err2) {
446 handler->zi_record.zi_match_count++;
451 if (!freq_triggered(handler->zi_record.zi_freq))
454 handler->zi_record.zi_inject_count++;
469 if (!handler->zi_record.zi_failfast &&
476 if (handler->zi_record.zi_error == EILSEQ) {
487 ret = handler->zi_record.zi_error;
490 if (handler->zi_record.zi_error == ENXIO) {
491 handler->zi_record.zi_match_count++;
492 handler->zi_record.zi_inject_count++;
523 inject_handler_t *handler;
527 for (handler = list_head(&inject_handlers); handler != NULL;
528 handler = list_next(&inject_handlers, handler)) {
531 if (zio->io_spa != handler->zi_spa ||
532 handler->zi_record.zi_cmd != ZINJECT_IGNORED_WRITES)
535 handler->zi_record.zi_match_count++;
541 if (handler->zi_record.zi_timer == 0) {
542 if (handler->zi_record.zi_duration > 0)
543 handler->zi_record.zi_timer = ddi_get_lbolt64();
545 handler->zi_record.zi_timer = zio->io_txg;
550 handler->zi_record.zi_inject_count++;
562 inject_handler_t *handler;
569 for (handler = list_head(&inject_handlers); handler != NULL;
570 handler = list_next(&inject_handlers, handler)) {
572 if (spa != handler->zi_spa ||
573 handler->zi_record.zi_cmd != ZINJECT_IGNORED_WRITES)
576 handler->zi_record.zi_match_count++;
577 handler->zi_record.zi_inject_count++;
579 if (handler->zi_record.zi_duration > 0) {
580 VERIFY(handler->zi_record.zi_timer == 0 ||
582 (int64_t)handler->zi_record.zi_timer +
583 handler->zi_record.zi_duration * hz,
587 VERIFY(handler->zi_record.zi_timer == 0 ||
588 handler->zi_record.zi_timer -
589 handler->zi_record.zi_duration >=
628 * Each inject handler has a number of "lanes" associated with
630 * another, and at a latency defined by the inject handler
631 * record's zi_timer field. Thus if a handler in configured with
641 * handler. The mutex allows us to perform the following two
644 * 1. determine the minimum handler and minimum target
646 * 2. update that minimum handler's lane array
650 * (2). This could allow a single lane handler to process
655 for (inject_handler_t *handler = list_head(&inject_handlers);
656 handler != NULL; handler = list_next(&inject_handlers, handler)) {
657 if (handler->zi_record.zi_cmd != ZINJECT_DELAY_IO)
660 if (vd->vdev_guid != handler->zi_record.zi_guid)
664 if (!zio_match_iotype(zio, handler->zi_record.zi_iotype))
669 * occurs prior to inserting this handler on the list.
671 ASSERT3P(handler->zi_lanes, !=, NULL);
677 ASSERT3U(handler->zi_record.zi_nlanes, !=, 0);
679 ASSERT3U(handler->zi_record.zi_nlanes, >,
680 handler->zi_next_lane);
682 handler->zi_record.zi_match_count++;
684 /* Limit the use of this handler if requested */
685 if (!freq_triggered(handler->zi_record.zi_freq))
691 * specific handler can complete the IO with all other
695 * Since each handler has a constant value for its
697 * handler; as it will always be the lane with the
698 * lowest value for that particular handler (i.e. the
700 * scan of each handler's lanes array.
714 hrtime_t idle = handler->zi_record.zi_timer + gethrtime();
715 hrtime_t busy = handler->zi_record.zi_timer +
716 handler->zi_lanes[handler->zi_next_lane];
720 min_handler = handler;
731 * handler during any remaining iterations. Once we're
733 * the lane and increment the handler's "next lane"
738 min_handler = handler;
745 * this vdev, otherwise it will point to the handler containing
753 * If we've used all possible lanes for this handler,
773 inject_handler_t *handler;
779 for (handler = list_head(&inject_handlers);
780 handler != NULL && handler->zi_record.zi_cmd == command;
781 handler = list_next(&inject_handlers, handler)) {
782 ASSERT3P(handler->zi_spa_name, !=, NULL);
783 if (strcmp(spa_name(spa), handler->zi_spa_name) == 0) {
784 handler->zi_record.zi_match_count++;
786 SEC2NSEC(handler->zi_record.zi_duration);
788 handler->zi_record.zi_inject_count++;
791 id = handler->zi_id;
806 /* all done with this one-shot handler */
892 for (inject_handler_t *handler = list_head(&inject_handlers);
893 handler != NULL; handler = list_next(&inject_handlers, handler)) {
894 if (command != handler->zi_record.zi_cmd)
897 const char *pool = (handler->zi_spa_name != NULL) ?
898 handler->zi_spa_name : spa_name(handler->zi_spa);
909 * Create a new handler for the given record. We add it to the list, adding
916 inject_handler_t *handler;
939 * an array used by the handler. Thus, to ensure the
967 * Only one import | export delay handler per pool.
992 handler = kmem_alloc(sizeof (inject_handler_t), KM_SLEEP);
993 handler->zi_spa = spa; /* note: can be NULL */
994 handler->zi_record = *record;
996 if (handler->zi_record.zi_cmd == ZINJECT_DELAY_IO) {
997 handler->zi_lanes = kmem_zalloc(
998 sizeof (*handler->zi_lanes) *
999 handler->zi_record.zi_nlanes, KM_SLEEP);
1000 handler->zi_next_lane = 0;
1002 handler->zi_lanes = NULL;
1003 handler->zi_next_lane = 0;
1006 if (handler->zi_spa == NULL)
1007 handler->zi_spa_name = spa_strdup(name);
1009 handler->zi_spa_name = NULL;
1017 * allocating the handler's zi_lanes array.
1019 if (handler->zi_record.zi_cmd == ZINJECT_DELAY_IO) {
1025 *id = handler->zi_id = inject_next_id++;
1026 list_insert_tail(&inject_handlers, handler);
1056 inject_handler_t *handler;
1062 for (handler = list_head(&inject_handlers); handler != NULL;
1063 handler = list_next(&inject_handlers, handler))
1064 if (handler->zi_id > *id)
1067 if (handler) {
1068 *record = handler->zi_record;
1069 *id = handler->zi_id;
1070 ASSERT(handler->zi_spa || handler->zi_spa_name);
1071 if (handler->zi_spa != NULL)
1072 (void) strlcpy(name, spa_name(handler->zi_spa), buflen);
1074 (void) strlcpy(name, handler->zi_spa_name, buflen);
1087 * Clear the fault handler with the given identifier, or return ENOENT if none
1093 inject_handler_t *handler;
1097 for (handler = list_head(&inject_handlers); handler != NULL;
1098 handler = list_next(&inject_handlers, handler))
1099 if (handler->zi_id == id)
1102 if (handler == NULL) {
1107 if (handler->zi_record.zi_cmd == ZINJECT_DELAY_IO) {
1113 list_remove(&inject_handlers, handler);
1116 if (handler->zi_record.zi_cmd == ZINJECT_DELAY_IO) {
1117 ASSERT3P(handler->zi_lanes, !=, NULL);
1118 kmem_free(handler->zi_lanes, sizeof (*handler->zi_lanes) *
1119 handler->zi_record.zi_nlanes);
1121 ASSERT3P(handler->zi_lanes, ==, NULL);
1124 if (handler->zi_spa_name != NULL)
1125 spa_strfree(handler->zi_spa_name);
1127 if (handler->zi_spa != NULL)
1128 spa_inject_delref(handler->zi_spa);
1129 kmem_free(handler, sizeof (inject_handler_t));