public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscalls: Check for leftover partition info in loopdev ioctl tests
@ 2022-04-06 11:08 Martin Doucha
  2022-04-19  7:09 ` Petr Vorel
  2022-04-25 15:21 ` Cyril Hrubis
  0 siblings, 2 replies; 5+ messages in thread
From: Martin Doucha @ 2022-04-06 11:08 UTC (permalink / raw)
  To: ltp

Due to a kernel bug, successful ioctl09 and ioctl_loop01 test runs
sometimes leave behind stale partition info on the loop device they used,
which then causes mkfs.vfat to fail in later tests. Check that partition
info was properly removed in cleanup.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---

This does not fix the mkfs.vfat failures but it makes the true cause visible.
We could add a workaround for the mkfs.vfat failures by simply initializing
the loop device with the LO_FLAGS_PARTSCAN flag by default, or at least when
stale partition info is found by tst_find_free_loopdev().

 testcases/kernel/syscalls/ioctl/ioctl09.c      | 12 +++++++++++-
 testcases/kernel/syscalls/ioctl/ioctl_loop01.c |  6 ++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/ioctl/ioctl09.c b/testcases/kernel/syscalls/ioctl/ioctl09.c
index 9728ecb9c..09867a5c5 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl09.c
+++ b/testcases/kernel/syscalls/ioctl/ioctl09.c
@@ -19,7 +19,7 @@
        ({ value ? TST_RETVAL_EQ0(x) : TST_RETVAL_NOTNULL(x); })
 
 static char dev_path[1024];
-static int dev_num, attach_flag, dev_fd;
+static int dev_num = -1, attach_flag, dev_fd;
 static char loop_partpath[1026], sys_loop_partpath[1026];
 
 static void change_partition(const char *const cmd[])
@@ -102,6 +102,16 @@ static void cleanup(void)
 		SAFE_CLOSE(dev_fd);
 	if (attach_flag)
 		tst_detach_device(dev_path);
+
+	if (dev_num < 0)
+		return;
+
+	sprintf(sys_loop_partpath, "/sys/block/loop%d/loop%dp1", dev_num,
+		dev_num);
+	sprintf(loop_partpath, "%sp1", dev_path);
+
+	if (!access(sys_loop_partpath, F_OK) || !access(loop_partpath, F_OK))
+		tst_res(TWARN, "Partition info was not cleared from loop dev");
 }
 
 static struct tst_test test = {
diff --git a/testcases/kernel/syscalls/ioctl/ioctl_loop01.c b/testcases/kernel/syscalls/ioctl/ioctl_loop01.c
index 734d803d5..17168ae04 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl_loop01.c
+++ b/testcases/kernel/syscalls/ioctl/ioctl_loop01.c
@@ -135,6 +135,12 @@ static void cleanup(void)
 		SAFE_CLOSE(dev_fd);
 	if (attach_flag)
 		tst_detach_device(dev_path);
+
+	if (!*sys_loop_partpath || !*loop_partpath)
+		return;
+
+	if (!access(sys_loop_partpath, F_OK) || !access(loop_partpath, F_OK))
+		tst_res(TWARN, "Partition info was not cleared from loop dev");
 }
 
 static struct tst_test test = {
-- 
2.35.1


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

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

end of thread, other threads:[~2022-10-10 10:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-06 11:08 [LTP] [PATCH] syscalls: Check for leftover partition info in loopdev ioctl tests Martin Doucha
2022-04-19  7:09 ` Petr Vorel
2022-04-25 15:21 ` Cyril Hrubis
2022-04-26 16:14   ` Martin Doucha
2022-10-10 10:29     ` Richard Palethorpe

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