Skip to contentSkip to conversation

check: set seqres before calling init_rc which could write there

PATCH In review Andrey Albershteyn 2 participants 2 messages Nov 3

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 check: set seqres before calling init_rc which could write there

There's path where >>$seqres is used in init_rc:

-> init_rc

	-> _test_mount
		-> _prepare_for_eio_shutdown
			->_xfs_prepare_for_eio_shutdown
				-> _set_fs_sysfs_attr

Which will try to write to .full because $seqres is not set. Fix this by setting seqres first, this way it should go to $RESULT_DIR/check.full.

The init_rc is called in the top context and then per section, however, for top context we don't have environment set up yet. These logs are just a few sysfs_attr writes and aren't that important, so, let's save those to /tmp/xxx.check.full just in case.

---
Changes in v2:
- remove The before init_rc in the comment

---
 check | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
check +6 -2
index 534c2cdf7a06..afe855bcf0ed 100755
@@ -534,6 +534,10 @@ if ! . ./common/rc; then
 	_fatal "check: failed to source common/rc"
 fi
 
+# init_rc could write to the $seqres.full, however we don't have any context
+# here yet, and no RESULT_BASE is setup. These logs aren't that important but
+# let's keep them in /tmp anyway.
+seqres=$tmp.check
 init_rc
 
 # If the test config specified a soak test duration, see if there are any
@@ -932,8 +936,6 @@ function run_section()
 		_test_unmount 2> /dev/null
 	fi
 
-	init_rc
-
 	seq="check.$$"
 	check="$RESULT_BASE/check"
 	seqres="$check"
@@ -941,6 +943,8 @@ function run_section()
 	# don't leave old full output behind on a clean run
 	rm -f $check.full
 
+	init_rc
+
 	[ -f $check.time ] || touch $check.time
 
 	# print out our test configuration
Signature · 1 line
2.54.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 30 lines · Andrey Albershteyn

There's path where >>$seqres is used in init_rc:

-> init_rc

	-> _test_mount
		-> _prepare_for_eio_shutdown
			->_xfs_prepare_for_eio_shutdown
				-> _set_fs_sysfs_attr

Which will try to write to .full because $seqres is not set. Fix this by setting seqres first, this way it should go to $RESULT_DIR/check.full.

The init_rc is called in the top context and then per section, however, for top context we don't have environment set up yet. These logs are just a few sysfs_attr writes and aren't that important, so, let's save those to /tmp/xxx.check.full just in case.

---
Changes in v2:
- remove The before init_rc in the comment

---
 check | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
check +0 -0
index 534c2cdf7a06..afe855bcf0ed 100755

check if ! . ./common/rc; then · line 540

Quoted 7 lines
check +4 -0
@@ -534,6 +534,10 @@ if ! . ./common/rc; then
 	_fatal "check: failed to source common/rc"
 fi
 
+# init_rc could write to the $seqres.full, however we don't have any context
+# here yet, and no RESULT_BASE is setup. These logs aren't that important but
+# let's keep them in /tmp anyway.
+seqres=$tmp.check

The code around init_rc is definitely messy and deserves a proper refactor. For this patch specifically, though, it looks good to me.

Quoted 24 lines
check +2 -2
 init_rc
 
 # If the test config specified a soak test duration, see if there are any
@@ -932,8 +936,6 @@ function run_section()
 		_test_unmount 2> /dev/null
 	fi
 
-	init_rc
-
 	seq="check.$$"
 	check="$RESULT_BASE/check"
 	seqres="$check"
@@ -941,6 +943,8 @@ function run_section()
 	# don't leave old full output behind on a clean run
 	rm -f $check.full
 
+	init_rc
+
 	[ -f $check.time ] || touch $check.time
 
 	# print out our test configuration
Signature · 1 line
2.54.0