[Ocfs2-tools-devel] [PATCH 35/39] ocfs2_controld: Pass the locking
version to ocfs2_control_open()
Joel Becker
joel.becker at oracle.com
Fri Mar 14 16:52:58 PDT 2008
Opening the ocfs2_control device requires telling the kernel what
version of the locking protocol to use. Move that work into
the control daemon.
Signed-off-by: Joel Becker <joel.becker at oracle.com>
---
include/o2cb/o2cb.h | 3 ++-
libo2cb/o2cb_abi.c | 15 ++++++---------
ocfs2_controld/main.c | 12 +++++++++++-
3 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/include/o2cb/o2cb.h b/include/o2cb/o2cb.h
index 59e3667..d3f2b5f 100644
--- a/include/o2cb/o2cb.h
+++ b/include/o2cb/o2cb.h
@@ -118,7 +118,8 @@ struct ocfs2_protocol_version {
uint8_t pv_minor;
};
errcode_t o2cb_get_max_locking_protocol(struct ocfs2_protocol_version *proto);
-errcode_t o2cb_control_open(unsigned int this_node);
+errcode_t o2cb_control_open(unsigned int this_node,
+ struct ocfs2_protocol_version *proto);
void o2cb_control_close(void);
errcode_t o2cb_control_node_down(const char *uuid, unsigned int nodeid);
diff --git a/libo2cb/o2cb_abi.c b/libo2cb/o2cb_abi.c
index 6f02a26..823a0d9 100644
--- a/libo2cb/o2cb_abi.c
+++ b/libo2cb/o2cb_abi.c
@@ -1945,12 +1945,12 @@ errcode_t o2cb_get_node_num(const char *cluster_name, const char *node_name,
#define OCFS2_CONTROL_MESSAGE_DOWN_OP "DOWN"
#define OCFS2_CONTROL_MESSAGE_DOWN_TOTAL_LEN 47
#define OCFS2_CONTROL_MESSAGE_NODENUM_LEN 8
-static errcode_t o2cb_control_handshake(unsigned int this_node)
+static errcode_t o2cb_control_handshake(unsigned int this_node,
+ struct ocfs2_protocol_version *proto)
{
errcode_t err = 0;
int found = 0;
size_t ret;
- struct ocfs2_protocol_version proto;
char buf[OCFS2_CONTROL_MESSAGE_SETNODE_TOTAL_LEN + 1];
if (control_device_fd == -1) {
@@ -1958,10 +1958,6 @@ static errcode_t o2cb_control_handshake(unsigned int this_node)
goto out;
}
- err = o2cb_get_max_locking_protocol(&proto);
- if (err)
- goto out;
-
buf[OCFS2_CONTROL_PROTO_LEN] = '\0';
while (1)
{
@@ -1999,7 +1995,7 @@ static errcode_t o2cb_control_handshake(unsigned int this_node)
snprintf(buf, OCFS2_CONTROL_MESSAGE_SETVERSION_TOTAL_LEN + 1,
OCFS2_CONTROL_MESSAGE_SETVERSION_OP " %02X %02X\n",
- proto.pv_major, proto.pv_minor);
+ proto->pv_major, proto->pv_minor);
ret = write(control_device_fd, buf,
OCFS2_CONTROL_MESSAGE_SETVERSION_TOTAL_LEN);
if (ret != OCFS2_CONTROL_MESSAGE_SETVERSION_TOTAL_LEN)
@@ -2009,7 +2005,8 @@ out:
return err;
}
-errcode_t o2cb_control_open(unsigned int this_node)
+errcode_t o2cb_control_open(unsigned int this_node,
+ struct ocfs2_protocol_version *proto)
{
errcode_t err = 0;
int rc;
@@ -2046,7 +2043,7 @@ errcode_t o2cb_control_open(unsigned int this_node)
control_device_fd = rc;
- err = o2cb_control_handshake(this_node);
+ err = o2cb_control_handshake(this_node, proto);
if (err) {
close(control_device_fd);
control_device_fd = -1;
diff --git a/ocfs2_controld/main.c b/ocfs2_controld/main.c
index 770a137..a13d6ad 100644
--- a/ocfs2_controld/main.c
+++ b/ocfs2_controld/main.c
@@ -572,9 +572,19 @@ static void cpg_joined(void)
{
int rv;
errcode_t err;
+ struct ocfs2_protocol_version proto;
log_debug("CPG is live, opening control device");
- err = o2cb_control_open(our_nodeid);
+
+ err = o2cb_get_max_locking_protocol(&proto);
+ if (err) {
+ log_error("Error querying maximum locking protocol: %s",
+ error_message(err));
+ shutdown_daemon();
+ return;
+ }
+
+ err = o2cb_control_open(our_nodeid, &proto);
if (err) {
log_error("Error opening control device: %s",
error_message(err));
--
1.5.3.8
More information about the Ocfs2-tools-devel
mailing list