summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarshavardhana <harsha@harshavardhana.net>2014-06-24 15:00:59 -0700
committerHarshavardhana <harsha@harshavardhana.net>2014-06-28 11:56:59 -0700
commit39209965366f9bbc1d485532496fc265874c7527 (patch)
tree1f39b79632a344db38a0ef4ea127ae2d85bf6d9c
parentfc1ae37ea4c353286f9a6f3d3e95041feee6ac7d (diff)
glusterd/snapshot: verify for lvm commands
On non-Linux platforms we need to verify the run time availability of LVM specific commands and fail accordingly with a message. Change-Id: Ie1e3870648f01ee129e390e2240c66e0c6249b90 BUG: 1061685 Signed-off-by: Harshavardhana <harsha@harshavardhana.net> Reviewed-on: http://review.gluster.org/8165 Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Sachin Pandit <spandit@redhat.com>
-rw-r--r--glusterfs.spec.in9
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c48
2 files changed, 54 insertions, 3 deletions
diff --git a/glusterfs.spec.in b/glusterfs.spec.in
index a9061ced62a..068df0eeff5 100644
--- a/glusterfs.spec.in
+++ b/glusterfs.spec.in
@@ -402,8 +402,11 @@ Group: Development/Tools
Requires: %{name} = %{version}-%{release}
Requires: %{name}-fuse = %{version}-%{release}
Requires: %{name}-server = %{version}-%{release}
-Requires: perl(App::Prove) perl(Test::Harness) gcc util-linux-ng lvm2
-Requires: python attr dbench file git libacl-devel mock net-tools nfs-utils xfsprogs yajl
+## thin provisioning support
+Requires: lvm2 >= 2.02.89
+Requires: perl(App::Prove) perl(Test::Harness) gcc util-linux-ng
+Requires: python attr dbench file git libacl-devel mock net-tools
+Requires: nfs-utils xfsprogs yajl
%description regression-tests
The Gluster Test Framework, is a suite of scripts used for
@@ -449,6 +452,8 @@ Requires: %{name} = %{version}-%{release}
Requires: %{name}-cli = %{version}-%{release}
Requires: %{name}-libs = %{version}-%{release}
Requires: %{name}-fuse = %{version}-%{release}
+# Runtime necessity for snapshot
+Requires: lvm2
%if ( 0%{?fedora} ) || ( 0%{?rhel} && 0%{?rhel} >= 6 )
Requires: rpcbind
%else
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,