From mboxrd@z Thu Jan 1 00:00:00 1970 From: teigland@sourceware.org Date: 22 Aug 2007 14:01:10 -0000 Subject: [Cluster-devel] cluster/dlm/tests/usertest dlmtest2.c Message-ID: <20070822140110.16687.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit CVSROOT: /cvs/cluster Module name: cluster Changes by: teigland at sourceware.org 2007-08-22 14:01:10 Modified files: dlm/tests/usertest: dlmtest2.c Log message: add new test for deadlocks Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tests/usertest/dlmtest2.c.diff?cvsroot=cluster&r1=1.8&r2=1.9 --- cluster/dlm/tests/usertest/dlmtest2.c 2007/05/30 19:31:28 1.8 +++ cluster/dlm/tests/usertest/dlmtest2.c 2007/08/22 14:01:09 1.9 @@ -732,6 +732,53 @@ printf("ast status: zero %d other %d\n", sts_zero, sts_other); } +void dstress(int num) +{ + int i, o, op, max_op, skip; + unsigned int n, skips, lock_ops, unlock_ops, unlockf_ops, cancel_ops; + struct lk *lk; + + n = skips = lock_ops = unlock_ops = unlockf_ops = cancel_ops = 0; + sts_eunlock = sts_ecancel = sts_etimedout = sts_edeadlk = sts_eagain = sts_other = sts_zero = 0; + bast_unlock = bast_skip = 0; + + noqueue = 0; + ignore_bast = 1; + quiet = 0; + + while (!stress_stop && n < num) { + + sleep(1); + + process_libdlm(); + + if (n && !(n % 60)) + unlock_all(); + + i = rand_int(0, maxn-1); + lk = get_lock(i); + if (!lk) + continue; + + if (lk->wait_ast || lk->grmode > -1) { + printf("%8x: lock %3d\t%x: skip gr %d wait_ast %d\n", + n, i, lk->lksb.sb_lkid, lk->grmode, lk->wait_ast); + continue; + } + + lock(i, rand_int(0, 5)); + lock_ops++; + printf("%8x: lock %3d\t%x\n", n, i, lk->lksb.sb_lkid); + } + + printf("ops: skip %d lock %d unlock %d unlockf %d cancel %d\n", + skips, lock_ops, unlock_ops, unlockf_ops, cancel_ops); + printf("bast: unlock %u skip %u\n", bast_unlock, bast_skip); + printf("ast status: eunlock %d ecancel %d etimedout %d edeadlk %d eagain %d\n", + sts_eunlock, sts_ecancel, sts_etimedout, sts_edeadlk, sts_eagain); + printf("ast status: zero %d other %d\n", sts_zero, sts_other); +} + void stress(int num) { int i, o, op, max_op, skip; @@ -913,6 +960,7 @@ printf("purge nodeid pid - purge orphan locks of process\n"); printf("stress n - loop doing random lock/unlock/unlockf/cancel on all locks, n times\n"); printf("tstress n - stress timeouts\n"); + printf("dstress n - stress deadlock\n"); printf("timeout n - enable lock timeouts, set timeout to n seconds\n"); printf("dump - show info for all locks\n"); printf("minhold - set minimum number of seconds locks will be held\n"); @@ -921,6 +969,7 @@ printf("persistent - toggle PERSISTENT flag for all requests\n"); printf("quiet - toggle quiet flag\n"); printf("verbose - toggle verbose flag\n"); + printf("settings - show settings\n"); printf("\ncombined operations\n"); printf("hold-kill - hold; kill\n"); @@ -950,6 +999,7 @@ printf("stress_stop %d\n", stress_stop); printf("stress_delay %d\n", stress_delay); printf("stress_lock_only %d\n", stress_lock_only); + printf("our_xid %x\n", (unsigned long long)our_xid); } void process_command(int *quit) @@ -1086,6 +1136,11 @@ return; } + if (!strncmp(cmd, "dstress", 7) && strlen(cmd) == 7) { + dstress(x); + return; + } + if (!strncmp(cmd, "stress_delay", 12) && strlen(cmd) == 12) { stress_delay = x; return; @@ -1097,12 +1152,25 @@ return; } + if (!strncmp(cmd, "stress_stop", 11) && strlen(cmd) == 11) { + stress_stop = !stress_stop; + printf("stress_stop is %d\n", stress_stop); + return; + } + if (!strncmp(cmd, "ignore_bast", 11) && strlen(cmd) == 11) { ignore_bast = !ignore_bast; printf("ignore_bast is %s\n", ignore_bast ? "on" : "off"); return; } + if (!strncmp(cmd, "our_xid", 7) && strlen(cmd) == 7) { + our_xid = x; + printf("our_xid is %llx\n", (unsigned long long)our_xid); + return; + } + + if (!strncmp(cmd, "purge", 5) && strlen(cmd) == 5) { purge(x, y); return;