All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 0/3] inotify tests for v5.9 regression
@ 2020-12-18  7:06 Amir Goldstein
  2020-12-18  7:06 ` [LTP] [PATCH 1/3] syscalls/inotify10: Generalize for more test cases Amir Goldstein
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Amir Goldstein @ 2020-12-18  7:06 UTC (permalink / raw)
  To: ltp

Hi Petr,

Here is the test for the other v5.9 regression that I mentioned earlier.
The fix commit has just been merged to master.

History:
Originally, inotify10 was written to cover a bug that was detected during
the review of the fsnotify changes for v5.9, but was not merged to v5.9.
Later, I wrote test case #3 to cover another bug that was merged to v5.9.
While testing the v5.9-bug-fix in linux-next, Hugh Dickins reported [1]
a bug introduced by the v5.9-bug-fix, so I added two more test cases
to cover the bug-in-the-bug-fix.
The bug-in-the-bug-fix was fixed before the v5.9-bug-fix was merged.

Long story short, the only test case expected to fail is test case #3 on
kernel >= v5.9 and now fixed in master :-)

Thanks,
Amir.

[1] https://lore.kernel.org/linux-fsdevel/alpine.LSU.2.11.2012101507080.1100@eggly.anvils/

Amir Goldstein (3):
  syscalls/inotify10: Generalize for more test cases
  syscalls/inotify10: Add test cases with two groups
  syscalls/inotify10: Test two inotify groups with parent and child
    watches

 testcases/kernel/syscalls/inotify/inotify10.c | 126 ++++++++++++++----
 1 file changed, 98 insertions(+), 28 deletions(-)

-- 
2.25.1


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

* [LTP] [PATCH 1/3] syscalls/inotify10: Generalize for more test cases
  2020-12-18  7:06 [LTP] [PATCH 0/3] inotify tests for v5.9 regression Amir Goldstein
@ 2020-12-18  7:06 ` Amir Goldstein
  2020-12-18  8:32   ` Petr Vorel
  2020-12-18  7:06 ` [LTP] [PATCH 2/3] syscalls/inotify10: Add test cases with two groups Amir Goldstein
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Amir Goldstein @ 2020-12-18  7:06 UTC (permalink / raw)
  To: ltp

Generalize the parent and child watches test to allow adding new
parent and child watch related test cases.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 testcases/kernel/syscalls/inotify/inotify10.c | 81 +++++++++++++------
 1 file changed, 55 insertions(+), 26 deletions(-)

diff --git a/testcases/kernel/syscalls/inotify/inotify10.c b/testcases/kernel/syscalls/inotify/inotify10.c
index 1c43915a8..baa955a0a 100644
--- a/testcases/kernel/syscalls/inotify/inotify10.c
+++ b/testcases/kernel/syscalls/inotify/inotify10.c
@@ -5,7 +5,9 @@
  * Started by Amir Goldstein <amir73il@gmail.com>
  *
  * DESCRIPTION
- *     Check that event is reported to both watching parent and watching child
+ *     Check that event is reported to watching parent and watching child
+ *     based on their interest
+ *
  */
 
 #include "config.h"
