Linux Test Project
 help / color / mirror / Atom feed
* [LTP] [PATCH 0/3] tst_device: add support for overlayfs
@ 2025-02-03 22:05 Jeff Moyer
  2025-02-03 22:05 ` [LTP] [PATCH 1/3] lib/tst_device.c: factor out btrfs-specific logic from tst_find_backing_dev Jeff Moyer
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Jeff Moyer @ 2025-02-03 22:05 UTC (permalink / raw)
  To: ltp

When running ltp-aiodio on an overlay file system, the following error
occurs:

tst_tmpdir.c:316: TINFO: Using /mnt/fstests/TEST_DIR/ovl-mnt/ltp-hSHEHy5M0s/LTP_aio4q4GMW as tmpdir (overlayfs filesystem)
tst_test.c:1888: TINFO: LTP version: 20220121-2271-g91a10df22
tst_test.c:1892: TINFO: Tested kernel: vendor kernel
tst_test.c:1723: TINFO: Timeout per run is 0h 40m 00s
aiocp.c:211: TINFO: Maximum AIO blocks: 65536
tst_device.c:551: TINFO: Use BTRFS specific strategy
tst_device.c:569: TBROK: BTRFS ioctl failed. Is . on a tmpfs?: ENOTTY (25)

The issue is that stat(2) on an overlayfs mount point will return a
major device number of 0.  The code assumes this is btrfs, and tries
to issue a btrfs-specific ioctl.  When that fails, the final message is
printed that suggests this might be tmpfs.

I modified the code to use statfs(2) to get the file system type, and
use that to determine which file system specific code to call.  Finally, I
added code to parse out the upper directory from the overlayfs mount options
using libmount.  libmount is part of util-linux, so it should be fairly
ubiquitous.  stat(2) is then called on the upper directory to get to the
underlying device node.

Review of the series is greatly appreciated.

Thanks in advance!
Jeff

[PATCH 1/3] lib/tst_device.c: factor out btrfs-specific logic from
[PATCH 2/3] lib/tst_device.c: check for BTRFS_SUPER_MAGIC instead of
[PATCH 3/3] lib/tst_device.c: add support for overlayfs


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [LTP] [PATCH 1/3] lib/tst_device.c: factor out btrfs-specific logic from tst_find_backing_dev
  2025-02-03 22:05 [LTP] [PATCH 0/3] tst_device: add support for overlayfs Jeff Moyer
@ 2025-02-03 22:05 ` Jeff Moyer
  2025-02-03 22:05 ` [LTP] [PATCH 2/3] lib/tst_device.c: check for BTRFS_SUPER_MAGIC instead of device major of 0 Jeff Moyer
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 11+ messages in thread
From: Jeff Moyer @ 2025-02-03 22:05 UTC (permalink / raw)
  To: ltp; +Cc: Jeff Moyer

In preparation for handling overlayfs (which also has a major device
number of 0), factor out the btrfs logic.

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
---
 lib/tst_device.c | 104 +++++++++++++++++++++++++----------------------
 1 file changed, 55 insertions(+), 49 deletions(-)

diff --git a/lib/tst_device.c b/lib/tst_device.c
index 723f6ca06..70234a83c 100644
--- a/lib/tst_device.c
+++ b/lib/tst_device.c
@@ -520,20 +520,68 @@ unsigned long tst_dev_bytes_written(const char *dev)
 	return dev_bytes_written;
 }
 
+static void btrfs_get_uevent_path(char *tmp_path, char *uevent_path)
+{
+	int fd;
+	struct btrfs_ioctl_fs_info_args args = {0};
+	char btrfs_uuid_str[UUID_STR_SZ];
+	struct dirent *d;
+	char bdev_path[PATH_MAX];
+	DIR *dir;
+
+	tst_resm(TINFO, "Use BTRFS specific strategy");
+
+	fd = SAFE_OPEN(NULL, tmp_path, O_DIRECTORY);
+	if (!ioctl(fd, BTRFS_IOC_FS_INFO, &args)) {
+		sprintf(btrfs_uuid_str,
+			UUID_FMT,
+			args.fsid[0], args.fsid[1],
+			args.fsid[2], args.fsid[3],
+			args.fsid[4], args.fsid[5],
+			args.fsid[6], args.fsid[7],
+			args.fsid[8], args.fsid[9],
+			args.fsid[10], args.fsid[11],
+			args.fsid[12], args.fsid[13],
+			args.fsid[14], args.fsid[15]);
+		sprintf(bdev_path,
+			"/sys/fs/btrfs/%s/devices", btrfs_uuid_str);
+	} else {
+		if (errno == ENOTTY)
+			tst_brkm(TBROK | TERRNO, NULL, "BTRFS ioctl failed. Is %s on a tmpfs?", tmp_path);
+
+		tst_brkm(TBROK | TERRNO, NULL, "BTRFS ioctl on %s failed.", tmp_path);
+	}
+	SAFE_CLOSE(NULL, fd);
+
+	dir = SAFE_OPENDIR(NULL, bdev_path);
+	while ((d = SAFE_READDIR(NULL, dir))) {
+		if (d->d_name[0] != '.')
+			break;
+	}
+
+	uevent_path[0] = '\0';
+
+	if (d) {
+		sprintf(uevent_path, "%s/%s/uevent",
+			bdev_path, d->d_name);
+	} else {
+		tst_brkm(TBROK | TERRNO, NULL, "No backing device found while looking in %s.", bdev_path);
+	}
+
+	if (SAFE_READDIR(NULL, dir))
+		tst_resm(TINFO, "Warning: used first of multiple backing device.");
+
+	SAFE_CLOSEDIR(NULL, dir);
+}
+
 __attribute__((nonnull))
 void tst_find_backing_dev(const char *path, char *dev, size_t dev_size)
 {
 	struct stat buf;
-	struct btrfs_ioctl_fs_info_args args = {0};
-	struct dirent *d;
 	char uevent_path[PATH_MAX+PATH_MAX+10]; //10 is for the static uevent path
 	char dev_name[NAME_MAX];
-	char bdev_path[PATH_MAX];
 	char tmp_path[PATH_MAX];
-	char btrfs_uuid_str[UUID_STR_SZ];
-	DIR *dir;
 	unsigned int dev_major, dev_minor;
-	int fd;
 
 	if (stat(path, &buf) < 0)
 		tst_brkm(TWARN | TERRNO, NULL, "stat() failed");
@@ -548,49 +596,7 @@ void tst_find_backing_dev(const char *path, char *dev, size_t dev_size)
 	*dev = '\0';
 
 	if (dev_major == 0) {
-		tst_resm(TINFO, "Use BTRFS specific strategy");
-
-		fd = SAFE_OPEN(NULL, tmp_path, O_DIRECTORY);
-		if (!ioctl(fd, BTRFS_IOC_FS_INFO, &args)) {
-			sprintf(btrfs_uuid_str,
-				UUID_FMT,
-				args.fsid[0], args.fsid[1],
-				args.fsid[2], args.fsid[3],
-				args.fsid[4], args.fsid[5],
-				args.fsid[6], args.fsid[7],
-				args.fsid[8], args.fsid[9],
-				args.fsid[10], args.fsid[11],
-				args.fsid[12], args.fsid[13],
-				args.fsid[14], args.fsid[15]);
-			sprintf(bdev_path,
-				"/sys/fs/btrfs/%s/devices", btrfs_uuid_str);
-		} else {
-			if (errno == ENOTTY)
-				tst_brkm(TBROK | TERRNO, NULL, "BTRFS ioctl failed. Is %s on a tmpfs?", path);
-
-			tst_brkm(TBROK | TERRNO, NULL, "BTRFS ioctl on %s failed.", tmp_path);
-		}
-		SAFE_CLOSE(NULL, fd);
-
-		dir = SAFE_OPENDIR(NULL, bdev_path);
-		while ((d = SAFE_READDIR(NULL, dir))) {
-			if (d->d_name[0] != '.')
-				break;
-		}
-
-		uevent_path[0] = '\0';
-
-		if (d) {
-			sprintf(uevent_path, "%s/%s/uevent",
-				bdev_path, d->d_name);
-		} else {
-			tst_brkm(TBROK | TERRNO, NULL, "No backing device found while looking in %s.", bdev_path);
-		}
-
-		if (SAFE_READDIR(NULL, dir))
-			tst_resm(TINFO, "Warning: used first of multiple backing device.");
-
-		SAFE_CLOSEDIR(NULL, dir);
+		btrfs_get_uevent_path(tmp_path, uevent_path);
 	} else {
 		tst_resm(TINFO, "Use uevent strategy");
 		sprintf(uevent_path,
-- 
2.43.5


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [LTP] [PATCH 2/3] lib/tst_device.c: check for BTRFS_SUPER_MAGIC instead of device major of 0
  2025-02-03 22:05 [LTP] [PATCH 0/3] tst_device: add support for overlayfs Jeff Moyer
  2025-02-03 22:05 ` [LTP] [PATCH 1/3] lib/tst_device.c: factor out btrfs-specific logic from tst_find_backing_dev Jeff Moyer
