From: teigland@sourceware.org <teigland@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] cluster/dlm/tests/usertest dlmtest2.c
Date: 4 Jan 2007 20:34:19 -0000 [thread overview]
Message-ID: <20070104203419.12353.qmail@sourceware.org> (raw)
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: teigland at sourceware.org 2007-01-04 20:34:19
Modified files:
dlm/tests/usertest: dlmtest2.c
Log message:
added "flood n mode" function a while ago, doesn't equate to pjc's
"flood" program even though that's what I was originally hoping to
emulate
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tests/usertest/dlmtest2.c.diff?cvsroot=cluster&r1=1.3&r2=1.4
--- cluster/dlm/tests/usertest/dlmtest2.c 2006/12/12 21:17:56 1.3
+++ cluster/dlm/tests/usertest/dlmtest2.c 2007/01/04 20:34:18 1.4
@@ -219,6 +219,69 @@
}
}
+void astfn_flood_unlock(void *arg)
+{
+ struct lk *lk = arg;
+ int i = lk->id, unlock = 0, rv;
+
+ if (!lk->wait_ast) {
+ printf("lk %d not waiting for ast\n", lk->id);
+ exit(-1);
+ }
+
+ lk->wait_ast = 0;
+
+ if (lk->lksb.sb_status == EUNLOCK) {
+ memset(&lk->lksb, 0, sizeof(struct dlm_lksb));
+ lk->grmode = -1;
+ lk->rqmode = -1;
+ unlock = 1;
+ locks_flood_ast_done++;
+ } else if (lk->lksb.sb_status == EAGAIN) {
+ if (lk->grmode == -1)
+ memset(&lk->lksb, 0, sizeof(struct dlm_lksb));
+ lk->rqmode = -1;
+ } else {
+ if (lk->lksb.sb_status != 0) {
+ printf("lk %d unknown sb_status %d\n", lk->id,
+ lk->lksb.sb_status);
+ exit(-1);
+ }
+
+ /* lock completed, now unlock it immediately */
+
+ lk->grmode = lk->rqmode;
+ lk->rqmode = -1;
+
+ rv = dlm_ls_unlock(dh, lk->lksb.sb_lkid, 0, &lk->lksb,
+ (void *)lk);
+ if (!rv) {
+ lk->wait_ast = 1;
+ lk->rqmode = -1;
+ } else {
+ char input[32];
+ printf("astfn_flood_unlock: dlm_ls_unlock: %d rv %d "
+ "errno %d\n", i, rv, errno);
+ printf("press X to exit, D to dispatch, "
+ "other to continue\n");
+ fgets(input, 32, stdin);
+ if (input[0] == 'X')
+ exit(-1);
+ else if (input[0] == 'D')
+ dlm_dispatch(libdlm_fd);
+ }
+ }
+
+ if (locks_flood_ast_done == locks_flood_n) {
+ printf("astfn_flood_unlock all %d unlocked\n", locks_flood_n);
+ if (unlock) {
+ free(locks_flood);
+ locks_flood = NULL;
+ locks_flood_n = 0;
+ }
+ }
+}
+
void process_libdlm(void)
{
dlm_dispatch(libdlm_fd);
@@ -453,6 +516,44 @@
}
}
+void flood(int n, int mode)
+{
+ struct lk *lk;
+ char name[DLM_RESNAME_MAXLEN];
+ int flags = 0, rv, i;
+
+ if (noqueue)
+ flags |= LKF_NOQUEUE;
+
+ if (locks_flood) {
+ printf("unlock_flood required first\n");
+ return;
+ }
+
+ locks_flood = malloc(n * sizeof(struct lk));
+ if (!locks_flood) {
+ printf("no mem for %d locks\n", n);
+ return;
+ }
+ locks_flood_n = n;
+ locks_flood_ast_done = 0;
+ memset(locks_flood, 0, sizeof(*locks_flood));
+
+ for (i = 0; i < n; i++) {
+ memset(name, 0, sizeof(name));
+ snprintf(name, sizeof(name), "testflood%d", i);
+ lk = &locks_flood[i];
+
+ rv = dlm_ls_lock(dh, mode, &lk->lksb, flags,
+ name, strlen(name), 0, astfn_flood_unlock, (void *) lk,
+ bastfn_flood, NULL);
+ if (!rv) {
+ lk->wait_ast = 1;
+ lk->rqmode = mode;
+ }
+ }
+}
+
void loop(int i, int num)
{
int n;
@@ -598,6 +699,11 @@
return;
}
+ if (!strncmp(cmd, "flood", 5)) {
+ flood(x, y);
+ return;
+ }
+
if (!strncmp(cmd, "hold", 4)) {
lock_all(LKM_PRMODE);
return;
@@ -650,6 +756,7 @@
printf("unlock_flood-kill - unlock all from lock_flood and exit\n");
printf("ex x - equivalent to: lock x 5\n");
printf("pr x - equivalent to: lock x 3\n");
+ printf("flood n mode - request n locks, unlock each as it completes\n");
printf("hold - for x in 0 to MAX, lock x 3\n");
printf("release - for x in 0 to MAX, unlock x\n");
printf("dump - show info for all resources\n");
next reply other threads:[~2007-01-04 20:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-04 20:34 teigland [this message]
-- strict thread matches above, loose matches on Subject: below --
2008-02-21 17:49 [Cluster-devel] cluster/dlm/tests/usertest dlmtest2.c teigland
2008-01-17 21:49 teigland
2007-08-23 19:13 teigland
2007-08-22 14:01 teigland
2007-05-30 19:31 teigland
2007-04-27 19:09 teigland
2007-03-27 19:04 teigland
2007-02-27 18:55 teigland
2006-12-12 21:17 teigland
2006-12-08 19:25 teigland
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070104203419.12353.qmail@sourceware.org \
--to=teigland@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.