summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd.c
diff options
context:
space:
mode:
authorAvra Sengupta <asengupt@redhat.com>2015-05-14 15:00:59 +0530
committerKrishnan Parthasarathi <kparthas@redhat.com>2015-06-05 02:20:26 -0700
commitae87a7fedfcf7f6b287ef5c3860f45412363e4f6 (patch)
tree967ea9f74debc940a5729aa8cd858867bbd9eba4 /xlators/mgmt/glusterd/src/glusterd.c
parentbedda7c258e000d94b09599340400955e4b8079f (diff)
glusterd/shared_storage: Provide a volume set option to create and mount the shared storage
Backport of http://review.gluster.org/#/c/10793/ Introducing a global volume set option(cluster.enable-shared-storage) which helps create and set-up the shared storage meta volume. gluster volume set all cluster.enable-shared-storage enable On enabling this option, the system analyzes the number of peers in the cluster, which are currently connected, and chooses three such peers(including the node the command is issued from). From these peers a volume(gluster_shared_storage) is created. Depending on the number of peers available the volume is either a replica 3 volume(if there are 3 connected peers), or a replica 2 volume(if there are 2 connected peers). "/var/run/gluster/ss_brick" serves as the brick path on each node for the shared storage volume. We also mount the shared storage at "/var/run/gluster/shared_storage" on all the nodes in the cluster as part of enabling this option. If there is only one node in the cluster, or only one node is up then the command will fail Once the volume is created, and mounted the maintainance of the volume like adding-bricks, removing bricks etc., is expected to be the onus of the user. On disabling the option, we provide the user a warning, and on affirmation from the user we stop the shared storage volume, and unmount it from all the nodes in the cluster. gluster volume set all cluster.enable-shared-storage disable Change-Id: Idd92d67b93f444244f99ede9f634ef18d2945dbc BUG: 1228181 Signed-off-by: Avra Sengupta <asengupt@redhat.com> Reviewed-on: http://review.gluster.org/11086 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Rajesh Joseph <rjoseph@redhat.com> Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.c107
1 files changed, 74 insertions, 33 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c
index 3735c62abc1..54a5fbdbda5 100644
--- a/xlators/mgmt/glusterd/src/glusterd.c
+++ b/xlators/mgmt/glusterd/src/glusterd.c
@@ -66,7 +66,8 @@ extern struct rpcsvc_program gd_svc_cli_trusted_progs;
extern struct rpc_clnt_program gd_brick_prog;
extern struct rpcsvc_program glusterd_mgmt_hndsk_prog;
-extern char snap_mount_folder[PATH_MAX];
+extern char snap_mount_dir[PATH_MAX];
+char ss_brick_path[PATH_MAX];
rpcsvc_cbk_program_t glusterd_cbk_prog = {
.progname = "Gluster Callback",
@@ -1119,18 +1120,18 @@ glusterd_stop_uds_listener (xlator_t *this)
}
static int
-glusterd_init_snap_folder (xlator_t *this)
+glusterd_find_correct_var_run_dir (xlator_t *this, char *var_run_dir)
{
int ret = -1;
struct stat buf = {0,};
- GF_ASSERT (this);
+ GF_VALIDATE_OR_GOTO ("glusterd", this, out);
+ GF_VALIDATE_OR_GOTO (this->name, var_run_dir, out);
- /* Snapshot volumes are mounted under /var/run/gluster/snaps folder.
- * But /var/run is normally a symbolic link to /run folder, which
+ /* /var/run is normally a symbolic link to /run dir, which
* creates problems as the entry point in the mtab for the mount point
* and glusterd maintained entry point will be different. Therefore
- * identify the correct run folder and use it for snap volume mounting.
+ * identify the correct run dir and use it
*/
ret = lstat (GLUSTERD_VAR_RUN_DIR, &buf);
if (ret != 0) {
@@ -1140,20 +1141,38 @@ glusterd_init_snap_folder (xlator_t *this)
goto out;
}
- /* If /var/run is symlink then use /run folder */
+ /* If /var/run is symlink then use /run dir */
if (S_ISLNK (buf.st_mode)) {
- strcpy (snap_mount_folder, GLUSTERD_RUN_DIR);
+ strcpy (var_run_dir, GLUSTERD_RUN_DIR);
} else {
- strcpy (snap_mount_folder, GLUSTERD_VAR_RUN_DIR);
+ strcpy (var_run_dir, GLUSTERD_VAR_RUN_DIR);
}
- strcat (snap_mount_folder, GLUSTERD_DEFAULT_SNAPS_BRICK_DIR);
+ ret = 0;
+out:
+ return ret;
+}
+
+static int
+glusterd_init_var_run_dirs (xlator_t *this, char *var_run_dir,
+ char *dir_to_be_created)
+{
+ int ret = -1;
+ struct stat buf = {0,};
+ char abs_path[PATH_MAX] = {0, };
+
+ GF_VALIDATE_OR_GOTO ("glusterd", this, out);
+ GF_VALIDATE_OR_GOTO (this->name, var_run_dir, out);
+ GF_VALIDATE_OR_GOTO (this->name, dir_to_be_created, out);
+
+ snprintf (abs_path, sizeof(abs_path), "%s%s",
+ var_run_dir, dir_to_be_created);
- ret = stat (snap_mount_folder, &buf);
+ ret = stat (abs_path, &buf);
if ((ret != 0) && (ENOENT != errno)) {
gf_log (this->name, GF_LOG_ERROR,
"stat fails on %s, exiting. (errno = %d)",
- snap_mount_folder, errno);
+ abs_path, errno);
ret = -1;
goto out;
}
@@ -1161,19 +1180,19 @@ glusterd_init_snap_folder (xlator_t *this)
if ((!ret) && (!S_ISDIR(buf.st_mode))) {
gf_log (this->name, GF_LOG_CRITICAL,
"Provided snap path %s is not a directory,"
- "exiting", snap_mount_folder);
+ "exiting", abs_path);
ret = -1;
goto out;
}
if ((-1 == ret) && (ENOENT == errno)) {
- /* Create missing folders */
- ret = mkdir_p (snap_mount_folder, 0777, _gf_true);
+ /* Create missing dirs */
+ ret = mkdir_p (abs_path, 0777, _gf_true);
if (-1 == ret) {
gf_log (this->name, GF_LOG_CRITICAL,
"Unable to create directory %s"
- " ,errno = %d", snap_mount_folder, errno);
+ " ,errno = %d", abs_path, errno);
goto out;
}
}
@@ -1250,21 +1269,22 @@ out:
int
init (xlator_t *this)
{
- int32_t ret = -1;
- rpcsvc_t *rpc = NULL;
- rpcsvc_t *uds_rpc = NULL;
- glusterd_conf_t *conf = NULL;
- data_t *dir_data = NULL;
- struct stat buf = {0,};
- char storedir [PATH_MAX] = {0,};
- char workdir [PATH_MAX] = {0,};
- char cmd_log_filename [PATH_MAX] = {0,};
- int first_time = 0;
- char *mountbroker_root = NULL;
- int i = 0;
- int total_transport = 0;
- char *valgrind_str = NULL;
- char *transport_type = NULL;
+ int32_t ret = -1;
+ rpcsvc_t *rpc = NULL;
+ rpcsvc_t *uds_rpc = NULL;
+ glusterd_conf_t *conf = NULL;
+ data_t *dir_data = NULL;
+ struct stat buf = {0,};
+ char storedir[PATH_MAX] = {0,};
+ char workdir[PATH_MAX] = {0,};
+ char cmd_log_filename[PATH_MAX] = {0,};
+ int first_time = 0;
+ char *mountbroker_root = NULL;
+ int i = 0;
+ int total_transport = 0;
+ char *valgrind_str = NULL;
+ char *transport_type = NULL;
+ char var_run_dir[PATH_MAX] = {0,};
#ifndef GF_DARWIN_HOST_OS
{
@@ -1326,14 +1346,35 @@ init (xlator_t *this)
gf_log (this->name, GF_LOG_INFO, "Using %s as working directory",
workdir);
- ret = glusterd_init_snap_folder (this);
+ ret = glusterd_find_correct_var_run_dir (this, var_run_dir);
+ if (ret) {
+ gf_log (this->name, GF_LOG_CRITICAL, "Unable to find "
+ "the correct var run dir");
+ exit (1);
+ }
+
+ ret = glusterd_init_var_run_dirs (this, var_run_dir,
+ GLUSTERD_DEFAULT_SNAPS_BRICK_DIR);
+ if (ret) {
+ gf_log (this->name, GF_LOG_CRITICAL, "Unable to create "
+ "snap backend dir");
+ exit (1);
+ }
+ snprintf (snap_mount_dir, sizeof(snap_mount_dir), "%s%s",
+ var_run_dir, GLUSTERD_DEFAULT_SNAPS_BRICK_DIR);
+
+ ret = glusterd_init_var_run_dirs (this, var_run_dir,
+ GLUSTER_SHARED_STORAGE_BRICK_DIR);
if (ret) {
gf_log (this->name, GF_LOG_CRITICAL, "Unable to create "
- "snap backend folder");
+ "shared storage brick");
exit (1);
}
+ snprintf (ss_brick_path, sizeof(ss_brick_path), "%s%s",
+ var_run_dir, GLUSTER_SHARED_STORAGE_BRICK_DIR);
+
snprintf (cmd_log_filename, PATH_MAX, "%s/cmd_history.log",
DEFAULT_LOG_FILE_DIRECTORY);
ret = gf_cmd_log_init (cmd_log_filename);