summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handshake.c50
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c28
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.h10
3 files changed, 62 insertions, 26 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c
index 115dd8bd145..7be1e9017bd 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handshake.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c
@@ -347,16 +347,17 @@ int32_t
glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo,
glusterd_snap_op_t *snap_opinfo)
{
- char *device = NULL;
- glusterd_conf_t *priv = NULL;
- glusterd_snap_t *snap = NULL;
- glusterd_volinfo_t *snap_vol = NULL;
- glusterd_volinfo_t *volinfo = NULL;
- glusterd_brickinfo_t *brickinfo = NULL;
- int32_t ret = -1;
- int32_t i = 0;
- uuid_t snap_uuid = {0,};
- xlator_t *this = NULL;
+ char *device = NULL;
+ char fstype[NAME_MAX] = "";
+ glusterd_conf_t *priv = NULL;
+ glusterd_snap_t *snap = NULL;
+ glusterd_volinfo_t *snap_vol = NULL;
+ glusterd_volinfo_t *volinfo = NULL;
+ glusterd_brickinfo_t *brickinfo = NULL;
+ int32_t ret = -1;
+ int32_t i = 0;
+ uuid_t snap_uuid = {0,};
+ xlator_t *this = NULL;
this = THIS;
GF_ASSERT (this);
@@ -431,6 +432,18 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo,
strncpy (brickinfo->device_path, device,
sizeof(brickinfo->device_path));
+ /* Update the backend file-system type of snap brick in
+ * snap volinfo. */
+ ret = glusterd_update_fstype (snap_opinfo->brick_path, brickinfo,
+ fstype, sizeof(fstype));
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "Failed to update "
+ "file-system type for %s brick",
+ brickinfo->path);
+ /* We should not fail snapshot operation if we fail to get
+ * the file-system type */
+ }
+
ret = glusterd_take_lvm_snapshot (brickinfo, snap_opinfo->brick_path);
if (ret) {
gf_log (this->name, GF_LOG_ERROR,
@@ -439,6 +452,21 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo,
goto out;
}
+ /* After the snapshot both the origin brick (LVM brick) and
+ * the snapshot brick will have the same file-system UUID. This
+ * will cause lot of problems at mount time. Therefore we must
+ * generate a new UUID for the snapshot brick
+ */
+ ret = glusterd_update_fs_uuid (brickinfo);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "Failed to update "
+ "file-system uuid for %s brick", brickinfo->path);
+ /* Failing to update UUID should not cause snapshot failure.
+ * Currently UUID is updated only for XFS and ext2/ext3/ext4
+ * file-system.
+ */
+ }
+
/* Create and mount the snap brick */
ret = glusterd_snap_brick_create (snap_vol, brickinfo,
snap_opinfo->brick_num - 1);
@@ -449,6 +477,7 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo,
snap_vol->snapshot->snapname);
goto out;
}
+
brickinfo->snap_status = 0;
ret = glusterd_store_volinfo (snap_vol,
GLUSTERD_VOLINFO_VER_AC_NONE);
@@ -459,7 +488,6 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo,
goto out;
}
-
ret = glusterd_brick_start (snap_vol, brickinfo, _gf_false);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "starting the "
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index 8b3ffd5b760..117004b4452 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
@@ -3767,13 +3767,13 @@ out:
*
* @return 0 on success and -1 on failure
*/
-static int
-glusterd_update_fstype (glusterd_brickinfo_t *orig_brickinfo,
- glusterd_brickinfo_t *snap_brickinfo)
+int
+glusterd_update_fstype (char *orig_brick_path,
+ glusterd_brickinfo_t *snap_brickinfo,
+ char *fstype, size_t fslen)
{
int32_t ret = -1;
char *mnt_pt = NULL;
- char *fstype = NULL;
char buff [PATH_MAX] = "";
char msg [PATH_MAX] = "";
char *cmd = NULL;
@@ -3784,19 +3784,18 @@ glusterd_update_fstype (glusterd_brickinfo_t *orig_brickinfo,
this = THIS;
GF_ASSERT (this);
- GF_ASSERT (orig_brickinfo);
+ GF_ASSERT (orig_brick_path);
GF_ASSERT (snap_brickinfo);
-
- fstype = orig_brickinfo->fstype;
+ GF_ASSERT (fstype);
/* If the file-system type is not set then set the file-system type
* in origin brickinfo */
if (0 == fstype [0]) {
- ret = glusterd_get_brick_root (orig_brickinfo->path, &mnt_pt);
+ ret = glusterd_get_brick_root (orig_brick_path, &mnt_pt);
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "getting the root "
"of the brick (%s) failed ",
- orig_brickinfo->path);
+ orig_brick_path);
goto out;
}
@@ -3805,14 +3804,14 @@ glusterd_update_fstype (glusterd_brickinfo_t *orig_brickinfo,
if (!entry) {
gf_log (this->name, GF_LOG_ERROR, "getting the mount "
"entry for the brick (%s) failed",
- orig_brickinfo->path);
+ orig_brick_path);
ret = -1;
goto out;
}
/* Update the origin brickinfo with the backend file-system
* type */
- snprintf (fstype, sizeof (orig_brickinfo->fstype), "%s",
+ snprintf (fstype, fslen, "%s",
entry->mnt_type);
}
@@ -3866,7 +3865,9 @@ glusterd_add_brick_to_snap_volume (dict_t *dict, dict_t *rsp_dict,
/* Update the backend file-system type of snap brick in
* snap volinfo. */
- ret = glusterd_update_fstype (original_brickinfo, snap_brickinfo);
+ ret = glusterd_update_fstype (original_brickinfo->path, snap_brickinfo,
+ original_brickinfo->fstype,
+ sizeof(original_brickinfo->fstype));
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "Failed to update "
"file-system type for %s brick",
@@ -3976,7 +3977,7 @@ out:
*
* @return 0 on success and -1 on failure
*/
-static int
+int
glusterd_update_fs_uuid (glusterd_brickinfo_t *brickinfo)
{
int32_t ret = -1;
@@ -4140,7 +4141,6 @@ glusterd_take_brick_snapshot (dict_t *dict, glusterd_volinfo_t *snap_vol,
*/
}
-
/* create the complete brick here */
ret = glusterd_snap_brick_create (snap_vol, brickinfo, brick_count);
if (ret) {
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
index 2a22831fe41..1764f642d3f 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
@@ -890,6 +890,7 @@ glusterd_snapd_set_online_status (glusterd_volinfo_t *volinfo,
int
glusterd_restart_snapds (glusterd_conf_t *priv);
+/* End snapd functions */
int32_t
glusterd_check_and_set_config_limit (glusterd_conf_t *priv);
@@ -897,10 +898,17 @@ glusterd_check_and_set_config_limit (glusterd_conf_t *priv);
int32_t
glusterd_is_snap_soft_limit_reached (glusterd_volinfo_t *volinfo,
dict_t *dict);
-/* End snapd functions */
int32_t
glusterd_find_brick_mount_path (char *brick_path, int32_t brick_count,
char **brick_mount_path);
+int
+glusterd_update_fstype (char *orig_brick_path,
+ glusterd_brickinfo_t *snap_brickinfo,
+ char *fstype, size_t fslen);
+
+int
+glusterd_update_fs_uuid (glusterd_brickinfo_t *brickinfo);
+
#endif