diff options
author | Gluster Ant <bugzilla-bot@gluster.org> | 2018-09-12 17:52:45 +0530 |
---|---|---|
committer | Nigel Babu <nigelb@redhat.com> | 2018-09-12 17:52:45 +0530 |
commit | e16868dede6455cab644805af6fe1ac312775e13 (patch) | |
tree | 15aebdb4fff2d87cf8a72f836816b3aa634da58d /xlators/experimental/jbr-client | |
parent | 45a71c0548b6fd2c757aa2e7b7671a1411948894 (diff) |
Land part 2 of clang-format changes
Change-Id: Ia84cc24c8924e6d22d02ac15f611c10e26db99b4
Signed-off-by: Nigel Babu <nigelb@redhat.com>
Diffstat (limited to 'xlators/experimental/jbr-client')
-rw-r--r-- | xlators/experimental/jbr-client/src/fop-template.c | 171 | ||||
-rw-r--r-- | xlators/experimental/jbr-client/src/jbrc.c | 373 |
2 files changed, 263 insertions, 281 deletions
diff --git a/xlators/experimental/jbr-client/src/fop-template.c b/xlators/experimental/jbr-client/src/fop-template.c index 7719f511f01..d2f2212c480 100644 --- a/xlators/experimental/jbr-client/src/fop-template.c +++ b/xlators/experimental/jbr-client/src/fop-template.c @@ -1,113 +1,104 @@ /* template-name fop */ -int32_t -jbrc_@NAME@ (call_frame_t *frame, xlator_t *this, - @LONG_ARGS@) +int32_t jbrc_ @NAME @(call_frame_t *frame, xlator_t *this, @LONG_ARGS @) { - jbrc_local_t *local = NULL; - xlator_t *target_xl = ACTIVE_CHILD(this); + jbrc_local_t *local = NULL; + xlator_t *target_xl = ACTIVE_CHILD(this); - local = mem_get(this->local_pool); - if (!local) { - goto err; - } + local = mem_get(this->local_pool); + if (!local) { + goto err; + } - local->stub = fop_@NAME@_stub (frame, jbrc_@NAME@_continue, - @SHORT_ARGS@); - if (!local->stub) { - goto err; - } - local->curr_xl = target_xl; - local->scars = 0; + local->stub = fop_ @NAME + @_stub(frame, jbrc_ @NAME @_continue, @SHORT_ARGS @); + if (!local->stub) { + goto err; + } + local->curr_xl = target_xl; + local->scars = 0; - frame->local = local; - STACK_WIND_COOKIE (frame, jbrc_@NAME@_cbk, target_xl, - target_xl, target_xl->fops->@NAME@, - @SHORT_ARGS@); - return 0; + frame->local = local; + STACK_WIND_COOKIE(frame, jbrc_ @NAME @_cbk, target_xl, target_xl, + target_xl->fops->@NAME @, @SHORT_ARGS @); + return 0; err: - if (local) { - mem_put(local); - } - STACK_UNWIND_STRICT (@NAME@, frame, -1, ENOMEM, - @ERROR_ARGS@); - return 0; + if (local) { + mem_put(local); + } + STACK_UNWIND_STRICT(@NAME @, frame, -1, ENOMEM, @ERROR_ARGS @); + return 0; } /* template-name cbk */ -int32_t -jbrc_@NAME@_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, - @LONG_ARGS@) +int32_t jbrc_ @NAME @_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, @LONG_ARGS @) { - jbrc_local_t *local = frame->local; - xlator_t *last_xl = cookie; - xlator_t *next_xl; - jbrc_private_t *priv = this->private; - struct timespec spec; + jbrc_local_t *local = frame->local; + xlator_t *last_xl = cookie; + xlator_t *next_xl; + jbrc_private_t *priv = this->private; + struct timespec spec; - if (op_ret != (-1)) { - if (local->scars) { - gf_msg (this->name, GF_LOG_INFO, 0, J_MSG_RETRY_MSG, - HILITE("retried %p OK"), frame->local); - } - priv->active = last_xl; - goto unwind; - } - if ((op_errno != EREMOTE) && (op_errno != ENOTCONN)) { - goto unwind; + if (op_ret != (-1)) { + if (local->scars) { + gf_msg(this->name, GF_LOG_INFO, 0, J_MSG_RETRY_MSG, + HILITE("retried %p OK"), frame->local); } + priv->active = last_xl; + goto unwind; + } + if ((op_errno != EREMOTE) && (op_errno != ENOTCONN)) { + goto unwind; + } - /* TBD: get leader ID from xdata? */ - next_xl = next_xlator(this, last_xl); - /* - * We can't just give up after we've tried all bricks, because it's - * quite likely that a new leader election just hasn't finished yet. - * We also shouldn't retry endlessly, and especially not at a high - * rate, but that's good enough while we work on other things. - * - * TBD: implement slow/finite retry via a worker thread - */ - if (!next_xl || (local->scars >= SCAR_LIMIT)) { - gf_msg (this->name, GF_LOG_DEBUG, 0, J_MSG_RETRY_MSG, - HILITE("ran out of retries for %p"), frame->local); - goto unwind; - } + /* TBD: get leader ID from xdata? */ + next_xl = next_xlator(this, last_xl); + /* + * We can't just give up after we've tried all bricks, because it's + * quite likely that a new leader election just hasn't finished yet. + * We also shouldn't retry endlessly, and especially not at a high + * rate, but that's good enough while we work on other things. + * + * TBD: implement slow/finite retry via a worker thread + */ + if (!next_xl || (local->scars >= SCAR_LIMIT)) { + gf_msg(this->name, GF_LOG_DEBUG, 0, J_MSG_RETRY_MSG, + HILITE("ran out of retries for %p"), frame->local); + goto unwind; + } - local->curr_xl = next_xl; - local->scars += 1; - spec.tv_sec = 1; - spec.tv_nsec = 0; - /* - * WARNING - * - * Just calling gf_timer_call_after like this leaves open the - * possibility that writes will get reordered, if a first write is - * rescheduled and then a second comes along to find an updated - * priv->active before the first actually executes. We might need to - * implement a stricter (and more complicated) queuing mechanism to - * ensure absolute consistency in this case. - */ - if (gf_timer_call_after(this->ctx, spec, jbrc_retry_cb, local)) { - return 0; - } + local->curr_xl = next_xl; + local->scars += 1; + spec.tv_sec = 1; + spec.tv_nsec = 0; + /* + * WARNING + * + * Just calling gf_timer_call_after like this leaves open the + * possibility that writes will get reordered, if a first write is + * rescheduled and then a second comes along to find an updated + * priv->active before the first actually executes. We might need to + * implement a stricter (and more complicated) queuing mechanism to + * ensure absolute consistency in this case. + */ + if (gf_timer_call_after(this->ctx, spec, jbrc_retry_cb, local)) { + return 0; + } unwind: - call_stub_destroy(local->stub); - STACK_UNWIND_STRICT (@NAME@, frame, op_ret, op_errno, - @SHORT_ARGS@); - return 0; + call_stub_destroy(local->stub); + STACK_UNWIND_STRICT(@NAME @, frame, op_ret, op_errno, @SHORT_ARGS @); + return 0; } /* template-name cont-func */ -int32_t -jbrc_@NAME@_continue (call_frame_t *frame, xlator_t *this, - @LONG_ARGS@) +int32_t jbrc_ @NAME + @_continue(call_frame_t *frame, xlator_t *this, @LONG_ARGS @) { - jbrc_local_t *local = frame->local; + jbrc_local_t *local = frame->local; - STACK_WIND_COOKIE (frame, jbrc_@NAME@_cbk, local->curr_xl, - local->curr_xl, local->curr_xl->fops->@NAME@, - @SHORT_ARGS@); - return 0; + STACK_WIND_COOKIE(frame, jbrc_ @NAME @_cbk, local->curr_xl, local->curr_xl, + local->curr_xl->fops->@NAME @, @SHORT_ARGS @); + return 0; } diff --git a/xlators/experimental/jbr-client/src/jbrc.c b/xlators/experimental/jbr-client/src/jbrc.c index 9bb9346c5c0..01c3020e117 100644 --- a/xlators/experimental/jbr-client/src/jbrc.c +++ b/xlators/experimental/jbr-client/src/jbrc.c @@ -20,8 +20,8 @@ #include "jbrc.h" #include "statedump.h" -#define SCAR_LIMIT 20 -#define HILITE(x) ("[1;33m"x"[0m") +#define SCAR_LIMIT 20 +#define HILITE(x) ("[1;33m" x "[0m") /* * The fops are actually generated by gen-fops.py; the rest was mostly copied @@ -29,292 +29,283 @@ */ enum gf_dht_mem_types_ { - gf_mt_jbrc_private_t = gf_common_mt_end + 1, - gf_mt_jbrc_end + gf_mt_jbrc_private_t = gf_common_mt_end + 1, + gf_mt_jbrc_end }; -char *JBRC_XATTR = "user.jbr.active"; +char *JBRC_XATTR = "user.jbr.active"; -static inline -xlator_t * -ACTIVE_CHILD (xlator_t *parent) +static inline xlator_t * +ACTIVE_CHILD(xlator_t *parent) { - jbrc_private_t *priv = parent->private; + jbrc_private_t *priv = parent->private; - return priv ? priv->active : FIRST_CHILD(parent); + return priv ? priv->active : FIRST_CHILD(parent); } xlator_t * -next_xlator (xlator_t *this, xlator_t *prev) +next_xlator(xlator_t *this, xlator_t *prev) { - xlator_list_t *trav; + xlator_list_t *trav; - for (trav = this->children; trav; trav = trav->next) { - if (trav->xlator == prev) { - return trav->next ? trav->next->xlator - : this->children->xlator; - } + for (trav = this->children; trav; trav = trav->next) { + if (trav->xlator == prev) { + return trav->next ? trav->next->xlator : this->children->xlator; } + } - return NULL; + return NULL; } void -jbrc_retry_cb (void *cb_arg) +jbrc_retry_cb(void *cb_arg) { - jbrc_local_t *local = cb_arg; + jbrc_local_t *local = cb_arg; - gf_msg (__func__, GF_LOG_INFO, 0, J_MSG_RETRY_MSG, - HILITE("retrying %p"), local); - call_resume_wind(local->stub); + gf_msg(__func__, GF_LOG_INFO, 0, J_MSG_RETRY_MSG, HILITE("retrying %p"), + local); + call_resume_wind(local->stub); } #pragma generate int32_t -jbrc_forget (xlator_t *this, inode_t *inode) +jbrc_forget(xlator_t *this, inode_t *inode) { - gf_msg_callingfn (this->name, GF_LOG_WARNING, 0, J_MSG_INIT_FAIL, - "xlator does not implement forget_cbk"); - return 0; + gf_msg_callingfn(this->name, GF_LOG_WARNING, 0, J_MSG_INIT_FAIL, + "xlator does not implement forget_cbk"); + return 0; } - int32_t -jbrc_releasedir (xlator_t *this, fd_t *fd) +jbrc_releasedir(xlator_t *this, fd_t *fd) { - gf_msg_callingfn (this->name, GF_LOG_WARNING, 0, J_MSG_INIT_FAIL, - "xlator does not implement releasedir_cbk"); - return 0; + gf_msg_callingfn(this->name, GF_LOG_WARNING, 0, J_MSG_INIT_FAIL, + "xlator does not implement releasedir_cbk"); + return 0; } int32_t -jbrc_release (xlator_t *this, fd_t *fd) +jbrc_release(xlator_t *this, fd_t *fd) { - gf_msg_callingfn (this->name, GF_LOG_WARNING, 0, J_MSG_INIT_FAIL, - "xlator does not implement release_cbk"); - return 0; + gf_msg_callingfn(this->name, GF_LOG_WARNING, 0, J_MSG_INIT_FAIL, + "xlator does not implement release_cbk"); + return 0; } struct xlator_fops fops = { - .lookup = jbrc_lookup, - .stat = jbrc_stat, - .fstat = jbrc_fstat, - .truncate = jbrc_truncate, - .ftruncate = jbrc_ftruncate, - .access = jbrc_access, - .readlink = jbrc_readlink, - .mknod = jbrc_mknod, - .mkdir = jbrc_mkdir, - .unlink = jbrc_unlink, - .rmdir = jbrc_rmdir, - .symlink = jbrc_symlink, - .rename = jbrc_rename, - .link = jbrc_link, - .create = jbrc_create, - .open = jbrc_open, - .readv = jbrc_readv, - .writev = jbrc_writev, - .flush = jbrc_flush, - .fsync = jbrc_fsync, - .opendir = jbrc_opendir, - .readdir = jbrc_readdir, - .readdirp = jbrc_readdirp, - .fsyncdir = jbrc_fsyncdir, - .statfs = jbrc_statfs, - .setxattr = jbrc_setxattr, - .getxattr = jbrc_getxattr, - .fsetxattr = jbrc_fsetxattr, - .fgetxattr = jbrc_fgetxattr, - .removexattr = jbrc_removexattr, - .fremovexattr = jbrc_fremovexattr, - .lk = jbrc_lk, - .inodelk = jbrc_inodelk, - .finodelk = jbrc_finodelk, - .entrylk = jbrc_entrylk, - .fentrylk = jbrc_fentrylk, - .rchecksum = jbrc_rchecksum, - .xattrop = jbrc_xattrop, - .fxattrop = jbrc_fxattrop, - .setattr = jbrc_setattr, - .fsetattr = jbrc_fsetattr, - .fallocate = jbrc_fallocate, - .discard = jbrc_discard, -}; - -struct xlator_cbks cbks = { + .lookup = jbrc_lookup, + .stat = jbrc_stat, + .fstat = jbrc_fstat, + .truncate = jbrc_truncate, + .ftruncate = jbrc_ftruncate, + .access = jbrc_access, + .readlink = jbrc_readlink, + .mknod = jbrc_mknod, + .mkdir = jbrc_mkdir, + .unlink = jbrc_unlink, + .rmdir = jbrc_rmdir, + .symlink = jbrc_symlink, + .rename = jbrc_rename, + .link = jbrc_link, + .create = jbrc_create, + .open = jbrc_open, + .readv = jbrc_readv, + .writev = jbrc_writev, + .flush = jbrc_flush, + .fsync = jbrc_fsync, + .opendir = jbrc_opendir, + .readdir = jbrc_readdir, + .readdirp = jbrc_readdirp, + .fsyncdir = jbrc_fsyncdir, + .statfs = jbrc_statfs, + .setxattr = jbrc_setxattr, + .getxattr = jbrc_getxattr, + .fsetxattr = jbrc_fsetxattr, + .fgetxattr = jbrc_fgetxattr, + .removexattr = jbrc_removexattr, + .fremovexattr = jbrc_fremovexattr, + .lk = jbrc_lk, + .inodelk = jbrc_inodelk, + .finodelk = jbrc_finodelk, + .entrylk = jbrc_entrylk, + .fentrylk = jbrc_fentrylk, + .rchecksum = jbrc_rchecksum, + .xattrop = jbrc_xattrop, + .fxattrop = jbrc_fxattrop, + .setattr = jbrc_setattr, + .fsetattr = jbrc_fsetattr, + .fallocate = jbrc_fallocate, + .discard = jbrc_discard, }; +struct xlator_cbks cbks = {}; int32_t -mem_acct_init (xlator_t *this) +mem_acct_init(xlator_t *this) { - int ret = -1; + int ret = -1; - GF_VALIDATE_OR_GOTO ("jbrc", this, out); + GF_VALIDATE_OR_GOTO("jbrc", this, out); - ret = xlator_mem_acct_init (this, gf_mt_jbrc_end + 1); + ret = xlator_mem_acct_init(this, gf_mt_jbrc_end + 1); - if (ret != 0) { - gf_msg (this->name, GF_LOG_ERROR, ENOMEM, J_MSG_MEM_ERR, - "Memory accounting init failed"); - return ret; - } -out: + if (ret != 0) { + gf_msg(this->name, GF_LOG_ERROR, ENOMEM, J_MSG_MEM_ERR, + "Memory accounting init failed"); return ret; + } +out: + return ret; } - int32_t -jbrc_init (xlator_t *this) +jbrc_init(xlator_t *this) { - jbrc_private_t *priv = NULL; - xlator_list_t *trav = NULL; - - this->local_pool = mem_pool_new (jbrc_local_t, 128); - if (!this->local_pool) { - gf_msg (this->name, GF_LOG_ERROR, ENOMEM, J_MSG_MEM_ERR, - "failed to create jbrc_local_t pool"); - goto err; - } + jbrc_private_t *priv = NULL; + xlator_list_t *trav = NULL; - priv = GF_CALLOC (1, sizeof (*priv), gf_mt_jbrc_private_t); - if (!priv) { - goto err; - } + this->local_pool = mem_pool_new(jbrc_local_t, 128); + if (!this->local_pool) { + gf_msg(this->name, GF_LOG_ERROR, ENOMEM, J_MSG_MEM_ERR, + "failed to create jbrc_local_t pool"); + goto err; + } - for (trav = this->children; trav; trav = trav->next) { - ++(priv->n_children); - } + priv = GF_CALLOC(1, sizeof(*priv), gf_mt_jbrc_private_t); + if (!priv) { + goto err; + } - priv->active = FIRST_CHILD(this); - this->private = priv; - return 0; + for (trav = this->children; trav; trav = trav->next) { + ++(priv->n_children); + } + + priv->active = FIRST_CHILD(this); + this->private = priv; + return 0; err: - if (priv) { - GF_FREE(priv); - } - return -1; + if (priv) { + GF_FREE(priv); + } + return -1; } void -jbrc_fini (xlator_t *this) +jbrc_fini(xlator_t *this) { - GF_FREE(this->private); + GF_FREE(this->private); } int -jbrc_get_child_index (xlator_t *this, xlator_t *kid) +jbrc_get_child_index(xlator_t *this, xlator_t *kid) { - xlator_list_t *trav; - int retval = -1; - - for (trav = this->children; trav; trav = trav->next) { - ++retval; - if (trav->xlator == kid) { - return retval; - } + xlator_list_t *trav; + int retval = -1; + + for (trav = this->children; trav; trav = trav->next) { + ++retval; + if (trav->xlator == kid) { + return retval; } + } - return -1; + return -1; } uint8_t -jbrc_count_up_kids (jbrc_private_t *priv) +jbrc_count_up_kids(jbrc_private_t *priv) { - uint8_t retval = 0; - uint8_t i; + uint8_t retval = 0; + uint8_t i; - for (i = 0; i < priv->n_children; ++i) { - if (priv->kid_state & (1 << i)) { - ++retval; - } + for (i = 0; i < priv->n_children; ++i) { + if (priv->kid_state & (1 << i)) { + ++retval; } + } - return retval; + return retval; } int32_t -jbrc_notify (xlator_t *this, int32_t event, void *data, ...) +jbrc_notify(xlator_t *this, int32_t event, void *data, ...) { - int32_t ret = 0; - int32_t index = 0; - jbrc_private_t *priv = NULL; + int32_t ret = 0; + int32_t index = 0; + jbrc_private_t *priv = NULL; - GF_VALIDATE_OR_GOTO (THIS->name, this, out); - priv = this->private; - GF_VALIDATE_OR_GOTO (this->name, priv, out); + GF_VALIDATE_OR_GOTO(THIS->name, this, out); + priv = this->private; + GF_VALIDATE_OR_GOTO(this->name, priv, out); - switch (event) { + switch (event) { case GF_EVENT_CHILD_UP: - index = jbrc_get_child_index(this, data); - if (index >= 0) { - priv->kid_state |= (1 << index); - priv->up_children = jbrc_count_up_kids(priv); - gf_msg (this->name, GF_LOG_INFO, 0, J_MSG_GENERIC, - "got CHILD_UP for %s, now %u kids", - ((xlator_t *)data)->name, - priv->up_children); - } - ret = default_notify (this, event, data); - break; + index = jbrc_get_child_index(this, data); + if (index >= 0) { + priv->kid_state |= (1 << index); + priv->up_children = jbrc_count_up_kids(priv); + gf_msg(this->name, GF_LOG_INFO, 0, J_MSG_GENERIC, + "got CHILD_UP for %s, now %u kids", + ((xlator_t *)data)->name, priv->up_children); + } + ret = default_notify(this, event, data); + break; case GF_EVENT_CHILD_DOWN: - index = jbrc_get_child_index(this, data); - if (index >= 0) { - priv->kid_state &= ~(1 << index); - priv->up_children = jbrc_count_up_kids(priv); - gf_msg (this->name, GF_LOG_INFO, 0, J_MSG_GENERIC, - "got CHILD_DOWN for %s, now %u kids", - ((xlator_t *)data)->name, - priv->up_children); - } - break; + index = jbrc_get_child_index(this, data); + if (index >= 0) { + priv->kid_state &= ~(1 << index); + priv->up_children = jbrc_count_up_kids(priv); + gf_msg(this->name, GF_LOG_INFO, 0, J_MSG_GENERIC, + "got CHILD_DOWN for %s, now %u kids", + ((xlator_t *)data)->name, priv->up_children); + } + break; default: - ret = default_notify (this, event, data); - } + ret = default_notify(this, event, data); + } out: - return ret; + return ret; } int -jbrc_priv_dump (xlator_t *this) +jbrc_priv_dump(xlator_t *this) { - jbrc_private_t *priv = NULL; - char key_prefix[GF_DUMP_MAX_BUF_LEN]; - xlator_list_t *trav = NULL; - int32_t i = -1; + jbrc_private_t *priv = NULL; + char key_prefix[GF_DUMP_MAX_BUF_LEN]; + xlator_list_t *trav = NULL; + int32_t i = -1; - GF_VALIDATE_OR_GOTO (THIS->name, this, out); - priv = this->private; - GF_VALIDATE_OR_GOTO (this->name, priv, out); + GF_VALIDATE_OR_GOTO(THIS->name, this, out); + priv = this->private; + GF_VALIDATE_OR_GOTO(this->name, priv, out); - snprintf(key_prefix, GF_DUMP_MAX_BUF_LEN, "%s.%s", - this->type, this->name); - gf_proc_dump_add_section(key_prefix); + snprintf(key_prefix, GF_DUMP_MAX_BUF_LEN, "%s.%s", this->type, this->name); + gf_proc_dump_add_section(key_prefix); - gf_proc_dump_write("up_children", "%u", priv->up_children); + gf_proc_dump_write("up_children", "%u", priv->up_children); - for (trav = this->children, i = 0; trav; trav = trav->next, i++) { - snprintf(key_prefix, GF_DUMP_MAX_BUF_LEN, "child_%d", i); - gf_proc_dump_write(key_prefix, "%s", trav->xlator->name); - } + for (trav = this->children, i = 0; trav; trav = trav->next, i++) { + snprintf(key_prefix, GF_DUMP_MAX_BUF_LEN, "child_%d", i); + gf_proc_dump_write(key_prefix, "%s", trav->xlator->name); + } out: - return 0; + return 0; } struct xlator_dumpops dumpops = { - .priv = jbrc_priv_dump, + .priv = jbrc_priv_dump, }; class_methods_t class_methods = { - .init = jbrc_init, - .fini = jbrc_fini, - .notify = jbrc_notify, + .init = jbrc_init, + .fini = jbrc_fini, + .notify = jbrc_notify, }; struct volume_options options[] = { - { .key = {NULL} }, + {.key = {NULL}}, }; |