This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch testing3
in repository sanlock.
commit 76444b921f50c76e490fab9e8c3da993a78362f3
Author: David Teigland <teigland(a)redhat.com>
Date: Wed Nov 29 14:38:54 2017 -0600
sanlock: add a NOWAIT flag for convert
Converting sh to ex acquires the paxos lease, like
a standard acquire. The caller may want the paxos
acquire to avoid blocking for convert like acquire.
Don't log an error message for a lock conflict
in conversion.
---
src/cmd.c | 2 +-
src/resource.c | 22 ++++++++++++++++------
src/resource.h | 2 +-
src/sanlock_resource.h | 9 +++++++++
4 files changed, 27 insertions(+), 8 deletions(-)
diff --git a/src/cmd.c b/src/cmd.c
index 453a1b6..c090819 100644
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -922,7 +922,7 @@ static void cmd_convert(struct task *task, struct cmd_args *ca)
goto cmd_done;
}
- rv = convert_token(task, &res, token);
+ rv = convert_token(task, &res, token, ca->header.cmd_flags);
if (rv < 0)
result = rv;
diff --git a/src/resource.c b/src/resource.c
index af8f91c..05bcc61 100644
--- a/src/resource.c
+++ b/src/resource.c
@@ -1175,10 +1175,12 @@ static struct resource *new_resource(struct token *token)
return r;
}
-static int convert_sh2ex_token(struct task *task, struct resource *r, struct token
*token)
+static int convert_sh2ex_token(struct task *task, struct resource *r, struct token
*token,
+ uint32_t cmd_flags)
{
struct leader_record leader;
struct paxos_dblock dblock;
+ uint32_t flags = 0;
int live_count = 0;
int retries;
int error;
@@ -1186,6 +1188,13 @@ static int convert_sh2ex_token(struct task *task, struct resource
*r, struct tok
memset(&leader, 0, sizeof(leader));
+ if (cmd_flags & SANLK_CONVERT_OWNER_NOWAIT)
+ flags |= PAXOS_ACQUIRE_OWNER_NOWAIT;
+ if (com.quiet_fail)
+ flags |= PAXOS_ACQUIRE_QUIET_FAIL;
+ if (com.paxos_debug_all)
+ flags |= PAXOS_ACQUIRE_DEBUG_ALL;
+
/* paxos_lease_acquire modifies these token values, and we check them after */
token->shared_count = 0;
memset(token->shared_bitmap, 0, HOSTID_BITMAP_SIZE);
@@ -1199,12 +1208,12 @@ static int convert_sh2ex_token(struct task *task, struct resource
*r, struct tok
token->flags |= T_WRITE_DBLOCK_MBLOCK_SH;
- rv = paxos_lease_acquire(task, token, 0, &leader, &dblock, 0, 0);
+ rv = paxos_lease_acquire(task, token, flags, &leader, &dblock, 0, 0);
token->flags &= ~T_WRITE_DBLOCK_MBLOCK_SH;
if (rv < 0) {
- log_errot(token, "convert_sh2ex acquire error %d t_flags %x", rv,
token->flags);
+ log_token(token, "convert_sh2ex acquire error %d t_flags %x", rv,
token->flags);
/* If the acquire failed before anything important was written,
then this RETRACT flag will not be set, and there is nothing
@@ -1381,7 +1390,8 @@ static int convert_ex2sh_token(struct task *task, struct resource
*r, struct tok
return SANLK_OK;
}
-int convert_token(struct task *task, struct sanlk_resource *res, struct token *cl_token)
+int convert_token(struct task *task, struct sanlk_resource *res, struct token *cl_token,
+ uint32_t cmd_flags)
{
struct resource *r;
struct token *tk;
@@ -1451,7 +1461,7 @@ int convert_token(struct task *task, struct sanlk_resource *res,
struct token *c
}
if (!(res->flags & SANLK_RES_SHARED)) {
- rv = convert_sh2ex_token(task, r, token);
+ rv = convert_sh2ex_token(task, r, token, cmd_flags);
} else if (res->flags & SANLK_RES_SHARED) {
rv = convert_ex2sh_token(task, r, token);
} else {
@@ -1686,7 +1696,7 @@ int acquire_token(struct task *task, struct token *token, uint32_t
cmd_flags,
}
if (rv < 0 && !(token->flags & T_RETRACT_PAXOS)) {
- log_errot(token, "acquire_token disk error %d", rv);
+ log_token(token, "acquire_token disk error %d", rv);
r->flags &= ~R_SHARED;
/* zero r->leader means not owned and release will just close */
release_token_opened(task, token);
diff --git a/src/resource.h b/src/resource.h
index 9821cfc..70cfd04 100644
--- a/src/resource.h
+++ b/src/resource.h
@@ -27,7 +27,7 @@ int resource_orphan_count(char *space_name);
void check_mode_block(struct token *token, uint64_t next_lver, int q, char *dblock);
/* locks resource_mutex */
-int convert_token(struct task *task, struct sanlk_resource *res, struct token
*cl_token);
+int convert_token(struct task *task, struct sanlk_resource *res, struct token *cl_token,
uint32_t cmd_flags);
/* locks resource_mutex */
int acquire_token(struct task *task, struct token *token, uint32_t cmd_flags,
diff --git a/src/sanlock_resource.h b/src/sanlock_resource.h
index d412482..80178d1 100644
--- a/src/sanlock_resource.h
+++ b/src/sanlock_resource.h
@@ -86,6 +86,15 @@
#define SANLK_REL_ORPHAN 0x00000004
/*
+ * convert flags
+ *
+ * SANLK_CONVERT_OWNER_NOWAIT
+ * Same as SANLK_ACQUIRE_OWNER_NOWAIT.
+ */
+
+#define SANLK_CONVERT_OWNER_NOWAIT 0x00000008 /* NB: value must match
SANLK_ACQUIRE_OWNER_NOWAIT */
+
+/*
* request flags
*
* SANLK_REQUEST_NEXT_LVER
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.