summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2010-07-27 16:34:18 -0500
committerDavid Teigland <teigland@redhat.com>2010-07-27 16:34:18 -0500
commit44c98e33bf8fc14d744c7989a7257fc710e0867c (patch)
tree54fe8f469e959ff72f103e9d9d988fccb3bd3b91
parentecb30a00e3683f50076fd27a3058a46c833de3bf (diff)
downloaddct-stuff-44c98e33bf8fc14d744c7989a7257fc710e0867c.tar.gz
dct-stuff-44c98e33bf8fc14d744c7989a7257fc710e0867c.tar.xz
dct-stuff-44c98e33bf8fc14d744c7989a7257fc710e0867c.zip
lock_load: misc
Signed-off-by: David Teigland <teigland@redhat.com>
-rw-r--r--dlm/dlm_load.c12
-rw-r--r--fs/lock_load.c42
2 files changed, 42 insertions, 12 deletions
diff --git a/dlm/dlm_load.c b/dlm/dlm_load.c
index 30cf161..9a953fe 100644
--- a/dlm/dlm_load.c
+++ b/dlm/dlm_load.c
@@ -383,6 +383,18 @@ static void astfn(void *arg)
};
}
+/* FIXME: ran two dlm_load's on four nodes over the weekend, and one instance
+ of dlm_load hit:
+ lk 007 unlock
+ lk 007 cast 3000665 EUNLOCK 022c0912 wait r0 c0 u1 c0 gr 2 rq -1 last unlock
+ lk 007 request mode 2 noqueue 1
+ lk 007 cast 3000705 EAGAIN 00680909 wait r1 c0 u0 c0 gr -1 rq 2 last request
+ lk 007 request mode 0 noqueue 1
+ lk 007 cast 3000732 EAGAIN 017b090e wait r1 c0 u0 c0 gr -1 rq 0 last request
+ lk 007 request mode 6 noqueue 0
+ ERROR lk 007 request errno 22 wait r0 c0 u0 c0 lastop request
+*/
+
static int do_request(struct lk *lk, int mode, int noqueue)
{
char name[DLM_RESNAME_MAXLEN];
diff --git a/fs/lock_load.c b/fs/lock_load.c
index 79c449f..1997b7b 100644
--- a/fs/lock_load.c
+++ b/fs/lock_load.c
@@ -27,6 +27,7 @@
#include <sys/file.h>
#include <fcntl.h>
#include <unistd.h>
+#include <time.h>
#define die(fmt, args...) \
{ \
@@ -48,6 +49,7 @@ int our_pid;
char *prog_name;
int blocking;
int delay = 10; /* milliseconds */
+int quiet;
void read_flock(int fd)
{
@@ -93,7 +95,7 @@ void unlock_flock(int fd)
int do_plock(int fd, int offset, int len, int type)
{
struct flock lock;
- int action;
+ int action, error;
lock.l_type = type;
lock.l_start = offset;
@@ -105,7 +107,15 @@ int do_plock(int fd, int offset, int len, int type)
else
action = F_SETLK;
- return fcntl(fd, action, &lock);
+ error = fcntl(fd, action, &lock);
+
+ if (error < 0 && errno != EAGAIN) {
+ fprintf(stderr, "fcntl type %d action %d errno %d\n",
+ type, action, errno);
+ exit(-1);
+ }
+
+ return error;
}
int rand_int(int a, int b)
@@ -159,9 +169,10 @@ void loop_plock(void)
rv = do_plock(fd, offset, len, F_UNLCK);
gettimeofday(&t2, NULL);
- printf("%06d file%04d ino %04x U %02d-%02d pid %d err %02d sec %.6f\n",
- i, fdi, inodea[fdi], offset, offset+len-1, our_pid,
- rv ? errno : 0, 1.e-6 * dt_usec(&t1, &t2));
+ if (!quiet)
+ printf("%06d file%04d ino %04x U %02d-%02d pid %d err %02d sec %.6f\n",
+ i, fdi, inodea[fdi], offset, offset+len-1, our_pid,
+ rv ? errno : 0, 1.e-6 * dt_usec(&t1, &t2));
break;
case 1:
@@ -169,9 +180,10 @@ void loop_plock(void)
rv = do_plock(fd, offset, len, F_RDLCK);
gettimeofday(&t2, NULL);
- printf("%06d file%04d ino %04x R %02d-%02d pid %d err %02d sec %.6f\n",
- i, fdi, inodea[fdi], offset, offset+len-1, our_pid,
- rv ? errno : 0, 1.e-6 * dt_usec(&t1, &t2));
+ if (!quiet)
+ printf("%06d file%04d ino %04x R %02d-%02d pid %d err %02d sec %.6f\n",
+ i, fdi, inodea[fdi], offset, offset+len-1, our_pid,
+ rv ? errno : 0, 1.e-6 * dt_usec(&t1, &t2));
break;
case 2:
@@ -179,9 +191,10 @@ void loop_plock(void)
rv = do_plock(fd, offset, len, F_WRLCK);
gettimeofday(&t2, NULL);
- printf("%06d file%04d ino %04x W %02d-%02d pid %d err %02d sec %.6f\n",
- i, fdi, inodea[fdi], offset, offset+len-1, our_pid,
- rv ? errno : 0, 1.e-6 * dt_usec(&t1, &t2));
+ if (!quiet)
+ printf("%06d file%04d ino %04x W %02d-%02d pid %d err %02d sec %.6f\n",
+ i, fdi, inodea[fdi], offset, offset+len-1, our_pid,
+ rv ? errno : 0, 1.e-6 * dt_usec(&t1, &t2));
break;
}
@@ -217,6 +230,7 @@ int open_all_files(void)
fstat(fd, &st);
inodea[i] = (unsigned int)st.st_ino;
}
+ return 0;
}
void close_all_files(void)
@@ -238,6 +252,7 @@ void print_usage(void)
fprintf(stderr, " -d <ms> millisecond delay between each op (default 10)\n");
fprintf(stderr, " -b use blocking locks (default non-blocking)\n");
fprintf(stderr, " (warning: can easily deadlock)\n");
+ fprintf(stderr, " -q quiet output\n");
exit(EXIT_FAILURE);
}
@@ -255,7 +270,7 @@ int main(int argc, char *argv[])
delay = 10;
while (cont) {
- optchar = getopt(argc, argv, "cfpn:i:d:bh");
+ optchar = getopt(argc, argv, "cfpn:i:d:bhq");
switch (optchar) {
case 'c':
@@ -286,6 +301,9 @@ int main(int argc, char *argv[])
blocking = 1;
break;
+ case 'q':
+ quiet = 1;
+ break;
case EOF:
cont = 0;