mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 10:37:35 +03:00
Add ability to scrub from last scrubbed txg
Some users might want to scrub only new data because they would like to know if the new write wasn't corrupted. This PR adds possibility scrub only newly written data. This introduces new `last_scrubbed_txg` property, indicating the transaction group (TXG) up to which the most recent scrub operation has checked and repaired the dataset, so users can run scrub only from the last saved point. We use a scn_max_txg and scn_min_txg which are already built into scrub, to accomplish that. Reviewed-by: Allan Jude <allan@klarasystems.com> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Mariusz Zaborski <mariusz.zaborski@klarasystems.com> Sponsored-By: Wasabi Technology, Inc. Sponsored-By: Klara Inc. Closes #16301
This commit is contained in:
@@ -1225,6 +1225,7 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
|
||||
functional/cli_root/zpool_scrub/zpool_scrub_multiple_copies.ksh \
|
||||
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_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 \
|
||||
|
||||
@@ -63,6 +63,7 @@ typeset -a properties=(
|
||||
"bcloneused"
|
||||
"bclonesaved"
|
||||
"bcloneratio"
|
||||
"last_scrubbed_txg"
|
||||
"feature@async_destroy"
|
||||
"feature@empty_bpobj"
|
||||
"feature@lz4_compress"
|
||||
|
||||
Executable
+104
@@ -0,0 +1,104 @@
|
||||
#!/bin/ksh -p
|
||||
#
|
||||
# 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 (c) 2023, Klara Inc.
|
||||
#
|
||||
# This software was developed by
|
||||
# Mariusz Zaborski <mariusz.zaborski@klarasystems.com>
|
||||
# under sponsorship from Wasabi Technology, Inc. and Klara Inc.
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
. $STF_SUITE/tests/functional/cli_root/zpool_scrub/zpool_scrub.cfg
|
||||
. $STF_SUITE/tests/functional/cli_root/zpool_import/zpool_import.kshlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Verify scrub -C
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Create a pool and create one file.
|
||||
# 2. Verify that the last_txg_scrub is 0.
|
||||
# 3. Run scrub.
|
||||
# 4. Verify that the last_txg_scrub is set.
|
||||
# 5. Create second file.
|
||||
# 6. Invalidate both files.
|
||||
# 7. Run scrub only from last point.
|
||||
# 8. Verify that only one file, that was created with newer txg,
|
||||
# was detected.
|
||||
#
|
||||
|
||||
verify_runnable "global"
|
||||
|
||||
function cleanup
|
||||
{
|
||||
log_must zinject -c all
|
||||
log_must rm -f $mntpnt/f1
|
||||
log_must rm -f $mntpnt/f2
|
||||
}
|
||||
|
||||
log_onexit cleanup
|
||||
|
||||
log_assert "Verify scrub -C."
|
||||
|
||||
# Create one file.
|
||||
mntpnt=$(get_prop mountpoint $TESTPOOL/$TESTFS)
|
||||
|
||||
log_must file_write -b 1048576 -c 10 -o create -d 0 -f $mntpnt/f1
|
||||
log_must sync_pool $TESTPOOL true
|
||||
f1txg=$(get_last_txg_synced $TESTPOOL)
|
||||
|
||||
# Verify that last_scrubbed_txg isn't set.
|
||||
zpoollasttxg=$(zpool get -H -o value last_scrubbed_txg $TESTPOOL)
|
||||
log_must [ $zpoollasttxg -eq 0 ]
|
||||
|
||||
# Run scrub.
|
||||
log_must zpool scrub -w $TESTPOOL
|
||||
|
||||
# Verify that last_scrubbed_txg is set.
|
||||
zpoollasttxg=$(zpool get -H -o value last_scrubbed_txg $TESTPOOL)
|
||||
log_must [ $zpoollasttxg -ne 0 ]
|
||||
|
||||
# Create second file.
|
||||
log_must file_write -b 1048576 -c 10 -o create -d 0 -f $mntpnt/f2
|
||||
log_must sync_pool $TESTPOOL true
|
||||
f2txg=$(get_last_txg_synced $TESTPOOL)
|
||||
|
||||
# Make sure that the sync txg are different.
|
||||
log_must [ $f1txg -ne $f2txg ]
|
||||
|
||||
# Insert faults.
|
||||
log_must zinject -a -t data -e io -T read $mntpnt/f1
|
||||
log_must zinject -a -t data -e io -T read $mntpnt/f2
|
||||
|
||||
# Run scrub from last saved point.
|
||||
log_must zpool scrub -w -C $TESTPOOL
|
||||
|
||||
# Verify that only newer file was detected.
|
||||
log_mustnot eval "zpool status -v $TESTPOOL | grep '$mntpnt/f1'"
|
||||
log_must eval "zpool status -v $TESTPOOL | grep '$mntpnt/f2'"
|
||||
|
||||
# Verify that both files are corrupted.
|
||||
log_must zpool scrub -w $TESTPOOL
|
||||
log_must eval "zpool status -v $TESTPOOL | grep '$mntpnt/f1'"
|
||||
log_must eval "zpool status -v $TESTPOOL | grep '$mntpnt/f2'"
|
||||
|
||||
log_pass "Verified scrub -C show expected status."
|
||||
Reference in New Issue
Block a user