From f5e52561d66f3777e4ec75992e52200779d9add1 Mon Sep 17 00:00:00 2001 From: Anoop C S Date: Wed, 4 Feb 2015 10:34:33 +0530 Subject: features/locks: Implement mandatory locks Initial change to fix/enable the mandatory locking support in GlusterFS as per the following design: https://review.gluster.org/#/c/12014/ Accordingly 'locks.mandatory-locking' option is available as part of this change which will accept one among the following values: * off * file * forced * optimal See design doc for more details > Reviewed-on: http://review.gluster.org/9768 > Smoke: Gluster Build System > CentOS-regression: Gluster Build System > NetBSD-regression: NetBSD Build System > Reviewed-by: Poornima G > Reviewed-by: Raghavendra Talur > Reviewed-by: Rajesh Joseph > Reviewed-by: Pranith Kumar Karampuri (cherry picked from commit 4517bf8dd6de310950cc5a612955aa3a2fddb57e) Change-Id: I14c489b3f8af5ebcbfa155a03f0c175e9558ac46 BUG: 1332162 Signed-off-by: Anoop C S Reviewed-on: http://review.gluster.org/14149 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System Reviewed-by: Niels de Vos CentOS-regression: Gluster Build System --- xlators/mgmt/glusterd/src/glusterd-volume-set.c | 35 ++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'xlators/mgmt') diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c index 68dec22ecaf..008a4589e10 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c @@ -790,6 +790,35 @@ validate_replica_heal_enable_disable (glusterd_volinfo_t *volinfo, dict_t *dict, return ret; } +static int +validate_mandatory_locking (glusterd_volinfo_t *volinfo, dict_t *dict, + char *key, char *value, char **op_errstr) +{ + char errstr[2048] = ""; + int ret = 0; + xlator_t *this = NULL; + + this = THIS; + GF_ASSERT (this); + + if (strcmp (value, "off") != 0 && strcmp (value, "file") != 0 && + strcmp(value, "forced") != 0 && + strcmp(value, "optimal") != 0) { + snprintf (errstr, sizeof(errstr), "Invalid option value '%s':" + " Available options are 'off', 'file', " + "'forced' or 'optimal'", value); + gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_INVALID_ENTRY, + "%s", errstr); + *op_errstr = gf_strdup (errstr); + ret = -1; + goto out; + } +out: + gf_msg_debug (this->name, 0, "Returning %d", ret); + + return ret; +} + static int validate_disperse_heal_enable_disable (glusterd_volinfo_t *volinfo, dict_t *dict, char *key, char *value, @@ -2789,9 +2818,13 @@ struct volopt_map_entry glusterd_volopt_map[] = { #endif /* USE_GFDB */ { .key = "locks.trace", .voltype = "features/locks", - .type = NO_DOC, .op_version = GD_OP_VERSION_3_7_0, }, + { .key = "locks.mandatory-locking", + .voltype = "features/locks", + .op_version = GD_OP_VERSION_4_0_0, + .validate_fn = validate_mandatory_locking, + }, { .key = "cluster.disperse-self-heal-daemon", .voltype = "cluster/disperse", .type = NO_DOC, -- cgit