diff mbox series

[3/5] syscalls/fanotify10: Watch directory that is not the mount path

Message ID 20220613143826.1328830-4-amir73il@gmail.com
State Accepted
Headers show
Series Fanotify tests for FAN_MARK_EVICTABLE | expand

Commit Message

Amir Goldstein June 13, 2022, 2:38 p.m. UTC
Move the test file into a test directory, so we won't set a mark
on the mount path when watching the children of a directory.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 .../kernel/syscalls/fanotify/fanotify10.c     | 28 +++++++++++--------
 1 file changed, 16 insertions(+), 12 deletions(-)

Comments

Jan Kara June 14, 2022, 10:26 a.m. UTC | #1
On Mon 13-06-22 17:38:24, Amir Goldstein wrote:
> Move the test file into a test directory, so we won't set a mark
> on the mount path when watching the children of a directory.
> 
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>

One question below...

> diff --git a/testcases/kernel/syscalls/fanotify/fanotify10.c b/testcases/kernel/syscalls/fanotify/fanotify10.c
> index 067dd65ae..efef25135 100644
> --- a/testcases/kernel/syscalls/fanotify/fanotify10.c
> +++ b/testcases/kernel/syscalls/fanotify/fanotify10.c
> @@ -74,16 +74,19 @@ static int filesystem_mark_unsupported;
>  
>  #define MOUNT_PATH "fs_mnt"
>  #define MNT2_PATH "mntpoint"
> +#define DIR_NAME "testdir"
>  #define FILE_NAME "testfile"
>  #define FILE2_NAME "testfile2"
>  #define TEST_APP "fanotify_child"
>  #define TEST_APP2 "fanotify_child2"
> -#define FILE_PATH MOUNT_PATH"/"FILE_NAME
> -#define FILE2_PATH MOUNT_PATH"/"FILE2_NAME
> +#define DIR_PATH MOUNT_PATH"/"DIR_NAME
> +#define FILE_PATH DIR_PATH"/"FILE_NAME
> +#define FILE2_PATH DIR_PATH"/"FILE2_NAME
>  #define FILE_EXEC_PATH MOUNT_PATH"/"TEST_APP
>  #define FILE2_EXEC_PATH MOUNT_PATH"/"TEST_APP2
> -#define FILE_MNT2 MNT2_PATH"/"FILE_NAME
> -#define FILE2_MNT2 MNT2_PATH"/"FILE2_NAME
> +#define DIR_MNT2 MNT2_PATH"/"DIR_NAME
> +#define FILE_MNT2 DIR_MNT2"/"FILE_NAME
> +#define FILE2_MNT2 DIR_MNT2"/"FILE2_NAME
>  #define FILE_EXEC_PATH2 MNT2_PATH"/"TEST_APP
>  #define FILE2_EXEC_PATH2 MNT2_PATH"/"TEST_APP2
>  
> @@ -239,50 +242,50 @@ static struct tcase {
>  	},
>  	{
>  		"ignore events on children of directory created on a specific file",
> -		MNT2_PATH, FANOTIFY_INODE,
> -		FILE_PATH, FANOTIFY_INODE,
> +		DIR_MNT2, FANOTIFY_INODE,
> +		DIR_PATH, FANOTIFY_INODE,

I'm somewhat confused here why you remove the FILE_PATH test here... In all
the other tests you just replace MNT2_PATH with DIR_PATH which makes sense.

								Honza

>  		FAN_EVENT_ON_CHILD,
>  		FILE_PATH, 0, FAN_OPEN
>  	},
>  	{
>  		"ignore events on file created inside a parent watching children",
>  		FILE_PATH, FANOTIFY_INODE,
> -		MNT2_PATH, FANOTIFY_INODE,
> +		DIR_PATH, FANOTIFY_INODE,
>  		FAN_EVENT_ON_CHILD,
>  		FILE_PATH, 0, FAN_OPEN
>  	},
>  	{
>  		"don't ignore events on file created inside a parent not watching children",
>  		FILE_PATH, FANOTIFY_INODE,
> -		MNT2_PATH, FANOTIFY_INODE,
> +		DIR_PATH, FANOTIFY_INODE,
>  		0,
>  		FILE_PATH, FAN_OPEN, FAN_OPEN
>  	},
>  	{
>  		"ignore mount events created inside a parent watching children",
>  		FILE_PATH, FANOTIFY_MOUNT,
> -		MNT2_PATH, FANOTIFY_INODE,
> +		DIR_PATH, FANOTIFY_INODE,
>  		FAN_EVENT_ON_CHILD,
>  		FILE_PATH, 0, FAN_OPEN
>  	},
>  	{
>  		"don't ignore mount events created inside a parent not watching children",
>  		FILE_PATH, FANOTIFY_MOUNT,
> -		MNT2_PATH, FANOTIFY_INODE,
> +		DIR_PATH, FANOTIFY_INODE,
>  		0,
>  		FILE_PATH, FAN_OPEN, FAN_OPEN
>  	},
>  	{
>  		"ignore fs events created inside a parent watching children",
>  		FILE_PATH, FANOTIFY_FILESYSTEM,
> -		MNT2_PATH, FANOTIFY_INODE,
> +		DIR_PATH, FANOTIFY_INODE,
>  		FAN_EVENT_ON_CHILD,
>  		FILE_PATH, 0, FAN_OPEN
>  	},
>  	{
>  		"don't ignore fs events created inside a parent not watching children",
>  		FILE_PATH, FANOTIFY_FILESYSTEM,
> -		MNT2_PATH, FANOTIFY_INODE,
> +		DIR_PATH, FANOTIFY_INODE,
>  		0,
>  		FILE_PATH, FAN_OPEN, FAN_OPEN
>  	},
> @@ -525,6 +528,7 @@ static void setup(void)
>  	SAFE_MOUNT(MOUNT_PATH, MNT2_PATH, "none", MS_BIND, NULL);
>  	bind_mount_created = 1;
>  
> +	SAFE_MKDIR(DIR_PATH, 0755);
>  	SAFE_FILE_PRINTF(FILE_PATH, "1");
>  	SAFE_FILE_PRINTF(FILE2_PATH, "1");
>  
> -- 
> 2.25.1
>
Amir Goldstein June 14, 2022, 11:10 a.m. UTC | #2
On Tue, Jun 14, 2022 at 1:26 PM Jan Kara <jack@suse.cz> wrote:
>
> On Mon 13-06-22 17:38:24, Amir Goldstein wrote:
> > Move the test file into a test directory, so we won't set a mark
> > on the mount path when watching the children of a directory.
> >
> > Signed-off-by: Amir Goldstein <amir73il@gmail.com>
>
> One question below...
>
> > diff --git a/testcases/kernel/syscalls/fanotify/fanotify10.c b/testcases/kernel/syscalls/fanotify/fanotify10.c
> > index 067dd65ae..efef25135 100644
> > --- a/testcases/kernel/syscalls/fanotify/fanotify10.c
> > +++ b/testcases/kernel/syscalls/fanotify/fanotify10.c
> > @@ -74,16 +74,19 @@ static int filesystem_mark_unsupported;
> >
> >  #define MOUNT_PATH "fs_mnt"
> >  #define MNT2_PATH "mntpoint"
> > +#define DIR_NAME "testdir"
> >  #define FILE_NAME "testfile"
> >  #define FILE2_NAME "testfile2"
> >  #define TEST_APP "fanotify_child"
> >  #define TEST_APP2 "fanotify_child2"
> > -#define FILE_PATH MOUNT_PATH"/"FILE_NAME
> > -#define FILE2_PATH MOUNT_PATH"/"FILE2_NAME
> > +#define DIR_PATH MOUNT_PATH"/"DIR_NAME
> > +#define FILE_PATH DIR_PATH"/"FILE_NAME
> > +#define FILE2_PATH DIR_PATH"/"FILE2_NAME
> >  #define FILE_EXEC_PATH MOUNT_PATH"/"TEST_APP
> >  #define FILE2_EXEC_PATH MOUNT_PATH"/"TEST_APP2
> > -#define FILE_MNT2 MNT2_PATH"/"FILE_NAME
> > -#define FILE2_MNT2 MNT2_PATH"/"FILE2_NAME
> > +#define DIR_MNT2 MNT2_PATH"/"DIR_NAME
> > +#define FILE_MNT2 DIR_MNT2"/"FILE_NAME
> > +#define FILE2_MNT2 DIR_MNT2"/"FILE2_NAME
> >  #define FILE_EXEC_PATH2 MNT2_PATH"/"TEST_APP
> >  #define FILE2_EXEC_PATH2 MNT2_PATH"/"TEST_APP2
> >
> > @@ -239,50 +242,50 @@ static struct tcase {
> >       },
> >       {
> >               "ignore events on children of directory created on a specific file",
> > -             MNT2_PATH, FANOTIFY_INODE,
> > -             FILE_PATH, FANOTIFY_INODE,
> > +             DIR_MNT2, FANOTIFY_INODE,
> > +             DIR_PATH, FANOTIFY_INODE,
> >               FAN_EVENT_ON_CHILD,
> >               FILE_PATH, 0, FAN_OPEN
> >       },
>
> I'm somewhat confused here why you remove the FILE_PATH test here... In all
> the other tests you just replace MNT2_PATH with DIR_PATH which makes sense.
>

