Skip to contentSkip to conversation

common/rc, ceph: add _require_not_encrypted test

PATCH Superseded Jeff Layton 2 participants 3 messages Dec 15, 2021

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 common/rc, ceph: add _require_not_encrypted test

Some tests on ceph require changing the layout of new files, which is forbidden when the files are encrypted. Add a test that touches a file in $TEST_DIR and then tests it to see if it reports the STATX_ATTR_ENCRYPTED flag, and does a _notrun if it's present.

Also add this requirement to the two ceph tests that change the layout.

Cc Luis Henriques <[email protected]>
---
 common/rc      | 17 +++++++++++++++++
 tests/ceph/002 |  1 +
 tests/ceph/003 |  1 +
 3 files changed, 19 insertions(+)
common/rc +17 -0
index 7973ceb5fdf8..9165325dc478 100644
@@ -4782,6 +4782,23 @@ _require_kernel_config()
 	_has_kernel_config $1 || _notrun "Installed kernel not built with $1"
 }
 
+_require_not_encrypted()
+{
+	local target=$TEST_DIR/require_not_encrypted.$$
+	local ret=0
+
+	#
+	# The top-level directory mounted with test_dummy_encryption is not
+	# itself encrypted. Only new files and directories created under it
+	# are.
+	touch $target
+	local attrs=$($XFS_IO_PROG -c 'statx -r' $target | awk '/stat.attributes / { print $3 }')
+	rm -f $target
+
+	# STATX_ATTR_ENCRYPTED == 0x800
+	[ $(( attrs & 0x800 )) -eq 0 ] || _notrun "Filesystem is encrypted"
+}
+
 init_rc
 
 ################################################################################
tests/ceph/002 +1 -0
index 9bc728fd2e18..be5c0f8c644d 100755
@@ -30,6 +30,7 @@ _begin_fstest auto quick copy_range
 _supported_fs ceph
 
 _require_xfs_io_command "copy_range"
+_require_not_encrypted
 _require_attrs
 _require_test
 
tests/ceph/003 +1 -0
index faedb48cfeea..c8aefc4ad06f 100755
@@ -18,6 +18,7 @@ _begin_fstest auto quick copy_range
 _supported_fs ceph
 
 _require_xfs_io_command "copy_range"
+_require_not_encrypted
 _require_attrs
 _require_test
 
Signature · 1 line
2.33.1
#1 lore raw

Hi Jeff,

Quoted 6 lines · Jeff Layton

Some tests on ceph require changing the layout of new files, which is forbidden when the files are encrypted. Add a test that touches a file in $TEST_DIR and then tests it to see if it reports the STATX_ATTR_ENCRYPTED flag, and does a _notrun if it's present.

Also add this requirement to the two ceph tests that change the layout.

Aren't you forgetting ceph/001?

Quoted 23 lines
Cc Luis Henriques <[email protected]>
---
 common/rc      | 17 +++++++++++++++++
 tests/ceph/002 |  1 +
 tests/ceph/003 |  1 +
 3 files changed, 19 insertions(+)
common/rc +7 -0
index 7973ceb5fdf8..9165325dc478 100644
@@ -4782,6 +4782,23 @@ _require_kernel_config()
 	_has_kernel_config $1 || _notrun "Installed kernel not built with $1"
 }
 
+_require_not_encrypted()
+{
+	local target=$TEST_DIR/require_not_encrypted.$$
+	local ret=0
+
+	#
+	# The top-level directory mounted with test_dummy_encryption is not

common/rc _require_kernel_config() · line 4801

Quoted 10 lines
common/rc +10 -0
+	# itself encrypted. Only new files and directories created under it
+	# are.
+	touch $target
+	local attrs=$($XFS_IO_PROG -c 'statx -r' $target | awk '/stat.attributes / { print $3 }')
+	rm -f $target
+
+	# STATX_ATTR_ENCRYPTED == 0x800
+	[ $(( attrs & 0x800 )) -eq 0 ] || _notrun "Filesystem is encrypted"
+}
+