@@ -37,48 +39,74 @@ struct event_t {
 #define	TEST_DIR	"test_dir"
 #define	TEST_FILE	"test_file"
 
+static struct tcase {
+	const char *tname;
+	unsigned int parent_mask;
+	unsigned int subdir_mask;
+	unsigned int child_mask;
+} tcases[] = {
+	{
+		"Group with parent and child watches",
+		IN_ATTRIB, IN_ATTRIB, IN_ATTRIB,
+	},
+};
+
 struct event_t event_set[EVENT_MAX];
 
 char event_buf[EVENT_BUF_LEN];
 
 int fd_notify;
 
-static void verify_inotify(void)
+static void verify_inotify(unsigned int n)
 {
+	struct tcase *tc = &tcases[n];
 	int i = 0, test_num = 0, len;
-	int wd_parent, wd_dir, wd_file;
+	int wd_parent = 0, wd_subdir = 0, wd_child = 0;
 	int test_cnt = 0;
 
+	tst_res(TINFO, "Test #%d: %s", n, tc->tname);
+
 	fd_notify = SAFE_MYINOTIFY_INIT();
 
-	/* Set watch on both parent dir and children */
-	wd_parent = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, ".", IN_ATTRIB);
-	wd_dir = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, TEST_DIR, IN_ATTRIB);
-	wd_file = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, TEST_FILE, IN_ATTRIB);
+	/* Setup watches on parent dir and children */
+	if (tc->parent_mask)
+		wd_parent = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, ".", tc->parent_mask);
+	if (tc->subdir_mask)
+		wd_subdir = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, TEST_DIR, tc->subdir_mask);
+	if (tc->child_mask)
+		wd_child = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, TEST_FILE, tc->child_mask);
 
 	/*
-	 * Generate events on file and subdir that should be reported to parent
-	 * dir with name and to children without name.
+	 * Generate IN_ATTRIB events on file and subdir that should be reported to parent
+	 * dir with name and to children without name if they have IN_ATTRIB in their mask.
 	 */
 	SAFE_CHMOD(TEST_DIR, 0755);
 	SAFE_CHMOD(TEST_FILE, 0644);
 
-	event_set[test_cnt].wd = wd_parent;
-	event_set[test_cnt].mask = IN_ATTRIB | IN_ISDIR;
-	strcpy(event_set[test_cnt].name, TEST_DIR);
-	test_cnt++;
-	event_set[test_cnt].wd = wd_dir;
-	event_set[test_cnt].mask = IN_ATTRIB | IN_ISDIR;
-	strcpy(event_set[test_cnt].name, "");
-	test_cnt++;
-	event_set[test_cnt].wd = wd_parent;
-	event_set[test_cnt].mask = IN_ATTRIB;
-	strcpy(event_set[test_cnt].name, TEST_FILE);
-	test_cnt++;
-	event_set[test_cnt].wd = wd_file;
-	event_set[test_cnt].mask = IN_ATTRIB;
-	strcpy(event_set[test_cnt].name, "");
-	test_cnt++;
+	if (wd_parent && (tc->parent_mask & IN_ATTRIB)) {
+		event_set[test_cnt].wd = wd_parent;
+		event_set[test_cnt].mask = tc->parent_mask | IN_ISDIR;
+		strcpy(event_set[test_cnt].name, TEST_DIR);
+		test_cnt++;
+	}
+	if (wd_subdir && (tc->subdir_mask & IN_ATTRIB)) {
+		event_set[test_cnt].wd = wd_subdir;
+		event_set[test_cnt].mask = tc->subdir_mask | IN_ISDIR;
+		strcpy(event_set[test_cnt].name, "");
+		test_cnt++;
+	}
+	if (wd_parent && (tc->parent_mask & IN_ATTRIB)) {
+		event_set[test_cnt].wd = wd_parent;
+		event_set[test_cnt].mask = tc->parent_mask;
+		strcpy(event_set[test_cnt].name, TEST_FILE);
+		test_cnt++;
+	}
+	if (wd_child && (tc->child_mask & IN_ATTRIB)) {
+		event_set[test_cnt].wd = wd_child;
+		event_set[test_cnt].mask = tc->child_mask;
+		strcpy(event_set[test_cnt].name, "");
+		test_cnt++;
+	}
 
 	len = read(fd_notify, event_buf, EVENT_BUF_LEN);
 	if (len == -1)
@@ -141,7 +169,8 @@ static struct tst_test test = {
 	.needs_tmpdir = 1,
 	.setup = setup,
 	.cleanup = cleanup,
-	.test_all = verify_inotify,
+	.test = verify_inotify,
+	.tcnt = ARRAY_SIZE(tcases),
 };
 
 #else
-- 
2.25.1


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

