summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2012-08-29 10:56:19 -0500
committerDavid Teigland <teigland@redhat.com>2012-08-29 10:56:19 -0500
commitc5e56956ea89a06644f17c24eb105e4273294c89 (patch)
tree32a7d0b4736bcf44e4953219847cd5b5449ab7cf
parentdb307d7727b9e218862ca27a56d7629f72fc237c (diff)
downloaddct-stuff-c5e56956ea89a06644f17c24eb105e4273294c89.tar.gz
dct-stuff-c5e56956ea89a06644f17c24eb105e4273294c89.tar.xz
dct-stuff-c5e56956ea89a06644f17c24eb105e4273294c89.zip
dlm_seq: update
Signed-off-by: David Teigland <teigland@redhat.com>
-rw-r--r--dlm/dlm_seq.c176
1 files changed, 166 insertions, 10 deletions
diff --git a/dlm/dlm_seq.c b/dlm/dlm_seq.c
index 005e8ae..7d27631 100644
--- a/dlm/dlm_seq.c
+++ b/dlm/dlm_seq.c
@@ -43,11 +43,17 @@ static int quiet = 0;
static int verbose = 0;
static int opt_convert = 0;
static int opt_unlock = 0;
+static int opt_async = 0;
+static int opt_delay = 0;
+static int opt_same = 0;
static unsigned int num_r = DEFAULT_NUM_R;
static unsigned int num_lpr = DEFAULT_NUM_LPR;
static unsigned int num_iter = 1;
static unsigned int iter = 0;
static uint32_t *lkids;
+static struct dlm_lksb lksb;
+static unsigned int cb_count;
+static int libdlm_fd;
#define log_debug(fmt, args...) \
do { \
@@ -78,10 +84,10 @@ static uint64_t dt_usec(struct timeval *start, struct timeval *stop)
static void do_seq(int acquire, int convert, int unlock)
{
- struct dlm_lksb lksb;
char name[DLM_RESNAME_MAXLEN];
struct timeval last, start, now;
uint32_t r_count = 0;
+ uint32_t x = 0;
uint32_t lkid;
int i, j, rv;
@@ -89,7 +95,10 @@ static void do_seq(int acquire, int convert, int unlock)
start = last;
for (i = 0; i < num_r; i++) {
- snprintf(name, sizeof(name), "seq.%08u.%08d", iter, i);
+ if (!opt_same)
+ x = iter;
+
+ snprintf(name, sizeof(name), "seq.%08u.%08d", x, i);
for (j = 0; j < num_lpr; j++) {
memset(&lksb, 0, sizeof(lksb));
@@ -154,6 +163,122 @@ static void do_seq(int acquire, int convert, int unlock)
unlock ? " unlock" : "");
}
+static void astfn(void *arg)
+{
+ int status = lksb.sb_status;
+
+ cb_count++;
+
+ if (!status)
+ return;
+ if (status == EUNLOCK)
+ return;
+
+ printf("astfn status %d count %u\n", status, cb_count);
+}
+
+static void do_seq_async(int acquire, int convert, int unlock)
+{
+ char name[DLM_RESNAME_MAXLEN];
+ struct timeval last, start, now;
+ uint32_t r_count = 0;
+ uint32_t x = 0;
+ uint32_t lkid;
+ int i, j, rv;
+
+ gettimeofday(&last, NULL);
+ start = last;
+
+ for (i = 0; i < num_r; i++) {
+ if (!opt_same)
+ x = iter;
+
+ snprintf(name, sizeof(name), "seq.%08u.%08d", x, i);
+
+ for (j = 0; j < num_lpr; j++) {
+ memset(&lksb, 0, sizeof(lksb));
+
+ if (acquire) {
+ rv = dlm_ls_lockx(dh, LKM_PRMODE, &lksb, 0,
+ name, strlen(name), 0,
+ astfn, &lksb, NULL,
+ NULL, NULL);
+ }
+ if (convert) {
+ lksb.sb_lkid = lkids[(i * num_lpr) + j];
+
+ rv = dlm_ls_lockx(dh, LKM_NLMODE, &lksb, LKF_CONVERT,
+ name, strlen(name), 0,
+ astfn, &lksb, NULL,
+ NULL, NULL);
+ }
+ if (unlock) {
+ lkid = lkids[(i * num_lpr) + j];
+
+ rv = dlm_ls_unlock(dh, lkid, 0, &lksb, &lksb);
+ }
+
+ if (rv) {
+ log_error("dlm op %d %d %d %d,%d error %d",
+ acquire, convert, unlock, i, j, rv);
+ return;
+ }
+
+ if (acquire && lkids)
+ lkids[(i * num_lpr) + j] = lksb.sb_lkid;
+ }
+ r_count++;
+
+ if (quiet)
+ continue;
+
+ if (verbose || !(r_count % 1000)) {
+ gettimeofday(&now, NULL);
+
+ printf("i %08u r %08u: %08llu %08llu us%s%s\n",
+ iter, r_count,
+ (unsigned long long)dt_usec(&last, &now),
+ (unsigned long long)dt_usec(&start, &now),
+ convert ? " convert" : "",
+ unlock ? " unlock" : "");
+
+ last = now;
+ }
+ }
+
+ cb_count = 0;
+
+ while (1) {
+ rv = dlm_dispatch(libdlm_fd);
+ if (rv < 0) {
+ printf("dlm_dispatch error %d %d\n", rv, errno);
+ }
+
+ if (cb_count == (num_r * num_lpr))
+ break;
+ }
+
+ if (verbose || !(r_count % 1000))
+ return;
+
+ gettimeofday(&now, NULL);
+
+ printf("i %08u r %08u: %08llu %08llu us%s\n",
+ iter, r_count,
+ (unsigned long long)dt_usec(&last, &now),
+ (unsigned long long)dt_usec(&start, &now),
+ convert ? " convert" : "",
+ unlock ? " unlock" : "");
+}
+
+static void seq(int acquire, int convert, int unlock)
+{
+ if (opt_async)
+ do_seq_async(acquire, convert, unlock);
+ else
+ do_seq(acquire, convert, unlock);
+}
+
static void print_usage(void)
{
printf("dlm_seq [options]\n");
@@ -164,6 +289,9 @@ static void print_usage(void)
printf(" -l <n> The number of locks per resource, default %d\n", DEFAULT_NUM_LPR);
printf(" -c Convert locks after acquiring them all\n");
printf(" -u Unlock locks after acquire/convert\n");
+ printf(" -a Async submission\n");
+ printf(" -s Same resource names in each iteration\n");
+ printf(" -d <us> Delay us between consecutive seq\n");
printf(" -o Open/close existing lockspace\n");
printf(" -v Verbose output\n");
printf(" -q Quiet output\n");
@@ -175,7 +303,7 @@ static void decode_arguments(int argc, char **argv)
int optchar;
while (cont) {
- optchar = getopt(argc, argv, "i:r:l:cuvqoh");
+ optchar = getopt(argc, argv, "i:r:l:cuvqohad:s");
switch (optchar) {
@@ -199,6 +327,18 @@ static void decode_arguments(int argc, char **argv)
opt_unlock = 1;
break;
+ case 'a':
+ opt_async = 1;
+ break;
+
+ case 's':
+ opt_same = 1;
+ break;
+
+ case 'd':
+ opt_delay = atoi(optarg);
+ break;
+
case 'o':
openclose = 1;
break;
@@ -267,10 +407,18 @@ int main(int argc, char *argv[])
}
}
- rv = dlm_ls_pthread_init(dh);
- if (rv < 0) {
- log_error("dlm_ls_pthread_init error %d %d", rv, errno);
- goto done;
+ if (opt_async) {
+ libdlm_fd = dlm_ls_get_fd(dh);
+ if (libdlm_fd < 0) {
+ log_error("dlm_ls_get fd error %d %d", libdlm_fd, errno);
+ goto done;
+ }
+ } else {
+ rv = dlm_ls_pthread_init(dh);
+ if (rv < 0) {
+ log_error("dlm_ls_pthread_init error %d %d", rv, errno);
+ goto done;
+ }
}
if (opt_convert || opt_unlock) {
@@ -282,14 +430,22 @@ int main(int argc, char *argv[])
}
while (1) {
- do_seq(1, 0, 0);
+ seq(1, 0, 0);
+
+ if (opt_delay)
+ usleep(opt_delay);
if (opt_convert)
- do_seq(0, 1, 0);
+ seq(0, 1, 0);
+
+ if (opt_delay)
+ usleep(opt_delay);
if (opt_unlock)
- do_seq(0, 0, 1);
+ seq(0, 0, 1);
+ if (opt_delay)
+ usleep(opt_delay);
iter++;
if (!num_iter)