Maybe this function could be in the 'common/encrypt' file instead.

Other than these 2 comments, I also agree that this approach is better than hooking into the _ceph_create_file_layout() function.

Cheers,
--
Luís

Quoted 30 lines
common/rc +0 -0
 init_rc
 
 ################################################################################
tests/ceph/002 +1 -0
index 9bc728fd2e18..be5c0f8c644d 100755
@@ -30,6 +30,7 @@ _begin_fstest auto quick copy_range
 _supported_fs ceph
 
 _require_xfs_io_command "copy_range"
+_require_not_encrypted
 _require_attrs
 _require_test
 
tests/ceph/003 +1 -0
index faedb48cfeea..c8aefc4ad06f 100755
@@ -18,6 +18,7 @@ _begin_fstest auto quick copy_range
 _supported_fs ceph
 
 _require_xfs_io_command "copy_range"
+_require_not_encrypted
 _require_attrs
 _require_test
 
Signature · 1 line
2.33.1
#2 lore raw
Quoted 48 lines · Luís Henriques

Hi Jeff,

Quoted 6 lines · Jeff Layton

Some tests on ceph require changing the layout of new files, which is forbidden when the files are encrypted. Add a test that touches a file in $TEST_DIR and then tests it to see if it reports the STATX_ATTR_ENCRYPTED flag, and does a _notrun if it's present.

Also add this requirement to the two ceph tests that change the layout.

Aren't you forgetting ceph/001?

Quoted 23 lines
Cc Luis Henriques <[email protected]>
---
 common/rc      | 17 +++++++++++++++++
 tests/ceph/002 |  1 +
 tests/ceph/003 |  1 +
 3 files changed, 19 insertions(+)
common/rc +7 -0
index 7973ceb5fdf8..9165325dc478 100644
@@ -4782,6 +4782,23 @@ _require_kernel_config()
 	_has_kernel_config $1 || _notrun "Installed kernel not built with $1"
 }
 
+_require_not_encrypted()
+{
+	local target=$TEST_DIR/require_not_encrypted.$$
+	local ret=0
+
+	#
+	# The top-level directory mounted with test_dummy_encryption is not

common/rc _require_kernel_config() · line 4801

Quoted 10 lines
common/rc +10 -0
+	# itself encrypted. Only new files and directories created under it
+	# are.
+	touch $target
+	local attrs=$($XFS_IO_PROG -c 'statx -r' $target | awk '/stat.attributes / { print $3 }')
+	rm -f $target
+
+	# STATX_ATTR_ENCRYPTED == 0x800
+	[ $(( attrs & 0x800 )) -eq 0 ] || _notrun "Filesystem is encrypted"
+}
+

Maybe this function could be in the 'common/encrypt' file instead.

Quoted 7 lines

Other than these 2 comments, I also agree that this approach is better than hooking into the _ceph_create_file_layout() function.

Cheers,
--
Luís

v3 patch sent that should address your comments.

Thanks!

Quoted 30 lines
Quoted 30 lines
common/rc +0 -0
 init_rc
 
 ################################################################################
tests/ceph/002 +1 -0
index 9bc728fd2e18..be5c0f8c644d 100755
@@ -30,6 +30,7 @@ _begin_fstest auto quick copy_range
 _supported_fs ceph
 
 _require_xfs_io_command "copy_range"
+_require_not_encrypted
 _require_attrs
 _require_test
 
tests/ceph/003 +1 -0
index faedb48cfeea..c8aefc4ad06f 100755
@@ -18,6 +18,7 @@ _begin_fstest auto quick copy_range
 _supported_fs ceph
 
 _require_xfs_io_command "copy_range"
+_require_not_encrypted
 _require_attrs
 _require_test
 
Signature · 1 line
2.33.1
Signature · 1 line
Jeff Layton <[email protected]>