summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
Diffstat (limited to 'xlators')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c48
1 files changed, 47 insertions, 1 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index f2fb2ba5552..3edbd827dcb 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
@@ -3665,7 +3665,7 @@ glusterd_take_lvm_snapshot (glusterd_brickinfo_t *brickinfo,
} while (ptr != NULL);
runner_end (&runner);
- /* Takng the actual snapshot */
+ /* Taking the actual snapshot */
runinit (&runner);
snprintf (msg, sizeof (msg), "taking snapshot of the brick %s",
origin_brick_path);
@@ -7104,6 +7104,44 @@ out:
return ret;
}
+/*
+ Verify availability of lvm commands
+*/
+
+static gf_boolean_t
+glusterd_is_lvm_cmd_available (char *lvm_cmd)
+{
+ int32_t ret = 0;
+ struct stat buf = {0,};
+
+ if (!lvm_cmd)
+ return _gf_false;
+
+ ret = stat (lvm_cmd, &buf);
+ if (ret != 0) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "stat fails on %s, exiting. (errno = %d (%s))",
+ lvm_cmd, errno, strerror(errno));
+ return _gf_false;
+ }
+
+ if ((!ret) && (!S_ISREG(buf.st_mode))) {
+ gf_log (THIS->name, GF_LOG_CRITICAL,
+ "Provided command %s is not a regular file,"
+ "exiting", lvm_cmd);
+ return _gf_false;
+ }
+
+ if ((!ret) && (!(buf.st_mode & S_IXUSR))) {
+ gf_log (THIS->name, GF_LOG_CRITICAL,
+ "Provided command %s has no exec permissions,"
+ "exiting", lvm_cmd);
+ return _gf_false;
+ }
+
+ return _gf_true;
+}
+
int
glusterd_handle_snapshot_fn (rpcsvc_request_t *req)
{
@@ -7176,6 +7214,14 @@ glusterd_handle_snapshot_fn (rpcsvc_request_t *req)
goto out;
}
+ if (!glusterd_is_lvm_cmd_available (LVM_CREATE)) {
+ snprintf (err_str, sizeof (err_str), "LVM commands not found,"
+ " snapshot functionality is disabled");
+ gf_log (this->name, GF_LOG_ERROR, "%s", err_str);
+ ret = -1;
+ goto out;
+ }
+
switch (type) {
case GF_SNAP_OPTION_TYPE_CREATE:
ret = glusterd_handle_snapshot_create (req, cli_op, dict,