All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscall/fcntl33.c: fix test on FUSE fs
@ 2016-04-19 17:17 Alexey Kodanev
  2016-04-19 18:01 ` Cyril Hrubis
  0 siblings, 1 reply; 3+ messages in thread
From: Alexey Kodanev @ 2016-04-19 17:17 UTC (permalink / raw)
  To: ltp

Even though a child process is waiting for a parent to be in 'S'
state before triggering SIGIO, the signal might come earlier than
sigtimedwait() being invoked in the parent process. As a result the
parent waited for the event that had already happened.

I can only think about that the parent process may be in a sleep state
somehow while executing open() syscall on which it might sleep while
running it on FUSE FS:
vfs -> fuse kernel driver -> userspace implementation.

It can be fixed if we move open() before fork.

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 testcases/kernel/syscalls/fcntl/fcntl33.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/testcases/kernel/syscalls/fcntl/fcntl33.c b/testcases/kernel/syscalls/fcntl/fcntl33.c
index 2d69866..13616c6 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl33.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl33.c
@@ -146,16 +146,17 @@ static void setup(void)
 
 static void do_test(int i)
 {
-	pid_t cpid;
+	fd = SAFE_OPEN(cleanup, "file", O_RDONLY);
+
+	pid_t cpid = tst_fork();
 
-	cpid = tst_fork();
 	if (cpid < 0)
 		tst_brkm(TBROK | TERRNO, cleanup, "fork() failed");
 
-	if (cpid == 0)
+	if (cpid == 0) {
+		SAFE_CLOSE(NULL, fd);
 		do_child(i);
-
-	fd = SAFE_OPEN(cleanup, "file", O_RDONLY);
+	}
 
 	TEST(fcntl(fd, F_SETLEASE, test_cases[i].lease_type));
 	if (TEST_RETURN == -1) {
-- 
1.7.1


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

* [LTP] [PATCH] syscall/fcntl33.c: fix test on FUSE fs
  2016-04-19 17:17 [LTP] [PATCH] syscall/fcntl33.c: fix test on FUSE fs Alexey Kodanev
@ 2016-04-19 18:01 ` Cyril Hrubis
  2016-04-20 10:55   ` Alexey Kodanev
  0 siblings, 1 reply; 3+ messages in thread
From: Cyril Hrubis @ 2016-04-19 18:01 UTC (permalink / raw)
  To: ltp

Hi!
> Even though a child process is waiting for a parent to be in 'S'
> state before triggering SIGIO, the signal might come earlier than
> sigtimedwait() being invoked in the parent process. As a result the
> parent waited for the event that had already happened.
> 
> I can only think about that the parent process may be in a sleep state
> somehow while executing open() syscall on which it might sleep while
> running it on FUSE FS:
> vfs -> fuse kernel driver -> userspace implementation.

That sounds plausible to me. Depending on the actuall FUSE filesystem it
may do basically anything.

> It can be fixed if we move open() before fork.
> 
> Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
> ---
>  testcases/kernel/syscalls/fcntl/fcntl33.c |   11 ++++++-----
>  1 files changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/fcntl/fcntl33.c b/testcases/kernel/syscalls/fcntl/fcntl33.c
> index 2d69866..13616c6 100644
> --- a/testcases/kernel/syscalls/fcntl/fcntl33.c
> +++ b/testcases/kernel/syscalls/fcntl/fcntl33.c
> @@ -146,16 +146,17 @@ static void setup(void)
>  
>  static void do_test(int i)
>  {
> -	pid_t cpid;
> +	fd = SAFE_OPEN(cleanup, "file", O_RDONLY);
> +
> +	pid_t cpid = tst_fork();
>  
> -	cpid = tst_fork();
>  	if (cpid < 0)
>  		tst_brkm(TBROK | TERRNO, cleanup, "fork() failed");
>  
> -	if (cpid == 0)
> +	if (cpid == 0) {
> +		SAFE_CLOSE(NULL, fd);
>  		do_child(i);
> -
> -	fd = SAFE_OPEN(cleanup, "file", O_RDONLY);
> +	}

Looks good.

Another possible solution would be to use checkpoints and wait in the
child before we call tst_process_state_wait() and wake it up from parent
just before we call the fcntl(). But that would be more complicated than
this.

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH] syscall/fcntl33.c: fix test on FUSE fs
  2016-04-19 18:01 ` Cyril Hrubis
@ 2016-04-20 10:55   ` Alexey Kodanev
  0 siblings, 0 replies; 3+ messages in thread
From: Alexey Kodanev @ 2016-04-20 10:55 UTC (permalink / raw)
  To: ltp

Hi,
On 19.04.2016 21:01, Cyril Hrubis wrote:
>   
>   static void do_test(int i)
>   {
> -	pid_t cpid;
> +	fd = SAFE_OPEN(cleanup, "file", O_RDONLY);
> +
> +	pid_t cpid = tst_fork();
>   
> -	cpid = tst_fork();
>   	if (cpid < 0)
>   		tst_brkm(TBROK | TERRNO, cleanup, "fork() failed");
>   
> -	if (cpid == 0)
> +	if (cpid == 0) {
> +		SAFE_CLOSE(NULL, fd);
>   		do_child(i);
> -
> -	fd = SAFE_OPEN(cleanup, "file", O_RDONLY);
> +	}
> Looks good.
>
> Another possible solution would be to use checkpoints and wait in the
> child before we call tst_process_state_wait() and wake it up from parent
> just before we call the fcntl(). But that would be more complicated than
> this.

Yes, it would be a more portable alternative instead of waiting for a 
sleep state in a child.

Applied the original patch which has a simpler fix.

Thanks,
Alexey



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

end of thread, other threads:[~2016-04-20 10:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-19 17:17 [LTP] [PATCH] syscall/fcntl33.c: fix test on FUSE fs Alexey Kodanev
2016-04-19 18:01 ` Cyril Hrubis
2016-04-20 10:55   ` Alexey Kodanev

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.