Changeset View
Changeset View
Standalone View
Standalone View
sys/contrib/openzfs/module/zfs/spa_history.c
Show First 20 Lines • Show All 282 Lines • ▼ Show 20 Lines | |||||
#ifdef ZFS_DEBUG | #ifdef ZFS_DEBUG | ||||
{ | { | ||||
dmu_object_info_t doi; | dmu_object_info_t doi; | ||||
dmu_object_info_from_db(dbp, &doi); | dmu_object_info_from_db(dbp, &doi); | ||||
ASSERT3U(doi.doi_bonus_type, ==, DMU_OT_SPA_HISTORY_OFFSETS); | ASSERT3U(doi.doi_bonus_type, ==, DMU_OT_SPA_HISTORY_OFFSETS); | ||||
} | } | ||||
#endif | #endif | ||||
fnvlist_add_uint64(nvl, ZPOOL_HIST_TIME, gethrestime_sec()); | |||||
fnvlist_add_string(nvl, ZPOOL_HIST_HOST, utsname()->nodename); | fnvlist_add_string(nvl, ZPOOL_HIST_HOST, utsname()->nodename); | ||||
if (nvlist_exists(nvl, ZPOOL_HIST_CMD)) { | if (nvlist_exists(nvl, ZPOOL_HIST_CMD)) { | ||||
zfs_dbgmsg("command: %s", | zfs_dbgmsg("command: %s", | ||||
fnvlist_lookup_string(nvl, ZPOOL_HIST_CMD)); | fnvlist_lookup_string(nvl, ZPOOL_HIST_CMD)); | ||||
} else if (nvlist_exists(nvl, ZPOOL_HIST_INT_NAME)) { | } else if (nvlist_exists(nvl, ZPOOL_HIST_INT_NAME)) { | ||||
if (nvlist_exists(nvl, ZPOOL_HIST_DSNAME)) { | if (nvlist_exists(nvl, ZPOOL_HIST_DSNAME)) { | ||||
zfs_dbgmsg("txg %lld %s %s (id %llu) %s", | zfs_dbgmsg("txg %lld %s %s (id %llu) %s", | ||||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | spa_history_log_nvl(spa_t *spa, nvlist_t *nvl) | ||||
VERIFY0(nvlist_dup(nvl, &nvarg, KM_SLEEP)); | VERIFY0(nvlist_dup(nvl, &nvarg, KM_SLEEP)); | ||||
if (spa_history_zone() != NULL) { | if (spa_history_zone() != NULL) { | ||||
fnvlist_add_string(nvarg, ZPOOL_HIST_ZONE, | fnvlist_add_string(nvarg, ZPOOL_HIST_ZONE, | ||||
spa_history_zone()); | spa_history_zone()); | ||||
} | } | ||||
fnvlist_add_uint64(nvarg, ZPOOL_HIST_WHO, crgetruid(CRED())); | fnvlist_add_uint64(nvarg, ZPOOL_HIST_WHO, crgetruid(CRED())); | ||||
/* | |||||
* Since the history is recorded asynchronously, the effective time is | |||||
* now, which may be considerably before the change is made on disk. | |||||
*/ | |||||
fnvlist_add_uint64(nvarg, ZPOOL_HIST_TIME, gethrestime_sec()); | |||||
/* Kick this off asynchronously; errors are ignored. */ | /* Kick this off asynchronously; errors are ignored. */ | ||||
dsl_sync_task_nowait(spa_get_dsl(spa), spa_history_log_sync, nvarg, tx); | dsl_sync_task_nowait(spa_get_dsl(spa), spa_history_log_sync, nvarg, tx); | ||||
dmu_tx_commit(tx); | dmu_tx_commit(tx); | ||||
/* spa_history_log_sync will free nvl */ | /* spa_history_log_sync will free nvl */ | ||||
return (err); | return (err); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 114 Lines • ▼ Show 20 Lines | log_internal(nvlist_t *nvl, const char *operation, spa_t *spa, | ||||
} | } | ||||
msg = kmem_vasprintf(fmt, adx); | msg = kmem_vasprintf(fmt, adx); | ||||
fnvlist_add_string(nvl, ZPOOL_HIST_INT_STR, msg); | fnvlist_add_string(nvl, ZPOOL_HIST_INT_STR, msg); | ||||
kmem_strfree(msg); | kmem_strfree(msg); | ||||
fnvlist_add_string(nvl, ZPOOL_HIST_INT_NAME, operation); | fnvlist_add_string(nvl, ZPOOL_HIST_INT_NAME, operation); | ||||
fnvlist_add_uint64(nvl, ZPOOL_HIST_TXG, tx->tx_txg); | fnvlist_add_uint64(nvl, ZPOOL_HIST_TXG, tx->tx_txg); | ||||
fnvlist_add_uint64(nvl, ZPOOL_HIST_TIME, gethrestime_sec()); | |||||
if (dmu_tx_is_syncing(tx)) { | if (dmu_tx_is_syncing(tx)) { | ||||
spa_history_log_sync(nvl, tx); | spa_history_log_sync(nvl, tx); | ||||
} else { | } else { | ||||
dsl_sync_task_nowait(spa_get_dsl(spa), | dsl_sync_task_nowait(spa_get_dsl(spa), | ||||
spa_history_log_sync, nvl, tx); | spa_history_log_sync, nvl, tx); | ||||
} | } | ||||
/* spa_history_log_sync() will free nvl */ | /* spa_history_log_sync() will free nvl */ | ||||
▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines |