From aaa3fd144f5f4495cf890918aa6b44472f559ba4 Mon Sep 17 00:00:00 2001 From: Vijaikumar M Date: Thu, 3 Apr 2014 12:45:45 +0530 Subject: glusterd/snapshot: code cleanup and fixes for review comments Change-Id: I358c30b42e71e5e1ddaeb5a3954bdd590671839b Signed-off-by: Vijaikumar M Reviewed-on: http://review.gluster.org/7386 Reviewed-by: Avra Sengupta Reviewed-by: Rajesh Joseph Tested-by: Rajesh Joseph --- xlators/mgmt/glusterd/src/glusterd-snapshot.c | 213 +++++++++++--------------- xlators/mgmt/glusterd/src/glusterd-volgen.c | 159 ------------------- 2 files changed, 86 insertions(+), 286 deletions(-) diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c index 5a0041535..e8587b55b 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c @@ -137,7 +137,7 @@ glusterd_snapshot_restore (dict_t *dict, char **op_errstr, dict_t *rsp_dict) goto out; } - ret = 0; /* Success */ + ret = 0; /* TODO: Need to check if we need to delete the snap after the * operation is successful or not. Also need to persist the state @@ -200,7 +200,7 @@ glusterd_snapshot_restore_prevalidate (dict_t *dict, char **op_errstr, snap_restored = snap->snap_restored; if (snap_restored) { - ret = gf_asprintf (op_errstr, "Snap (%s) already " + ret = gf_asprintf (op_errstr, "Snap (%s) is already " "restored", snapname); if (ret < 0) { goto out; @@ -224,9 +224,8 @@ glusterd_snapshot_restore_prevalidate (dict_t *dict, char **op_errstr, goto out; } - /* Snapshot restore will only work if the volume is stopped. - * If volume is running then snapshot restore will fail. - */ + /* Snapshot restore will only work if all the volumes, + that are part of the snapshot, are stopped. */ for (i = 1; i <= volcount; ++i) { snprintf (key, sizeof (key), "volname%d", i); ret = dict_get_str (dict, key, &volname); @@ -402,7 +401,7 @@ glusterd_snapshot_config_prevalidate (dict_t *dict, char **op_errstr) break; } - ret = 0; /* Success */ + ret = 0; out: if (ret && err_str[0] != '\0') { @@ -1096,7 +1095,7 @@ glusterd_snap_volume_remove (dict_t *rsp_dict, gf_boolean_t force) { int ret = -1; - int ret_1 = 0; + int save_ret = 0; glusterd_brickinfo_t *brickinfo = NULL; glusterd_volinfo_t *origin_vol = NULL; xlator_t *this = NULL; @@ -1108,7 +1107,7 @@ glusterd_snap_volume_remove (dict_t *rsp_dict, if (!snap_vol) { gf_log(this->name, GF_LOG_WARNING, "snap_vol in NULL"); - ret_1 = -1; + ret = -1; goto out; } @@ -1120,7 +1119,7 @@ glusterd_snap_volume_remove (dict_t *rsp_dict, if (ret) { gf_log(this->name, GF_LOG_WARNING, "Failed to stop " "brick for volume %s", snap_vol->volname); - ret_1 = ret; + save_ret = ret; /* Continue to cleaning up the snap in case of error if force flag is enabled */ @@ -1135,7 +1134,7 @@ glusterd_snap_volume_remove (dict_t *rsp_dict, if (ret) { gf_log(this->name, GF_LOG_WARNING, "Failed to remove " "lvm snapshot volume %s", snap_vol->volname); - ret_1 = ret; + save_ret = ret; if (!force) goto out; } @@ -1145,7 +1144,7 @@ glusterd_snap_volume_remove (dict_t *rsp_dict, if (ret) { gf_log(this->name, GF_LOG_WARNING, "Failed to remove volume %s " "from store", snap_vol->volname); - ret_1 = ret; + save_ret = ret; if (!force) goto out; } @@ -1157,7 +1156,7 @@ glusterd_snap_volume_remove (dict_t *rsp_dict, gf_log (this->name, GF_LOG_ERROR, "Failed to get " "parent volinfo %s for volume %s", snap_vol->parent_volname, snap_vol->volname); - ret_1 = ret; + save_ret = ret; if (!force) goto out; } @@ -1168,21 +1167,23 @@ glusterd_snap_volume_remove (dict_t *rsp_dict, if (ret) { gf_log(this->name, GF_LOG_WARNING, "Failed to remove volinfo " "%s ", snap_vol->volname); - ret_1 = ret; + save_ret = ret; if (!force) goto out; } + if (save_ret) + ret = save_ret; out: - gf_log (this->name, GF_LOG_TRACE, "returning %d", ret_1); - return ret_1; + gf_log (this->name, GF_LOG_TRACE, "returning %d", ret); + return ret; } int32_t glusterd_snapobject_delete (glusterd_snap_t *snap) { if (snap == NULL) { - gf_log(THIS->name, GF_LOG_WARNING, "snap in NULL"); + gf_log(THIS->name, GF_LOG_WARNING, "snap is NULL"); return -1; } @@ -1205,7 +1206,7 @@ glusterd_snap_remove (dict_t *rsp_dict, gf_boolean_t force) { int ret = -1; - int ret_1 = 0; + int save_ret = 0; glusterd_volinfo_t *snap_vol = NULL; glusterd_volinfo_t *tmp = NULL; xlator_t *this = NULL; @@ -1216,8 +1217,8 @@ glusterd_snap_remove (dict_t *rsp_dict, GF_ASSERT (snap); if (!snap) { - gf_log(this->name, GF_LOG_WARNING, "snap in NULL"); - ret_1 = -1; + gf_log(this->name, GF_LOG_WARNING, "snap is NULL"); + ret = -1; goto out; } @@ -1228,7 +1229,7 @@ glusterd_snap_remove (dict_t *rsp_dict, gf_log(this->name, GF_LOG_WARNING, "Failed to remove " "volinfo %s for snap %s", snap_vol->volname, snap->snapname); - ret_1 = ret; + save_ret = ret; /* Continue to cleaning up the snap in case of error if force flag is enabled */ @@ -1241,7 +1242,7 @@ glusterd_snap_remove (dict_t *rsp_dict, if (ret) { gf_log(this->name, GF_LOG_WARNING, "Failed to remove snap %s " "from store", snap->snapname); - ret_1 = ret; + save_ret = ret; if (!force) goto out; } @@ -1251,9 +1252,11 @@ glusterd_snap_remove (dict_t *rsp_dict, gf_log (this->name, GF_LOG_WARNING, "Failed to delete " "snap object %s", snap->snapname); + if (save_ret) + ret = save_ret; out: - gf_log (THIS->name, GF_LOG_TRACE, "returning %d", ret_1); - return ret_1; + gf_log (THIS->name, GF_LOG_TRACE, "returning %d", ret); + return ret; } static int @@ -1304,9 +1307,6 @@ glusterd_snapshot_get_snapvol_detail (dict_t *dict, "volume id in dictionary: %s", key); goto out; } - - /* Ownership of value transferred to dict. Therefore we must initialize - * it to NULL */ value = NULL; /* volume status */ @@ -1391,7 +1391,7 @@ glusterd_snapshot_get_snapvol_detail (dict_t *dict, } value = NULL; - ret = 0; /* Success */ + ret = 0; out: if (value) GF_FREE (value); @@ -1446,13 +1446,8 @@ glusterd_snapshot_get_snap_detail (dict_t *dict, glusterd_snap_t *snap, "snap id in dictionary"); goto out; } - - /* Ownership of value transferred to dict. Therefore we must initalize - * it to NULL */ value = NULL; - /* Snap Timestamp */ - /* convert time_t to tm struct. */ tmptr = localtime (&(snap->time_stamp)); if (NULL == tmptr) { gf_log (this->name, GF_LOG_ERROR, "Failed to convert " @@ -1467,7 +1462,6 @@ glusterd_snapshot_get_snap_detail (dict_t *dict, glusterd_snap_t *snap, goto out; } - /* Format time into string */ ret = strftime (timestr, PATH_MAX, "%Y-%m-%d %H:%M:%S", tmptr); if (0 == ret) { gf_log (this->name, GF_LOG_ERROR, "Failed to convert time_t " @@ -1483,9 +1477,6 @@ glusterd_snapshot_get_snap_detail (dict_t *dict, glusterd_snap_t *snap, "snap time stamp in dictionary"); goto out; } - - /* Ownership of timestr transferred to dict. Therefore we must initalize - * it to NULL */ timestr = NULL; /* If snap description is provided then add that into dictionary */ @@ -1506,7 +1497,6 @@ glusterd_snapshot_get_snap_detail (dict_t *dict, glusterd_snap_t *snap, value = NULL; } - /* Snap status */ snprintf (key, sizeof (key), "%s.snap-status", keyprefix); switch (snap->snap_status) { case GD_SNAP_STATUS_INIT: @@ -1572,7 +1562,7 @@ done: goto out; } - ret = 0; /* Success */ + ret = 0; out: if (value) GF_FREE (value); @@ -1618,7 +1608,7 @@ glusterd_snapshot_get_all_snap_info (dict_t *dict) goto out; } - ret = 0; /* Success */ + ret = 0; out: return ret; } @@ -1830,7 +1820,8 @@ glusterd_handle_snapshot_info (rpcsvc_request_t *req, glusterd_op_t op, } /* If everything is successful then send the response back to cli. - * In case of failure the caller of this function will take of response.*/ + * In case of failure the caller of this function will take care + of the response */ ret = glusterd_op_send_cli_response (op, 0, 0, req, dict, err_str); if (ret) { gf_log (this->name, GF_LOG_ERROR, "Failed to send cli " @@ -1838,16 +1829,15 @@ glusterd_handle_snapshot_info (rpcsvc_request_t *req, glusterd_op_t op, goto out; } - ret = 0; /* Success */ + ret = 0; out: return ret; } -/* Function glusterd_snapshot_get_list1 sets all the snapshot names - in the dictionary */ +/* This function sets all the snapshot names in the dictionary */ int -glusterd_snapshot_get_list1 (dict_t *dict) +glusterd_snapshot_get_all_snapnames (dict_t *dict) { int ret = -1; int snapcount = 0; @@ -1893,10 +1883,10 @@ out: return ret; } -/* Function glusterd_snapshot_get_list2 sets all the snapshot names +/* This function sets all the snapshot names under a given volume in the dictionary */ int -glusterd_snapshot_get_list2 (dict_t *dict, glusterd_volinfo_t *volinfo) +glusterd_snapshot_get_vol_snapnames (dict_t *dict, glusterd_volinfo_t *volinfo) { int ret = -1; int snapcount = 0; @@ -1960,7 +1950,7 @@ glusterd_handle_snapshot_list (rpcsvc_request_t *req, glusterd_op_t op, ret = dict_get_str (dict, "volname", &volname); if (NULL == volname) { - ret = glusterd_snapshot_get_list1 (dict); + ret = glusterd_snapshot_get_all_snapnames (dict); if (ret) { gf_log (this->name, GF_LOG_ERROR, "Failed to get snapshot list"); @@ -1976,7 +1966,7 @@ glusterd_handle_snapshot_list (rpcsvc_request_t *req, glusterd_op_t op, goto out; } - ret = glusterd_snapshot_get_list2 (dict, volinfo); + ret = glusterd_snapshot_get_vol_snapnames (dict, volinfo); if (ret) { gf_log (this->name, GF_LOG_ERROR, "Failed to get snapshot list for volume %s", @@ -1994,7 +1984,7 @@ glusterd_handle_snapshot_list (rpcsvc_request_t *req, glusterd_op_t op, goto out; } - ret = 0; /* Success */ + ret = 0; out: return ret; @@ -2329,7 +2319,7 @@ glusterd_handle_snapshot_status (rpcsvc_request_t *req, glusterd_op_t op, goto out; } - ret = 0; /* Success */ + ret = 0; out : if (voldict) { @@ -2400,7 +2390,8 @@ glusterd_handle_snapshot_restore (rpcsvc_request_t *req, glusterd_op_t op, ret = dict_set_dynstr (dict, key, buf); if (ret) { gf_log (this->name, GF_LOG_ERROR, "Could not set " - "parent volume name"); + "parent volume name %s in the dict", + snap_volinfo->parent_volname); GF_FREE (buf); goto out; } @@ -2421,7 +2412,7 @@ glusterd_handle_snapshot_restore (rpcsvc_request_t *req, glusterd_op_t op, goto out; } - ret = 0; /* Success */ + ret = 0; out: return ret; @@ -2592,11 +2583,7 @@ glusterd_build_snap_device_path (char *device, char *snapname) } runner_end (&runner); - strcpy(snap, "/dev/"); - strcat(snap, gf_trim(volgroup)); - strcat(snap, "/"); - strcat(snap, 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 " @@ -2715,8 +2702,6 @@ glusterd_snap_brick_create (char *device, glusterd_volinfo_t *snap_volinfo, char snap_brick_mount_path[PATH_MAX] = ""; char snap_brick_path[PATH_MAX] = ""; char msg[1024] = ""; - char *mnt_pt = NULL; - FILE *mtab = NULL; struct stat statbuf = {0, }; runner_t runner = {0, }; @@ -2795,11 +2780,8 @@ out: " mount %s", snap_brick_mount_path); umount (snap_brick_mount_path); } - if (mtab) - endmntent (mtab); gf_log ("", GF_LOG_TRACE, "Returning %d", ret); - GF_FREE (mnt_pt); return ret; } @@ -2880,6 +2862,7 @@ glusterd_add_bricks_to_snap_volume (dict_t *dict, dict_t *rsp_dict, char key[PATH_MAX] = ""; char snap_brick_path[PATH_MAX] = ""; char *snap_device = NULL; + gf_boolean_t add_missed_snap = _gf_false; int32_t ret = -1; xlator_t *this = NULL; @@ -2908,21 +2891,8 @@ glusterd_add_bricks_to_snap_volume (dict_t *dict, dict_t *rsp_dict, /* In origiator node add snaps missed * from different nodes to the dict */ - if (is_origin_glusterd (dict) == _gf_true) { - ret = glusterd_add_missed_snaps_to_dict - (rsp_dict, snap_vol->volname, - original_brickinfo, - brick_count + 1, - GF_SNAP_OPTION_TYPE_CREATE); - if (ret) { - gf_log (this->name, GF_LOG_ERROR, - "Failed to add missed snapshot info " - "for %s:%s in the rsp_dict", - original_brickinfo->hostname, - original_brickinfo->path); - goto out; - } - } + if (is_origin_glusterd (dict) == _gf_true) + add_missed_snap = _gf_true; } else { /* Create brick-path in the format /var/run/gluster/snaps/ * * //snap-brick-dir * @@ -2933,6 +2903,36 @@ glusterd_add_bricks_to_snap_volume (dict_t *dict, dict_t *rsp_dict, *snap_brick_dir); } + if ((snap_brickinfo->snap_status != -1) && + (!uuid_compare (original_brickinfo->uuid, MY_UUID)) && + (!glusterd_is_brick_started (original_brickinfo))) { + /* In case if the brick goes down after prevalidate. */ + gf_log (this->name, GF_LOG_WARNING, "brick %s:%s is not" + " started (snap: %s)", + original_brickinfo->hostname, + original_brickinfo->path, + snap_vol->snapshot->snapname); + + snap_brickinfo->snap_status = -1; + strcpy (snap_brick_path, original_brickinfo->path); + add_missed_snap = _gf_true; + } + + if (add_missed_snap) { + ret = glusterd_add_missed_snaps_to_dict (rsp_dict, + snap_vol->volname, + original_brickinfo, + brick_count + 1, + GF_SNAP_OPTION_TYPE_CREATE); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, "Failed to add missed" + " snapshot info for %s:%s in the rsp_dict", + original_brickinfo->hostname, + original_brickinfo->path); + goto out; + } + } + snprintf (key, sizeof(key), "vol%ld.brick_snapdevice%d", volcount, brick_count); ret = dict_get_ptr (dict, key, (void **)&snap_device); @@ -2945,14 +2945,6 @@ glusterd_add_bricks_to_snap_volume (dict_t *dict, dict_t *rsp_dict, } else strcpy (snap_brickinfo->device_path, snap_device); - /* Create brick-path in the format /var/run/gluster/snaps/ * - * //snap-brick-dir * - */ - snprintf (snap_brick_path, sizeof(snap_brick_path), - "%s/%s/brick%d%s", snap_mount_folder, - snap_vol->volname, brick_count+1, - *snap_brick_dir); - ret = gf_canonicalize_path (snap_brick_path); if (ret) { gf_log (this->name, GF_LOG_ERROR, @@ -2990,35 +2982,6 @@ glusterd_take_brick_snapshot (glusterd_volinfo_t *origin_vol, GF_ASSERT (snap_brickinfo); GF_ASSERT (snap_brick_dir); - if (!glusterd_is_brick_started (original_brickinfo)) { - gf_log (this->name, GF_LOG_WARNING, "brick %s:%s is not" - " started (volume: %s snap: %s)", - original_brickinfo->hostname, - original_brickinfo->path, - origin_vol->volname, - snap_vol->snapshot->snapname); - - /* Adding the not started bricks to the missed snaps list */ - ret = glusterd_add_missed_snaps_to_dict - (rsp_dict, - snap_vol->volname, - original_brickinfo, - brick_count + 1, - GF_SNAP_OPTION_TYPE_CREATE); - if (ret) { - gf_log (this->name, GF_LOG_ERROR, - "Failed to add missed snapshot info " - "for %s:%s in the rsp_dict", - original_brickinfo->hostname, - original_brickinfo->path); - goto out; - } - - snap_brickinfo->snap_status = -1; - ret = 0; - goto out; - } - device = glusterd_take_lvm_snapshot (snap_vol, original_brickinfo); /* Fail the snapshot even though snapshot on one of the bricks fails. At the end when we check whether @@ -3251,7 +3214,7 @@ glusterd_do_snap_vol (glusterd_volinfo_t *origin_vol, glusterd_snap_t *snap, goto out; } - ret = generate_snap_brick_volfiles (origin_vol, snap_vol); + ret = generate_brick_volfiles (snap_vol); if (ret) { gf_log (this->name, GF_LOG_ERROR, "generating the brick " "volfiles for the snap %s (volume: %s) failed", @@ -3259,16 +3222,14 @@ glusterd_do_snap_vol (glusterd_volinfo_t *origin_vol, glusterd_snap_t *snap, goto out; } - ret = generate_snap_client_volfiles (origin_vol, snap_vol, - GF_CLIENT_TRUSTED, _gf_false); + ret = generate_client_volfiles (snap_vol, GF_CLIENT_TRUSTED); if (ret) { gf_log (this->name, GF_LOG_ERROR, "generating the trusted " "client volfiles for the snap %s (volume: %s) failed", snap->snapname, origin_vol->volname); goto out; } - ret = generate_snap_client_volfiles (origin_vol, snap_vol, - GF_CLIENT_OTHER, _gf_false); + ret = generate_client_volfiles (snap_vol, GF_CLIENT_OTHER); if (ret) { gf_log (this->name, GF_LOG_ERROR, "generating the client " "volfiles for the snap %s (volume: %s) failed", @@ -3307,7 +3268,8 @@ glusterd_do_snap_vol (glusterd_volinfo_t *origin_vol, glusterd_snap_t *snap, } snap_vol->status = GLUSTERD_STATUS_STARTED; - ret = glusterd_store_volinfo (snap_vol, GLUSTERD_VOLINFO_VER_AC_INCREMENT); + ret = glusterd_store_volinfo (snap_vol, + GLUSTERD_VOLINFO_VER_AC_INCREMENT); if (ret) { gf_log (this->name, GF_LOG_ERROR, "Failed to store snap volinfo"); @@ -3405,7 +3367,7 @@ glusterd_handle_snapshot_remove (rpcsvc_request_t *req, glusterd_op_t op, goto out; } - ret = 0; /* Success */ + ret = 0; out: return ret; } @@ -4381,10 +4343,6 @@ glusterd_get_single_brick_status (char **op_errstr, dict_t *rsp_dict, ret = 0; goto out; } - - /* Ownership has been transferred to dict*. Therefore we must - * initialize this to NULL - */ value = NULL; ret = snprintf (key, sizeof (key), "%s.brick%d.status", @@ -4712,7 +4670,8 @@ glusterd_get_all_snapshot_status (dict_t *dict, char **op_errstr, if (ret) { gf_log (this->name, GF_LOG_ERROR, "Could not get " - "snap object details"); + "the details of a snap object: %s", + snap->snapname); goto out; } i++; @@ -4724,7 +4683,7 @@ glusterd_get_all_snapshot_status (dict_t *dict, char **op_errstr, goto out; } - ret = 0; /* Success */ + ret = 0; out : return ret; } diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index be5efd60c..6f3c69e7d 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -3175,40 +3175,6 @@ glusterd_generate_brick_volfile (glusterd_volinfo_t *volinfo, return ret; } -static int -glusterd_generate_snap_brick_volfile (glusterd_volinfo_t *volinfo, - glusterd_brickinfo_t *brickinfo, - glusterd_volinfo_t *snap_volinfo) -{ - volgen_graph_t graph = {0,}; - char filename[PATH_MAX] = {0,}; - int ret = -1; - char path[PATH_MAX] = {0,}; - char brick[PATH_MAX] = {0,}; - glusterd_conf_t *priv = NULL; - - priv = THIS->private; - GF_ASSERT (volinfo); - GF_ASSERT (brickinfo); - - GLUSTERD_REMOVE_SLASH_FROM_PATH (brickinfo->path, brick); - GLUSTERD_GET_VOLUME_DIR (path, snap_volinfo, priv); - - snprintf (filename, PATH_MAX, "%s/%s.%s.%s.vol", - path, snap_volinfo->volname, - brickinfo->hostname, - brick); - - ret = build_server_graph (&graph, snap_volinfo, NULL, brickinfo); - if (!ret) - ret = volgen_write_volfile (&graph, filename); - - volgen_graph_free (&graph); - - return ret; -} - - static void get_vol_tstamp_file (char *filename, glusterd_volinfo_t *volinfo) { @@ -3276,32 +3242,6 @@ out: return ret; } -int -generate_snap_brick_volfiles (glusterd_volinfo_t *volinfo, - glusterd_volinfo_t *snap_volinfo) -{ - glusterd_brickinfo_t *brickinfo = NULL; - int ret = -1; - - list_for_each_entry (brickinfo, &snap_volinfo->bricks, brick_list) { - gf_log ("", GF_LOG_DEBUG, - "Found a brick - %s:%s", brickinfo->hostname, - brickinfo->path); - - ret = glusterd_generate_snap_brick_volfile (volinfo, - brickinfo, - snap_volinfo); - if (ret) - goto out; - } - - ret = 0; - -out: - gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); - return ret; -} - static int generate_single_transport_client_volfile (glusterd_volinfo_t *volinfo, char *filepath, dict_t *dict) @@ -3383,105 +3323,6 @@ out: return ret; } -int -generate_snap_client_volfiles (glusterd_volinfo_t *actual_volinfo, - glusterd_volinfo_t *snap_volinfo, - glusterd_client_type_t client_type, - gf_boolean_t vol_restore) -{ - char filepath[PATH_MAX] = {0,}; - int ret = -1; - char *types[] = {NULL, NULL, NULL}; - int i = 0; - dict_t *dict = NULL; - gf_transport_type type = GF_TRANSPORT_TCP; - char path[PATH_MAX] = {0, }; - xlator_t *this = NULL; - glusterd_conf_t *conf = NULL; - - this = THIS; - GF_ASSERT (this); - conf = this->private; - GF_ASSERT (conf); - - if (!actual_volinfo) { - gf_log (this->name, GF_LOG_ERROR, "actual volinfo is NULL." - "Unable to generate the client volfiles for snap"); - goto out; - } - - if (!snap_volinfo) { - gf_log (this->name, GF_LOG_ERROR, "snap volinfo is NULL. Unable" - "to generate the client volfiles for snap (volume: %s)", - actual_volinfo->volname); - goto out; - } - - enumerate_transport_reqs (actual_volinfo->transport_type, types); - dict = dict_new (); - if (!dict) - goto out; - - /* If the brick volfile is generated as part of a restore - * operation then we should be generating the brick volfile - * in the origin volume folder instead of snap volume folder. - */ - if (vol_restore) { - GLUSTERD_GET_VOLUME_DIR (path, actual_volinfo, conf); - } else { - GLUSTERD_GET_VOLUME_DIR (path, snap_volinfo, conf); - } - - for (i = 0; types[i]; i++) { - memset (filepath, 0, sizeof (filepath)); - ret = dict_set_str (dict, "client-transport-type", types[i]); - if (ret) - goto out; - type = transport_str_to_type (types[i]); - - ret = dict_set_uint32 (dict, "trusted-client", client_type); - if (ret) - goto out; - - if (client_type == GF_CLIENT_TRUSTED) { - if ((actual_volinfo->transport_type == - GF_TRANSPORT_BOTH_TCP_RDMA) && - type == GF_TRANSPORT_RDMA) { - snprintf (filepath, PATH_MAX, - "%s/trusted-%s.rdma-fuse.vol", - path, snap_volinfo->volname); - } else { - snprintf (filepath, PATH_MAX, - "%s/trusted-%s-fuse.vol", - path, snap_volinfo->volname); - } - } else { - if ((actual_volinfo->transport_type == - GF_TRANSPORT_BOTH_TCP_RDMA) && - (type == GF_TRANSPORT_RDMA)) { - snprintf (filepath, PATH_MAX, "%s/%s.rdma-fuse.vol", - path, snap_volinfo->volname); - } else { - snprintf (filepath, PATH_MAX, "%s/%s-fuse.vol", - path, snap_volinfo->volname); - } - } - - ret = generate_single_transport_client_volfile (snap_volinfo, - filepath, - dict); - if (ret) - goto out; - } - -out: - if (dict) - dict_unref (dict); - - gf_log ("", GF_LOG_TRACE, "Returning %d", ret); - return ret; -} - int glusterd_create_rb_volfiles (glusterd_volinfo_t *volinfo, glusterd_brickinfo_t *brickinfo) -- cgit