Whamcloud - gitweb
LU-13019 tests: replace usleep in test scripts
[fs/lustre-release.git] / lustre / tests / sendfile_grouplock.c
index 42d66a3..c293fd6 100644 (file)
@@ -22,6 +22,9 @@
 
 /*
  * Copyright 2015 Cray Inc, all rights reserved.
+ *
+ * Copyright (c) 2017, Intel Corporation.
+ *
  * Author: Frank Zago.
  *
  * A few portions are extracted from llapi_layout_test.c
 #include <fcntl.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <time.h>
 #include <unistd.h>
 #include <poll.h>
 #include <sys/sendfile.h>
 
 #include <lustre/lustreapi.h>
-#include <lustre/lustre_idl.h>
 
 #define ERROR(fmt, ...)                                                        \
        fprintf(stderr, "%s: %s:%d: %s: " fmt "\n",                     \
@@ -226,7 +229,7 @@ static int sendfile_copy(const char *source, int source_gid,
                        source_gid, source, strerror(-rc));
        }
 
-       fd_out = open(dest, O_WRONLY | O_TRUNC | O_CREAT);
+       fd_out = open(dest, O_WRONLY | O_TRUNC | O_CREAT, 0644);
        ASSERTF(fd_out >= 0, "creation failed for '%s': %s",
                dest, strerror(errno));
 
@@ -266,6 +269,17 @@ static int sendfile_copy(const char *source, int source_gid,
 
        }
 
+       if (dest_gid != 0) {
+               rc = llapi_group_unlock(fd_out, dest_gid);
+               ASSERTF(rc == 0, "cannot clear group lock %d for '%s': %s",
+                       dest_gid, dest, strerror(-rc));
+       }
+       if (source_gid != 0) {
+               rc = llapi_group_unlock(fd_in, source_gid);
+               ASSERTF(rc == 0, "cannot clear group lock %d for '%s': %s",
+                       source_gid, source, strerror(-rc));
+       }
+
        close(fd_out);
        close(fd_in);