Whamcloud - gitweb
b=22766 cascading_rw: take lmm_stripe_count returned by ioctl(LL_IOC_LOV_SETSTRIPE)
[fs/lustre-release.git] / lustre / tests / mpi / parallel_grouplock.c
index 3c63369..3b107cd 100644 (file)
@@ -26,7 +26,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  */
 /*
@@ -50,6 +50,7 @@
 #include <unistd.h>
 #include <time.h>
 #include <errno.h>
+#include <libcfs/libcfs.h>
 #include <lustre/lustre_user.h>
 #include "lp_utils.h"
 
@@ -105,15 +106,15 @@ read_buf(int fd)
         rc = read(fd, buf, sizeof(buf));
         if (rc == -1) {
                 pos = lseek(fd, 0, SEEK_CUR);
-                sprintf(errmsg, "read of file %s at pos %d for %lu bytes "
+                sprintf(errmsg, "read of file %s at pos %d for %zu bytes "
                         "returned %d: (%d) %s.\n",
-                        filename, pos, (unsigned long)sizeof(buf), rc, errno, strerror(errno));
+                        filename, pos, sizeof(buf), rc, errno, strerror(errno));
                 FAIL(errmsg);
         } else if (rc != sizeof(buf)) {
                 pos = lseek(fd, 0, SEEK_CUR);
-                sprintf(errmsg, "read of file %s at pos %d for %lu bytes "
+                sprintf(errmsg, "read of file %s at pos %d for %zu bytes "
                         "returned %d.\n",
-                        filename, pos, (unsigned long) sizeof(buf), rc);
+                        filename, pos, sizeof(buf), rc);
                 FAIL(errmsg);
         }
 }
@@ -128,14 +129,14 @@ write_buf(int fd, int index)
         lseek(fd, pos, SEEK_SET);
         rc = write(fd, buf, sizeof(buf));
         if (rc == -1) {
-                sprintf(errmsg, "write of file %s at pos %d for %lu bytes "
+                sprintf(errmsg, "write of file %s at pos %d for %zu bytes "
                         "returned %d: (%d) %s.\n",
-                        filename, pos, (unsigned long)sizeof(buf), rc, errno, strerror(errno));
+                        filename, pos, sizeof(buf), rc, errno, strerror(errno));
                 FAIL(errmsg);
         } else if (rc != sizeof(buf)) {
-                sprintf(errmsg, "write of file %s at pos %d for %lu bytes "
+                sprintf(errmsg, "write of file %s at pos %d for %zu bytes "
                         "returned %d.\n",
-                        filename, pos, (unsigned long)sizeof(buf), rc);
+                        filename, pos, sizeof(buf), rc);
                 FAIL(errmsg);
         }
 }
@@ -251,7 +252,7 @@ void grouplock_test1(char *filename, int fd, int blocking_op, int unlock_op)
                                 filename, errno, strerror(errno));
                         FAIL(errmsg);
                 }
-                
+
                 /* Wait for task1 to complete. */
                 iter = MAX_WAIT_TRIES;
                 do {
@@ -685,7 +686,7 @@ void grouplock_test4(char *filename, int fd)
         }
 }
 
-/* 
+/*
  * task0 attempts GR(gid=1) -- granted
  * task1 attempts PR on non-blocking fd -> should return -EWOULDBLOCK
  * task2 attempts PW on non-blocking fd -> should return -EWOULDBLOCK
@@ -796,7 +797,7 @@ void grouplock_errorstest(char *filename, int fd)
                                         "with errno %d instead of EINVAL\n",
                                         errno);
                                 FAIL(errmsg);
-                        } 
+                        }
                 } else {
                         FAIL("Taking second GROUP lock on same fd succeed\n");
                 }
@@ -808,7 +809,7 @@ void grouplock_errorstest(char *filename, int fd)
                                         "different gid failed with errno %d "
                                         "instead of EINVAL\n", errno);
                                 FAIL(errmsg);
-                        } 
+                        }
                 } else {
                         FAIL("Taking second GROUP lock on same fd, with "
                              "different gid, succeeded.\n");
@@ -821,7 +822,7 @@ void grouplock_errorstest(char *filename, int fd)
                                         "failed with errno %d instead of "
                                         "EINVAL\n", errno);
                                 FAIL(errmsg);
-                        } 
+                        }
                 } else {
                         FAIL("GROUP unlock with wrong gid succeed\n");
                 }
@@ -841,7 +842,7 @@ void grouplock_errorstest(char *filename, int fd)
                                         "fd failed with errno %d instead of "
                                         "EINVAL.\n", errno);
                                 FAIL(errmsg);
-                        } 
+                        }
                 } else {
                         FAIL("GROUP unlock on never locked fd succeed\n");
                 }
@@ -959,8 +960,7 @@ void usage(char *proc)
 
 int main(int argc, char *argv[])
 {
-        char c;
-        int i, iterations = 1;
+        int i, iterations = 1, c;
 
         setbuf(stdout, 0);
         setbuf(stderr, 0);
@@ -1013,7 +1013,8 @@ int main(int argc, char *argv[])
 
         if (size < MIN_GLHOST) {
                 fprintf(stderr, "Error: "
-                        "should be at least four tasks to run the test!\n");
+                        "%d tasks run, but should be at least %d tasks to run "
+                        "the test!\n", size, MIN_GLHOST);
                 MPI_Abort(MPI_COMM_WORLD, 2);
         }