summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-snapshot.c
diff options
context:
space:
mode:
authorAvra Sengupta <asengupt@redhat.com>2014-01-30 02:05:51 +0000
committerRajesh Joseph <rjoseph@redhat.com>2014-02-05 22:37:26 -0800
commita6351ee1c823a295f592f4adf5876a6166d47afe (patch)
treebc62271ad687802918ec4f6fab07914a270af9f3 /xlators/mgmt/glusterd/src/glusterd-snapshot.c
parent6837ff620deb96d93ff4b8ea19689f70beb62c56 (diff)
glusterd/snapshot: Running lvcreate --help to check if setactivationskip is supported
To check if setactivationskip is supported or not, we run lvcreate --help and look for the setactivationskip flag, and accordingly issue lvcreate with or without the said flag. Change-Id: Ief349674ea3f7ceff6b7051b1a5104257e547ce2 Signed-off-by: Avra Sengupta <asengupt@redhat.com> Reviewed-on: http://review.gluster.org/6776 Reviewed-by: Rajesh Joseph <rjoseph@redhat.com> Tested-by: Rajesh Joseph <rjoseph@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-snapshot.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c67
1 files changed, 50 insertions, 17 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index f8a84cb26..b33be0982 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
@@ -2798,15 +2798,18 @@ out:
*/
int
glusterd_take_snapshot (glusterd_brickinfo_t *brickinfo, char *volname,
- char *snapname, dict_t *dict, char **snap_device)
+ char *snapname, char **snap_device)
{
- int ret = -1;
- xlator_t *this = NULL;
- glusterd_conf_t *priv = NULL;
- runner_t runner = {0,};
- char *device = NULL;
- char msg[1024] = {0, };
- char *tmp = NULL;
+ char msg[NAME_MAX] = "";
+ char buf[PATH_MAX] = "";
+ char *tmp = NULL;
+ char *ptr = NULL;
+ char *device = NULL;
+ int ret = -1;
+ gf_boolean_t match = _gf_false;
+ glusterd_conf_t *priv = NULL;
+ runner_t runner = {0,};
+ xlator_t *this = NULL;
this = THIS;
priv = this->private;
@@ -2824,24 +2827,54 @@ glusterd_take_snapshot (glusterd_brickinfo_t *brickinfo, char *volname,
goto out;
}
+ /* Figuring out if setactivationskip flag is supported or not */
runinit (&runner);
- snprintf (msg, sizeof (msg), "taking snapshot of the brick %s:%s",
- brickinfo->hostname, brickinfo->path);
- runner_add_args (&runner, "/sbin/lvcreate", "-s", device,
- "--setactivationskip", "n", "--name", snapname, NULL);
+ snprintf (msg, sizeof (msg), "running lvcreate help");
+ runner_add_args (&runner, "/sbin/lvcreate", "--help", NULL);
runner_log (&runner, "", GF_LOG_DEBUG, msg);
+ runner_redir (&runner, STDOUT_FILENO, RUN_PIPE);
+ ret = runner_start (&runner);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "Failed to run lvcreate help");
+ runner_end (&runner);
+ goto out;
+ }
- //let glusterd get blocked till snapshot is over
- synclock_unlock (&priv->big_lock);
- ret = runner_run (&runner);
- synclock_lock (&priv->big_lock);
+ /* Looking for setactivationskip in lvcreate --help */
+ do {
+ ptr = fgets(buf, sizeof(buf),
+ runner_chio (&runner, STDOUT_FILENO));
+ if (ptr) {
+ if (strstr(buf, "setactivationskip")) {
+ match = _gf_true;
+ break;
+ }
+ }
+ } while (ptr != NULL);
+ runner_end (&runner);
+ /* Takng the actual snapshot */
+ runinit (&runner);
+ snprintf (msg, sizeof (msg), "taking snapshot of the brick %s:%s",
+ brickinfo->hostname, brickinfo->path);
+ if (match == _gf_true)
+ runner_add_args (&runner, "/sbin/lvcreate", "-s", device,
+ "--setactivationskip", "n", "--name",
+ snapname, NULL);
+ else
+ runner_add_args (&runner, "/sbin/lvcreate", "-s", device,
+ "--name", snapname, NULL);
+ runner_log (&runner, "", GF_LOG_DEBUG, msg);
+ ret = runner_start (&runner);
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "taking snapshot of the "
"brick (%s:%s) of device %s failed",
brickinfo->hostname, brickinfo->path, device);
+ runner_end (&runner);
goto out;
}
+ runner_end (&runner);
gf_log (this->name, GF_LOG_INFO, "device: %s", device);
if (device) {
@@ -3125,7 +3158,7 @@ glusterd_do_snap (glusterd_volinfo_t *volinfo, char *snapname, dict_t *dict,
ret = glusterd_take_snapshot (brickinfo,
volinfo->volname,
- snapname, dict, &device);
+ snapname, &device);
/* Fail the snapshot even though snapshot on one of
the bricks fails. At the end when we check whether
the snapshot volume meets quorum or not, then the