mirror of
				https://git.proxmox.com/git/mirror_zfs.git
				synced 2025-10-26 18:05:04 +03:00 
			
		
		
		
	scrub: generate scrub_finish event
The `scn_min_txg` can now be used not only with resilver. Instead of checking `scn_min_txg` to determine whether it’s a resilver or a scrub, simply check which function is defined. Thanks to this change, a scrub_finish event is generated when performing a scrub from the saved txg. Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Reviewed-by: Alexander Motin <mav@FreeBSD.org> Signed-off-by: Mariusz Zaborski <mariusz.zaborski@klarasystems.com> Closes #17432
This commit is contained in:
		
							parent
							
								
									af7d609592
								
							
						
					
					
						commit
						46b82de618
					
				| @ -235,6 +235,9 @@ static uint_t zfs_resilver_defer_percent = 10; | |||||||
| #define	DSL_SCAN_IS_SCRUB(scn)		\ | #define	DSL_SCAN_IS_SCRUB(scn)		\ | ||||||
| 	((scn)->scn_phys.scn_func == POOL_SCAN_SCRUB) | 	((scn)->scn_phys.scn_func == POOL_SCAN_SCRUB) | ||||||
| 
 | 
 | ||||||
|  | #define	DSL_SCAN_IS_RESILVER(scn) \ | ||||||
|  | 	((scn)->scn_phys.scn_func == POOL_SCAN_RESILVER) | ||||||
|  | 
 | ||||||
| /*
 | /*
 | ||||||
|  * Enable/disable the processing of the free_bpobj object. |  * Enable/disable the processing of the free_bpobj object. | ||||||
|  */ |  */ | ||||||
| @ -1169,7 +1172,7 @@ dsl_scan_done(dsl_scan_t *scn, boolean_t complete, dmu_tx_t *tx) | |||||||
| 			vdev_dtl_reassess(spa->spa_root_vdev, tx->tx_txg, | 			vdev_dtl_reassess(spa->spa_root_vdev, tx->tx_txg, | ||||||
| 			    scn->scn_phys.scn_max_txg, B_TRUE, B_FALSE); | 			    scn->scn_phys.scn_max_txg, B_TRUE, B_FALSE); | ||||||
| 
 | 
 | ||||||
| 			if (scn->scn_phys.scn_min_txg) { | 			if (DSL_SCAN_IS_RESILVER(scn)) { | ||||||
| 				nvlist_t *aux = fnvlist_alloc(); | 				nvlist_t *aux = fnvlist_alloc(); | ||||||
| 				fnvlist_add_string(aux, ZFS_EV_RESILVER_TYPE, | 				fnvlist_add_string(aux, ZFS_EV_RESILVER_TYPE, | ||||||
| 				    "healing"); | 				    "healing"); | ||||||
|  | |||||||
| @ -1091,6 +1091,7 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \ | |||||||
| 	functional/cli_root/zpool_events/zpool_events_errors.ksh \
 | 	functional/cli_root/zpool_events/zpool_events_errors.ksh \
 | ||||||
| 	functional/cli_root/zpool_events/zpool_events_follow.ksh \
 | 	functional/cli_root/zpool_events/zpool_events_follow.ksh \
 | ||||||
| 	functional/cli_root/zpool_events/zpool_events_poolname.ksh \
 | 	functional/cli_root/zpool_events/zpool_events_poolname.ksh \
 | ||||||
|  | 	functional/cli_root/zpool_events/zpool_events_scrub_txg_continue_from_last.ksh \
 | ||||||
| 	functional/cli_root/zpool_expand/cleanup.ksh \
 | 	functional/cli_root/zpool_expand/cleanup.ksh \
 | ||||||
| 	functional/cli_root/zpool_expand/setup.ksh \
 | 	functional/cli_root/zpool_expand/setup.ksh \
 | ||||||
| 	functional/cli_root/zpool_expand/zpool_expand_001_pos.ksh \
 | 	functional/cli_root/zpool_expand/zpool_expand_001_pos.ksh \
 | ||||||
|  | |||||||
| @ -0,0 +1,71 @@ | |||||||
|  | #!/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 (c) 2025, Klara Inc. | ||||||
|  | # | ||||||
|  | # This software was developed by | ||||||
|  | # Mariusz Zaborski <oshogbo@FreeBSD.org> | ||||||
|  | # under sponsorship from Wasabi Technology, Inc. and Klara Inc. | ||||||
|  | 
 | ||||||
|  | . $STF_SUITE/include/libtest.shlib | ||||||
|  | . $STF_SUITE/tests/functional/cli_root/zpool_events/zpool_events.kshlib | ||||||
|  | 
 | ||||||
|  | # | ||||||
|  | # DESCRIPTION: | ||||||
|  | #      Verify that using “zpool scrub -C” correctly generates events. | ||||||
|  | # | ||||||
|  | # STRATEGY: | ||||||
|  | #      1. Run an initial “zpool scrub” on the test pool to generate a txg. | ||||||
|  | #      2. Clear existing pool events. | ||||||
|  | #      3. Run “zpool scrub -C” to scrub from the last txg. | ||||||
|  | #      4. Capture the event log and confirm it contains both “scrub_start” and | ||||||
|  | #         “scrub_finish” entries. | ||||||
|  | # | ||||||
|  | 
 | ||||||
|  | verify_runnable "global" | ||||||
|  | 
 | ||||||
|  | function cleanup | ||||||
|  | { | ||||||
|  | 	rm -f $EVENTS_FILE | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | EVENTS_FILE="$TESTDIR/zpool_events.$$" | ||||||
|  | log_onexit cleanup | ||||||
|  | 
 | ||||||
|  | log_assert "Verify scrub -C events." | ||||||
|  | 
 | ||||||
|  | # Run an initial “zpool scrub” | ||||||
|  | log_must zpool scrub -w $TESTPOOL | ||||||
|  | 
 | ||||||
|  | # Clear existing pool events. | ||||||
|  | log_must zpool events -c | ||||||
|  | 
 | ||||||
|  | # Generate new scrub events. | ||||||
|  | log_must zpool scrub -Cw $TESTPOOL | ||||||
|  | 
 | ||||||
|  | # Verify events. | ||||||
|  | log_must eval "zpool events -H > $EVENTS_FILE" | ||||||
|  | log_must grep "scrub_start" $EVENTS_FILE | ||||||
|  | log_must grep "scrub_finish" $EVENTS_FILE | ||||||
|  | 
 | ||||||
|  | log_pass "Verified scrub -C generate correct events." | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Mariusz Zaborski
						Mariusz Zaborski