summaryrefslogtreecommitdiffstats
path: root/xlators/playground/template/src/template.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/playground/template/src/template.c')
-rw-r--r--xlators/playground/template/src/template.c227
1 files changed, 111 insertions, 116 deletions
diff --git a/xlators/playground/template/src/template.c b/xlators/playground/template/src/template.c
index 8cbc086a302..c832167dc16 100644
--- a/xlators/playground/template/src/template.c
+++ b/xlators/playground/template/src/template.c
@@ -11,181 +11,176 @@
#include "statedump.h"
static int32_t
-template_mem_acct_init (xlator_t *this)
+template_mem_acct_init(xlator_t *this)
{
- int ret = -1;
+ int ret = -1;
- GF_VALIDATE_OR_GOTO ("template", this, out);
+ GF_VALIDATE_OR_GOTO("template", this, out);
- ret = xlator_mem_acct_init (this, gf_template_mt_end + 1);
+ ret = xlator_mem_acct_init(this, gf_template_mt_end + 1);
- if (ret != 0) {
- gf_msg (this->name, GF_LOG_ERROR, ENOMEM, TEMPLATE_MSG_NO_MEMORY,
- "Memory accounting init failed");
- goto out;
- }
+ if (ret != 0) {
+ gf_msg(this->name, GF_LOG_ERROR, ENOMEM, TEMPLATE_MSG_NO_MEMORY,
+ "Memory accounting init failed");
+ goto out;
+ }
- ret = 0;
+ ret = 0;
out:
- return ret;
+ return ret;
}
static int32_t
-template_priv_to_dict (xlator_t *this, dict_t *dict, char *brickname)
+template_priv_to_dict(xlator_t *this, dict_t *dict, char *brickname)
{
- int ret = 0;
- template_private_t *priv = NULL;
+ int ret = 0;
+ template_private_t *priv = NULL;
- priv = this->private;
- ret = dict_set_uint64 (dict, "template.dummy", priv->dummy);
- if (ret)
- gf_msg_debug (this->name, ENOMEM,
- "dict_set of dummy key failed");
+ priv = this->private;
+ ret = dict_set_uint64(dict, "template.dummy", priv->dummy);
+ if (ret)
+ gf_msg_debug(this->name, ENOMEM, "dict_set of dummy key failed");
- return 0;
+ return 0;
}
-
static int32_t
-template_priv (xlator_t *this)
+template_priv(xlator_t *this)
{
- template_private_t *priv = NULL;
+ template_private_t *priv = NULL;
- priv = this->private;
- gf_proc_dump_write ("template.dummy", "%lu", priv->dummy);
+ priv = this->private;
+ gf_proc_dump_write("template.dummy", "%lu", priv->dummy);
- return 0;
+ return 0;
}
static int32_t
-template_dump_metrics (xlator_t *this, int fd)
+template_dump_metrics(xlator_t *this, int fd)
{
- template_private_t *priv = NULL;
+ template_private_t *priv = NULL;
- priv = this->private;
- /* NOTE: currently this is adding private variable, which can
- be constant here. But in reality, things which are changing
- can be added here, so we get to plot them on graph. */
- dprintf (fd, "%s.private.dummy %d\n", this->name, priv->dummy);
+ priv = this->private;
+ /* NOTE: currently this is adding private variable, which can
+ be constant here. But in reality, things which are changing
+ can be added here, so we get to plot them on graph. */
+ dprintf(fd, "%s.private.dummy %d\n", this->name, priv->dummy);
- return 0;
+ return 0;
}
static int32_t
-template_init (xlator_t *this)
+template_init(xlator_t *this)
{
- int ret = -1;
- template_private_t *priv = NULL;
-
- if (!this->children || this->children->next) {
- gf_msg (this->name, GF_LOG_ERROR, EINVAL, TEMPLATE_MSG_NO_GRAPH,
- "not configured with exactly one child. exiting");
- goto out;
- }
-
- if (!this->parents) {
- gf_msg (this->name, GF_LOG_ERROR, EINVAL, TEMPLATE_MSG_NO_GRAPH,
- "dangling volume. check volfile ");
- goto out;
- }
-
- priv = GF_CALLOC (1, sizeof (template_private_t),
- gf_template_mt_private_t);
- if (!priv) {
- gf_msg (this->name, GF_LOG_ERROR, ENOMEM, TEMPLATE_MSG_NO_MEMORY,
- "priv allocation failed");
- goto out;
- }
-
- GF_OPTION_INIT ("dummy", priv->dummy, int32, out);
-
- this->private = priv;
- priv = NULL;
- ret = 0;
+ int ret = -1;
+ template_private_t *priv = NULL;
+
+ if (!this->children || this->children->next) {
+ gf_msg(this->name, GF_LOG_ERROR, EINVAL, TEMPLATE_MSG_NO_GRAPH,
+ "not configured with exactly one child. exiting");
+ goto out;
+ }
+
+ if (!this->parents) {
+ gf_msg(this->name, GF_LOG_ERROR, EINVAL, TEMPLATE_MSG_NO_GRAPH,
+ "dangling volume. check volfile ");
+ goto out;
+ }
+
+ priv = GF_CALLOC(1, sizeof(template_private_t), gf_template_mt_private_t);
+ if (!priv) {
+ gf_msg(this->name, GF_LOG_ERROR, ENOMEM, TEMPLATE_MSG_NO_MEMORY,
+ "priv allocation failed");
+ goto out;
+ }
+
+ GF_OPTION_INIT("dummy", priv->dummy, int32, out);
+
+ this->private = priv;
+ priv = NULL;
+ ret = 0;
out:
- if (priv)
- GF_FREE (priv);
+ if (priv)
+ GF_FREE(priv);
- return ret;
+ return ret;
}
static int
-template_reconfigure (xlator_t *this, dict_t *options)
+template_reconfigure(xlator_t *this, dict_t *options)
{
- int ret = -1;
- template_private_t *priv = NULL;
+ int ret = -1;
+ template_private_t *priv = NULL;
- priv = this->private;
+ priv = this->private;
- GF_OPTION_RECONF ("dummy", priv->dummy, options, int32, out);
+ GF_OPTION_RECONF("dummy", priv->dummy, options, int32, out);
- ret = 0;
- out:
- return ret;
+ ret = 0;
+out:
+ return ret;
}
static void
-template_fini (xlator_t *this)
+template_fini(xlator_t *this)
{
- template_private_t *priv = NULL;
+ template_private_t *priv = NULL;
- priv = this->private;
- this->private = NULL;
+ priv = this->private;
+ this->private = NULL;
- GF_FREE (priv);
+ GF_FREE(priv);
}
static int
-template_notify (xlator_t *this, int32_t event, void *data, ...)
+template_notify(xlator_t *this, int32_t event, void *data, ...)
{
- switch (event) {
+ switch (event) {
default:
- default_notify (this, event, data);
- gf_msg_debug (this->name, 0, "event %d received", event);
- }
+ default_notify(this, event, data);
+ gf_msg_debug(this->name, 0, "event %d received", event);
+ }
- return 0;
+ return 0;
}
-struct xlator_fops template_fops = {
-};
+struct xlator_fops template_fops = {};
-struct xlator_cbks template_cbks = {
-};
+struct xlator_cbks template_cbks = {};
struct xlator_dumpops template_dumpops = {
- .priv = template_priv,
- .priv_to_dict = template_priv_to_dict,
+ .priv = template_priv,
+ .priv_to_dict = template_priv_to_dict,
};
struct volume_options template_options[] = {
- { .key = {"dummy"},
- .type = GF_OPTION_TYPE_INT,
- .min = 1,
- .max = 1024,
- .default_value = "1",
- .description = "a dummy option to show how to set the option",
- .op_version = {GD_OP_VERSION_4_2_0},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC,
- .level = OPT_STATUS_EXPERIMENTAL,
- .tags = { "development", "experimental", "template" },
- },
- { .key = {NULL} },
+ {
+ .key = {"dummy"},
+ .type = GF_OPTION_TYPE_INT,
+ .min = 1,
+ .max = 1024,
+ .default_value = "1",
+ .description = "a dummy option to show how to set the option",
+ .op_version = {GD_OP_VERSION_4_2_0},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC,
+ .level = OPT_STATUS_EXPERIMENTAL,
+ .tags = {"development", "experimental", "template"},
+ },
+ {.key = {NULL}},
};
-
xlator_api_t xlator_api = {
- .init = template_init,
- .fini = template_fini,
- .notify = template_notify,
- .reconfigure = template_reconfigure,
- .mem_acct_init = template_mem_acct_init,
- .dump_metrics = template_dump_metrics,
- .op_version = {GD_OP_VERSION_4_2_0},
- .dumpops = &template_dumpops,
- .fops = &template_fops,
- .cbks = &template_cbks,
- .options = template_options,
- .identifier = "template",
+ .init = template_init,
+ .fini = template_fini,
+ .notify = template_notify,
+ .reconfigure = template_reconfigure,
+ .mem_acct_init = template_mem_acct_init,
+ .dump_metrics = template_dump_metrics,
+ .op_version = {GD_OP_VERSION_4_2_0},
+ .dumpops = &template_dumpops,
+ .fops = &template_fops,
+ .cbks = &template_cbks,
+ .options = template_options,
+ .identifier = "template",
};