Whamcloud - gitweb
LU-5710 all: second batch of corrected typos and grammar errors
[fs/lustre-release.git] / lustre / tests / multiop.c
index c1c44bc..e42aeaa 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, 2013, Intel Corporation.
+ * Copyright (c) 2012, 2014, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -46,6 +46,7 @@
 #include <sys/mman.h>
 #include <sys/vfs.h>
 #include <sys/ioctl.h>
+#include <sys/xattr.h>
 #include <signal.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -63,10 +64,13 @@ char *buf, *buf_align;
 int bufsize = 0;
 sem_t sem;
 #define ALIGN_LEN 65535
+#define XATTR "user.multiop"
 
 char usage[] =
 "Usage: %s filename command-sequence [path...]\n"
 "    command-sequence items:\n"
+"       A  fsetxattr(\"user.multiop\")\n"
+"       a  fgetxattr(\"user.multiop\")\n"
 "       c  close\n"
 "       B[num] call setstripe ioctl to create stripes\n"
 "       C[num] create with optional stripes\n"
@@ -150,6 +154,9 @@ struct flag_mapping {
 #ifdef O_DIRECT
        {"O_DIRECT", O_DIRECT},
 #endif
+#ifdef O_NOATIME
+       {"O_NOATIME", O_NOATIME},
+#endif
        {"O_LARGEFILE", O_LARGEFILE},
        {"O_DIRECTORY", O_DIRECTORY},
        {"O_NOFOLLOW", O_NOFOLLOW},
@@ -244,6 +251,20 @@ int main(int argc, char **argv)
                        ts.tv_nsec = 0;
                         while (sem_timedwait(&sem, &ts) < 0 && errno == EINTR);
                         break;
+               case 'A':
+                       if (fsetxattr(fd, XATTR, "multiop", 8, 0)) {
+                               save_errno = errno;
+                               perror("fsetxattr");
+                               exit(save_errno);
+                       }
+                       break;
+               case 'a':
+                       if (fgetxattr(fd, XATTR, NULL, 0) == -1) {
+                               save_errno = errno;
+                               perror("fgetxattr");
+                               exit(save_errno);
+                       }
+                       break;
                 case 'c':
                         if (close(fd) == -1) {
                                 save_errno = errno;
@@ -293,13 +314,13 @@ int main(int argc, char **argv)
                        commands++;
                        switch (*commands) {
                        case 'U':
-                               flags = F_UNLCK;
+                               flags = LL_LEASE_UNLCK;
                                break;
                        case 'R':
-                               flags = F_RDLCK;
+                               flags = LL_LEASE_RDLCK;
                                break;
                        case 'W':
-                               flags = F_WRLCK;
+                               flags = LL_LEASE_WRLCK;
                                break;
                        default:
                                errx(-1, "unknown mode: %c", *commands);
@@ -309,16 +330,16 @@ int main(int argc, char **argv)
                        if (rc < 0)
                                err(errno, "apply lease error");
 
-                       if (flags != F_UNLCK)
+                       if (flags != LL_LEASE_UNLCK)
                                break;
 
                        /* F_UNLCK, interpret return code */
                        if (rc > 0) {
-                               const char *str = "Unknown";
-                               if (rc == FMODE_READ)
-                                       str = "FMODE_READ";
-                               else if (rc == FMODE_WRITE)
-                                       str = "FMODE_WRITE";
+                               const char *str = "unknown";
+                               if (rc == LL_LEASE_RDLCK)
+                                       str = "read";
+                               else if (rc == LL_LEASE_WRLCK)
+                                       str = "write";
                                fprintf(stdout, "%s lease(%d) released.\n",
                                        str, rc);
                        } else if (rc == 0) {
@@ -332,12 +353,12 @@ int main(int argc, char **argv)
 
                        rc = ioctl(fd, LL_IOC_GET_LEASE);
                        if (rc > 0) {
-                               const char *str = "Unknown";
+                               const char *str = "unknown";
 
-                               if (rc == FMODE_READ)
-                                       str = "FMODE_READ";
-                               else if (rc == FMODE_WRITE)
-                                       str = "FMODE_WRITE";
+                               if (rc == LL_LEASE_RDLCK)
+                                       str = "read";
+                               else if (rc == LL_LEASE_WRLCK)
+                                       str = "write";
                                fprintf(stdout, "%s lease(%d) has applied.\n",
                                        str, rc);
                                if (*commands == '-')
@@ -632,11 +653,12 @@ int main(int argc, char **argv)
                         }
                         break;
                 case 'Y':
-                        if (fdatasync(fd) == -1) {
-                                save_errno = errno;
-                                perror("fdatasync");
-                                exit(save_errno);
-                        }
+                       if (fdatasync(fd) == -1) {
+                               save_errno = errno;
+                               perror("fdatasync");
+                               exit(save_errno);
+                       }
+                       break;
                 case 'z':
                         len = atoi(commands+1);
                         if (lseek(fd, len, SEEK_SET) == -1) {