* [LTP] [PATCH 2/3] syscalls/inotify10: Add test cases with two groups
  2020-12-18  7:06 [LTP] [PATCH 0/3] inotify tests for v5.9 regression Amir Goldstein
  2020-12-18  7:06 ` [LTP] [PATCH 1/3] syscalls/inotify10: Generalize for more test cases Amir Goldstein
@ 2020-12-18  7:06 ` Amir Goldstein
  2020-12-18  8:36   ` Petr Vorel
  2020-12-18  7:06 ` [LTP] [PATCH 3/3] syscalls/inotify10: Test two inotify groups with parent and child watches Amir Goldstein
  2020-12-18  9:01 ` [LTP] [PATCH 0/3] inotify tests for v5.9 regression Petr Vorel
  3 siblings, 1 reply; 9+ messages in thread
From: Amir Goldstein @ 2020-12-18  7:06 UTC (permalink / raw)
  To: ltp

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 testcases/kernel/syscalls/inotify/inotify10.c | 30 ++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/inotify/inotify10.c b/testcases/kernel/syscalls/inotify/inotify10.c
index baa955a0a..17aafc773 100644
--- a/testcases/kernel/syscalls/inotify/inotify10.c
+++ b/testcases/kernel/syscalls/inotify/inotify10.c
@@ -44,10 +44,24 @@ static struct tcase {
 	unsigned int parent_mask;
 	unsigned int subdir_mask;
 	unsigned int child_mask;
+	unsigned int parent_mask_other;
+	unsigned int subdir_mask_other;
+	unsigned int child_mask_other;
 } tcases[] = {
 	{
 		"Group with parent and child watches",
 		IN_ATTRIB, IN_ATTRIB, IN_ATTRIB,
+		0, 0, 0,
+	},
+	{
+		"Group with child watches and other group with parent watch",
+		0, IN_ATTRIB, IN_ATTRIB,
+		IN_ATTRIB, 0, 0,
+	},
+	{
+		"Group with parent watch and other group with child watches",
+		IN_ATTRIB, 0, 0,
+		0, IN_ATTRIB, IN_ATTRIB,
 	},
 };
 
@@ -55,7 +69,7 @@ struct event_t event_set[EVENT_MAX];
 
 char event_buf[EVENT_BUF_LEN];
 
-int fd_notify;
+int fd_notify, fd_notify_other;
 
 static void verify_inotify(unsigned int n)
 {
@@ -67,6 +81,7 @@ static void verify_inotify(unsigned int n)
 	tst_res(TINFO, "Test #%d: %s", n, tc->tname);
 
 	fd_notify = SAFE_MYINOTIFY_INIT();
+	fd_notify_other = SAFE_MYINOTIFY_INIT();
 
 	/* Setup watches on parent dir and children */
 	if (tc->parent_mask)
@@ -75,6 +90,16 @@ static void verify_inotify(unsigned int n)
 		wd_subdir = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, TEST_DIR, tc->subdir_mask);
 	if (tc->child_mask)
 		wd_child = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, TEST_FILE, tc->child_mask);
+	/*
+	 * Setup watches on "other" group to verify no intereferecne with our group.
+	 * We do not check events reported to the "other" group.
+	 */
+	if (tc->parent_mask_other)
+		SAFE_MYINOTIFY_ADD_WATCH(fd_notify_other, ".", tc->parent_mask_other);
+	if (tc->subdir_mask_other)
+		SAFE_MYINOTIFY_ADD_WATCH(fd_notify_other, TEST_DIR, tc->subdir_mask_other);
+	if (tc->child_mask_other)
+		SAFE_MYINOTIFY_ADD_WATCH(fd_notify_other, TEST_FILE, tc->child_mask_other);
 
 	/*
 	 * Generate IN_ATTRIB events on file and subdir that should be reported to parent
@@ -151,6 +176,7 @@ static void verify_inotify(unsigned int n)
 	}
 
 	SAFE_CLOSE(fd_notify);
+	SAFE_CLOSE(fd_notify_other);
 }
 
 static void setup(void)
@@ -163,6 +189,8 @@ static void cleanup(void)
 {
 	if (fd_notify > 0)
 		SAFE_CLOSE(fd_notify);
+	if (fd_notify_other > 0)
+		SAFE_CLOSE(fd_notify_other);
 }
 
 static struct tst_test test = {
-- 
2.25.1


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

* [LTP] [PATCH 3/3] syscalls/inotify10: Test two inotify groups with parent and child watches
  2020-12-18  7:06 [LTP] [PATCH 0/3] inotify tests for v5.9 regression Amir Goldstein
  2020-12-18  7:06 ` [LTP] [PATCH 1/3] syscalls/inotify10: Generalize for more test cases Amir Goldstein
  2020-12-18  7:06 ` [LTP] [PATCH 2/3] syscalls/inotify10: Add test cases with two groups Amir Goldstein
@ 2020-12-18  7:06 ` Amir Goldstein
  2020-12-18  8:53   ` Petr Vorel
  2020-12-18  9:01 ` [LTP] [PATCH 0/3] inotify tests for v5.9 regression Petr Vorel
  3 siblings, 1 reply; 9+ messages in thread
