FreeBSD/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_errlog.c
/*
 * Copy all known errors to userland as an array of bookmarks.  This is
 * actually a union of the on-disk last log and current log, as well as any
 * pending error requests.
 *
 * Because the act of reading the on-disk log could cause errors to be
 * generated, we have two separate locks: one for the error log and one for the
 * in-core error lists.  We only need the error list lock to log and error, so
 * we grab the error log lock while we read the on-disk logs, and only pick up
 * the error list lock when we are finished.
 */
Copy all known errors to userland as an array of bookmarks.  This is
actually a union of the on-disk last log and current log, as well as any
pending error requests.

Because the act of reading the on-disk log could cause errors to be
generated, we have two separate locks: one for the error log and one for the
in-core error lists.  We only need the error list lock to log and error, so
we grab the error log lock while we read the on-disk logs, and only pick up
the error list lock when we are finished.
Copy all known errors to userland as an array of bookmarks . This is actually a union of the on - disk last log and current log as well as any pending error requests . Because the act of reading the on - disk log could cause errors to be generated we have two separate locks : one for the error log and one for the in - core error lists . We only need the error list lock to log and error so we grab the error log lock while we read the on - disk logs and only pick up the error list lock when we are finished .
int
spa_get_errlog(spa_t *spa, void *uaddr, size_t *count)
{
	int ret = 0;
#ifdef _KERNEL
	mutex_enter(&spa->spa_errlog_lock);
	ret = process_error_log(spa, spa->spa_errlog_scrub, uaddr, count);
	if (!ret && !spa->spa_scrub_finished)
		ret = process_error_log(spa, spa->spa_errlog_last, uaddr,
		    count);
	mutex_enter(&spa->spa_errlist_lock);
	if (!ret)
		ret = process_error_list(&spa->spa_errlist_scrub, uaddr,
		    count);
	if (!ret)
		ret = process_error_list(&spa->spa_errlist_last, uaddr,
		    count);
	mutex_exit(&spa->spa_errlist_lock);
	mutex_exit(&spa->spa_errlog_lock);
#endif
	return (ret);
}
int spa_get_errlog ( spa_t * spa , void * uaddr , size_t * count ) { int ret = 0 ; #ifdef _KERNEL mutex_enter ( & spa -> spa_errlog_lock ) ; ret = process_error_log ( spa , spa -> spa_errlog_scrub , uaddr , count ) ; if ( ! ret && ! spa -> spa_scrub_finished ) ret = process_error_log ( spa , spa -> spa_errlog_last , uaddr , count ) ; mutex_enter ( & spa -> spa_errlist_lock ) ; if ( ! ret ) ret = process_error_list ( & spa -> spa_errlist_scrub , uaddr , count ) ; if ( ! ret ) ret = process_error_list ( & spa -> spa_errlist_last , uaddr , count ) ; mutex_exit ( & spa -> spa_errlist_lock ) ; mutex_exit ( & spa -> spa_errlog_lock ) ; #endif return ( ret ) ; }
Copy all known errors to userland as an array of bookmarks.
Copy all known errors to userland as an array of bookmarks .