/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=8:tabstop=8:
*
- * Copyright (C) 2002 Cluster File Systems, Inc.
- * Author: You Feng <youfeng@clusterfs.com>
+ * GPL HEADER START
*
- * This file is part of Lustre, http://www.lustre.org.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
- * Lustre 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 free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
*
- * Lustre 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.
+ * 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 version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
*
- * You should have received a copy of the GNU General Public License
- * along with Lustre; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved
+ * Use is subject to license terms.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ *
+ * lustre/tests/parallel_grouplock.c
+ *
+ * Author: You Feng <youfeng@clusterfs.com>
*/
#include <mpi.h>
#include <unistd.h>
#include <time.h>
#include <errno.h>
+#include <liblustre.h>
#include <lustre/lustre_user.h>
-#include "lp_utils.h"
+#include <lustre/tests/lp_utils.h>
#define LPGL_FILEN 700000
#define LPGL_TEST_ITEMS 7
if (rank == 0) {
int iter = MAX_WAITING_TIME;
int flag1, flag2;
-
+
/* reading task will tell us when it completes */
MPI_Irecv(&temp1, 1, MPI_INT, 1, 1, MPI_COMM_WORLD, &req1);
/* 2nd locking task will tell us when it completes */
if (rank == 0) {
int iter = MAX_WAITING_TIME;
int flag1;
-
+
do {
iter--;
if (!iter) {
if (rank == 0) {
int iter = MAX_WAITING_TIME;
int flag1, flag2, flag3;
-
+
/* 2nd locking task will tell us when it completes */
MPI_Irecv(&temp1, 1, MPI_INT, 1, 1, MPI_COMM_WORLD, &req1);
/* 3nd locking task will tell us when it completes */
if (rank == 0) {
int iter = MAX_WAITING_TIME;
int flag3;
-
+
do {
iter--;
if (!iter) {
if (rank == 0) {
int iter = MAX_WAITING_TIME;
int flag1, flag2;
-
+
/* reading task will tell us when it completes */
MPI_Irecv(&temp1, 1, MPI_INT, 1, 1, MPI_COMM_WORLD, &req1);
/* 2nd locking task will tell us when it completes */
if (rank == 0) {
int iter = MAX_WAITING_TIME;
int flag1;
-
+
do {
iter--;
usleep(100);
filename, rc);
FAIL(errmsg);
}
-
+
do {
iter--;
if (!iter) {
}
-/*
+/*
* process1 attempts CW(gid=1) -- granted
* process2 attempts PR on non-blocking fd -> should return -EWOULDBLOCK
* process3 attempts CW(gid=2) on non-blocking fd -> should return -EWOULDBLOCK
int flag1, flag2;
MPI_Request req1, req2;
int temp1, temp2;
-
+
/* reading task will tell us when it completes */
MPI_Irecv(&temp1, 1, MPI_INT, 1, 1, MPI_COMM_WORLD, &req1);
/* 2nd locking task will tell us when it completes */
*/
void grouplock_test5(char *filename, int fd, char *errmsg)
{
- int rc, count, gid = 1;
- char buf[LPGL_FILEN];
- char zeros[LPGL_FILEN];
+ int rc, gid = 1;
MPI_Request req1, req2;
int temp1, temp2;
if (rank == 0) {
int iter = MAX_WAITING_TIME;
int flag1, flag2;
-
+
/* 3rd locking task will tell us when it completes */
MPI_Irecv(&temp1, 1, MPI_INT, 1, 1, MPI_COMM_WORLD, &req1);
/* 2nd locking task will tell us when it completes */
filename, rc);
FAIL(errmsg);
}
-
+
do {
iter--;
if (!iter) {
/* To not do lots of separate tests with lots of fd opening/closing,
different parts of this test are performed in different processes */
-
+
if (rank == 0 || rank == 1 ) {
if ((rc = ioctl(fd, LL_IOC_GROUP_LOCK, gid)) == -1) {
sprintf(errmsg, "ioctl GROUP_LOCK of file %s return %d",
if (errno != EINVAL) {
sprintf(errmsg, "Double GROUP lock failed with errno %d instead of EINVAL\n", errno);
FAIL(errmsg);
- }
+ }
} else {
FAIL("Taking second GROUP lock on same fd succeed\n");
}
if (errno != EINVAL) {
sprintf(errmsg, "Double GROUP lock different gid failed with errno %d instead of EINVAL\n", errno);
FAIL(errmsg);
- }
+ }
} else {
FAIL("Taking second GROUP lock on same fd, different gid, succeed\n");
}
sprintf(errmsg, "GROUP unlock with wrong gid failed with errno %d instead of EINVAL\n",
errno);
FAIL(errmsg);
- }
+ }
} else {
FAIL("GROUP unlock with wrong gid succeed\n");
}
sprintf(errmsg, "GROUP unlock on never locked fd failed with errno %d instead of EINVAL\n",
errno);
FAIL(errmsg);
- }
+ }
} else {
FAIL("GROUP unlock on never locked fd succeed\n");
}
void grouplock_file(char *name, int items)
{
- int i, fd;
+ int fd;
char filename[MAX_FILENAME_LEN];
char errmsg[MAX_FILENAME_LEN+20];
{
char c;
int i, iterations = 1;
- int tr = 1;
/* Check for -h parameter before MPI_Init so the binary can be
called directly, without, for instance, mpirun */
}
if (testdir == NULL && rank == 0) {
- fprintf(stderr, "Please specify a test directory! (\"%s -h\" for help)\n",
- argv[0]);
+ fprintf(stderr, "Please specify a test directory! "
+ "(\"%s -h\" for help)\n", argv[0]);
MPI_Abort(MPI_COMM_WORLD, 2);
}