diff options
Diffstat (limited to 'xlators/features/barrier/src')
| -rw-r--r-- | xlators/features/barrier/src/barrier-mem-types.h | 2 | ||||
| -rw-r--r-- | xlators/features/barrier/src/barrier.c | 100 | ||||
| -rw-r--r-- | xlators/features/barrier/src/barrier.h | 9 |
3 files changed, 55 insertions, 56 deletions
diff --git a/xlators/features/barrier/src/barrier-mem-types.h b/xlators/features/barrier/src/barrier-mem-types.h index 93ccab633ce..71ed7898d9c 100644 --- a/xlators/features/barrier/src/barrier-mem-types.h +++ b/xlators/features/barrier/src/barrier-mem-types.h @@ -11,7 +11,7 @@ #ifndef __BARRIER_MEM_TYPES_H__ #define __BARRIER_MEM_TYPES_H__ -#include "mem-types.h" +#include <glusterfs/mem-types.h> enum gf_barrier_mem_types_ { gf_barrier_mt_priv_t = gf_common_mt_end + 1, diff --git a/xlators/features/barrier/src/barrier.c b/xlators/features/barrier/src/barrier.c index 1c5c5ffdc22..852bbacb99d 100644 --- a/xlators/features/barrier/src/barrier.c +++ b/xlators/features/barrier/src/barrier.c @@ -9,10 +9,10 @@ */ #include "barrier.h" -#include "defaults.h" -#include "call-stub.h" +#include <glusterfs/defaults.h> +#include <glusterfs/call-stub.h> -#include "statedump.h" +#include <glusterfs/statedump.h> void barrier_local_set_gfid(call_frame_t *frame, uuid_t gfid, xlator_t *this) @@ -461,16 +461,14 @@ out: int notify(xlator_t *this, int event, void *data, ...) { - barrier_priv_t *priv = NULL; + barrier_priv_t *priv = this->private; dict_t *dict = NULL; - gf_boolean_t past = _gf_false; int ret = -1; int barrier_enabled = _gf_false; struct list_head queue = { 0, }; - priv = this->private; GF_ASSERT(priv); INIT_LIST_HEAD(&queue); @@ -488,35 +486,27 @@ notify(xlator_t *this, int event, void *data, ...) LOCK(&priv->lock); { - past = priv->barrier_enabled; - - switch (past) { - case _gf_false: - if (barrier_enabled) { - ret = __barrier_enable(this, priv); - if (ret) - goto unlock; - } else { - gf_log(this->name, GF_LOG_ERROR, - "Already disabled."); - goto unlock; - } - break; - - case _gf_true: - if (!barrier_enabled) { - __barrier_disable(this, &queue); - } else { - gf_log(this->name, GF_LOG_ERROR, "Already enabled"); - goto unlock; - } - break; + if (!priv->barrier_enabled) { + if (barrier_enabled) { + ret = __barrier_enable(this, priv); + } else { + UNLOCK(&priv->lock); + gf_log(this->name, GF_LOG_ERROR, "Already disabled."); + goto post_unlock; + } + } else { + if (!barrier_enabled) { + __barrier_disable(this, &queue); + ret = 0; + } else { + UNLOCK(&priv->lock); + gf_log(this->name, GF_LOG_ERROR, "Already enabled"); + goto post_unlock; + } } - ret = 0; } - unlock: UNLOCK(&priv->lock); - + post_unlock: if (!list_empty(&queue)) barrier_dequeue_all(this, &queue); @@ -536,7 +526,6 @@ int reconfigure(xlator_t *this, dict_t *options) { barrier_priv_t *priv = NULL; - gf_boolean_t past = _gf_false; int ret = -1; gf_boolean_t barrier_enabled = _gf_false; uint32_t timeout = { @@ -556,23 +545,17 @@ reconfigure(xlator_t *this, dict_t *options) LOCK(&priv->lock); { - past = priv->barrier_enabled; - - switch (past) { - case _gf_false: - if (barrier_enabled) { - ret = __barrier_enable(this, priv); - if (ret) { - goto unlock; - } + if (!priv->barrier_enabled) { + if (barrier_enabled) { + ret = __barrier_enable(this, priv); + if (ret) { + goto unlock; } - break; - - case _gf_true: - if (!barrier_enabled) { - __barrier_disable(this, &queue); - } - break; + } + } else { + if (!barrier_enabled) { + __barrier_disable(this, &queue); + } } priv->timeout.tv_sec = timeout; ret = 0; @@ -746,13 +729,13 @@ barrier_dump_priv(xlator_t *this) gf_proc_dump_build_key(key, "xlator.features.barrier", "priv"); gf_proc_dump_add_section("%s", key); + gf_proc_dump_build_key(key, "barrier", "enabled"); LOCK(&priv->lock); { - gf_proc_dump_build_key(key, "barrier", "enabled"); gf_proc_dump_write(key, "%d", priv->barrier_enabled); gf_proc_dump_build_key(key, "barrier", "timeout"); - gf_proc_dump_write(key, "%" PRId64, priv->timeout.tv_sec); + gf_proc_dump_write(key, "%ld", priv->timeout.tv_sec); if (priv->barrier_enabled) { gf_proc_dump_build_key(key, "barrier", "queue_size"); gf_proc_dump_write(key, "%d", priv->queue_size); @@ -809,3 +792,18 @@ struct volume_options options[] = { "blocked acknowledgements are sent to the application"}, {.key = {NULL}}, }; + +xlator_api_t xlator_api = { + .init = init, + .fini = fini, + .notify = notify, + .reconfigure = reconfigure, + .mem_acct_init = mem_acct_init, + .op_version = {1}, /* Present from the initial version */ + .dumpops = &dumpops, + .fops = &fops, + .cbks = &cbks, + .options = options, + .identifier = "barrier", + .category = GF_MAINTAINED, +}; diff --git a/xlators/features/barrier/src/barrier.h b/xlators/features/barrier/src/barrier.h index d11d71d151e..1337f311f7d 100644 --- a/xlators/features/barrier/src/barrier.h +++ b/xlators/features/barrier/src/barrier.h @@ -12,9 +12,9 @@ #define __BARRIER_H__ #include "barrier-mem-types.h" -#include "xlator.h" -#include "timer.h" -#include "call-stub.h" +#include <glusterfs/xlator.h> +#include <glusterfs/timer.h> +#include <glusterfs/call-stub.h> #define BARRIER_FOP_CBK(fop_name, label, frame, this, params...) \ do { \ @@ -65,11 +65,12 @@ typedef struct { gf_timer_t *timer; - gf_boolean_t barrier_enabled; gf_lock_t lock; struct list_head queue; struct timespec timeout; uint32_t queue_size; + gf_boolean_t barrier_enabled; + char _pad[3]; /* manual padding */ } barrier_priv_t; int |
