diff options
Diffstat (limited to 'xlators/mgmt/glusterd/src')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volgen.c | 10 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volume-set.c | 113 |
2 files changed, 114 insertions, 9 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index 23890238933..e88116e02ba 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -2075,7 +2075,8 @@ brick_graph_add_ro (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, goto out; if (dict_get_str_boolean (set_dict, "features.read-only", 0) && - dict_get_str_boolean (set_dict, "features.worm", 0)) { + (dict_get_str_boolean (set_dict, "features.worm", 0) || + dict_get_str_boolean (set_dict, "features.worm-file-level", 0))) { gf_msg (THIS->name, GF_LOG_ERROR, errno, GD_MSG_DICT_GET_FAILED, "read-only and worm cannot be set together"); @@ -2107,7 +2108,8 @@ brick_graph_add_worm (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, goto out; if (dict_get_str_boolean (set_dict, "features.read-only", 0) && - dict_get_str_boolean (set_dict, "features.worm", 0)) { + (dict_get_str_boolean (set_dict, "features.worm", 0) || + dict_get_str_boolean (set_dict, "features.worm-file-level", 0))) { gf_msg (THIS->name, GF_LOG_ERROR, 0, GD_MSG_INCOMPATIBLE_VALUE, "read-only and worm cannot be set together"); @@ -2402,8 +2404,6 @@ static volgen_brick_xlator_t server_graph_table[] = { {brick_graph_add_server, NULL}, {brick_graph_add_io_stats, NULL}, {brick_graph_add_cdc, NULL}, - {brick_graph_add_ro, NULL}, - {brick_graph_add_worm, NULL}, {brick_graph_add_quota, "quota"}, {brick_graph_add_index, "index"}, {brick_graph_add_barrier, NULL}, @@ -2412,6 +2412,8 @@ static volgen_brick_xlator_t server_graph_table[] = { {brick_graph_add_iot, "io-threads"}, {brick_graph_add_upcall, "upcall"}, {brick_graph_add_pump, NULL}, + {brick_graph_add_ro, NULL}, + {brick_graph_add_worm, NULL}, {brick_graph_add_locks, "locks"}, {brick_graph_add_acl, "acl"}, {brick_graph_add_bitrot_stub, "bitrot-stub"}, diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c index 5bb9d9077b5..68dec22ecaf 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c @@ -863,6 +863,82 @@ out: return ret; } + +static int +validate_worm (glusterd_volinfo_t *volinfo, dict_t *dict, char *key, + char *value, char **op_errstr) +{ + xlator_t *this = NULL; + gf_boolean_t b = _gf_false; + int ret = -1; + + this = THIS; + GF_VALIDATE_OR_GOTO ("glusterd", this, out); + ret = gf_string2boolean (value, &b); + if (ret) { + gf_asprintf (op_errstr, "%s is not a valid boolean value. %s " + "expects a valid boolean value.", value, key); + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_INVALID_ENTRY, "%s", *op_errstr); + } +out: + gf_msg_debug ("glusterd", 0, "Returning %d", ret); + + return ret; +} + + +static int +validate_worm_period (glusterd_volinfo_t *volinfo, dict_t *dict, char *key, + char *value, char **op_errstr) +{ + xlator_t *this = NULL; + uint64_t period = -1; + int ret = -1; + + this = THIS; + GF_VALIDATE_OR_GOTO ("glusterd", this, out); + ret = gf_string2uint64 (value, &period); + if (ret) { + gf_asprintf (op_errstr, "%s is not a valid uint64_t value." + " %s expects a valid uint64_t value.", value, key); + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_INVALID_ENTRY, "%s", *op_errstr); + } +out: + gf_msg_debug ("glusterd", 0, "Returning %d", ret); + + return ret; +} + + +static int +validate_reten_mode (glusterd_volinfo_t *volinfo, dict_t *dict, char *key, + char *value, char **op_errstr) +{ + xlator_t *this = NULL; + int ret = -1; + + this = THIS; + GF_VALIDATE_OR_GOTO ("glusterd", this, out); + if ((strcmp (value, "relax") && + strcmp (value, "enterprise"))) { + gf_asprintf (op_errstr, "The value of retention mode should be " + "either relax or enterprise. But the value" + " of %s is %s", key, value); + gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_INVALID_ENTRY, + "%s", *op_errstr); + ret = -1; + goto out; + } + ret = 0; +out: + gf_msg_debug ("glusterd", 0, "Returning %d", ret); + + return ret; +} + + /* dispatch table for VOLUME SET * ----------------------------- * @@ -2314,13 +2390,40 @@ struct volopt_map_entry glusterd_volopt_map[] = { .op_version = 1, .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_XLATOR_OPT }, - { .key = "features.worm", - .voltype = "features/worm", - .option = "worm", - .value = "off", - .op_version = 2, + { .key = "features.worm", + .voltype = "features/worm", + .option = "worm", + .value = "off", + .validate_fn = validate_worm, + .op_version = 2, + .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_XLATOR_OPT + }, + { .key = "features.worm-file-level", + .voltype = "features/worm", + .option = "worm-file-level", + .value = "off", + .validate_fn = validate_worm, + .op_version = GD_OP_VERSION_3_8_0, .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_XLATOR_OPT }, + { .key = "features.default-retention-period", + .voltype = "features/worm", + .option = "default-retention-period", + .validate_fn = validate_worm_period, + .op_version = GD_OP_VERSION_3_8_0, + }, + { .key = "features.retention-mode", + .voltype = "features/worm", + .option = "retention-mode", + .validate_fn = validate_reten_mode, + .op_version = GD_OP_VERSION_3_8_0, + }, + { .key = "features.auto-commit-period", + .voltype = "features/worm", + .option = "auto-commit-period", + .validate_fn = validate_worm_period, + .op_version = GD_OP_VERSION_3_8_0, + }, { .key = "storage.linux-aio", .voltype = "storage/posix", .op_version = 1 |