@ 2025-02-03 22:05 ` Jeff Moyer
  2025-02-03 22:06 ` [LTP] [PATCH 3/3] lib/tst_device.c: add support for overlayfs Jeff Moyer
  2025-02-07 11:37 ` [LTP] [PATCH 0/3] tst_device: " Petr Vorel
  3 siblings, 0 replies; 11+ messages in thread
From: Jeff Moyer @ 2025-02-03 22:05 UTC (permalink / raw)
  To: ltp; +Cc: Jeff Moyer

stat() may return a major number of 0 in st_dev for any number of
pseudo file systems.  Check for the exact file system instead.  There
should be no change in behavior with this patch.

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
---
 lib/tst_device.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/lib/tst_device.c b/lib/tst_device.c
index 70234a83c..744e08a68 100644
--- a/lib/tst_device.c
+++ b/lib/tst_device.c
@@ -17,6 +17,8 @@
 #include <sys/sysmacros.h>
 #include <linux/btrfs.h>
 #include <linux/limits.h>
+#include <sys/vfs.h>
+#include <linux/magic.h>
 #include "lapi/syscalls.h"
 #include "test.h"
 #include "safe_macros.h"
@@ -546,9 +548,6 @@ static void btrfs_get_uevent_path(char *tmp_path, char *uevent_path)
 		sprintf(bdev_path,
 			"/sys/fs/btrfs/%s/devices", btrfs_uuid_str);
 	} else {
-		if (errno == ENOTTY)
-			tst_brkm(TBROK | TERRNO, NULL, "BTRFS ioctl failed. Is %s on a tmpfs?", tmp_path);
-
 		tst_brkm(TBROK | TERRNO, NULL, "BTRFS ioctl on %s failed.", tmp_path);
 	}
 	SAFE_CLOSE(NULL, fd);
@@ -578,6 +577,7 @@ __attribute__((nonnull))
 void tst_find_backing_dev(const char *path, char *dev, size_t dev_size)
 {
 	struct stat buf;
+	struct statfs fsbuf;
 	char uevent_path[PATH_MAX+PATH_MAX+10]; //10 is for the static uevent path
 	char dev_name[NAME_MAX];
 	char tmp_path[PATH_MAX];
@@ -595,8 +595,13 @@ void tst_find_backing_dev(const char *path, char *dev, size_t dev_size)
 	dev_minor = minor(buf.st_dev);
 	*dev = '\0';
 
-	if (dev_major == 0) {
+	if (statfs(path, &fsbuf) < 0)
+		tst_brkm(TWARN | TERRNO, NULL, "statfs() failed");
+
+	if (fsbuf.f_type == BTRFS_SUPER_MAGIC) {
 		btrfs_get_uevent_path(tmp_path, uevent_path);
+	} else if (dev_major == 0) {
+		tst_brkm(TBROK, NULL, "%s resides on an unsupported pseudo-file system.", path);
 	} else {
 		tst_resm(TINFO, "Use uevent strategy");
 		sprintf(uevent_path,
-- 
2.43.5


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [LTP] [PATCH 3/3] lib/tst_device.c: add support for overlayfs
  2025-02-03 22:05 [LTP] [PATCH 0/3] tst_device: add support for overlayfs Jeff Moyer
  2025-02-03 22:05 ` [LTP] [PATCH 1/3] lib/tst_device.c: factor out btrfs-specific logic from tst_find_backing_dev Jeff Moyer
  2025-02-03 22:05 ` [LTP] [PATCH 2/3] lib/tst_device.c: check for BTRFS_SUPER_MAGIC instead of device major of 0 Jeff Moyer
@ 2025-02-03 22:06 ` Jeff Moyer
  2025-02-07 11:23   ` Petr Vorel
  2025-02-07 11:37 ` [LTP] [PATCH 0/3] tst_device: " Petr Vorel
  3 siblings, 1 reply; 11+ messages in thread
