summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cli/src/cli-cmd-parser.c20
-rw-r--r--cli/src/cli-cmd-snapshot.c3
-rw-r--r--tests/basic/uss.t16
-rwxr-xr-xtests/basic/volume-snapshot.t27
-rw-r--r--tests/bugs/core/bug-1168875.t2
-rwxr-xr-xtests/bugs/snapshot/bug-1045333.t6
-rwxr-xr-xtests/bugs/snapshot/bug-1049834.t4
-rwxr-xr-xtests/bugs/snapshot/bug-1090042.t4
-rw-r--r--tests/bugs/snapshot/bug-1109770.t8
-rw-r--r--tests/bugs/snapshot/bug-1109889.t8
-rwxr-xr-xtests/bugs/snapshot/bug-1112559.t2
-rw-r--r--tests/bugs/snapshot/bug-1113975.t4
-rw-r--r--tests/bugs/snapshot/bug-1155042-dont-display-deactivated-snapshots.t2
-rwxr-xr-xtests/bugs/snapshot/bug-1157991.t4
-rwxr-xr-xtests/bugs/snapshot/bug-1162462.t2
-rw-r--r--tests/bugs/snapshot/bug-1162498.t8
-rw-r--r--tests/bugs/snapshot/bug-1164613.t2
-rwxr-xr-xtests/bugs/snapshot/bug-1166197.t4
-rw-r--r--tests/bugs/snapshot/bug-1167580-set-proper-uid-and-gid-during-nfs-access.t4
-rw-r--r--tests/snapshot.rc4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c63
21 files changed, 127 insertions, 70 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index bbec6aa5f8d..0981f11b7be 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -3397,7 +3397,9 @@ cli_snap_create_parse (dict_t *dict, const char **words, int wordcount) {
/* Filling volume name in the dictionary */
for (i = cmdi + 1 ; i < wordcount
&& (strcmp (words[i], "description")) != 0
- && (strcmp (words[i], "force") != 0); i++) {
+ && (strcmp (words[i], "force") != 0)
+ && (strcmp (words[i], "no-timestamp") != 0);
+ i++) {
volcount++;
/* volume index starts from 1 */
ret = snprintf (key, sizeof (key), "volname%"PRIu64, volcount);
@@ -3437,13 +3439,24 @@ cli_snap_create_parse (dict_t *dict, const char **words, int wordcount) {
/* Verify how we got out of "for" loop,
* if it is by reaching wordcount limit then goto "out",
- * because we need not parse for "description" and "force"
- * after this.
+ * because we need not parse for "description","force" and
+ * "no-timestamp" after this.
*/
if (i == wordcount) {
goto out;
}
+ if (strcmp (words[i], "no-timestamp") == 0) {
+ ret = dict_set_str (dict, "no-timestamp", "true");
+ if (ret) {
+ gf_log ("cli", GF_LOG_ERROR, "Could not save "
+ "time-stamp option");
+ }
+ if (i == (wordcount-1))
+ goto out;
+ i++;
+ }
+
if ((strcmp (words[i], "description")) == 0) {
++i;
if (i > (wordcount - 1)) {
@@ -4291,6 +4304,7 @@ cli_cmd_snapshot_parse (const char **words, int wordcount, dict_t **options,
case GF_SNAP_OPTION_TYPE_CREATE:
/* Syntax :
* gluster snapshot create <snapname> <vol-name(s)>
+ * [no-timestamp]
* [description <description>]
* [force]
*/
diff --git a/cli/src/cli-cmd-snapshot.c b/cli/src/cli-cmd-snapshot.c
index d03b5b99dd0..7c6a52e0a88 100644
--- a/cli/src/cli-cmd-snapshot.c
+++ b/cli/src/cli-cmd-snapshot.c
@@ -82,7 +82,8 @@ struct cli_cmd snapshot_cmds[] = {
cli_cmd_snapshot_help_cbk,
"display help for snapshot commands"
},
- { "snapshot create <snapname> <volname(s)> [description <description>] [force]",
+ { "snapshot create <snapname> <volname(s)> [no-timestamp] "
+ "[description <description>] [force]",
cli_cmd_snapshot_cbk,
"Snapshot Create."
},
diff --git a/tests/basic/uss.t b/tests/basic/uss.t
index 2de66a97f48..4465391245a 100644
--- a/tests/basic/uss.t
+++ b/tests/basic/uss.t
@@ -43,11 +43,11 @@ for i in {1..10} ; do echo "file" > $M0/file$i ; done
TEST $CLI snapshot config activate-on-create enable
-TEST $CLI snapshot create snap1 $V0;
+TEST $CLI snapshot create snap1 $V0 no-timestamp;
for i in {11..20} ; do echo "file" > $M0/file$i ; done
-TEST $CLI snapshot create snap2 $V0;
+TEST $CLI snapshot create snap2 $V0 no-timestamp;
mkdir $M0/dir1;
mkdir $M0/dir2;
@@ -55,13 +55,12 @@ mkdir $M0/dir2;
for i in {1..10} ; do echo "foo" > $M0/dir1/foo$i ; done
for i in {1..10} ; do echo "foo" > $M0/dir2/foo$i ; done
-TEST $CLI snapshot create snap3 $V0;
+TEST $CLI snapshot create snap3 $V0 no-timestamp;
for i in {11..20} ; do echo "foo" > $M0/dir1/foo$i ; done
for i in {11..20} ; do echo "foo" > $M0/dir2/foo$i ; done
-TEST $CLI snapshot create snap4 $V0;
-
+TEST $CLI snapshot create snap4 $V0 no-timestamp;
## Test that features.uss takes only options enable/disable and throw error for
## any other argument.
for i in {1..10}; do
@@ -81,7 +80,6 @@ TEST ls $M0/.snaps;
NUM_SNAPS=$(ls $M0/.snaps | wc -l);
TEST [ $NUM_SNAPS == 4 ]
-
TEST ls $M0/.snaps/snap1;
TEST ls $M0/.snaps/snap2;
TEST ls $M0/.snaps/snap3;
@@ -290,7 +288,7 @@ TEST fd_close $fd3;
EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" umount_nfs $N0
#test 131
-TEST $CLI snapshot create snap5 $V0
+TEST $CLI snapshot create snap5 $V0 no-timestamp
TEST ls $M0/.history;
function count_snaps
@@ -319,7 +317,7 @@ EXPECT_WITHIN 30 "5" count_snaps $M0;
echo "aaa" > $M0/aaa;
-TEST $CLI snapshot create snap6 $V0
+TEST $CLI snapshot create snap6 $V0 no-timestamp
TEST ls $M0/.history;
@@ -331,7 +329,7 @@ TEST rm -f $M0/aaa;
TEST $CLI snapshot delete snap6;
-TEST $CLI snapshot create snap6 $V0
+TEST $CLI snapshot create snap6 $V0 no-timestamp
TEST ls $M0/.history;
diff --git a/tests/basic/volume-snapshot.t b/tests/basic/volume-snapshot.t
index 46440d1a706..65ce54b0a26 100755
--- a/tests/basic/volume-snapshot.t
+++ b/tests/basic/volume-snapshot.t
@@ -19,15 +19,25 @@ function create_volumes() {
}
function create_snapshots() {
- $CLI_1 snapshot create ${V0}_snap ${V0}&
+ $CLI_1 snapshot create ${V0}_snap ${V0} no-timestamp &
PID_1=$!
- $CLI_1 snapshot create ${V1}_snap ${V1}&
+ $CLI_1 snapshot create ${V1}_snap ${V1} no-timestamp &
PID_2=$!
wait $PID_1 $PID_2
}
+function create_snapshots_with_timestamp() {
+ $CLI_1 snapshot create ${V0}_snap1 ${V0}&
+ PID_1=$!
+ $CLI_1 snapshot create ${V1}_snap1 ${V1}&
+ PID_2=$!
+
+ wait $PID_1 $PID_2
+}
+
+
function activate_snapshots() {
$CLI_1 snapshot activate ${V0}_snap &
PID_1=$!
@@ -49,10 +59,10 @@ function deactivate_snapshots() {
}
function delete_snapshots() {
- $CLI_1 snapshot delete ${V0}_snap &
+ $CLI_1 snapshot delete $1 &
PID_1=$!
- $CLI_1 snapshot delete ${V1}_snap &
+ $CLI_1 snapshot delete $2 &
PID_2=$!
wait $PID_1 $PID_2
@@ -114,6 +124,15 @@ EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
TEST glusterfs -s $H2 --volfile-id=/snaps/${V1}_snap/${V1} $M0
EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
+#create timestamp appended snaps
+create_snapshots_with_timestamp;
+new_name1=`$CLI_1 snapshot list ${V0} | grep ${V0}_snap1`;
+new_name2=`$CLI_1 snapshot list ${V1} | grep ${V1}_snap1`;
+
+EXPECT_NOT "{V0}_snap1" echo $new_name1;
+EXPECT_NOT "{V1}_snap1" echo $new_name1;
+delete_snapshots $new_name1 $new_name2;
+
#Clean up
stop_force_volumes 2
EXPECT 'Stopped' volinfo_field $V0 'Status';
diff --git a/tests/bugs/core/bug-1168875.t b/tests/bugs/core/bug-1168875.t
index f6fa9f729c9..9737784fd84 100644
--- a/tests/bugs/core/bug-1168875.t
+++ b/tests/bugs/core/bug-1168875.t
@@ -54,7 +54,7 @@ for i in {1..10} ; do echo "foo" > $M0/dir2/foo$i ; done
for i in {11..20} ; do echo "foo" > $M0/dir1/foo$i ; done
for i in {11..20} ; do echo "foo" > $M0/dir2/foo$i ; done
-TEST $CLI snapshot create snap1 $V0;
+TEST $CLI snapshot create snap1 $V0 no-timestamp;
TEST $CLI snapshot activate snap1;
TEST $CLI volume set $V0 features.uss enable;
diff --git a/tests/bugs/snapshot/bug-1045333.t b/tests/bugs/snapshot/bug-1045333.t
index ad2d0021aaa..6c0b995b5b0 100755
--- a/tests/bugs/snapshot/bug-1045333.t
+++ b/tests/bugs/snapshot/bug-1045333.t
@@ -19,13 +19,13 @@ S2="-${V0}-snap2" #Create snapshot with name starts with hyphen(-)
#Create snapshot with a long name
S3="${V0}_single_gluster_volume_is_accessible_by_multiple_clients_offline_snapshot_is_a_long_name"
-TEST $CLI snapshot create $S1 $V0
+TEST $CLI snapshot create $S1 $V0 no-timestamp
TEST snapshot_exists 0 $S1
-TEST $CLI snapshot create $S2 $V0
+TEST $CLI snapshot create $S2 $V0 no-timestamp
TEST snapshot_exists 0 $S2
-TEST $CLI snapshot create $S3 $V0
+TEST $CLI snapshot create $S3 $V0 no-timestamp
TEST snapshot_exists 0 $S3
diff --git a/tests/bugs/snapshot/bug-1049834.t b/tests/bugs/snapshot/bug-1049834.t
index cdb8a3babf8..29c75cc7f96 100755
--- a/tests/bugs/snapshot/bug-1049834.t
+++ b/tests/bugs/snapshot/bug-1049834.t
@@ -30,11 +30,11 @@ TEST snapshot_n_exists $V0 3 $V0_snap
#Creating the 4th snapshot on the volume and expecting it to be created
# but with the deletion of the oldest snapshot i.e 1st snapshot
-TEST $CLI_1 snapshot create ${V0}_snap4 ${V0}
+TEST $CLI_1 snapshot create ${V0}_snap4 ${V0} no-timestamp
TEST snapshot_exists 1 ${V0}_snap4
TEST ! snapshot_exists 1 ${V0}_snap1
TEST $CLI_1 snapshot delete ${V0}_snap4
-TEST $CLI_1 snapshot create ${V0}_snap1 ${V0}
+TEST $CLI_1 snapshot create ${V0}_snap1 ${V0} no-timestamp
TEST snapshot_exists 1 ${V0}_snap1
#Deleting the 4 snaps
diff --git a/tests/bugs/snapshot/bug-1090042.t b/tests/bugs/snapshot/bug-1090042.t
index 9eb3a9aecc4..98531a9751e 100755
--- a/tests/bugs/snapshot/bug-1090042.t
+++ b/tests/bugs/snapshot/bug-1090042.t
@@ -16,11 +16,11 @@ TEST $CLI volume start $V0;
TEST kill_brick $V0 $H0 $L1;
#Normal snap create should fail
-TEST ! $CLI snapshot create ${V0}_snap1 $V0;
+TEST ! $CLI snapshot create ${V0}_snap1 $V0 no-timestamp;
TEST ! snapshot_exists 0 ${V0}_snap1;
#With changes introduced in BZ #1184344 force snap create should fail too
-TEST ! $CLI snapshot create ${V0}_snap1 $V0 force;
+TEST ! $CLI snapshot create ${V0}_snap1 $V0 no-timestamp force;
TEST ! snapshot_exists 0 ${V0}_snap1;
cleanup;
diff --git a/tests/bugs/snapshot/bug-1109770.t b/tests/bugs/snapshot/bug-1109770.t
index eca4969f2e3..22511995937 100644
--- a/tests/bugs/snapshot/bug-1109770.t
+++ b/tests/bugs/snapshot/bug-1109770.t
@@ -23,11 +23,11 @@ TEST glusterfs --volfile-server=$H0 --volfile-id=$V0 $M0;
for i in {1..10} ; do echo "file" > $M0/file$i ; done
-TEST $CLI snapshot create snap1 $V0;
+TEST $CLI snapshot create snap1 $V0 no-timestamp;
for i in {11..20} ; do echo "file" > $M0/file$i ; done
-TEST $CLI snapshot create snap2 $V0;
+TEST $CLI snapshot create snap2 $V0 no-timestamp;
mkdir $M0/dir1;
mkdir $M0/dir2;
@@ -35,12 +35,12 @@ mkdir $M0/dir2;
for i in {1..10} ; do echo "foo" > $M0/dir1/foo$i ; done
for i in {1..10} ; do echo "foo" > $M0/dir2/foo$i ; done
-TEST $CLI snapshot create snap3 $V0;
+TEST $CLI snapshot create snap3 $V0 no-timestamp;
for i in {11..20} ; do echo "foo" > $M0/dir1/foo$i ; done
for i in {11..20} ; do echo "foo" > $M0/dir2/foo$i ; done
-TEST $CLI snapshot create snap4 $V0;
+TEST $CLI snapshot create snap4 $V0 no-timestamp;
TEST $CLI volume set $V0 features.uss enable;
diff --git a/tests/bugs/snapshot/bug-1109889.t b/tests/bugs/snapshot/bug-1109889.t
index eac5ac17f5b..6b0eb37f14f 100644
--- a/tests/bugs/snapshot/bug-1109889.t
+++ b/tests/bugs/snapshot/bug-1109889.t
@@ -27,11 +27,11 @@ for i in {1..10} ; do echo "file" > $M0/file$i ; done
TEST $CLI snapshot config activate-on-create enable
-TEST $CLI snapshot create snap1 $V0;
+TEST $CLI snapshot create snap1 $V0 no-timestamp;
for i in {11..20} ; do echo "file" > $M0/file$i ; done
-TEST $CLI snapshot create snap2 $V0;
+TEST $CLI snapshot create snap2 $V0 no-timestamp;
mkdir $M0/dir1;
mkdir $M0/dir2;
@@ -39,12 +39,12 @@ mkdir $M0/dir2;
for i in {1..10} ; do echo "foo" > $M0/dir1/foo$i ; done
for i in {1..10} ; do echo "foo" > $M0/dir2/foo$i ; done
-TEST $CLI snapshot create snap3 $V0;
+TEST $CLI snapshot create snap3 $V0 no-timestamp;
for i in {11..20} ; do echo "foo" > $M0/dir1/foo$i ; done
for i in {11..20} ; do echo "foo" > $M0/dir2/foo$i ; done
-TEST $CLI snapshot create snap4 $V0;
+TEST $CLI snapshot create snap4 $V0 no-timestamp;
TEST $CLI volume set $V0 features.uss enable;
diff --git a/tests/bugs/snapshot/bug-1112559.t b/tests/bugs/snapshot/bug-1112559.t
index f318db61b8a..8a2e228d3da 100755
--- a/tests/bugs/snapshot/bug-1112559.t
+++ b/tests/bugs/snapshot/bug-1112559.t
@@ -34,7 +34,7 @@ TEST $CLI_1 volume create $V0 $H1:$L1 $H2:$L2
TEST $CLI_1 volume start $V0
#Create snapshot and add a peer together
-$CLI_1 snapshot create ${V0}_snap1 ${V0} &
+$CLI_1 snapshot create ${V0}_snap1 ${V0} no-timestamp &
PID_1=$!
$CLI_1 peer probe $H3
wait $PID_1
diff --git a/tests/bugs/snapshot/bug-1113975.t b/tests/bugs/snapshot/bug-1113975.t
index c1b9b1e3e2c..86c1739fb46 100644
--- a/tests/bugs/snapshot/bug-1113975.t
+++ b/tests/bugs/snapshot/bug-1113975.t
@@ -21,11 +21,11 @@ TEST glusterfs --volfile-server=$H0 --volfile-id=$V0 $M0;
for i in {1..10} ; do echo "file" > $M0/file$i ; done
-TEST $CLI snapshot create snap1 $V0;
+TEST $CLI snapshot create snap1 $V0 no-timestamp;
for i in {11..20} ; do echo "file" > $M0/file$i ; done
-TEST $CLI snapshot create snap2 $V0;
+TEST $CLI snapshot create snap2 $V0 no-timestamp;
TEST $CLI volume stop $V0
diff --git a/tests/bugs/snapshot/bug-1155042-dont-display-deactivated-snapshots.t b/tests/bugs/snapshot/bug-1155042-dont-display-deactivated-snapshots.t
index cf35caad0aa..6697c263ac1 100644
--- a/tests/bugs/snapshot/bug-1155042-dont-display-deactivated-snapshots.t
+++ b/tests/bugs/snapshot/bug-1155042-dont-display-deactivated-snapshots.t
@@ -20,7 +20,7 @@ TEST $GFS --volfile-server=$H0 --volfile-id=$V0 $M0
# create 10 snapshots and check if all are being reflected
# in the USS world
gluster snapshot config activate-on-create enable
-for i in {1..10}; do $CLI snapshot create snap$i $V0; done
+for i in {1..10}; do $CLI snapshot create snap$i $V0 no-timestamp; done
EXPECT 10 uss_count_snap_displayed $M0
# snapshots should not be displayed after deactivation
diff --git a/tests/bugs/snapshot/bug-1157991.t b/tests/bugs/snapshot/bug-1157991.t
index 77440bc2301..f626ef2b705 100755
--- a/tests/bugs/snapshot/bug-1157991.t
+++ b/tests/bugs/snapshot/bug-1157991.t
@@ -13,11 +13,11 @@ TEST setup_lvm 1
TEST $CLI volume create $V0 $H0:$L1
TEST $CLI volume start $V0
-TEST $CLI snapshot create snap1 $V0
+TEST $CLI snapshot create snap1 $V0 no-timestamp
EXPECT 'Stopped' snapshot_status snap1;
TEST $CLI snapshot config activate-on-create enable
-TEST $CLI snapshot create snap2 $V0
+TEST $CLI snapshot create snap2 $V0 no-timestamp
EXPECT 'Started' snapshot_status snap2;
#Clean up
diff --git a/tests/bugs/snapshot/bug-1162462.t b/tests/bugs/snapshot/bug-1162462.t
index aed79fdd2c7..5c2e4fe37f0 100755
--- a/tests/bugs/snapshot/bug-1162462.t
+++ b/tests/bugs/snapshot/bug-1162462.t
@@ -22,7 +22,7 @@ ln -s $M0/file1 $M0/test/file_symlink
ls -l $M0/ > /dev/null
ls -l $M0/test/ > /dev/null
-TEST $CLI snapshot create snap1 $V0;
+TEST $CLI snapshot create snap1 $V0 no-timestamp;
$CLI snapshot activate snap1;
EXPECT 'Started' snapshot_status snap1;
diff --git a/tests/bugs/snapshot/bug-1162498.t b/tests/bugs/snapshot/bug-1162498.t
index 06b3d74691c..665d60fd0bf 100644
--- a/tests/bugs/snapshot/bug-1162498.t
+++ b/tests/bugs/snapshot/bug-1162498.t
@@ -20,13 +20,13 @@ TEST glusterfs -s $H0 --volfile-id=$V0 $M0
TEST mkdir $M0/xyz
-TEST $CLI snapshot create snap1 $V0
-TEST $CLI snapshot create snap2 $V0
+TEST $CLI snapshot create snap1 $V0 no-timestamp
+TEST $CLI snapshot create snap2 $V0 no-timestamp
TEST rmdir $M0/xyz
-TEST $CLI snapshot create snap3 $V0
-TEST $CLI snapshot create snap4 $V0
+TEST $CLI snapshot create snap3 $V0 no-timestamp
+TEST $CLI snapshot create snap4 $V0 no-timestamp
TEST mkdir $M0/xyz
TEST ls $M0/xyz/.snaps/
diff --git a/tests/bugs/snapshot/bug-1164613.t b/tests/bugs/snapshot/bug-1164613.t
index 9cf122bc4b8..d7f956ce369 100644
--- a/tests/bugs/snapshot/bug-1164613.t
+++ b/tests/bugs/snapshot/bug-1164613.t
@@ -16,7 +16,7 @@ TEST glusterfs -s $H0 --volfile-id=$V0 $M0
TEST touch $M0/testfile
-TEST $CLI snapshot create snaps $V0
+TEST $CLI snapshot create snaps $V0 no-timestamp
TEST $CLI snapshot activate snaps
TEST $CLI volume set $V0 features.uss enable
TEST $CLI volume set $V0 snapshot-directory snaps
diff --git a/tests/bugs/snapshot/bug-1166197.t b/tests/bugs/snapshot/bug-1166197.t
index 6592382df6c..65b242250bf 100755
--- a/tests/bugs/snapshot/bug-1166197.t
+++ b/tests/bugs/snapshot/bug-1166197.t
@@ -23,8 +23,8 @@ EXPECT_WITHIN $PROCESS_UP_TIMEOUT 'Started' volinfo_field $V0 'Status';
TEST mount_nfs $H0:/$V0 $N0 nolock
TEST mkdir $N0/testdir
-TEST $CLI snapshot create snap1 $V0
-TEST $CLI snapshot create snap2 $V0
+TEST $CLI snapshot create snap1 $V0 no-timestamp
+TEST $CLI snapshot create snap2 $V0 no-timestamp
EXPECT_WITHIN $PROCESS_UP_TIMEOUT "0" STAT $N0/testdir/.snaps
diff --git a/tests/bugs/snapshot/bug-1167580-set-proper-uid-and-gid-during-nfs-access.t b/tests/bugs/snapshot/bug-1167580-set-proper-uid-and-gid-during-nfs-access.t
index 5bea7a71306..0893826b343 100644
--- a/tests/bugs/snapshot/bug-1167580-set-proper-uid-and-gid-during-nfs-access.t
+++ b/tests/bugs/snapshot/bug-1167580-set-proper-uid-and-gid-during-nfs-access.t
@@ -93,7 +93,7 @@ chmod 700 $M0/README
# enable uss and take a snapshot
TEST $CLI volume set $V0 uss enable
TEST $CLI snapshot config activate-on-create on
-TEST $CLI snapshot create snap1 $V0
+TEST $CLI snapshot create snap1 $V0 no-timestamp
# try to access the file using user1 account.
# It should succeed with both normal mount and snapshot world.
@@ -146,7 +146,7 @@ create_user $user5
chgrp $group3 $M0/file3
-TEST $CLI snapshot create snap2 $V0
+TEST $CLI snapshot create snap2 $V0 no-timestamp
EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" check_if_permitted $user3 $M0/file3 cat
EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" check_if_permitted $user3 $M0/.snaps/snap2/file3 cat
diff --git a/tests/snapshot.rc b/tests/snapshot.rc
index a0c92d96343..defce075cf5 100644
--- a/tests/snapshot.rc
+++ b/tests/snapshot.rc
@@ -228,7 +228,7 @@ function create_n_snapshots() {
local snap_name=$3
local ret=0
for i in `seq 1 $snap_count`; do
- $CLI_1 snapshot create $snap_name$i ${vol}&
+ $CLI_1 snapshot create $snap_name$i ${vol} no-timestamp &
PID_1=$!
wait $PID_1
ret=$?
@@ -337,7 +337,7 @@ function snap_create()
while [ $i -lt $limit ]
do
- $cli_index snapshot create snap$i $volname
+ $cli_index snapshot create snap$i $volname no-timestamp
i=$[$i+1]
done
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index 2ce81da200f..f3d20f3e1e9 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
@@ -3471,19 +3471,22 @@ int
glusterd_handle_snapshot_create (rpcsvc_request_t *req, glusterd_op_t op,
dict_t *dict, char *err_str, size_t len)
{
- int ret = -1;
- char *volname = NULL;
- char *snapname = NULL;
- int64_t volcount = 0;
- xlator_t *this = NULL;
- char key[PATH_MAX] = "";
- char *username = NULL;
- char *password = NULL;
- uuid_t *uuid_ptr = NULL;
- uuid_t tmp_uuid = {0};
- int i = 0;
- char snap_volname[GD_VOLUME_NAME_MAX] = {0, };
-
+ int ret = -1;
+ char *volname = NULL;
+ char *snapname = NULL;
+ int64_t volcount = 0;
+ xlator_t *this = NULL;
+ char key[PATH_MAX] = "";
+ char *username = NULL;
+ char *password = NULL;
+ uuid_t *uuid_ptr = NULL;
+ uuid_t tmp_uuid = {0};
+ int i = 0;
+ gf_boolean_t timestamp = _gf_false;
+ char snap_volname[GD_VOLUME_NAME_MAX] = {0, };
+ char new_snapname[GLUSTERD_MAX_SNAP_NAME] = {0, };
+ char gmt_snaptime[GLUSTERD_MAX_SNAP_NAME] = {0, };
+ time_t snap_time;
this = THIS;
GF_ASSERT (this);
GF_ASSERT (req);
@@ -3509,6 +3512,34 @@ glusterd_handle_snapshot_create (rpcsvc_request_t *req, glusterd_op_t op,
goto out;
}
+ timestamp = dict_get_str_boolean (dict, "no-timestamp", _gf_false);
+ if (ret) {
+ gf_log (this->name, GF_LOG_DEBUG, "no-timestamp flag "
+ "is not set");
+ goto out;
+ }
+
+ ret = dict_set_int64 (dict, "snap-time", (int64_t)time(&snap_time));
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "Unable to set snap-time");
+ goto out;
+ }
+
+ if (!timestamp) {
+ strftime (gmt_snaptime, sizeof (gmt_snaptime),
+ "_GMT-%Y.%m.%d-%H.%M.%S", gmtime(&snap_time));
+ snprintf (new_snapname, sizeof (new_snapname), "%s%s",
+ snapname, gmt_snaptime);
+ ret = dict_set_dynstr_with_alloc (dict, "snapname",
+ new_snapname);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "Unable to update "
+ "snap-name");
+ goto out;
+ }
+ snapname = new_snapname;
+ }
+
if (strlen(snapname) >= GLUSTERD_MAX_SNAP_NAME) {
snprintf (err_str, len, "snapname cannot exceed 255 "
"characters");
@@ -3533,12 +3564,6 @@ glusterd_handle_snapshot_create (rpcsvc_request_t *req, glusterd_op_t op,
}
uuid_ptr = NULL;
- ret = dict_set_int64 (dict, "snap-time", (int64_t)time(NULL));
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to set snap-time");
- goto out;
- }
-
for (i = 1; i <= volcount; i++) {
snprintf (key, sizeof (key), "volname%d", i);
ret = dict_get_str (dict, key, &volname);