All of lore.kernel.org
 help / color / mirror / Atom feed
* [Ocfs2-devel] ocfs2-test: fix flock_unit_test for fcntl locks
@ 2008-08-14  4:06 Mark Fasheh
  2008-08-14 18:51 ` [Ocfs2-devel] [Ocfs2-tools-devel] " Joel Becker
  2008-08-20 16:26 ` [Ocfs2-devel] " Sunil Mushran
  0 siblings, 2 replies; 4+ messages in thread
From: Mark Fasheh @ 2008-08-14  4:06 UTC (permalink / raw)
  To: ocfs2-devel

We were expecting a failure for the same-node same-fd trylock tests when in
fcntl mode, but fcntl locks will actually succeed for this, while flock
locks won't. The solution is to check which locking mode we're using and
adjust our expected return accordingly.

Signed-off-by: Mark Fasheh <mfasheh@suse.com>

Index: ocfs2-test/programs/flock_tests/flock_unit_test.c
===================================================================
--- ocfs2-test/programs/flock_tests/flock_unit_test.c	(revision 183)
+++ ocfs2-test/programs/flock_tests/flock_unit_test.c	(working copy)
@@ -329,7 +329,19 @@
 static void test_1node_1file(char *fname)
 {
 	int fd1, fd2;
+	int trylock_return = 0;
 
+	/*
+	 * flock allows one lock per fd, so a trylock on the 2nd file
+	 * descriptor will return EWOULDBLOCK.
+	 *
+	 * fcntl on the other hand, only allows one lock per process,
+	 * regardless of the number of fds used. So our trylocks here
+	 * should succeed as it'll be considered an EX->EX convert.
+	 */
+	if (use_flock)
+		trylock_return = EWOULDBLOCK;
+
 	fd1 = get_fd(fname);
 	fd2 = get_fd(fname);
 
@@ -344,13 +356,13 @@
 
 	info("Two exclusive trylocks\n");
 	lock_abort(fname, fd1, 0, 1, 1);
-	lock_abort(fname, fd2, EWOULDBLOCK, 1, 1);
+	lock_abort(fname, fd2, trylock_return, 1, 1);
 	unlock_abort(fname, fd1, 0);
 
 
 	info("One exclusive, one shared trylock\n");
 	lock_abort(fname, fd1, 0, 1, 0);
-	lock_abort(fname, fd2, EWOULDBLOCK, 0, 1);
+	lock_abort(fname, fd2, trylock_return, 0, 1);
 	unlock_abort(fname, fd1, 0);
 
 

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

* [Ocfs2-devel] [Ocfs2-tools-devel] ocfs2-test: fix flock_unit_test for fcntl locks
  2008-08-14  4:06 [Ocfs2-devel] ocfs2-test: fix flock_unit_test for fcntl locks Mark Fasheh
@ 2008-08-14 18:51 ` Joel Becker
  2008-08-20 16:26 ` [Ocfs2-devel] " Sunil Mushran
  1 sibling, 0 replies; 4+ messages in thread
From: Joel Becker @ 2008-08-14 18:51 UTC (permalink / raw)
  To: ocfs2-devel

On Wed, Aug 13, 2008 at 09:06:12PM -0700, Mark Fasheh wrote:
> We were expecting a failure for the same-node same-fd trylock tests when in
> fcntl mode, but fcntl locks will actually succeed for this, while flock
> locks won't. The solution is to check which locking mode we're using and
> adjust our expected return accordingly.
> 
> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Signed-off-by: Joel Becker <joel.becker@oracle.com>


> 
> Index: ocfs2-test/programs/flock_tests/flock_unit_test.c
> ===================================================================
> --- ocfs2-test/programs/flock_tests/flock_unit_test.c	(revision 183)
> +++ ocfs2-test/programs/flock_tests/flock_unit_test.c	(working copy)
> @@ -329,7 +329,19 @@
>  static void test_1node_1file(char *fname)
>  {
>  	int fd1, fd2;
> +	int trylock_return = 0;
>  
> +	/*
> +	 * flock allows one lock per fd, so a trylock on the 2nd file
> +	 * descriptor will return EWOULDBLOCK.
> +	 *
> +	 * fcntl on the other hand, only allows one lock per process,
> +	 * regardless of the number of fds used. So our trylocks here
> +	 * should succeed as it'll be considered an EX->EX convert.
> +	 */
> +	if (use_flock)
> +		trylock_return = EWOULDBLOCK;
> +
>  	fd1 = get_fd(fname);
>  	fd2 = get_fd(fname);
>  
> @@ -344,13 +356,13 @@
>  
>  	info("Two exclusive trylocks\n");
>  	lock_abort(fname, fd1, 0, 1, 1);
> -	lock_abort(fname, fd2, EWOULDBLOCK, 1, 1);
> +	lock_abort(fname, fd2, trylock_return, 1, 1);
>  	unlock_abort(fname, fd1, 0);
>  
>  
>  	info("One exclusive, one shared trylock\n");
>  	lock_abort(fname, fd1, 0, 1, 0);
> -	lock_abort(fname, fd2, EWOULDBLOCK, 0, 1);
> +	lock_abort(fname, fd2, trylock_return, 0, 1);
>  	unlock_abort(fname, fd1, 0);
>  
>  
> 
> _______________________________________________
> Ocfs2-tools-devel mailing list
> Ocfs2-tools-devel at oss.oracle.com
> http://oss.oracle.com/mailman/listinfo/ocfs2-tools-devel

-- 

"You must remember this:
 A kiss is just a kiss,
 A sigh is just a sigh.
 The fundamental rules apply
 As time goes by."

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127

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

* [Ocfs2-devel] ocfs2-test: fix flock_unit_test for fcntl locks
  2008-08-14  4:06 [Ocfs2-devel] ocfs2-test: fix flock_unit_test for fcntl locks Mark Fasheh
  2008-08-14 18:51 ` [Ocfs2-devel] [Ocfs2-tools-devel] " Joel Becker
@ 2008-08-20 16:26 ` Sunil Mushran
  2008-08-21 19:33   ` Mark Fasheh
  1 sibling, 1 reply; 4+ messages in thread
From: Sunil Mushran @ 2008-08-20 16:26 UTC (permalink / raw)
  To: ocfs2-devel


Mark Fasheh wrote:
> We were expecting a failure for the same-node same-fd trylock tests when in
> fcntl mode, but fcntl locks will actually succeed for this, while flock
> locks won't. The solution is to check which locking mode we're using and
> adjust our expected return accordingly.
>
> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
>   

Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com>

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

* [Ocfs2-devel] ocfs2-test: fix flock_unit_test for fcntl locks
  2008-08-20 16:26 ` [Ocfs2-devel] " Sunil Mushran
@ 2008-08-21 19:33   ` Mark Fasheh
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Fasheh @ 2008-08-21 19:33 UTC (permalink / raw)
  To: ocfs2-devel

On Wed, Aug 20, 2008 at 09:26:53AM -0700, Sunil Mushran wrote:
> Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com>

Thanks.

Can someone please commit this? Ocfs2-test is still svn so I don't think I
can commit.
	--Mark

--
Mark Fasheh

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

end of thread, other threads:[~2008-08-21 19:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-14  4:06 [Ocfs2-devel] ocfs2-test: fix flock_unit_test for fcntl locks Mark Fasheh
2008-08-14 18:51 ` [Ocfs2-devel] [Ocfs2-tools-devel] " Joel Becker
2008-08-20 16:26 ` [Ocfs2-devel] " Sunil Mushran
2008-08-21 19:33   ` Mark Fasheh

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.