From: Jeff Moyer @ 2025-02-03 22:06 UTC (permalink / raw)
  To: ltp; +Cc: Jeff Moyer

Add checks for overlayfs in tst_find_backing_dev.  As with btrfs, only
a single device is checked (the upper one) and returned from
tst_find_backing_dev().

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
---
 .gitignore       |  1 +
 INSTALL          |  6 ++---
 lib/Makefile     |  2 +-
 lib/libltp.a     |  1 +
 lib/tst_device.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 68 insertions(+), 4 deletions(-)
 create mode 100644 lib/libltp.a

diff --git a/.gitignore b/.gitignore
index 24f4a4ea8..38bf1fab9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,6 +9,7 @@ core
 .gdb_history
 .gdbinit
 lib*.a
+!libltp.a
 .cache.mk
 *.dwo
 *.mod
diff --git a/INSTALL b/INSTALL
index ad43514d4..557cf4abc 100644
--- a/INSTALL
+++ b/INSTALL
@@ -6,15 +6,15 @@ package in any Linux distribution (no specific version is required).
 
 Debian / Ubuntu
 
-	# apt install gcc git make pkgconf autoconf automake bison flex m4 linux-headers-$(uname -r) libc6-dev
+	# apt install gcc git make pkgconf autoconf automake bison flex m4 linux-headers-$(uname -r) libc6-dev libmount-dev
 
 openSUSE / SLES
 
