mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-01-15 01:32:04 +03:00
Fix time database update calculations
The time database update math assumed that the timestamps were in
nanoseconds, but at some point in the development or review process they
changed to seconds. This PR fixes the math to use seconds instead.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com>
Signed-off-by: Paul Dagnelie <paul.dagnelie@klarasystems.com>
Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Closes #17735
This commit is contained in:
parent
c9de42e089
commit
cac483dbd4
@ -162,9 +162,9 @@ dbrrd_add(dbrrd_t *db, hrtime_t time, uint64_t txg)
|
||||
daydiff = time - rrd_tail(&db->dbr_days);
|
||||
monthdiff = time - rrd_tail(&db->dbr_months);
|
||||
|
||||
if (monthdiff >= 0 && monthdiff >= SEC2NSEC(30 * 24 * 60 * 60))
|
||||
if (monthdiff >= 0 && monthdiff >= 30 * 24 * 60 * 60)
|
||||
rrd_add(&db->dbr_months, time, txg);
|
||||
else if (daydiff >= 0 && daydiff >= SEC2NSEC(24 * 60 * 60))
|
||||
else if (daydiff >= 0 && daydiff >= 24 * 60 * 60)
|
||||
rrd_add(&db->dbr_days, time, txg);
|
||||
else if (minutedif >= 0)
|
||||
rrd_add(&db->dbr_minutes, time, txg);
|
||||
|
||||
@ -550,7 +550,7 @@ tests = ['zpool_scrub_001_neg', 'zpool_scrub_002_pos', 'zpool_scrub_003_pos',
|
||||
'zpool_scrub_multiple_pools',
|
||||
'zpool_error_scrub_001_pos', 'zpool_error_scrub_002_pos',
|
||||
'zpool_error_scrub_003_pos', 'zpool_error_scrub_004_pos',
|
||||
'zpool_scrub_date_range_001']
|
||||
'zpool_scrub_date_range_001', 'zpool_scrub_date_range_002']
|
||||
tags = ['functional', 'cli_root', 'zpool_scrub']
|
||||
|
||||
[tests/functional/cli_root/zpool_set]
|
||||
|
||||
@ -91,6 +91,7 @@ SPA_DISCARD_MEMORY_LIMIT spa.discard_memory_limit zfs_spa_discard_memory_limit
|
||||
SPA_LOAD_VERIFY_DATA spa.load_verify_data spa_load_verify_data
|
||||
SPA_LOAD_VERIFY_METADATA spa.load_verify_metadata spa_load_verify_metadata
|
||||
SPA_NOTE_TXG_TIME spa.note_txg_time spa_note_txg_time
|
||||
SPA_FLUSH_TXG_TIME spa.flush_txg_time spa_flush_txg_time
|
||||
TRIM_EXTENT_BYTES_MIN trim.extent_bytes_min zfs_trim_extent_bytes_min
|
||||
TRIM_METASLAB_SKIP trim.metaslab_skip zfs_trim_metaslab_skip
|
||||
TRIM_TXG_BATCH trim.txg_batch zfs_trim_txg_batch
|
||||
|
||||
@ -1251,6 +1251,7 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
|
||||
functional/cli_root/zpool_scrub/zpool_scrub_print_repairing.ksh \
|
||||
functional/cli_root/zpool_scrub/zpool_scrub_txg_continue_from_last.ksh \
|
||||
functional/cli_root/zpool_scrub/zpool_scrub_date_range_001.ksh \
|
||||
functional/cli_root/zpool_scrub/zpool_scrub_date_range_002.ksh \
|
||||
functional/cli_root/zpool_scrub/zpool_error_scrub_001_pos.ksh \
|
||||
functional/cli_root/zpool_scrub/zpool_error_scrub_002_pos.ksh \
|
||||
functional/cli_root/zpool_scrub/zpool_error_scrub_003_pos.ksh \
|
||||
|
||||
@ -0,0 +1,76 @@
|
||||
#!/bin/ksh -p
|
||||
# SPDX-License-Identifier: CDDL-1.0
|
||||
#
|
||||
# CDDL HEADER START
|
||||
#
|
||||
# The contents of this file are subject to the terms of the
|
||||
# Common Development and Distribution License (the "License").
|
||||
# You may not use this file except in compliance with the License.
|
||||
#
|
||||
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
||||
# or https://opensource.org/licenses/CDDL-1.0.
|
||||
# See the License for the specific language governing permissions
|
||||
# and limitations under the License.
|
||||
#
|
||||
# When distributing Covered Code, include this CDDL HEADER in each
|
||||
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
||||
# If applicable, add the following below this CDDL HEADER, with the
|
||||
# fields enclosed by brackets "[]" replaced with your own identifying
|
||||
# information: Portions Copyright [yyyy] [name of copyright owner]
|
||||
#
|
||||
# CDDL HEADER END
|
||||
#
|
||||
# Copyright 2025 Klara, Inc.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
. $STF_SUITE/tests/functional/cli_root/zpool_scrub/zpool_scrub.cfg
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Verify that the timestamp database updates all the tables as expected.
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Decrease the note and flush frequency of the txg database.
|
||||
# 2. Force the pool to sync several txgs
|
||||
# 3. Verify that there are entries in each of the "month", "day", and
|
||||
# "minute" tables.
|
||||
#
|
||||
|
||||
verify_runnable "global"
|
||||
|
||||
function cleanup
|
||||
{
|
||||
log_must restore_tunable SPA_NOTE_TXG_TIME
|
||||
log_must restore_tunable SPA_FLUSH_TXG_TIME
|
||||
rm /$TESTPOOL/f1
|
||||
}
|
||||
|
||||
log_onexit cleanup
|
||||
|
||||
log_assert "Verifiy timestamp databases all update as expected."
|
||||
|
||||
log_must save_tunable SPA_NOTE_TXG_TIME
|
||||
log_must set_tunable64 SPA_NOTE_TXG_TIME 1
|
||||
log_must save_tunable SPA_FLUSH_TXG_TIME
|
||||
log_must set_tunable64 SPA_FLUSH_TXG_TIME 1
|
||||
|
||||
log_must touch /$TESTPOOL/f1
|
||||
log_must zpool sync $TESTPOOL
|
||||
sleep 1
|
||||
log_must touch /$TESTPOOL/f1
|
||||
log_must zpool sync $TESTPOOL
|
||||
sleep 1
|
||||
log_must touch /$TESTPOOL/f1
|
||||
log_must zpool sync $TESTPOOL
|
||||
|
||||
mos_zap="$(zdb -dddd $TESTPOOL 1)"
|
||||
minutes_entries=$(echo "$mos_zap" | grep "txg_log_time:minutes" | awk '{print $5}')
|
||||
days_entries=$(echo "$mos_zap" | grep "txg_log_time:days" | awk '{print $5}')
|
||||
months_entries=$(echo "$mos_zap" | grep "txg_log_time:months" | awk '{print $5}')
|
||||
|
||||
[[ "$minutes_entries" -ne "0" ]] || log_fail "0 entries in the minutes table"
|
||||
[[ "$days_entries" -ne "0" ]] || log_fail "0 entries in the days table"
|
||||
[[ "$months_entries" -ne "0" ]] || log_fail "0 entries in the months table"
|
||||
|
||||
log_pass "Verified all timestamp databases had entries as expected."
|
||||
Loading…
Reference in New Issue
Block a user