Skip to content

Commit

Permalink
Add TXG timestamp database
Browse files Browse the repository at this point in the history
This feature enables tracking of when TXGs are committed to disk,
providing an estimated timestamp for each TXG.

With this information, it becomes possible to perform scrubs based
on specific date ranges, improving the granularity of
data management and recovery operations.

Signed-off-by: Mariusz Zaborski <[email protected]>
  • Loading branch information
oshogbo committed Jan 31, 2025
1 parent 756d7e4 commit d79f409
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
11 changes: 6 additions & 5 deletions lib/libzfs/libzfs.abi
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@
<elf-symbol name='fletcher_4_superscalar_ops' size='128' type='object-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
<elf-symbol name='libzfs_config_ops' size='16' type='object-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
<elf-symbol name='sa_protocol_names' size='16' type='object-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
<elf-symbol name='spa_feature_table' size='2464' type='object-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
<elf-symbol name='spa_feature_table' size='2520' type='object-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
<elf-symbol name='zfeature_checks_disable' size='4' type='object-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
<elf-symbol name='zfs_deleg_perm_tab' size='512' type='object-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
<elf-symbol name='zfs_history_event_names' size='328' type='object-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
Expand Down Expand Up @@ -6172,7 +6172,8 @@
<enumerator name='SPA_FEATURE_FAST_DEDUP' value='41'/>
<enumerator name='SPA_FEATURE_LONGNAME' value='42'/>
<enumerator name='SPA_FEATURE_LARGE_MICROZAP' value='43'/>
<enumerator name='SPA_FEATURES' value='44'/>
<enumerator name='SPA_FEATURE_TXG_TIMELOG' value='44'/>
<enumerator name='SPA_FEATURES' value='45'/>
</enum-decl>
<typedef-decl name='spa_feature_t' type-id='33ecb627' id='d6618c78'/>
<qualified-type-def type-id='80f4b756' const='yes' id='b99c00c9'/>
Expand Down Expand Up @@ -9358,8 +9359,8 @@
</function-decl>
</abi-instr>
<abi-instr address-size='64' path='module/zcommon/zfeature_common.c' language='LANG_C99'>
<array-type-def dimensions='1' type-id='83f29ca2' size-in-bits='19712' id='fd4573e5'>
<subrange length='44' type-id='7359adad' id='cf8ba455'/>
<array-type-def dimensions='1' type-id='83f29ca2' size-in-bits='20160' id='b948da70'>
<subrange length='45' type-id='7359adad' id='cb8ddca0'/>
</array-type-def>
<enum-decl name='zfeature_flags' id='6db816a4'>
<underlying-type type-id='9cac1fee'/>
Expand Down Expand Up @@ -9436,7 +9437,7 @@
<pointer-type-def type-id='611586a1' size-in-bits='64' id='2e243169'/>
<qualified-type-def type-id='eaa32e2f' const='yes' id='83be723c'/>
<pointer-type-def type-id='83be723c' size-in-bits='64' id='7acd98a2'/>
<var-decl name='spa_feature_table' type-id='fd4573e5' mangled-name='spa_feature_table' visibility='default' elf-symbol-id='spa_feature_table'/>
<var-decl name='spa_feature_table' type-id='b948da70' mangled-name='spa_feature_table' visibility='default' elf-symbol-id='spa_feature_table'/>
<var-decl name='zfeature_checks_disable' type-id='c19b74c3' mangled-name='zfeature_checks_disable' visibility='default' elf-symbol-id='zfeature_checks_disable'/>
<function-decl name='opendir' visibility='default' binding='global' size-in-bits='64'>
<parameter type-id='80f4b756'/>
Expand Down
14 changes: 9 additions & 5 deletions module/zfs/spa.c
Original file line number Diff line number Diff line change
Expand Up @@ -3357,15 +3357,16 @@ spa_rrd_write(spa_t *spa, dmu_tx_t *tx, rrd_t *rrd, const char *what,
}

static void
spa_sync_time_logger(spa_t *spa, dmu_tx_t *tx)
spa_sync_time_logger(spa_t *spa, uint64_t txg)
{
uint64_t curtime;
boolean_t insert;
dmu_tx_t *tx;

if (!spa_writeable(spa)) {
return;
}
if (tx->tx_txg == spa->spa_last_noted_txg) {
if (txg == spa->spa_last_noted_txg) {
return;
}
curtime = gethrestime_sec();
Expand All @@ -3374,10 +3375,10 @@ spa_sync_time_logger(spa_t *spa, dmu_tx_t *tx)
}

spa->spa_last_noted_txg_time = curtime;
spa->spa_last_noted_txg = tx->tx_txg;
spa->spa_last_noted_txg = txg;

mutex_enter(&spa->spa_txg_log_time_lock);
dbrrd_add(&spa->spa_txg_log_time, curtime, tx->tx_txg);
dbrrd_add(&spa->spa_txg_log_time, curtime, txg);

if (curtime < spa->spa_last_flush_txg_time + spa_flush_txg_time) {
goto out;
Expand All @@ -3387,12 +3388,14 @@ spa_sync_time_logger(spa_t *spa, dmu_tx_t *tx)
insert = (zap_contains(spa_meta_objset(spa), DMU_POOL_DIRECTORY_OBJECT,
DMU_POOL_TXG_LOG_TIME_MINUTES) == ENOENT);

tx = dmu_tx_create_assigned(spa_get_dsl(spa), txg);
VERIFY0(spa_rrd_write(spa, tx, &spa->spa_txg_log_time.dbr_minutes,
DMU_POOL_TXG_LOG_TIME_MINUTES, insert));
VERIFY0(spa_rrd_write(spa, tx, &spa->spa_txg_log_time.dbr_days,
DMU_POOL_TXG_LOG_TIME_DAYS, insert));
VERIFY0(spa_rrd_write(spa, tx, &spa->spa_txg_log_time.dbr_days,
DMU_POOL_TXG_LOG_TIME_MONTHS, insert));
dmu_tx_commit(tx);

out:
mutex_exit(&spa->spa_txg_log_time_lock);
Expand Down Expand Up @@ -10261,6 +10264,8 @@ spa_sync(spa_t *spa, uint64_t txg)
*/
brt_pending_apply(spa, txg);

spa_sync_time_logger(spa, txg);

/*
* Lock out configuration changes.
*/
Expand Down Expand Up @@ -10309,7 +10314,6 @@ spa_sync(spa_t *spa, uint64_t txg)
dmu_tx_t *tx = dmu_tx_create_assigned(dp, txg);

spa->spa_sync_starttime = gethrtime();
spa_sync_time_logger(spa, tx);

taskq_cancel_id(system_delay_taskq, spa->spa_deadman_tqid);
spa->spa_deadman_tqid = taskq_dispatch_delay(system_delay_taskq,
Expand Down

0 comments on commit d79f409

Please sign in to comment.