|
|
a3470f |
From cbdc0b38c18583852fc9b2ca79ea5fdfa92c6ed5 Mon Sep 17 00:00:00 2001
|
|
|
a3470f |
From: Sunny Kumar <sunkumar@redhat.com>
|
|
|
a3470f |
Date: Mon, 27 Nov 2017 14:24:55 +0530
|
|
|
a3470f |
Subject: [PATCH 085/128] snapshot: Issue with other processes accessing the
|
|
|
a3470f |
mounted brick
|
|
|
a3470f |
|
|
|
a3470f |
Added code for unmount of activated snapshot brick during snapshot
|
|
|
a3470f |
deactivation process which make sense as mount point for deactivated
|
|
|
a3470f |
bricks should not exist.
|
|
|
a3470f |
|
|
|
a3470f |
Removed code for mounting newly created snapshot, as newly created
|
|
|
a3470f |
snapshots should not mount until it is activated.
|
|
|
a3470f |
|
|
|
a3470f |
Added code for mount point creation and snapshot mount during snapshot
|
|
|
a3470f |
activation.
|
|
|
a3470f |
|
|
|
a3470f |
Added validation during glusterd init for mounting only those snapshot
|
|
|
a3470f |
whose status is either STARTED or RESTORED.
|
|
|
a3470f |
|
|
|
a3470f |
During snapshot restore, mount point for stopped snap should exist as
|
|
|
a3470f |
it is required to set extended attribute.
|
|
|
a3470f |
|
|
|
a3470f |
During handshake, after getting updates from friend mount point for
|
|
|
a3470f |
activated snapshot should exist and should not for deactivated
|
|
|
a3470f |
snapshot.
|
|
|
a3470f |
|
|
|
a3470f |
While getting snap status we should show relevent information for
|
|
|
a3470f |
deactivated snapshots, after this pathch 'gluster snap status' command
|
|
|
a3470f |
will show output like-
|
|
|
a3470f |
|
|
|
a3470f |
Snap Name : snap1
|
|
|
a3470f |
Snap UUID : snap-uuid
|
|
|
a3470f |
|
|
|
a3470f |
Brick Path : server1:/run/gluster/snaps/snap-vol-name/brick
|
|
|
a3470f |
Volume Group : N/A (Deactivated Snapshot)
|
|
|
a3470f |
Brick Running : No
|
|
|
a3470f |
Brick PID : N/A
|
|
|
a3470f |
Data Percentage : N/A
|
|
|
a3470f |
LV Size : N/A
|
|
|
a3470f |
|
|
|
a3470f |
Fixes: #276
|
|
|
a3470f |
|
|
|
a3470f |
>BUG: 1482023
|
|
|
a3470f |
>Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
|
|
|
a3470f |
upstream patch : https://review.gluster.org/18047
|
|
|
a3470f |
|
|
|
a3470f |
Change-Id: I65783488e35fac43632615ce1b8ff7b8e84834dc
|
|
|
a3470f |
BUG: 1464150
|
|
|
a3470f |
Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
|
|
|
a3470f |
Reviewed-on: https://code.engineering.redhat.com/gerrit/124305
|
|
|
a3470f |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
a3470f |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
a3470f |
---
|
|
|
a3470f |
.../bug-1322772-real-path-fix-for-snapshot.t | 1 +
|
|
|
a3470f |
...e-with-other-processes-accessing-mounted-path.t | 114 ++++++++++++++++
|
|
|
a3470f |
.../mgmt/glusterd/src/glusterd-snapshot-utils.c | 85 ++++++++++++
|
|
|
a3470f |
.../mgmt/glusterd/src/glusterd-snapshot-utils.h | 3 +
|
|
|
a3470f |
xlators/mgmt/glusterd/src/glusterd-snapshot.c | 145 ++++++++++++++++-----
|
|
|
a3470f |
xlators/mgmt/glusterd/src/glusterd-store.c | 25 ++--
|
|
|
a3470f |
xlators/mgmt/glusterd/src/glusterd-store.h | 4 +
|
|
|
a3470f |
7 files changed, 333 insertions(+), 44 deletions(-)
|
|
|
a3470f |
create mode 100644 tests/bugs/snapshot/bug-1482023-snpashot-issue-with-other-processes-accessing-mounted-path.t
|
|
|
a3470f |
|
|
|
a3470f |
diff --git a/tests/bugs/snapshot/bug-1322772-real-path-fix-for-snapshot.t b/tests/bugs/snapshot/bug-1322772-real-path-fix-for-snapshot.t
|
|
|
a3470f |
index bf625ec..488bd46 100644
|
|
|
a3470f |
--- a/tests/bugs/snapshot/bug-1322772-real-path-fix-for-snapshot.t
|
|
|
a3470f |
+++ b/tests/bugs/snapshot/bug-1322772-real-path-fix-for-snapshot.t
|
|
|
a3470f |
@@ -26,6 +26,7 @@ EXPECT 'Started' volinfo_field $V0 'Status'
|
|
|
a3470f |
TEST $CLI volume start $V1
|
|
|
a3470f |
EXPECT 'Started' volinfo_field $V1 'Status'
|
|
|
a3470f |
|
|
|
a3470f |
+TEST $CLI snapshot config activate-on-create enable
|
|
|
a3470f |
TEST $CLI snapshot create ${V0}_snap $V0 no-timestamp
|
|
|
a3470f |
TEST $CLI snapshot create ${V1}_snap $V1 no-timestamp
|
|
|
a3470f |
|
|
|
a3470f |
diff --git a/tests/bugs/snapshot/bug-1482023-snpashot-issue-with-other-processes-accessing-mounted-path.t b/tests/bugs/snapshot/bug-1482023-snpashot-issue-with-other-processes-accessing-mounted-path.t
|
|
|
a3470f |
new file mode 100644
|
|
|
a3470f |
index 0000000..c5a0088
|
|
|
a3470f |
--- /dev/null
|
|
|
a3470f |
+++ b/tests/bugs/snapshot/bug-1482023-snpashot-issue-with-other-processes-accessing-mounted-path.t
|
|
|
a3470f |
@@ -0,0 +1,114 @@
|
|
|
a3470f |
+#!/bin/bash
|
|
|
a3470f |
+
|
|
|
a3470f |
+. $(dirname $0)/../../volume.rc
|
|
|
a3470f |
+. $(dirname $0)/../../snapshot.rc
|
|
|
a3470f |
+. $(dirname $0)/../../include.rc
|
|
|
a3470f |
+. $(dirname $0)/../../cluster.rc
|
|
|
a3470f |
+
|
|
|
a3470f |
+function create_snapshots() {
|
|
|
a3470f |
+ $CLI_1 snapshot create ${V0}_snap ${V0} no-timestamp &
|
|
|
a3470f |
+ PID_1=$!
|
|
|
a3470f |
+
|
|
|
a3470f |
+ $CLI_1 snapshot create ${V1}_snap ${V1} no-timestamp &
|
|
|
a3470f |
+ PID_2=$!
|
|
|
a3470f |
+
|
|
|
a3470f |
+ wait $PID_1 $PID_2
|
|
|
a3470f |
+}
|
|
|
a3470f |
+
|
|
|
a3470f |
+function activate_snapshots() {
|
|
|
a3470f |
+ $CLI_1 snapshot activate ${V0}_snap &
|
|
|
a3470f |
+ PID_1=$!
|
|
|
a3470f |
+
|
|
|
a3470f |
+ $CLI_1 snapshot activate ${V1}_snap &
|
|
|
a3470f |
+ PID_2=$!
|
|
|
a3470f |
+
|
|
|
a3470f |
+ wait $PID_1 $PID_2
|
|
|
a3470f |
+}
|
|
|
a3470f |
+
|
|
|
a3470f |
+function deactivate_snapshots() {
|
|
|
a3470f |
+ $CLI_1 snapshot deactivate ${V0}_snap &
|
|
|
a3470f |
+ PID_1=$!
|
|
|
a3470f |
+
|
|
|
a3470f |
+ $CLI_1 snapshot deactivate ${V1}_snap &
|
|
|
a3470f |
+ PID_2=$!
|
|
|
a3470f |
+
|
|
|
a3470f |
+ wait $PID_1 $PID_2
|
|
|
a3470f |
+}
|
|
|
a3470f |
+cleanup;
|
|
|
a3470f |
+
|
|
|
a3470f |
+TEST verify_lvm_version;
|
|
|
a3470f |
+# Create cluster with 3 nodes
|
|
|
a3470f |
+TEST launch_cluster 3;
|
|
|
a3470f |
+TEST setup_lvm 3
|
|
|
a3470f |
+
|
|
|
a3470f |
+TEST $CLI_1 peer probe $H2;
|
|
|
a3470f |
+TEST $CLI_1 peer probe $H3;
|
|
|
a3470f |
+EXPECT_WITHIN $PROBE_TIMEOUT 2 peer_count;
|
|
|
a3470f |
+
|
|
|
a3470f |
+# Create volumes
|
|
|
a3470f |
+TEST $CLI_1 volume create $V0 $H1:$L1
|
|
|
a3470f |
+TEST $CLI_2 volume create $V1 $H2:$L2 $H3:$L3
|
|
|
a3470f |
+
|
|
|
a3470f |
+# Start volumes
|
|
|
a3470f |
+TEST $CLI_1 volume start $V0
|
|
|
a3470f |
+TEST $CLI_2 volume start $V1
|
|
|
a3470f |
+
|
|
|
a3470f |
+TEST $CLI_1 snapshot config activate-on-create enable
|
|
|
a3470f |
+
|
|
|
a3470f |
+# Snapshot Operations
|
|
|
a3470f |
+create_snapshots
|
|
|
a3470f |
+
|
|
|
a3470f |
+EXPECT 'Started' snapshot_status ${V0}_snap;
|
|
|
a3470f |
+EXPECT 'Started' snapshot_status ${V1}_snap;
|
|
|
a3470f |
+
|
|
|
a3470f |
+deactivate_snapshots
|
|
|
a3470f |
+
|
|
|
a3470f |
+EXPECT 'Stopped' snapshot_status ${V0}_snap;
|
|
|
a3470f |
+EXPECT 'Stopped' snapshot_status ${V1}_snap;
|
|
|
a3470f |
+
|
|
|
a3470f |
+activate_snapshots
|
|
|
a3470f |
+
|
|
|
a3470f |
+EXPECT 'Started' snapshot_status ${V0}_snap;
|
|
|
a3470f |
+EXPECT 'Started' snapshot_status ${V1}_snap;
|
|
|
a3470f |
+
|
|
|
a3470f |
+# This Function will get snap id form snap info command and will
|
|
|
a3470f |
+# check for mount point in system against snap id.
|
|
|
a3470f |
+function mounted_snaps
|
|
|
a3470f |
+{
|
|
|
a3470f |
+ snap_id=`$CLI_1 snap info $1_snap | grep "Snap Volume Name" |
|
|
|
a3470f |
+ awk -F ":" '{print $2}'`
|
|
|
a3470f |
+ echo `mount | grep $snap_id | wc -l`
|
|
|
a3470f |
+}
|
|
|
a3470f |
+
|
|
|
a3470f |
+EXPECT "1" mounted_snaps ${V0}
|
|
|
a3470f |
+EXPECT "2" mounted_snaps ${V1}
|
|
|
a3470f |
+
|
|
|
a3470f |
+deactivate_snapshots
|
|
|
a3470f |
+
|
|
|
a3470f |
+EXPECT "0" mounted_snaps ${V0}
|
|
|
a3470f |
+EXPECT "0" mounted_snaps ${V1}
|
|
|
a3470f |
+
|
|
|
a3470f |
+# This part of test is designed to validate that updates are properly being
|
|
|
a3470f |
+# handled during handshake.
|
|
|
a3470f |
+
|
|
|
a3470f |
+activate_snapshots
|
|
|
a3470f |
+kill_glusterd 2
|
|
|
a3470f |
+deactivate_snapshots
|
|
|
a3470f |
+TEST start_glusterd 2
|
|
|
a3470f |
+
|
|
|
a3470f |
+# Updates form friend should reflect as snap was deactivated while glusterd
|
|
|
a3470f |
+# process was inactive and mount point should also not exist.
|
|
|
a3470f |
+
|
|
|
a3470f |
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "0" mounted_snaps ${V0}
|
|
|
a3470f |
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "0" mounted_snaps ${V1}
|
|
|
a3470f |
+
|
|
|
a3470f |
+kill_glusterd 2
|
|
|
a3470f |
+activate_snapshots
|
|
|
a3470f |
+TEST start_glusterd 2
|
|
|
a3470f |
+
|
|
|
a3470f |
+# Updates form friend should reflect as snap was activated while glusterd
|
|
|
a3470f |
+# process was inactive and mount point should exist.
|
|
|
a3470f |
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" mounted_snaps ${V0}
|
|
|
a3470f |
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "2" mounted_snaps ${V1}
|
|
|
a3470f |
+
|
|
|
a3470f |
+cleanup;
|
|
|
a3470f |
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
|
|
|
a3470f |
index 2a0d321..3f03d2b 100644
|
|
|
a3470f |
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
|
|
|
a3470f |
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
|
|
|
a3470f |
@@ -1678,7 +1678,21 @@ glusterd_import_friend_snap (dict_t *peer_data, int32_t snap_count,
|
|
|
a3470f |
"for snap %s", peer_snap_name);
|
|
|
a3470f |
goto out;
|
|
|
a3470f |
}
|
|
|
a3470f |
+ /* During handshake, after getting updates from friend mount
|
|
|
a3470f |
+ * point for activated snapshot should exist and should not
|
|
|
a3470f |
+ * for deactivated snapshot.
|
|
|
a3470f |
+ */
|
|
|
a3470f |
if (glusterd_is_volume_started (snap_vol)) {
|
|
|
a3470f |
+ ret = glusterd_recreate_vol_brick_mounts (this,
|
|
|
a3470f |
+ snap_vol);
|
|
|
a3470f |
+ if (ret) {
|
|
|
a3470f |
+ gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
a3470f |
+ GD_MSG_BRK_MNT_RECREATE_FAIL,
|
|
|
a3470f |
+ "Failed to recreate brick mounts"
|
|
|
a3470f |
+ " for %s", snap->snapname);
|
|
|
a3470f |
+ goto out;
|
|
|
a3470f |
+ }
|
|
|
a3470f |
+
|
|
|
a3470f |
(void) glusterd_start_bricks (snap_vol);
|
|
|
a3470f |
ret = glusterd_store_volinfo
|
|
|
a3470f |
(snap_vol,
|
|
|
a3470f |
@@ -1692,6 +1706,13 @@ glusterd_import_friend_snap (dict_t *peer_data, int32_t snap_count,
|
|
|
a3470f |
}
|
|
|
a3470f |
} else {
|
|
|
a3470f |
(void) glusterd_stop_bricks(snap_vol);
|
|
|
a3470f |
+ ret = glusterd_snap_unmount(this, snap_vol);
|
|
|
a3470f |
+ if (ret) {
|
|
|
a3470f |
+ gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
a3470f |
+ GD_MSG_GLUSTERD_UMOUNT_FAIL,
|
|
|
a3470f |
+ "Failed to unmounts for %s",
|
|
|
a3470f |
+ snap->snapname);
|
|
|
a3470f |
+ }
|
|
|
a3470f |
}
|
|
|
a3470f |
|
|
|
a3470f |
ret = glusterd_import_quota_conf (peer_data, i,
|
|
|
a3470f |
@@ -3347,6 +3368,70 @@ out:
|
|
|
a3470f |
return ret;
|
|
|
a3470f |
}
|
|
|
a3470f |
|
|
|
a3470f |
+/* This function will do unmount for snaps.
|
|
|
a3470f |
+ */
|
|
|
a3470f |
+int32_t
|
|
|
a3470f |
+glusterd_snap_unmount (xlator_t *this, glusterd_volinfo_t *volinfo)
|
|
|
a3470f |
+{
|
|
|
a3470f |
+ char *brick_mount_path = NULL;
|
|
|
a3470f |
+ glusterd_brickinfo_t *brickinfo = NULL;
|
|
|
a3470f |
+ int32_t ret = -1;
|
|
|
a3470f |
+ int retry_count = 0;
|
|
|
a3470f |
+
|
|
|
a3470f |
+ GF_ASSERT (this);
|
|
|
a3470f |
+ GF_ASSERT (volinfo);
|
|
|
a3470f |
+
|
|
|
a3470f |
+ cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
|
|
|
a3470f |
+ /* If the brick is not of this node, we continue */
|
|
|
a3470f |
+ if (gf_uuid_compare (brickinfo->uuid, MY_UUID)) {
|
|
|
a3470f |
+ continue;
|
|
|
a3470f |
+ }
|
|
|
a3470f |
+ /* If snapshot is pending, we continue */
|
|
|
a3470f |
+ if (brickinfo->snap_status == -1) {
|
|
|
a3470f |
+ continue;
|
|
|
a3470f |
+ }
|
|
|
a3470f |
+
|
|
|
a3470f |
+ /* Fetch the brick mount path from the brickinfo->path */
|
|
|
a3470f |
+ ret = glusterd_get_brick_root (brickinfo->path,
|
|
|
a3470f |
+ &brick_mount_path);
|
|
|
a3470f |
+ if (ret) {
|
|
|
a3470f |
+ gf_msg (this->name, GF_LOG_INFO, 0,
|
|
|
a3470f |
+ GD_MSG_BRICK_PATH_UNMOUNTED,
|
|
|
a3470f |
+ "Failed to find brick_mount_path for %s",
|
|
|
a3470f |
+ brickinfo->path);
|
|
|
a3470f |
+ /* There is chance that brick path is already
|
|
|
a3470f |
+ * unmounted. */
|
|
|
a3470f |
+ ret = 0;
|
|
|
a3470f |
+ goto out;
|
|
|
a3470f |
+ }
|
|
|
a3470f |
+ /* unmount cannot be done when the brick process is still in
|
|
|
a3470f |
+ * the process of shutdown, so give three re-tries
|
|
|
a3470f |
+ */
|
|
|
a3470f |
+ retry_count = 0;
|
|
|
a3470f |
+ while (retry_count <= 2) {
|
|
|
a3470f |
+ retry_count++;
|
|
|
a3470f |
+ /* umount2 system call doesn't cleanup mtab entry
|
|
|
a3470f |
+ * after un-mount, using external umount command.
|
|
|
a3470f |
+ */
|
|
|
a3470f |
+ ret = glusterd_umount(brick_mount_path);
|
|
|
a3470f |
+ if (!ret)
|
|
|
a3470f |
+ break;
|
|
|
a3470f |
+ gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
a3470f |
+ GD_MSG_GLUSTERD_UMOUNT_FAIL, "umount failed "
|
|
|
a3470f |
+ "for path %s (brick: %s): %s. Retry(%d)",
|
|
|
a3470f |
+ brick_mount_path, brickinfo->path,
|
|
|
a3470f |
+ strerror (errno), retry_count);
|
|
|
a3470f |
+ sleep (3);
|
|
|
a3470f |
+ }
|
|
|
a3470f |
+ }
|
|
|
a3470f |
+
|
|
|
a3470f |
+out:
|
|
|
a3470f |
+ if (brick_mount_path)
|
|
|
a3470f |
+ GF_FREE(brick_mount_path);
|
|
|
a3470f |
+
|
|
|
a3470f |
+ return ret;
|
|
|
a3470f |
+}
|
|
|
a3470f |
+
|
|
|
a3470f |
int32_t
|
|
|
a3470f |
glusterd_umount (const char *path)
|
|
|
a3470f |
{
|
|
|
a3470f |
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.h b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.h
|
|
|
a3470f |
index e050166..814bf4a 100644
|
|
|
a3470f |
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.h
|
|
|
a3470f |
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.h
|
|
|
a3470f |
@@ -76,6 +76,9 @@ int32_t
|
|
|
a3470f |
glusterd_umount (const char *path);
|
|
|
a3470f |
|
|
|
a3470f |
int32_t
|
|
|
a3470f |
+glusterd_snap_unmount (xlator_t *this, glusterd_volinfo_t *volinfo);
|
|
|
a3470f |
+
|
|
|
a3470f |
+int32_t
|
|
|
a3470f |
glusterd_add_snapshots_to_export_dict (dict_t *peer_data);
|
|
|
a3470f |
|
|
|
a3470f |
int32_t
|
|
|
a3470f |
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
|
|
|
a3470f |
index c38d2ff..275abe3 100644
|
|
|
a3470f |
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
|
|
|
a3470f |
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
|
|
|
a3470f |
@@ -872,6 +872,17 @@ glusterd_snapshot_restore (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
|
|
a3470f |
goto out;
|
|
|
a3470f |
}
|
|
|
a3470f |
}
|
|
|
a3470f |
+ /* During snapshot restore, mount point for stopped snap
|
|
|
a3470f |
+ * should exist as it is required to set extended attribute.
|
|
|
a3470f |
+ */
|
|
|
a3470f |
+ ret = glusterd_recreate_vol_brick_mounts (this, snap_volinfo);
|
|
|
a3470f |
+ if (ret) {
|
|
|
a3470f |
+ gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
a3470f |
+ GD_MSG_BRK_MNT_RECREATE_FAIL,
|
|
|
a3470f |
+ "Failed to recreate brick mounts for %s",
|
|
|
a3470f |
+ snap->snapname);
|
|
|
a3470f |
+ goto out;
|
|
|
a3470f |
+ }
|
|
|
a3470f |
|
|
|
a3470f |
ret = gd_restore_snap_volume (dict, rsp_dict, parent_volinfo,
|
|
|
a3470f |
snap_volinfo, volcount);
|
|
|
a3470f |
@@ -5195,13 +5206,17 @@ glusterd_take_brick_snapshot (dict_t *dict, glusterd_volinfo_t *snap_vol,
|
|
|
a3470f |
char *origin_brick_path = NULL;
|
|
|
a3470f |
char key[PATH_MAX] = "";
|
|
|
a3470f |
int32_t ret = -1;
|
|
|
a3470f |
+ gf_boolean_t snap_activate = _gf_false;
|
|
|
a3470f |
xlator_t *this = NULL;
|
|
|
a3470f |
+ glusterd_conf_t *priv = NULL;
|
|
|
a3470f |
|
|
|
a3470f |
this = THIS;
|
|
|
a3470f |
+ priv = this->private;
|
|
|
a3470f |
GF_ASSERT (this);
|
|
|
a3470f |
GF_ASSERT (dict);
|
|
|
a3470f |
GF_ASSERT (snap_vol);
|
|
|
a3470f |
GF_ASSERT (brickinfo);
|
|
|
a3470f |
+ GF_ASSERT (priv);
|
|
|
a3470f |
|
|
|
a3470f |
if (strlen(brickinfo->device_path) == 0) {
|
|
|
a3470f |
gf_msg (this->name, GF_LOG_ERROR, EINVAL,
|
|
|
a3470f |
@@ -5245,16 +5260,23 @@ glusterd_take_brick_snapshot (dict_t *dict, glusterd_volinfo_t *snap_vol,
|
|
|
a3470f |
*/
|
|
|
a3470f |
}
|
|
|
a3470f |
|
|
|
a3470f |
- /* create the complete brick here */
|
|
|
a3470f |
- ret = glusterd_snap_brick_create (snap_vol, brickinfo,
|
|
|
a3470f |
- brick_count, clone);
|
|
|
a3470f |
- if (ret) {
|
|
|
a3470f |
- gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
a3470f |
- GD_MSG_BRICK_CREATION_FAIL, "not able to"
|
|
|
a3470f |
- " create the brick for the snap %s"
|
|
|
a3470f |
- ", volume %s", snap_vol->snapshot->snapname,
|
|
|
a3470f |
- snap_vol->volname);
|
|
|
a3470f |
- goto out;
|
|
|
a3470f |
+ /* create the complete brick here in case of clone and
|
|
|
a3470f |
+ * activate-on-create configuration.
|
|
|
a3470f |
+ */
|
|
|
a3470f |
+ snap_activate = dict_get_str_boolean (priv->opts,
|
|
|
a3470f |
+ GLUSTERD_STORE_KEY_SNAP_ACTIVATE,
|
|
|
a3470f |
+ _gf_false);
|
|
|
a3470f |
+ if (clone || snap_activate) {
|
|
|
a3470f |
+ ret = glusterd_snap_brick_create (snap_vol, brickinfo,
|
|
|
a3470f |
+ brick_count, clone);
|
|
|
a3470f |
+ if (ret) {
|
|
|
a3470f |
+ gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
a3470f |
+ GD_MSG_BRICK_CREATION_FAIL, "not able to "
|
|
|
a3470f |
+ "create the brick for the snap %s, volume %s",
|
|
|
a3470f |
+ snap_vol->snapshot->snapname,
|
|
|
a3470f |
+ snap_vol->volname);
|
|
|
a3470f |
+ goto out;
|
|
|
a3470f |
+ }
|
|
|
a3470f |
}
|
|
|
a3470f |
|
|
|
a3470f |
out:
|
|
|
a3470f |
@@ -6126,8 +6148,10 @@ glusterd_snapshot_activate_commit (dict_t *dict, char **op_errstr,
|
|
|
a3470f |
char *snapname = NULL;
|
|
|
a3470f |
glusterd_snap_t *snap = NULL;
|
|
|
a3470f |
glusterd_volinfo_t *snap_volinfo = NULL;
|
|
|
a3470f |
+ glusterd_brickinfo_t *brickinfo = NULL;
|
|
|
a3470f |
xlator_t *this = NULL;
|
|
|
a3470f |
- int flags = 0;
|
|
|
a3470f |
+ int flags = 0;
|
|
|
a3470f |
+ int brick_count = -1;
|
|
|
a3470f |
|
|
|
a3470f |
this = THIS;
|
|
|
a3470f |
GF_ASSERT (this);
|
|
|
a3470f |
@@ -6178,6 +6202,24 @@ glusterd_snapshot_activate_commit (dict_t *dict, char **op_errstr,
|
|
|
a3470f |
goto out;
|
|
|
a3470f |
}
|
|
|
a3470f |
|
|
|
a3470f |
+ /* create the complete brick here */
|
|
|
a3470f |
+ cds_list_for_each_entry (brickinfo, &snap_volinfo->bricks,
|
|
|
a3470f |
+ brick_list) {
|
|
|
a3470f |
+ brick_count++;
|
|
|
a3470f |
+ if (gf_uuid_compare (brickinfo->uuid, MY_UUID))
|
|
|
a3470f |
+ continue;
|
|
|
a3470f |
+ ret = glusterd_snap_brick_create (snap_volinfo, brickinfo,
|
|
|
a3470f |
+ brick_count, _gf_false);
|
|
|
a3470f |
+ if (ret) {
|
|
|
a3470f |
+ gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
a3470f |
+ GD_MSG_BRICK_CREATION_FAIL, "not able to "
|
|
|
a3470f |
+ "create the brick for the snap %s, volume %s",
|
|
|
a3470f |
+ snap_volinfo->snapshot->snapname,
|
|
|
a3470f |
+ snap_volinfo->volname);
|
|
|
a3470f |
+ goto out;
|
|
|
a3470f |
+ }
|
|
|
a3470f |
+ }
|
|
|
a3470f |
+
|
|
|
a3470f |
ret = glusterd_start_volume (snap_volinfo, flags, _gf_true);
|
|
|
a3470f |
|
|
|
a3470f |
if (ret) {
|
|
|
a3470f |
@@ -6263,6 +6305,13 @@ glusterd_snapshot_deactivate_commit (dict_t *dict, char **op_errstr,
|
|
|
a3470f |
goto out;
|
|
|
a3470f |
}
|
|
|
a3470f |
|
|
|
a3470f |
+ ret = glusterd_snap_unmount(this, snap_volinfo);
|
|
|
a3470f |
+ if (ret) {
|
|
|
a3470f |
+ gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
a3470f |
+ GD_MSG_GLUSTERD_UMOUNT_FAIL,
|
|
|
a3470f |
+ "Failed to unmounts for %s", snap->snapname);
|
|
|
a3470f |
+ }
|
|
|
a3470f |
+
|
|
|
a3470f |
ret = dict_set_dynstr_with_alloc (rsp_dict, "snapuuid",
|
|
|
a3470f |
uuid_utoa (snap->snap_id));
|
|
|
a3470f |
if (ret) {
|
|
|
a3470f |
@@ -6907,6 +6956,7 @@ glusterd_snapshot_create_commit (dict_t *dict, char **op_errstr,
|
|
|
a3470f |
int64_t i = 0;
|
|
|
a3470f |
int64_t volcount = 0;
|
|
|
a3470f |
int32_t snap_activate = 0;
|
|
|
a3470f |
+ int32_t flags = 0;
|
|
|
a3470f |
char *snapname = NULL;
|
|
|
a3470f |
char *volname = NULL;
|
|
|
a3470f |
char *tmp_name = NULL;
|
|
|
a3470f |
@@ -6915,7 +6965,6 @@ glusterd_snapshot_create_commit (dict_t *dict, char **op_errstr,
|
|
|
a3470f |
glusterd_snap_t *snap = NULL;
|
|
|
a3470f |
glusterd_volinfo_t *origin_vol = NULL;
|
|
|
a3470f |
glusterd_volinfo_t *snap_vol = NULL;
|
|
|
a3470f |
- glusterd_brickinfo_t *brickinfo = NULL;
|
|
|
a3470f |
glusterd_conf_t *priv = NULL;
|
|
|
a3470f |
|
|
|
a3470f |
this = THIS;
|
|
|
a3470f |
@@ -7054,30 +7103,21 @@ glusterd_snapshot_create_commit (dict_t *dict, char **op_errstr,
|
|
|
a3470f |
goto out;
|
|
|
a3470f |
}
|
|
|
a3470f |
|
|
|
a3470f |
- cds_list_for_each_entry (snap_vol, &snap->volumes, vol_list) {
|
|
|
a3470f |
- cds_list_for_each_entry (brickinfo, &snap_vol->bricks,
|
|
|
a3470f |
- brick_list) {
|
|
|
a3470f |
- ret = glusterd_brick_start (snap_vol, brickinfo,
|
|
|
a3470f |
- _gf_false);
|
|
|
a3470f |
- if (ret) {
|
|
|
a3470f |
- gf_msg (this->name, GF_LOG_WARNING, 0,
|
|
|
a3470f |
- GD_MSG_BRICK_DISCONNECTED, "starting "
|
|
|
a3470f |
- "the brick %s:%s for the snap %s "
|
|
|
a3470f |
- "(volume: %s) failed",
|
|
|
a3470f |
- brickinfo->hostname, brickinfo->path,
|
|
|
a3470f |
- snap_vol->snapshot->snapname,
|
|
|
a3470f |
- snap_vol->volname);
|
|
|
a3470f |
- goto out;
|
|
|
a3470f |
- }
|
|
|
a3470f |
- }
|
|
|
a3470f |
+ /* Activate created bricks in case of activate-on-create config. */
|
|
|
a3470f |
+ ret = dict_get_int32 (dict, "flags", &flags);
|
|
|
a3470f |
+ if (ret) {
|
|
|
a3470f |
+ gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
a3470f |
+ GD_MSG_DICT_GET_FAILED, "Unable to get flags");
|
|
|
a3470f |
+ goto out;
|
|
|
a3470f |
+ }
|
|
|
a3470f |
|
|
|
a3470f |
- snap_vol->status = GLUSTERD_STATUS_STARTED;
|
|
|
a3470f |
- ret = glusterd_store_volinfo (snap_vol,
|
|
|
a3470f |
- GLUSTERD_VOLINFO_VER_AC_INCREMENT);
|
|
|
a3470f |
+ cds_list_for_each_entry (snap_vol, &snap->volumes, vol_list) {
|
|
|
a3470f |
+ ret = glusterd_start_volume (snap_vol, flags, _gf_true);
|
|
|
a3470f |
if (ret) {
|
|
|
a3470f |
gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
a3470f |
- GD_MSG_VOLINFO_SET_FAIL, "Failed to store "
|
|
|
a3470f |
- "snap volinfo %s", snap_vol->volname);
|
|
|
a3470f |
+ GD_MSG_SNAP_ACTIVATE_FAIL,
|
|
|
a3470f |
+ "Failed to activate snap volume %s of the "
|
|
|
a3470f |
+ "snap %s", snap_vol->volname, snap->snapname);
|
|
|
a3470f |
goto out;
|
|
|
a3470f |
}
|
|
|
a3470f |
}
|
|
|
a3470f |
@@ -7619,6 +7659,30 @@ glusterd_get_single_brick_status (char **op_errstr, dict_t *rsp_dict,
|
|
|
a3470f |
if (ret < 0) {
|
|
|
a3470f |
goto out;
|
|
|
a3470f |
}
|
|
|
a3470f |
+ /* While getting snap status we should show relevent information
|
|
|
a3470f |
+ * for deactivated snaps.
|
|
|
a3470f |
+ */
|
|
|
a3470f |
+ if (snap_volinfo->status == GLUSTERD_STATUS_STOPPED) {
|
|
|
a3470f |
+ /* Setting vgname as "Deactivated Snapshot" */
|
|
|
a3470f |
+ value = gf_strdup ("N/A (Deactivated Snapshot)");
|
|
|
a3470f |
+ if (!value) {
|
|
|
a3470f |
+ ret = -1;
|
|
|
a3470f |
+ goto out;
|
|
|
a3470f |
+ }
|
|
|
a3470f |
+
|
|
|
a3470f |
+ snprintf (key, sizeof (key), "%s.brick%d.vgname",
|
|
|
a3470f |
+ keyprefix, index);
|
|
|
a3470f |
+ ret = dict_set_dynstr (rsp_dict, key, value);
|
|
|
a3470f |
+ if (ret) {
|
|
|
a3470f |
+ gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
a3470f |
+ GD_MSG_DICT_SET_FAILED,
|
|
|
a3470f |
+ "Could not save vgname ");
|
|
|
a3470f |
+ goto out;
|
|
|
a3470f |
+ }
|
|
|
a3470f |
+
|
|
|
a3470f |
+ ret = 0;
|
|
|
a3470f |
+ goto out;
|
|
|
a3470f |
+ }
|
|
|
a3470f |
|
|
|
a3470f |
ret = glusterd_get_brick_lvm_details (rsp_dict, brickinfo,
|
|
|
a3470f |
snap_volinfo->volname,
|
|
|
a3470f |
@@ -9200,6 +9264,19 @@ glusterd_snapshot_restore_postop (dict_t *dict, int32_t op_ret,
|
|
|
a3470f |
snap->snapname);
|
|
|
a3470f |
goto out;
|
|
|
a3470f |
}
|
|
|
a3470f |
+
|
|
|
a3470f |
+ /* After restore fails, we have to remove mount point for
|
|
|
a3470f |
+ * deactivated snaps which was created at start of restore op.
|
|
|
a3470f |
+ */
|
|
|
a3470f |
+ if (volinfo->status == GLUSTERD_STATUS_STOPPED) {
|
|
|
a3470f |
+ ret = glusterd_snap_unmount(this, volinfo);
|
|
|
a3470f |
+ if (ret) {
|
|
|
a3470f |
+ gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
a3470f |
+ GD_MSG_GLUSTERD_UMOUNT_FAIL,
|
|
|
a3470f |
+ "Failed to unmounts for %s",
|
|
|
a3470f |
+ snap->snapname);
|
|
|
a3470f |
+ }
|
|
|
a3470f |
+ }
|
|
|
a3470f |
}
|
|
|
a3470f |
|
|
|
a3470f |
ret = 0;
|
|
|
a3470f |
@@ -9965,7 +10042,7 @@ gd_restore_snap_volume (dict_t *dict, dict_t *rsp_dict,
|
|
|
a3470f |
glusterd_conf_t *conf = NULL;
|
|
|
a3470f |
glusterd_volinfo_t *temp_volinfo = NULL;
|
|
|
a3470f |
glusterd_volinfo_t *voliter = NULL;
|
|
|
a3470f |
- gf_boolean_t conf_present = _gf_false;
|
|
|
a3470f |
+ gf_boolean_t conf_present = _gf_false;
|
|
|
a3470f |
|
|
|
a3470f |
this = THIS;
|
|
|
a3470f |
GF_ASSERT (this);
|
|
|
a3470f |
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
|
|
|
a3470f |
index 42bb8ce..e35fcde 100644
|
|
|
a3470f |
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
|
|
|
a3470f |
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
|
|
|
a3470f |
@@ -3519,7 +3519,7 @@ out:
|
|
|
a3470f |
return ret;
|
|
|
a3470f |
}
|
|
|
a3470f |
|
|
|
a3470f |
-static int32_t
|
|
|
a3470f |
+int32_t
|
|
|
a3470f |
glusterd_recreate_vol_brick_mounts (xlator_t *this,
|
|
|
a3470f |
glusterd_volinfo_t *volinfo)
|
|
|
a3470f |
{
|
|
|
a3470f |
@@ -4501,17 +4501,22 @@ glusterd_recreate_all_snap_brick_mounts (xlator_t *this)
|
|
|
a3470f |
}
|
|
|
a3470f |
}
|
|
|
a3470f |
|
|
|
a3470f |
- /* Recreate bricks of snapshot volumes */
|
|
|
a3470f |
+ /* Recreate bricks of snapshot volumes
|
|
|
a3470f |
+ * We are not creating brick mounts for stopped snaps.
|
|
|
a3470f |
+ */
|
|
|
a3470f |
cds_list_for_each_entry (snap, &priv->snapshots, snap_list) {
|
|
|
a3470f |
cds_list_for_each_entry (volinfo, &snap->volumes, vol_list) {
|
|
|
a3470f |
- ret = glusterd_recreate_vol_brick_mounts (this,
|
|
|
a3470f |
- volinfo);
|
|
|
a3470f |
- if (ret) {
|
|
|
a3470f |
- gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
a3470f |
- GD_MSG_BRK_MNT_RECREATE_FAIL,
|
|
|
a3470f |
- "Failed to recreate brick mounts "
|
|
|
a3470f |
- "for %s", snap->snapname);
|
|
|
a3470f |
- goto out;
|
|
|
a3470f |
+ if (volinfo->status != GLUSTERD_STATUS_STOPPED) {
|
|
|
a3470f |
+ ret = glusterd_recreate_vol_brick_mounts
|
|
|
a3470f |
+ (this, volinfo);
|
|
|
a3470f |
+ if (ret) {
|
|
|
a3470f |
+ gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
a3470f |
+ GD_MSG_BRK_MNT_RECREATE_FAIL,
|
|
|
a3470f |
+ "Failed to recreate brick "
|
|
|
a3470f |
+ "mounts for %s",
|
|
|
a3470f |
+ snap->snapname);
|
|
|
a3470f |
+ goto out;
|
|
|
a3470f |
+ }
|
|
|
a3470f |
}
|
|
|
a3470f |
}
|
|
|
a3470f |
}
|
|
|
a3470f |
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.h b/xlators/mgmt/glusterd/src/glusterd-store.h
|
|
|
a3470f |
index bf504e0..383a475 100644
|
|
|
a3470f |
--- a/xlators/mgmt/glusterd/src/glusterd-store.h
|
|
|
a3470f |
+++ b/xlators/mgmt/glusterd/src/glusterd-store.h
|
|
|
a3470f |
@@ -203,4 +203,8 @@ glusterd_quota_conf_write_header (int fd);
|
|
|
a3470f |
int32_t
|
|
|
a3470f |
glusterd_quota_conf_write_gfid (int fd, void *buf, char type);
|
|
|
a3470f |
|
|
|
a3470f |
+int32_t
|
|
|
a3470f |
+glusterd_recreate_vol_brick_mounts (xlator_t *this,
|
|
|
a3470f |
+ glusterd_volinfo_t *volinfo);
|
|
|
a3470f |
+
|
|
|
a3470f |
#endif
|
|
|
a3470f |
--
|
|
|
a3470f |
1.8.3.1
|
|
|
a3470f |
|