+static void ocfs2_control_send_down(const char *uuid,
+ int nodenum)
+{
+ struct ocfs2_live_connection *c;
+
+ mutex_lock(&ocfs2_control_lock);
+
+ c = ocfs2_connection_find(uuid);
+ if (c) {
+ BUG_ON(c->oc_conn == NULL);
+ c->oc_conn->cc_recovery_handler(nodenum,
+ c->oc_conn->cc_recovery_data);
+ }
+
+ mutex_unlock(&ocfs2_control_lock);
+}
+
+/* DOWN<space><32-char-cap-hex-uuid><space><8-char-hex-nodenum><newline> */
+struct ocfs2_control_message_down {
+ char tag[OCFS2_CONTROL_MESSAGE_DOWN_LEN];
+ char space1;
+ char uuid[OCFS2_TEXT_UUID_LEN];
+ char space2;
+ char nodestr[OCFS2_CONTROL_MESSAGE_NODENUM_LEN];
+ char newline;
+};
+
+static ssize_t ocfs2_control_message(struct file *file,
+ const char __user *buf,
+ size_t count)
+{
+ ssize_t ret;
+ char *p = NULL;
+ long nodenum;
+ struct ocfs2_control_message_down msg;
+
+ /* Try to catch padding issues */
+ WARN_ON(offsetof(struct ocfs2_control_message_down, uuid) !=
+ (sizeof(msg.tag) + sizeof(msg.space1)));
+
+ memset(&msg, 0, sizeof(struct ocfs2_control_message_down));
+ ret = ocfs2_control_cfu(&msg, OCFS2_CONTROL_MESSAGE_DOWN_TOTAL_LEN,
+ buf, count);
+ if (ret != count)
+ return ret;
+
+ if (strncmp(msg.tag, OCFS2_CONTROL_MESSAGE_DOWN,
+ strlen(OCFS2_CONTROL_MESSAGE_DOWN)))
+ return -EINVAL;
+
+ if ((msg.space1 != ' ') || (msg.space2 != ' ') ||
+ (msg.newline != '\n'))
+ return -EINVAL;
+ msg.space1 = msg.space2 = msg.newline = '\0';
+
+ nodenum = simple_strtol(msg.nodestr, &p, 16);
+ if (!p || *p)
+ return -EINVAL;
+
+ if ((nodenum == LONG_MIN) || (nodenum == LONG_MAX) ||
+ (nodenum > INT_MAX) || (nodenum < 0))
+ return -ERANGE;
+
+ ocfs2_control_send_down(msg.uuid, nodenum);
+
+ return count;
+}