summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-snapshot.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-snapshot.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c371
1 files changed, 191 insertions, 180 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index a6c79e4ec..9b811cd05 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,