mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-23 02:44:41 +03:00
Add TXG timestamp database
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. Reviewed-by: Tony Hutter <hutter2@llnl.gov> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com> Reviewed-by: Paul Dagnelie <paul.dagnelie@klarasystems.com> Signed-off-by: Mariusz Zaborski <mariusz.zaborski@klarasystems.com> Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Closes #16853
This commit is contained in:
@@ -545,7 +545,8 @@ tests = ['zpool_scrub_001_neg', 'zpool_scrub_002_pos', 'zpool_scrub_003_pos',
|
||||
'zpool_scrub_offline_device', 'zpool_scrub_multiple_copies',
|
||||
'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_error_scrub_003_pos', 'zpool_error_scrub_004_pos',
|
||||
'zpool_scrub_date_range_001']
|
||||
tags = ['functional', 'cli_root', 'zpool_scrub']
|
||||
|
||||
[tests/functional/cli_root/zpool_set]
|
||||
|
||||
@@ -87,6 +87,7 @@ SPA_ASIZE_INFLATION spa.asize_inflation spa_asize_inflation
|
||||
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
|
||||
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
|
||||
|
||||
@@ -1244,6 +1244,7 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
|
||||
functional/cli_root/zpool_scrub/zpool_scrub_offline_device.ksh \
|
||||
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_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 \
|
||||
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
#!/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.
|
||||
# Copyright 2025 Mariusz Zaborski <oshogbo@FreeBSD.org>
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
. $STF_SUITE/tests/functional/cli_root/zpool_scrub/zpool_scrub.cfg
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Verify that the date range scrub only scrubs the files that were
|
||||
# created/modified within a given time slot.
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Write a file.
|
||||
# 2. Force a sync of everything via export/import.
|
||||
# 3. Wait for one minute.
|
||||
# 4. Repeat steps 1, 2, and 3 four two times.
|
||||
# 5. Inject checksum errors into all 3 files.
|
||||
# 6. Scrub the date range for the first file.
|
||||
# 7. Verify that the first file is scrubbed.
|
||||
# 8. Verify that newer files are not scrubbed.
|
||||
# 9. Repeat steps 6–8 for each of the remaining 2 files.
|
||||
#
|
||||
|
||||
verify_runnable "global"
|
||||
|
||||
function cleanup
|
||||
{
|
||||
log_must zinject -c all
|
||||
rm -f $TESTDIR/*_file
|
||||
log_must restore_tunable SPA_NOTE_TXG_TIME
|
||||
}
|
||||
|
||||
log_onexit cleanup
|
||||
|
||||
log_assert "Verifiy scrub, -E, and -S show expected status."
|
||||
|
||||
log_must save_tunable SPA_NOTE_TXG_TIME
|
||||
log_must set_tunable64 SPA_NOTE_TXG_TIME 30
|
||||
|
||||
typeset -a date_list
|
||||
for i in `seq 0 2`; do
|
||||
log_must sleep 60
|
||||
log_must zpool export $TESTPOOL
|
||||
log_must zpool import $TESTPOOL
|
||||
date_list+=("$(date '+%Y-%m-%d %H:%M')")
|
||||
|
||||
log_must file_write -o create -f"$TESTDIR/${i}_file" \
|
||||
-b 512 -c 2048 -dR
|
||||
|
||||
log_must sleep 60
|
||||
log_must zpool export $TESTPOOL
|
||||
log_must zpool import $TESTPOOL
|
||||
date_list+=("$(date '+%Y-%m-%d %H:%M')")
|
||||
done
|
||||
|
||||
for i in `seq 0 2`; do
|
||||
log_must zinject -t data -e checksum -f 100 $TESTDIR/${i}_file
|
||||
done
|
||||
|
||||
for i in `seq 0 2`; do
|
||||
log_must zpool scrub -w -S "${date_list[$((i * 2))]}" -E "${date_list[$((i * 2 + 1))]}" $TESTPOOL
|
||||
log_must eval "zpool status -v $TESTPOOL | grep '${i}_file'"
|
||||
for j in `seq 0 2`; do
|
||||
if [ $i == $j ]; then
|
||||
continue
|
||||
fi
|
||||
log_mustnot eval "zpool status -v $TESTPOOL | grep '${j}_file'"
|
||||
done
|
||||
done
|
||||
|
||||
log_pass "Verified scrub, -E, and -S show expected status."
|
||||
Reference in New Issue
Block a user