[Git][lvmteam/lvm2][main] 6 commits: filters: leave device_id_sysfs_dir only for device_id

Zdeněk Kabeláč (@zdenek.kabelac) <[email protected]>
Newsgroups gmane.linux.lvm.devel
Message-ID <651de251d9f3c_2aa528081199@gitlab-sidekiq-low-urgency-cpu-bound-v2-7dc44445b-8c6gg.mail>

Zdeněk Kabeláč pushed to branch main at LVM team / lvm2


Commits:
4edaa9fd by Zdenek Kabelac at 2023-10-04T22:03:56+02:00
filters: leave device_id_sysfs_dir only for device_id

Do not use filters for sysfs with device_id.

- - - - -
e72e130e by Zdenek Kabelac at 2023-10-04T22:05:22+02:00
tests: convert to heredoc string

Multi-line echo command are problemat across variety of bash version
and may have produce shorter results.
Convert to stable heredoc string with &#39;tab&#39; skipping &lt;&lt;- for better
formating.

- - - - -
e3adccb5 by Zdenek Kabelac at 2023-10-04T22:05:22+02:00
tests: retry removal

After umout we may race with system udevd rule - so
just retry once again after 1s sleep - that should be
enough - otherwise we would need some loop here...

- - - - -
470f1058 by Zdenek Kabelac at 2023-10-04T23:58:54+02:00
tests: better coredump lookup

