diff options
-rw-r--r-- | glusterfs.spec.in | 9 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-snapshot.c | 48 |
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, |