src/token_manager.c | 19 ++++++++++++++++---
tests/devcount.c | 11 +++++++++--
2 files changed, 25 insertions(+), 5 deletions(-)
New commits:
commit 3db854c867ae53aa08f1d9c1476dc5a7c8cd991c
Author: David Teigland <teigland(a)redhat.com>
Date: Thu Mar 10 14:21:34 2011 -0600
sanlock: migrate to target fix
fix check when source gives target host_id to migrate
add another validation check for setowner incoming
have devcount also test specified migrate target
diff --git a/src/token_manager.c b/src/token_manager.c
index bc86b07..5b4ea53 100644
--- a/src/token_manager.c
+++ b/src/token_manager.c
@@ -364,7 +364,7 @@ static int check_incoming_state(struct token *token, char *opt_str,
leader_src.lver == leader_ret.lver &&
leader_src.timestamp == leader_ret.timestamp) {
log_token(token, "check_incoming_state all match");
- return DP_OK;
+ goto out_ok;
} else {
log_errot(token, "check_incoming_state mismatch "
"next_owner %llu %llu %llu "
@@ -399,6 +399,8 @@ static int check_incoming_state(struct token *token, char *opt_str,
return -1;
}
+ out_ok:
+ memcpy(&token->leader, &leader_ret, sizeof(struct leader_record));
return DP_OK;
}
@@ -495,7 +497,18 @@ static int setowner_token_incoming(struct token *token)
if (rv < 0)
return rv;
- if (token->leader.next_owner_id != leader.next_owner_id) {
+ /* the owner should be the same (the source) as when we last read
+ the leader in incoming_token */
+
+ if (token->leader.owner_id != leader.owner_id) {
+ log_errot(token, "setowner incoming bad owner %llu %llu",
+ (unsigned long long)token->leader.owner_id,
+ (unsigned long long)leader.owner_id);
+ return DP_ERROR;
+ }
+
+ if (token->leader.next_owner_id != leader.next_owner_id ||
+ token->host_id != leader.next_owner_id) {
log_errot(token, "setowner incoming bad next_owner %llu %llu",
(unsigned long long)token->leader.next_owner_id,
(unsigned long long)leader.next_owner_id);
@@ -529,7 +542,7 @@ int setowner_token(struct token *token)
{
int rv;
- log_token(token, "setowner incoming %d migrating %d",
+ log_token(token, "setowner migrating %d incoming %d",
token->migrating, token->incoming);
if (token->migrating) {
diff --git a/tests/devcount.c b/tests/devcount.c
index b83a49a..d60e4f9 100644
--- a/tests/devcount.c
+++ b/tests/devcount.c
@@ -659,7 +659,7 @@ static int do_migrate(int argc, char *argv[])
struct sanlk_lockspace lockspace;
struct sanlk_resource *res;
struct sanlk_options *opt;
- int i, j, pid, rv, sock, len, status, init;
+ int i, j, pid, rv, sock, len, status, init, target;
uint32_t parent_pid = getpid();
if (argc < MIGRATE_ARGS)
@@ -776,7 +776,14 @@ static int do_migrate(int argc, char *argv[])
sleep(10);
- rv = sanlock_migrate(-1, pid, 0, &state);
+ /* exercise both migrate options: giving target on host or not */
+
+ if (rand_int(1,3) == 1)
+ target = (our_hostid % max_hostid) + 1;
+ else
+ target = 0;
+
+ rv = sanlock_migrate(-1, pid, target, &state);
if (rv < 0 || !state) {
printf("%d sanlock_migrate error %d\n", parent_pid, rv);
goto fail;