From 7ec0e858760d91bfffce6fbbabd81e7df9c74333 Mon Sep 17 00:00:00 2001 From: tarick Date: Sat, 13 Sep 2025 12:25:55 +0200 Subject: [PATCH 1/2] Update zpool-attach.8 Fixes bug report #17734 Signed-off-by: trick2011 --- man/man8/zpool-attach.8 | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/man/man8/zpool-attach.8 b/man/man8/zpool-attach.8 index f120350a5190..04996ed4fa11 100644 --- a/man/man8/zpool-attach.8 +++ b/man/man8/zpool-attach.8 @@ -39,24 +39,24 @@ .Cm attach .Op Fl fsw .Oo Fl o Ar property Ns = Ns Ar value Oc -.Ar pool device new_device +.Ar pool vdev new_device . .Sh DESCRIPTION Attaches .Ar new_device to the existing -.Ar device . +.Ar vdev . The behavior differs depending on if the existing -.Ar device +.Ar vdev is a RAID-Z device, or a mirror/plain device. .Pp -If the existing device is a mirror or plain device +If the existing vdev is a mirror or plain device .Pq e.g. specified as Qo Li sda Qc or Qq Li mirror-7 , -the new device will be mirrored with the existing device, a resilver will be +the new device will be mirrored with the existing vdev, a resilver will be initiated, and the new device will contribute to additional redundancy once the resilver completes. If -.Ar device +.Ar vdev is not currently part of a mirrored configuration, .Ar device automatically transforms into a two-way mirror of @@ -64,7 +64,7 @@ automatically transforms into a two-way mirror of and .Ar new_device . If -.Ar device +.Ar vdev is part of a two-way mirror, attaching .Ar new_device creates a three-way mirror, and so on. @@ -72,7 +72,7 @@ In either case, .Ar new_device begins to resilver immediately and any running scrub is canceled. .Pp -If the existing device is a RAID-Z device +If the existing vdev is a RAID-Z device .Pq e.g. specified as Qq Ar raidz2-0 , the new device will become part of that RAID-Z group. A "raidz expansion" will be initiated, and once the expansion completes, @@ -112,7 +112,7 @@ the checksums of all blocks which have been copied during the expansion. Forces use of .Ar new_device , even if it appears to be in use. -Not all devices can be overridden in this manner. +Not all vdevs can be overridden in this manner. .It Fl o Ar property Ns = Ns Ar value Sets the given pool properties. See the @@ -121,7 +121,7 @@ manual page for a list of valid properties that can be set. The only property supported at the moment is .Sy ashift . .It Fl s -When attaching to a mirror or plain device, the +When attaching to a mirror or plain vdev, the .Ar new_device is reconstructed sequentially to restore redundancy as quickly as possible. Checksums are not verified during sequential reconstruction so a scrub is From d37e966938a9cbc33ba19ea4f4d1fe5a2f45214e Mon Sep 17 00:00:00 2001 From: Paul Dagnelie Date: Fri, 12 Sep 2025 16:33:36 -0700 Subject: [PATCH 2/2] 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 Reviewed-by: Alexander Motin Signed-off-by: Paul Dagnelie Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Closes #17735 --- module/zfs/zfs_crrd.c | 4 +- tests/runfiles/common.run | 2 +- tests/zfs-tests/include/tunables.cfg | 1 + tests/zfs-tests/tests/Makefile.am | 1 + .../zpool_scrub_date_range_002.ksh | 76 +++++++++++++++++++ 5 files changed, 81 insertions(+), 3 deletions(-) create mode 100755 tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub_date_range_002.ksh diff --git a/module/zfs/zfs_crrd.c b/module/zfs/zfs_crrd.c index e5783b7b8a82..30d4c7c36897 100644 --- a/module/zfs/zfs_crrd.c +++ b/module/zfs/zfs_crrd.c @@ -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); diff --git a/tests/runfiles/common.run b/tests/runfiles/common.run index bae9c0f35946..4dd700ef361c 100644 --- a/tests/runfiles/common.run +++ b/tests/runfiles/common.run @@ -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] diff --git a/tests/zfs-tests/include/tunables.cfg b/tests/zfs-tests/include/tunables.cfg index b8d72f391bd5..54b50c9dba77 100644 --- a/tests/zfs-tests/include/tunables.cfg +++ b/tests/zfs-tests/include/tunables.cfg @@ -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 diff --git a/tests/zfs-tests/tests/Makefile.am b/tests/zfs-tests/tests/Makefile.am index 32fe351f6dd7..1517f90e99a5 100644 --- a/tests/zfs-tests/tests/Makefile.am +++ b/tests/zfs-tests/tests/Makefile.am @@ -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 \ diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub_date_range_002.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub_date_range_002.ksh new file mode 100755 index 000000000000..9327df81a5c5 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub_date_range_002.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."