src/main.c | 4 ++++ src/paxos_lease.c | 3 ++- src/token_manager.c | 1 + tests/devcount.c | 18 ++++++++++++------ 4 files changed, 19 insertions(+), 7 deletions(-)
New commits: commit 1e29cebddbc04b22a8dd8ec2b53b74521afbea44 Author: David Teigland teigland@redhat.com Date: Tue Apr 5 15:02:07 2011 -0500
sanlock: fix release and inquire
sanlock_release was missing some cleanup, which caused subsequent acquire to fail
sanlock_inquire was always giving 0 as current lver
diff --git a/src/main.c b/src/main.c index 4ab96ed..7038ce7 100644 --- a/src/main.c +++ b/src/main.c @@ -848,6 +848,8 @@ static void *cmd_release_thread(void *args_in) rv = release_token(token); if (rv < 0) result = -1; + close_disks(token->disks, token->r.num_disks); + del_resource(token); free(token); cl->tokens[j] = NULL; } @@ -879,6 +881,8 @@ static void *cmd_release_thread(void *args_in) rv = release_token(token); if (rv < 0) result = -1; + close_disks(token->disks, token->r.num_disks); + del_resource(token); free(token); cl->tokens[j] = NULL; found = 1; diff --git a/src/paxos_lease.c b/src/paxos_lease.c index c9c07cd..bd06d1f 100644 --- a/src/paxos_lease.c +++ b/src/paxos_lease.c @@ -608,7 +608,8 @@ int paxos_lease_acquire(struct token *token, int force, uint64_t last_timestamp = 0; int error;
- log_token(token, "paxos_acquire begin force %d", force); + log_token(token, "paxos_acquire begin lver %llu force %d", + (unsigned long long)acquire_lver, force);
error = paxos_lease_leader_read(token, &prev_leader); if (error < 0) diff --git a/src/token_manager.c b/src/token_manager.c index 2c88560..547d20d 100644 --- a/src/token_manager.c +++ b/src/token_manager.c @@ -137,6 +137,7 @@ int acquire_token(struct token *token, uint64_t acquire_lver, return rv;
memcpy(&token->leader, &leader_ret, sizeof(struct leader_record)); + token->r.lver = token->leader.lver; return rv; /* DP_OK */ }
diff --git a/tests/devcount.c b/tests/devcount.c index 1ddbd84..df538ac 100644 --- a/tests/devcount.c +++ b/tests/devcount.c @@ -1,5 +1,6 @@ #define _GNU_SOURCE #include <sys/types.h> +#include <sys/wait.h> #include <sys/un.h> #include <sys/mount.h> #include <inttypes.h> @@ -409,11 +410,10 @@ static int do_relock(int argc, char *argv[]) */
j = 0; - memset(av, 0, sizeof(char *) * COUNT_ARGS+1); - av[j++] = strdup(argv[0]); for (i = 3; i < LOCK_ARGS; i++) av[j++] = strdup(argv[i]); + av[j] = NULL;
while (1) { pid = fork(); @@ -478,6 +478,10 @@ static int do_relock(int argc, char *argv[]) goto fail; } lver = res_inq->lver; + + printf("%d sanlock_inquire %llu done\n", parent_pid, + (unsigned long long)lver); + free(res_inq); free(state);
@@ -489,6 +493,8 @@ static int do_relock(int argc, char *argv[]) goto fail; }
+ printf("%d sanlock_release done\n", parent_pid); + /* give a chance to someone else to acquire the lock in here */ usleep(1000000);
@@ -518,6 +524,7 @@ static int do_relock(int argc, char *argv[]) fail: printf("test failed...\n"); sleep(1000000); + return -1; }
/* @@ -579,11 +586,10 @@ static int do_lock(int argc, char *argv[]) */
j = 0; - memset(av, 0, sizeof(char *) * COUNT_ARGS+1); - av[j++] = strdup(argv[0]); for (i = 3; i < LOCK_ARGS; i++) av[j++] = strdup(argv[i]); + av[j] = NULL;
while (1) { pid = fork(); @@ -622,9 +628,9 @@ static int do_lock(int argc, char *argv[]) sleep(rand_int(0, 1)); }
- fail: printf("test failed...\n"); sleep(1000000); + return -1; }
#if 0 @@ -1017,7 +1023,6 @@ static int do_migrate(int argc, char *argv[]) int do_init(int argc, char *argv[]) { char command[4096]; - char *colon;
if (argc < 4) return -1; @@ -1058,6 +1063,7 @@ int do_init(int argc, char *argv[]) printf("%s\n", command);
system(command); + return 0; }
int main(int argc, char *argv[])
sanlock-devel@lists.fedorahosted.org