src/client.c | 5 +++-- src/cmd.c | 17 +++++++++++++++++ src/resource.c | 13 +++++++++---- 3 files changed, 29 insertions(+), 6 deletions(-)
New commits: commit 315ab19e7756414fa8cc092b52d735d80def6f50 Author: David Teigland teigland@redhat.com Date: Fri Jan 15 14:43:42 2016 -0600
sanlock: improve lvb logging and error checks
set_lvb/get_lvb were not appearing in the debug log. improve check and error for bad lvb lengths.
diff --git a/src/client.c b/src/client.c index 8f8c096..3992250 100644 --- a/src/client.c +++ b/src/client.c @@ -1420,7 +1420,7 @@ int sanlock_set_lvb(uint32_t flags, struct sanlk_resource *res, char *lvb, int l
rv = send(fd, res, sizeof(struct sanlk_resource), 0); if (rv < 0) { - rv = -1; + rv = -errno; goto out; }
diff --git a/src/cmd.c b/src/cmd.c index 64f7f00..c2f05ba 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1116,6 +1116,15 @@ static void cmd_set_lvb(struct task *task GNUC_UNUSED, struct cmd_args *ca)
lvblen = ca->header.length - sizeof(struct sm_header) - sizeof(struct sanlk_resource);
+ /* 4096 is the max sector size we handle, it is compared + against the actual 512/4K sector size in res_set_lvb. */ + + if (lvblen > 4096) { + log_error("cmd_set_lvb %d,%d lvblen %d too big", ca->ci_in, fd, lvblen); + result = -E2BIG; + goto reply; + } + lvb = malloc(lvblen); if (!lvb) { result = -ENOMEM; @@ -1124,11 +1133,16 @@ static void cmd_set_lvb(struct task *task GNUC_UNUSED, struct cmd_args *ca)
rv = recv(fd, lvb, lvblen, MSG_WAITALL); if (rv != lvblen) { + log_error("cmd_set_lvb %d,%d recv lvblen %d lvb %d %d", + ca->ci_in, fd, lvblen, rv, errno); result = -ENOTCONN; goto reply; }
result = res_set_lvb(&res, lvb, lvblen); + + log_debug("cmd_set_lvb ci %d fd %d result %d res %s:%s", + ca->ci_in, fd, result, res.lockspace_name, res.name); reply: if (lvb) free(lvb); @@ -1157,6 +1171,9 @@ static void cmd_get_lvb(struct task *task GNUC_UNUSED, struct cmd_args *ca) lvblen = ca->header.data2;
result = res_get_lvb(&res, &lvb, &lvblen); + + log_debug("cmd_get_lvb ci %d fd %d result %d res %s:%s", + ca->ci_in, fd, result, res.lockspace_name, res.name); reply: memcpy(&h, &ca->header, sizeof(struct sm_header)); h.version = SM_PROTO;
commit ada1cb58097de4179656f3ea437ad56fc1afa497 Author: David Teigland teigland@redhat.com Date: Fri Jan 15 14:38:54 2016 -0600
sanlock: fix sanlock_convert on registered fd
When the caller used a registered connection to perform the convert, the fd for that connection was being closed at the end, killing the caller's connection to sanlock.
diff --git a/src/client.c b/src/client.c index 0f7a298..8f8c096 100644 --- a/src/client.c +++ b/src/client.c @@ -1272,7 +1272,8 @@ int sanlock_convert(int sock, int pid, uint32_t flags, struct sanlk_resource *re
rv = recv_result(fd); out: - close(fd); + if (sock == -1) + close(fd); return rv; }
commit 197a68b5b4d28c5cd7c841c0d3d2fb5d2d107ffc Author: David Teigland teigland@redhat.com Date: Fri Jan 15 14:35:52 2016 -0600
sanlock: fix convert sh to ex
When the only sh holder converted to ex, it was looking for 0 shared count intead of 1, causing an unnecessary search for other live holders.
diff --git a/src/resource.c b/src/resource.c index 91a18e9..4d80528 100644 --- a/src/resource.c +++ b/src/resource.c @@ -1141,15 +1141,20 @@ static int convert_sh2ex_token(struct task *task, struct resource *r, struct tok token->r.lver = leader.lver;
/* paxos_lease_acquire set token->shared_count to the number of - SHARED mode blocks it found */ + SHARED mode blocks it found. It should find at least 1 for + our own shared mode block. */ + + log_token(token, "convert_sh2ex shared_count %d", token->shared_count); + + if (token->shared_count == 1) + goto do_mb;
if (!token->shared_count) { - /* no other SHARED mode blocks found */ + /* should never happen */ + log_errot(token, "convert_sh2ex zero shared_count"); goto do_mb; }
- log_token(token, "convert_sh2ex shared_count %d", token->shared_count); - rv = clear_dead_shared(task, token, leader.num_hosts, &live_count); if (rv < 0) { log_errot(token, "convert_sh2ex clear_dead error %d", rv);
sanlock-devel@lists.fedorahosted.org