636 }
637
638 *id = handler->zi_id = inject_next_id++;
639 list_insert_tail(&inject_handlers, handler);
640 atomic_inc_32(&zio_injection_enabled);
641
642 rw_exit(&inject_lock);
643 }
644
645 /*
646 * Flush the ARC, so that any attempts to read this data will end up
647 * going to the ZIO layer. Note that this is a little overkill, but
648 * we don't have the necessary ARC interfaces to do anything else, and
649 * fault injection isn't a performance critical path.
650 */
651 if (flags & ZINJECT_FLUSH_ARC)
652 /*
653 * We must use FALSE to ensure arc_flush returns, since
654 * we're not preventing concurrent ARC insertions.
655 */
656 arc_flush(NULL, FALSE);
657
658 return (0);
659 }
660
661 /*
662 * Returns the next record with an ID greater than that supplied to the
663 * function. Used to iterate over all handlers in the system.
664 */
665 int
666 zio_inject_list_next(int *id, char *name, size_t buflen,
667 zinject_record_t *record)
668 {
669 inject_handler_t *handler;
670 int ret;
671
672 mutex_enter(&spa_namespace_lock);
673 rw_enter(&inject_lock, RW_READER);
674
675 for (handler = list_head(&inject_handlers); handler != NULL;
676 handler = list_next(&inject_handlers, handler))
|
636 }
637
638 *id = handler->zi_id = inject_next_id++;
639 list_insert_tail(&inject_handlers, handler);
640 atomic_inc_32(&zio_injection_enabled);
641
642 rw_exit(&inject_lock);
643 }
644
645 /*
646 * Flush the ARC, so that any attempts to read this data will end up
647 * going to the ZIO layer. Note that this is a little overkill, but
648 * we don't have the necessary ARC interfaces to do anything else, and
649 * fault injection isn't a performance critical path.
650 */
651 if (flags & ZINJECT_FLUSH_ARC)
652 /*
653 * We must use FALSE to ensure arc_flush returns, since
654 * we're not preventing concurrent ARC insertions.
655 */
656 arc_flush(NULL, B_FALSE);
657
658 return (0);
659 }
660
661 /*
662 * Returns the next record with an ID greater than that supplied to the
663 * function. Used to iterate over all handlers in the system.
664 */
665 int
666 zio_inject_list_next(int *id, char *name, size_t buflen,
667 zinject_record_t *record)
668 {
669 inject_handler_t *handler;
670 int ret;
671
672 mutex_enter(&spa_namespace_lock);
673 rw_enter(&inject_lock, RW_READER);
674
675 for (handler = list_head(&inject_handlers); handler != NULL;
676 handler = list_next(&inject_handlers, handler))
|