summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rpc/rpc-transport/socket/src/socket.c1
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handshake.c254
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-locks.c4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-mgmt.h6
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c371
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c5
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.h3
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c34
9 files changed, 368 insertions, 312 deletions
diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c
index 3314c92..93da3f2 100644
--- a/rpc/rpc-transport/socket/src/socket.c
+++ b/rpc/rpc-transport/socket/src/socket.c
@@ -3138,7 +3138,6 @@ socket_submit_reply (rpc_transport_t *this, rpc_transport_reply_t *reply)
}
priv->submit_log = 0;
-
entry = __socket_ioq_new (this, &reply->msg);
if (!entry)
goto unlock;
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 61e5b5a..71d0766 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -4201,8 +4201,6 @@ rpcsvc_actor_t gd_svc_cli_actors[] = {
[GLUSTER_CLI_STATEDUMP_VOLUME] = {"STATEDUMP_VOLUME", GLUSTER_CLI_STATEDUMP_VOLUME, glusterd_handle_cli_statedump_volume, NULL, 0, DRC_NA},
[GLUSTER_CLI_LIST_VOLUME] = {"LIST_VOLUME", GLUSTER_CLI_LIST_VOLUME, glusterd_handle_cli_list_volume, NULL, 0, DRC_NA},
[GLUSTER_CLI_CLRLOCKS_VOLUME] = {"CLEARLOCKS_VOLUME", GLUSTER_CLI_CLRLOCKS_VOLUME, glusterd_handle_cli_clearlocks_volume, NULL, 0, DRC_NA},
- [GLUSTER_CLI_COPY_FILE] = {"COPY_FILE", GLUSTER_CLI_COPY_FILE, glusterd_handle_copy_file, NULL, 0, DRC_NA},
- [GLUSTER_CLI_SYS_EXEC] = {"SYS_EXEC", GLUSTER_CLI_SYS_EXEC, glusterd_handle_sys_exec, NULL, 0, DRC_NA},
[GLUSTER_CLI_COPY_FILE] = {"COPY_FILE", GLUSTER_CLI_COPY_FILE, glusterd_handle_copy_file, NULL, 0, DRC_NA},
[GLUSTER_CLI_SYS_EXEC] = {"SYS_EXEC", GLUSTER_CLI_SYS_EXEC, glusterd_handle_sys_exec, NULL, 0, DRC_NA},
[GLUSTER_CLI_SNAP] = {"SNAP", GLUSTER_CLI_SNAP, glusterd_handle_snapshot, NULL, 0, DRC_NA},
diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c
index fee627f..0f0357c 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handshake.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c
@@ -38,27 +38,139 @@ extern struct rpc_clnt_program gd_mgmt_v3_prog;
typedef ssize_t (*gfs_serialize_t) (struct iovec outmsg, void *data);
+static int
+get_snap_volname_and_volinfo (const char *volpath, char **volname,
+ glusterd_volinfo_t **volinfo)
+{
+ int ret = -1;
+ char *save_ptr = NULL;
+ char *str_token = NULL;
+ char *snapname = NULL;
+ char *volname_token = NULL;
+ char *vol = NULL;
+ glusterd_snap_t *snap = NULL;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
+ GF_ASSERT (volpath);
+ GF_ASSERT (volinfo);
+
+ str_token = gf_strdup (volpath);
+ if (NULL == str_token) {
+ goto out;
+ }
+
+ /* Input volname will have below formats:
+ * /snaps/<snapname>/<volname>.<hostname>
+ * or
+ * /snaps/<snapname>/<parent-volname>
+ * We need to extract snapname and parent_volname */
+
+ /*split string by "/" */
+ strtok_r (str_token, "/", &save_ptr);
+ snapname = strtok_r(NULL, "/", &save_ptr);
+ if (!snapname) {
+ gf_log(this->name, GF_LOG_ERROR, "Invalid path: %s", volpath);
+ goto out;
+ }
+
+ volname_token = strtok_r(NULL, "/", &save_ptr);
+ if (!volname_token) {
+ gf_log(this->name, GF_LOG_ERROR, "Invalid path: %s", volpath);
+ goto out;
+ }
+
+ snap = glusterd_find_snap_by_name (snapname);
+ if (!snap) {
+ gf_log(this->name, GF_LOG_ERROR, "Failed to "
+ "fetch snap %s", snapname);
+ goto out;
+ }
+
+ /* Find if its a parent volume name or snap volume
+ * name. This function will succeed if volname_token
+ * is a parent volname
+ */
+ ret = glusterd_volinfo_find (volname_token, volinfo);
+ if (ret) {
+ *volname = gf_strdup (volname_token);
+ if (NULL == *volname) {
+ ret = -1;
+ goto out;
+ }
+
+ ret = glusterd_snap_volinfo_find (volname_token, snap,
+ volinfo);
+ if (ret) {
+ /* Split the volume name */
+ vol = strtok_r (volname_token, ".", &save_ptr);
+ if (!vol) {
+ gf_log(this->name, GF_LOG_ERROR, "Invalid "
+ "volname (%s)", volname_token);
+ goto out;
+ }
+
+ ret = glusterd_snap_volinfo_find (vol, snap, volinfo);
+ if (ret) {
+ gf_log(this->name, GF_LOG_ERROR, "Failed to "
+ "fetch snap volume from volname (%s)",
+ vol);
+ goto out;
+ }
+ }
+ } else {
+ /*volname_token is parent volname*/
+ ret = glusterd_snap_volinfo_find_from_parent_volname (
+ volname_token, snap, volinfo);
+ if (ret) {
+ gf_log(this->name, GF_LOG_ERROR, "Failed to "
+ "fetch snap volume from parent "
+ "volname (%s)", volname_token);
+ goto out;
+ }
+
+ /* Since volname_token is a parent volname we should
+ * get the snap volname here*/
+ *volname = gf_strdup ((*volinfo)->volname);
+ if (NULL == *volname) {
+ ret = -1;
+ goto out;
+ }
+ }
+
+out:
+ if (ret && NULL != *volname) {
+ GF_FREE (*volname);
+ *volname = NULL;
+ }
+ return ret;
+}
+
static size_t
build_volfile_path (const char *volname, char *path,
size_t path_len, char *trusted_str)
{
- struct stat stbuf = {0,};
- int32_t ret = -1;
- glusterd_conf_t *priv = NULL;
- char *vol = NULL;
- char *dup_volname = NULL;
- char *free_ptr = NULL;
- char *save_ptr = NULL;
- char *str_token = NULL;
- char *snapname = NULL;
- char *snap_volname = NULL;
- glusterd_volinfo_t *parent_volinfo = NULL;
- glusterd_volinfo_t *volinfo = NULL;
- glusterd_snap_t *snap = NULL;
- char *server = NULL;
- gf_boolean_t snap_volume = _gf_false;
-
- priv = THIS->private;
+ struct stat stbuf = {0,};
+ int32_t ret = -1;
+ glusterd_conf_t *priv = NULL;
+ char *vol = NULL;
+ char *dup_volname = NULL;
+ char *free_ptr = NULL;
+ char *save_ptr = NULL;
+ char *str_token = NULL;
+ glusterd_volinfo_t *volinfo = NULL;
+ char *server = NULL;
+ const char *volname_ptr = NULL;
+ char path_prefix [PATH_MAX] = {0,};
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
+ priv = this->private;
+ GF_ASSERT (priv);
+ GF_ASSERT (volname);
+ GF_ASSERT (path);
if (strstr (volname, "gluster/")) {
server = strchr (volname, '/') + 1;
@@ -67,53 +179,21 @@ build_volfile_path (const char *volname, char *path,
ret = 1;
goto out;
} else if ((str_token = strstr (volname, "/snaps/"))) {
- /* Input volname will have below formats:
- /snaps/<snapname>/<volname>.<hostname>
- or
- /snaps/<snapname>/<parent-volname>
- We need to extract snapname and parent_volname */
-
- snap_volume = _gf_true;
-
- /*split string by "/" */
- str_token = strtok_r(str_token, "/", &save_ptr);
- snapname = strtok_r(NULL, "/", &save_ptr);
- if (!snapname) {
- gf_log(THIS->name, GF_LOG_ERROR, "Invalid path: %s",
- volname);
+ ret = get_snap_volname_and_volinfo (str_token, &dup_volname,
+ &volinfo);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "Failed to get snap"
+ " volinfo from path (%s)", volname);
ret = -1;
goto out;
}
- snap_volname = strtok_r(NULL, "/", &save_ptr);
- if (!snap_volname) {
- gf_log(THIS->name, GF_LOG_ERROR, "Invalid path: %s",
- volname);
- ret = -1;
- goto out;
- }
+ snprintf (path_prefix, sizeof (path_prefix), "%s/snaps/%s",
+ priv->workdir, volinfo->snapshot->snapname);
- snap = glusterd_find_snap_by_name (snapname);
- if (!snap) {
- gf_log(THIS->name, GF_LOG_ERROR, "Failed to "
- "fetch snap %s", snapname);
- ret = -1;
- goto out;
- }
- ret = glusterd_volinfo_find (snap_volname,
- &parent_volinfo);
- if (ret) {
- dup_volname = gf_strdup (snap_volname);
- } else {
- ret = glusterd_snap_volinfo_find_from_parent_volname
- (snap_volname, snap, &volinfo);
- if (ret) {
- gf_log(THIS->name, GF_LOG_ERROR, "Failed to "
- "fetch snap volume from parent volname");
- goto out;
- }
- dup_volname = gf_strdup (volinfo->volname);
- }
+ free_ptr = dup_volname;
+ volname_ptr = dup_volname;
+ goto gotvolinfo;
} else if (volname[0] != '/') {
/* Normal behavior */
dup_volname = gf_strdup (volname);
@@ -130,15 +210,12 @@ build_volfile_path (const char *volname, char *path,
goto out;
}
free_ptr = dup_volname;
+ volname_ptr = volname;
- if (!snap_volume) {
- ret = glusterd_volinfo_find (dup_volname, &volinfo);
- } else {
- ret = 0;
- if (!volinfo)
- ret = glusterd_snap_volinfo_find (dup_volname, snap,
- &volinfo);
- }
+ snprintf (path_prefix, sizeof (path_prefix), "%s/vols",
+ priv->workdir);
+
+ ret = glusterd_volinfo_find (dup_volname, &volinfo);
if (ret) {
/* Split the volume name */
@@ -146,57 +223,34 @@ build_volfile_path (const char *volname, char *path,
if (!vol)
goto out;
- if (!snap_volume) {
- ret = glusterd_volinfo_find (vol, &volinfo);
- } else {
- ret = glusterd_snap_volinfo_find (dup_volname, snap,
- &volinfo);
- }
-
+ ret = glusterd_volinfo_find (vol, &volinfo);
if (ret)
goto out;
}
+gotvolinfo:
if (!glusterd_auth_get_username (volinfo))
trusted_str = NULL;
- if (!snap_volume)
- ret = snprintf (path, path_len, "%s/vols/%s/%s.vol",
- priv->workdir, volinfo->volname, volname);
- else
- ret = snprintf (path, path_len, "%s/snaps/%s/%s/%s.vol",
- priv->workdir, volinfo->snapshot->snapname,
- volinfo->volname, snap_volname);
-
+ ret = snprintf (path, path_len, "%s/%s/%s.vol", path_prefix,
+ volinfo->volname, volname_ptr);
if (ret == -1)
goto out;
ret = stat (path, &stbuf);
if ((ret == -1) && (errno == ENOENT)) {
- if (!snap_volume)
- snprintf (path, path_len, "%s/vols/%s/%s%s-fuse.vol",
- priv->workdir, volinfo->volname,
- (trusted_str ? trusted_str : ""),
- dup_volname);
- else
- snprintf (path, path_len,
- "%s/snaps/%s/%s/%s%s-fuse.vol", priv->workdir,
- volinfo->snapshot->snapname, volinfo->volname,
- (trusted_str ? trusted_str:""), dup_volname);
+ snprintf (path, path_len, "%s/%s/%s%s-fuse.vol",
+ path_prefix, volinfo->volname,
+ (trusted_str ? trusted_str : ""),
+ dup_volname);
ret = stat (path, &stbuf);
}
if ((ret == -1) && (errno == ENOENT)) {
- if (!snap_volume)
- snprintf (path, path_len, "%s/vols/%s/%s-tcp.vol",
- priv->workdir, volinfo->volname, volname);
- else
- snprintf (path, path_len,
- "%s/snaps/%s/%s/%s-tcp.vol",
- priv->workdir, volinfo->snapshot->snapname,
- volinfo->volname, snap_volname);
+ snprintf (path, path_len, "%s/%s/%s-tcp.vol",
+ path_prefix, volinfo->volname, volname_ptr);
}
ret = 1;
diff --git a/xlators/mgmt/glusterd/src/glusterd-locks.c b/xlators/mgmt/glusterd/src/glusterd-locks.c
index 531e0ba..0af2a18 100644
--- a/xlators/mgmt/glusterd/src/glusterd-locks.c
+++ b/xlators/mgmt/glusterd/src/glusterd-locks.c
@@ -26,7 +26,7 @@
#include <signal.h>
-#define MAX_LOCKING_ENTITIES 2
+#define GF_MAX_LOCKING_ENTITIES 2
/* Valid entities that the mgmt_v3 lock can hold locks upon *
* To add newer entities to be locked, we can just add more *
@@ -453,7 +453,7 @@ glusterd_multiple_mgmt_v3_lock (dict_t *dict, uuid_t uuid)
locked_count++;
}
- if (locked_count == MAX_LOCKING_ENTITIES) {
+ if (locked_count == GF_MAX_LOCKING_ENTITIES) {
/* If all locking ops went successfuly, return as success */
ret = 0;
goto out;
diff --git a/xlators/mgmt/glusterd/src/glusterd-mgmt.h b/xlators/mgmt/glusterd/src/glusterd-mgmt.h
index 685f591..b185a9b 100644
--- a/xlators/mgmt/glusterd/src/glusterd-mgmt.h
+++ b/xlators/mgmt/glusterd/src/glusterd-mgmt.h
@@ -7,8 +7,8 @@
later), or the GNU General Public License, version 2 (GPLv2), in all
cases as published by the Free Software Foundation.
*/
-#ifndef _GLUSTERD_JARVIS_H_
-#define _GLUSTERD_JARVIS_H_
+#ifndef _GLUSTERD_MGMT_H_
+#define _GLUSTERD_MGMT_H_
#ifndef _CONFIG_H
#define _CONFIG_H
@@ -42,4 +42,4 @@ glusterd_mgmt_v3_initiate_snap_phases (rpcsvc_request_t *req, glusterd_op_t op,
int
glusterd_snap_pre_validate_use_rsp_dict (dict_t *dst, dict_t *src);
-#endif
+#endif /* _GLUSTERD_MGMT_H_ */
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index a6c79e4..9b811cd 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
@@ -269,12 +269,12 @@ int
snap_max_hard_limits_validate (dict_t *dict, char *volname,
uint64_t value, char **op_errstr)
{
- char err_str[PATH_MAX] = "";
- glusterd_conf_t *conf = NULL;
- glusterd_volinfo_t *volinfo = NULL;
- int ret = -1;
- uint64_t max_limit = GLUSTERD_SNAPS_MAX_HARD_LIMIT;
- xlator_t *this = NULL;
+ char err_str[PATH_MAX] = "";
+ glusterd_conf_t *conf = NULL;
+ glusterd_volinfo_t *volinfo = NULL;
+ int ret = -1;
+ uint64_t max_limit = GLUSTERD_SNAPS_MAX_HARD_LIMIT;
+ xlator_t *this = NULL;
this = THIS;
@@ -301,9 +301,14 @@ snap_max_hard_limits_validate (dict_t *dict, char *volname,
}
if (value) {
- max_limit = GLUSTERD_SNAPS_MAX_HARD_LIMIT;
- if ((max_limit > conf->snap_max_hard_limit) && volname)
+ /* Max limit for the system is GLUSTERD_SNAPS_MAX_HARD_LIMIT
+ * but max limit for a volume is conf->snap_max_hard_limit.
+ */
+ if (volname) {
max_limit = conf->snap_max_hard_limit;
+ } else {
+ max_limit = GLUSTERD_SNAPS_MAX_HARD_LIMIT;
+ }
}
if ((value < 0) || (value > max_limit)) {
@@ -404,10 +409,10 @@ glusterd_snapshot_config_prevalidate (dict_t *dict, char **op_errstr)
ret = 0;
out:
- if (ret && err_str[0] != '\0') {
- gf_log (this->name, loglevel, "%s", err_str);
- *op_errstr = gf_strdup (err_str);
- }
+ if (ret && err_str[0] != '\0') {
+ gf_log (this->name, loglevel, "%s", err_str);
+ *op_errstr = gf_strdup (err_str);
+ }
return ret;
}
@@ -460,9 +465,9 @@ glusterd_snap_create_pre_val_use_rsp_dict (dict_t *dst, dict_t *src)
ret = dict_get_ptr (src, key,
(void **)&snap_brick_dir);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING,
- "Unable to fetch %s", key);
- continue;
+ gf_log (this->name, GF_LOG_WARNING,
+ "Unable to fetch %s", key);
+ continue;
}
snprintf (key, sizeof(key) - 1,
@@ -471,9 +476,9 @@ glusterd_snap_create_pre_val_use_rsp_dict (dict_t *dst, dict_t *src)
ret = dict_get_ptr (src, key,
(void **)&snap_device);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Unable to fetch snap_device");
- goto out;
+ gf_log (this->name, GF_LOG_ERROR,
+ "Unable to fetch snap_device");
+ goto out;
}
snprintf (snapbrckord, sizeof(snapbrckord) - 1,
@@ -535,18 +540,22 @@ out:
int
glusterd_snap_pre_validate_use_rsp_dict (dict_t *dst, dict_t *src)
{
- int ret = -1;
- int32_t snap_command = 0;
+ int ret = -1;
+ int32_t snap_command = 0;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
if (!dst || !src) {
- gf_log ("", GF_LOG_ERROR, "Source or Destination "
+ gf_log (this->name, GF_LOG_ERROR, "Source or Destination "
"dict is empty.");
goto out;
}
ret = dict_get_int32 (dst, "type", &snap_command);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "unable to get the type of "
+ gf_log (this->name, GF_LOG_ERROR, "unable to get the type of "
"the snapshot command");
goto out;
}
@@ -555,7 +564,8 @@ glusterd_snap_pre_validate_use_rsp_dict (dict_t *dst, dict_t *src)
case GF_SNAP_OPTION_TYPE_CREATE:
ret = glusterd_snap_create_pre_val_use_rsp_dict (dst, src);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to use rsp dict");
+ gf_log (this->name, GF_LOG_ERROR, "Unable to use "
+ "rsp dict");
goto out;
}
break;
@@ -565,7 +575,7 @@ glusterd_snap_pre_validate_use_rsp_dict (dict_t *dst, dict_t *src)
ret = 0;
out:
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
return ret;
}
@@ -645,8 +655,8 @@ glusterd_snapshot_create_prevalidate (dict_t *dict, char **op_errstr,
ret = -1;
if (!glusterd_is_volume_started (volinfo)) {
- snprintf (err_str, sizeof (err_str),
- "volume %s is not started",volinfo->volname);
+ snprintf (err_str, sizeof (err_str), "volume %s is "
+ "not started", volinfo->volname);
loglevel = GF_LOG_WARNING;
goto out;
}
@@ -672,11 +682,11 @@ glusterd_snapshot_create_prevalidate (dict_t *dict, char **op_errstr,
effective_max_limit = conf->snap_max_hard_limit;
if (volinfo->snap_count >= effective_max_limit) {
- snprintf (err_str, sizeof (err_str),
- "The number of existing snaps has reached the "
- "effective maximum limit of %"PRIu64" ,"
- "for the volume %s", effective_max_limit,
- volname);
+ snprintf (err_str, sizeof (err_str),
+ "The number of existing snaps has reached "
+ "the effective maximum limit of %"PRIu64" ,"
+ "for the volume %s", effective_max_limit,
+ volname);
loglevel = GF_LOG_WARNING;
goto out;
}
@@ -746,7 +756,8 @@ glusterd_snapshot_create_prevalidate (dict_t *dict, char **op_errstr,
goto out;
}
- ret = glusterd_get_brick_root (brickinfo->path, &mnt_pt);
+ ret = glusterd_get_brick_root (brickinfo->path,
+ &mnt_pt);
if (ret) {
snprintf (err_str, sizeof (err_str),
"could not get the root of the brick path %s",
@@ -754,7 +765,7 @@ glusterd_snapshot_create_prevalidate (dict_t *dict, char **op_errstr,
loglevel = GF_LOG_WARNING;
goto out;
}
- if (strncmp (brickinfo->path, mnt_pt, strlen (mnt_pt))) {
+ if (strncmp (brickinfo->path, mnt_pt, strlen(mnt_pt))) {
snprintf (err_str, sizeof (err_str),
"brick: %s brick mount: %s",
brickinfo->path, mnt_pt);
@@ -798,7 +809,7 @@ glusterd_snapshot_create_prevalidate (dict_t *dict, char **op_errstr,
snprintf (key, sizeof(key) - 1, "vol%ld_brickcount", i);
ret = dict_set_int64 (rsp_dict, key, brick_count);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Failed to set %s",
+ gf_log (this->name, GF_LOG_ERROR, "Failed to set %s",
key);
goto out;
}
@@ -806,7 +817,7 @@ glusterd_snapshot_create_prevalidate (dict_t *dict, char **op_errstr,
ret = dict_set_int64 (rsp_dict, "volcount", volcount);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Failed to set volcount");
+ gf_log (this->name, GF_LOG_ERROR, "Failed to set volcount");
goto out;
}
@@ -815,10 +826,10 @@ out:
if (ret)
GF_FREE (tmpstr);
- if (ret && err_str[0] != '\0') {
- gf_log (this->name, loglevel, "%s", err_str);
- *op_errstr = gf_strdup (err_str);
- }
+ if (ret && err_str[0] != '\0') {
+ gf_log (this->name, loglevel, "%s", err_str);
+ *op_errstr = gf_strdup (err_str);
+ }
gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
return ret;
@@ -1160,7 +1171,7 @@ glusterd_snap_volume_remove (dict_t *rsp_dict,
goto out;
}
- if (!list_empty(&snap_vol->snapvol_list) ) {
+ if (!list_empty(&snap_vol->snapvol_list)) {
ret = glusterd_volinfo_find (snap_vol->parent_volname,
&origin_vol);
if (ret) {
@@ -1323,24 +1334,23 @@ glusterd_snapshot_get_snapvol_detail (dict_t *dict,
/* volume status */
snprintf (key, sizeof (key), "%s.vol-status", keyprefix);
switch (snap_vol->status) {
- case GLUSTERD_STATUS_STARTED:
- ret = dict_set_str (dict, key, "Started");
- break;
- case GLUSTERD_STATUS_STOPPED:
- ret = dict_set_str (dict, key, "Stopped");
- break;
- case GD_SNAP_STATUS_NONE:
- ret = dict_set_str (dict, key, "None");
- break;
- default:
- gf_log (this->name, GF_LOG_ERROR, "Invalid volume "
- "status");
- ret = -1;
- goto out;
+ case GLUSTERD_STATUS_STARTED:
+ ret = dict_set_str (dict, key, "Started");
+ break;
+ case GLUSTERD_STATUS_STOPPED:
+ ret = dict_set_str (dict, key, "Stopped");
+ break;
+ case GD_SNAP_STATUS_NONE:
+ ret = dict_set_str (dict, key, "None");
+ break;
+ default:
+ gf_log (this->name, GF_LOG_ERROR, "Invalid volume status");
+ ret = -1;
+ goto out;
}
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set volume status "
- "in dictionary: %s", key);
+ gf_log (this->name, GF_LOG_ERROR, "Failed to set volume status"
+ " in dictionary: %s", key);
goto out;
}
@@ -1358,12 +1368,11 @@ glusterd_snapshot_get_snapvol_detail (dict_t *dict,
gf_log(this->name, GF_LOG_DEBUG, "system snap-max-hard-limit is"
" lesser than volume snap-max-hard-limit, "
"snap-max-hard-limit value is set to %d", snap_limit);
- }
- else {
- snap_limit = origin_vol->snap_max_hard_limit ;
+ } else {
+ snap_limit = origin_vol->snap_max_hard_limit;
gf_log(this->name, GF_LOG_DEBUG, "volume snap-max-hard-limit is"
" lesser than system snap-max-hard-limit, "
- "snap-max-hard-limit value is set to %d",snap_limit);
+ "snap-max-hard-limit value is set to %d", snap_limit);
}
snprintf (key, sizeof (key), "%s.snaps-available", keyprefix);
@@ -1510,26 +1519,25 @@ glusterd_snapshot_get_snap_detail (dict_t *dict, glusterd_snap_t *snap,
snprintf (key, sizeof (key), "%s.snap-status", keyprefix);
switch (snap->snap_status) {
- case GD_SNAP_STATUS_INIT:
- ret = dict_set_str (dict, key, "Init");
- break;
- case GD_SNAP_STATUS_IN_USE:
- ret = dict_set_str (dict, key, "In-use");
- break;
- case GD_SNAP_STATUS_DECOMMISSION:
- ret = dict_set_str (dict, key, "Decommisioned");
- break;
- case GD_SNAP_STATUS_RESTORED:
- ret = dict_set_str (dict, key, "Restored");
- break;
- case GD_SNAP_STATUS_NONE:
- ret = dict_set_str (dict, key, "None");
- break;
- default:
- gf_log (this->name, GF_LOG_ERROR, "Invalid snap "
- "status");
- ret = -1;
- goto out;
+ case GD_SNAP_STATUS_INIT:
+ ret = dict_set_str (dict, key, "Init");
+ break;
+ case GD_SNAP_STATUS_IN_USE:
+ ret = dict_set_str (dict, key, "In-use");
+ break;
+ case GD_SNAP_STATUS_DECOMMISSION:
+ ret = dict_set_str (dict, key, "Decommisioned");
+ break;
+ case GD_SNAP_STATUS_RESTORED:
+ ret = dict_set_str (dict, key, "Restored");
+ break;
+ case GD_SNAP_STATUS_NONE:
+ ret = dict_set_str (dict, key, "None");
+ break;
+ default:
+ gf_log (this->name, GF_LOG_ERROR, "Invalid snap status");
+ ret = -1;
+ goto out;
}
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "Failed to set snap status "
@@ -1659,12 +1667,11 @@ glusterd_snapshot_get_info_by_volume (dict_t *dict, char *volname,
gf_log(this->name, GF_LOG_DEBUG, "system snap-max-hard-limit is"
" lesser than volume snap-max-hard-limit, "
"snap-max-hard-limit value is set to %d", snap_limit);
- }
- else {
- snap_limit = volinfo->snap_max_hard_limit ;
+ } else {
+ snap_limit = volinfo->snap_max_hard_limit;
gf_log(this->name, GF_LOG_DEBUG, "volume snap-max-hard-limit is"
" lesser than system snap-max-hard-limit, "
- "snap-max-hard-limit value is set to %d",snap_limit);
+ "snap-max-hard-limit value is set to %d", snap_limit);
}
if (snap_limit > volinfo->snap_count)
@@ -1756,7 +1763,7 @@ glusterd_handle_snapshot_info (rpcsvc_request_t *req, glusterd_op_t op,
}
switch (cmd) {
- case GF_SNAP_INFO_TYPE_ALL :
+ case GF_SNAP_INFO_TYPE_ALL:
{
ret = glusterd_snapshot_get_all_snap_info (dict);
if (ret) {
@@ -1767,7 +1774,7 @@ glusterd_handle_snapshot_info (rpcsvc_request_t *req, glusterd_op_t op,
break;
}
- case GF_SNAP_INFO_TYPE_SNAP :
+ case GF_SNAP_INFO_TYPE_SNAP:
{
ret = dict_get_str (dict, "snapname", &snapname);
if (ret) {
@@ -1803,7 +1810,7 @@ glusterd_handle_snapshot_info (rpcsvc_request_t *req, glusterd_op_t op,
break;
}
- case GF_SNAP_INFO_TYPE_VOL :
+ case GF_SNAP_INFO_TYPE_VOL:
{
ret = dict_get_str (dict, "volname", &volname);
if (ret) {
@@ -2055,7 +2062,8 @@ glusterd_handle_snapshot_create (rpcsvc_request_t *req, glusterd_op_t op,
}
if (strlen(snapname) >= GLUSTERD_MAX_SNAP_NAME) {
- snprintf (err_str, len,"snapname cannot exceed 255 characters");
+ snprintf (err_str, len, "snapname cannot exceed 255 "
+ "characters");
gf_log (this->name, GF_LOG_ERROR, "%s", err_str);
ret = -1;
goto out;
@@ -2191,7 +2199,7 @@ glusterd_handle_snapshot_status (rpcsvc_request_t *req, glusterd_op_t op,
goto out;
}
switch (cmd) {
- case GF_SNAP_STATUS_TYPE_ALL :
+ case GF_SNAP_STATUS_TYPE_ALL:
{
/* IF we give "gluster snapshot status"
* then lock is held on all snaps.
@@ -2231,7 +2239,7 @@ glusterd_handle_snapshot_status (rpcsvc_request_t *req, glusterd_op_t op,
break;
}
- case GF_SNAP_STATUS_TYPE_SNAP :
+ case GF_SNAP_STATUS_TYPE_SNAP:
{
/* IF we give "gluster snapshot status <snapname>"
* then lock is held on single snap.
@@ -2305,7 +2313,7 @@ glusterd_handle_snapshot_status (rpcsvc_request_t *req, glusterd_op_t op,
goto out;
}
break;
- default :
+ default:
{
gf_log (this->name, GF_LOG_ERROR, "Unknown type");
ret = -1;
@@ -2332,7 +2340,7 @@ glusterd_handle_snapshot_status (rpcsvc_request_t *req, glusterd_op_t op,
ret = 0;
-out :
+out:
if (voldict) {
dict_unref (voldict);
}
@@ -2536,7 +2544,7 @@ out:
if (snap)
glusterd_snap_remove (rsp_dict, snap,
_gf_true, _gf_true);
- snap=NULL;
+ snap = NULL;
}
return snap;
@@ -2594,7 +2602,8 @@ glusterd_build_snap_device_path (char *device, char *snapname)
}
runner_end (&runner);
- snprintf (snap, sizeof(snap),"/dev/%s/%s", gf_trim(volgroup), snapname);
+ snprintf (snap, sizeof(snap), "/dev/%s/%s", gf_trim(volgroup),
+ snapname);
snap_device = gf_strdup (snap);
if (!snap_device) {
gf_log (this->name, GF_LOG_WARNING, "Cannot copy the "
@@ -2741,8 +2750,8 @@ glusterd_snap_brick_create (char *device, glusterd_volinfo_t *snap_volinfo,
/* mount the snap logical device on the directory inside
/run/gluster/snaps/<snapname>/@snap_brick_mount_path
Way to mount the snap brick via mount api is this.
- ret = mount (device, snap_brick_mount_path, entry->mnt_type, MS_MGC_VAL,
- "nouuid");
+ ret = mount (device, snap_brick_mount_path, entry->mnt_type,
+ MS_MGC_VAL, "nouuid");
But for now, mounting using runner apis.
*/
runinit (&runner);
@@ -2752,7 +2761,7 @@ glusterd_snap_brick_create (char *device, glusterd_volinfo_t *snap_volinfo,
snap_brick_mount_path, NULL);
runner_log (&runner, "", GF_LOG_DEBUG, msg);
- //let glusterd get blocked till snapshot is over
+ /* let glusterd get blocked till snapshot is over */
synclock_unlock (&priv->big_lock);
ret = runner_run (&runner);
synclock_lock (&priv->big_lock);
@@ -2792,7 +2801,7 @@ out:
umount (snap_brick_mount_path);
}
- gf_log ("", GF_LOG_TRACE, "Returning %d", ret);
+ gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
return ret;
}
@@ -3337,7 +3346,7 @@ glusterd_handle_snapshot_remove (rpcsvc_request_t *req, glusterd_op_t op,
}
snap = glusterd_find_snap_by_name (snapname);
- if (!snap){
+ if (!snap) {
snprintf (err_str, len, "Snap (%s) does not exist", snapname);
gf_log (this->name, GF_LOG_ERROR,
"%s", err_str);
@@ -3400,14 +3409,14 @@ glusterd_snapshot_remove_prevalidate (dict_t *dict, char **op_errstr,
}
ret = dict_get_str (dict, "snapname", &snapname);
- if (ret){
+ if (ret) {
gf_log (this->name, GF_LOG_ERROR, "Getting the snap name "
"failed");
goto out;
}
snap = glusterd_find_snap_by_name (snapname);
- if (!snap){
+ if (!snap) {
gf_log (this->name, GF_LOG_ERROR, "Snap %s does not exist",
snapname);
ret = -1;
@@ -3449,11 +3458,11 @@ glusterd_snapshot_status_prevalidate (dict_t *dict, char **op_errstr,
}
switch (cmd) {
- case GF_SNAP_STATUS_TYPE_ALL :
+ case GF_SNAP_STATUS_TYPE_ALL:
{
break;
}
- case GF_SNAP_STATUS_TYPE_SNAP :
+ case GF_SNAP_STATUS_TYPE_SNAP:
{
ret = dict_get_str (dict, "snapname", &snapname);
if (ret) {
@@ -3475,7 +3484,7 @@ glusterd_snapshot_status_prevalidate (dict_t *dict, char **op_errstr,
}
break;
}
- case GF_SNAP_STATUS_TYPE_VOL :
+ case GF_SNAP_STATUS_TYPE_VOL:
{
ret = dict_get_str (dict, "volname", &volname);
if (ret) {
@@ -3499,7 +3508,7 @@ glusterd_snapshot_status_prevalidate (dict_t *dict, char **op_errstr,
break;
}
- default :
+ default:
{
gf_log (this->name, GF_LOG_ERROR, "Invalid command");
break;
@@ -3507,7 +3516,7 @@ glusterd_snapshot_status_prevalidate (dict_t *dict, char **op_errstr,
}
ret = 0;
-out :
+out:
return ret;
}
@@ -3538,14 +3547,14 @@ glusterd_snapshot_remove_commit (dict_t *dict, char **op_errstr,
}
ret = dict_get_str (dict, "snapname", &snapname);
- if (ret){
+ if (ret) {
gf_log (this->name, GF_LOG_ERROR, "Getting the snap name "
"failed");
goto out;
}
snap = glusterd_find_snap_by_name (snapname);
- if (!snap){
+ if (!snap) {
gf_log (this->name, GF_LOG_ERROR, "Snap %s does not exist",
snapname);
ret = -1;
@@ -3580,7 +3589,7 @@ glusterd_snapshot_remove_commit (dict_t *dict, char **op_errstr,
}
ret = glusterd_snap_remove (rsp_dict, snap, _gf_true, _gf_false);
- if (ret){
+ if (ret) {
gf_log (this->name, GF_LOG_ERROR, "Failed to remove snap %s",
snapname);
goto out;
@@ -3594,7 +3603,7 @@ glusterd_snapshot_remove_commit (dict_t *dict, char **op_errstr,
}
ret = dict_set_dynstr (rsp_dict, "snapname", dup_snapname);
- if (ret){
+ if (ret) {
gf_log (this->name, GF_LOG_ERROR, "Failed to set the snapname");
GF_FREE (dup_snapname);
goto out;
@@ -3802,10 +3811,10 @@ out:
if (snap)
glusterd_snap_remove (rsp_dict, snap,
_gf_true, _gf_true);
- snap=NULL;
+ snap = NULL;
}
- gf_log ("", GF_LOG_TRACE, "Returning %d", ret);
+ gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
return ret;
}
@@ -3837,7 +3846,7 @@ snap_max_hard_limit_set_commit (dict_t *dict, uint64_t value,
ret = glusterd_store_global_info (this);
if (ret) {
- snprintf (err_str, PATH_MAX,"Failed to store "
+ snprintf (err_str, PATH_MAX, "Failed to store "
"snap-max-hard-limit for system");
goto out;
}
@@ -3845,7 +3854,7 @@ snap_max_hard_limit_set_commit (dict_t *dict, uint64_t value,
/* For one volume */
ret = glusterd_volinfo_find (volname, &volinfo);
if (ret) {
- snprintf (err_str, PATH_MAX,"Failed to get the"
+ snprintf (err_str, PATH_MAX, "Failed to get the"
" volinfo for volume %s", volname);
goto out;
}
@@ -3853,9 +3862,9 @@ snap_max_hard_limit_set_commit (dict_t *dict, uint64_t value,
volinfo->snap_max_hard_limit = value;
ret = glusterd_store_volinfo (volinfo,
- GLUSTERD_VOLINFO_VER_AC_INCREMENT);
+ GLUSTERD_VOLINFO_VER_AC_INCREMENT);
if (ret) {
- snprintf (err_str, PATH_MAX,"Failed to store "
+ snprintf (err_str, PATH_MAX, "Failed to store "
"snap-max-hard-limit for volume %s", volname);
goto out;
}
@@ -3928,7 +3937,8 @@ snap_max_limits_display_commit (dict_t *rsp_dict, char *volname,
snprintf (buf, sizeof(buf),
"volume%ld-active-hard-limit", count);
- ret = dict_set_uint64 (rsp_dict, buf, active_hard_limit);
+ ret = dict_set_uint64 (rsp_dict, buf,
+ active_hard_limit);
if (ret) {
snprintf (err_str, PATH_MAX,
"Failed to set %s", buf);
@@ -3956,7 +3966,7 @@ snap_max_limits_display_commit (dict_t *rsp_dict, char *volname,
/* For one volume */
ret = glusterd_volinfo_find (volname, &volinfo);
if (ret) {
- snprintf (err_str, PATH_MAX,"Failed to get the"
+ snprintf (err_str, PATH_MAX, "Failed to get the"
" volinfo for volume %s", volname);
goto out;
}
@@ -4085,7 +4095,8 @@ glusterd_snapshot_config_commit (dict_t *dict, char **op_errstr,
if (hard_limit) {
/* Commit ops for snap-max-hard-limit */
ret = snap_max_hard_limit_set_commit (dict, hard_limit,
- volname, op_errstr);
+ volname,
+ op_errstr);
if (ret) {
gf_log (this->name, GF_LOG_ERROR,
"snap-max-hard-limit set "
@@ -4100,10 +4111,11 @@ glusterd_snapshot_config_commit (dict_t *dict, char **op_errstr,
ret = glusterd_store_global_info (this);
if (ret) {
- snprintf (err_str, PATH_MAX,"Failed to store "
+ snprintf (err_str, PATH_MAX, "Failed to store "
"snap-max-soft-limit for system");
*op_errstr = gf_strdup (err_str);
- gf_log (this->name, GF_LOG_ERROR, "%s", err_str);
+ gf_log (this->name, GF_LOG_ERROR, "%s",
+ err_str);
goto out;
}
}
@@ -4271,10 +4283,10 @@ glusterd_get_brick_lvm_details (dict_t *rsp_dict,
ret = 0;
-end :
+end:
runner_end (&runner);
-out :
+out:
if (ret && value) {
GF_FREE (value);
}
@@ -4288,15 +4300,15 @@ glusterd_get_single_brick_status (char **op_errstr, dict_t *rsp_dict,
glusterd_volinfo_t *snap_volinfo,
glusterd_brickinfo_t *brickinfo)
{
- int ret = -1;
- xlator_t *this = NULL;
- glusterd_conf_t *priv = NULL;
- char key[PATH_MAX] = "";
- char *device = NULL;
- char *value = NULL;
- char brick_path[PATH_MAX]= "";
- char pidfile[PATH_MAX] = "";
- pid_t pid = -1;
+ int ret = -1;
+ xlator_t *this = NULL;
+ glusterd_conf_t *priv = NULL;
+ char key[PATH_MAX] = "";
+ char *device = NULL;
+ char *value = NULL;
+ char brick_path[PATH_MAX] = "";
+ char pidfile[PATH_MAX] = "";
+ pid_t pid = -1;
this = THIS;
GF_ASSERT (this);
@@ -4316,7 +4328,7 @@ glusterd_get_single_brick_status (char **op_errstr, dict_t *rsp_dict,
}
ret = snprintf (brick_path, sizeof (brick_path),
- "%s:%s",brickinfo->hostname, brickinfo->path);
+ "%s:%s", brickinfo->hostname, brickinfo->path);
if (ret < 0) {
goto out;
}
@@ -4421,7 +4433,7 @@ glusterd_get_single_brick_status (char **op_errstr, dict_t *rsp_dict,
"brick LVM details");
goto out;
}
-out :
+out:
if (ret && value) {
GF_FREE (value);
}
@@ -4504,7 +4516,7 @@ glusterd_get_single_snap_status (char **op_errstr, dict_t *rsp_dict,
goto out;
}
-out :
+out:
return ret;
}
@@ -4533,7 +4545,7 @@ glusterd_get_each_snap_object_status (char **op_errstr, dict_t *rsp_dict,
goto out;
}
- temp = gf_strdup (snap -> snapname);
+ temp = gf_strdup (snap->snapname);
if (temp == NULL) {
ret = -1;
goto out;
@@ -4552,7 +4564,7 @@ glusterd_get_each_snap_object_status (char **op_errstr, dict_t *rsp_dict,
goto out;
}
- temp = gf_strdup (uuid_utoa(snap -> snap_id));
+ temp = gf_strdup (uuid_utoa (snap->snap_id));
if (temp == NULL) {
ret = -1;
goto out;
@@ -4585,7 +4597,7 @@ glusterd_get_each_snap_object_status (char **op_errstr, dict_t *rsp_dict,
gf_log (this->name, GF_LOG_ERROR, "Could not save volcount");
goto out;
}
-out :
+out:
if (ret && temp)
GF_FREE (temp);
@@ -4645,7 +4657,7 @@ glusterd_get_snap_status_of_volume (char **op_errstr, dict_t *rsp_dict,
ret = -1;
goto out;
}
-out :
+out:
return ret;
}
@@ -4695,7 +4707,7 @@ glusterd_get_all_snapshot_status (dict_t *dict, char **op_errstr,
}
ret = 0;
-out :
+out:
return ret;
}
@@ -4798,7 +4810,7 @@ glusterd_snapshot_status_commit (dict_t *dict, char **op_errstr,
}
}
ret = 0;
-out :
+out:
return ret;
}
@@ -4855,7 +4867,7 @@ glusterd_snapshot (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
GF_ASSERT (this);
GF_ASSERT (dict);
- GF_ASSERT (rsp_dict); //not sure if this is needed, verify.
+ GF_ASSERT (rsp_dict);
priv = this->private;
GF_ASSERT (priv);
@@ -4942,7 +4954,8 @@ glusterd_snapshot_brickop (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
GF_ASSERT (this);
GF_ASSERT (dict);
- GF_ASSERT (rsp_dict); //not sure if this is needed, verify.
+ GF_ASSERT (rsp_dict);
+
ret = dict_get_int32 (dict, "type", &snap_command);
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "unable to get the type of "
@@ -4951,39 +4964,37 @@ glusterd_snapshot_brickop (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
}
switch (snap_command) {
- case GF_SNAP_OPTION_TYPE_CREATE:
- {
- ret = dict_get_int64 (dict, "volcount", &vol_count);
- if (ret)
- goto out;
- while (count <= vol_count) {
- snprintf (key, 1024, "volname%"PRId64, count);
- ret = dict_get_str (dict, key, &volname);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Unable to get volname");
- goto out;
- }
- ret = dict_set_str (dict, "volname", volname);
- if (ret)
- goto out;
-
- ret = gd_brick_op_phase (GD_OP_SNAP, NULL, dict,
- op_errstr);
- if (ret)
- goto out;
- volname = NULL;
- count++;
- }
-
- dict_del (dict, "volname");
- ret = 0;
- break;
- }
- case GF_SNAP_OPTION_TYPE_DELETE:
- break;
- default:
- break;
+ case GF_SNAP_OPTION_TYPE_CREATE:
+ ret = dict_get_int64 (dict, "volcount", &vol_count);
+ if (ret)
+ goto out;
+ while (count <= vol_count) {
+ snprintf (key, 1024, "volname%"PRId64, count);
+ ret = dict_get_str (dict, key, &volname);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "Unable to get volname");
+ goto out;
+ }
+ ret = dict_set_str (dict, "volname", volname);
+ if (ret)
+ goto out;
+
+ ret = gd_brick_op_phase (GD_OP_SNAP, NULL, dict,
+ op_errstr);
+ if (ret)
+ goto out;
+ volname = NULL;
+ count++;
+ }
+
+ dict_del (dict, "volname");
+ ret = 0;
+ break;
+ case GF_SNAP_OPTION_TYPE_DELETE:
+ break;
+ default:
+ break;
}
out:
@@ -5002,7 +5013,7 @@ glusterd_snapshot_prevalidate (dict_t *dict, char **op_errstr,
GF_ASSERT (this);
GF_ASSERT (dict);
- GF_ASSERT (rsp_dict); //not sure if this is needed, verify.
+ GF_ASSERT (rsp_dict);
ret = dict_get_int32 (dict, "type", &snap_command);
if (ret) {
@@ -5082,7 +5093,7 @@ glusterd_snapshot_postvalidate (dict_t *dict, int32_t op_ret, char **op_errstr,
GF_ASSERT (this);
GF_ASSERT (dict);
- GF_ASSERT (rsp_dict); //not sure if this is needed, verify.
+ GF_ASSERT (rsp_dict);
ret = dict_get_int32 (dict, "type", &snap_command);
if (ret) {
@@ -5529,8 +5540,8 @@ glusterd_add_missed_snaps_to_list (dict_t *dict, int32_t missed_snap_count)
* is resent to the non-originator nodes */
tmp = gf_strdup (buf);
if (!tmp) {
- ret = -1;
- goto out;
+ ret = -1;
+ goto out;
}
/* Fetch the node-id, snap-id, brick_num,
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index 2340c40..1c2ec58 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -2209,8 +2209,7 @@ out:
int
-glusterd_store_update_volinfo (glusterd_volinfo_t *volinfo,
- glusterd_snap_t *snap)
+glusterd_store_update_volinfo (glusterd_volinfo_t *volinfo)
{
int ret = -1;
int exists = 0;
@@ -2456,7 +2455,7 @@ glusterd_store_retrieve_volume (char *volname, glusterd_snap_t *snap)
if (snap)
volinfo->is_snap_volume = _gf_true;
- ret = glusterd_store_update_volinfo (volinfo, snap);
+ ret = glusterd_store_update_volinfo (volinfo);
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "Failed to update volinfo "
"for %s volume", volname);
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.h b/xlators/mgmt/glusterd/src/glusterd-store.h
index e46d712..1b5cebc 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.h
+++ b/xlators/mgmt/glusterd/src/glusterd-store.h
@@ -142,9 +142,6 @@ glusterd_store_global_info (xlator_t *this);
int32_t
glusterd_store_retrieve_options (xlator_t *this);
-int
-glusterd_store_update_volinfo (glusterd_volinfo_t *volinfo,
- glusterd_snap_t *snap);
int32_t
glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo);
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 905ac6e..e8ae058 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -5013,35 +5013,33 @@ glusterd_get_brick_mount_details (glusterd_brickinfo_t *brickinfo)
char *device = NULL;
FILE *mtab = NULL;
struct mntent *entry = NULL;
+ xlator_t *this = NULL;
- ret = glusterd_get_brick_root (brickinfo->path, &mnt_pt);
- if (ret)
- goto out;
+ this = THIS;
+ GF_ASSERT (this);
+ GF_ASSERT (brickinfo);
- mtab = setmntent (_PATH_MOUNTED, "r");
- if (!mtab) {
- ret = -1;
+ ret = glusterd_get_brick_root (brickinfo->path, &mnt_pt);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "Failed to get mount point "
+ "for %s brick", brickinfo->path);
goto out;
}
- entry = getmntent (mtab);
-
- while (1) {
- if (!entry) {
- ret = -1;
- goto out;
- }
- if (!strcmp (entry->mnt_dir, mnt_pt) &&
- strcmp (entry->mnt_type, "rootfs"))
- break;
- entry = getmntent (mtab);
+ entry = glusterd_get_mnt_entry_info (mnt_pt, mtab);
+ if (NULL == entry) {
+ gf_log (this->name, GF_LOG_ERROR, "Failed to get mnt entry "
+ "for %s mount path", mnt_pt);
+ goto out;
}
-
/* get the fs_name/device */
device = gf_strdup (entry->mnt_fsname);
out:
+ if (NULL != mtab) {
+ endmntent (mtab);
+ }
return device;
}