From: Amir Goldstein @ 2020-12-18  7:06 UTC (permalink / raw)
  To: ltp

Add a test case for commit fecc4559780d that fixes a bug introduced in
kernel v5.9:

     fsnotify: fix events reported to watching parent and child

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 testcases/kernel/syscalls/inotify/inotify10.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/testcases/kernel/syscalls/inotify/inotify10.c b/testcases/kernel/syscalls/inotify/inotify10.c
index 17aafc773..eb2322090 100644
--- a/testcases/kernel/syscalls/inotify/inotify10.c
+++ b/testcases/kernel/syscalls/inotify/inotify10.c
@@ -8,6 +8,10 @@
  *     Check that event is reported to watching parent and watching child
  *     based on their interest
  *
+ * Test case #3 is a regression test for commit fecc4559780d that fixes
+ * a bug introduced in kernel v5.9:
+ *
+ *     fsnotify: fix events reported to watching parent and child
  */
 
 #include "config.h"
@@ -63,6 +67,11 @@ static struct tcase {
 		IN_ATTRIB, 0, 0,
 		0, IN_ATTRIB, IN_ATTRIB,
 	},
+	{
+		"Two Groups with parent and child watches for different events",
+		IN_ATTRIB, IN_OPEN, IN_OPEN,
+		IN_OPEN, IN_ATTRIB, IN_ATTRIB,
+	},
 };
 
 struct event_t event_set[EVENT_MAX];
@@ -199,6 +208,10 @@ static struct tst_test test = {
 	.cleanup = cleanup,
 	.test = verify_inotify,
 	.tcnt = ARRAY_SIZE(tcases),
+	.tags = (const struct tst_tag[]) {
+		{"linux-git", "fecc4559780d"},
+		{}
+	}
 };
 
 #else
-- 
2.25.1


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

* [LTP] [PATCH 1/3] syscalls/inotify10: Generalize for more test cases
  2020-12-18  7:06 ` [LTP] [PATCH 1/3] syscalls/inotify10: Generalize for more test cases Amir Goldstein
@ 2020-12-18  8:32   ` Petr Vorel
  0 siblings, 0 replies; 9+ messages in thread
From: Petr Vorel @ 2020-12-18  8:32 UTC (permalink / raw)
  To: ltp

Hi Amir,

> Generalize the parent and child watches test to allow adding new
> parent and child watch related test cases.

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr

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

* [LTP] [PATCH 2/3] syscalls/inotify10: Add test cases with two groups
  2020-12-18  7:06 ` [LTP] [PATCH 2/3] syscalls/inotify10: Add test cases with two groups Amir Goldstein
@ 2020-12-18  8:36   ` Petr Vorel
  0 siblings, 0 replies; 9+ messages in thread
From: Petr Vorel @ 2020-12-18  8:36 UTC (permalink / raw)
  To: ltp

Hi Amir,

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr

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

* [LTP] [PATCH 3/3] syscalls/inotify10: Test two inotify groups with parent and child watches
  2020-12-18  7:06 ` [LTP] [PATCH 3/3] syscalls/inotify10: Test two inotify groups with parent and child watches Amir Goldstein
@ 2020-12-18  8:53   ` Petr Vorel
  0 siblings, 0 replies; 9+ messages in thread
From: Petr Vorel @ 2020-12-18  8:53 UTC (permalink / raw)
  To: ltp

Hi Amir,

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr

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

