Skip to contentSkip to conversation

tests/filesystem: use native quota support for ext4

PATCH Applied Ondrej Mosnacek 1 participant 2 messages Jan 10, 2023 – Jan 12, 2023 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/filesystem: use native quota support for ext4

Use of external quota files is now deprecated for ext4 in favor of native quota support, which can be enabled by passing -O quota to mkfs.ext4 when creating the filesystem.

To accommodate to that, modify the [fs_]filesystem tests such that the native quota support is used on kernels that support it (3.6+ according to kernel's git history).

The EXT4 native quota support is similar to the XFS one in that it doesn't require calling quotacheck(8) and the quota support is turned on implicitly when the filesystem is mounted. However, contrary to XFS it doesn't use special quota commands. This means that a new helper program is needed to test the quota operations (neither quotas_test nor xfs_quotas_test can be reused).

Fixes issue #83.

---
 tests/filesystem/.gitignore           |  1 +
 tests/filesystem/Filesystem.pm        |  4 +-
 tests/filesystem/Makefile             |  2 +-
 tests/filesystem/native_quotas_test.c | 94 +++++++++++++++++++++++++++
 tests/filesystem/test                 | 86 ++++++++++++++++--------
 tests/fs_filesystem/test              | 88 +++++++++++++++++--------
 6 files changed, 217 insertions(+), 58 deletions(-)
 create mode 100644 tests/filesystem/native_quotas_test.c
tests/filesystem/.gitignore +1 -0
index e76fcd3..9d5d6b2 100644
@@ -10,3 +10,4 @@ check_mount_context
 create_file
 grim_reaper
 xfs_quotas_test
+native_quotas_test
tests/filesystem/Filesystem.pm +2 -2
index bd91a11..1a67a90 100644
@@ -121,7 +121,7 @@ sub attach_dev {
 }
 
 sub make_fs {
-    my ( $mk_type, $mk_dev, $mk_dir ) = @_;
+    my ( $mk_type, $mk_dev, $mk_dir, $mk_opts ) = @_;
     my $mk_size = 16;
     if ( $mk_type eq "xfs" ) {
         $mk_size = 300;
@@ -137,7 +137,7 @@ sub make_fs {
     attach_dev( $mk_dev, $mk_dir );
 
     print "Make $mk_type filesystem on $mk_dev\n";
-    $result = system("yes | mkfs.$mk_type $mk_dev > /dev/null 2>&1");
+    $result = system("yes | mkfs.$mk_type $mk_opts $mk_dev > /dev/null 2>&1");
     if ( $result != 0 ) {
         system("losetup -d $mk_dev 2>/dev/null");
         print "mkfs.$mk_type failed to create filesystem on $mk_dev\n";
tests/filesystem/Makefile +1 -1
index a863ea2..5172696 100644
@@ -3,7 +3,7 @@
 
 TARGETS = mount umount quotas_test statfs_test create_file_change_context \
 fs_relabel check_file_context grim_reaper check_mount_context create_file \
-xfs_quotas_test
+xfs_quotas_test native_quotas_test
 
 LDLIBS += -lselinux
 
tests/filesystem/native_quotas_test.c new file +94 -0

94 lines not on this page · raw message

tests/filesystem/test +59 -27

255 lines not on this page · raw message

tests/fs_filesystem/test +60 -28

263 lines not on this page · raw message

Signature · 1 line
2.39.0
author Applied
#1 lore raw
Quoted 18 lines · Ondrej Mosnacek

Use of external quota files is now deprecated for ext4 in favor of native quota support, which can be enabled by passing -O quota to mkfs.ext4 when creating the filesystem.

To accommodate to that, modify the [fs_]filesystem tests such that the native quota support is used on kernels that support it (3.6+ according to kernel's git history).

The EXT4 native quota support is similar to the XFS one in that it doesn't require calling quotacheck(8) and the quota support is turned on implicitly when the filesystem is mounted. However, contrary to XFS it doesn't use special quota commands. This means that a new helper program is needed to test the quota operations (neither quotas_test nor xfs_quotas_test can be reused).

Fixes issue #83.

Quoted 9 lines
---
 tests/filesystem/.gitignore           |  1 +
 tests/filesystem/Filesystem.pm        |  4 +-
 tests/filesystem/Makefile             |  2 +-
 tests/filesystem/native_quotas_test.c | 94 +++++++++++++++++++++++++++
 tests/filesystem/test                 | 86 ++++++++++++++++--------
 tests/fs_filesystem/test              | 88 +++++++++++++++++--------
 6 files changed, 217 insertions(+), 58 deletions(-)
 create mode 100644 tests/filesystem/native_quotas_test.c

Applied:
https://github.com/SELinuxProject/selinux-testsuite/commit/bbab270f66c3fc33b4fdc7cec8beb0003afbb4ee

Signature · 3 lines
Ondrej Mosnacek
Senior Software Engineer, Linux Security - SELinux kernel
Red Hat, Inc.