summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xtests/features/leases.t22
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c25
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.h1
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volume-set.c10
4 files changed, 58 insertions, 0 deletions
diff --git a/tests/features/leases.t b/tests/features/leases.t
new file mode 100755
index 00000000000..27f0405cfb1
--- /dev/null
+++ b/tests/features/leases.t
@@ -0,0 +1,22 @@
+#!/bin/bash
+. $(dirname $0)/../include.rc
+. $(dirname $0)/../volume.rc
+
+cleanup;
+
+## Start and create a volume
+TEST glusterd;
+TEST pidof glusterd;
+TEST $CLI volume info;
+
+TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2};
+TEST $CLI volume start $V0
+TEST $CLI volume set $V0 leases on
+
+TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 $M0;
+TEST mkdir $M0/test
+TEST touch $M0/test/lease
+
+TEST $CLI volume set $V0 leases off
+
+cleanup;
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 505f13afd82..fe7c3405ed3 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -2062,6 +2062,30 @@ out:
}
static int
+brick_graph_add_leases (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
+ dict_t *set_dict, glusterd_brickinfo_t *brickinfo)
+{
+
+ xlator_t *xl = NULL;
+ int ret = -1;
+
+ if (!graph || !volinfo || !set_dict)
+ goto out;
+
+ xl = volgen_graph_add (graph, "features/leases", volinfo->volname);
+ if (!xl) {
+ gf_msg ("glusterd", GF_LOG_WARNING, 0,
+ GD_MSG_GRAPH_FEATURE_ADD_FAIL,
+ "failed to add features/leases to graph");
+ goto out;
+ }
+
+ ret = 0;
+out:
+ return ret;
+}
+
+static int
brick_graph_add_server (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
dict_t *set_dict, glusterd_brickinfo_t *brickinfo)
{
@@ -2271,6 +2295,7 @@ static volgen_brick_xlator_t server_graph_table[] = {
{brick_graph_add_marker, "marker"},
{brick_graph_add_iot, "io-threads"},
{brick_graph_add_upcall, "upcall"},
+ {brick_graph_add_leases, "leases"},
{brick_graph_add_pump, NULL},
{brick_graph_add_ro, NULL},
{brick_graph_add_worm, NULL},
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.h b/xlators/mgmt/glusterd/src/glusterd-volgen.h
index d8dd70bc33b..f90177372dc 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.h
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.h
@@ -99,6 +99,7 @@ typedef enum {
GF_XLATOR_POSIX = 0,
GF_XLATOR_ACL,
GF_XLATOR_LOCKS,
+ GF_XLATOR_LEASES,
GF_XLATOR_UPCALL,
GF_XLATOR_IOT,
GF_XLATOR_INDEX,
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
index 36e5483ee87..2ee969f7c80 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
@@ -2907,6 +2907,16 @@ struct volopt_map_entry glusterd_volopt_map[] = {
.voltype = "features/upcall",
.op_version = GD_OP_VERSION_3_7_0,
},
+ /* Lease translator options */
+ { .key = "features.leases",
+ .voltype = "features/leases",
+ .value = "off",
+ .op_version = GD_OP_VERSION_3_8_0,
+ },
+ { .key = "features.lease-lock-recall-timeout",
+ .voltype = "features/leases",
+ .op_version = GD_OP_VERSION_3_8_0,
+ },
{ .key = "disperse.background-heals",
.voltype = "cluster/disperse",
.op_version = GD_OP_VERSION_3_7_3,