Whamcloud - gitweb
LU-1187 mdt: enqueue rename lock locally for phase I.
[fs/lustre-release.git] / lustre / tests / multiop.c
old mode 100755 (executable)
new mode 100644 (file)
index 7e0dbfe..ab360c4
@@ -1,6 +1,4 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
  * GPL HEADER START
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -28,6 +26,8 @@
 /*
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2012, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
 #include <sys/stat.h>
 #include <sys/mman.h>
 #include <sys/vfs.h>
+#include <sys/ioctl.h>
 #include <signal.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <semaphore.h>
-#include <libcfs/libcfs.h>
-#include <lustre/liblustreapi.h>
+#include <time.h>
+
+#include <lustre/lustreapi.h>
 
 #define T1 "write data before unlink\n"
 #define T2 "write data after unlink\n"
@@ -197,6 +199,7 @@ int main(int argc, char **argv)
         int save_errno;
         int verbose = 0;
         int gid = 0;
+       struct timespec ts;
 
         if (argc < 3) {
                 fprintf(stderr, usage, argv[0]);
@@ -218,7 +221,12 @@ int main(int argc, char **argv)
                                 printf("PAUSING\n");
                                 fflush(stdout);
                         }
-                        while (sem_wait(&sem) == -1 && errno == EINTR);
+                       len = atoi(commands+1);
+                       if (len <= 0)
+                               len = 3600; /* 1 hour */
+                       ts.tv_sec = time(NULL) + len;
+                       ts.tv_nsec = 0;
+                        while (sem_timedwait(&sem, &ts) < 0 && errno == EINTR);
                         break;
                 case 'c':
                         if (close(fd) == -1) {
@@ -371,9 +379,12 @@ int main(int argc, char **argv)
                                         perror("read");
                                         exit(save_errno);
                                 }
-                                if (rc < len)
-                                        fprintf(stderr, "short read: %u/%u\n",
-                                                rc, len);
+                               if (rc < len) {
+                                       fprintf(stderr, "short read: %u/%u\n",
+                                               rc, len);
+                                       if (rc == 0)
+                                               exit(ENODATA);
+                               }
                                 len -= rc;
                                 if (verbose >= 2)
                                         printf("%.*s\n", rc, buf_align);