diff options
author | Raghavendra Bhat <raghavendra@redhat.com> | 2013-10-16 18:18:04 +0530 |
---|---|---|
committer | shishir gowda <sgowda@redhat.com> | 2013-11-15 12:38:59 +0530 |
commit | cc4fa72926f9ac517365d91ae6144530dc67c001 (patch) | |
tree | 9da64c3ceeda354726be21c6df118f2ce6616b5c /xlators/mgmt/glusterd/src/glusterd.c | |
parent | d15ad38e8623f510fb1e121a8ff0d845a99238e4 (diff) |
mgmt/glusterd: snapshot create command
This is still a work in progress.
As of now, these things are done:
* Take the snapshot of the backend brick
* Create the new volume for the snapshot
* Create the brick and the client volfiles
* Store the snapshot related info in /var/lib/glusterd
* Create the snap object representing the snapshot
TODO:
Start the brick processes for the snapshot
Change-Id: I26fbb0f8e5cf004d4c1dbca51819bab1cd1bac15
Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c index c932800c3..acefc8e42 100644 --- a/xlators/mgmt/glusterd/src/glusterd.c +++ b/xlators/mgmt/glusterd/src/glusterd.c @@ -1084,6 +1084,7 @@ init (xlator_t *this) struct stat buf = {0,}; char storedir [PATH_MAX] = {0,}; char workdir [PATH_MAX] = {0,}; + char snap_brick_dir[PATH_MAX] = {0, }; char hooks_dir [PATH_MAX] = {0,}; char cmd_log_filename [PATH_MAX] = {0,}; int first_time = 0; @@ -1133,6 +1134,43 @@ init (xlator_t *this) gf_log (this->name, GF_LOG_INFO, "Using %s as working directory", workdir); + dir_data = dict_get (this->options, "snap-bricks-path"); + if (!dir_data) { + //Use default working dir + strncpy (snap_brick_dir, GLUSTERD_DEFAULT_SNAPS_BRICK_DIR, PATH_MAX); + } else { + strncpy (snap_brick_dir, dir_data->data, PATH_MAX); + } + + ret = stat (snap_brick_dir, &buf); + if ((ret != 0) && (ENOENT != errno)) { + gf_log (this->name, GF_LOG_ERROR, + "stat fails on %s, exiting. (errno = %d)", + workdir, errno); + exit (1); + } + + if ((!ret) && (!S_ISDIR(buf.st_mode))) { + gf_log (this->name, GF_LOG_CRITICAL, + "Provided working area %s is not a directory," + "exiting", workdir); + exit (1); + } + + + if ((-1 == ret) && (ENOENT == errno)) { + ret = mkdir (snap_brick_dir, 0777); + + if (-1 == ret) { + gf_log (this->name, GF_LOG_CRITICAL, + "Unable to create directory %s" + " ,errno = %d", snap_brick_dir, errno); + exit (1); + } + + first_time = 1; + } + snprintf (cmd_log_filename, PATH_MAX,"%s/.cmd_log_history", DEFAULT_LOG_FILE_DIRECTORY); ret = gf_cmd_log_init (cmd_log_filename); @@ -1514,5 +1552,9 @@ struct volume_options options[] = { .type = GF_OPTION_TYPE_INT, .description = "Sets the base port for portmap query" }, + { .key = {"snap-brick-path"}, + .type = GF_OPTION_TYPE_STR, + .description = "directory where the bricks for the snapshots will be created" + }, { .key = {NULL} }, }; |