ocfs2-tools/0002-Remove-controld-dependency-in-group_join-leave.patch

189 lines
4.4 KiB
Diff

From c863784d971acd7efddc415d5140b8846799162e Mon Sep 17 00:00:00 2001
From: Goldwyn Rodrigues <rgoldwyn@suse.com>
Date: Fri, 27 Dec 2013 09:20:52 -0600
Subject: [PATCH] Remove controld dependency in group_join/leave
---
libo2cb/o2cb_abi.c | 156 +++--------------------------------------------------
1 file changed, 7 insertions(+), 149 deletions(-)
diff --git a/libo2cb/o2cb_abi.c b/libo2cb/o2cb_abi.c
index 40f8176..5eca49d 100644
--- a/libo2cb/o2cb_abi.c
+++ b/libo2cb/o2cb_abi.c
@@ -1373,164 +1373,22 @@ static errcode_t user_parse_status(char **args, int *error, char **error_msg)
}
static errcode_t user_begin_group_join(struct o2cb_cluster_desc *cluster,
- struct o2cb_region_desc *region)
+ struct o2cb_region_desc *region)
{
- errcode_t err;
- int rc;
- int error;
- char *error_msg;
- client_message message;
- char *argv[OCFS2_CONTROLD_MAXARGS + 1];
- char buf[OCFS2_CONTROLD_MAXLINE];
-
- if (control_daemon_fd != -1) {
- /* fprintf(stderr, "Join already in progress!\n"); */
- err = O2CB_ET_INTERNAL_FAILURE;
- goto out;
- }
-
- rc = ocfs2_client_connect();
- if (rc < 0) {
- /* fprintf(stderr, "Unable to connect to ocfs2_controld: %s\n",
- strerror(-rc)); */
- switch (rc) {
- case -EACCES:
- case -EPERM:
- err = O2CB_ET_PERMISSION_DENIED;
- break;
-
- default:
- err = O2CB_ET_SERVICE_UNAVAILABLE;
- break;
- }
- goto out;
- }
- control_daemon_fd = rc;
-
- rc = send_message(control_daemon_fd, CM_MOUNT, OCFS2_FS_NAME,
- region->r_name, cluster->c_cluster,
- region->r_device_name, region->r_service);
- if (rc) {
- /* fprintf(stderr, "Unable to send MOUNT message: %s\n",
- strerror(-rc)); */
- err = O2CB_ET_IO;
- goto out;
- }
-
- rc = receive_message(control_daemon_fd, buf, &message, argv);
- if (rc < 0) {
- /* fprintf(stderr, "Error reading from daemon: %s\n",
- strerror(-rc)); */
- err = O2CB_ET_IO;
- goto out;
- }
-
- switch (message) {
- case CM_STATUS:
- err = user_parse_status(argv, &error, &error_msg);
- if (err) {
- /* fprintf(stderr, "Bad status message: %s\n",
- strerror(-rc)); */
- goto out;
- }
- if (error && (error != EALREADY)) {
- /* fprintf(stderr,
- "Error %d from daemon: %s\n",
- error, error_msg); */
- err = O2CB_ET_CONFIGURATION_ERROR;
- goto out;
- }
- break;
-
- default:
- /* fprintf(stderr,
- "Unexpected message %s from daemon\n",
- message_to_string(message)); */
- err = O2CB_ET_INTERNAL_FAILURE;
- goto out;
- break;
- }
-
- err = 0;
+ errcode_t ret = 0;
-out:
- if (err && (control_daemon_fd != -1)) {
- close(control_daemon_fd);
- control_daemon_fd = -1;
- }
+ ret = o2cb_validate_cluster_name(cluster);
+ if (ret)
+ return ret;
- return err;
+ return ret;
}
static errcode_t user_complete_group_join(struct o2cb_cluster_desc *cluster,
struct o2cb_region_desc *region,
int result)
{
- errcode_t err = O2CB_ET_SERVICE_UNAVAILABLE;
- int rc;
- int error;
- char *error_msg;
- client_message message;
- char *argv[OCFS2_CONTROLD_MAXARGS + 1];
- char buf[OCFS2_CONTROLD_MAXLINE];
-
- if (control_daemon_fd == -1) {
- /* fprintf(stderr, "Join not started!\n"); */
- err = O2CB_ET_SERVICE_UNAVAILABLE;
- goto out;
- }
-
- rc = send_message(control_daemon_fd, CM_MRESULT, OCFS2_FS_NAME,
- region->r_name, result, region->r_service);
- if (rc) {
- /* fprintf(stderr, "Unable to send MRESULT message: %s\n",
- strerror(-rc)); */
- err = O2CB_ET_IO;
- goto out;
- }
-
- rc = receive_message(control_daemon_fd, buf, &message, argv);
- if (rc < 0) {
- /* fprintf(stderr, "Error reading from daemon: %s\n",
- strerror(-rc)); */
- err = O2CB_ET_IO;
- goto out;
- }
-
- switch (message) {
- case CM_STATUS:
- err = user_parse_status(argv, &error, &error_msg);
- if (err) {
- /* fprintf(stderr, "Bad status message: %s\n",
- strerror(-rc)); */
- goto out;
- }
- if (error) {
- /* fprintf(stderr,
- "Error %d from daemon: %s\n",
- error, error_msg); */
- err = O2CB_ET_CONFIGURATION_ERROR;
- }
- break;
-
- default:
- /* fprintf(stderr,
- "Unexpected message %s from daemon\n",
- message_to_string(message)); */
- err = O2CB_ET_INTERNAL_FAILURE;
- goto out;
- break;
- }
-
- err = 0;
-
-out:
- if (control_daemon_fd != -1) {
- close(control_daemon_fd);
- control_daemon_fd = -1;
- }
-
- return err;
+ return 0;
}
static errcode_t user_group_leave(struct o2cb_cluster_desc *cluster,
--
1.8.4