Some bash version may have problem with contruct:
done &lt; &lt;(

Replace it with array reading.

- - - - -
b80404f2 by Zdenek Kabelac at 2023-10-04T23:58:54+02:00
tests: utils use read without slash mangling

Do not use backslash as escape character for path.

- - - - -
ede63b50 by Zdenek Kabelac at 2023-10-05T00:03:30+02:00
tests: more complex check for resize of reiserfs

Detection of how the command is supposed to behave actually depends on
the configure.h compilation and whether binary is compiled with
HAVE_BLKID_SUBLKS_FSINFO.

This makes it somewhat complicated in a way how to recognize which
behavior is expected.

Currently we can eventually recognize by checking error output
of some &#39;random&#39; lvresize command and see if the --fs checksize is
actually recognized and rejected.  If this changes - test needs
to be updated.

- - - - -


5 changed files:

- lib/commands/toolcontext.c
- test/lib/utils.sh
- test/shell/devicesfile-vpd-ids.sh
- test/shell/fsadm-renamed.sh
- test/shell/thin-foreign-dmeventd.sh


Changes:

=====================================
lib/commands/toolcontext.c
=====================================
@@ -1229,7 +1229,7 @@ static struct dev_filter *_init_filter_chain(struct cmd_context *cmd)
 	 * (currently not used for devs match to device id using syfs)
 	 */
 	if (find_config_tree_bool(cmd, devices_sysfs_scan_CFG, NULL)) {
-		if ((filters[nr_filt] = sysfs_filter_create(cmd->device_id_sysfs_dir ?: dm_sysfs_dir())))
+		if ((filters[nr_filt] = sysfs_filter_create(dm_sysfs_dir())))
 			nr_filt++;
 	}
 


=====================================
test/lib/utils.sh
=====================================
@@ -138,25 +138,29 @@ STACKTRACE() {
 		# Check for all cores newer then TESTNAME file
 		# Assume users keep prefix 'core'
 		# TODO: possibly better integrate with coredumpctl & systemd
-		while IFS= read -r i; do
+		local cores=()
+		local IFS=$IFS_NL
+		cores=( $(find . "$(dirname "$(sysctl -n kernel.core_pattern)")" \
+			"/var/lib/systemd/coredump/" -name 'core*' -newer TESTNAME 2>/dev/null || true ) )
+
+		for i in "${cores[@]-}"; do
 			bin=$(gdb -batch -c "$i" 2>&1 | grep "generated by" | \
 			sed -e "s,.*generated by \`\([^ ']*\).*,\1,") || continue
-			{
-				echo bt full
-				echo l
-				echo quit
-			} > gdb_commands.txt || rm -f gdb_commands.txt
+			cat > gdb_commands.txt <<- EOF || rm -f gdb_commands.txt
+				bt full
+				l
+				quit
+			EOF
 
 			if test ! -s gdb_commands.txt ; then
-				echo "Out of disk space, can't check coredump $i generated by $bin."
-				continue
+				echo "Out of disk space, cannot check coredump \"$i\" generated by \"$bin\"."
+				break
 			fi
 
 			echo "## Checking coredump: $i generated by $bin."
 			gdb -batch -c "$i" -x gdb_commands.txt "$(which "$bin")" 2>/dev/null | \
 			sed -e "s,^,## GDB:	," || continue
-		done < <(find . "$(dirname "$(sysctl -n kernel.core_pattern)")" \
-			"/var/lib/systemd/coredump/" -name 'core*' -newer TESTNAME 2>/dev/null || true)
+		done
 	fi
 
 	test -f SKIP_THIS_TEST && exit 200
@@ -281,7 +285,7 @@ prepare_test_vars() {
 
 	if test -n "$LVM_TEST_DEVICE_LIST"; then
 		local count=0
-		while read path; do
+		while read -r path; do
 			count=$((  count + 1 ))
 			eval "dev$count=\"$path\""
 		done < "$LVM_TEST_DEVICE_LIST"


=====================================
test/shell/devicesfile-vpd-ids.sh
=====================================
@@ -34,16 +34,18 @@ DEV1_NAA3=naa.553b13644430344b4e3f486d32647962
 create_base() {
 	mkdir -p "$SYS_DIR/dev/block"
 
-	echo -n "0083 009c 0201 0020 4c56 4d54 5354 2020 \
-	204c 554e 2038 3039 7741 4c56 4d54 5354 \
-	6f20 2020 2020 2020 0103 0010 600a 0980 \
-	3830 3877 413f 4e70 4959 2e6e 0102 0010 \
-	3f4e 7049 592d 6f00 00a0 9737 3038 7741 \
-	0113 0010 600a 0980 0000 0002 ac18 5424 \
-	0000 0dbd 0114 0004 0101 0005 0115 0004 \
-	0000 03ec 0328 0028 6e61 612e 3535 3342 \
-	3133 3634 3434 3330 3334 3442 3445 3346 \
-	3438 3644 3332 3634 3739 3632 0000 0000" | xxd -r -p > "$SYS_DIR/dev1_vpd_pg83"
+	xxd -r -p > "$SYS_DIR/dev1_vpd_pg83" <<- EOF
+	0083 009c 0201 0020 4c56 4d54 5354 2020
+	204c 554e 2038 3039 7741 4c56 4d54 5354
+	6f20 2020 2020 2020 0103 0010 600a 0980
+	3830 3877 413f 4e70 4959 2e6e 0102 0010
+	3f4e 7049 592d 6f00 00a0 9737 3038 7741
+	0113 0010 600a 0980 0000 0002 ac18 5424
+	0000 0dbd 0114 0004 0101 0005 0115 0004
+	0000 03ec 0328 0028 6e61 612e 3535 3342
+	3133 3634 3434 3330 3334 3442 3445 3346
+	3438 3644 3332 3634 3739 3632 0000 0000
+	EOF
 }
 
 remove_base() {
@@ -246,11 +248,13 @@ cleanup_sysfs
 rm "$DF"
 aux wipefs_a "$DEV1"
 mkdir -p "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device"
-echo -n "7431 302e 4154 4120 2020 2020 5642 4f58 \
-2048 4152 4444 4953 4b20 2020 2020 2020 \
-2020 2020 2020 2020 2020 2020 2020 2020 \
-2020 2020 5642 3963 3130 6433 3138 2d31 \
-3838 6439 6562 6320 0a" | xxd -r -p > "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
+xxd -r -p > "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid" <<- EOF
+	431 302e 4154 4120 2020 2020 5642 4f58
+	048 4152 4444 4953 4b20 2020 2020 2020
+	020 2020 2020 2020 2020 2020 2020 2020
+	020 2020 5642 3963 3130 6433 3138 2d31
+	838 6439 6562 6320 0a
+EOF
 cat "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
 lvmdevices --adddev "$DEV1"
 cat "$DF"
@@ -271,11 +275,13 @@ cleanup_sysfs
 rm "$DF"
 aux wipefs_a "$DEV1"
 mkdir -p "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device"
-echo -n "7431 302e 4154 4120 2020 2020 5642 4f58 \
-2048 4152 4444 4953 4b20 2020 2020 2020 \
-2020 2020 2020 2020 2020 2020 2020 2020 \
-2020 2020 5642 3963 3130 6433 3138 2d31 \
-3838 6439 6562 6320 0a" | xxd -r -p > "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
+xxd -r -p > "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid" <<- EOF
+	431 302e 4154 4120 2020 2020 5642 4f58
+	048 4152 4444 4953 4b20 2020 2020 2020
+	020 2020 2020 2020 2020 2020 2020 2020
+	020 2020 5642 3963 3130 6433 3138 2d31
+	838 6439 6562 6320 0a
+EOF
 cat "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
 lvmdevices --adddev "$DEV1"
 cat "$DF"
@@ -318,11 +324,13 @@ cleanup_sysfs
 rm "$DF"
 aux wipefs_a "$DEV1"
 mkdir -p "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device"
-echo -n "7431 302e 4154 4120 2020 2020 5642 4f58 \
-2048 4152 4444 4953 4b20 2020 2020 2020 \
-2020 2020 2020 2020 2020 2020 2020 2020 \
-2020 2020 5642 3963 3130 6433 3138 2d31 \
-3838 6439 6562 5f20 0a" | xxd -r -p > "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
+xxd -r -p > "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid" <<- EOF
+	431 302e 4154 4120 2020 2020 5642 4f58
+	048 4152 4444 4953 4b20 2020 2020 2020
+	020 2020 2020 2020 2020 2020 2020 2020
+	020 2020 5642 3963 3130 6433 3138 2d31
+	838 6439 6562 5f20 0a
+EOF
 cat "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
 # The wwid has an actual underscore char (5f) followed by a space char (20)
 # 9.1 converts the trailing space to an underscore


=====================================
test/shell/fsadm-renamed.sh
=====================================
@@ -77,8 +77,8 @@ echo "$i"
 # Adding couple udev wait ops as some older systemd
 # might get confused and was 'randomly/racy' umounting
 # devices  just mounted.
-# 
-# See for explanation: 
+#
+# See for explanation:
 #   https://github.com/systemd/systemd/commit/628c89cc68ab96fce2de7ebba5933725d147aecc
 #   https://github.com/systemd/systemd/pull/2017
 aux udev_wait
@@ -125,11 +125,19 @@ not lvresize -L+10M -r $vg_lv_ren
 
 umount "$mount_dir"
 
-# ATM  fsadm is required instead of '-r' option with reiserfs
+
+USE_NOT=
+# TODO: this is somewhat suprising for users
+# Detect if the 'lvresize' was compiled with HAVE_BLKID_SUBLKS_FSINFO
+# In such case --fs checksize is a supported parameter
+# otherwise command automatically fallbacks to fsadm and resize reiserfs
+not lvresize --fs checksize -L+1 $vg/XXX 2>err
+if not grep "Unknown --fs value" err ; then
 case "$i" in
+# ATM  fsadm is required instead of '-r' option with reiserfs
 *reiserfs) USE_NOT="not" ;;
-*)	   USE_NOT="" ;;
 esac
+fi
 $USE_NOT lvresize -y -L+10M -r $vg_lv
 
 aux udev_wait


=====================================
test/shell/thin-foreign-dmeventd.sh
=====================================
@@ -22,7 +22,10 @@ MOUNT_DIR=mnt
 cleanup_mounted_and_teardown()
 {
 	umount "$MOUNT_DIR" || true
-	dmsetup remove $THIN
+	dmsetup remove $THIN || {
+		sleep 1 # retry once more after sleep (udev race)
+		dmsetup remove $THIN
+	}
 	vgremove -ff $vg
 	aux teardown
 }



View it on GitLab: https://gitlab.com/lvmteam/lvm2/-/compare/8f61a127b5350ddb639b9950c07f2862b567b791...ede63b50291b548af4dd87ba08793f4ee57c9cee

-- 
View it on GitLab: https://gitlab.com/lvmteam/lvm2/-/compare/8f61a127b5350ddb639b9950c07f2862b567b791...ede63b50291b548af4dd87ba08793f4ee57c9cee
You're receiving this email because of your account on gitlab.com.

--
lvm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/lvm-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.