Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 Jul 2013 12:07:37 +0000 (UTC)
From:      Peter Holm <pho@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r253031 - user/pho/stress2/testcases/lockf
Message-ID:  <201307081207.r68C7bAR056772@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pho
Date: Mon Jul  8 12:07:36 2013
New Revision: 253031
URL: http://svnweb.freebsd.org/changeset/base/253031

Log:
  Added missing resource reservation to this test. Moved debug information to
  a higher verbose level.
  
  Sponsored by:	EMC / Isilon storage division

Modified:
  user/pho/stress2/testcases/lockf/lockf.c

Modified: user/pho/stress2/testcases/lockf/lockf.c
==============================================================================
--- user/pho/stress2/testcases/lockf/lockf.c	Mon Jul  8 11:29:59 2013	(r253030)
+++ user/pho/stress2/testcases/lockf/lockf.c	Mon Jul  8 12:07:36 2013	(r253031)
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
 
 char file[128];
 int fd;
+int freespace;
 pid_t	pid;
 
 int
@@ -78,9 +79,36 @@ incr(void) {
 	if (lockf(fd, F_ULOCK, 0) == -1)
 		err(1, "lockf(%s, F_ULOCK)", file);
 }
+
 int
 setup(int nb)
 {
+	int64_t bl;
+	int64_t in;
+	int64_t reserve_bl;
+	int64_t reserve_in;
+
+	if (nb == 0) {
+		getdf(&bl, &in);
+
+		/* Resource requirements: */
+		reserve_in =    1 * op->incarnations;
+		reserve_bl = 4096 * op->incarnations;
+		freespace = (reserve_bl <= bl && reserve_in <= in);
+		if (!freespace)
+			reserve_bl = reserve_in = 0;
+
+		if (op->verbose > 1)
+			printf("lockf(incarnations=%d). Free(%jdk, %jd), reserve(%jdk, %jd)\n",
+			    op->incarnations, bl/1024, in, reserve_bl/1024, reserve_in);
+		reservedf(reserve_bl, reserve_in);
+		putval(freespace);
+	} else {
+		freespace = getval();
+	}
+	if (!freespace)
+		exit(0);
+
         return (0);
 }
 
@@ -113,7 +141,7 @@ test(void)
 		for (i = 0; i < 100; i++) {
 			while ((get() & 1) == 0)
 				;
-			if (op->verbose > 2)
+			if (op->verbose > 3)
 				printf("Child  %d, sem = %d\n", i, get()),
 					fflush(stdout);
 			incr();
@@ -123,7 +151,7 @@ test(void)
 		for (i = 0; i < 100; i++) {
 			while ((get() & 1) == 1)
 				;
-			if (op->verbose > 2)
+			if (op->verbose > 3)
 				printf("Parent %d, sem = %d\n", i, get()),
 					fflush(stdout);
 			incr();



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201307081207.r68C7bAR056772>