diff options
author | Mohammed Rafi KC <rkavunga@redhat.com> | 2015-02-05 16:12:53 +0530 |
---|---|---|
committer | Krishnan Parthasarathi <kparthas@redhat.com> | 2015-03-10 04:42:00 -0700 |
commit | 1ae8b4c33af175545d6afe99aeb7a21896960a35 (patch) | |
tree | 4e56f0a7b8d760e9ceaea39f1b4c0b863a754218 /xlators/mgmt/glusterd/src | |
parent | 8cdd272dcf277aa4148c57458cc5477a49b08383 (diff) |
snapshot: append timestamp with snapname
Appending GMT time stamp with snapname by default.
If no-timestamp flag is given during snapshot creation,
then time stamp will not append with snapname;
Initial consumer of this feature is Samba's Shadow Copy
feature. This feature allows Windows user to get previous
revisions of a file. For this feature to work snapshot
names under .snaps folder (USS) should have timestamp in
following format appended:
@GMT-YYYY.MM.DD-hh.mm.ss
PS: https://www.samba.org/samba/docs/man/manpages/vfs_shadow_copy2.8.html
This format is configurable by Samba conf file. Due to a
limitation in Windows directory access the exact format
cannot be used by USS. Therefore we have modified the file
format to:
_GMT-YYYY.MM.DD-hh.mm.ss
Snapshot scheduling feature also required to append timestamp
to the snapshot name therefore timestamp is appended in
snapshot creation itself instead of doing the changes in
snapview server.
More info:
https://www.mail-archive.com/gluster-users@gluster.org/msg18895.html
Change-Id: Idac24670948cf4c0fbe916ea6690e49cbc832d07
BUG: 1189473
Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
Reviewed-on: http://review.gluster.org/9597
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-snapshot.c | 63 |
1 files changed, 44 insertions, 19 deletions
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); |