* [LTP] [PATCH 0/3] inotify tests for v5.9 regression
  2020-12-18  7:06 [LTP] [PATCH 0/3] inotify tests for v5.9 regression Amir Goldstein
                   ` (2 preceding siblings ...)
  2020-12-18  7:06 ` [LTP] [PATCH 3/3] syscalls/inotify10: Test two inotify groups with parent and child watches Amir Goldstein
@ 2020-12-18  9:01 ` Petr Vorel
  2020-12-18 16:23   ` Petr Vorel
  3 siblings, 1 reply; 9+ messages in thread
From: Petr Vorel @ 2020-12-18  9:01 UTC (permalink / raw)
  To: ltp

Hi Amir,

> Hi Petr,

> Here is the test for the other v5.9 regression that I mentioned earlier.
> The fix commit has just been merged to master.
Thanks for your patch, LGTM. I'll probably merge it later today.

> History:
> Originally, inotify10 was written to cover a bug that was detected during
> the review of the fsnotify changes for v5.9, but was not merged to v5.9.
> Later, I wrote test case #3 to cover another bug that was merged to v5.9.
> While testing the v5.9-bug-fix in linux-next, Hugh Dickins reported [1]
> a bug introduced by the v5.9-bug-fix, so I added two more test cases
> to cover the bug-in-the-bug-fix.
> The bug-in-the-bug-fix was fixed before the v5.9-bug-fix was merged.

> Long story short, the only test case expected to fail is test case #3 on
> kernel >= v5.9 and now fixed in master :-)
Correct, it fails on my openSUSE 5.10.0-rc5 kernel.
I tested it on someold kernels (patched 4.4; 4.9) and on some newer ones
(5.8.14 and on current devel SLES kernel).

BTW interesting (nothing to be fixed in the test) that second commit slower down
on newer kernels (0,200s), while on old kernels is the same (0.010s).

Kind regards,
Petr

> Thanks,
> Amir.

> [1] https://lore.kernel.org/linux-fsdevel/alpine.LSU.2.11.2012101507080.1100@eggly.anvils/

> Amir Goldstein (3):
>   syscalls/inotify10: Generalize for more test cases
>   syscalls/inotify10: Add test cases with two groups
>   syscalls/inotify10: Test two inotify groups with parent and child
>     watches

>  testcases/kernel/syscalls/inotify/inotify10.c | 126 ++++++++++++++----
>  1 file changed, 98 insertions(+), 28 deletions(-)

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

* [LTP] [PATCH 0/3] inotify tests for v5.9 regression
  2020-12-18  9:01 ` [LTP] [PATCH 0/3] inotify tests for v5.9 regression Petr Vorel
@ 2020-12-18 16:23   ` Petr Vorel
  0 siblings, 0 replies; 9+ messages in thread
From: Petr Vorel @ 2020-12-18 16:23 UTC (permalink / raw)
  To: ltp

Hi Amir,

> > Hi Petr,

> > Here is the test for the other v5.9 regression that I mentioned earlier.
> > The fix commit has just been merged to master.
> Thanks for your patch, LGTM. I'll probably merge it later today.
Merged.

Thanks for your pathset. I wish other kernel subsystems were getting the
same care as {fa,i}notify.

Kind regards,
Petr

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

end of thread, other threads:[~2020-12-18 16:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-18  7:06 [LTP] [PATCH 0/3] inotify tests for v5.9 regression Amir Goldstein
2020-12-18  7:06 ` [LTP] [PATCH 1/3] syscalls/inotify10: Generalize for more test cases Amir Goldstein
2020-12-18  8:32   ` Petr Vorel
2020-12-18  7:06 ` [LTP] [PATCH 2/3] syscalls/inotify10: Add test cases with two groups Amir Goldstein
2020-12-18  8:36   ` Petr Vorel
2020-12-18  7:06 ` [LTP] [PATCH 3/3] syscalls/inotify10: Test two inotify groups with parent and child watches Amir Goldstein
2020-12-18  8:53   ` Petr Vorel
2020-12-18  9:01 ` [LTP] [PATCH 0/3] inotify tests for v5.9 regression Petr Vorel
2020-12-18 16:23   ` Petr Vorel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.