-	# zypper install gcc git make pkg-config autoconf automake bison flex m4 linux-glibc-devel glibc-devel
+	# zypper install gcc git make pkg-config autoconf automake bison flex m4 linux-glibc-devel glibc-devel libmount-devel
 
 Fedora / CentOS / RHEL
 
-	# yum install gcc git make pkgconf autoconf automake bison flex m4 kernel-headers glibc-headers
+	# yum install gcc git make pkgconf autoconf automake bison flex m4 kernel-headers glibc-headers libmount-devel
 
 These are minimal build requirements for git compilation. Some tests require
 extra development files of some libraries, see ci/*.sh. There is also
diff --git a/lib/Makefile b/lib/Makefile
index 67169f149..2f180405e 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -14,7 +14,7 @@ else
 FILTER_OUT_LIBSRCS	+= tlibio.c tst_safe_sysv_ipc.c
 endif
 
-INTERNAL_LIB		:= libltp.a
+INTERNAL_LIB		:= libltp_internal.a
 
 pc_file			:= $(DESTDIR)/$(datarootdir)/pkgconfig/ltp.pc
 
diff --git a/lib/libltp.a b/lib/libltp.a
new file mode 100644
index 000000000..006f3557e
--- /dev/null
+++ b/lib/libltp.a
@@ -0,0 +1 @@
+INPUT (libltp_internal.a -lmount)
diff --git a/lib/tst_device.c b/lib/tst_device.c
index 744e08a68..d99da1c51 100644
--- a/lib/tst_device.c
+++ b/lib/tst_device.c
@@ -19,6 +19,7 @@
 #include <linux/limits.h>
 #include <sys/vfs.h>
 #include <linux/magic.h>
+#include <libmount/libmount.h>
 #include "lapi/syscalls.h"
 #include "test.h"
 #include "safe_macros.h"
@@ -573,6 +574,65 @@ static void btrfs_get_uevent_path(char *tmp_path, char *uevent_path)
 	SAFE_CLOSEDIR(NULL, dir);
 }
 
+static void overlay_get_dev(struct libmnt_fs *fs, const char *dir_opt,
+			    dev_t *dev)
+{
+	int ret;
+	char *value, *dir_name;
+	size_t val_size;
+	struct stat st;
+
+	ret = mnt_fs_get_option(fs, dir_opt, &value, &val_size);
+	if (ret)
+		tst_brkm(TBROK, NULL,
+			 "overlayfs: no %s in mount options", dir_opt);
+
+	dir_name = calloc(val_size + 1, 1);
+	if (!dir_name)
+		tst_brkm(TBROK | TERRNO, NULL, "calloc failed");
+
+	memcpy(dir_name, value, val_size);
+	if (stat(dir_name, &st) < 0)
+		tst_brkm(TBROK | TERRNO, NULL, "stat failed");
+
+	*dev = st.st_dev;
+	free(dir_name);
+}
+
+/*
+ * NOTE: this will not work for stacked overlay mounts.
+ */
+static void overlay_get_uevent_path(char *tmp_path, char *uevent_path)
+{
+	struct libmnt_table *mtab;
+	struct libmnt_fs *fs;
+	struct stat st;
+	dev_t upper_dev;
+
+	tst_resm(TINFO, "Use OVERLAYFS specific strategy");
+
+	mtab = mnt_new_table();
+	if (!mtab)
+		tst_brkm(TBROK | TERRNO, NULL, "mnt_new_table failed");
+
+	if (mnt_table_parse_file(mtab, "/proc/self/mountinfo") != 0)
+		tst_brkm(TBROK, NULL, "mnt_table_parse_file failed");
+
+	if (stat(tmp_path, &st) < 0)
+		tst_brkm(TBROK | TERRNO, NULL, "stat failed");
+
+	fs = mnt_table_find_devno(mtab, st.st_dev, MNT_ITER_FORWARD);
+	if (!fs)
+		tst_brkm(TBROK, NULL, "mnt_table_find_devno failed");
+
+	overlay_get_dev(fs, "upperdir", &upper_dev);
+	mnt_unref_table(mtab);
+
+	tst_resm(TINFO, "Warning: used first of multiple backing devices.");
+	sprintf(uevent_path, "/sys/dev/block/%d:%d/uevent",
+		major(upper_dev), minor(upper_dev));
+}
+
 __attribute__((nonnull))
 void tst_find_backing_dev(const char *path, char *dev, size_t dev_size)
 {
@@ -600,6 +660,8 @@ void tst_find_backing_dev(const char *path, char *dev, size_t dev_size)
 
 	if (fsbuf.f_type == BTRFS_SUPER_MAGIC) {
 		btrfs_get_uevent_path(tmp_path, uevent_path);
+	} else if (fsbuf.f_type == OVERLAYFS_SUPER_MAGIC) {
+		overlay_get_uevent_path(tmp_path, uevent_path);
 	} else if (dev_major == 0) {
 		tst_brkm(TBROK, NULL, "%s resides on an unsupported pseudo-file system.", path);
 	} else {
-- 
2.43.5


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [LTP] [PATCH 3/3] lib/tst_device.c: add support for overlayfs
  2025-02-03 22:06 ` [LTP] [PATCH 3/3] lib/tst_device.c: add support for overlayfs Jeff Moyer
@ 2025-02-07 11:23   ` Petr Vorel
  0 siblings, 0 replies; 11+ messages in thread
From: Petr Vorel @ 2025-02-07 11:23 UTC (permalink / raw)
  To: Jeff Moyer; +Cc: ltp

Hi Jeff,

> Add checks for overlayfs in tst_find_backing_dev.  As with btrfs, only
> a single device is checked (the upper one) and returned from
> tst_find_backing_dev().

...
> +++ b/INSTALL
> @@ -6,15 +6,15 @@ package in any Linux distribution (no specific version is required).

>  Debian / Ubuntu

> -	# apt install gcc git make pkgconf autoconf automake bison flex m4 linux-headers-$(uname -r) libc6-dev
> +	# apt install gcc git make pkgconf autoconf automake bison flex m4 linux-headers-$(uname -r) libc6-dev libmount-dev

>  openSUSE / SLES

> -	# zypper install gcc git make pkg-config autoconf automake bison flex m4 linux-glibc-devel glibc-devel
> +	# zypper install gcc git make pkg-config autoconf automake bison flex m4 linux-glibc-devel glibc-devel libmount-devel

>  Fedora / CentOS / RHEL

> -	# yum install gcc git make pkgconf autoconf automake bison flex m4 kernel-headers glibc-headers
> +	# yum install gcc git make pkgconf autoconf automake bison flex m4 kernel-headers glibc-headers libmount-devel

FYI it's good to update docs, but this is not enough.
You need to add libmount devel packages to ci/*.sh scripts otherwise it fails,
see [1].


We have note about ci/*.sh in INSTALL, maybe we should explicitly state that
build dependencies must be updated there.

I updated it for you (see diff below or use branch
jmoyer/tst_device-overlayfs.fixes in my fork [2]), but it still not enough [3].

It is reproducible even locally:

$ make autotools && ./configure
$ cd lib && make
AR libltp_internal.a
RANLIB libltp_internal.a
/usr/bin/ld: cannot find -lltp: No such file or directory
collect2: error: ld returned 1 exit status
make[1]: *** [../../include/mk/rules.mk:48: test01] Error 1
make[1]: *** Waiting for unfinished jobs....
/usr/bin/ld: cannot find -lltp: No such file or directory
collect2: error: ld returned 1 exit status
make[1]: *** [../../include/mk/rules.mk:48: test02] Error 1
/usr/bin/ld: cannot find -lltp: No such file or directory
collect2: error: ld returned 1 exit status
make[1]: *** [../../include/mk/rules.mk:48: test04] Error 1
/usr/bin/ld: cannot find -lltp: No such file or directory
collect2: error: ld returned 1 exit status
make[1]: *** [../../include/mk/rules.mk:48: test03] Error 1
make: *** [../include/mk/generic_trunk_target.inc:92: all] Error 2

> --- /dev/null
> +++ b/lib/libltp.a
> @@ -0,0 +1 @@
> +INPUT (libltp_internal.a -lmount)

'rm -fv lib/libltp.a' is required to apply the patchset.

Kind regards,
Petr

[1] https://github.com/pevik/ltp/actions/runs/13198563478
[2] https://github.com/pevik/ltp/tree/refs/heads/jmoyer/tst_device-overlayfs.fixes
[3] https://github.com/pevik/ltp/actions/runs/13198676398/job/36845555749

Fix CI for missing packages.

diff --git ci/alpine.sh ci/alpine.sh
index 93acd6267b..26a3775ac6 100755
--- ci/alpine.sh
+++ ci/alpine.sh
@@ -26,7 +26,8 @@ apk add \
 	numactl-dev \
 	openssl-dev \
 	perl-json \
-	pkgconfig
+	pkgconfig \
+	util-linux-dev
 
 cat /etc/os-release
 
diff --git ci/debian.cross-compile.sh ci/debian.cross-compile.sh
index 95cf11da22..18ee44ef58 100755
--- ci/debian.cross-compile.sh
+++ ci/debian.cross-compile.sh
@@ -21,4 +21,5 @@ apt install -y --no-install-recommends \
 	gcc-${gcc_arch}-linux-gnu \
 	libc6-dev-${ARCH}-cross \
 	libmnl-dev:$ARCH \
+	libmount-dev:$ARCH \
 	libtirpc-dev:$ARCH
diff --git ci/debian.i386.sh ci/debian.i386.sh
index 2846053098..b0f916d05f 100755
--- ci/debian.i386.sh
+++ ci/debian.i386.sh
@@ -14,6 +14,7 @@ apt install -y --no-install-recommends \
 	libc6-dev-i386 \
 	libc6:i386 \
 	libkeyutils-dev:i386 \
+	libmount-dev:i386 \
 	libnuma-dev:i386 \
 	libssl-dev:i386 \
 	libtirpc-dev:i386 \
diff --git ci/debian.sh ci/debian.sh
index fc1c1b3ec6..5fe1bf18da 100755
--- ci/debian.sh
+++ ci/debian.sh
@@ -27,6 +27,7 @@ pkg_minimal="
 	git
 	iproute2
 	libc6-dev
+	libmount-dev
 	libtirpc-dev
 	linux-libc-dev
 	lsb-release
diff --git ci/fedora.sh ci/fedora.sh
index 623dbb5cb6..244e2dae37 100755
--- ci/fedora.sh
+++ ci/fedora.sh
@@ -15,6 +15,7 @@ $yum \
 	findutils \
 	iproute \
 	numactl-devel \
+	libmount-devel \
 	libtirpc \
 	libtirpc-devel \
 	perl-JSON \

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [LTP] [PATCH 0/3] tst_device: add support for overlayfs
  2025-02-03 22:05 [LTP] [PATCH 0/3] tst_device: add support for overlayfs Jeff Moyer
                   ` (2 preceding siblings ...)
  2025-02-03 22:06 ` [LTP] [PATCH 3/3] lib/tst_device.c: add support for overlayfs Jeff Moyer
@ 2025-02-07 11:37 ` Petr Vorel
  2025-02-07 12:38   ` Cyril Hrubis
                     ` (2 more replies)
  3 siblings, 3 replies; 11+ messages in thread
From: Petr Vorel @ 2025-02-07 11:37 UTC (permalink / raw)
  To: Jeff Moyer; +Cc: ltp

Hi Jeff, all,

NOTE: 'rm -fv lib/libltp.a' is required to apply the patchset.

Besides it, it does not compile yet:
/usr/bin/ld: cannot find -lltp: No such file or directory
https://lore.kernel.org/ltp/20250207112353.GA1739723@pevik/

> When running ltp-aiodio on an overlay file system, the following error
> occurs:

> tst_tmpdir.c:316: TINFO: Using /mnt/fstests/TEST_DIR/ovl-mnt/ltp-hSHEHy5M0s/LTP_aio4q4GMW as tmpdir (overlayfs filesystem)
> tst_test.c:1888: TINFO: LTP version: 20220121-2271-g91a10df22
> tst_test.c:1892: TINFO: Tested kernel: vendor kernel
> tst_test.c:1723: TINFO: Timeout per run is 0h 40m 00s
> aiocp.c:211: TINFO: Maximum AIO blocks: 65536
> tst_device.c:551: TINFO: Use BTRFS specific strategy
> tst_device.c:569: TBROK: BTRFS ioctl failed. Is . on a tmpfs?: ENOTTY (25)

> The issue is that stat(2) on an overlayfs mount point will return a
> major device number of 0.  The code assumes this is btrfs, and tries
> to issue a btrfs-specific ioctl.  When that fails, the final message is
> printed that suggests this might be tmpfs.

> I modified the code to use statfs(2) to get the file system type, and
> use that to determine which file system specific code to call.  Finally, I
> added code to parse out the upper directory from the overlayfs mount options
> using libmount.  libmount is part of util-linux, so it should be fairly

We try to avoid external libraries to help testing kernel on some minimal
embedded devices. @Cyril: is it ok to drag libmount-devel?

@Jeff: would it be too hard to parse /proc/self/mountinfo (I suppose
/proc/self/mounts is not enough)? I'm looking into libmount code E.e.
mnt_fs_get_option() [1]. Or do you think it would be too fragile to parse it
without libmount?

Kind regards,
Petr

[1] https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git/tree/libmount/src/fs.c#n1568

> ubiquitous.  stat(2) is then called on the upper directory to get to the
> underlying device node.

> Review of the series is greatly appreciated.

> Thanks in advance!
> Jeff

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [LTP] [PATCH 0/3] tst_device: add support for overlayfs
  2025-02-07 11:37 ` [LTP] [PATCH 0/3] tst_device: " Petr Vorel
@ 2025-02-07 12:38   ` Cyril Hrubis
  2025-02-07 15:28     ` Jeff Moyer
  2025-02-07 15:27   ` Jeff Moyer
  2025-02-07 17:08   ` Jeff Moyer
  2 siblings, 1 reply; 11+ messages in thread
From: Cyril Hrubis @ 2025-02-07 12:38 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Jeff Moyer, ltp

Hi!
> > tst_tmpdir.c:316: TINFO: Using /mnt/fstests/TEST_DIR/ovl-mnt/ltp-hSHEHy5M0s/LTP_aio4q4GMW as tmpdir (overlayfs filesystem)
> > tst_test.c:1888: TINFO: LTP version: 20220121-2271-g91a10df22
> > tst_test.c:1892: TINFO: Tested kernel: vendor kernel
> > tst_test.c:1723: TINFO: Timeout per run is 0h 40m 00s
> > aiocp.c:211: TINFO: Maximum AIO blocks: 65536
> > tst_device.c:551: TINFO: Use BTRFS specific strategy
> > tst_device.c:569: TBROK: BTRFS ioctl failed. Is . on a tmpfs?: ENOTTY (25)
> 
> > The issue is that stat(2) on an overlayfs mount point will return a
> > major device number of 0.  The code assumes this is btrfs, and tries
> > to issue a btrfs-specific ioctl.  When that fails, the final message is
> > printed that suggests this might be tmpfs.
> 
> > I modified the code to use statfs(2) to get the file system type, and
> > use that to determine which file system specific code to call.  Finally, I
> > added code to parse out the upper directory from the overlayfs mount options
> > using libmount.  libmount is part of util-linux, so it should be fairly
> 
> We try to avoid external libraries to help testing kernel on some minimal
> embedded devices. @Cyril: is it ok to drag libmount-devel?

For the base LTP library? I would say no.

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [LTP] [PATCH 0/3] tst_device: add support for overlayfs
  2025-02-07 11:37 ` [LTP] [PATCH 0/3] tst_device: " Petr Vorel
  2025-02-07 12:38   ` Cyril Hrubis
@ 2025-02-07 15:27   ` Jeff Moyer
  2025-02-07 17:08   ` Jeff Moyer
  2 siblings, 0 replies; 11+ messages in thread
From: Jeff Moyer @ 2025-02-07 15:27 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

Hi, Petr,

Petr Vorel <pvorel@suse.cz> writes:

> Hi Jeff, all,
>
> NOTE: 'rm -fv lib/libltp.a' is required to apply the patchset.

Right, sorry for not mentioning that.

> Besides it, it does not compile yet:
> /usr/bin/ld: cannot find -lltp: No such file or directory
> https://lore.kernel.org/ltp/20250207112353.GA1739723@pevik/

It compiled for me, so that's surprising.  I would help track it down,
but it sounds like Cyril would prefer we didn't add a dependency.

>
>> When running ltp-aiodio on an overlay file system, the following error
>> occurs:
>
>> tst_tmpdir.c:316: TINFO: Using
>> /mnt/fstests/TEST_DIR/ovl-mnt/ltp-hSHEHy5M0s/LTP_aio4q4GMW as tmpdir
>> (overlayfs filesystem)
>> tst_test.c:1888: TINFO: LTP version: 20220121-2271-g91a10df22
>> tst_test.c:1892: TINFO: Tested kernel: vendor kernel
>> tst_test.c:1723: TINFO: Timeout per run is 0h 40m 00s
>> aiocp.c:211: TINFO: Maximum AIO blocks: 65536
>> tst_device.c:551: TINFO: Use BTRFS specific strategy
>> tst_device.c:569: TBROK: BTRFS ioctl failed. Is . on a tmpfs?: ENOTTY (25)
>
>> The issue is that stat(2) on an overlayfs mount point will return a
>> major device number of 0.  The code assumes this is btrfs, and tries
>> to issue a btrfs-specific ioctl.  When that fails, the final message is
>> printed that suggests this might be tmpfs.
>
>> I modified the code to use statfs(2) to get the file system type, and
>> use that to determine which file system specific code to call.  Finally, I
>> added code to parse out the upper directory from the overlayfs mount options
>> using libmount.  libmount is part of util-linux, so it should be fairly
>
> We try to avoid external libraries to help testing kernel on some minimal
> embedded devices. @Cyril: is it ok to drag libmount-devel?
>
> @Jeff: would it be too hard to parse /proc/self/mountinfo (I suppose
> /proc/self/mounts is not enough)? I'm looking into libmount code E.e.
> mnt_fs_get_option() [1]. Or do you think it would be too fragile to parse it
> without libmount?

I thought about it, but I typically avoid string parsing whenever
possible.  There are just too many corner cases.  Looking through the
libmount code convinced me I did not want to wade into those waters.  :)
It is, of course, possible to parse it directly.  There may be some
added maintenance burden, but it should be managable.  I'll purue that
route.

Thanks for taking a look!

-Jeff

>
> Kind regards,
> Petr
>
> [1]
> https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git/tree/libmount/src/fs.c#n1568
>
>> ubiquitous.  stat(2) is then called on the upper directory to get to the
>> underlying device node.
>
>> Review of the series is greatly appreciated.
>
>> Thanks in advance!
>> Jeff


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [LTP] [PATCH 0/3] tst_device: add support for overlayfs
  2025-02-07 12:38   ` Cyril Hrubis
@ 2025-02-07 15:28     ` Jeff Moyer
  0 siblings, 0 replies; 11+ messages in thread
From: Jeff Moyer @ 2025-02-07 15:28 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

Hi, Cyril,

Cyril Hrubis <chrubis@suse.cz> writes:

> Hi!
>> > tst_tmpdir.c:316: TINFO: Using
>> > /mnt/fstests/TEST_DIR/ovl-mnt/ltp-hSHEHy5M0s/LTP_aio4q4GMW as
>> > tmpdir (overlayfs filesystem)
>> > tst_test.c:1888: TINFO: LTP version: 20220121-2271-g91a10df22
>> > tst_test.c:1892: TINFO: Tested kernel: vendor kernel
>> > tst_test.c:1723: TINFO: Timeout per run is 0h 40m 00s
>> > aiocp.c:211: TINFO: Maximum AIO blocks: 65536
>> > tst_device.c:551: TINFO: Use BTRFS specific strategy
>> > tst_device.c:569: TBROK: BTRFS ioctl failed. Is . on a tmpfs?: ENOTTY (25)
>> 
>> > The issue is that stat(2) on an overlayfs mount point will return a
>> > major device number of 0.  The code assumes this is btrfs, and tries
>> > to issue a btrfs-specific ioctl.  When that fails, the final message is
>> > printed that suggests this might be tmpfs.
>> 
>> > I modified the code to use statfs(2) to get the file system type, and
>> > use that to determine which file system specific code to call.  Finally, I
>> > added code to parse out the upper directory from the overlayfs mount options
>> > using libmount.  libmount is part of util-linux, so it should be fairly
>> 
>> We try to avoid external libraries to help testing kernel on some minimal
>> embedded devices. @Cyril: is it ok to drag libmount-devel?
>
> For the base LTP library? I would say no.

OK, I'll spin a version with custom parsing code.

Thanks for taking a look!

-Jeff


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [LTP] [PATCH 0/3] tst_device: add support for overlayfs
  2025-02-07 11:37 ` [LTP] [PATCH 0/3] tst_device: " Petr Vorel
  2025-02-07 12:38   ` Cyril Hrubis
  2025-02-07 15:27   ` Jeff Moyer
@ 2025-02-07 17:08   ` Jeff Moyer
  2025-02-07 17:15     ` Petr Vorel
  2 siblings, 1 reply; 11+ messages in thread
From: Jeff Moyer @ 2025-02-07 17:08 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

Petr Vorel <pvorel@suse.cz> writes:

> @Jeff: would it be too hard to parse /proc/self/mountinfo (I suppose
> /proc/self/mounts is not enough)? I'm looking into libmount code E.e.

Looking more closely, I think /proc/self/mounts will work just fine.  I
was pointed to mountinfo originally and didn't consider mounts.  Thanks
for the suggestion, that will make this much easier!

Cheers,
Jeff


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [LTP] [PATCH 0/3] tst_device: add support for overlayfs
  2025-02-07 17:08   ` Jeff Moyer
@ 2025-02-07 17:15     ` Petr Vorel
  0 siblings, 0 replies; 11+ messages in thread
From: Petr Vorel @ 2025-02-07 17:15 UTC (permalink / raw)
  To: Jeff Moyer; +Cc: ltp

Hi Jeff,

> Petr Vorel <pvorel@suse.cz> writes:

> > @Jeff: would it be too hard to parse /proc/self/mountinfo (I suppose
> > /proc/self/mounts is not enough)? I'm looking into libmount code E.e.

> Looking more closely, I think /proc/self/mounts will work just fine.  I
> was pointed to mountinfo originally and didn't consider mounts.  Thanks
> for the suggestion, that will make this much easier!

Great, thank you! Not dragging libmount as a hard dependency for base library
helps us a lot.

Kind regards,
Petr

> Cheers,
> Jeff


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-02-07 17:15 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-03 22:05 [LTP] [PATCH 0/3] tst_device: add support for overlayfs Jeff Moyer
2025-02-03 22:05 ` [LTP] [PATCH 1/3] lib/tst_device.c: factor out btrfs-specific logic from tst_find_backing_dev Jeff Moyer
2025-02-03 22:05 ` [LTP] [PATCH 2/3] lib/tst_device.c: check for BTRFS_SUPER_MAGIC instead of device major of 0 Jeff Moyer
2025-02-03 22:06 ` [LTP] [PATCH 3/3] lib/tst_device.c: add support for overlayfs Jeff Moyer
2025-02-07 11:23   ` Petr Vorel
2025-02-07 11:37 ` [LTP] [PATCH 0/3] tst_device: " Petr Vorel
2025-02-07 12:38   ` Cyril Hrubis
2025-02-07 15:28     ` Jeff Moyer
2025-02-07 15:27   ` Jeff Moyer
2025-02-07 17:08   ` Jeff Moyer
2025-02-07 17:15     ` Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox