All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 0/8] network/nfs: fix/cleanup tests
@ 2016-06-20 14:28 Alexey Kodanev
  2016-06-20 14:28 ` [LTP] [PATCH resend 1/8] lib: add safe_gethostname() Alexey Kodanev
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Alexey Kodanev @ 2016-06-20 14:28 UTC (permalink / raw)
  To: ltp

Alexey Kodanev (8):
  lib: add safe_gethostname()
  network/nfs05: rewrite the test, make use of new library
  network/nfs_lib.sh: add options, socket type and NFS ver
  network/nfs/fsx: cleanup test, use test_net library
  network/nfs/nfsstat: cleanup test, use test_net.sh library
  network/nfs/nfsflock: clenaup & use test_net library
  network/nfs/nfs_fsstress: remove fsstress test
  network/nfs: remove README

 include/safe_net_fn.h                              |    3 +
 include/tst_safe_net.h                             |    3 +
 lib/safe_net.c                                     |   14 +
 runtest/net.nfs                                    |   83 +-
 testcases/network/.gitignore                       |    1 -
 testcases/network/nfs/README                       |   28 -
 testcases/network/nfs/fsx-linux/fsx.sh             |  204 +--
 testcases/network/nfs/nfs_fsstress/Makefile        |    7 -
 testcases/network/nfs/nfs_fsstress/fsstress.c      | 2591 --------------------
 testcases/network/nfs/nfs_fsstress/global.h        |   66 -
 testcases/network/nfs/nfs_fsstress/xfscompat.h     |    7 -
 testcases/network/nfs/nfs_stress/Makefile          |    2 +-
 testcases/network/nfs/nfs_stress/nfs05             |    8 +-
 testcases/network/nfs/nfs_stress/nfs05_make_tree.c |  911 ++------
 testcases/network/nfs/nfs_stress/nfs_lib.sh        |   32 +-
 testcases/network/nfs/nfslock01/nfs_flock_frk.c    |   39 -
 testcases/network/nfs/nfslock01/nfslock01          |  155 +-
 testcases/network/nfs/nfsstat01/nfsstat01          |  343 +--
 18 files changed, 433 insertions(+), 4064 deletions(-)
 delete mode 100644 testcases/network/nfs/README
 delete mode 100644 testcases/network/nfs/nfs_fsstress/fsstress.c
 delete mode 100644 testcases/network/nfs/nfs_fsstress/global.h
 delete mode 100644 testcases/network/nfs/nfs_fsstress/xfscompat.h
 delete mode 100644 testcases/network/nfs/nfslock01/nfs_flock_frk.c


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

* [LTP] [PATCH resend 1/8] lib: add safe_gethostname()
  2016-06-20 14:28 [LTP] [PATCH 0/8] network/nfs: fix/cleanup tests Alexey Kodanev
@ 2016-06-20 14:28 ` Alexey Kodanev
  2016-06-20 14:28 ` [LTP] [PATCH resend 2/8] network/nfs05: rewrite the test, make use of new library Alexey Kodanev
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Alexey Kodanev @ 2016-06-20 14:28 UTC (permalink / raw)
  To: ltp

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 include/safe_net_fn.h  |    3 +++
 include/tst_safe_net.h |    3 +++
 lib/safe_net.c         |   14 ++++++++++++++
 3 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/include/safe_net_fn.h b/include/safe_net_fn.h
index e85842b..14609b8 100644
--- a/include/safe_net_fn.h
+++ b/include/safe_net_fn.h
@@ -45,4 +45,7 @@ int safe_getsockname(const char *file, const int lineno,
 		     void (cleanup_fn)(void), int sockfd, struct sockaddr *addr,
 		     socklen_t *addrlen);
 
+int safe_gethostname(const char *file, const int lineno,
+		     void (cleanup_fn)(void), char *name, size_t size);
+
 #endif /* SAFE_NET_FN_H__ */
diff --git a/include/tst_safe_net.h b/include/tst_safe_net.h
index 98dcfa5..3bfc052 100644
--- a/include/tst_safe_net.h
+++ b/include/tst_safe_net.h
@@ -43,4 +43,7 @@
 	safe_getsockname(__FILE__, __LINE__, NULL, sockfd, addr, \
 			 addrlen)
 
+#define SAFE_GETHOSTNAME(name, size) \
+	safe_gethostname(__FILE__, __LINE__, NULL, name, size)
+
 #endif /* TST_SAFE_NET_H__ */
diff --git a/lib/safe_net.c b/lib/safe_net.c
index 98a79cf..1ee447d 100644
--- a/lib/safe_net.c
+++ b/lib/safe_net.c
@@ -183,3 +183,17 @@ int safe_getsockname(const char *file, const int lineno,
 
 	return rval;
 }
+
+int safe_gethostname(const char *file, const int lineno,
+		     void (cleanup_fn)(void), char *name, size_t size)
+{
+	int rval = gethostname(name, size);
+
+	if (rval < 0) {
+		tst_brkm(TBROK | TERRNO, cleanup_fn,
+			 "%s:%d: gethostname(%p, %zu) failed",
+			 file, lineno, name, size);
+	}
+
+	return rval;
+}
-- 
1.7.1


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

* [LTP] [PATCH resend 2/8] network/nfs05: rewrite the test, make use of new library
  2016-06-20 14:28 [LTP] [PATCH 0/8] network/nfs: fix/cleanup tests Alexey Kodanev
  2016-06-20 14:28 ` [LTP] [PATCH resend 1/8] lib: add safe_gethostname() Alexey Kodanev
@ 2016-06-20 14:28 ` Alexey Kodanev
  2016-06-20 14:28 ` [LTP] [PATCH 3/8] network/nfs_lib.sh: add options, socket type and NFS ver Alexey Kodanev
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Alexey Kodanev @ 2016-06-20 14:28 UTC (permalink / raw)
  To: ltp

* remove dynamic allocation of memory, use asprintf in few places;
* run tst_run_cmd() to call make/make clean;
* clean directories with tst_rmdir library.

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 testcases/network/nfs/nfs_stress/Makefile          |    2 +-
 testcases/network/nfs/nfs_stress/nfs05             |    8 +-
 testcases/network/nfs/nfs_stress/nfs05_make_tree.c |  911 ++++----------------
 3 files changed, 160 insertions(+), 761 deletions(-)

diff --git a/testcases/network/nfs/nfs_stress/Makefile b/testcases/network/nfs/nfs_stress/Makefile
index 0e6aebc..0a7bf6a 100644
--- a/testcases/network/nfs/nfs_stress/Makefile
+++ b/testcases/network/nfs/nfs_stress/Makefile
@@ -19,7 +19,7 @@ top_srcdir		?= ../../../..
 include $(top_srcdir)/include/mk/env_pre.mk
 
 nfs04_create_file: CPPFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
-nfs05_make_tree: LDLIBS += -lpthread
+nfs05_make_tree: LDLIBS += -I../../../kernel/include -lltp -lpthread
 
 INSTALL_TARGETS		:= nfs_lib.sh \
 			   nfs01 \
diff --git a/testcases/network/nfs/nfs_stress/nfs05 b/testcases/network/nfs/nfs_stress/nfs05
index 0e15c8c..26977ab 100755
--- a/testcases/network/nfs/nfs_stress/nfs05
+++ b/testcases/network/nfs/nfs_stress/nfs05
@@ -34,8 +34,12 @@ THREAD_NUM=${THREAD_NUM:-"8"}
 nfs_setup
 
 tst_resm TINFO "start nfs05_make_tree -d $DIR_NUM -f $FILE_NUM -t $THREAD_NUM"
-ROD nfs05_make_tree -d $DIR_NUM -f $FILE_NUM -t $THREAD_NUM
+TMPDIR=$(pwd) nfs05_make_tree -d $DIR_NUM -f $FILE_NUM -t $THREAD_NUM
 
-tst_resm TPASS "test finished"
+if [ $? -ne 0 ]; then
+	tst_resm TFAIL "'make' test failed"
+else
+	tst_resm TPASS "'make' test finished"
+fi
 
 tst_exit
diff --git a/testcases/network/nfs/nfs_stress/nfs05_make_tree.c b/testcases/network/nfs/nfs_stress/nfs05_make_tree.c
index 4163988..5d128dd 100644
--- a/testcases/network/nfs/nfs_stress/nfs05_make_tree.c
+++ b/testcases/network/nfs/nfs_stress/nfs05_make_tree.c
@@ -1,179 +1,50 @@
-/******************************************************************************/
-/*									      */
-/* Copyright (c) International Business Machines  Corp., 2001		      */
-/*									      */
-/* This program is free software;  you can redistribute it and/or modify      */
-/* it under the terms of the GNU General Public License as published by       */
-/* the Free Software Foundation; either version 2 of the License, or          */
-/* (at your option) any later version.					      */
-/*									      */
-/* This program is distributed in the hope that it will be useful,	      */
-/* but WITHOUT ANY WARRANTY;  without even the implied warranty of	      */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See	              */
-/* the GNU General Public License for more details.			      */
-/*									      */
-/* You should have received a copy of the GNU General Public License	      */
-/* along with this program;  if not, write to the Free Software		      */
-/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    */
-/*									      */
-/******************************************************************************/
-
-/******************************************************************************/
-/*                                                                            */
-/* History:     Oct - 10 - 2001 Created - Manoj Iyer, IBM Austin TX.          */
-/*                               email:manjo@austin.ibm.com                   */
-/*					- create a directory tree that is     */
-/*				unique to each process. The base directory    */
-/*				looks like hostname.<pid of the process>      */
-/*				the subdirectories will be <pid>.0 <pid.1> etc*/
-/*				eg:					      */
-/*				    hostname.1234			      */
-/*					       |_ 1234.0	              */
-/*					               |_ 1234.1              */
-/*					                      |_1234.2        */
-/*								    |....     */
-/*				hostname -  hostname of the machine           */
-/*			        1234     -  pid of the current process.       */
-/*			        Each of these directories are populated with  */
-/*				N number of ".c" files and a makefile that can*/
-/*				compile the ".c" files and also initiate      */
-/*				compile of ".c" files in the subdirectories   */
-/*				under it.			              */
-/*                                                                            */
-/*		Oct - 11 - 2001 Modified 				      */
-/*				- fixed a bug in the makefiles, the last make-*/
-/*				  file was expecting subdirectories. Added    */
-/*				  code to generate a different makefile for   */
-/*				  the last subdirectory.		      */
-/*				- Added logic to first compile all the c files*/
-/*				  and upon completion remove them.            */
-/*			        - Added multithreading, arguments handling.   */
-/*				  By default the program will generate 8      */
-/*				  threads, each creating by default 100 deep  */
-/*				  directory tree each containing default 100  */
-/*			          ".c" files and one makefile.                */
-/*			        - Added usage message.                        */
-/*								              */
-/*		Oct - 12 - 2001 Modified			              */
-/*				- Added logic to print missing arguments to   */
-/*				  options.                                    */
-/*                                                                            */
-/*		Oct - 15 - 2001 Modified			              */
-/*				- Added logic to remove the files, makefiles  */
-/*				  and subdirectories that were created.       */
-/*			        - Added logic to print debug messages.        */
-/*								              */
-/*		Oct - 16 - 2001 Modified		                      */
-/*				- Added sync() calls to commit changes.       */
-/*				- Fixed bug. pthread_join() returns 0 when    */
-/*			          pthread_join fails, if the thread function  */
-/*				  fails pthread_join() will put the exit value*/
-/*			          of the thread function in the thread_return */
-/*				  output argument.			      */
-/*				- Debugging function crte_mk_rm fails to      */
-/*				  create fies, problem appears only in multi- */
-/*				  threaded case.                              */
-/*								              */
-/*		Oct - 17 - 2001 Checked in		                      */
-/*				- GPL statement was added and the initial ver */
-/*			        - checked into CVS.		              */
-/*			        - note: this version works only if it is run  */
-/*				  single threaded, when its run multithreaded */
-/*		                  random thread will fail on open() sys call  */
-/*				  problem currently under investigation.      */
-/*                                                                            */
-/*		Oct - 20 - 2001 Modified				      */
-/*				- fixed a whole bunch of problems.            */
-/*			        - created function init_compile. Apparently   */
-/*				  this code works!!.                          */
-/*			        - removed system() system call that was doing */
-/*				  make and make clean. init_compile() replaces*/
-/*				  this piece of code.                         */
-/*				- on supplying the full pathname to unlink()  */
-/*				  solved most of the problems with rm_file_mk */
-/*			          function.                                   */
-/*				- reset the default vaulues for MAXT = 8      */
-/*				  MAXD = 100 and MAXF = 100.                  */
-/*				  ie. maximum number of threads = 8           */
-/*				      directory depth (num of sub dirs) = 100 */
-/*				      numeber of .c fils in each sub dir = 100*/
-/*				- finally program is now in working state.    */
-/*                                                                            */
-/*		Nov - 01 - 2001 Modified.				      */
-/*				- fixed usage message default MAXT is 8 not 1 */
-/*				- fixed make to compile the files silently    */
-/*									      */
-/*		Nov - 19 - 2001 Modified.				      */
-/*				- changed th_status in function main() from   */
-/*				  dynamic variable to static array.           */
-/*									      */
-/* File:        make_tree.c                                                   */
-/*                                                                            */
-/* Description:	This program is designed stress the NFS implimentation.       */
-/* 		Many bugs were uncovered in the AIX operating system          */
-/*		implimentation of NFS when AIX kernel was built over NFS.     */
-/*		Source directory on a remote machine (one server many clients)*/
-/*		NFS-mounted on to a directory on a local machine from which   */
-/*		the kernel build was initiated. Apparently many defects/bugs  */
-/* 		were uncovered when multiple users tried to build the kernel  */
-/* 		by NFS mounting the kernel source from a remote machine and   */
-/* 		tried to build the kernel on a local machine. AIX build envi- */
-/*		ronment is set up to create the object files and executable   */
-/*		on the local machine. 					      */
-/* 		This testcase will try to recreate such a senario.            */
-/*		Spawn N number of threads. Each thread does the following.    */
-/*		* Create a directory tree.                                    */
-/*		* Populate it with ".c" files and makefiles.                  */
-/*		* initate a build. Executable will print hello world when exed*/
-/*		* clean up all the executables that were created.             */
-/*		* recurssively remove each subdir and its contents.           */
-/*		The test is aimed at stressing the NFS client and server.     */
-/*				    hostname.1234			      */
-/*                                             |                              */
-/*				               | - 1234.0.0.c                 */
-/*					       | - 1234.0.1.c                 */
-/*                                             | - ..........                 */
-/*					       | - makefile                   */
-/*                                             |                              */
-/*					       |_ 1234.0	              */
-/*                                                    |                       */
-/*				                      | - 1234.1.0.c          */
-/*					              | - 1234.1.1.c          */
-/*                                                    | - ..........          */
-/*					              | - makefile            */
-/*                                                    |                       */
-/*					              |_ 1234.1               */
-/*                                                           |                */
-/*				                             | - 1234.2.0.c   */
-/*					                     | - 1234.2.1.c   */
-/*                                                           | - ..........   */
-/*					                     | - makefile     */
-/*                                                           |                */
-/*					                     |_1234.2         */
-/*								    |....     */
-/*                                                                            */
-/* Setup:	- on the server side:			                      */
-/*		  * create a directory /nfs_test 		              */
-/*		  * make an entry in /etc/exports file like this...           */
-/*		    "/nfs_test *(rw,no_root_squash)"		              */
-/*		  * run command "exportfs -a"		                      */
-/*	        - on client side:			                      */
-/*		  * create a directory say for eg: /nfs_cli                   */
-/*		  * mount -t nfs servername:/nfs_test /nfs_cli                */
-/*		  * set up the tescase in /nfs_cli directory		      */
-/*		- I reccomend that you have atleast 8 client machines running */
-/*		   this test, linux has 8 NFSD's running by default, you might*/
-/*		   have to increase it as per your requirement.               */
-/*		                                                              */
-/* Note:	- assumed that NFS services are installed and configured      */
-/*		- you have atleast 2 machines to act as client and server     */
-/*		  (you can have muiltiple client machines and one server)     */
-/*		- large amount of disk space, this depends on the number of   */
-/*		  of clients you will have, if you have only one client, I    */
-/*		  reccomend that the server have atleast 4 Giga bytes of      */
-/*		  disk space (paranoid!).			              */
-/*									      */
-/******************************************************************************/
+/*
+ * Copyright (c) 2016 Oracle and/or its affiliates. All Rights Reserved.
+ * Copyright (c) International Business Machines  Corp., 2001
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ * Description:
+ * This program is designed to stress the NFS implimentation. Many bugs were
+ * uncovered in the AIX operating system implimentation of NFS when AIX kernel
+ * was built over NFS. Source directory on a remote machine (one server many
+ * clients) NFS-mounted on to a directory on a local machine from which the
+ * kernel build was initiated. Apparently many defects/bugs were uncovered when
+ * multiple users tried to build the kernel by NFS mounting the kernel source
+ * from a remote machine and tried to build the kernel on a local machine.
+ *
+ * The test's aimed to stress NFS client/server and recreates such a senario.
+ * Spawn N number of threads. Each thread does the following:
+ *   * create a directory tree;
+ *   * populate it with ".c" files and makefiles;
+ *     hostname.1234
+ *             | - 1234.0.0.c
+ *             | - ..........
+ *             | - makefile
+ *             |_ 1234.0
+ *                    |
+ *                    | - 1234.1.0.c
+ *                    | - ..........
+ *                    | - makefile
+ *                    |_ 1234.1
+ *                           |....
+ *
+ *   * initate a build, executable will print hello world;
+ *   * clean up all the executables that were created;
+ *   * recurssively remove each subdir and its contents.
+ *
+ */
 
 #include <stdio.h>
 #include <sys/stat.h>
@@ -188,609 +59,133 @@
 #include <errno.h>
 #include <linux/unistd.h>
 
-#define gettid() syscall(__NR_gettid)
-
-#ifdef DEBUG
-#define dprt(fmt, args...)	printf(fmt, ## args)
-#else
-#define dprt(fmt, args...)
-#endif
-
-#define MAKE_EXE	1	/* initate a make                             */
-#define MAKE_CLEAN	0	/* initate a make clean                       */
-
-#define PTHREAD_EXIT(val)    do {\
-			exit_val = val; \
-                        dprt("pid[%d]: exiting with %d\n", gettid(),exit_val); \
-			pthread_exit((void *)exit_val); \
-				} while (0)
-
-#define OPT_MISSING(prog, opt)   do{\
-			       fprintf(stderr, "%s: option -%c ", prog, opt); \
-                               fprintf(stderr, "requires an argument\n"); \
-                               usage(prog); \
-                                   } while (0)
-
-#define MAXD	100		/* default number of directories to create.           */
-#define MAXF	100		/* default number of files to create.                 */
-#define MAXT	8		/* default number of threads to create.               */
-
-/******************************************************************************/
-/*								 	      */
-/* Function:	usage							      */
-/*									      */
-/* Description:	Print the usage message.				      */
-/*									      */
-/* Return:	exits with -1						      */
-/*									      */
-/******************************************************************************/
-static void usage(char *progname)
-{				/* name of this program                       */
-	fprintf(stderr,
-		"Usage: %s -d NUMDIR -f NUMFILES -h -t NUMTHRD\n"
-		"\t -d Number of subdirectories to generate:   Default: 100\n"
-		"\t -f Number of c files in each subdirectory: Default: 100\n"
-		"\t -h Help!\n"
-		"\t -t Number of threads to generate:          Default: 8\n",
-		progname);
-	exit(-1);
-}
-
-/******************************************************************************/
-/*								 	      */
-/* Function:	init_compile						      */
-/*									      */
-/* Description:	This function compiles the .c files and removes the exeutables*/
-/*		This function does the same function as the system() system   */
-/*		call, the code is available in the system() man page. When    */
-/*		called with the parameter MAKE_EXE it will initiate make in   */
-/*		the first directory created, the makefile is designed to build*/
-/*		recursively all the files in the subdirectories below.        */
-/*		When called with the MAKE_CLEAN parameter it will remove the  */
-/*		executables that were created design is similar to the case   */
-/*		were it initiates a make.                                     */
-/*									      */
-/* Return:	exits with 1 on error, 0 on success                           */
-/*									      */
-/******************************************************************************/
-static int init_compile(int what_todo,	/* do a compile or clean             */
-			char *base_dir,	/* base directory of the test        */
-			char *hname)
-{				/* hostname of the machine           */
-	int status;		/* return status of execve process            */
-	pid_t pid;		/* pid of the process that does compile       */
-	char *dirname;		/* location where compile is initated         */
-	char *command;		/* make or make clean command.                */
-
-	if ((dirname = malloc(sizeof(char) * 2048)) == NULL) {	/* just paranoid */
-		perror("init_compile(): dirname malloc()");
-		return 1;
-	}
-
-	if ((command = malloc(sizeof(char) * 1024)) == NULL) {	/* just paranoid */
-		perror("init_compile(): dirname malloc()");
-		return 1;
-	}
-
-	what_todo ? sprintf(command, "make -s") : sprintf(command,
-							  "make -s clean");
+#include "lapi/mkdirat.h"
+#include "tst_safe_stdio.h"
+#include "tst_test.h"
 
-	sprintf(dirname, "%s/%s.%ld", base_dir, hname, gettid());
+#define gettid() syscall(__NR_gettid)
 
-	if (chdir(dirname) == -1) {
-		dprt("pid[%d]: init_compile(): dir name = %s\n", gettid(),
-		     dirname);
-		perror("init_compile() chdir()");
-		free(dirname);
-		return 1;
-	}
+static int thrd_num = 8;
+static int dirs_num = 100;
+static int file_num = 100;
 
-	dprt("pid[%d]: init_compile(): command = %s\n", gettid(), command);
+static char *t_arg, *d_arg, *f_arg;
 
-	if ((pid = fork()) == -1) {
-		perror("init_compile(): fork()");
-		return 1;
-	}
-	if (!pid) {
-		char *argv[4];
+static struct tst_option opts[] = {
+	{"t:", &t_arg, "-t x    Number of threads to generate, default: 8\n"},
+	{"d:", &d_arg, "-d x    Number of subdirs to generate, default: 100\n"},
+	{"f:", &f_arg, "-f x    Number of c files in each dir, default: 100\n"},
+	{NULL, NULL, NULL}
+};
 
-		argv[0] = "/bin/sh";
-		argv[1] = "-c";
-		argv[2] = command;
-		argv[3] = 0;
-
-		if (execv("/bin/sh", argv) == -1) {
-			perror("init_compile(): execv()");
-			return 1;
-		}
-	}
-	do {
-		if (waitpid(pid, &status, 0) == -1) {
-			if (errno != EINTR) {
-				fprintf(stderr,
-					"init_compile(): waitpid() failed\n");
-				return 1;
-			}
+static void *thread_fn(LTP_ATTRIBUTE_UNUSED void *args)
+{
+	const char prog_buf[] = "main()\n{\n\t printf(\"hello world\");\n}\n";
+	const size_t prog_buf_size = strlen(prog_buf);
+	int i, k, fd, dirfd, len, ret;
+	char *dirname, *tmpdir;
+	char cfile[PATH_MAX];
+	char make_buf[1024];
+	char hostname[256];
+	pid_t tid = gettid();
+
+	SAFE_GETHOSTNAME(hostname, 256);
+	SAFE_ASPRINTF(&dirname, "%s.%ld", hostname, tid);
+	SAFE_ASPRINTF(&tmpdir, "%ld", tid);
+
+	SAFE_MKDIR(dirname, 0755);
+	dirfd = SAFE_OPEN(dirname, O_DIRECTORY);
+
+	for (i = 0; i < dirs_num; ++i) {
+		if (i == dirs_num - 1) {
+			len = snprintf(make_buf, 1024,
+				"CFLAGS := -O -w -g\n"
+				"SUBDIRS = %s\n"
+				"SRCS=$(wildcard *.c)\n"
+				"TARGETS=$(patsubst %%.c,\%%,$(SRCS))\n"
+				"all:\t $(TARGETS)\n"
+				"clean:\n"
+				"\trm -f $(TARGETS)\n",
+				tmpdir);
 		} else {
-			if (chdir(base_dir) == -1) {
-				dprt("pid[%d]: init_compile(): dir = %s\n",
-				     gettid(), dirname);
-				perror("init_compile(): chdir()");
-				return 1;
+			len = snprintf(make_buf, 1024,
+				"CFLAGS := -O -w -g\n"
+				"SUBDIRS = %s\n"
+				"SRCS=$(wildcard *.c)\n"
+				"TARGETS=$(patsubst %%.c,\%%,$(SRCS))\n"
+				"all:\t $(TARGETS)\n\t@for i in $(SUBDIRS);"
+				"do $(MAKE) -C $$i ; done\nclean:\n"
+				"\trm -f $(TARGETS)\n\t@for i in $(SUBDIRS);"
+				"do $(MAKE) -C $$i clean ; done\n", tmpdir);
+		}
+
+		fd = openat(dirfd, "makefile", O_CREAT | O_RDWR,
+			    S_IRWXU | S_IRWXG | S_IRWXO);
+		if (fd < 0)
+			tst_brk(TFAIL | TERRNO, "openat(makefile) failed");
+
+		SAFE_WRITE(1, fd, make_buf, len);
+		SAFE_CLOSE(fd);
+
+		for (k = 0; k < file_num; ++k) {
+			snprintf(cfile, PATH_MAX, "%d.%d.%d.c", tid, i, k);
+			fd = openat(dirfd, cfile, O_CREAT | O_RDWR,
+				    S_IRWXU | S_IRWXG | S_IRWXO);
+			if (fd < 0) {
+				tst_brk(TFAIL | TERRNO,
+					"openat(%s) failed", cfile);
 			}
 
-			dprt("pid[%d]: init_compile(): status = %d\n",
-			     gettid(), status);
-			dprt("we are here %d\n", __LINE__);
-			return status;
+			SAFE_WRITE(1, fd, prog_buf, prog_buf_size);
+			fsync(fd);
+			SAFE_CLOSE(fd);
 		}
 
-	} while (1);
-}
-
-/******************************************************************************/
-/*								 	      */
-/* Function:	rm_file_dir						      */
-/*									      */
-/* Description: This function removes the .c files makefiles and directories. */
-/*		First removes the files in the files in the last directory    */
-/*		first then removes the last directory, then cycles through    */
-/*		each subdirectory and does the same.			      */
-/*									      */
-/* Return:	exits with 1 on error, 0 on success      		      */
-/*									      */
-/******************************************************************************/
-static int rm_file_dir(int numsdir,	/* how many subdirs to remove         */
-		       int numfiles,	/* number of files to remove per dir  */
-		       char *hname,	/* hostname of the client machine     */
-		       char *base_dir)
-{				/* directory where the test is located */
-	int filecnt;		/* index to the num of files to remove */
-	int dircnt;		/* index into directory tree          */
-	int sindex = numsdir;	/* num subdirectory tree to remove    */
-	char *dirname;		/* name of the directory to chdir()   */
-	char *tmpdirname;	/* temp name for directory, for swap  */
-	char *filename;		/* name of the cfile to remove        */
-	char *subdir;		/* name of the sub dir to remove      */
-
-	if ((dirname = malloc(sizeof(char) * 2048)) == NULL) {	/* just paranoid */
-		perror("crte_mk_rm(): dirname malloc()");
-		return 1;
-	}
-
-	if ((tmpdirname = malloc(sizeof(char) * 2048)) == NULL) {	/* just paranoid */
-		perror("crte_mk_rm(): tmpdirname malloc()");
-		return 1;
+		ret = mkdirat(dirfd, tmpdir, 0755);
+		if (ret < 0)
+			tst_brk(TFAIL | TERRNO, "mkdirat(%s) failed", tmpdir);
+		dirfd = openat(dirfd, tmpdir, O_DIRECTORY);
+		if (dirfd < 0)
+			tst_brk(TFAIL | TERRNO, "openat(%s) failed", tmpdir);
 	}
 
-	if ((filename = malloc(sizeof(char) * 2048)) == NULL) {	/* just paranoid */
-		perror("crte_mk_rm(): filename malloc()");
-		return 1;
-	}
-
-	if ((subdir = malloc(sizeof(char) * 2048)) == NULL) {	/* just paranoid */
-		perror("crte_mk_rm(): subdir malloc()");
-		return 1;
-	}
-
-	dprt("pid[%d]: base directory: %s\n", gettid(), base_dir);
-	while (sindex) {
-		/* get the name of the last directory created. */
-		for (dircnt = 0; dircnt < sindex; dircnt++) {
-			if (dircnt == 0)
-				sprintf(dirname, "%s/%s.%ld", base_dir, hname,
-					gettid());
-			else {
-				sprintf(tmpdirname, "%s/%ld.%d", dirname,
-					gettid(), dircnt);
-				sprintf(dirname, "%s", tmpdirname);
-			}
-			sync();
-		}
-
-		dprt("pid[%d]: cd'ing to last created dir: %s\n", gettid(),
-		     dirname);
+	const char *const cmd_make[] = {"make", "-s", "-C", dirname, NULL};
+	const char *const cmd_make_clean[] = {
+		"make", "-C", dirname, "-s", "clean", NULL};
 
-		sindex--;
+	tst_run_cmd(cmd_make, NULL, NULL, 0);
+	tst_run_cmd(cmd_make_clean, NULL, NULL, 0);
 
-		/* remove all the ".c" files and makefile in this directory */
-		for (filecnt = 0; filecnt < numfiles; filecnt++) {
-			sprintf(filename, "%s/%ld.%d.%d.c", dirname, gettid(),
-				dircnt - 1, filecnt);
-			dprt("pid[%d]: removing file: %s\n", gettid(),
-			     filename);
-
-			if (unlink(filename)) {
-				dprt("pid[%d]: failed removing file: %s\n",
-				     gettid(), filename);
-				perror("rm_file_dir(): unlink()");
-				free(tmpdirname);
-				free(dirname);
-				free(filename);
-				free(subdir);
-				return 1;
-			}
-			sync();
-		}
-
-		sprintf(filename, "%s/%s", dirname, "makefile");
-		dprt("pid[%d]: removing %s\n", gettid(), filename);
-		if (unlink(filename)) {
-			perror
-			    ("rm_file_dir() cound not remove makefile unlink()");
-			free(tmpdirname);
-			free(dirname);
-			free(filename);
-			free(subdir);
-			return 1;
-		}
-		sync();
-
-		/* the last directory does not have any more sub directories */
-		/* nothing to remove.                                    */
-		dprt("pid[%d]: in directory count(dircnt): %d\n", gettid(),
-		     dircnt);
-		dprt("pid[%d]: last directory(numsdir): %d\n", gettid(),
-		     numsdir);
-		if (dircnt < numsdir) {
-			/* remove the sub directory */
-			sprintf(subdir, "%s/%ld.%d", dirname, gettid(), dircnt);
-			dprt("pid[%d]: removing subdirectory: %s\n", gettid(),
-			     subdir);
-			if (rmdir(subdir) == -1) {
-				perror("rm_file_dir() rmdir()");
-				free(tmpdirname);
-				free(dirname);
-				free(filename);
-				free(subdir);
-				return 1;
-			}
-			sync();
-		}
-	}
+	sync();
 
-	free(tmpdirname);
-	free(dirname);
-	free(filename);
-	free(subdir);
-	return 0;
+	return NULL;
 }
 
-/******************************************************************************/
-/*								 	      */
-/* Function:	crte_mk_rm						      */
-/*									      */
-/* Description:	This function gets executed by each thread that is created.   */
-/*		crte_mk_rm() created the directory tree, polpulates it with   */
-/*		".c" files and a makefile that will compile the ".c" files and*/
-/*		initiate the makefile in the subdirectory under it. Once the  */
-/*		c source files are compiled it will remove them.              */
-/*									      */
-/* Input:	The argument pointer contains the following.                  */
-/*		arg[0] - number of directories to create, depth of the tree.  */
-/*		arg[1] - number of ".c" files to create in each dir branch.   */
-/*									      */
-/* Return:	-1 on failure						      */
-/*		 0 on success					              */
-/*									      */
-/******************************************************************************/
-static void *crte_mk_rm(void *args)
+static void setup(void)
 {
-	int dircnt;		/* index to the number of subdirectories      */
-	int fd;			/* file discriptor of the files genetated     */
-	int filecnt;		/* index to the number of ".c" files created  */
-	int numchar[2];		/* number of characters written to buffer     */
-	char *dirname;		/* name of the directory/idirectory tree      */
-	char *tmpdirname;	/* name of a temporary directory, for swaping */
-	char *cfilename;	/* name of the ".c" file created              */
-	char *mkfilename;	/* name of the makefile - which is "makefile" */
-	char *hostname;		/* hostname of the client machine             */
-	char *prog_buf;		/* buffer containing contents of the ".c" file */
-	char *make_buf;		/* buffer the contents of the makefile        */
-	char *pwd;		/* contains the current working directory     */
-	long *locargptr =	/* local pointer to arguments                 */
-	    (long *)args;
-	volatile int exit_val = 0;	/* exit value of the pthreads                 */
-
-	if ((dirname = malloc(sizeof(char) * 2048)) == NULL) {	/* just paranoid */
-		perror("crte_mk_rm(): dirname malloc()");
-		PTHREAD_EXIT(-1);
-	}
-
-	if ((tmpdirname = malloc(sizeof(char) * 2048)) == NULL) {
-		perror("crte_mk_rm(): tmpdirname malloc()");
-		PTHREAD_EXIT(-1);
-	}
-
-	if ((cfilename = malloc(sizeof(char) * 2048)) == NULL) {
-		perror("crte_mk_rm(): cfilename malloc()");
-		PTHREAD_EXIT(-1);
-	}
-
-	if ((mkfilename = malloc(sizeof(char) * 2048)) == NULL) {
-		perror("crte_mk_rm(): mkfilename malloc()");
-		PTHREAD_EXIT(-1);
-	}
-
-	if ((prog_buf = malloc(sizeof(char) * 4096)) == NULL) {
-		perror("crte_mk_rm(): prog_buf malloc()");
-		PTHREAD_EXIT(-1);
-	}
-
-	if ((pwd = malloc(PATH_MAX)) == NULL) {
-		perror("crte_mk_rm(): pwd malloc()");
-		PTHREAD_EXIT(-1);
-	}
-
-	if ((hostname = malloc(sizeof(char) * 1024)) == NULL) {
-		perror("crte_mk_rm(): hostname malloc()");
-		PTHREAD_EXIT(-1);
-	}
-
-	if (gethostname(hostname, 255) == -1) {
-		perror("crte_mk_rm(): gethostname()");
-		PTHREAD_EXIT(-1);
-	}
-	if (!getcwd(pwd, PATH_MAX)) {
-		perror("crte_mk_rm(): getcwd()");
-		PTHREAD_EXIT(-1);
-	}
-
-	numchar[0] = sprintf(prog_buf,
-			     "main()\n{\n\t printf(\"hello world\");\n}\n");
-
-	for (dircnt = 0; dircnt < (int)locargptr[0]; dircnt++) {
-		/* First create the base directory, then create the subdirectories   */
-		if (dircnt == 0)
-			sprintf(dirname, "%s.%ld", hostname, gettid());
-		else {
-			sprintf(tmpdirname, "%s/%ld.%d", dirname, gettid(),
-				dircnt);
-			sprintf(dirname, "%s", tmpdirname);
-		}
-		sync();
-
-		dprt("pid[%d] creating directory: %s\n", gettid(), dirname);
-		if (mkdir(dirname, 0777) == -1) {
-			perror("crte_mk_rm(): mkdir()");
-			PTHREAD_EXIT(-1);
-		}
-	}
-
-	sync();
-	usleep(10);
-	for (dircnt = 0; dircnt < (int)locargptr[0]; dircnt++) {
-		if (dircnt == 0)
-			sprintf(dirname, "%s/%s.%ld", pwd, hostname, gettid());
-		else {
-			sprintf(tmpdirname, "%s/%ld.%d", dirname, gettid(),
-				dircnt);
-			sprintf(dirname, "%s", tmpdirname);
-		}
-		sync();
-		if ((make_buf = malloc(sizeof(char) * 4096)) == NULL) {
-			perror("crte_mk_rm(): make_buf malloc()");
-			PTHREAD_EXIT(-1);
-		}
-		sprintf(mkfilename, "%s/makefile", dirname);
-		{
-			/* HACK! I could not write "%.c" to the makefile */
-			/* there is probably a correct way to do it      */
-			char *dotc = malloc(10);
-			dotc = ".c";
-			sync();
-			usleep(10);
-			if (dircnt == (locargptr[0] - 1)) {
-				numchar[1] = sprintf(make_buf,
-						     "CFLAGS := -O -w -g\n"
-						     "SUBDIRS = %ld.%d\n"
-						     "SRCS=$(wildcard *.c)\n"
-						     "TARGETS=$(patsubst %%%s,\%%,$(SRCS))\n"
-						     "all:\t $(TARGETS)\n"
-						     "clean:\n"
-						     "\trm -f $(TARGETS)\n",
-						     gettid(), dircnt + 1,
-						     dotc);
-			} else {
-				numchar[1] = sprintf(make_buf,
-						     "CFLAGS := -O -w -g\n"
-						     "SUBDIRS = %ld.%d\n"
-						     "SRCS=$(wildcard *.c)\n"
-						     "TARGETS=$(patsubst %%%s,\%%,$(SRCS))\n\n\n"
-						     "all:\t $(TARGETS)\n"
-						     "\t@for i in $(SUBDIRS); do $(MAKE) -C $$i ; done\n\n"
-						     "clean:\n"
-						     "\trm -f $(TARGETS)\n"
-						     "\t@for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done\n",
-						     gettid(), dircnt + 1,
-						     dotc);
-			}
-		}
-
-		sync();
-		usleep(10);
-		dprt("pid[%d]: creating in dir: %s\n", gettid(), mkfilename);
-		/* create the makefile, complies .c files and initiates make in   */
-		/* subdirectories.                                                */
-		if ((fd = open(mkfilename, O_CREAT | O_RDWR,
-			       S_IRWXU | S_IRWXG | S_IRWXO)) == -1) {
-			dprt(" pid[%d]: failed to create makefile\n", gettid());
-			dprt("pid[%d]: failed in directory %s\n", gettid(),
-			     dirname);
-			perror("crte_mk_rm() failed creating makefile: open()");
-			PTHREAD_EXIT(-1);
-		} else {
-			sync();
-			if (write(fd, make_buf, numchar[1]) == -1) {
-				perror("crte_mk_rm(): write()");
-				PTHREAD_EXIT(-1);
-			}
-
-			free(make_buf);
-
-			if (close(fd) == -1) {
-				perror("crte_mk_rm(): close()");
-				PTHREAD_EXIT(-1);
-			}
-		}
-	}
-
-	for (dircnt = 0; dircnt < (int)locargptr[0]; dircnt++) {
-		if (dircnt == 0)
-			sprintf(dirname, "%s/%s.%ld", pwd, hostname, gettid());
-		else {
-			sprintf(tmpdirname, "%s/%ld.%d", dirname, gettid(),
-				dircnt);
-			sprintf(dirname, "%s", tmpdirname);
-		}
-		sync();
-		/* In each directory create N ".c" files and a makefile. */
-		for (filecnt = 0; filecnt < (int)locargptr[1]; filecnt++) {
-			sprintf(cfilename, "%s/%ld.%d.%d.c", dirname, gettid(),
-				dircnt, filecnt);
-			dprt("pid[%d]: creating file: %s\n", gettid(),
-			     cfilename);
-			if ((fd =
-			     open(cfilename, O_CREAT | O_RDWR,
-				  S_IRWXU | S_IRWXG | S_IRWXO)) == -1) {
-				fprintf(stderr,
-					"open() failed to create file %s\n",
-					cfilename);
-				perror
-				    ("crte_mk_rm(): failed creating .c files: open()");
-				PTHREAD_EXIT(-1);
-			} else {
-				sync();
-				/* write the code, this program prints hello world */
-				if (write(fd, prog_buf, numchar[0]) == -1) {
-					perror("crte_mk_rm(): write()");
-					PTHREAD_EXIT(-1);
-				}
-
-				fsync(fd);
-
-				if (close(fd) == -1) {
-					perror("crte_mk_rm(): close()");
-					PTHREAD_EXIT(-1);
-				}
-			}
-
-		}
-	}
-
-	if (init_compile(MAKE_EXE, pwd, hostname) == 1) {
-		fprintf(stderr, "init_compile() make failed\n");
-		PTHREAD_EXIT(-1);
-	} else {
-		if (init_compile(MAKE_CLEAN, pwd, hostname) == 1) {
-			fprintf(stderr, "init_compile() make clean failed\n");
-			PTHREAD_EXIT(-1);
-		}
-	}
-
-	sync();
-	/* remove all the files makefiles and subdirecotries  */
-	if (rm_file_dir((int)locargptr[0], (int)locargptr[1], hostname, pwd)) {
-		fprintf(stderr, "crte_mk_rm(): rm_file_dir() failed\n");
-		PTHREAD_EXIT(-1);
-	}
-	/* if it made it this far exit with success */
-	PTHREAD_EXIT(0);
+	thrd_num = atoi(t_arg);
+	dirs_num = atoi(d_arg);
+	file_num = atoi(f_arg);
 }
 
-/******************************************************************************/
-/*								 	      */
-/* Function:	main							      */
-/*									      */
-/* Description:	This is the entry point to the program. This function will    */
-/*		parse the input arguments and set the values accordingly. If  */
-/*		no arguments (or desired) are provided default values are used*/
-/*		refer the usage function for the arguments that this program  */
-/*		takes. It also creates the threads which do most of the dirty */
-/*		work. If the threads exits with a value '0' the program exits */
-/*		with success '0' else it exits with failure '-1'.             */
-/*									      */
-/* Return:	-1 on failure						      */
-/*		 0 on success						      */
-/*									      */
-/******************************************************************************/
-int main(int argc,		/* number of input parameters                 */
-	 char **argv)
-{				/* pointer to the command line arguments.     */
-	int c;			/* command line options                       */
-	int num_thrd = MAXT;	/* number of threads to create                */
-	int num_dirs = MAXD;	/* number of subdirectories to create         */
-	int num_files = MAXF;	/* number of files in each subdirectory      */
-	int thrd_ndx;		/* index into the array of thread ids         */
-	void *th_status;	/* exit status of LWP's                       */
-	pthread_t thrdid[30];	/* maxinum of 30 threads allowed              */
-	long chld_args[3];	/* arguments to the thread function           */
-	extern int optopt;	/* options to the program                     */
-
-	while ((c = getopt(argc, argv, "d:f:ht:")) != -1) {
-		switch (c) {
-		case 'd':	/* specify how deep the tree needs to grow    */
-			if ((num_dirs = atoi(optarg)) == 0)
-				OPT_MISSING(argv[0], optopt);
-			else if (num_dirs < 0) {
-				fprintf(stdout,
-					"WARNING: bad argument. Using default\n");
-				num_dirs = MAXD;
-			}
-			break;
-		case 'f':	/* how many ".c" files in each directory.     */
-			if ((num_files = atoi(optarg)) == 0)
-				OPT_MISSING(argv[0], optopt);
-			else if (num_files < 0) {
-				fprintf(stdout,
-					"WARNING: bad argument. Using default\n");
-				num_files = MAXF;
-			}
-			break;
-		case 'h':
-			usage(argv[0]);
-			break;
-		case 't':
-			if ((num_thrd = atoi(optarg)) == 0)
-				OPT_MISSING(argv[0], optopt);
-			else if (num_thrd < 0) {
-				fprintf(stdout,
-					"WARNING: bad argument. Using default\n");
-				num_thrd = MAXT;
-			}
-			break;
-		default:
-			usage(argv[0]);
-			break;
-		}
-	}
-
-	chld_args[0] = num_dirs;
-	chld_args[1] = num_files;
+static void do_test(void)
+{
+	int i;
+	pthread_t id[thrd_num];
 
-	for (thrd_ndx = 0; thrd_ndx < num_thrd; thrd_ndx++) {
-		if (pthread_create
-		    (&thrdid[thrd_ndx], NULL, crte_mk_rm, chld_args)) {
-			perror("crte_mk_rm(): pthread_create()");
-			exit(-1);
-		}
-	}
+	for (i = 0; i < thrd_num; ++i)
+		SAFE_PTHREAD_CREATE(id + i, NULL, thread_fn, NULL);
 
-	sync();
+	for (i = 0; i < thrd_num; ++i)
+		SAFE_PTHREAD_JOIN(id[i], NULL);
 
-	for (thrd_ndx = 0; thrd_ndx < num_thrd; thrd_ndx++) {
-		if (pthread_join(thrdid[thrd_ndx], &th_status) != 0) {
-			perror("crte_mk_rm(): pthread_join()");
-			exit(-1);
-		} else {
-			dprt("WE ARE HERE %d\n", __LINE__);
-			if (th_status == (void *)-1) {
-				fprintf(stderr,
-					"thread [%ld] - process exited with errors\n",
-					thrdid[thrd_ndx]);
-				exit(-1);
-			}
-		}
-	}
-	return (0);
+	tst_res(TPASS, "'make' successfully build and clean all targets");
 }
+
+static struct tst_test test = {
+	.tid = "nfs05_make_tree",
+	.options = opts,
+	.needs_tmpdir = 1,
+	.test_all = do_test,
+	.setup = setup,
+};
-- 
1.7.1


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

* [LTP] [PATCH 3/8] network/nfs_lib.sh: add options, socket type and NFS ver
  2016-06-20 14:28 [LTP] [PATCH 0/8] network/nfs: fix/cleanup tests Alexey Kodanev
  2016-06-20 14:28 ` [LTP] [PATCH resend 1/8] lib: add safe_gethostname() Alexey Kodanev
  2016-06-20 14:28 ` [LTP] [PATCH resend 2/8] network/nfs05: rewrite the test, make use of new library Alexey Kodanev
@ 2016-06-20 14:28 ` Alexey Kodanev
  2016-06-20 14:28 ` [LTP] [PATCH 4/8] network/nfs/fsx: cleanup test, use test_net library Alexey Kodanev
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Alexey Kodanev @ 2016-06-20 14:28 UTC (permalink / raw)
  To: ltp

Additionally, add more configurations including NFSv4.2.

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 runtest/net.nfs                             |   62 ++++++++++++++++++---------
 testcases/network/nfs/nfs_stress/nfs_lib.sh |   32 ++++++++++++--
 2 files changed, 68 insertions(+), 26 deletions(-)

diff --git a/runtest/net.nfs b/runtest/net.nfs
index 43cf504..7208a3b 100644
--- a/runtest/net.nfs
+++ b/runtest/net.nfs
@@ -1,31 +1,51 @@
 #DESCRIPTION:Network filesystem stress
 #
-# PLEASE READ THE README FILE IN /nfs BEFORE RUNNING THESE.
+# PLEASE READ THE README FILE network/README.md BEFORE RUNNING THESE.
 #
-nfs3_01 export VERSION=3 SOCKET_TYPE=udp; nfs01
-nfs4_01 export VERSION=4 SOCKET_TYPE=tcp; nfs01
-nfs3_ipv6_01 export VERSION=3 SOCKET_TYPE=udp; nfs01 -6
-nfs4_ipv6_01 export VERSION=4 SOCKET_TYPE=tcp; nfs01 -6
+nfs3_01 nfs01 -v 3 -t udp
+nfs4_01 nfs01 -v 3 -t tcp
+nfs41_01 nfs01 -v 4.1 -t tcp
+nfs42_01 nfs01 -v 4.2 -t tcp
+nfs3_ipv6_01 nfs01 -6 -v 3 -t udp
+nfs4_ipv6_01 nfs01 -6 -v 4 -t tcp
+nfs41_ipv6_01 nfs01 -6 -v 4.1 -t tcp
+nfs42_ipv6_01 nfs01 -6 -v 4.2 -t tcp
 
-nfs3_02 export VERSION=3 SOCKET_TYPE=udp; nfs02
-nfs4_02 export VERSION=4 SOCKET_TYPE=tcp; nfs02
-nfs3_ipv6_02 export VERSION=3 SOCKET_TYPE=udp; nfs02 -6
-nfs4_ipv6_02 export VERSION=4 SOCKET_TYPE=tcp; nfs02 -6
+nfs3_02 nfs02 -v 3 -t udp
+nfs4_02 nfs02 -v 3 -t tcp
+nfs41_02 nfs02 -v 4.1 -t tcp
+nfs42_02 nfs02 -v 4.2 -t tcp
+nfs3_ipv6_02 nfs02 -6 -v 3 -t udp
+nfs4_ipv6_02 nfs02 -6 -v 4 -t tcp
+nfs41_ipv6_02 nfs02 -6 -v 4.1 -t tcp
+nfs42_ipv6_02 nfs02 -6 -v 4.2 -t tcp
 
-nfs3_03 export VERSION=3 SOCKET_TYPE=udp; nfs03
-nfs4_03 export VERSION=4 SOCKET_TYPE=tcp; nfs03
-nfs3_ipv6_03 export VERSION=3 SOCKET_TYPE=udp; nfs03 -6
-nfs4_ipv6_03 export VERSION=4 SOCKET_TYPE=tcp; nfs03 -6
+nfs3_03 nfs03 -v 3 -t udp
+nfs4_03 nfs03 -v 3 -t tcp
+nfs41_03 nfs03 -v 4.1 -t tcp
+nfs42_03 nfs03 -v 4.2 -t tcp
+nfs3_ipv6_03 nfs03 -6 -v 3 -t udp
+nfs4_ipv6_03 nfs03 -6 -v 4 -t tcp
+nfs41_ipv6_03 nfs03 -6 -v 4.1 -t tcp
+nfs42_ipv6_03 nfs03 -6 -v 4.2 -t tcp
 
-nfs3_04 export VERSION=3 SOCKET_TYPE=udp; nfs04
-nfs4_04 export VERSION=4 SOCKET_TYPE=tcp; nfs04
-nfs3_ipv6_04 export VERSION=3 SOCKET_TYPE=udp; nfs04 -6
-nfs4_ipv6_04 export VERSION=4 SOCKET_TYPE=tcp; nfs04 -6
+nfs3_04 nfs04 -v 3 -t udp
+nfs4_04 nfs04 -v 3 -t tcp
+nfs41_04 nfs04 -v 4.1 -t tcp
+nfs42_04 nfs04 -v 4.2 -t tcp
+nfs3_ipv6_04 nfs04 -6 -v 3 -t udp
+nfs4_ipv6_04 nfs04 -6 -v 4 -t tcp
+nfs41_ipv6_04 nfs04 -6 -v 4.1 -t tcp
+nfs42_ipv6_04 nfs04 -6 -v 4.2 -t tcp
 
-nfs3_05 export VERSION=3 SOCKET_TYPE=udp; nfs05
-nfs4_05 export VERSION=4 SOCKET_TYPE=tcp; nfs05
-nfs3_ipv6_05 export VERSION=3 SOCKET_TYPE=udp; nfs05 -6
-nfs4_ipv6_05 export VERSION=4 SOCKET_TYPE=tcp; nfs05 -6
+nfs3_05 nfs05 -v 3 -t udp
+nfs4_05 nfs05 -v 4 -t tcp
+nfs41_05 nfs05 -v 4.1 -t tcp
+nfs42_05 nfs05 -v 4.2 -t tcp
+nfs3_ipv6_05 nfs05 -6 -v 3 -t udp
+nfs4_ipv6_05 nfs05 -6 -v 4 -t tcp
+nfs41_ipv6_05 nfs05 -6 -v 4.1 -t tcp
+nfs42_ipv6_05 nfs05 -6 -v 4.2 -t tcp
 
 nfslock01 export VERSION; TCbin=$LTPROOT/testcases/bin nfslock01
 
diff --git a/testcases/network/nfs/nfs_stress/nfs_lib.sh b/testcases/network/nfs/nfs_stress/nfs_lib.sh
index 38fec05..aca150d 100644
--- a/testcases/network/nfs/nfs_stress/nfs_lib.sh
+++ b/testcases/network/nfs/nfs_stress/nfs_lib.sh
@@ -1,4 +1,4 @@
-# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) 2015-2016 Oracle and/or its affiliates. All Rights Reserved.
 # Copyright (c) International Business Machines  Corp., 2001
 #
 # This program is free software; you can redistribute it and/or
@@ -14,12 +14,34 @@
 # You should have received a copy of the GNU General Public License
 # along with this program. If not, see <http://www.gnu.org/licenses/>.
 
+VERSION=${VERSION:=3}
+NFILES=${NFILES:=1000}
+SOCKET_TYPE="${SOCKET_TYPE:-udp}"
+NFS_TYPE=${NFS_TYPE:=nfs}
+
+while getopts :ht:v:6 opt; do
+	case "$opt" in
+	h)
+		echo "Usage:"
+		echo "h        help"
+		echo "t x      socket type, tcp or udp, default is udp"
+		echo "v x      NFS version, default is '3'"
+		echo "6        run over IPv6"
+		exit 0
+	;;
+	v) VERSION=$OPTARG ;;
+	t) SOCKET_TYPE=$OPTARG ;;
+	6) # skip, test_net library already processed it
+	;;
+	*)
+		tst_brkm TBROK "unknown option: $opt"
+	;;
+	esac
+done
+
 nfs_setup()
 {
-	VERSION=${VERSION:=3}
-	NFILES=${NFILES:=1000}
-	SOCKET_TYPE="${SOCKET_TYPE:=udp}${TST_IPV6}"
-	NFS_TYPE=${NFS_TYPE:=nfs}
+	SOCKET_TYPE="${SOCKET_TYPE}${TST_IPV6}"
 
 	tst_check_cmds mount exportfs
 
-- 
1.7.1


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

* [LTP] [PATCH 4/8] network/nfs/fsx: cleanup test, use test_net library
  2016-06-20 14:28 [LTP] [PATCH 0/8] network/nfs: fix/cleanup tests Alexey Kodanev
                   ` (2 preceding siblings ...)
  2016-06-20 14:28 ` [LTP] [PATCH 3/8] network/nfs_lib.sh: add options, socket type and NFS ver Alexey Kodanev
@ 2016-06-20 14:28 ` Alexey Kodanev
  2016-06-20 14:28 ` [LTP] [PATCH 5/8] network/nfs/nfsstat: cleanup test, use test_net.sh library Alexey Kodanev
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Alexey Kodanev @ 2016-06-20 14:28 UTC (permalink / raw)
  To: ltp

With nfs_lib.sh we can test several versions of NFS,
so changing test-cases in runtest/net.nfs as well.

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 runtest/net.nfs                        |   10 ++-
 testcases/network/nfs/fsx-linux/fsx.sh |  204 +++++---------------------------
 2 files changed, 38 insertions(+), 176 deletions(-)

diff --git a/runtest/net.nfs b/runtest/net.nfs
index 7208a3b..5853573 100644
--- a/runtest/net.nfs
+++ b/runtest/net.nfs
@@ -50,4 +50,12 @@ nfs42_ipv6_05 nfs05 -6 -v 4.2 -t tcp
 nfslock01 export VERSION; TCbin=$LTPROOT/testcases/bin nfslock01
 
 nfsstat01 export VERSION; TCbin=$LTPROOT/testcases/bin nfsstat01
-nfsx-linux export VERSION SOCKET_TYPE; TCbin=$LTPROOT/testcases/bin fsx.sh
+
+nfsx3 fsx.sh -v 3 -t udp
+nfsx4 fsx.sh -v 4 -t tcp
+nfsx41 fsx.sh -v 4.1 -t tcp
+nfsx42 fsx.sh -v 4.2 -t tcp
+nfsx3_ipv6 fsx.sh -6 -v 3 -t udp
+nfsx4_ipv6 fsx.sh -6 -v 4 -t tcp
+nfsx41_ipv6 fsx.sh -6 -v 4.1 -t tcp
+nfsx42_ipv6 fsx.sh -6 -v 4.2 -t tcp
diff --git a/testcases/network/nfs/fsx-linux/fsx.sh b/testcases/network/nfs/fsx-linux/fsx.sh
index facc708..9f2e437 100755
--- a/testcases/network/nfs/fsx-linux/fsx.sh
+++ b/testcases/network/nfs/fsx-linux/fsx.sh
@@ -1,194 +1,48 @@
-#! /bin/sh
+#!/bin/sh
+# Copyright (c) 2016 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) International Business Machines  Corp., 2001
 #
-#   Copyright (c) International Business Machines  Corp., 2001
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
 #
-#   This program is free software;  you can redistribute it and/or modify
-#   it under the terms of the GNU General Public License as published by
-#   the Free Software Foundation; either version 2 of the License, or
-#   (at your option) any later version.
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
 #
-#   This program is distributed in the hope that it will be useful,
-#   but WITHOUT ANY WARRANTY;  without even the implie; warranty of
-#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
-#   the GNU General Public License for more details.
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
 #
-#   You should have received a copy of the GNU General Public License
-#   along with this program;  if not, write to the Free Software
-#   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-#
-#
-#
-#  FILE   : fsx.sh
 #
 #  PURPOSE: Runs the fsx-linux tool with a 50000 iterations setting to
 #	    attempt to uncover the "doread:read input/output" error
 #	    received if the latest NFS patches for 2.4.17 from Trond
 #	    are not applied. http://nfs.sf.net
-#
-#
-#  SETUP: The home directory of root on the machine exported as "RHOST"
-#         MUST have a ".rhosts" file with the hostname of the machine
-#         where the test is executed.
-#
-#
-#  HISTORY:
-#    12/18/01 Robbie Williamson (robbiew@us.ibm.com)
-#      -Written
-#
-#***********************************************************************
-
-#Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-
-$trace_logic
-
-#-----------------------------------------------------------------------
-# Initialize local variables
-#-----------------------------------------------------------------------
-TC=${TC:=fsx}
-TCbin=${TCbin:=`pwd`}
-TCdat=${TCdat:=$TCbin}
-TCsrc=${TCsrc:=$TCbin}
-TCtmp=${TCtmp:=$TCbin/$TC$$}
-TCdump=${TCdump:=$TCbin}
-export TCID=$TC
-export TST_TOTAL=1
-export TST_COUNT=1
-
-# If CLEANUP is not set; set it to "ON"
-CLEANUP=${CLEANUP:="ON"}
-
-# If EXECUTABLES is not set; set it to default executables
-EXECUTABLES=${EXECUTABLES:="fsx-linux"}
-
-
-#=============================================================================
-# FUNCTION NAME:        setup_testcase
-#
-# FUNCTION DESCRIPTION: Perform the setup function for the testcase.
-#
-# PARAMETERS:   	None.
-#
-# RETURNS:      	None.
-#=============================================================================
-
-setup_testcase()
-{
-$trace_logic
-
-    PID=$$
-
-    VERSION=${VERSION:=3}
-    RHOST=${RHOST:=`hostname`}
-    ITERATIONS=${ITERATIONS:=50000}
-    SOCKET_TYPE=${SOCKET_TYPE:=udp}
-    TESTDIR=${TESTDIR:=/tmp/$TC$PID.testdir}
-    NFS_TYPE=${NFS_TYPE:=nfs}
 
-    echo ""
-    echo "Test Options:"
-    echo " VERSION: $VERSION"
-    echo " RHOST: $RHOST"
-    echo " ITERATIONS: $ITERATIONS"
-    echo " SOCKET_TYPE: $SOCKET_TYPE"
-    echo " NFS_TYPE: $NFS_TYPE"
+TCID=nfsx
+TST_TOTAL=1
+TST_CLEANUP="nfs_cleanup"
 
-    if [ "x$NFS_TYPE" != "xnfs4" ]; then
-        OPTS=${OPTS:="-o proto=$SOCKET_TYPE,vers=$VERSION "}
-    fi
+. nfs_lib.sh
+. test_net.sh
 
-    REMOTE_DIR=${RHOST}:${TESTDIR}
-    LUSER=${LUSER:=root}
-    mkdir -p $TCtmp || end_testcase "Could not create $TCtmp"
-    chmod 777 $TCtmp
-
-    echo "Setting up remote machine: $RHOST"
-    rsh -n $RHOST "mkdir $TESTDIR"
-    [ $? = 0 ] || end_testcase "Could not create remote directory"
-    rsh -n $RHOST "touch $TESTDIR/testfile"
-    [ $? = 0 ] || end_testcase "Could not create testfile in remote directory"
-
-    if [ "x$NFS_TYPE" = "xnfs4" ]; then
-        rsh -n $RHOST "mkdir -p /export$TESTDIR"
-        [ $? = 0 ] || end_testcase "Could not create /export$TESTDIR on server"
-        rsh -n $RHOST "mount --bind $TESTDIR /export$TESTDIR"
-        [ $? = 0 ] || end_testcase "Could not bind $TESTDIR to export on server"
-        rsh -n $RHOST "/usr/sbin/exportfs -o no_root_squash,rw,nohide,insecure,no_subtree_check *:$TESTDIR"
-        [ $? = 0 ] || end_testcase "Could not export remote directory"
-    else
-        rsh -n $RHOST "/usr/sbin/exportfs -i -o no_root_squash,rw *:$TESTDIR"
-        [ $? = 0 ] || end_testcase "Could not export remote directory"
-    fi
-
-    echo "Mounting NFS filesystem $REMOTE_DIR on $TCtmp with options '$OPTS'"
-    mount -t $NFS_TYPE $OPTS $REMOTE_DIR $TCtmp || end_testcase "Cannot mount $TCtmp"
-    [ $? = 0 ] || end_testcase "Could not mount $REMOTE_DIR"
-}
-
-
-#=============================================================================
-# FUNCTION NAME:        do_test
-#
-# FUNCTION DESCRIPTION: Perform the test
-#
-# PARAMETERS:   	None.
-#
-# RETURNS:      	None.
-#=============================================================================
 do_test()
 {
-$trace_logic
-    for executable in $EXECUTABLES
-    do
-
-        cd $TCbin
-    	echo "${executable} -N $ITERATIONS $TCtmp/testfile Starting"
-	./${executable} -N $ITERATIONS $TCtmp/testfile 2>&1
-	retval=$?
-    	echo "${executable} -N $ITERATIONS $TCtmp/testfile Finished"
-
-	if [ "$retval" != 0 ]; then
-		end_testcase "Errors have resulted from this test"
+	ITERATIONS=${ITERATIONS:=50000}
+	tst_resm TINFO "starting fsx-linux -N $ITERATIONS..."
+	fsx-linux -N $ITERATIONS testfile 2>&1 > fsx-out.log
+	if [ "$?" -ne 0 ]; then
+		tst_resm TFAIL "Errors have resulted from this test"
+		cat fsx-out.log
+	else
+		tst_resm TPASS "fsx-linux test passed"
 	fi
-
-    done
 }
 
+nfs_setup
 
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:   	None.
-#
-# RETURNS:      	None.
-#=============================================================================
-end_testcase()
-{
-$trace_logic
-    if [ "$CLEANUP" = "ON" ]; then
-	cd \
-
-	echo "Cleaning up testcase"
-        cd $HOME
-    	echo "Unmounting $TCtmp"
-	sleep 2
-        umount $TCtmp || { echo "Cannot umount $TCtmp"; exit 1; }
-	rm -rf $TCtmp || echo "Cannot remove $TCtmp"
-        rsh -n $RHOST "/usr/sbin/exportfs -u *:$TESTDIR"
- rsh -n $RHOST "rm -rf $TESTDIR"
-    fi
-
-    [ $# = 0 ] && { tst_resm TPASS "Test Successful"; exit 0; }
-    tst_resm TFAIL "Test Failed: $@"
-    exit 1
-}
-
-#=============================================================================
-# MAIN PROCEDURE
-#=============================================================================
-
-setup_testcase
 do_test
-end_testcase
+
+tst_exit
-- 
1.7.1


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

* [LTP] [PATCH 5/8] network/nfs/nfsstat: cleanup test, use test_net.sh library
  2016-06-20 14:28 [LTP] [PATCH 0/8] network/nfs: fix/cleanup tests Alexey Kodanev
                   ` (3 preceding siblings ...)
  2016-06-20 14:28 ` [LTP] [PATCH 4/8] network/nfs/fsx: cleanup test, use test_net library Alexey Kodanev
@ 2016-06-20 14:28 ` Alexey Kodanev
  2016-06-20 14:28 ` [LTP] [PATCH 6/8] network/nfs/nfsflock: clenaup & use test_net library Alexey Kodanev
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Alexey Kodanev @ 2016-06-20 14:28 UTC (permalink / raw)
  To: ltp

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 runtest/net.nfs                           |    2 +-
 testcases/network/nfs/nfsstat01/nfsstat01 |  343 +++++++++--------------------
 2 files changed, 103 insertions(+), 242 deletions(-)

diff --git a/runtest/net.nfs b/runtest/net.nfs
index 5853573..81d75aa 100644
--- a/runtest/net.nfs
+++ b/runtest/net.nfs
@@ -49,7 +49,7 @@ nfs42_ipv6_05 nfs05 -6 -v 4.2 -t tcp
 
 nfslock01 export VERSION; TCbin=$LTPROOT/testcases/bin nfslock01
 
-nfsstat01 export VERSION; TCbin=$LTPROOT/testcases/bin nfsstat01
+nfsstat3_01 nfsstat01
 
 nfsx3 fsx.sh -v 3 -t udp
 nfsx4 fsx.sh -v 4 -t tcp
diff --git a/testcases/network/nfs/nfsstat01/nfsstat01 b/testcases/network/nfs/nfsstat01/nfsstat01
index 4a34d93..256fe60 100755
--- a/testcases/network/nfs/nfsstat01/nfsstat01
+++ b/testcases/network/nfs/nfsstat01/nfsstat01
@@ -1,261 +1,122 @@
-#! /bin/sh
+#!/bin/sh
+# Copyright (c) 2016 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) International Business Machines  Corp., 2001
 #
-#   Copyright (c) International Business Machines  Corp., 2001
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
 #
-#   This program is free software;  you can redistribute it and/or modify
-#   it under the terms of the GNU General Public License as published by
-#   the Free Software Foundation; either version 2 of the License, or
-#   (at your option) any later version.
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
 #
-#   This program is distributed in the hope that it will be useful,
-#   but WITHOUT ANY WARRANTY;  without even the implie; warranty of
-#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
-#   the GNU General Public License for more details.
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
 #
-#   You should have received a copy of the GNU General Public License
-#   along with this program;  if not, write to the Free Software
-#   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 #
-#  FILE   : nfsstat
-#
-#  PURPOSE: Tests the 'nfsstat' command.  This test runs locally, so no
-#           actual network connection is needed.
-#
-#  SETUP: The nfs server/client daemons must be active.
-#
-#
-#  HISTORY:
-#    07/30/01 Robbie Williamson (robbiew@us.ibm.com)
-#      -Written
-#
-#**********************************************************************
-
-#Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-
-$trace_logic
 
-#-----------------------------------------------------------------------
-# Initialize local variables
-#-----------------------------------------------------------------------
+TCID=nfsstat01
+TST_TOTAL=4
+TST_CLEANUP="nfs_cleanup"
 
-PID=$$
+. nfs_lib.sh
+. test_net.sh
 
-TC=nfsstat01
-TCbin=${TCbin:=`pwd`}
-EXPORTDIR=${EXPORTDIR:=/tmp/$TC$PID}
-HOST=`hostname`
-CLEANUP=${CLEANUP:="ON"}
-VERSION=${VERSION:=3}
-TESTDIR=${TESTDIR:=/tmp/$TC$PID.testdir}
-NFS_TYPE=${NFS_TYPE:=nfs}
-export TCID=$TC
-export TST_TOTAL=1
-export TST_COUNT=1
-
-if [ "x$NFS_TYPE" != "xnfs4" ]; then
-    OPTS=${OPTS:="-o vers=$VERSION "}
-fi
-
-#---------------------------------------------------------------------#
-# FUNCTION: do_setup
-# PURPOSE:  To create the necessary files to carry out the test
-# INPUT:    None.
-# OUTPUT:   None.
-#---------------------------------------------------------------------#
-do_setup()
+setup()
 {
-$trace_logic
-
-   echo "do_setup $TC"
-
-   echo "This test runs LOCALLY."
-
-   IAM=${IAM:=`whoami`}
-   [ $IAM = "root" ] || end_testcase "Must be root user"
-
-   #Check for mountd.
-   rpcinfo -p | grep mountd
-   [ $? -eq 0 ] || end_testcase "Mountd is NOT running"
-
-   #Check for nfsd.
-   rpcinfo -p | grep nfs
-   [ $? -eq 0 ] || end_testcase "NFS server daemon (nfsd) is NOT running"
-
-   #Create export directory
-   mkdir -p $EXPORTDIR
-   [ $? -eq 0 ] || end_testcase "Could not create $EXPORTDIR"
-
-   #Export the data directory on HOST
-   if [ "x$NFS_TYPE" = "xnfs4" ]; then
-        mkdir -p /export$EXPORTDIR
-        [ $? = 0 ] || end_testcase "Could not create /export$EXPORTDIR locally"
-        mount --bind $EXPORTDIR /export$EXPORTDIR
-        [ $? = 0 ] || end_testcase "Could not bind $EXPORTDIR to /export"
-        /usr/sbin/exportfs -o no_root_squash,rw,nohide,insecure,no_subtree_check $HOST:$EXPORTDIR > /dev/null
-        [ $? = 0 ] || end_testcase "Could not export $EXPORTDIR on $HOST"
-    else
-       /usr/sbin/exportfs -i -o rw,no_root_squash $HOST:/$EXPORTDIR > /dev/null
-       [ $? -eq 0 ] || end_testcase "Could not export $EXPORTDIR on $HOST"
-   fi
-
-   #Verify export
-   showmount -e $HOST | grep $EXPORTDIR > /dev/null
-   [ $? -eq 0 ] || end_testcase "$EXPORTDIR not exported"
-
-   #Create mount point
-   mkdir -p $TESTDIR
-   [ $? -eq 0 ] || end_testcase "Could not create $TESTDIR"
-
-   #Mount from HOST.
-   mount -t $NFS_TYPE $OPTS $HOST:$EXPORTDIR $TESTDIR
-   [ $? -eq 0 ] || end_testcase "Could not mount from $HOST"
-
+	tst_check_cmds nfsstat
+	nfs_setup
 }
 
+get_calls()
+{
+	local name=$1
+	local field=$2
+	local nfs_f=$3
+	local calls=
+	local opt=
+	[ "$name" = "rpc" ] && opt="r" || opt="n"
+
+	if [ "$nfs_f" = "nfs" ]; then
+		calls="$(grep $name /proc/net/rpc/$nfs_f | cut -d' ' -f$field)"
+		ROD nfsstat -c$opt | grep -q "$calls"
+		echo "$calls"
+		return
+	fi
+
+	calls=$(tst_rhost_run -c "grep $name /proc/net/rpc/$nfs_f" | \
+		cut -d' ' -f$field)
+	tst_rhost_run -s -c "nfsstat -s$opt" | grep -q "$calls"
+	echo "$calls"
+}
 
-#---------------------------------------------------------------------#
-# FUNCTION: do_test
 # PURPOSE:  Performs simple copies and removes to verify statistic
 #           tracking using the 'nfsstat' command and /proc/net/rpc
-#---------------------------------------------------------------------#
 do_test()
 {
-$trace_logic
-  echo "do_test $TC"
-
-  echo "Checking RPC calls for server and client"
-
-  # Server
-  SERVER_CALLS=`cat /proc/net/rpc/nfsd | grep rpc | awk '{print $2}'`
-  nfsstat -sr | grep $SERVER_CALLS
-  [ $? -eq 0 ] || end_testcase "Check of server RPC calls failed"
-
-  # Client
-  CLIENT_CALLS=`cat /proc/net/rpc/nfs | grep rpc | awk '{print $2}'`
-  nfsstat -cr | grep $CLIENT_CALLS
-  [ $? -eq 0 ] || end_testcase "Check of client RPC calls failed"
-
-
-  echo "Checking for tracking of RPC calls for server and client"
-  cat /proc/cpuinfo > $TESTDIR/nfsstat01.tmp
-  NEW_SERVER_CALLS=`cat /proc/net/rpc/nfsd | grep rpc | awk '{print $2}'`
-  [ $NEW_SERVER_CALLS -gt $SERVER_CALLS ] || end_testcase "Server RPC calls not increased"
-  NEW_CLIENT_CALLS=`cat /proc/net/rpc/nfs | grep rpc | awk '{print $2}'`
-  [ $NEW_CLIENT_CALLS -gt $CLIENT_CALLS ] || end_testcase "Client RPC calls not increased"
-
-  nfsstat -sr | grep $NEW_SERVER_CALLS
-  [ $? -eq 0 ] || end_testcase "nfsstat not reporting change in server RPC calls"
-  nfsstat -cr | grep $NEW_CLIENT_CALLS
-  [ $? -eq 0 ] || end_testcase "nfsstat not reporting change in client RPC calls"
-
-
-  echo "Checking NFS calls for server and client"
-
-  # Server
-  if [ "$VERSION" = "2" ]; then
-   SERVER_CALLS=`cat /proc/net/rpc/nfsd | grep proc2 | awk '{print $13}'`
-  else
-   SERVER_CALLS=`cat /proc/net/rpc/nfsd | grep proc3 | awk '{print $15}'`
-  fi
-  nfsstat -sn | grep $SERVER_CALLS
-  [ $? -eq 0 ] || end_testcase "Check of server NFS calls failed"
-
-  # Client
-  if [ "$VERSION" = "2" ]; then
-    CLIENT_CALLS=`cat /proc/net/rpc/nfs | grep proc2 | awk '{print $13}'`
-  else
-    CLIENT_CALLS=`cat /proc/net/rpc/nfs | grep proc3 | awk '{print $15}'`
-  fi
-  nfsstat -cn | grep $CLIENT_CALLS
-  [ $? -eq 0 ] || end_testcase "Check of client NFS calls failed"
-
-
-  echo "Checking for tracking of NFS calls for server and client"
-
-  rm -f $TESTDIR/nfsstat01.tmp
-  if [ "$VERSION" = "2" ]; then
-   NEW_SERVER_CALLS=`cat /proc/net/rpc/nfsd | grep proc2 | awk '{print $13}'`
-  else
-   NEW_SERVER_CALLS=`cat /proc/net/rpc/nfsd | grep proc3 | awk '{print $15}'`
-  fi
-  [ $NEW_SERVER_CALLS -gt $SERVER_CALLS ] || end_testcase "Server NFS calls not increased"
-
-  if [ "$VERSION" = "2" ]; then
-    NEW_CLIENT_CALLS=`cat /proc/net/rpc/nfs | grep proc2 | awk '{print $13}'`
-  else
-    NEW_CLIENT_CALLS=`cat /proc/net/rpc/nfs | grep proc3 | awk '{print $15}'`
-  fi
-  [ $NEW_CLIENT_CALLS -gt $CLIENT_CALLS ] || end_testcase "Client NFS calls not increased"
-
-  nfsstat -sn | grep $NEW_SERVER_CALLS
-  [ $? -eq 0 ] || end_testcase "nfsstat not reporting change in server NFS calls"
-  nfsstat -cn | grep $NEW_CLIENT_CALLS
-  [ $? -eq 0 ] || end_testcase "nfsstat not reporting change in client NFS calls"
-
-
-}
-
-#---------------------------------------------------------------------#
-# FUNCTION: do_cleanup
-# PURPOSE:  To delete all the files created to run this test.
-# INPUT:    None.
-# OUTPUT:   None.
-#---------------------------------------------------------------------#
-do_cleanup()
-{
-$trace_logic
-   echo "do_cleanup $TC "
-
-   echo "Unmounting TESTDIR"
-   umount $TESTDIR
-   sleep 3
-   rm -rf $TESTDIR
-   sleep 3
-
-   echo "Unmounting EXPORTDIR"
-   /usr/sbin/exportfs -u $HOST:$EXPORTDIR
-
-   if [ "x$NFS_TYPE" = "xnfs4" ]; then
-       umount $EXPORTDIR
-       sleep 3
-       rm -rf /export$EXPORTDIR
-   fi
-
-   rm -rf $EXPORTDIR
-
+	tst_resm TINFO "checking RPC calls for server/client"
+
+	local server_calls="$(get_calls rpc 2 nfsd)"
+	local client_calls="$(get_calls rpc 2 nfs)"
+
+	tst_resm TINFO "calls $server_calls/$client_calls"
+
+	tst_resm TINFO "Checking for tracking of RPC calls for server/client"
+	cat /proc/cpuinfo > nfsstat01.tmp
+
+	local new_server_calls="$(get_calls rpc 2 nfsd)"
+	local new_client_calls="$(get_calls rpc 2 nfs)"
+	tst_resm TINFO "new calls $new_server_calls/$new_client_calls"
+
+	if [ "$new_server_calls" -le "$server_calls" ]; then
+		tst_resm TFAIL "server RPC calls not increased"
+	else
+		tst_resm TPASS "server RPC calls increased"
+	fi
+
+	if [ "$new_client_calls" -le "$client_calls" ]; then
+		tst_resm TFAIL "client RPC calls not increased"
+	else
+		tst_resm TPASS "client RPC calls increased"
+	fi
+
+	tst_resm TINFO "checking NFS calls for server/client"
+	local field=
+	case $VERSION in
+	2) field=13
+	;;
+	*) field=15
+	;;
+	esac
+
+	server_calls="$(get_calls proc$VERSION $field nfsd)"
+	client_calls="$(get_calls proc$VERSION $field nfs)"
+	tst_resm TINFO "calls $server_calls/$client_calls"
+
+	tst_resm TINFO "Checking for tracking of NFS calls for server/client"
+	rm -f nfsstat01.tmp
+
+	new_server_calls="$(get_calls proc$VERSION $field nfsd)"
+	new_client_calls="$(get_calls proc$VERSION $field nfs)"
+	tst_resm TINFO "new calls $new_server_calls/$new_client_calls"
+
+	if [ "$new_server_calls" -le "$server_calls" ]; then
+		tst_resm TFAIL "server NFS calls not increased"
+	else
+		tst_resm TPASS "server NFS calls increased"
+	fi
+
+	if [ "$new_client_calls" -le "$client_calls" ]; then
+		tst_resm TFAIL "client NFS calls not increased"
+	else
+		tst_resm TPASS "client NFS calls increased"
+	fi
 }
 
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:           None.
-#
-# RETURNS:              None.
-#=============================================================================
-end_testcase()
-{
-$trace_logic
-    if [ "$CLEANUP" = "ON" ]; then
-       do_cleanup
-    fi
+setup
 
-    [ $# = 0 ] && { tst_resm TPASS "Test Successful"; exit 0; }
-    tst_resm TFAIL "Test Failed: $@"
-    exit 1
-}
-
-#=============================================================================
-#---------------------------------------------------------------------#
-# FUNCTION: MAIN
-# PURPOSE:  To invoke the functions to perform the tasks described in
-#           the prologue.
-# INPUT:    None.
-# OUTPUT:   A testcase run log with the results of the execution of this
-#           test.
-#---------------------------------------------------------------------#
-do_setup
 do_test
-end_testcase
+
+tst_exit
-- 
1.7.1


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

* [LTP] [PATCH 6/8] network/nfs/nfsflock: clenaup & use test_net library
  2016-06-20 14:28 [LTP] [PATCH 0/8] network/nfs: fix/cleanup tests Alexey Kodanev
                   ` (4 preceding siblings ...)
  2016-06-20 14:28 ` [LTP] [PATCH 5/8] network/nfs/nfsstat: cleanup test, use test_net.sh library Alexey Kodanev
@ 2016-06-20 14:28 ` Alexey Kodanev
  2016-06-20 14:28 ` [LTP] [PATCH 7/8] network/nfs/nfs_fsstress: remove fsstress test Alexey Kodanev
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Alexey Kodanev @ 2016-06-20 14:28 UTC (permalink / raw)
  To: ltp

Add new test configurations and remove not used nfs_flock_frk.

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 runtest/net.nfs                                 |    9 ++-
 testcases/network/.gitignore                    |    1 -
 testcases/network/nfs/nfslock01/nfs_flock_frk.c |   39 ------
 testcases/network/nfs/nfslock01/nfslock01       |  155 ++++++-----------------
 4 files changed, 44 insertions(+), 160 deletions(-)
 delete mode 100644 testcases/network/nfs/nfslock01/nfs_flock_frk.c

diff --git a/runtest/net.nfs b/runtest/net.nfs
index 81d75aa..9898f1b 100644
--- a/runtest/net.nfs
+++ b/runtest/net.nfs
@@ -47,7 +47,14 @@ nfs4_ipv6_05 nfs05 -6 -v 4 -t tcp
 nfs41_ipv6_05 nfs05 -6 -v 4.1 -t tcp
 nfs42_ipv6_05 nfs05 -6 -v 4.2 -t tcp
 
-nfslock01 export VERSION; TCbin=$LTPROOT/testcases/bin nfslock01
+nfslock3_01 nfslock01 -v 3 -t udp
+nfslock4_01 nfslock01 -v 4 -t tcp
+nfslock41_01 nfslock01 -v 4.1 -t tcp
+nfslock42_01 nfslock01 -v 4.2 -t tcp
+nfslock3_ipv6_01 nfslock01 -6 -v 3 -t udp
+nfslock4_ipv6_01 nfslock01 -6 -v 4 -t tcp
+nfslock41_ipv6_01 nfslock01 -6 -v 4.1 -t tcp
+nfslock42_ipv6_01 nfslock01 -6 -v 4.2 -t tcp
 
 nfsstat3_01 nfsstat01
 
diff --git a/testcases/network/.gitignore b/testcases/network/.gitignore
index ca4e0f3..2260475 100644
--- a/testcases/network/.gitignore
+++ b/testcases/network/.gitignore
@@ -19,7 +19,6 @@
 /nfs/nfs_fsstress/fsstress
 /nfs/nfslock01/nfs_flock
 /nfs/nfslock01/nfs_flock_dgen
-/nfs/nfslock01/nfs_flock_frk
 /nfsv4/acl/acl1
 /nfsv4/locks/locktests
 /rpc/basic_tests/rpc01/rpc1
diff --git a/testcases/network/nfs/nfslock01/nfs_flock_frk.c b/testcases/network/nfs/nfslock01/nfs_flock_frk.c
deleted file mode 100644
index 234da9f..0000000
--- a/testcases/network/nfs/nfslock01/nfs_flock_frk.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * This program starts processes one and two simultaneously.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-
-int main(int argc, char **argv)
-{
-	pid_t pid;
-	char *Prog;
-
-	if (argc != 3) {
-		fprintf(stderr, "Usage: %s <process> <datafile>\n", argv[0]);
-		exit(2);
-	}
-
-	Prog = strrchr(argv[1], '/');
-	Prog++;
-
-	if ((pid = fork()) < 0) {
-		printf("Failed in forking, Errno = %d", errno);
-		exit(2);
-	} else if (pid == 0) {	/* child */
-		execl(argv[1], Prog, "0", argv[2], NULL);
-	} else {		/* parent */
-		execl(argv[1], Prog, "1", argv[2], NULL);
-	}
-
-	/*if (waitpid(pid, NULL, 0) != pid)
-	   printf("Failed in waitpid, Errno = %d", errno);
-	 */
-	exit(0);
-}
diff --git a/testcases/network/nfs/nfslock01/nfslock01 b/testcases/network/nfs/nfslock01/nfslock01
index 8485d85..f480da8 100755
--- a/testcases/network/nfs/nfslock01/nfslock01
+++ b/testcases/network/nfs/nfslock01/nfslock01
@@ -1,152 +1,69 @@
 #!/bin/sh
+# Copyright (c) 2016 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) International Business Machines  Corp., 2001
 #
-#   Copyright (c) International Business Machines  Corp., 2001
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
 #
-#   This program is free software;  you can redistribute it and/or modify
-#   it under the terms of the GNU General Public License as published by
-#   the Free Software Foundation; either version 2 of the License, or
-#   (at your option) any later version.
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
 #
-#   This program is distributed in the hope that it will be useful,
-#   but WITHOUT ANY WARRANTY;  without even the implied warranty of
-#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
-#   the GNU General Public License for more details.
-#
-#   You should have received a copy of the GNU General Public License
-#   along with this program;  if not, write to the Free Software
-#   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-#
-#
-#
-#  FILE   : nfslock
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
 #
 #  PURPOSE:
 #           Two processes open FLOCK_IDATA file simultaneously
 #           each one locks odd and even lines of the file simultaneously
 #           and fill them with '0's and '1's. After they find eof, the
 #           datafiles are compared.
-#
-#  HISTORY:
-#    04/25/01 Robbie Williamson (robbiew@us.ibm.com)
-#      -Ported
-#
-#***********************************************************************
 
-#Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
+TCID=nfslock
+TST_TOTAL=1
+TST_CLEANUP="nfs_cleanup"
 
-$trace_logic
+. nfs_lib.sh
+. test_net.sh
 
-TC=nfslock
-TCbin=${TCbin:=`pwd`}
-TCtmp=${TCtmp:=$TCbin/$TC$$}
-TCsrc=${TCsrc:=$TCbin}
-TClog=${TClog:=$TCtmp}
-export TCID=$TC
-export TST_TOTAL=1
-export TST_COUNT=1
-
-mkdir $TCtmp >/dev/null 2>&1
-
-CLEANUP=${CLEANUP:=ON}
 LUSER=${LUSER:=root}
 
-FLOCK_DATA=$TClog/nfs_flock_data
-FLOCK_IDATA=$TClog/nfs_flock_idata
-FLOCK_ODATA=$TClog/nfs_flock_odata
-
-FLOCK_EXEC=$TCsrc/nfs_flock
-FLOCK_DGEN=$TCsrc/nfs_flock_dgen
-FLOCK_FRK=$TCsrc/nfs_flock_frk
-
-#----------------------------------------------------------------------
-# FUNCTION: do_setup
-# PURPOSE:  To create the necessary files to carry out the test
-# INPUT:    None.
-# OUTPUT:   None.
-#----------------------------------------------------------------------
 do_setup()
 {
-$trace_logic
-   echo "doing Setup"
+	nfs_setup
 
-   $FLOCK_DGEN $FLOCK_DATA 63 16384 0
-   $FLOCK_DGEN $FLOCK_ODATA 63 16384 1
+	tst_resm TINFO "creating test files"
+	ROD nfs_flock_dgen flock_data 63 16384 0
+	ROD nfs_flock_dgen flock_odata 63 16384 1
 
-   [ `wc -c $FLOCK_DATA | awk '{print $1}'` -ne 1048576 ] && { \
-      echo "abort - could not create $FLOCK_DATA"; exit 99; }
-   [ `wc -c $FLOCK_ODATA | awk '{print $1}'` -ne 1048576 ] && { \
-      echo "abort - could not create $FLOCK_ODATA"; exit 99; }
-}
+	[ "$(wc -c flock_data | awk '{print $1}')" -ne 1048576 ] && \
+		tst_brkm TBROK "could not create 'flock_data'"
 
-#----------------------------------------------------------------------
-# FUNCTION: do_cleanup
-# PURPOSE:  To delete all the files created to run this test.
-# INPUT:    None.
-# OUTPUT:   None.
-#----------------------------------------------------------------------
-do_cleanup()
-{
-$trace_logic
-   sleep 5
-   rm -rf $TCtmp
+	[ "$(wc -c flock_odata | awk '{print $1}')" -ne 1048576 ] && \
+		tst_brkm TBROK "could not create 'flock_odata'"
 }
 
-#----------------------------------------------------------------------
-# FUNCTION: do_test
-# PURPOSE:  Perform the necessary steps to complete the test.
-# INPUT:    None.
-# OUPUT:    Error messages are logged if any of the tests fail.
-#----------------------------------------------------------------------
 do_test()
 {
-$trace_logic
-   echo "Testing locking"
+	tst_resm TINFO "Testing locking"
 
-   cp $FLOCK_DATA $FLOCK_IDATA
+	ROD cp flock_data flock_idata
 
-   echo "locking $FLOCK_IDATA file and writing data"
-   $FLOCK_FRK $FLOCK_EXEC $FLOCK_IDATA
-   [ $? = 0 ] || end_testcase "Errors in do_test $TC"
-   sleep 1
-   diff $FLOCK_ODATA $FLOCK_IDATA > /dev/null 2>&1
-   [ $? = 0 ] || end_testcase "$FLOCK_ODATA is different than $FLOCK_IDATA"
+	tst_resm TINFO "locking 'flock_idata' file and writing data"
 
-}
+	nfs_flock 0 flock_idata &
+	nfs_flock 1 flock_idata &
+	wait
 
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:           string, IF AND ONLY IF the testcase fails
-#
-# RETURNS:              None.
-#=============================================================================
+	ROD diff flock_odata flock_idata > /dev/null 2>&1
 
-end_testcase()
-{
-   $trace_logic
-   echo "$this_file: doing $0."
-   if [ "$CLEANUP" = "ON" ]; then
-     do_cleanup
-   fi
-
-   [ $# = 0 ] && { tst_resm TPASS "Test Successful"; exit 0; }
-   tst_resm TFAIL "Test Failed: $@"
-   exit 1
+	tst_resm TPASS "'flock_odata' and 'flock_idata' have the same content"
 }
 
-
-#----------------------------------------------------------------------
-# FUNCTION: MAIN
-# PURPOSE:  To invoke the functions to perform the tasks described in
-#           the prologue.
-# INPUT:    None.
-# OUTPUT:   A testcase run log with the results of the execution of this
-#           test.
-#----------------------------------------------------------------------
-
 do_setup
+
 do_test
-end_testcase
+
+tst_exit
-- 
1.7.1


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

* [LTP] [PATCH 7/8] network/nfs/nfs_fsstress: remove fsstress test
  2016-06-20 14:28 [LTP] [PATCH 0/8] network/nfs: fix/cleanup tests Alexey Kodanev
                   ` (5 preceding siblings ...)
  2016-06-20 14:28 ` [LTP] [PATCH 6/8] network/nfs/nfsflock: clenaup & use test_net library Alexey Kodanev
@ 2016-06-20 14:28 ` Alexey Kodanev
  2016-06-20 14:28 ` [LTP] [PATCH 8/8] network/nfs: remove README Alexey Kodanev
  2016-08-04 10:13 ` [LTP] [PATCH 0/8] network/nfs: fix/cleanup tests Alexey Kodanev
  8 siblings, 0 replies; 10+ messages in thread
From: Alexey Kodanev @ 2016-06-20 14:28 UTC (permalink / raw)
  To: ltp

The most recent version resides in testcases/fs/fsstress/.
There is no resone to keep both versions.

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 testcases/network/nfs/nfs_fsstress/Makefile    |    7 -
 testcases/network/nfs/nfs_fsstress/fsstress.c  | 2591 ------------------------
 testcases/network/nfs/nfs_fsstress/global.h    |   66 -
 testcases/network/nfs/nfs_fsstress/xfscompat.h |    7 -
 4 files changed, 0 insertions(+), 2671 deletions(-)
 delete mode 100644 testcases/network/nfs/nfs_fsstress/fsstress.c
 delete mode 100644 testcases/network/nfs/nfs_fsstress/global.h
 delete mode 100644 testcases/network/nfs/nfs_fsstress/xfscompat.h

diff --git a/testcases/network/nfs/nfs_fsstress/Makefile b/testcases/network/nfs/nfs_fsstress/Makefile
index c1b3c2b..7492028 100644
--- a/testcases/network/nfs/nfs_fsstress/Makefile
+++ b/testcases/network/nfs/nfs_fsstress/Makefile
@@ -24,13 +24,6 @@ top_srcdir		?= ../../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
-CPPFLAGS		+= -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -DNO_XFS \
-			   -I$(abs_srcdir)
-
-# XXX (garrcoop): this copy of fsstress has issues with -Wuninitialized that
-# aren't as easy to resolve as I would like.
-CPPFLAGS		+= -Wno-error
-
 INSTALL_TARGETS		:= nfs_fsstress.sh
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/nfs/nfs_fsstress/fsstress.c b/testcases/network/nfs/nfs_fsstress/fsstress.c
deleted file mode 100644
index a34c416..0000000
--- a/testcases/network/nfs/nfs_fsstress/fsstress.c
+++ /dev/null
@@ -1,2591 +0,0 @@
-/*
- * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-#include "global.h"
-#include <limits.h>
-
-#define XFS_ERRTAG_MAX		17
-
-typedef enum {
-#ifndef NO_XFS
-	OP_ALLOCSP,
-	OP_ATTR_REMOVE,
-	OP_ATTR_SET,
-	OP_BULKSTAT,
-	OP_BULKSTAT1,
-#endif
-	OP_CHOWN,
-	OP_CREAT,
-	OP_DREAD,
-	OP_DWRITE,
-	OP_FDATASYNC,
-#ifndef NO_XFS
-	OP_FREESP,
-#endif
-	OP_FSYNC,
-	OP_GETDENTS,
-	OP_LINK,
-	OP_MKDIR,
-	OP_MKNOD,
-	OP_READ,
-	OP_READLINK,
-	OP_RENAME,
-#ifndef NO_XFS
-	OP_RESVSP,
-#endif
-	OP_RMDIR,
-	OP_STAT,
-	OP_SYMLINK,
-	OP_SYNC,
-	OP_TRUNCATE,
-	OP_UNLINK,
-#ifndef NO_XFS
-	OP_UNRESVSP,
-#endif
-	OP_WRITE,
-	OP_LAST
-} opty_t;
-
-typedef void (*opfnc_t) (int, long);
-
-typedef struct opdesc {
-	opty_t op;
-	char *name;
-	opfnc_t func;
-	int freq;
-	int iswrite;
-	int isxfs;
-} opdesc_t;
-
-typedef struct fent {
-	int id;
-	int parent;
-} fent_t;
-
-typedef struct flist {
-	int nfiles;
-	int nslots;
-	int tag;
-	fent_t *fents;
-} flist_t;
-
-typedef struct pathname {
-	int len;
-	char *path;
-} pathname_t;
-
-#define	FT_DIR	0
-#define	FT_DIRm	(1 << FT_DIR)
-#define	FT_REG	1
-#define	FT_REGm	(1 << FT_REG)
-#define	FT_SYM	2
-#define	FT_SYMm	(1 << FT_SYM)
-#define	FT_DEV	3
-#define	FT_DEVm	(1 << FT_DEV)
-#define	FT_RTF	4
-#define	FT_RTFm	(1 << FT_RTF)
-#define	FT_nft	5
-#define	FT_ANYm	((1 << FT_nft) - 1)
-#define	FT_REGFILE	(FT_REGm | FT_RTFm)
-#define	FT_NOTDIR	(FT_ANYm & ~FT_DIRm)
-
-#define	FLIST_SLOT_INCR	16
-#define	NDCACHE	64
-
-#define	MAXFSIZE	((1ULL << 63) - 1ULL)
-#define	MAXFSIZE32	((1ULL << 40) - 1ULL)
-
-void allocsp_f(int, long);
-void attr_remove_f(int, long);
-void attr_set_f(int, long);
-void bulkstat_f(int, long);
-void bulkstat1_f(int, long);
-void chown_f(int, long);
-void creat_f(int, long);
-void dread_f(int, long);
-void dwrite_f(int, long);
-void fdatasync_f(int, long);
-void freesp_f(int, long);
-void fsync_f(int, long);
-void getdents_f(int, long);
-void link_f(int, long);
-void mkdir_f(int, long);
-void mknod_f(int, long);
-void read_f(int, long);
-void readlink_f(int, long);
-void rename_f(int, long);
-void resvsp_f(int, long);
-void rmdir_f(int, long);
-void stat_f(int, long);
-void symlink_f(int, long);
-void sync_f(int, long);
-void truncate_f(int, long);
-void unlink_f(int, long);
-void unresvsp_f(int, long);
-void write_f(int, long);
-
-opdesc_t ops[] = {
-#ifndef NO_XFS
-	{OP_ALLOCSP, "allocsp", allocsp_f, 1, 1, 1},
-	{OP_ATTR_REMOVE, "attr_remove", attr_remove_f, /* 1 */ 0, 1, 1},
-	{OP_ATTR_SET, "attr_set", attr_set_f, /* 2 */ 0, 1, 1},
-	{OP_BULKSTAT, "bulkstat", bulkstat_f, 1, 0, 1},
-	{OP_BULKSTAT1, "bulkstat1", bulkstat1_f, 1, 0, 1},
-#endif
-	{OP_CHOWN, "chown", chown_f, 3, 1},
-	{OP_CREAT, "creat", creat_f, 4, 1},
-	{OP_DREAD, "dread", dread_f, 4, 0},
-	{OP_DWRITE, "dwrite", dwrite_f, 4, 1},
-	{OP_FDATASYNC, "fdatasync", fdatasync_f, 1, 1},
-#ifndef NO_XFS
-	{OP_FREESP, "freesp", freesp_f, 1, 1, 1},
-#endif
-	{OP_FSYNC, "fsync", fsync_f, 1, 1},
-	{OP_GETDENTS, "getdents", getdents_f, 1, 0},
-	{OP_LINK, "link", link_f, 1, 1},
-	{OP_MKDIR, "mkdir", mkdir_f, 2, 1},
-	{OP_MKNOD, "mknod", mknod_f, 2, 1},
-	{OP_READ, "read", read_f, 1, 0},
-	{OP_READLINK, "readlink", readlink_f, 1, 0},
-	{OP_RENAME, "rename", rename_f, 2, 1},
-#ifndef NO_XFS
-	{OP_RESVSP, "resvsp", resvsp_f, 1, 1, 1},
-#endif
-	{OP_RMDIR, "rmdir", rmdir_f, 1, 1},
-	{OP_STAT, "stat", stat_f, 1, 0},
-	{OP_SYMLINK, "symlink", symlink_f, 2, 1},
-	{OP_SYNC, "sync", sync_f, 1, 0},
-	{OP_TRUNCATE, "truncate", truncate_f, 2, 1},
-	{OP_UNLINK, "unlink", unlink_f, 1, 1},
-#ifndef NO_XFS
-	{OP_UNRESVSP, "unresvsp", unresvsp_f, 1, 1, 1},
-#endif
-	{OP_WRITE, "write", write_f, 4, 1},
-}, *ops_end;
-
-flist_t flist[FT_nft] = {
-	{0, 0, 'd', NULL},
-	{0, 0, 'f', NULL},
-	{0, 0, 'l', NULL},
-	{0, 0, 'c', NULL},
-	{0, 0, 'r', NULL},
-};
-
-int dcache[NDCACHE];
-int errrange;
-int errtag;
-opty_t *freq_table;
-int freq_table_size;
-#ifndef NO_XFS
-xfs_fsop_geom_t geom;
-#endif
-char *homedir;
-int *ilist;
-int ilistlen;
-off64_t maxfsize;
-char *myprog;
-int namerand;
-int nameseq;
-int nops;
-int nproc = 1;
-int operations = 1;
-int procid;
-int rtpct;
-unsigned long seed = 0;
-ino_t top_ino;
-int verbose = 0;
-#ifndef NO_XFS
-int no_xfs = 0;
-#else
-int no_xfs = 1;
-#endif
-
-void add_to_flist(int, int, int);
-void append_pathname(pathname_t *, char *);
-#ifndef NO_XFS
-int attr_list_path(pathname_t *, char *, const int, int, attrlist_cursor_t *);
-int attr_remove_path(pathname_t *, const char *, int);
-int attr_set_path(pathname_t *, const char *, const char *, const int, int);
-#endif
-void check_cwd(void);
-int creat_path(pathname_t *, mode_t);
-void dcache_enter(int, int);
-void dcache_init(void);
-fent_t *dcache_lookup(int);
-void dcache_purge(int);
-void del_from_flist(int, int);
-int dirid_to_name(char *, int);
-void doproc(void);
-void fent_to_name(pathname_t *, flist_t *, fent_t *);
-void fix_parent(int, int);
-void free_pathname(pathname_t *);
-int generate_fname(fent_t *, int, pathname_t *, int *, int *);
-int get_fname(int, long, pathname_t *, flist_t **, fent_t **, int *);
-void init_pathname(pathname_t *);
-int lchown_path(pathname_t *, uid_t, gid_t);
-int link_path(pathname_t *, pathname_t *);
-int lstat64_path(pathname_t *, struct stat64 *);
-void make_freq_table(void);
-int mkdir_path(pathname_t *, mode_t);
-int mknod_path(pathname_t *, mode_t, dev_t);
-void namerandpad(int, char *, int);
-int open_path(pathname_t *, int);
-DIR *opendir_path(pathname_t *);
-void process_freq(char *);
-int readlink_path(pathname_t *, char *, size_t);
-int rename_path(pathname_t *, pathname_t *);
-int rmdir_path(pathname_t *);
-void separate_pathname(pathname_t *, char *, pathname_t *);
-void show_ops(int, char *);
-int stat64_path(pathname_t *, struct stat64 *);
-int symlink_path(const char *, pathname_t *);
-int truncate64_path(pathname_t *, off64_t);
-int unlink_path(pathname_t *);
-void usage(void);
-void write_freq(void);
-void zero_freq(void);
-
-int main(int argc, char **argv)
-{
-	char buf[10];
-	int c;
-	char *dirname = NULL;
-	int fd;
-	int i;
-	int cleanup = 0;
-	int loops = 1;
-	int loopcntr = 1;
-	char cmd[256];
-#ifndef NO_XFS
-	int j;
-#endif
-	char *p;
-	int stat;
-	struct timeval t;
-#ifndef NO_XFS
-	ptrdiff_t srval;
-#endif
-	int nousage = 0;
-#ifndef NO_XFS
-	xfs_error_injection_t err_inj;
-#endif
-
-	errrange = errtag = 0;
-	umask(0);
-	nops = sizeof(ops) / sizeof(ops[0]);
-	ops_end = &ops[nops];
-	myprog = argv[0];
-	while ((c = getopt(argc, argv, "cd:e:f:i:l:n:p:rs:vwzHSX")) != -1) {
-		switch (c) {
-		case 'c':
-			/*Don't cleanup */
-			cleanup = 1;
-			break;
-		case 'd':
-			dirname = optarg;
-			break;
-		case 'e':
-			sscanf(optarg, "%d", &errtag);
-			if (errtag < 0) {
-				errtag = -errtag;
-				errrange = 1;
-			} else if (errtag == 0)
-				errtag = -1;
-			if (errtag >= XFS_ERRTAG_MAX) {
-				fprintf(stderr,
-					"error tag %d too large (max %d)\n",
-					errtag, XFS_ERRTAG_MAX - 1);
-				exit(1);
-			}
-			break;
-		case 'f':
-			process_freq(optarg);
-			break;
-		case 'i':
-			ilist = realloc(ilist, ++ilistlen * sizeof(*ilist));
-			ilist[ilistlen - 1] = strtol(optarg, &p, 16);
-			break;
-		case 'l':
-			loops = atoi(optarg);
-			break;
-		case 'n':
-			operations = atoi(optarg);
-			break;
-		case 'p':
-			nproc = atoi(optarg);
-			break;
-		case 'r':
-			namerand = 1;
-			break;
-		case 's':
-			seed = strtoul(optarg, NULL, 0);
-			break;
-		case 'v':
-			verbose = 1;
-			break;
-		case 'w':
-			write_freq();
-			break;
-		case 'z':
-			zero_freq();
-			break;
-		case 'S':
-			show_ops(0, NULL);
-			printf("\n");
-			nousage = 1;
-			break;
-		case '?':
-			fprintf(stderr, "%s - invalid parameters\n", myprog);
-			/* fall through */
-		case 'H':
-			usage();
-			exit(1);
-		case 'X':
-			no_xfs = 1;
-			break;
-		}
-	}
-	while ((loopcntr <= loops) || (loops == 0)) {
-		if (no_xfs && errtag) {
-			fprintf(stderr, "error injection only works on XFS\n");
-			exit(1);
-		}
-
-		if (no_xfs) {
-			int i;
-			for (i = 0; ops + i < ops_end; ++i) {
-				if (ops[i].isxfs)
-					ops[i].freq = 0;
-			}
-		}
-
-		if (!dirname) {
-			/* no directory specified */
-			if (!nousage)
-				usage();
-			exit(1);
-		}
-
-		(void)mkdir(dirname, 0777);
-		if (chdir(dirname) < 0) {
-			perror(dirname);
-			exit(1);
-		}
-		sprintf(buf, "fss%x", getpid());
-		fd = creat(buf, 0666);
-		if (lseek64(fd, (off64_t) (MAXFSIZE32 + 1ULL), SEEK_SET) < 0)
-			maxfsize = (off64_t) MAXFSIZE32;
-		else
-			maxfsize = (off64_t) MAXFSIZE;
-		make_freq_table();
-		dcache_init();
-		setlinebuf(stdout);
-		if (!seed) {
-			gettimeofday(&t, NULL);
-			seed = (int)t.tv_sec ^ (int)t.tv_usec;
-			printf("seed = %ld\n", seed);
-		}
-#ifndef NO_XFS
-		if (!no_xfs) {
-			i = ioctl(fd, XFS_IOC_FSGEOMETRY, &geom);
-			if (i >= 0 && geom.rtblocks)
-				rtpct = MIN(MAX(geom.rtblocks * 100 /
-						(geom.rtblocks +
-						 geom.datablocks), 1), 99);
-			else
-				rtpct = 0;
-		}
-		if (errtag != 0) {
-			if (errrange == 0) {
-				if (errtag <= 0) {
-					srandom(seed);
-					j = random() % 100;
-
-					for (i = 0; i < j; i++)
-						(void)random();
-
-					errtag =
-					    (random() % (XFS_ERRTAG_MAX - 1)) +
-					    1;
-				}
-			} else {
-				srandom(seed);
-				j = random() % 100;
-
-				for (i = 0; i < j; i++)
-					(void)random();
-
-				errtag +=
-				    (random() % (XFS_ERRTAG_MAX - errtag));
-			}
-			printf("Injecting failure on tag #%d\n", errtag);
-			err_inj.errtag = errtag;
-			err_inj.fd = fd;
-			srval = ioctl(fd, XFS_IOC_ERROR_INJECTION, &err_inj);
-			if (srval < -1) {
-				perror
-				    ("fsstress - XFS_SYSSGI error injection call");
-				close(fd);
-				unlink(buf);
-				exit(1);
-			}
-		} else
-#endif
-			close(fd);
-		unlink(buf);
-		if (nproc == 1) {
-			procid = 0;
-			doproc();
-		} else {
-			for (i = 0; i < nproc; i++) {
-				if (fork() == 0) {
-					procid = i;
-					doproc();
-					return 0;
-				}
-			}
-			while (wait(&stat) > 0)
-				continue;
-		}
-#ifndef NO_XFS
-		if (errtag != 0) {
-			err_inj.errtag = 0;
-			err_inj.fd = fd;
-			if ((srval =
-			     ioctl(fd, XFS_IOC_ERROR_CLEARALL,
-				   &err_inj)) != 0) {
-				fprintf(stderr, "Bad ej clear on %d (%d).\n",
-					fd, errno);
-				perror
-				    ("fsstress - XFS_SYSSGI clear error injection call");
-				close(fd);
-				exit(1);
-			}
-			close(fd);
-		}
-#endif
-		if (cleanup == 0) {
-			sprintf(cmd, "rm -rf %s/*", dirname);
-			system(cmd);
-		}
-		loopcntr++;
-	}
-	return 0;
-}
-
-void add_to_flist(int ft, int id, int parent)
-{
-	fent_t *fep;
-	flist_t *ftp;
-
-	ftp = &flist[ft];
-	if (ftp->nfiles == ftp->nslots) {
-		ftp->nslots += FLIST_SLOT_INCR;
-		ftp->fents = realloc(ftp->fents, ftp->nslots * sizeof(fent_t));
-	}
-	fep = &ftp->fents[ftp->nfiles++];
-	fep->id = id;
-	fep->parent = parent;
-}
-
-void append_pathname(pathname_t * name, char *str)
-{
-	int len;
-
-	len = strlen(str);
-#ifdef DEBUG
-	if (len && *str == '/' && name->len == 0) {
-		fprintf(stderr, "fsstress: append_pathname failure\n");
-		chdir(homedir);
-		abort();
-
-	}
-#endif
-	name->path = realloc(name->path, name->len + 1 + len);
-	strcpy(&name->path[name->len], str);
-	name->len += len;
-}
-
-#ifndef NO_XFS
-int
-attr_list_path(pathname_t * name, char *buffer, const int buffersize, int flags,
-	       attrlist_cursor_t * cursor)
-{
-	char buf[MAXNAMELEN];
-	pathname_t newname;
-	int rval;
-
-	rval = attr_list(name->path, buffer, buffersize, flags, cursor);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name, buf, &newname);
-	if (chdir(buf) == 0) {
-		rval = attr_list_path(&newname, buffer, buffersize, flags,
-				      cursor);
-		chdir("..");
-	}
-	free_pathname(&newname);
-	return rval;
-}
-
-int attr_remove_path(pathname_t * name, const char *attrname, int flags)
-{
-	char buf[MAXNAMELEN];
-	pathname_t newname;
-	int rval;
-
-	rval = attr_remove(name->path, attrname, flags);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name, buf, &newname);
-	if (chdir(buf) == 0) {
-		rval = attr_remove_path(&newname, attrname, flags);
-		chdir("..");
-	}
-	free_pathname(&newname);
-	return rval;
-}
-
-int
-attr_set_path(pathname_t * name, const char *attrname, const char *attrvalue,
-	      const int valuelength, int flags)
-{
-	char buf[MAXNAMELEN];
-	pathname_t newname;
-	int rval;
-
-	rval = attr_set(name->path, attrname, attrvalue, valuelength, flags);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name, buf, &newname);
-	if (chdir(buf) == 0) {
-		rval = attr_set_path(&newname, attrname, attrvalue, valuelength,
-				     flags);
-		chdir("..");
-	}
-	free_pathname(&newname);
-	return rval;
-}
-#endif
-
-void check_cwd(void)
-{
-#ifdef DEBUG
-	struct stat64 statbuf;
-
-	if (stat64(".", &statbuf) == 0 && statbuf.st_ino == top_ino)
-		return;
-	chdir(homedir);
-	fprintf(stderr, "fsstress: check_cwd failure\n");
-	abort();
-
-#endif
-}
-
-int creat_path(pathname_t * name, mode_t mode)
-{
-	char buf[MAXNAMELEN];
-	pathname_t newname;
-	int rval;
-
-	rval = creat(name->path, mode);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name, buf, &newname);
-	if (chdir(buf) == 0) {
-		rval = creat_path(&newname, mode);
-		chdir("..");
-	}
-	free_pathname(&newname);
-	return rval;
-}
-
-void dcache_enter(int dirid, int slot)
-{
-	dcache[dirid % NDCACHE] = slot;
-}
-
-void dcache_init(void)
-{
-	int i;
-
-	for (i = 0; i < NDCACHE; i++)
-		dcache[i] = -1;
-}
-
-fent_t *dcache_lookup(int dirid)
-{
-	fent_t *fep;
-	int i;
-
-	i = dcache[dirid % NDCACHE];
-	if (i >= 0 && (fep = &flist[FT_DIR].fents[i])->id == dirid)
-		return fep;
-	return NULL;
-}
-
-void dcache_purge(int dirid)
-{
-	int *dcp;
-
-	dcp = &dcache[dirid % NDCACHE];
-	if (*dcp >= 0 && flist[FT_DIR].fents[*dcp].id == dirid)
-		*dcp = -1;
-}
-
-void del_from_flist(int ft, int slot)
-{
-	flist_t *ftp;
-
-	ftp = &flist[ft];
-	if (ft == FT_DIR)
-		dcache_purge(ftp->fents[slot].id);
-	if (slot != ftp->nfiles - 1) {
-		if (ft == FT_DIR)
-			dcache_purge(ftp->fents[ftp->nfiles - 1].id);
-		ftp->fents[slot] = ftp->fents[--ftp->nfiles];
-	} else
-		ftp->nfiles--;
-}
-
-fent_t *dirid_to_fent(int dirid)
-{
-	fent_t *efep;
-	fent_t *fep;
-	flist_t *flp;
-
-	if ((fep = dcache_lookup(dirid)))
-		return fep;
-	flp = &flist[FT_DIR];
-	for (fep = flp->fents, efep = &fep[flp->nfiles]; fep < efep; fep++) {
-		if (fep->id == dirid) {
-			dcache_enter(dirid, fep - flp->fents);
-			return fep;
-		}
-	}
-	return NULL;
-}
-
-void doproc(void)
-{
-	struct stat64 statbuf;
-	char buf[10];
-	int opno;
-	int rval;
-	opdesc_t *p;
-
-	sprintf(buf, "p%x", procid);
-	(void)mkdir(buf, 0777);
-	if (chdir(buf) < 0 || stat64(".", &statbuf) < 0) {
-		perror(buf);
-		_exit(1);
-	}
-	top_ino = statbuf.st_ino;
-	homedir = getcwd(NULL, -1);
-	seed += procid;
-	srandom(seed);
-	if (namerand)
-		namerand = random();
-	for (opno = 0; opno < operations; opno++) {
-		p = &ops[freq_table[random() % freq_table_size]];
-		if ((unsigned long)p->func < 4096)
-			abort();
-
-		p->func(opno, random());
-		/*
-		 * test for forced shutdown by stat'ing the test
-		 * directory.  If this stat returns EIO, assume
-		 * the forced shutdown happened.
-		 */
-		if (errtag != 0 && opno % 100 == 0) {
-			rval = stat64(".", &statbuf);
-			if (rval == EIO) {
-				fprintf(stderr, "Detected EIO\n");
-				return;
-			}
-		}
-	}
-}
-
-void fent_to_name(pathname_t * name, flist_t * flp, fent_t * fep)
-{
-	char buf[MAXNAMELEN];
-	int i;
-	fent_t *pfep;
-
-	if (fep == NULL)
-		return;
-	if (fep->parent != -1) {
-		pfep = dirid_to_fent(fep->parent);
-		fent_to_name(name, &flist[FT_DIR], pfep);
-		append_pathname(name, "/");
-	}
-	i = sprintf(buf, "%c%x", flp->tag, fep->id);
-	namerandpad(fep->id, buf, i);
-	append_pathname(name, buf);
-}
-
-void fix_parent(int oldid, int newid)
-{
-	fent_t *fep;
-	flist_t *flp;
-	int i;
-	int j;
-
-	for (i = 0, flp = flist; i < FT_nft; i++, flp++) {
-		for (j = 0, fep = flp->fents; j < flp->nfiles; j++, fep++) {
-			if (fep->parent == oldid)
-				fep->parent = newid;
-		}
-	}
-}
-
-void free_pathname(pathname_t * name)
-{
-	if (name->path) {
-		free(name->path);
-		name->path = NULL;
-		name->len = 0;
-	}
-}
-
-int generate_fname(fent_t * fep, int ft, pathname_t * name, int *idp, int *v)
-{
-	char buf[MAXNAMELEN];
-	flist_t *flp;
-	int id;
-	int j;
-	int len;
-
-	flp = &flist[ft];
-	len = sprintf(buf, "%c%x", flp->tag, id = nameseq++);
-	namerandpad(id, buf, len);
-	if (fep) {
-		fent_to_name(name, &flist[FT_DIR], fep);
-		append_pathname(name, "/");
-	}
-	append_pathname(name, buf);
-	*idp = id;
-	*v = verbose;
-	for (j = 0; !*v && j < ilistlen; j++) {
-		if (ilist[j] == id) {
-			*v = 1;
-			break;
-		}
-	}
-	return 1;
-}
-
-int
-get_fname(int which, long r, pathname_t * name, flist_t ** flpp, fent_t ** fepp,
-	  int *v)
-{
-	int c;
-	fent_t *fep;
-	flist_t *flp;
-	int i;
-	int j;
-	int x;
-
-	for (i = 0, c = 0, flp = flist; i < FT_nft; i++, flp++) {
-		if (which & (1 << i))
-			c += flp->nfiles;
-	}
-	if (c == 0) {
-		if (flpp)
-			*flpp = NULL;
-		if (fepp)
-			*fepp = NULL;
-		*v = verbose;
-		return 0;
-	}
-	x = (int)(r % c);
-	for (i = 0, c = 0, flp = flist; i < FT_nft; i++, flp++) {
-		if (which & (1 << i)) {
-			if (x < c + flp->nfiles) {
-				fep = &flp->fents[x - c];
-				if (name)
-					fent_to_name(name, flp, fep);
-				if (flpp)
-					*flpp = flp;
-				if (fepp)
-					*fepp = fep;
-				*v = verbose;
-				for (j = 0; !*v && j < ilistlen; j++) {
-					if (ilist[j] == fep->id) {
-						*v = 1;
-						break;
-					}
-				}
-				return 1;
-			}
-			c += flp->nfiles;
-		}
-	}
-#ifdef DEBUG
-	fprintf(stderr, "fsstress: get_fname failure\n");
-	abort();
-#endif
-	return -1;
-
-}
-
-void init_pathname(pathname_t * name)
-{
-	name->len = 0;
-	name->path = NULL;
-}
-
-int lchown_path(pathname_t * name, uid_t owner, gid_t group)
-{
-	char buf[MAXNAMELEN];
-	pathname_t newname;
-	int rval;
-
-	rval = lchown(name->path, owner, group);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name, buf, &newname);
-	if (chdir(buf) == 0) {
-		rval = lchown_path(&newname, owner, group);
-		chdir("..");
-	}
-	free_pathname(&newname);
-	return rval;
-}
-
-int link_path(pathname_t * name1, pathname_t * name2)
-{
-	char buf1[MAXNAMELEN];
-	char buf2[MAXNAMELEN];
-	int down1;
-	pathname_t newname1;
-	pathname_t newname2;
-	int rval;
-
-	rval = link(name1->path, name2->path);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name1, buf1, &newname1);
-	separate_pathname(name2, buf2, &newname2);
-	if (strcmp(buf1, buf2) == 0) {
-		if (chdir(buf1) == 0) {
-			rval = link_path(&newname1, &newname2);
-			chdir("..");
-		}
-	} else {
-		if (strcmp(buf1, "..") == 0)
-			down1 = 0;
-		else if (strcmp(buf2, "..") == 0)
-			down1 = 1;
-		else if (strlen(buf1) == 0)
-			down1 = 0;
-		else if (strlen(buf2) == 0)
-			down1 = 1;
-		else
-			down1 = MAX(newname1.len, 3 + name2->len) <=
-			    MAX(3 + name1->len, newname2.len);
-		if (down1) {
-			free_pathname(&newname2);
-			append_pathname(&newname2, "../");
-			append_pathname(&newname2, name2->path);
-			if (chdir(buf1) == 0) {
-				rval = link_path(&newname1, &newname2);
-				chdir("..");
-			}
-		} else {
-			free_pathname(&newname1);
-			append_pathname(&newname1, "../");
-			append_pathname(&newname1, name1->path);
-			if (chdir(buf2) == 0) {
-				rval = link_path(&newname1, &newname2);
-				chdir("..");
-			}
-		}
-	}
-	free_pathname(&newname1);
-	free_pathname(&newname2);
-	return rval;
-}
-
-int lstat64_path(pathname_t * name, struct stat64 *sbuf)
-{
-	char buf[MAXNAMELEN];
-	pathname_t newname;
-	int rval;
-
-	rval = lstat64(name->path, sbuf);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name, buf, &newname);
-	if (chdir(buf) == 0) {
-		rval = lstat64_path(&newname, sbuf);
-		chdir("..");
-	}
-	free_pathname(&newname);
-	return rval;
-}
-
-void make_freq_table(void)
-{
-	int f;
-	int i;
-	opdesc_t *p;
-
-	for (p = ops, f = 0; p < ops_end; p++)
-		f += p->freq;
-	freq_table = malloc(f * sizeof(*freq_table));
-	freq_table_size = f;
-	for (p = ops, i = 0; p < ops_end; p++) {
-		for (f = 0; f < p->freq; f++, i++)
-			freq_table[i] = p->op;
-	}
-}
-
-int mkdir_path(pathname_t * name, mode_t mode)
-{
-	char buf[MAXNAMELEN];
-	pathname_t newname;
-	int rval;
-
-	rval = mkdir(name->path, mode);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name, buf, &newname);
-	if (chdir(buf) == 0) {
-		rval = mkdir_path(&newname, mode);
-		chdir("..");
-	}
-	free_pathname(&newname);
-	return rval;
-}
-
-int mknod_path(pathname_t * name, mode_t mode, dev_t dev)
-{
-	char buf[MAXNAMELEN];
-	pathname_t newname;
-	int rval;
-
-	rval = mknod(name->path, mode, dev);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name, buf, &newname);
-	if (chdir(buf) == 0) {
-		rval = mknod_path(&newname, mode, dev);
-		chdir("..");
-	}
-	free_pathname(&newname);
-	return rval;
-}
-
-void namerandpad(int id, char *buf, int i)
-{
-	int bucket;
-	static int buckets[] = { 2, 4, 8, 16, 32, 64, 128, MAXNAMELEN - 1 };
-	int padlen;
-	int padmod;
-
-	if (namerand == 0)
-		return;
-	bucket = (id ^ namerand) % (sizeof(buckets) / sizeof(buckets[0]));
-	padmod = buckets[bucket] + 1 - i;
-	if (padmod <= 0)
-		return;
-	padlen = (id ^ namerand) % padmod;
-	if (padlen) {
-		memset(&buf[i], 'X', padlen);
-		buf[i + padlen] = '\0';
-	}
-}
-
-int open_path(pathname_t * name, int oflag)
-{
-	char buf[MAXNAMELEN];
-	pathname_t newname;
-	int rval;
-
-	rval = open(name->path, oflag);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name, buf, &newname);
-	if (chdir(buf) == 0) {
-		rval = open_path(&newname, oflag);
-		chdir("..");
-	}
-	free_pathname(&newname);
-	return rval;
-}
-
-DIR *opendir_path(pathname_t * name)
-{
-	char buf[MAXNAMELEN];
-	pathname_t newname;
-	DIR *rval;
-
-	rval = opendir(name->path);
-	if (rval || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name, buf, &newname);
-	if (chdir(buf) == 0) {
-		rval = opendir_path(&newname);
-		chdir("..");
-	}
-	free_pathname(&newname);
-	return rval;
-}
-
-void process_freq(char *arg)
-{
-	opdesc_t *p;
-	char *s;
-
-	s = strchr(arg, '=');
-	if (s == NULL) {
-		fprintf(stderr, "bad argument '%s'\n", arg);
-		exit(1);
-	}
-	*s++ = '\0';
-	for (p = ops; p < ops_end; p++) {
-		if (strcmp(arg, p->name) == 0) {
-			p->freq = atoi(s);
-			return;
-		}
-	}
-	fprintf(stderr, "can't find op type %s for -f\n", arg);
-	exit(1);
-}
-
-int readlink_path(pathname_t * name, char *lbuf, size_t lbufsiz)
-{
-	char buf[MAXNAMELEN];
-	pathname_t newname;
-	int rval;
-
-	rval = readlink(name->path, lbuf, lbufsiz);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name, buf, &newname);
-	if (chdir(buf) == 0) {
-		rval = readlink_path(&newname, lbuf, lbufsiz);
-		chdir("..");
-	}
-	free_pathname(&newname);
-	return rval;
-}
-
-int rename_path(pathname_t * name1, pathname_t * name2)
-{
-	char buf1[MAXNAMELEN];
-	char buf2[MAXNAMELEN];
-	int down1;
-	pathname_t newname1;
-	pathname_t newname2;
-	int rval;
-
-	rval = rename(name1->path, name2->path);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name1, buf1, &newname1);
-	separate_pathname(name2, buf2, &newname2);
-	if (strcmp(buf1, buf2) == 0) {
-		if (chdir(buf1) == 0) {
-			rval = rename_path(&newname1, &newname2);
-			chdir("..");
-		}
-	} else {
-		if (strcmp(buf1, "..") == 0)
-			down1 = 0;
-		else if (strcmp(buf2, "..") == 0)
-			down1 = 1;
-		else if (strlen(buf1) == 0)
-			down1 = 0;
-		else if (strlen(buf2) == 0)
-			down1 = 1;
-		else
-			down1 = MAX(newname1.len, 3 + name2->len) <=
-			    MAX(3 + name1->len, newname2.len);
-		if (down1) {
-			free_pathname(&newname2);
-			append_pathname(&newname2, "../");
-			append_pathname(&newname2, name2->path);
-			if (chdir(buf1) == 0) {
-				rval = rename_path(&newname1, &newname2);
-				chdir("..");
-			}
-		} else {
-			free_pathname(&newname1);
-			append_pathname(&newname1, "../");
-			append_pathname(&newname1, name1->path);
-			if (chdir(buf2) == 0) {
-				rval = rename_path(&newname1, &newname2);
-				chdir("..");
-			}
-		}
-	}
-	free_pathname(&newname1);
-	free_pathname(&newname2);
-	return rval;
-}
-
-int rmdir_path(pathname_t * name)
-{
-	char buf[MAXNAMELEN];
-	pathname_t newname;
-	int rval;
-
-	rval = rmdir(name->path);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name, buf, &newname);
-	if (chdir(buf) == 0) {
-		rval = rmdir_path(&newname);
-		chdir("..");
-	}
-	free_pathname(&newname);
-	return rval;
-}
-
-void separate_pathname(pathname_t * name, char *buf, pathname_t * newname)
-{
-	char *slash;
-
-	init_pathname(newname);
-	slash = strchr(name->path, '/');
-	if (slash == NULL) {
-		buf[0] = '\0';
-		return;
-	}
-	*slash = '\0';
-	strcpy(buf, name->path);
-	*slash = '/';
-	append_pathname(newname, slash + 1);
-}
-
-#define WIDTH 80
-
-void show_ops(int flag, char *lead_str)
-{
-	opdesc_t *p;
-
-	if (flag < 0) {
-		/* print in list form */
-		int x = WIDTH;
-
-		for (p = ops; p < ops_end; p++) {
-			if (lead_str != NULL
-			    && x + strlen(p->name) >= WIDTH - 5)
-				x = printf("%s%s", (p == ops) ? "" : "\n",
-					   lead_str);
-			x += printf("%s ", p->name);
-		}
-		printf("\n");
-	} else {
-		int f;
-		for (f = 0, p = ops; p < ops_end; p++)
-			f += p->freq;
-
-		if (f == 0)
-			flag = 1;
-
-		for (p = ops; p < ops_end; p++) {
-			if (flag != 0 || p->freq > 0) {
-				if (lead_str != NULL)
-					printf("%s", lead_str);
-				printf("%20s %d/%d %s\n",
-				       p->name, p->freq, f,
-				       (p->iswrite == 0) ? " " : "write op");
-			}
-		}
-	}
-}
-
-int stat64_path(pathname_t * name, struct stat64 *sbuf)
-{
-	char buf[MAXNAMELEN];
-	pathname_t newname;
-	int rval;
-
-	rval = stat64(name->path, sbuf);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name, buf, &newname);
-	if (chdir(buf) == 0) {
-		rval = stat64_path(&newname, sbuf);
-		chdir("..");
-	}
-	free_pathname(&newname);
-	return rval;
-}
-
-int symlink_path(const char *name1, pathname_t * name)
-{
-	char buf[MAXNAMELEN];
-	pathname_t newname;
-	int rval;
-
-	if (!strcmp(name1, name->path)) {
-		printf("yikes! %s %s\n", name1, name->path);
-		return 0;
-	}
-
-	rval = symlink(name1, name->path);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name, buf, &newname);
-	if (chdir(buf) == 0) {
-		rval = symlink_path(name1, &newname);
-		chdir("..");
-	}
-	free_pathname(&newname);
-	return rval;
-}
-
-int truncate64_path(pathname_t * name, off64_t length)
-{
-	char buf[MAXNAMELEN];
-	pathname_t newname;
-	int rval;
-
-	rval = truncate64(name->path, length);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name, buf, &newname);
-	if (chdir(buf) == 0) {
-		rval = truncate64_path(&newname, length);
-		chdir("..");
-	}
-	free_pathname(&newname);
-	return rval;
-}
-
-int unlink_path(pathname_t * name)
-{
-	char buf[MAXNAMELEN];
-	pathname_t newname;
-	int rval;
-
-	rval = unlink(name->path);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name, buf, &newname);
-	if (chdir(buf) == 0) {
-		rval = unlink_path(&newname);
-		chdir("..");
-	}
-	free_pathname(&newname);
-	return rval;
-}
-
-void usage(void)
-{
-	printf("Usage: %s -H   or\n", myprog);
-	printf
-	    ("       %s [-c][-d dir][-e errtg][-f op_name=freq][-l loops][-n nops]\n",
-	     myprog);
-	printf("          [-p nproc][-r len][-s seed][-v][-w][-z][-S]\n");
-	printf("where\n");
-	printf
-	    ("   -c               specifies not to remove files(cleanup) after execution\n");
-	printf
-	    ("   -d dir           specifies the base directory for operations\n");
-	printf("   -e errtg         specifies error injection stuff\n");
-	printf
-	    ("   -f op_name=freq  changes the frequency of option name to freq\n");
-	printf("                    the valid operation names are:\n");
-	show_ops(-1, "                        ");
-	printf
-	    ("   -l loops         specifies the no. of times the testrun should loop.\n");
-	printf("                     *use 0 for infinite (default 1)\n");
-	printf
-	    ("   -n nops          specifies the no. of operations per process (default 1)\n");
-	printf
-	    ("   -p nproc         specifies the no. of processes (default 1)\n");
-	printf("   -r               specifies random name padding\n");
-	printf
-	    ("   -s seed          specifies the seed for the random generator (default random)\n");
-	printf("   -v               specifies verbose mode\n");
-	printf
-	    ("   -w               zeros frequencies of non-write operations\n");
-	printf("   -z               zeros frequencies of all operations\n");
-	printf
-	    ("   -S               prints the table of operations (omitting zero frequency)\n");
-	printf("   -H               prints usage and exits\n");
-	printf
-	    ("   -X               don't do anything XFS specific (default with -DNO_XFS)\n");
-}
-
-void write_freq(void)
-{
-	opdesc_t *p;
-
-	for (p = ops; p < ops_end; p++) {
-		if (!p->iswrite)
-			p->freq = 0;
-	}
-}
-
-void zero_freq(void)
-{
-	opdesc_t *p;
-
-	for (p = ops; p < ops_end; p++)
-		p->freq = 0;
-}
-
-#ifndef NO_XFS
-
-void allocsp_f(int opno, long r)
-{
-	int e;
-	pathname_t f;
-	int fd;
-	struct flock64 fl;
-	int64_t lr;
-	off64_t off;
-	struct stat64 stb;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
-		if (v)
-			printf("%d/%d: allocsp - no filename\n", procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	fd = open_path(&f, O_RDWR);
-	e = fd < 0 ? errno : 0;
-	check_cwd();
-	if (fd < 0) {
-		if (v)
-			printf("%d/%d: allocsp - open %s failed %d\n",
-			       procid, opno, f.path, e);
-		free_pathname(&f);
-		return;
-	}
-	if (fstat64(fd, &stb) < 0) {
-		if (v)
-			printf("%d/%d: allocsp - fstat64 %s failed %d\n",
-			       procid, opno, f.path, errno);
-		free_pathname(&f);
-		close(fd);
-		return;
-	}
-	lr = ((int64_t) random() << 32) + random();
-	off = (off64_t) (lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
-	off %= maxfsize;
-	fl.l_whence = SEEK_SET;
-	fl.l_start = off;
-	fl.l_len = 0;
-	e = ioctl(fd, XFS_IOC_ALLOCSP64, &fl) < 0 ? errno : 0;
-	if (v)
-		printf("%d/%d: ioctl(XFS_IOC_ALLOCSP64) %s %lld 0 %d\n",
-		       procid, opno, f.path, off, e);
-	free_pathname(&f);
-	close(fd);
-}
-
-void attr_remove_f(int opno, long r)
-{
-	attrlist_ent_t *aep;
-	attrlist_t *alist;
-	char *aname;
-	char buf[4096];
-	attrlist_cursor_t cursor;
-	int e;
-	int ent;
-	pathname_t f;
-	int total;
-	int v;
-	int which;
-
-	init_pathname(&f);
-	if (!get_fname(FT_ANYm, r, &f, NULL, NULL, &v))
-		append_pathname(&f, ".");
-	total = 0;
-	memset(&cursor, 0x00, sizeof(cursor));
-	do {
-		e = attr_list_path(&f, buf, sizeof(buf), ATTR_DONTFOLLOW,
-				   &cursor);
-		check_cwd();
-		if (e)
-			break;
-		alist = (attrlist_t *) buf;
-		total += alist->al_count;
-	} while (alist->al_more);
-	if (total == 0) {
-		if (v)
-			printf("%d/%d: attr_remove - no attrs for %s\n",
-			       procid, opno, f.path);
-		free_pathname(&f);
-		return;
-	}
-	which = (int)(random() % total);
-	memset(&cursor, 0x00, sizeof(cursor));
-	ent = 0;
-	aname = NULL;
-	do {
-		e = attr_list_path(&f, buf, sizeof(buf), ATTR_DONTFOLLOW,
-				   &cursor);
-		check_cwd();
-		if (e)
-			break;
-		alist = (attrlist_t *) buf;
-		if (which < ent + alist->al_count) {
-			aep = (attrlist_ent_t *)
-			    & buf[alist->al_offset[which - ent]];
-			aname = aep->a_name;
-			break;
-		}
-		ent += alist->al_count;
-	} while (alist->al_more);
-	if (aname == NULL) {
-		if (v)
-			printf("%d/%d: attr_remove - name %d not found at %s\n",
-			       procid, opno, which, f.path);
-		free_pathname(&f);
-		return;
-	}
-	e = attr_remove_path(&f, aname, ATTR_DONTFOLLOW) < 0 ? errno : 0;
-	check_cwd();
-	if (v)
-		printf("%d/%d: attr_remove %s %s %d\n",
-		       procid, opno, f.path, aname, e);
-	free_pathname(&f);
-}
-
-void attr_set_f(int opno, long r)
-{
-	char aname[10];
-	char *aval;
-	int e;
-	pathname_t f;
-	int len;
-	static int lengths[] = { 10, 100, 1000, 10000 };
-	int li;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_ANYm, r, &f, NULL, NULL, &v))
-		append_pathname(&f, ".");
-	sprintf(aname, "a%x", nameseq++);
-	li = (int)(random() % (sizeof(lengths) / sizeof(lengths[0])));
-	len = (int)(random() % lengths[li]);
-	if (len == 0)
-		len = 1;
-	aval = malloc(len);
-	memset(aval, nameseq & 0xff, len);
-	e = attr_set_path(&f, aname, aval, len, ATTR_DONTFOLLOW) < 0 ?
-	    errno : 0;
-	check_cwd();
-	free(aval);
-	if (v)
-		printf("%d/%d: attr_set %s %s %d\n", procid, opno, f.path,
-		       aname, e);
-	free_pathname(&f);
-}
-
-void bulkstat_f(int opno, long r)
-{
-	int count;
-	int fd;
-	__uint64_t last;
-	int nent;
-	xfs_bstat_t *t;
-	int64_t total;
-	xfs_fsop_bulkreq_t bsr;
-
-	last = 0;
-	nent = (r % 999) + 2;
-	t = malloc(nent * sizeof(*t));
-	fd = open(".", O_RDONLY);
-	total = 0;
-
-	bsr.lastip = &last;
-	bsr.icount = nent;
-	bsr.ubuffer = t;
-	bsr.ocount = &count;
-
-	while (ioctl(fd, XFS_IOC_FSBULKSTAT, &bsr) == 0 && count > 0)
-		total += count;
-	free(t);
-	if (verbose)
-		printf("%d/%d: bulkstat nent %d total %lld\n",
-		       procid, opno, nent, total);
-	close(fd);
-}
-
-void bulkstat1_f(int opno, long r)
-{
-	int e;
-	pathname_t f;
-	int fd;
-	int good;
-	__uint64_t ino;
-	struct stat64 s;
-	xfs_bstat_t t;
-	int v;
-	xfs_fsop_bulkreq_t bsr;
-
-	good = random() & 1;
-	if (good) {
-		/* use an inode we know exists */
-		init_pathname(&f);
-		if (!get_fname(FT_ANYm, r, &f, NULL, NULL, &v))
-			append_pathname(&f, ".");
-		ino = stat64_path(&f, &s) < 0 ? (ino64_t) r : s.st_ino;
-		check_cwd();
-		free_pathname(&f);
-	} else {
-		/*
-		 * pick a random inode
-		 *
-		 * note this can generate kernel warning messages
-		 * since bulkstat_one will read the disk block that
-		 * would contain a given inode even if that disk
-		 * block doesn't contain inodes.
-		 *
-		 * this is detected later, but not until after the
-		 * warning is displayed.
-		 *
-		 * "XFS: device 0x825- bad inode magic/vsn daddr 0x0 #0"
-		 *
-		 */
-		ino = (ino64_t) r;
-		v = verbose;
-	}
-	fd = open(".", O_RDONLY);
-
-	bsr.lastip = &ino;
-	bsr.icount = 1;
-	bsr.ubuffer = &t;
-	bsr.ocount = NULL;
-
-	e = ioctl(fd, XFS_IOC_FSBULKSTAT_SINGLE, &bsr) < 0 ? errno : 0;
-	if (v)
-		printf("%d/%d: bulkstat1 %s ino %lld %d\n",
-		       procid, opno, good ? "real" : "random", (int64_t) ino,
-		       e);
-	close(fd);
-}
-
-#endif
-
-void chown_f(int opno, long r)
-{
-	int e;
-	pathname_t f;
-	int nbits;
-	uid_t u;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_ANYm, r, &f, NULL, NULL, &v))
-		append_pathname(&f, ".");
-	u = (uid_t) random();
-	nbits = (int)(random() % 32);
-	u &= (1 << nbits) - 1;
-	e = lchown_path(&f, u, -1) < 0 ? errno : 0;
-	check_cwd();
-	if (v)
-		printf("%d/%d: chown %s %d %d\n", procid, opno, f.path, u, e);
-	free_pathname(&f);
-}
-
-void creat_f(int opno, long r)
-{
-	int e;
-	int e1;
-	int extsize;
-	pathname_t f;
-	int fd;
-	fent_t *fep;
-	int id;
-	int parid;
-	int type;
-	int v;
-	int v1;
-	int esz = 0;
-
-	if (!get_fname(FT_DIRm, r, NULL, NULL, &fep, &v1))
-		parid = -1;
-	else
-		parid = fep->id;
-	init_pathname(&f);
-	type = rtpct ? ((random() % 100) > rtpct ? FT_REG : FT_RTF) : FT_REG;
-	if (type == FT_RTF)
-		extsize = (random() % 10) + 1;
-	else
-		extsize = 0;
-	e = generate_fname(fep, type, &f, &id, &v);
-	v |= v1;
-	if (!e) {
-		if (v) {
-			fent_to_name(&f, &flist[FT_DIR], fep);
-			printf("%d/%d: creat - no filename from %s\n",
-			       procid, opno, f.path);
-		}
-		free_pathname(&f);
-		return;
-	}
-	fd = creat_path(&f, 0666);
-	e = fd < 0 ? errno : 0;
-	e1 = 0;
-	check_cwd();
-	esz = 0;
-	if (fd >= 0) {
-#ifndef NO_XFS
-		struct fsxattr a;
-		if (extsize && ioctl(fd, XFS_IOC_FSGETXATTR, &a) >= 0) {
-			a.fsx_xflags |= XFS_XFLAG_REALTIME;
-			a.fsx_extsize =
-			    geom.rtextsize * geom.blocksize * extsize;
-			if (ioctl(fd, XFS_IOC_FSSETXATTR, &a) < 0)
-				e1 = errno;
-			esz = a.fsx_estsize;
-
-		}
-#endif
-		add_to_flist(type, id, parid);
-		close(fd);
-	}
-	if (v)
-		printf("%d/%d: creat %s x:%d %d %d\n", procid, opno, f.path,
-		       esz, e, e1);
-	free_pathname(&f);
-}
-
-int setdirect(int fd)
-{
-	static int no_direct;
-	int flags;
-
-	if (no_direct)
-		return 0;
-
-	flags = fcntl(fd, F_GETFL, 0);
-	if (flags < 0)
-		return 0;
-
-	if (fcntl(fd, F_SETFL, flags | O_DIRECT) < 0) {
-		if (no_xfs) {
-			no_direct = 1;
-			return 0;
-		}
-		printf("cannot set O_DIRECT: %s\n", strerror(errno));
-		return 0;
-	}
-
-	return 1;
-}
-
-void dread_f(int opno, long r)
-{
-	int64_t align;
-	char *buf;
-	struct dioattr diob;
-	int e;
-	pathname_t f;
-	int fd;
-	size_t len;
-	int64_t lr;
-	off64_t off;
-	struct stat64 stb;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
-		if (v)
-			printf("%d/%d: dread - no filename\n", procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	fd = open_path(&f, O_RDONLY);
-
-	if (!setdirect(fd)) {
-		return;
-	}
-
-	e = fd < 0 ? errno : 0;
-	check_cwd();
-	if (fd < 0) {
-		if (v)
-			printf("%d/%d: dread - open %s failed %d\n",
-			       procid, opno, f.path, e);
-		free_pathname(&f);
-		return;
-	}
-	if (fstat64(fd, &stb) < 0) {
-		if (v)
-			printf("%d/%d: dread - fstat64 %s failed %d\n",
-			       procid, opno, f.path, errno);
-		free_pathname(&f);
-		close(fd);
-		return;
-	}
-	if (stb.st_size == 0) {
-		if (v)
-			printf("%d/%d: dread - %s zero size\n", procid, opno,
-			       f.path);
-		free_pathname(&f);
-		close(fd);
-		return;
-	}
-
-	if (no_xfs) {
-		diob.d_miniosz = stb.st_blksize;
-		diob.d_maxiosz = stb.st_blksize * 256;	/* good number ? */
-		diob.d_mem = stb.st_blksize;
-	}
-#ifndef NO_XFS
-	else if (ioctl(fd, XFS_IOC_DIOINFO, &diob) < 0) {
-		if (v)
-			printf
-			    ("%d/%d: dread - ioctl(fd, XFS_IOC_DIOINFO) %s failed %d\n",
-			     procid, opno, f.path, errno);
-		free_pathname(&f);
-		close(fd);
-		return;
-	}
-#endif
-	align = (int64_t) diob.d_miniosz;
-	lr = ((int64_t) random() << 32) + random();
-	off = (off64_t) (lr % stb.st_size);
-	off -= (off % align);
-	lseek64(fd, off, SEEK_SET);
-	len = (random() % (getpagesize() * 32)) + 1;
-	len -= (len % align);
-	if (len <= 0)
-		len = align;
-	else if (len > diob.d_maxiosz)
-		len = diob.d_maxiosz;
-	posix_memalign((void **)&buf, diob.d_mem, len);
-	e = read(fd, buf, len) < 0 ? errno : 0;
-	free(buf);
-	if (v)
-		printf("%d/%d: dread %s [%lld,%ld] %d\n",
-		       procid, opno, f.path, (long long int)off, (long)len, e);
-	free_pathname(&f);
-	close(fd);
-}
-
-void dwrite_f(int opno, long r)
-{
-	int64_t align;
-	char *buf;
-	struct dioattr diob;
-	int e;
-	pathname_t f;
-	int fd;
-	size_t len;
-	int64_t lr;
-	off64_t off;
-	struct stat64 stb;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
-		if (v)
-			printf("%d/%d: dwrite - no filename\n", procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	fd = open_path(&f, O_WRONLY);
-	e = fd < 0 ? errno : 0;
-	check_cwd();
-	if (fd < 0) {
-		if (v)
-			printf("%d/%d: dwrite - open %s failed %d\n",
-			       procid, opno, f.path, e);
-		free_pathname(&f);
-		return;
-	}
-
-	if (!setdirect(fd))
-		return;
-	if (fstat64(fd, &stb) < 0) {
-		if (v)
-			printf("%d/%d: dwrite - fstat64 %s failed %d\n",
-			       procid, opno, f.path, errno);
-		free_pathname(&f);
-		close(fd);
-		return;
-	}
-	if (no_xfs) {
-		diob.d_miniosz = stb.st_blksize;
-		diob.d_maxiosz = stb.st_blksize * 256;	/* good number ? */
-		diob.d_mem = stb.st_blksize;
-	}
-#ifndef NO_XFS
-	else if (ioctl(fd, XFS_IOC_DIOINFO, &diob) < 0) {
-		if (v)
-			printf
-			    ("%d/%d: dwrite - ioctl(fd, XFS_IOC_DIOINFO) %s failed %d\n",
-			     procid, opno, f.path, errno);
-		free_pathname(&f);
-		close(fd);
-		return;
-	}
-#endif
-	align = (int64_t) diob.d_miniosz;
-	lr = ((int64_t) random() << 32) + random();
-	off = (off64_t) (lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
-	off -= (off % align);
-	lseek64(fd, off, SEEK_SET);
-	len = (random() % (getpagesize() * 32)) + 1;
-	len -= (len % align);
-	if (len <= 0)
-		len = align;
-	else if (len > diob.d_maxiosz)
-		len = diob.d_maxiosz;
-	posix_memalign((void **)&buf, diob.d_mem, len);
-	off %= maxfsize;
-	lseek64(fd, off, SEEK_SET);
-	memset(buf, nameseq & 0xff, len);
-	e = write(fd, buf, len) < 0 ? errno : 0;
-	free(buf);
-	if (v)
-		printf("%d/%d: dwrite %s [%lld,%ld] %d\n",
-		       procid, opno, f.path, (long long)off, (long int)len, e);
-	free_pathname(&f);
-	close(fd);
-}
-
-void fdatasync_f(int opno, long r)
-{
-	int e;
-	pathname_t f;
-	int fd;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
-		if (v)
-			printf("%d/%d: fdatasync - no filename\n",
-			       procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	fd = open_path(&f, O_WRONLY);
-	e = fd < 0 ? errno : 0;
-	check_cwd();
-	if (fd < 0) {
-		if (v)
-			printf("%d/%d: fdatasync - open %s failed %d\n",
-			       procid, opno, f.path, e);
-		free_pathname(&f);
-		return;
-	}
-	e = fdatasync(fd) < 0 ? errno : 0;
-	if (v)
-		printf("%d/%d: fdatasync %s %d\n", procid, opno, f.path, e);
-	free_pathname(&f);
-	close(fd);
-}
-
-#ifndef NO_XFS
-void freesp_f(int opno, long r)
-{
-	int e;
-	pathname_t f;
-	int fd;
-	struct flock64 fl;
-	int64_t lr;
-	off64_t off;
-	struct stat64 stb;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
-		if (v)
-			printf("%d/%d: freesp - no filename\n", procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	fd = open_path(&f, O_RDWR);
-	e = fd < 0 ? errno : 0;
-	check_cwd();
-	if (fd < 0) {
-		if (v)
-			printf("%d/%d: freesp - open %s failed %d\n",
-			       procid, opno, f.path, e);
-		free_pathname(&f);
-		return;
-	}
-	if (fstat64(fd, &stb) < 0) {
-		if (v)
-			printf("%d/%d: freesp - fstat64 %s failed %d\n",
-			       procid, opno, f.path, errno);
-		free_pathname(&f);
-		close(fd);
-		return;
-	}
-	lr = ((int64_t) random() << 32) + random();
-	off = (off64_t) (lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
-	off %= maxfsize;
-	fl.l_whence = SEEK_SET;
-	fl.l_start = off;
-	fl.l_len = 0;
-	e = ioctl(fd, XFS_IOC_FREESP64, &fl) < 0 ? errno : 0;
-	if (v)
-		printf("%d/%d: ioctl(XFS_IOC_FREESP64) %s %lld 0 %d\n",
-		       procid, opno, f.path, off, e);
-	free_pathname(&f);
-	close(fd);
-}
-
-#endif
-
-void fsync_f(int opno, long r)
-{
-	int e;
-	pathname_t f;
-	int fd;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
-		if (v)
-			printf("%d/%d: fsync - no filename\n", procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	fd = open_path(&f, O_WRONLY);
-	e = fd < 0 ? errno : 0;
-	check_cwd();
-	if (fd < 0) {
-		if (v)
-			printf("%d/%d: fsync - open %s failed %d\n",
-			       procid, opno, f.path, e);
-		free_pathname(&f);
-		return;
-	}
-	e = fsync(fd) < 0 ? errno : 0;
-	if (v)
-		printf("%d/%d: fsync %s %d\n", procid, opno, f.path, e);
-	free_pathname(&f);
-	close(fd);
-}
-
-void getdents_f(int opno, long r)
-{
-	DIR *dir;
-	pathname_t f;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_DIRm, r, &f, NULL, NULL, &v))
-		append_pathname(&f, ".");
-	dir = opendir_path(&f);
-	check_cwd();
-	if (dir == NULL) {
-		if (v)
-			printf("%d/%d: getdents - can't open %s\n",
-			       procid, opno, f.path);
-		free_pathname(&f);
-		return;
-	}
-	while (readdir64(dir) != NULL)
-		continue;
-	if (v)
-		printf("%d/%d: getdents %s 0\n", procid, opno, f.path);
-	free_pathname(&f);
-	closedir(dir);
-}
-
-void link_f(int opno, long r)
-{
-	int e;
-	pathname_t f;
-	fent_t *fep;
-	flist_t *flp;
-	int id;
-	pathname_t l;
-	int parid;
-	int v;
-	int v1;
-
-	init_pathname(&f);
-	if (!get_fname(FT_NOTDIR, r, &f, &flp, NULL, &v1)) {
-		if (v1)
-			printf("%d/%d: link - no file\n", procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	if (!get_fname(FT_DIRm, random(), NULL, NULL, &fep, &v))
-		parid = -1;
-	else
-		parid = fep->id;
-	v |= v1;
-	init_pathname(&l);
-	e = generate_fname(fep, flp - flist, &l, &id, &v1);
-	v |= v1;
-	if (!e) {
-		if (v) {
-			fent_to_name(&l, &flist[FT_DIR], fep);
-			printf("%d/%d: link - no filename from %s\n",
-			       procid, opno, l.path);
-		}
-		free_pathname(&l);
-		free_pathname(&f);
-		return;
-	}
-	e = link_path(&f, &l) < 0 ? errno : 0;
-	check_cwd();
-	if (e == 0)
-		add_to_flist(flp - flist, id, parid);
-	if (v)
-		printf("%d/%d: link %s %s %d\n", procid, opno, f.path, l.path,
-		       e);
-	free_pathname(&l);
-	free_pathname(&f);
-}
-
-void mkdir_f(int opno, long r)
-{
-	int e;
-	pathname_t f;
-	fent_t *fep;
-	int id;
-	int parid;
-	int v;
-	int v1;
-
-	if (!get_fname(FT_DIRm, r, NULL, NULL, &fep, &v))
-		parid = -1;
-	else
-		parid = fep->id;
-	init_pathname(&f);
-	e = generate_fname(fep, FT_DIR, &f, &id, &v1);
-	v |= v1;
-	if (!e) {
-		if (v) {
-			fent_to_name(&f, &flist[FT_DIR], fep);
-			printf("%d/%d: mkdir - no filename from %s\n",
-			       procid, opno, f.path);
-		}
-		free_pathname(&f);
-		return;
-	}
-	e = mkdir_path(&f, 0777) < 0 ? errno : 0;
-	check_cwd();
-	if (e == 0)
-		add_to_flist(FT_DIR, id, parid);
-	if (v)
-		printf("%d/%d: mkdir %s %d\n", procid, opno, f.path, e);
-	free_pathname(&f);
-}
-
-void mknod_f(int opno, long r)
-{
-	int e;
-	pathname_t f;
-	fent_t *fep;
-	int id;
-	int parid;
-	int v;
-	int v1;
-
-	if (!get_fname(FT_DIRm, r, NULL, NULL, &fep, &v))
-		parid = -1;
-	else
-		parid = fep->id;
-	init_pathname(&f);
-	e = generate_fname(fep, FT_DEV, &f, &id, &v1);
-	v |= v1;
-	if (!e) {
-		if (v) {
-			fent_to_name(&f, &flist[FT_DIR], fep);
-			printf("%d/%d: mknod - no filename from %s\n",
-			       procid, opno, f.path);
-		}
-		free_pathname(&f);
-		return;
-	}
-	e = mknod_path(&f, S_IFCHR | 0444, 0) < 0 ? errno : 0;
-	check_cwd();
-	if (e == 0)
-		add_to_flist(FT_DEV, id, parid);
-	if (v)
-		printf("%d/%d: mknod %s %d\n", procid, opno, f.path, e);
-	free_pathname(&f);
-}
-
-void read_f(int opno, long r)
-{
-	char *buf;
-	int e;
-	pathname_t f;
-	int fd;
-	size_t len;
-	int64_t lr;
-	off64_t off;
-	struct stat64 stb;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
-		if (v)
-			printf("%d/%d: read - no filename\n", procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	fd = open_path(&f, O_RDONLY);
-	e = fd < 0 ? errno : 0;
-	check_cwd();
-	if (fd < 0) {
-		if (v)
-			printf("%d/%d: read - open %s failed %d\n",
-			       procid, opno, f.path, e);
-		free_pathname(&f);
-		return;
-	}
-	if (fstat64(fd, &stb) < 0) {
-		if (v)
-			printf("%d/%d: read - fstat64 %s failed %d\n",
-			       procid, opno, f.path, errno);
-		free_pathname(&f);
-		close(fd);
-		return;
-	}
-	if (stb.st_size == 0) {
-		if (v)
-			printf("%d/%d: read - %s zero size\n", procid, opno,
-			       f.path);
-		free_pathname(&f);
-		close(fd);
-		return;
-	}
-	lr = ((int64_t) random() << 32) + random();
-	off = (off64_t) (lr % stb.st_size);
-	lseek64(fd, off, SEEK_SET);
-	len = (random() % (getpagesize() * 32)) + 1;
-	buf = malloc(len);
-	e = read(fd, buf, len) < 0 ? errno : 0;
-	free(buf);
-	if (v)
-		printf("%d/%d: read %s [%lld,%ld] %d\n",
-		       procid, opno, f.path, (long long)off, (long int)len, e);
-	free_pathname(&f);
-	close(fd);
-}
-
-void readlink_f(int opno, long r)
-{
-	char buf[PATH_MAX];
-	int e;
-	pathname_t f;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_SYMm, r, &f, NULL, NULL, &v)) {
-		if (v)
-			printf("%d/%d: readlink - no filename\n", procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	e = readlink_path(&f, buf, PATH_MAX) < 0 ? errno : 0;
-	check_cwd();
-	if (v)
-		printf("%d/%d: readlink %s %d\n", procid, opno, f.path, e);
-	free_pathname(&f);
-}
-
-void rename_f(int opno, long r)
-{
-	fent_t *dfep;
-	int e;
-	pathname_t f;
-	fent_t *fep;
-	flist_t *flp;
-	int id;
-	pathname_t newf;
-	int oldid;
-	int parid;
-	int v;
-	int v1;
-
-	init_pathname(&f);
-	if (!get_fname(FT_ANYm, r, &f, &flp, &fep, &v1)) {
-		if (v1)
-			printf("%d/%d: rename - no filename\n", procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	if (!get_fname(FT_DIRm, random(), NULL, NULL, &dfep, &v))
-		parid = -1;
-	else
-		parid = dfep->id;
-	v |= v1;
-	init_pathname(&newf);
-	e = generate_fname(dfep, flp - flist, &newf, &id, &v1);
-	v |= v1;
-	if (!e) {
-		if (v) {
-			fent_to_name(&f, &flist[FT_DIR], dfep);
-			printf("%d/%d: rename - no filename from %s\n",
-			       procid, opno, f.path);
-		}
-		free_pathname(&newf);
-		free_pathname(&f);
-		return;
-	}
-	e = rename_path(&f, &newf) < 0 ? errno : 0;
-	check_cwd();
-	if (e == 0) {
-		if (flp - flist == FT_DIR) {
-			oldid = fep->id;
-			fix_parent(oldid, id);
-		}
-		del_from_flist(flp - flist, fep - flp->fents);
-		add_to_flist(flp - flist, id, parid);
-	}
-	if (v)
-		printf("%d/%d: rename %s to %s %d\n", procid, opno, f.path,
-		       newf.path, e);
-	free_pathname(&newf);
-	free_pathname(&f);
-}
-
-#ifndef NO_XFS
-void resvsp_f(int opno, long r)
-{
-	int e;
-	pathname_t f;
-	int fd;
-	struct flock64 fl;
-	int64_t lr;
-	off64_t off;
-	struct stat64 stb;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
-		if (v)
-			printf("%d/%d: resvsp - no filename\n", procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	fd = open_path(&f, O_RDWR);
-	e = fd < 0 ? errno : 0;
-	check_cwd();
-	if (fd < 0) {
-		if (v)
-			printf("%d/%d: resvsp - open %s failed %d\n",
-			       procid, opno, f.path, e);
-		free_pathname(&f);
-		return;
-	}
-	if (fstat64(fd, &stb) < 0) {
-		if (v)
-			printf("%d/%d: resvsp - fstat64 %s failed %d\n",
-			       procid, opno, f.path, errno);
-		free_pathname(&f);
-		close(fd);
-		return;
-	}
-	lr = ((int64_t) random() << 32) + random();
-	off = (off64_t) (lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
-	off %= maxfsize;
-	fl.l_whence = SEEK_SET;
-	fl.l_start = off;
-	fl.l_len = (off64_t) (random() % (1024 * 1024));
-	e = ioctl(fd, XFS_IOC_RESVSP64, &fl) < 0 ? errno : 0;
-	if (v)
-		printf("%d/%d: ioctl(XFS_IOC_RESVSP64) %s %lld %lld %d\n",
-		       procid, opno, f.path, off, fl.l_len, e);
-	free_pathname(&f);
-	close(fd);
-}
-#endif
-
-void rmdir_f(int opno, long r)
-{
-	int e;
-	pathname_t f;
-	fent_t *fep;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_DIRm, r, &f, NULL, &fep, &v)) {
-		if (v)
-			printf("%d/%d: rmdir - no directory\n", procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	e = rmdir_path(&f) < 0 ? errno : 0;
-	check_cwd();
-	if (e == 0)
-		del_from_flist(FT_DIR, fep - flist[FT_DIR].fents);
-	if (v)
-		printf("%d/%d: rmdir %s %d\n", procid, opno, f.path, e);
-	free_pathname(&f);
-}
-
-void stat_f(int opno, long r)
-{
-	int e;
-	pathname_t f;
-	struct stat64 stb;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_ANYm, r, &f, NULL, NULL, &v)) {
-		if (v)
-			printf("%d/%d: stat - no entries\n", procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	e = lstat64_path(&f, &stb) < 0 ? errno : 0;
-	check_cwd();
-	if (v)
-		printf("%d/%d: stat %s %d\n", procid, opno, f.path, e);
-	free_pathname(&f);
-}
-
-void symlink_f(int opno, long r)
-{
-	int e;
-	pathname_t f;
-	fent_t *fep;
-	int i;
-	int id;
-	int len;
-	int parid;
-	int v;
-	int v1;
-	char *val;
-
-	if (!get_fname(FT_DIRm, r, NULL, NULL, &fep, &v))
-		parid = -1;
-	else
-		parid = fep->id;
-	init_pathname(&f);
-	e = generate_fname(fep, FT_SYM, &f, &id, &v1);
-	v |= v1;
-	if (!e) {
-		if (v) {
-			fent_to_name(&f, &flist[FT_DIR], fep);
-			printf("%d/%d: symlink - no filename from %s\n",
-			       procid, opno, f.path);
-		}
-		free_pathname(&f);
-		return;
-	}
-	len = (int)(random() % PATH_MAX);
-	val = malloc(len + 1);
-	if (len)
-		memset(val, 'x', len);
-	val[len] = '\0';
-	for (i = 10; i < len - 1; i += 10)
-		val[i] = '/';
-	e = symlink_path(val, &f) < 0 ? errno : 0;
-	check_cwd();
-	if (e == 0)
-		add_to_flist(FT_SYM, id, parid);
-	free(val);
-	if (v)
-		printf("%d/%d: symlink %s %d\n", procid, opno, f.path, e);
-	free_pathname(&f);
-}
-
-/* ARGSUSED */
-void sync_f(int opno, long r)
-{
-	sync();
-	if (verbose)
-		printf("%d/%d: sync\n", procid, opno);
-}
-
-void truncate_f(int opno, long r)
-{
-	int e;
-	pathname_t f;
-	int64_t lr;
-	off64_t off;
-	struct stat64 stb;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
-		if (v)
-			printf("%d/%d: truncate - no filename\n", procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	e = stat64_path(&f, &stb) < 0 ? errno : 0;
-	check_cwd();
-	if (e > 0) {
-		if (v)
-			printf("%d/%d: truncate - stat64 %s failed %d\n",
-			       procid, opno, f.path, e);
-		free_pathname(&f);
-		return;
-	}
-	lr = ((int64_t) random() << 32) + random();
-	off = (off64_t) (lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
-	off %= maxfsize;
-	e = truncate64_path(&f, off) < 0 ? errno : 0;
-	check_cwd();
-	if (v)
-		printf("%d/%d: truncate %s %lld %d\n", procid, opno, f.path,
-		       (long long)off, e);
-	free_pathname(&f);
-}
-
-void unlink_f(int opno, long r)
-{
-	int e;
-	pathname_t f;
-	fent_t *fep;
-	flist_t *flp;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_NOTDIR, r, &f, &flp, &fep, &v)) {
-		if (v)
-			printf("%d/%d: unlink - no file\n", procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	e = unlink_path(&f) < 0 ? errno : 0;
-	check_cwd();
-	if (e == 0)
-		del_from_flist(flp - flist, fep - flp->fents);
-	if (v)
-		printf("%d/%d: unlink %s %d\n", procid, opno, f.path, e);
-	free_pathname(&f);
-}
-
-#ifndef NO_XFS
-void unresvsp_f(int opno, long r)
-{
-	int e;
-	pathname_t f;
-	int fd;
-	struct flock64 fl;
-	int64_t lr;
-	off64_t off;
-	struct stat64 stb;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
-		if (v)
-			printf("%d/%d: unresvsp - no filename\n", procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	fd = open_path(&f, O_RDWR);
-	e = fd < 0 ? errno : 0;
-	check_cwd();
-	if (fd < 0) {
-		if (v)
-			printf("%d/%d: unresvsp - open %s failed %d\n",
-			       procid, opno, f.path, e);
-		free_pathname(&f);
-		return;
-	}
-	if (fstat64(fd, &stb) < 0) {
-		if (v)
-			printf("%d/%d: unresvsp - fstat64 %s failed %d\n",
-			       procid, opno, f.path, errno);
-		free_pathname(&f);
-		close(fd);
-		return;
-	}
-	lr = ((int64_t) random() << 32) + random();
-	off = (off64_t) (lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
-	off %= maxfsize;
-	fl.l_whence = SEEK_SET;
-	fl.l_start = off;
-	fl.l_len = (off64_t) (random() % (1 << 20));
-	e = ioctl(fd, XFS_IOC_UNRESVSP64, &fl) < 0 ? errno : 0;
-	if (v)
-		printf("%d/%d: ioctl(XFS_IOC_UNRESVSP64) %s %lld %lld %d\n",
-		       procid, opno, f.path, off, fl.l_len, e);
-	free_pathname(&f);
-	close(fd);
-}
-#endif
-
-void write_f(int opno, long r)
-{
-	char *buf;
-	int e;
-	pathname_t f;
-	int fd;
-	size_t len;
-	int64_t lr;
-	off64_t off;
-	struct stat64 stb;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_REGm, r, &f, NULL, NULL, &v)) {
-		if (v)
-			printf("%d/%d: write - no filename\n", procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	fd = open_path(&f, O_WRONLY);
-	e = fd < 0 ? errno : 0;
-	check_cwd();
-	if (fd < 0) {
-		if (v)
-			printf("%d/%d: write - open %s failed %d\n",
-			       procid, opno, f.path, e);
-		free_pathname(&f);
-		return;
-	}
-	if (fstat64(fd, &stb) < 0) {
-		if (v)
-			printf("%d/%d: write - fstat64 %s failed %d\n",
-			       procid, opno, f.path, errno);
-		free_pathname(&f);
-		close(fd);
-		return;
-	}
-	lr = ((int64_t) random() << 32) + random();
-	off = (off64_t) (lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
-	off %= maxfsize;
-	lseek64(fd, off, SEEK_SET);
-	len = (random() % (getpagesize() * 32)) + 1;
-	buf = malloc(len);
-	memset(buf, nameseq & 0xff, len);
-	e = write(fd, buf, len) < 0 ? errno : 0;
-	free(buf);
-	if (v)
-		printf("%d/%d: write %s [%lld,%ld] %d\n",
-		       procid, opno, f.path, (long long)off, (long int)len, e);
-	free_pathname(&f);
-	close(fd);
-}
diff --git a/testcases/network/nfs/nfs_fsstress/global.h b/testcases/network/nfs/nfs_fsstress/global.h
deleted file mode 100644
index 46b2bd8..0000000
--- a/testcases/network/nfs/nfs_fsstress/global.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-#ifndef GLOBAL_H
-#define GLOBAL_H
-
-/* xfs-specific includes */
-
-#if defined(NO_XFS)
-# include "xfscompat.h"
-#else
-# include <libxfs.h>
-# include <attributes.h>
-#endif
-
-/* libc includes */
-
-#include <sys/stat.h>
-#include <sys/statvfs.h>
-#include <sys/time.h>
-#include <sys/ioctl.h>
-#include <sys/wait.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <dirent.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-
-#ifndef O_DIRECT
-#define O_DIRECT 040000
-#endif
-
-#endif
diff --git a/testcases/network/nfs/nfs_fsstress/xfscompat.h b/testcases/network/nfs/nfs_fsstress/xfscompat.h
deleted file mode 100644
index 61550a8..0000000
--- a/testcases/network/nfs/nfs_fsstress/xfscompat.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#define MAXNAMELEN 1024
-struct dioattr {
-	int d_miniosz, d_maxiosz, d_mem;
-};
-
-#define MIN(a,b) ((a)<(b) ? @:(b))
-#define MAX(a,b) ((a)>(b) ? (a):(b))
-- 
1.7.1


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

* [LTP] [PATCH 8/8] network/nfs: remove README
  2016-06-20 14:28 [LTP] [PATCH 0/8] network/nfs: fix/cleanup tests Alexey Kodanev
                   ` (6 preceding siblings ...)
  2016-06-20 14:28 ` [LTP] [PATCH 7/8] network/nfs/nfs_fsstress: remove fsstress test Alexey Kodanev
@ 2016-06-20 14:28 ` Alexey Kodanev
  2016-08-04 10:13 ` [LTP] [PATCH 0/8] network/nfs: fix/cleanup tests Alexey Kodanev
  8 siblings, 0 replies; 10+ messages in thread
From: Alexey Kodanev @ 2016-06-20 14:28 UTC (permalink / raw)
  To: ltp

The more detailed description can be found in network/README.md.

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 testcases/network/nfs/README |   28 ----------------------------
 1 files changed, 0 insertions(+), 28 deletions(-)
 delete mode 100644 testcases/network/nfs/README

diff --git a/testcases/network/nfs/README b/testcases/network/nfs/README
deleted file mode 100644
index ee58415..0000000
--- a/testcases/network/nfs/README
+++ /dev/null
@@ -1,28 +0,0 @@
-
-NOTE:
-
-  These tests ALL assume that the "RHOST" variable is set to the hostname
-of the remote machine, i.e.
-
-    # export RHOST=<hostname here>.
-
-
-These tests also assume an identical path tree for their location on the remote
-machine.  So if pan's root path is "/home/ltptests" on the test machine, then
-it must also be located in "/home/ltptests" on the remote machine (RHOST). You
-also need to do a make and make install on both the local and remote machines
-before you run the test.
-
- You will also need to setup a ".rhosts" file in root's home directory on the
-remote machine, with the name of the local machine listed.  For example, if
-machineA is running the tests, with machineB set as RHOST, then machineB's
-root home directory will need an ".rhosts" file with machineA's hostname
-listed. After you create the .rhost file you must also set the proper
-permissions on the .rhost file.  chmod 600 .rhosts
-
-I apologize for the lengthy setup, but I tried to make it as minimal as
-possible.
-
-
--Robbie Williamson
-(robbiew@us.ibm.com)
-- 
1.7.1


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

* [LTP] [PATCH 0/8] network/nfs: fix/cleanup tests
  2016-06-20 14:28 [LTP] [PATCH 0/8] network/nfs: fix/cleanup tests Alexey Kodanev
                   ` (7 preceding siblings ...)
  2016-06-20 14:28 ` [LTP] [PATCH 8/8] network/nfs: remove README Alexey Kodanev
@ 2016-08-04 10:13 ` Alexey Kodanev
  8 siblings, 0 replies; 10+ messages in thread
From: Alexey Kodanev @ 2016-08-04 10:13 UTC (permalink / raw)
  To: ltp

Hi,
On 06/20/2016 05:28 PM, Alexey Kodanev wrote:
> Alexey Kodanev (8):
>    lib: add safe_gethostname()
>    network/nfs05: rewrite the test, make use of new library
>    network/nfs_lib.sh: add options, socket type and NFS ver
>    network/nfs/fsx: cleanup test, use test_net library
>    network/nfs/nfsstat: cleanup test, use test_net.sh library
>    network/nfs/nfsflock: clenaup & use test_net library
>    network/nfs/nfs_fsstress: remove fsstress test
>    network/nfs: remove README

Patch-set applied except first two patches that were sent separately as v2.

Thanks,
Alexey


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

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

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-20 14:28 [LTP] [PATCH 0/8] network/nfs: fix/cleanup tests Alexey Kodanev
2016-06-20 14:28 ` [LTP] [PATCH resend 1/8] lib: add safe_gethostname() Alexey Kodanev
2016-06-20 14:28 ` [LTP] [PATCH resend 2/8] network/nfs05: rewrite the test, make use of new library Alexey Kodanev
2016-06-20 14:28 ` [LTP] [PATCH 3/8] network/nfs_lib.sh: add options, socket type and NFS ver Alexey Kodanev
2016-06-20 14:28 ` [LTP] [PATCH 4/8] network/nfs/fsx: cleanup test, use test_net library Alexey Kodanev
2016-06-20 14:28 ` [LTP] [PATCH 5/8] network/nfs/nfsstat: cleanup test, use test_net.sh library Alexey Kodanev
2016-06-20 14:28 ` [LTP] [PATCH 6/8] network/nfs/nfsflock: clenaup & use test_net library Alexey Kodanev
2016-06-20 14:28 ` [LTP] [PATCH 7/8] network/nfs/nfs_fsstress: remove fsstress test Alexey Kodanev
2016-06-20 14:28 ` [LTP] [PATCH 8/8] network/nfs: remove README Alexey Kodanev
2016-08-04 10:13 ` [LTP] [PATCH 0/8] network/nfs: fix/cleanup tests 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.