Good question.
I guess while doing the conversion, I realized that the test case definition
was wrong, so I fixed it and forgot to mention it in the commit message.

The test case (#17) should be placing an ignored mask on a directory
(DIR_PATH) with FAN_EVENT_ON_CHILD and see that the event on
a child (FILE_PATH) is ignored.

But what the test case was doing is setting an ignored mask
with FAN_EVENT_ON_CHILD on the child (FILE_PATH).

Petr,

Do you want to add this to the commit message?
Or split to a separate patch?

Thanks,
Amir.
Petr Vorel June 16, 2022, 1:31 p.m. UTC | #3
> On Tue, Jun 14, 2022 at 1:26 PM Jan Kara <jack@suse.cz> wrote:

> > On Mon 13-06-22 17:38:24, Amir Goldstein wrote:
> > > Move the test file into a test directory, so we won't set a mark
> > > on the mount path when watching the children of a directory.

> > > Signed-off-by: Amir Goldstein <amir73il@gmail.com>

> > One question below...

> > > diff --git a/testcases/kernel/syscalls/fanotify/fanotify10.c b/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > index 067dd65ae..efef25135 100644
> > > --- a/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > +++ b/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > @@ -74,16 +74,19 @@ static int filesystem_mark_unsupported;

> > >  #define MOUNT_PATH "fs_mnt"
> > >  #define MNT2_PATH "mntpoint"
> > > +#define DIR_NAME "testdir"
> > >  #define FILE_NAME "testfile"
> > >  #define FILE2_NAME "testfile2"
> > >  #define TEST_APP "fanotify_child"
> > >  #define TEST_APP2 "fanotify_child2"
> > > -#define FILE_PATH MOUNT_PATH"/"FILE_NAME
> > > -#define FILE2_PATH MOUNT_PATH"/"FILE2_NAME
> > > +#define DIR_PATH MOUNT_PATH"/"DIR_NAME
> > > +#define FILE_PATH DIR_PATH"/"FILE_NAME
> > > +#define FILE2_PATH DIR_PATH"/"FILE2_NAME
> > >  #define FILE_EXEC_PATH MOUNT_PATH"/"TEST_APP
> > >  #define FILE2_EXEC_PATH MOUNT_PATH"/"TEST_APP2
> > > -#define FILE_MNT2 MNT2_PATH"/"FILE_NAME
> > > -#define FILE2_MNT2 MNT2_PATH"/"FILE2_NAME
> > > +#define DIR_MNT2 MNT2_PATH"/"DIR_NAME
> > > +#define FILE_MNT2 DIR_MNT2"/"FILE_NAME
> > > +#define FILE2_MNT2 DIR_MNT2"/"FILE2_NAME
> > >  #define FILE_EXEC_PATH2 MNT2_PATH"/"TEST_APP
> > >  #define FILE2_EXEC_PATH2 MNT2_PATH"/"TEST_APP2

> > > @@ -239,50 +242,50 @@ static struct tcase {
> > >       },
> > >       {
> > >               "ignore events on children of directory created on a specific file",
> > > -             MNT2_PATH, FANOTIFY_INODE,
> > > -             FILE_PATH, FANOTIFY_INODE,
> > > +             DIR_MNT2, FANOTIFY_INODE,
> > > +             DIR_PATH, FANOTIFY_INODE,
> > >               FAN_EVENT_ON_CHILD,
> > >               FILE_PATH, 0, FAN_OPEN
> > >       },

> > I'm somewhat confused here why you remove the FILE_PATH test here... In all
> > the other tests you just replace MNT2_PATH with DIR_PATH which makes sense.


> Good question.
> I guess while doing the conversion, I realized that the test case definition
> was wrong, so I fixed it and forgot to mention it in the commit message.

> The test case (#17) should be placing an ignored mask on a directory
> (DIR_PATH) with FAN_EVENT_ON_CHILD and see that the event on
> a child (FILE_PATH) is ignored.

> But what the test case was doing is setting an ignored mask
> with FAN_EVENT_ON_CHILD on the child (FILE_PATH).

> Petr,

> Do you want to add this to the commit message?
> Or split to a separate patch?

Both ways work for me. Could you please rebase your LTP fork, do either of these
changes and ping me to pull?

Thx!

Petr

> Thanks,
> Amir.
Amir Goldstein June 16, 2022, 1:46 p.m. UTC | #4
On Thu, Jun 16, 2022 at 4:31 PM Petr Vorel <pvorel@suse.cz> wrote:
>
> > On Tue, Jun 14, 2022 at 1:26 PM Jan Kara <jack@suse.cz> wrote:
>
> > > On Mon 13-06-22 17:38:24, Amir Goldstein wrote:
> > > > Move the test file into a test directory, so we won't set a mark
> > > > on the mount path when watching the children of a directory.
>
> > > > Signed-off-by: Amir Goldstein <amir73il@gmail.com>
>
> > > One question below...
>
> > > > diff --git a/testcases/kernel/syscalls/fanotify/fanotify10.c b/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > > index 067dd65ae..efef25135 100644
> > > > --- a/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > > +++ b/testcases/kernel/syscalls/fanotify/fanotify10.c
> > > > @@ -74,16 +74,19 @@ static int filesystem_mark_unsupported;
>
> > > >  #define MOUNT_PATH "fs_mnt"
> > > >  #define MNT2_PATH "mntpoint"
> > > > +#define DIR_NAME "testdir"
> > > >  #define FILE_NAME "testfile"
> > > >  #define FILE2_NAME "testfile2"
> > > >  #define TEST_APP "fanotify_child"
> > > >  #define TEST_APP2 "fanotify_child2"
> > > > -#define FILE_PATH MOUNT_PATH"/"FILE_NAME
> > > > -#define FILE2_PATH MOUNT_PATH"/"FILE2_NAME
> > > > +#define DIR_PATH MOUNT_PATH"/"DIR_NAME
> > > > +#define FILE_PATH DIR_PATH"/"FILE_NAME
> > > > +#define FILE2_PATH DIR_PATH"/"FILE2_NAME
> > > >  #define FILE_EXEC_PATH MOUNT_PATH"/"TEST_APP
> > > >  #define FILE2_EXEC_PATH MOUNT_PATH"/"TEST_APP2
> > > > -#define FILE_MNT2 MNT2_PATH"/"FILE_NAME
> > > > -#define FILE2_MNT2 MNT2_PATH"/"FILE2_NAME
> > > > +#define DIR_MNT2 MNT2_PATH"/"DIR_NAME
> > > > +#define FILE_MNT2 DIR_MNT2"/"FILE_NAME
> > > > +#define FILE2_MNT2 DIR_MNT2"/"FILE2_NAME
> > > >  #define FILE_EXEC_PATH2 MNT2_PATH"/"TEST_APP
> > > >  #define FILE2_EXEC_PATH2 MNT2_PATH"/"TEST_APP2
>
> > > > @@ -239,50 +242,50 @@ static struct tcase {
> > > >       },
> > > >       {
> > > >               "ignore events on children of directory created on a specific file",
> > > > -             MNT2_PATH, FANOTIFY_INODE,
> > > > -             FILE_PATH, FANOTIFY_INODE,
> > > > +             DIR_MNT2, FANOTIFY_INODE,
> > > > +             DIR_PATH, FANOTIFY_INODE,
> > > >               FAN_EVENT_ON_CHILD,
> > > >               FILE_PATH, 0, FAN_OPEN
> > > >       },
>
> > > I'm somewhat confused here why you remove the FILE_PATH test here... In all
> > > the other tests you just replace MNT2_PATH with DIR_PATH which makes sense.
>
>
> > Good question.
> > I guess while doing the conversion, I realized that the test case definition
> > was wrong, so I fixed it and forgot to mention it in the commit message.
>
> > The test case (#17) should be placing an ignored mask on a directory
> > (DIR_PATH) with FAN_EVENT_ON_CHILD and see that the event on
> > a child (FILE_PATH) is ignored.
>
> > But what the test case was doing is setting an ignored mask
> > with FAN_EVENT_ON_CHILD on the child (FILE_PATH).
>
> > Petr,
>
> > Do you want to add this to the commit message?
> > Or split to a separate patch?
>
> Both ways work for me. Could you please rebase your LTP fork, do either of these
> changes and ping me to pull?

Done:
https://github.com/amir73il/ltp/commits/fan_evictable

Thanks,
Amir.
Petr Vorel June 16, 2022, 4:57 p.m. UTC | #5
Hi Amir,

...
> > Both ways work for me. Could you please rebase your LTP fork, do either of these
> > changes and ping me to pull?

> Done:
> https://github.com/amir73il/ltp/commits/fan_evictable

Thanks a lot, merged!

Kind regards,
Petr

> Thanks,
> Amir.
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/fanotify/fanotify10.c b/testcases/kernel/syscalls/fanotify/fanotify10.c
index 067dd65ae..efef25135 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify10.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify10.c
@@ -74,16 +74,19 @@  static int filesystem_mark_unsupported;
 
 #define MOUNT_PATH "fs_mnt"
 #define MNT2_PATH "mntpoint"
+#define DIR_NAME "testdir"
 #define FILE_NAME "testfile"
 #define FILE2_NAME "testfile2"
 #define TEST_APP "fanotify_child"
 #define TEST_APP2 "fanotify_child2"
-#define FILE_PATH MOUNT_PATH"/"FILE_NAME
-#define FILE2_PATH MOUNT_PATH"/"FILE2_NAME
+#define DIR_PATH MOUNT_PATH"/"DIR_NAME
+#define FILE_PATH DIR_PATH"/"FILE_NAME
+#define FILE2_PATH DIR_PATH"/"FILE2_NAME
 #define FILE_EXEC_PATH MOUNT_PATH"/"TEST_APP
 #define FILE2_EXEC_PATH MOUNT_PATH"/"TEST_APP2
-#define FILE_MNT2 MNT2_PATH"/"FILE_NAME
-#define FILE2_MNT2 MNT2_PATH"/"FILE2_NAME
+#define DIR_MNT2 MNT2_PATH"/"DIR_NAME
+#define FILE_MNT2 DIR_MNT2"/"FILE_NAME
+#define FILE2_MNT2 DIR_MNT2"/"FILE2_NAME
 #define FILE_EXEC_PATH2 MNT2_PATH"/"TEST_APP
 #define FILE2_EXEC_PATH2 MNT2_PATH"/"TEST_APP2
 
@@ -239,50 +242,50 @@  static struct tcase {
 	},
 	{
 		"ignore events on children of directory created on a specific file",
-		MNT2_PATH, FANOTIFY_INODE,
-		FILE_PATH, FANOTIFY_INODE,
+		DIR_MNT2, FANOTIFY_INODE,
+		DIR_PATH, FANOTIFY_INODE,
 		FAN_EVENT_ON_CHILD,
 		FILE_PATH, 0, FAN_OPEN
 	},
 	{
 		"ignore events on file created inside a parent watching children",
 		FILE_PATH, FANOTIFY_INODE,
-		MNT2_PATH, FANOTIFY_INODE,
+		DIR_PATH, FANOTIFY_INODE,
 		FAN_EVENT_ON_CHILD,
 		FILE_PATH, 0, FAN_OPEN
 	},
 	{
 		"don't ignore events on file created inside a parent not watching children",
 		FILE_PATH, FANOTIFY_INODE,
-		MNT2_PATH, FANOTIFY_INODE,
+		DIR_PATH, FANOTIFY_INODE,
 		0,
 		FILE_PATH, FAN_OPEN, FAN_OPEN
 	},
 	{
 		"ignore mount events created inside a parent watching children",
 		FILE_PATH, FANOTIFY_MOUNT,
-		MNT2_PATH, FANOTIFY_INODE,
+		DIR_PATH, FANOTIFY_INODE,
 		FAN_EVENT_ON_CHILD,
 		FILE_PATH, 0, FAN_OPEN
 	},
 	{
 		"don't ignore mount events created inside a parent not watching children",
 		FILE_PATH, FANOTIFY_MOUNT,
-		MNT2_PATH, FANOTIFY_INODE,
+		DIR_PATH, FANOTIFY_INODE,
 		0,
 		FILE_PATH, FAN_OPEN, FAN_OPEN
 	},
 	{
 		"ignore fs events created inside a parent watching children",
 		FILE_PATH, FANOTIFY_FILESYSTEM,
-		MNT2_PATH, FANOTIFY_INODE,
+		DIR_PATH, FANOTIFY_INODE,
 		FAN_EVENT_ON_CHILD,
 		FILE_PATH, 0, FAN_OPEN
 	},
 	{
 		"don't ignore fs events created inside a parent not watching children",
 		FILE_PATH, FANOTIFY_FILESYSTEM,
-		MNT2_PATH, FANOTIFY_INODE,
+		DIR_PATH, FANOTIFY_INODE,
 		0,
 		FILE_PATH, FAN_OPEN, FAN_OPEN
 	},
@@ -525,6 +528,7 @@  static void setup(void)
 	SAFE_MOUNT(MOUNT_PATH, MNT2_PATH, "none", MS_BIND, NULL);
 	bind_mount_created = 1;
 
+	SAFE_MKDIR(DIR_PATH, 0755);
 	SAFE_FILE_PRINTF(FILE_PATH, "1");
 	SAFE_FILE_PRINTF(FILE2_PATH, "1");