mirror of
				https://git.proxmox.com/git/mirror_zfs.git
				synced 2025-10-26 18:05:04 +03:00 
			
		
		
		
	 6fc3099248
			
		
	
	
		6fc3099248
		
	
	
	
	
		
			
			Before, make shellcheck checked
  scripts/{commitcheck,make_gitrev,man-dates,paxcheck,zfs-helpers,zfs,
           zfs-tests,zimport,zloop}.sh
  cmd/zed/zed.d/{{all-debug,all-syslog,data-notify,generic-notify,
                 resilver_finish-start-scrub,scrub_finish-notify,
                 statechange-led,statechange-notify,trim_finish-notify,
                 zed-functions}.sh,history_event-zfs-list-cacher.sh.in}
  cmd/zpool/zpool.d/{dm-deps,iostat,lsblk,media,ses,smart,upath}
now it also checks
  contrib/dracut/{02zfsexpandknowledge/module-setup,
                  90zfs/{export-zfs,parse-zfs,zfs-needshutdown,
                         zfs-load-key,zfs-lib,module-setup,
                         mount-zfs,zfs-generator}}.sh.in
  cmd/zed/zed.d/{pool_import-led,vdev_attach-led,
                 resilver_finish-notify,vdev_clear-led}.sh
  contrib/initramfs/{zfsunlock,hooks/zfs.in,scripts/local-top/zfs}
  tests/zfs-tests/tests/perf/scripts/prefetch_io.sh
  scripts/common.sh.in
  contrib/bpftrace/zfs-trace.sh
  autogen.sh
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12042
		
	
			
		
			
				
	
	
		
			114 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			114 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
| #!/bin/sh
 | |
| 
 | |
| count_zvols() {
 | |
| 	if [ -z "$zvols" ]; then
 | |
| 		echo 0
 | |
| 	else
 | |
| 		echo "$zvols" | wc -l
 | |
| 	fi
 | |
| }
 | |
| 
 | |
| filter_out_zvols_with_links() {
 | |
| 	echo "$zvols" | tr ' ' '+' | while read -r zvol; do
 | |
| 		if ! [ -L "/dev/zvol/$zvol" ]; then
 | |
| 			echo "$zvol"
 | |
| 		fi
 | |
| 	done | tr '+' ' '
 | |
| }
 | |
| 
 | |
| filter_out_deleted_zvols() {
 | |
| 	OIFS="$IFS"
 | |
| 	IFS="
 | |
| "
 | |
| 	# shellcheck disable=SC2086
 | |
| 	zfs list -H -o name $zvols 2>/dev/null
 | |
| 	IFS="$OIFS"
 | |
| }
 | |
| 
 | |
| list_zvols() {
 | |
| 	read -r default_volmode < /sys/module/zfs/parameters/zvol_volmode
 | |
| 	zfs list -t volume -H -o \
 | |
| 	    name,volmode,receive_resume_token,redact_snaps |
 | |
| 	    while IFS="	" read -r name volmode token redacted; do # IFS=\t here!
 | |
| 
 | |
| 		# /dev links are not created for zvols with volmode = "none"
 | |
| 		# or for redacted zvols.
 | |
| 		[ "$volmode" = "none" ] && continue
 | |
| 		[ "$volmode" = "default" ] && [ "$default_volmode" = "3" ] &&
 | |
| 		    continue
 | |
| 		[ "$redacted" = "-" ] || continue
 | |
| 
 | |
| 		# We also ignore partially received zvols if it is
 | |
| 		# not an incremental receive, as those won't even have a block
 | |
| 		# device minor node created yet.
 | |
| 		if [ "$token" != "-" ]; then
 | |
| 
 | |
| 			# Incremental receives create an invisible clone that
 | |
| 			# is not automatically displayed by zfs list.
 | |
| 			if ! zfs list "$name/%recv" >/dev/null 2>&1; then
 | |
| 				continue
 | |
| 			fi
 | |
| 		fi
 | |
| 		echo "$name"
 | |
| 	done
 | |
| }
 | |
| 
 | |
| zvols=$(list_zvols)
 | |
| zvols_count=$(count_zvols)
 | |
| if [ "$zvols_count" -eq 0 ]; then
 | |
| 	echo "No zvols found, nothing to do."
 | |
| 	exit 0
 | |
| fi
 | |
| 
 | |
| echo "Testing $zvols_count zvol links"
 | |
| 
 | |
| outer_loop=0
 | |
| while [ "$outer_loop" -lt 20 ]; do
 | |
| 	outer_loop=$((outer_loop + 1))
 | |
| 
 | |
| 	old_zvols_count=$(count_zvols)
 | |
| 
 | |
| 	inner_loop=0
 | |
| 	while [ "$inner_loop" -lt 30 ]; do
 | |
| 		inner_loop=$((inner_loop + 1))
 | |
| 
 | |
| 		zvols="$(filter_out_zvols_with_links)"
 | |
| 
 | |
| 		zvols_count=$(count_zvols)
 | |
| 		if [ "$zvols_count" -eq 0 ]; then
 | |
| 			echo "All zvol links are now present."
 | |
| 			exit 0
 | |
| 		fi
 | |
| 		sleep 1
 | |
| 	done
 | |
| 
 | |
| 	echo "Still waiting on $zvols_count zvol links ..."
 | |
| 	#
 | |
| 	# Although zvols should normally not be deleted at boot time,
 | |
| 	# if that is the case then their links will be missing and
 | |
| 	# we would stall.
 | |
| 	#
 | |
| 	if [ "$old_zvols_count" -eq "$zvols_count" ]; then
 | |
| 		echo "No progress since last loop."
 | |
| 		echo "Checking if any zvols were deleted."
 | |
| 
 | |
| 		zvols=$(filter_out_deleted_zvols)
 | |
| 		zvols_count=$(count_zvols)
 | |
| 
 | |
| 		if [ "$old_zvols_count" -ne "$zvols_count" ]; then
 | |
| 			echo "$((old_zvols_count - zvols_count)) zvol(s) deleted."
 | |
| 		fi
 | |
| 
 | |
| 		if [ "$zvols_count" -ne 0 ]; then
 | |
| 			echo "Remaining zvols:"
 | |
| 			echo "$zvols"
 | |
| 		else
 | |
| 			echo "All zvol links are now present."
 | |
| 			exit 0
 | |
| 		fi
 | |
| 	fi
 | |
| done
 | |
| 
 | |
| echo "Timed out waiting on zvol links"
 | |
| exit 1
 |