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/features/upcall | |
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/features/upcall')
-rw-r--r-- | xlators/features/upcall/src/upcall-internal.c | 987 | ||||
-rw-r--r-- | xlators/features/upcall/src/upcall.c | 3205 |
2 files changed, 2031 insertions, 2161 deletions
diff --git a/xlators/features/upcall/src/upcall-internal.c b/xlators/features/upcall/src/upcall-internal.c index 7635063c14e..9d16e5f0ef8 100644 --- a/xlators/features/upcall/src/upcall-internal.c +++ b/xlators/features/upcall/src/upcall-internal.c @@ -32,336 +32,319 @@ * - cache_invalidation */ gf_boolean_t -is_upcall_enabled(xlator_t *this) { - upcall_private_t *priv = NULL; - gf_boolean_t is_enabled = _gf_false; +is_upcall_enabled(xlator_t *this) +{ + upcall_private_t *priv = NULL; + gf_boolean_t is_enabled = _gf_false; - if (this->private) { - priv = (upcall_private_t *)this->private; + if (this->private) { + priv = (upcall_private_t *)this->private; - if (priv->cache_invalidation_enabled) { - is_enabled = _gf_true; - } + if (priv->cache_invalidation_enabled) { + is_enabled = _gf_true; } + } - return is_enabled; + return is_enabled; } /* * Get the cache_invalidation_timeout */ int32_t -get_cache_invalidation_timeout(xlator_t *this) { - upcall_private_t *priv = NULL; - int32_t timeout = 0; +get_cache_invalidation_timeout(xlator_t *this) +{ + upcall_private_t *priv = NULL; + int32_t timeout = 0; - if (this->private) { - priv = (upcall_private_t *)this->private; - timeout = priv->cache_invalidation_timeout; - } + if (this->private) { + priv = (upcall_private_t *)this->private; + timeout = priv->cache_invalidation_timeout; + } - return timeout; + return timeout; } /* * Allocate and add a new client entry to the given upcall entry */ -upcall_client_t* -add_upcall_client (call_frame_t *frame, client_t *client, - upcall_inode_ctx_t *up_inode_ctx) +upcall_client_t * +add_upcall_client(call_frame_t *frame, client_t *client, + upcall_inode_ctx_t *up_inode_ctx) { - upcall_client_t *up_client_entry = NULL; + upcall_client_t *up_client_entry = NULL; - pthread_mutex_lock (&up_inode_ctx->client_list_lock); - { - up_client_entry = __add_upcall_client (frame, - client, - up_inode_ctx); - } - pthread_mutex_unlock (&up_inode_ctx->client_list_lock); + pthread_mutex_lock(&up_inode_ctx->client_list_lock); + { + up_client_entry = __add_upcall_client(frame, client, up_inode_ctx); + } + pthread_mutex_unlock(&up_inode_ctx->client_list_lock); - return up_client_entry; + return up_client_entry; } -upcall_client_t* -__add_upcall_client (call_frame_t *frame, client_t *client, - upcall_inode_ctx_t *up_inode_ctx) +upcall_client_t * +__add_upcall_client(call_frame_t *frame, client_t *client, + upcall_inode_ctx_t *up_inode_ctx) { - upcall_client_t *up_client_entry = NULL; - - up_client_entry = GF_CALLOC (1, sizeof(*up_client_entry), - gf_upcall_mt_upcall_client_entry_t); - if (!up_client_entry) { - gf_msg ("upcall", GF_LOG_WARNING, 0, - UPCALL_MSG_NO_MEMORY, - "Memory allocation failed"); - return NULL; - } - INIT_LIST_HEAD (&up_client_entry->client_list); - up_client_entry->client_uid = gf_strdup(client->client_uid); - up_client_entry->access_time = time(NULL); - up_client_entry->expire_time_attr = - get_cache_invalidation_timeout(frame->this); + upcall_client_t *up_client_entry = NULL; + + up_client_entry = GF_CALLOC(1, sizeof(*up_client_entry), + gf_upcall_mt_upcall_client_entry_t); + if (!up_client_entry) { + gf_msg("upcall", GF_LOG_WARNING, 0, UPCALL_MSG_NO_MEMORY, + "Memory allocation failed"); + return NULL; + } + INIT_LIST_HEAD(&up_client_entry->client_list); + up_client_entry->client_uid = gf_strdup(client->client_uid); + up_client_entry->access_time = time(NULL); + up_client_entry->expire_time_attr = get_cache_invalidation_timeout( + frame->this); - list_add_tail (&up_client_entry->client_list, - &up_inode_ctx->client_list); + list_add_tail(&up_client_entry->client_list, &up_inode_ctx->client_list); - gf_log (THIS->name, GF_LOG_DEBUG, "upcall_entry_t client added - %s", - up_client_entry->client_uid); + gf_log(THIS->name, GF_LOG_DEBUG, "upcall_entry_t client added - %s", + up_client_entry->client_uid); - return up_client_entry; + return up_client_entry; } /* * Given client->uid, retrieve the corresponding upcall client entry. * If none found, create a new entry. */ -upcall_client_t* -__get_upcall_client (call_frame_t *frame, client_t *client, - upcall_inode_ctx_t *up_inode_ctx) +upcall_client_t * +__get_upcall_client(call_frame_t *frame, client_t *client, + upcall_inode_ctx_t *up_inode_ctx) { - upcall_client_t *up_client_entry = NULL; - upcall_client_t *tmp = NULL; - gf_boolean_t found_client = _gf_false; - - list_for_each_entry_safe (up_client_entry, tmp, - &up_inode_ctx->client_list, - client_list) { - if (strcmp(client->client_uid, - up_client_entry->client_uid) == 0) { - /* found client entry. Update the access_time */ - up_client_entry->access_time = time(NULL); - found_client = _gf_true; - gf_log (THIS->name, GF_LOG_DEBUG, - "upcall_entry_t client found - %s", - up_client_entry->client_uid); - break; - } + upcall_client_t *up_client_entry = NULL; + upcall_client_t *tmp = NULL; + gf_boolean_t found_client = _gf_false; + + list_for_each_entry_safe(up_client_entry, tmp, &up_inode_ctx->client_list, + client_list) + { + if (strcmp(client->client_uid, up_client_entry->client_uid) == 0) { + /* found client entry. Update the access_time */ + up_client_entry->access_time = time(NULL); + found_client = _gf_true; + gf_log(THIS->name, GF_LOG_DEBUG, "upcall_entry_t client found - %s", + up_client_entry->client_uid); + break; } + } - if (!found_client) { /* create one */ - up_client_entry = __add_upcall_client (frame, client, - up_inode_ctx); - } + if (!found_client) { /* create one */ + up_client_entry = __add_upcall_client(frame, client, up_inode_ctx); + } - return up_client_entry; + return up_client_entry; } int -__upcall_inode_ctx_set (inode_t *inode, xlator_t *this) +__upcall_inode_ctx_set(inode_t *inode, xlator_t *this) { - upcall_inode_ctx_t *inode_ctx = NULL; - upcall_private_t *priv = NULL; - int ret = -1; - uint64_t ctx = 0; - - priv = this->private; - GF_ASSERT(priv); - - ret = __inode_ctx_get (inode, this, &ctx); - - if (!ret) - goto out; - - inode_ctx = GF_CALLOC (1, sizeof (upcall_inode_ctx_t), - gf_upcall_mt_upcall_inode_ctx_t); - - if (!inode_ctx) { - ret = -ENOMEM; - goto out; - } - - pthread_mutex_init (&inode_ctx->client_list_lock, NULL); - INIT_LIST_HEAD (&inode_ctx->inode_ctx_list); - INIT_LIST_HEAD (&inode_ctx->client_list); - inode_ctx->destroy = 0; - gf_uuid_copy (inode_ctx->gfid, inode->gfid); - - ctx = (long) inode_ctx; - ret = __inode_ctx_set (inode, this, &ctx); - if (ret) { - gf_log (this->name, GF_LOG_DEBUG, - "failed to set inode ctx (%p)", inode); - GF_FREE (inode_ctx); - goto out; - } - - /* add this inode_ctx to the global list */ - LOCK (&priv->inode_ctx_lk); - { - list_add_tail (&inode_ctx->inode_ctx_list, - &priv->inode_ctx_list); - } - UNLOCK (&priv->inode_ctx_lk); + upcall_inode_ctx_t *inode_ctx = NULL; + upcall_private_t *priv = NULL; + int ret = -1; + uint64_t ctx = 0; + + priv = this->private; + GF_ASSERT(priv); + + ret = __inode_ctx_get(inode, this, &ctx); + + if (!ret) + goto out; + + inode_ctx = GF_CALLOC(1, sizeof(upcall_inode_ctx_t), + gf_upcall_mt_upcall_inode_ctx_t); + + if (!inode_ctx) { + ret = -ENOMEM; + goto out; + } + + pthread_mutex_init(&inode_ctx->client_list_lock, NULL); + INIT_LIST_HEAD(&inode_ctx->inode_ctx_list); + INIT_LIST_HEAD(&inode_ctx->client_list); + inode_ctx->destroy = 0; + gf_uuid_copy(inode_ctx->gfid, inode->gfid); + + ctx = (long)inode_ctx; + ret = __inode_ctx_set(inode, this, &ctx); + if (ret) { + gf_log(this->name, GF_LOG_DEBUG, "failed to set inode ctx (%p)", inode); + GF_FREE(inode_ctx); + goto out; + } + + /* add this inode_ctx to the global list */ + LOCK(&priv->inode_ctx_lk); + { + list_add_tail(&inode_ctx->inode_ctx_list, &priv->inode_ctx_list); + } + UNLOCK(&priv->inode_ctx_lk); out: - return ret; + return ret; } upcall_inode_ctx_t * -__upcall_inode_ctx_get (inode_t *inode, xlator_t *this) +__upcall_inode_ctx_get(inode_t *inode, xlator_t *this) { - upcall_inode_ctx_t *inode_ctx = NULL; - uint64_t ctx = 0; - int ret = 0; + upcall_inode_ctx_t *inode_ctx = NULL; + uint64_t ctx = 0; + int ret = 0; - ret = __inode_ctx_get (inode, this, &ctx); + ret = __inode_ctx_get(inode, this, &ctx); - if (ret < 0) { - ret = __upcall_inode_ctx_set (inode, this); - if (ret < 0) - goto out; + if (ret < 0) { + ret = __upcall_inode_ctx_set(inode, this); + if (ret < 0) + goto out; - ret = __inode_ctx_get (inode, this, &ctx); - if (ret < 0) - goto out; - } + ret = __inode_ctx_get(inode, this, &ctx); + if (ret < 0) + goto out; + } - inode_ctx = (upcall_inode_ctx_t *) (long) (ctx); + inode_ctx = (upcall_inode_ctx_t *)(long)(ctx); out: - return inode_ctx; + return inode_ctx; } upcall_inode_ctx_t * -upcall_inode_ctx_get (inode_t *inode, xlator_t *this) +upcall_inode_ctx_get(inode_t *inode, xlator_t *this) { - upcall_inode_ctx_t *inode_ctx = NULL; + upcall_inode_ctx_t *inode_ctx = NULL; - LOCK (&inode->lock); - { - inode_ctx = __upcall_inode_ctx_get (inode, this); - } - UNLOCK (&inode->lock); + LOCK(&inode->lock); + { + inode_ctx = __upcall_inode_ctx_get(inode, this); + } + UNLOCK(&inode->lock); - return inode_ctx; + return inode_ctx; } int -upcall_cleanup_expired_clients (xlator_t *this, - upcall_inode_ctx_t *up_inode_ctx) { +upcall_cleanup_expired_clients(xlator_t *this, upcall_inode_ctx_t *up_inode_ctx) +{ + upcall_client_t *up_client = NULL; + upcall_client_t *tmp = NULL; + int ret = -1; + time_t timeout = 0; + time_t t_expired = 0; + + timeout = get_cache_invalidation_timeout(this); + + pthread_mutex_lock(&up_inode_ctx->client_list_lock); + { + list_for_each_entry_safe(up_client, tmp, &up_inode_ctx->client_list, + client_list) + { + t_expired = time(NULL) - up_client->access_time; - upcall_client_t *up_client = NULL; - upcall_client_t *tmp = NULL; - int ret = -1; - time_t timeout = 0; - time_t t_expired = 0; + if (t_expired > (2 * timeout)) { + gf_log(THIS->name, GF_LOG_TRACE, "Cleaning up client_entry(%s)", + up_client->client_uid); - timeout = get_cache_invalidation_timeout(this); + ret = __upcall_cleanup_client_entry(up_client); - pthread_mutex_lock (&up_inode_ctx->client_list_lock); - { - list_for_each_entry_safe (up_client, - tmp, - &up_inode_ctx->client_list, - client_list) { - t_expired = time(NULL) - - up_client->access_time; - - if (t_expired > (2*timeout)) { - - gf_log (THIS->name, GF_LOG_TRACE, - "Cleaning up client_entry(%s)", - up_client->client_uid); - - ret = - __upcall_cleanup_client_entry (up_client); - - if (ret) { - gf_msg ("upcall", GF_LOG_WARNING, 0, - UPCALL_MSG_INTERNAL_ERROR, - "Client entry cleanup failed (%p)", - up_client); - goto out; - } - } + if (ret) { + gf_msg("upcall", GF_LOG_WARNING, 0, + UPCALL_MSG_INTERNAL_ERROR, + "Client entry cleanup failed (%p)", up_client); + goto out; } + } } - pthread_mutex_unlock (&up_inode_ctx->client_list_lock); + } + pthread_mutex_unlock(&up_inode_ctx->client_list_lock); - ret = 0; + ret = 0; out: - return ret; + return ret; } int -__upcall_cleanup_client_entry (upcall_client_t *up_client) +__upcall_cleanup_client_entry(upcall_client_t *up_client) { - list_del_init (&up_client->client_list); + list_del_init(&up_client->client_list); - GF_FREE (up_client->client_uid); - GF_FREE (up_client); + GF_FREE(up_client->client_uid); + GF_FREE(up_client); - return 0; + return 0; } /* * Free Upcall inode_ctx client list */ int -__upcall_cleanup_inode_ctx_client_list (upcall_inode_ctx_t *inode_ctx) +__upcall_cleanup_inode_ctx_client_list(upcall_inode_ctx_t *inode_ctx) { - upcall_client_t *up_client = NULL; - upcall_client_t *tmp = NULL; + upcall_client_t *up_client = NULL; + upcall_client_t *tmp = NULL; - list_for_each_entry_safe (up_client, tmp, - &inode_ctx->client_list, - client_list) { - __upcall_cleanup_client_entry (up_client); - } + list_for_each_entry_safe(up_client, tmp, &inode_ctx->client_list, + client_list) + { + __upcall_cleanup_client_entry(up_client); + } - return 0; + return 0; } /* * Free upcall_inode_ctx */ int -upcall_cleanup_inode_ctx (xlator_t *this, inode_t *inode) +upcall_cleanup_inode_ctx(xlator_t *this, inode_t *inode) { - uint64_t ctx = 0; - upcall_inode_ctx_t *inode_ctx = NULL; - int ret = 0; - upcall_private_t *priv = NULL; - - priv = this->private; - GF_ASSERT(priv); - - ret = inode_ctx_del (inode, this, &ctx); - - if (ret < 0) { - gf_msg ("upcall", GF_LOG_WARNING, 0, - UPCALL_MSG_INTERNAL_ERROR, - "Failed to del upcall_inode_ctx (%p)", - inode); - goto out; - } + uint64_t ctx = 0; + upcall_inode_ctx_t *inode_ctx = NULL; + int ret = 0; + upcall_private_t *priv = NULL; - inode_ctx = (upcall_inode_ctx_t *)(long) ctx; + priv = this->private; + GF_ASSERT(priv); - if (inode_ctx) { + ret = inode_ctx_del(inode, this, &ctx); - /* Invalidate all the upcall cache entries */ - upcall_cache_forget (this, inode, inode_ctx); + if (ret < 0) { + gf_msg("upcall", GF_LOG_WARNING, 0, UPCALL_MSG_INTERNAL_ERROR, + "Failed to del upcall_inode_ctx (%p)", inode); + goto out; + } - /* do we really need lock? yes now reaper thread - * may also be trying to cleanup the client entries. - */ - pthread_mutex_lock (&inode_ctx->client_list_lock); - { - if (!list_empty (&inode_ctx->client_list)) { - __upcall_cleanup_inode_ctx_client_list (inode_ctx); - } - } - pthread_mutex_unlock (&inode_ctx->client_list_lock); + inode_ctx = (upcall_inode_ctx_t *)(long)ctx; + + if (inode_ctx) { + /* Invalidate all the upcall cache entries */ + upcall_cache_forget(this, inode, inode_ctx); - /* Mark the inode_ctx to be destroyed */ - inode_ctx->destroy = 1; - gf_msg_debug ("upcall", 0, "set upcall_inode_ctx (%p) to destroy mode", - inode_ctx); + /* do we really need lock? yes now reaper thread + * may also be trying to cleanup the client entries. + */ + pthread_mutex_lock(&inode_ctx->client_list_lock); + { + if (!list_empty(&inode_ctx->client_list)) { + __upcall_cleanup_inode_ctx_client_list(inode_ctx); + } } + pthread_mutex_unlock(&inode_ctx->client_list_lock); + + /* Mark the inode_ctx to be destroyed */ + inode_ctx->destroy = 1; + gf_msg_debug("upcall", 0, "set upcall_inode_ctx (%p) to destroy mode", + inode_ctx); + } out: - return ret; + return ret; } /* @@ -370,161 +353,153 @@ out: * which is no longer valid and has destroy bit set. */ void * -upcall_reaper_thread (void *data) +upcall_reaper_thread(void *data) { - upcall_private_t *priv = NULL; - upcall_inode_ctx_t *inode_ctx = NULL; - upcall_inode_ctx_t *tmp = NULL; - xlator_t *this = NULL; - time_t timeout = 0; - - this = (xlator_t *)data; - GF_ASSERT (this); - - priv = this->private; - GF_ASSERT (priv); - - - while (!priv->fini) { - list_for_each_entry_safe (inode_ctx, tmp, - &priv->inode_ctx_list, - inode_ctx_list) { - - /* cleanup expired clients */ - upcall_cleanup_expired_clients (this, inode_ctx); - - if (!inode_ctx->destroy) { - continue; - } - - LOCK (&priv->inode_ctx_lk); - { - /* client list would have been cleaned up*/ - gf_msg_debug ("upcall", 0, "Freeing upcall_inode_ctx (%p)", - inode_ctx); - list_del_init (&inode_ctx->inode_ctx_list); - pthread_mutex_destroy (&inode_ctx->client_list_lock); - GF_FREE (inode_ctx); - inode_ctx = NULL; - } - UNLOCK (&priv->inode_ctx_lk); - } + upcall_private_t *priv = NULL; + upcall_inode_ctx_t *inode_ctx = NULL; + upcall_inode_ctx_t *tmp = NULL; + xlator_t *this = NULL; + time_t timeout = 0; + + this = (xlator_t *)data; + GF_ASSERT(this); + + priv = this->private; + GF_ASSERT(priv); - /* don't do a very busy loop */ - timeout = get_cache_invalidation_timeout (this); - sleep (timeout / 2); + while (!priv->fini) { + list_for_each_entry_safe(inode_ctx, tmp, &priv->inode_ctx_list, + inode_ctx_list) + { + /* cleanup expired clients */ + upcall_cleanup_expired_clients(this, inode_ctx); + + if (!inode_ctx->destroy) { + continue; + } + + LOCK(&priv->inode_ctx_lk); + { + /* client list would have been cleaned up*/ + gf_msg_debug("upcall", 0, "Freeing upcall_inode_ctx (%p)", + inode_ctx); + list_del_init(&inode_ctx->inode_ctx_list); + pthread_mutex_destroy(&inode_ctx->client_list_lock); + GF_FREE(inode_ctx); + inode_ctx = NULL; + } + UNLOCK(&priv->inode_ctx_lk); } - return NULL; + /* don't do a very busy loop */ + timeout = get_cache_invalidation_timeout(this); + sleep(timeout / 2); + } + + return NULL; } /* * Initialize upcall reaper thread. */ int -upcall_reaper_thread_init (xlator_t *this) +upcall_reaper_thread_init(xlator_t *this) { - upcall_private_t *priv = NULL; - int ret = -1; + upcall_private_t *priv = NULL; + int ret = -1; - priv = this->private; - GF_ASSERT (priv); + priv = this->private; + GF_ASSERT(priv); - ret = gf_thread_create (&priv->reaper_thr, NULL, - upcall_reaper_thread, this, "upreaper"); + ret = gf_thread_create(&priv->reaper_thr, NULL, upcall_reaper_thread, this, + "upreaper"); - return ret; + return ret; } - int -up_compare_afr_xattr (dict_t *d, char *k, data_t *v, void *tmp) +up_compare_afr_xattr(dict_t *d, char *k, data_t *v, void *tmp) { - dict_t *dict = tmp; + dict_t *dict = tmp; - if (!strncmp (k, AFR_XATTR_PREFIX, SLEN (AFR_XATTR_PREFIX)) - && (!is_data_equal (v, dict_get (dict, k)))) - return -1; + if (!strncmp(k, AFR_XATTR_PREFIX, SLEN(AFR_XATTR_PREFIX)) && + (!is_data_equal(v, dict_get(dict, k)))) + return -1; - return 0; + return 0; } - static void -up_filter_afr_xattr (dict_t *xattrs, char *xattr, data_t *v) +up_filter_afr_xattr(dict_t *xattrs, char *xattr, data_t *v) { - /* Filter the afr pending xattrs, with value 0. Ideally this should - * be executed only in case of xattrop and not in set and removexattr, - * butset and remove xattr fops do not come with keys AFR_XATTR_PREFIX - */ - if (!strncmp (xattr, AFR_XATTR_PREFIX, SLEN (AFR_XATTR_PREFIX)) - && (mem_0filled (v->data, v->len) == 0)) { - dict_del (xattrs, xattr); - } - return; + /* Filter the afr pending xattrs, with value 0. Ideally this should + * be executed only in case of xattrop and not in set and removexattr, + * butset and remove xattr fops do not come with keys AFR_XATTR_PREFIX + */ + if (!strncmp(xattr, AFR_XATTR_PREFIX, SLEN(AFR_XATTR_PREFIX)) && + (mem_0filled(v->data, v->len) == 0)) { + dict_del(xattrs, xattr); + } + return; } - static gf_boolean_t -up_key_is_regd_xattr (dict_t *regd_xattrs, char *regd_xattr, data_t *v, - void *xattr) +up_key_is_regd_xattr(dict_t *regd_xattrs, char *regd_xattr, data_t *v, + void *xattr) { - int ret = _gf_false; - char *key = xattr; + int ret = _gf_false; + char *key = xattr; - if (fnmatch (regd_xattr, key, 0) == 0) - ret = _gf_true; + if (fnmatch(regd_xattr, key, 0) == 0) + ret = _gf_true; - return ret; + return ret; } - int -up_filter_unregd_xattr (dict_t *xattrs, char *xattr, data_t *v, - void *regd_xattrs) +up_filter_unregd_xattr(dict_t *xattrs, char *xattr, data_t *v, + void *regd_xattrs) { - int ret = 0; - - ret = dict_foreach_match (regd_xattrs, up_key_is_regd_xattr, xattr, - dict_null_foreach_fn, NULL); - if (ret == 0) { - /* xattr was not found in the registered xattr, hence do not - * send notification for its change - */ - dict_del (xattrs, xattr); - goto out; - } - up_filter_afr_xattr (xattrs, xattr, v); + int ret = 0; + + ret = dict_foreach_match(regd_xattrs, up_key_is_regd_xattr, xattr, + dict_null_foreach_fn, NULL); + if (ret == 0) { + /* xattr was not found in the registered xattr, hence do not + * send notification for its change + */ + dict_del(xattrs, xattr); + goto out; + } + up_filter_afr_xattr(xattrs, xattr, v); out: - return 0; + return 0; } - int -up_filter_xattr (dict_t *xattr, dict_t *regd_xattrs) +up_filter_xattr(dict_t *xattr, dict_t *regd_xattrs) { - int ret = 0; + int ret = 0; - ret = dict_foreach (xattr, up_filter_unregd_xattr, regd_xattrs); + ret = dict_foreach(xattr, up_filter_unregd_xattr, regd_xattrs); - return ret; + return ret; } - gf_boolean_t -up_invalidate_needed (dict_t *xattrs) +up_invalidate_needed(dict_t *xattrs) { - if (dict_key_count (xattrs) == 0) { - gf_msg_trace ("upcall", 0, "None of xattrs requested for" - " invalidation, were changed. Nothing to " - "invalidate"); - return _gf_false; - } - - return _gf_true; + if (dict_key_count(xattrs) == 0) { + gf_msg_trace("upcall", 0, + "None of xattrs requested for" + " invalidation, were changed. Nothing to " + "invalidate"); + return _gf_false; + } + + return _gf_true; } - /* * Given a client, first fetch upcall_entry_t from the inode_ctx client list. * Later traverse through the client list of that upcall entry. If this client @@ -536,104 +511,96 @@ up_invalidate_needed (dict_t *xattrs) * any errors during the process are logged and ignored. */ void -upcall_cache_invalidate (call_frame_t *frame, xlator_t *this, client_t *client, - inode_t *inode, uint32_t flags, struct iatt *stbuf, - struct iatt *p_stbuf, struct iatt *oldp_stbuf, - dict_t *xattr) +upcall_cache_invalidate(call_frame_t *frame, xlator_t *this, client_t *client, + inode_t *inode, uint32_t flags, struct iatt *stbuf, + struct iatt *p_stbuf, struct iatt *oldp_stbuf, + dict_t *xattr) { - upcall_client_t *up_client_entry = NULL; - upcall_client_t *tmp = NULL; - upcall_inode_ctx_t *up_inode_ctx = NULL; - gf_boolean_t found = _gf_false; - - if (!is_upcall_enabled(this)) - return; + upcall_client_t *up_client_entry = NULL; + upcall_client_t *tmp = NULL; + upcall_inode_ctx_t *up_inode_ctx = NULL; + gf_boolean_t found = _gf_false; - /* server-side generated fops like quota/marker will not have any - * client associated with them. Ignore such fops. - */ - if (!client) { - gf_msg_debug ("upcall", 0, "Internal fop - client NULL"); - return; - } + if (!is_upcall_enabled(this)) + return; - if (inode) - up_inode_ctx = upcall_inode_ctx_get (inode, this); + /* server-side generated fops like quota/marker will not have any + * client associated with them. Ignore such fops. + */ + if (!client) { + gf_msg_debug("upcall", 0, "Internal fop - client NULL"); + return; + } - if (!up_inode_ctx) { - gf_msg ("upcall", GF_LOG_WARNING, 0, - UPCALL_MSG_INTERNAL_ERROR, - "upcall_inode_ctx_get failed (%p)", - inode); - return; - } + if (inode) + up_inode_ctx = upcall_inode_ctx_get(inode, this); - /* In case of LOOKUP, if first time, inode created shall be - * invalid till it gets linked to inode table. Read gfid from - * the stat returned in such cases. + if (!up_inode_ctx) { + gf_msg("upcall", GF_LOG_WARNING, 0, UPCALL_MSG_INTERNAL_ERROR, + "upcall_inode_ctx_get failed (%p)", inode); + return; + } + + /* In case of LOOKUP, if first time, inode created shall be + * invalid till it gets linked to inode table. Read gfid from + * the stat returned in such cases. + */ + if (gf_uuid_is_null(up_inode_ctx->gfid) && stbuf) { + /* That means inode must have been invalid when this inode_ctx + * is created. Copy the gfid value from stbuf instead. */ - if (gf_uuid_is_null (up_inode_ctx->gfid) && stbuf) { - /* That means inode must have been invalid when this inode_ctx - * is created. Copy the gfid value from stbuf instead. - */ - gf_uuid_copy (up_inode_ctx->gfid, stbuf->ia_gfid); - } - - if (gf_uuid_is_null (up_inode_ctx->gfid)) { - gf_msg_debug (this->name, 0, "up_inode_ctx->gfid and " - "stbuf->ia_gfid is NULL, fop:%s", - gf_fop_list[frame->root->op]); - goto out; - } - - pthread_mutex_lock (&up_inode_ctx->client_list_lock); + gf_uuid_copy(up_inode_ctx->gfid, stbuf->ia_gfid); + } + + if (gf_uuid_is_null(up_inode_ctx->gfid)) { + gf_msg_debug(this->name, 0, + "up_inode_ctx->gfid and " + "stbuf->ia_gfid is NULL, fop:%s", + gf_fop_list[frame->root->op]); + goto out; + } + + pthread_mutex_lock(&up_inode_ctx->client_list_lock); + { + list_for_each_entry_safe(up_client_entry, tmp, + &up_inode_ctx->client_list, client_list) { - list_for_each_entry_safe (up_client_entry, tmp, - &up_inode_ctx->client_list, - client_list) { - - /* Do not send UPCALL event if same client. */ - if (!strcmp(client->client_uid, - up_client_entry->client_uid)) { - up_client_entry->access_time = time(NULL); - found = _gf_true; - continue; - } - - /* - * Ignore sending notifications in case of only UP_ATIME - */ - if (!(flags & ~(UP_ATIME))) { - if (found) - break; - else /* we still need to find current client entry*/ - continue; - } - - /* any other client */ - - /* XXX: Send notifications asynchrounously - * instead of in the I/O path - BZ 1200264 - * Also if the file is frequently accessed, set - * expire_time_attr to 0. - */ - upcall_client_cache_invalidate (this, - up_inode_ctx->gfid, - up_client_entry, - flags, stbuf, - p_stbuf, oldp_stbuf, - xattr); - } + /* Do not send UPCALL event if same client. */ + if (!strcmp(client->client_uid, up_client_entry->client_uid)) { + up_client_entry->access_time = time(NULL); + found = _gf_true; + continue; + } + + /* + * Ignore sending notifications in case of only UP_ATIME + */ + if (!(flags & ~(UP_ATIME))) { + if (found) + break; + else /* we still need to find current client entry*/ + continue; + } + + /* any other client */ + + /* XXX: Send notifications asynchrounously + * instead of in the I/O path - BZ 1200264 + * Also if the file is frequently accessed, set + * expire_time_attr to 0. + */ + upcall_client_cache_invalidate(this, up_inode_ctx->gfid, + up_client_entry, flags, stbuf, + p_stbuf, oldp_stbuf, xattr); + } - if (!found) { - up_client_entry = __add_upcall_client (frame, - client, - up_inode_ctx); - } + if (!found) { + up_client_entry = __add_upcall_client(frame, client, up_inode_ctx); } - pthread_mutex_unlock (&up_inode_ctx->client_list_lock); + } + pthread_mutex_unlock(&up_inode_ctx->client_list_lock); out: - return; + return; } /* @@ -641,67 +608,69 @@ out: * priv->cache_invalidation_timeout), send a upcall notification. */ void -upcall_client_cache_invalidate (xlator_t *this, uuid_t gfid, - upcall_client_t *up_client_entry, - uint32_t flags, struct iatt *stbuf, - struct iatt *p_stbuf, - struct iatt *oldp_stbuf, dict_t *xattr) +upcall_client_cache_invalidate(xlator_t *this, uuid_t gfid, + upcall_client_t *up_client_entry, uint32_t flags, + struct iatt *stbuf, struct iatt *p_stbuf, + struct iatt *oldp_stbuf, dict_t *xattr) { - struct gf_upcall up_req = {0,}; - struct gf_upcall_cache_invalidation ca_req = {0,}; - time_t timeout = 0; - int ret = -1; - time_t t_expired = time(NULL) - up_client_entry->access_time; - - GF_VALIDATE_OR_GOTO ("upcall_client_cache_invalidate", - !(gf_uuid_is_null (gfid)), out); - timeout = get_cache_invalidation_timeout(this); + struct gf_upcall up_req = { + 0, + }; + struct gf_upcall_cache_invalidation ca_req = { + 0, + }; + time_t timeout = 0; + int ret = -1; + time_t t_expired = time(NULL) - up_client_entry->access_time; + + GF_VALIDATE_OR_GOTO("upcall_client_cache_invalidate", + !(gf_uuid_is_null(gfid)), out); + timeout = get_cache_invalidation_timeout(this); + + if (t_expired < timeout) { + /* Send notify call */ + up_req.client_uid = up_client_entry->client_uid; + gf_uuid_copy(up_req.gfid, gfid); + + ca_req.flags = flags; + ca_req.expire_time_attr = up_client_entry->expire_time_attr; + if (stbuf) + ca_req.stat = *stbuf; + if (p_stbuf) + ca_req.p_stat = *p_stbuf; + if (oldp_stbuf) + ca_req.oldp_stat = *oldp_stbuf; + ca_req.dict = xattr; + + up_req.data = &ca_req; + up_req.event_type = GF_UPCALL_CACHE_INVALIDATION; + + gf_log(THIS->name, GF_LOG_TRACE, + "Cache invalidation notification sent to %s", + up_client_entry->client_uid); + + /* Need to send inode flags */ + ret = this->notify(this, GF_EVENT_UPCALL, &up_req); + + /* + * notify may fail as the client could have been + * dis(re)connected. Cleanup the client entry. + */ + if (ret < 0) + __upcall_cleanup_client_entry(up_client_entry); - if (t_expired < timeout) { - /* Send notify call */ - up_req.client_uid = up_client_entry->client_uid; - gf_uuid_copy (up_req.gfid, gfid); - - ca_req.flags = flags; - ca_req.expire_time_attr = - up_client_entry->expire_time_attr; - if (stbuf) - ca_req.stat = *stbuf; - if (p_stbuf) - ca_req.p_stat = *p_stbuf; - if (oldp_stbuf) - ca_req.oldp_stat = *oldp_stbuf; - ca_req.dict = xattr; - - up_req.data = &ca_req; - up_req.event_type = GF_UPCALL_CACHE_INVALIDATION; - - gf_log (THIS->name, GF_LOG_TRACE, - "Cache invalidation notification sent to %s", - up_client_entry->client_uid); - - /* Need to send inode flags */ - ret = this->notify (this, GF_EVENT_UPCALL, &up_req); - - /* - * notify may fail as the client could have been - * dis(re)connected. Cleanup the client entry. - */ - if (ret < 0) - __upcall_cleanup_client_entry (up_client_entry); - - } else { - gf_log (THIS->name, GF_LOG_TRACE, - "Cache invalidation notification NOT sent to %s", - up_client_entry->client_uid); - - if (t_expired > (2*timeout)) { - /* Cleanup the entry */ - __upcall_cleanup_client_entry (up_client_entry); - } + } else { + gf_log(THIS->name, GF_LOG_TRACE, + "Cache invalidation notification NOT sent to %s", + up_client_entry->client_uid); + + if (t_expired > (2 * timeout)) { + /* Cleanup the entry */ + __upcall_cleanup_client_entry(up_client_entry); } + } out: - return; + return; } /* @@ -710,34 +679,32 @@ out: * entry and do a fresh lookup next time when any I/O comes in. */ void -upcall_cache_forget (xlator_t *this, inode_t *inode, upcall_inode_ctx_t *up_inode_ctx) +upcall_cache_forget(xlator_t *this, inode_t *inode, + upcall_inode_ctx_t *up_inode_ctx) { - upcall_client_t *up_client_entry = NULL; - upcall_client_t *tmp = NULL; - uint32_t flags = 0; + upcall_client_t *up_client_entry = NULL; + upcall_client_t *tmp = NULL; + uint32_t flags = 0; - if (!up_inode_ctx) { - return; - } + if (!up_inode_ctx) { + return; + } - pthread_mutex_lock (&up_inode_ctx->client_list_lock); + pthread_mutex_lock(&up_inode_ctx->client_list_lock); + { + list_for_each_entry_safe(up_client_entry, tmp, + &up_inode_ctx->client_list, client_list) { - list_for_each_entry_safe (up_client_entry, tmp, - &up_inode_ctx->client_list, - client_list) { - flags = UP_FORGET; - - /* Set the access time to time(NULL) - * to send notify */ - up_client_entry->access_time = time(NULL); - - upcall_client_cache_invalidate(this, - up_inode_ctx->gfid, - up_client_entry, - flags, NULL, - NULL, NULL, NULL); - } + flags = UP_FORGET; + + /* Set the access time to time(NULL) + * to send notify */ + up_client_entry->access_time = time(NULL); + upcall_client_cache_invalidate(this, up_inode_ctx->gfid, + up_client_entry, flags, NULL, NULL, + NULL, NULL); } - pthread_mutex_unlock (&up_inode_ctx->client_list_lock); + } + pthread_mutex_unlock(&up_inode_ctx->client_list_lock); } diff --git a/xlators/features/upcall/src/upcall.c b/xlators/features/upcall/src/upcall.c index 6dfc8723553..5fdd4993003 100644 --- a/xlators/features/upcall/src/upcall.c +++ b/xlators/features/upcall/src/upcall.c @@ -28,1412 +28,1360 @@ #include "defaults.h" static int32_t -up_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, fd_t *fd, dict_t *xdata) +up_open_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, + int32_t op_errno, fd_t *fd, dict_t *xdata) { - client_t *client = NULL; - uint32_t flags = 0; - upcall_local_t *local = NULL; + client_t *client = NULL; + uint32_t flags = 0; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } - flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, local->inode, flags, - NULL, NULL, NULL, NULL); + if ((op_ret < 0) || !local) { + goto out; + } + flags = UP_UPDATE_CLIENT; + upcall_cache_invalidate(frame, this, client, local->inode, flags, NULL, + NULL, NULL, NULL); out: - UPCALL_STACK_UNWIND (open, frame, op_ret, op_errno, fd, xdata); + UPCALL_STACK_UNWIND(open, frame, op_ret, op_errno, fd, xdata); - return 0; + return 0; } - static int32_t -up_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, - fd_t *fd, dict_t *xdata) +up_open(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, + fd_t *fd, dict_t *xdata) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, NULL, NULL, fd->inode, NULL); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, NULL, NULL, fd->inode, NULL); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - STACK_WIND (frame, up_open_cbk, - FIRST_CHILD(this), FIRST_CHILD(this)->fops->open, - loc, flags, fd, xdata); + STACK_WIND(frame, up_open_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->open, loc, flags, fd, xdata); - return 0; + return 0; err: - UPCALL_STACK_UNWIND (open, frame, -1, op_errno, NULL, NULL); + UPCALL_STACK_UNWIND(open, frame, -1, op_errno, NULL, NULL); - return 0; + return 0; } static int32_t -up_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, struct iatt *prebuf, - struct iatt *postbuf, dict_t *xdata) +up_writev_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + int op_errno, struct iatt *prebuf, struct iatt *postbuf, + dict_t *xdata) { - client_t *client = NULL; - uint32_t flags = 0; - upcall_local_t *local = NULL; + client_t *client = NULL; + uint32_t flags = 0; + upcall_local_t *local = NULL; - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } - flags = UP_WRITE_FLAGS; - upcall_cache_invalidate (frame, this, client, local->inode, flags, - postbuf, NULL, NULL, NULL); + if ((op_ret < 0) || !local) { + goto out; + } + flags = UP_WRITE_FLAGS; + upcall_cache_invalidate(frame, this, client, local->inode, flags, postbuf, + NULL, NULL, NULL); out: - UPCALL_STACK_UNWIND (writev, frame, op_ret, op_errno, - prebuf, postbuf, xdata); + UPCALL_STACK_UNWIND(writev, frame, op_ret, op_errno, prebuf, postbuf, + xdata); - return 0; + return 0; } - static int32_t -up_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, - struct iovec *vector, int count, off_t off, uint32_t flags, - struct iobref *iobref, dict_t *xdata) +up_writev(call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, + int count, off_t off, uint32_t flags, struct iobref *iobref, + dict_t *xdata) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, NULL, NULL, fd->inode, NULL); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, NULL, NULL, fd->inode, NULL); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - STACK_WIND (frame, up_writev_cbk, - FIRST_CHILD(this), FIRST_CHILD(this)->fops->writev, - fd, vector, count, off, flags, iobref, xdata); + STACK_WIND(frame, up_writev_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->writev, fd, vector, count, off, flags, + iobref, xdata); - return 0; + return 0; err: - UPCALL_STACK_UNWIND (writev, frame, -1, op_errno, NULL, NULL, NULL); + UPCALL_STACK_UNWIND(writev, frame, -1, op_errno, NULL, NULL, NULL); - return 0; + return 0; } - static int32_t -up_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, - struct iovec *vector, int count, struct iatt *stbuf, - struct iobref *iobref, dict_t *xdata) +up_readv_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + int op_errno, struct iovec *vector, int count, struct iatt *stbuf, + struct iobref *iobref, dict_t *xdata) { - client_t *client = NULL; - uint32_t flags = 0; - upcall_local_t *local = NULL; + client_t *client = NULL; + uint32_t flags = 0; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } - flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, local->inode, flags, - stbuf, NULL, NULL, NULL); + if ((op_ret < 0) || !local) { + goto out; + } + flags = UP_UPDATE_CLIENT; + upcall_cache_invalidate(frame, this, client, local->inode, flags, stbuf, + NULL, NULL, NULL); out: - UPCALL_STACK_UNWIND (readv, frame, op_ret, op_errno, vector, - count, stbuf, iobref, xdata); + UPCALL_STACK_UNWIND(readv, frame, op_ret, op_errno, vector, count, stbuf, + iobref, xdata); - return 0; + return 0; } static int32_t -up_readv (call_frame_t *frame, xlator_t *this, - fd_t *fd, size_t size, off_t offset, - uint32_t flags, dict_t *xdata) +up_readv(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, + off_t offset, uint32_t flags, dict_t *xdata) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, NULL, NULL, fd->inode, NULL); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, NULL, NULL, fd->inode, NULL); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - STACK_WIND (frame, up_readv_cbk, - FIRST_CHILD(this), FIRST_CHILD(this)->fops->readv, - fd, size, offset, flags, xdata); + STACK_WIND(frame, up_readv_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->readv, fd, size, offset, flags, xdata); - return 0; + return 0; err: - UPCALL_STACK_UNWIND (readv, frame, -1, op_errno, NULL, 0, - NULL, NULL, NULL); + UPCALL_STACK_UNWIND(readv, frame, -1, op_errno, NULL, 0, NULL, NULL, NULL); - return 0; + return 0; } static int32_t -up_lk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, struct gf_flock *lock, - dict_t *xdata) +up_lk_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, + int32_t op_errno, struct gf_flock *lock, dict_t *xdata) { - client_t *client = NULL; - uint32_t flags = 0; - upcall_local_t *local = NULL; + client_t *client = NULL; + uint32_t flags = 0; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } - flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, local->inode, flags, - NULL, NULL, NULL, NULL); + if ((op_ret < 0) || !local) { + goto out; + } + flags = UP_UPDATE_CLIENT; + upcall_cache_invalidate(frame, this, client, local->inode, flags, NULL, + NULL, NULL, NULL); out: - UPCALL_STACK_UNWIND (lk, frame, op_ret, op_errno, lock, xdata); + UPCALL_STACK_UNWIND(lk, frame, op_ret, op_errno, lock, xdata); - return 0; + return 0; } static int32_t -up_lk (call_frame_t *frame, xlator_t *this, - fd_t *fd, int32_t cmd, struct gf_flock *flock, dict_t *xdata) +up_lk(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd, + struct gf_flock *flock, dict_t *xdata) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, NULL, NULL, fd->inode, NULL); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, NULL, NULL, fd->inode, NULL); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - STACK_WIND (frame, up_lk_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->lk, - fd, cmd, flock, xdata); - return 0; + STACK_WIND(frame, up_lk_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->lk, + fd, cmd, flock, xdata); + return 0; err: - UPCALL_STACK_UNWIND (lk, frame, -1, op_errno, NULL, NULL); + UPCALL_STACK_UNWIND(lk, frame, -1, op_errno, NULL, NULL); - return 0; + return 0; } static int32_t -up_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, struct iatt *prebuf, - struct iatt *postbuf, dict_t *xdata) +up_truncate_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + int op_errno, struct iatt *prebuf, struct iatt *postbuf, + dict_t *xdata) { - client_t *client = NULL; - uint32_t flags = 0; - upcall_local_t *local = NULL; + client_t *client = NULL; + uint32_t flags = 0; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } - flags = UP_WRITE_FLAGS; - upcall_cache_invalidate (frame, this, client, local->inode, flags, - postbuf, NULL, NULL, NULL); + if ((op_ret < 0) || !local) { + goto out; + } + flags = UP_WRITE_FLAGS; + upcall_cache_invalidate(frame, this, client, local->inode, flags, postbuf, + NULL, NULL, NULL); out: - UPCALL_STACK_UNWIND (truncate, frame, op_ret, op_errno, - prebuf, postbuf, xdata); + UPCALL_STACK_UNWIND(truncate, frame, op_ret, op_errno, prebuf, postbuf, + xdata); - return 0; + return 0; } static int32_t -up_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset, - dict_t *xdata) +up_truncate(call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset, + dict_t *xdata) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, NULL, NULL, loc->inode, NULL); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, NULL, NULL, loc->inode, NULL); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - STACK_WIND (frame, up_truncate_cbk, - FIRST_CHILD(this), FIRST_CHILD(this)->fops->truncate, - loc, offset, xdata); + STACK_WIND(frame, up_truncate_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->truncate, loc, offset, xdata); - return 0; + return 0; err: - UPCALL_STACK_UNWIND (truncate, frame, -1, op_errno, NULL, NULL, NULL); + UPCALL_STACK_UNWIND(truncate, frame, -1, op_errno, NULL, NULL, NULL); - return 0; + return 0; } static int32_t -up_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, struct iatt *statpre, - struct iatt *statpost, dict_t *xdata) +up_setattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + int op_errno, struct iatt *statpre, struct iatt *statpost, + dict_t *xdata) { - client_t *client = NULL; - uint32_t flags = 0; - upcall_local_t *local = NULL; + client_t *client = NULL; + uint32_t flags = 0; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } - /* XXX: setattr -> UP_SIZE or UP_OWN or UP_MODE or UP_TIMES - * or INODE_UPDATE (or UP_PERM esp in case of ACLs -> INODE_INVALIDATE) - * Need to check what attr is changed and accordingly pass UP_FLAGS. - * Bug1200271. - */ - flags = UP_ATTR_FLAGS; - /* If mode bits have changed invalidate the xattrs, as posix-acl and - * others store permission related information in xattrs. With changing - * of permissions/mode, we need to make clients to forget all the - * xattrs related to permissions. - * TODO: Invalidate the xattr system.posix_acl_access alone. - */ - if (is_same_mode(statpre->ia_prot, statpost->ia_prot) != 0) - flags |= UP_XATTR; - - upcall_cache_invalidate (frame, this, client, local->inode, flags, - statpost, NULL, NULL, NULL); - -out: - UPCALL_STACK_UNWIND (setattr, frame, op_ret, op_errno, - statpre, statpost, xdata); + if ((op_ret < 0) || !local) { + goto out; + } + /* XXX: setattr -> UP_SIZE or UP_OWN or UP_MODE or UP_TIMES + * or INODE_UPDATE (or UP_PERM esp in case of ACLs -> INODE_INVALIDATE) + * Need to check what attr is changed and accordingly pass UP_FLAGS. + * Bug1200271. + */ + flags = UP_ATTR_FLAGS; + /* If mode bits have changed invalidate the xattrs, as posix-acl and + * others store permission related information in xattrs. With changing + * of permissions/mode, we need to make clients to forget all the + * xattrs related to permissions. + * TODO: Invalidate the xattr system.posix_acl_access alone. + */ + if (is_same_mode(statpre->ia_prot, statpost->ia_prot) != 0) + flags |= UP_XATTR; - return 0; + upcall_cache_invalidate(frame, this, client, local->inode, flags, statpost, + NULL, NULL, NULL); + +out: + UPCALL_STACK_UNWIND(setattr, frame, op_ret, op_errno, statpre, statpost, + xdata); + + return 0; } static int32_t -up_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc, - struct iatt *stbuf, int32_t valid, dict_t *xdata) +up_setattr(call_frame_t *frame, xlator_t *this, loc_t *loc, struct iatt *stbuf, + int32_t valid, dict_t *xdata) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, NULL, NULL, loc->inode, NULL); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, NULL, NULL, loc->inode, NULL); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - STACK_WIND (frame, up_setattr_cbk, - FIRST_CHILD(this), - FIRST_CHILD(this)->fops->setattr, - loc, stbuf, valid, xdata); + STACK_WIND(frame, up_setattr_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->setattr, loc, stbuf, valid, xdata); - return 0; + return 0; err: - UPCALL_STACK_UNWIND (setattr, frame, -1, op_errno, NULL, NULL, NULL); + UPCALL_STACK_UNWIND(setattr, frame, -1, op_errno, NULL, NULL, NULL); - return 0; + return 0; } static int32_t -up_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, struct iatt *stbuf, - struct iatt *preoldparent, struct iatt *postoldparent, - struct iatt *prenewparent, struct iatt *postnewparent, - dict_t *xdata) +up_rename_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, + int32_t op_errno, struct iatt *stbuf, struct iatt *preoldparent, + struct iatt *postoldparent, struct iatt *prenewparent, + struct iatt *postnewparent, dict_t *xdata) { - client_t *client = NULL; - uint32_t flags = 0; - upcall_local_t *local = NULL; + client_t *client = NULL; + uint32_t flags = 0; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } - flags = (UP_RENAME_FLAGS | UP_PARENT_DENTRY_FLAGS); - upcall_cache_invalidate (frame, this, client, local->inode, flags, - stbuf, postnewparent, postoldparent, NULL); + if ((op_ret < 0) || !local) { + goto out; + } + flags = (UP_RENAME_FLAGS | UP_PARENT_DENTRY_FLAGS); + upcall_cache_invalidate(frame, this, client, local->inode, flags, stbuf, + postnewparent, postoldparent, NULL); - flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, - local->rename_oldloc.parent, flags, - postoldparent, NULL, NULL, NULL); + flags = UP_UPDATE_CLIENT; + upcall_cache_invalidate(frame, this, client, local->rename_oldloc.parent, + flags, postoldparent, NULL, NULL, NULL); - if (local->rename_oldloc.parent == local->loc.parent) - goto out; + if (local->rename_oldloc.parent == local->loc.parent) + goto out; - flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, local->loc.parent, - flags, postnewparent, NULL, NULL, NULL); + flags = UP_UPDATE_CLIENT; + upcall_cache_invalidate(frame, this, client, local->loc.parent, flags, + postnewparent, NULL, NULL, NULL); out: - UPCALL_STACK_UNWIND (rename, frame, op_ret, op_errno, - stbuf, preoldparent, postoldparent, - prenewparent, postnewparent, xdata); + UPCALL_STACK_UNWIND(rename, frame, op_ret, op_errno, stbuf, preoldparent, + postoldparent, prenewparent, postnewparent, xdata); - return 0; + return 0; } static int32_t -up_rename (call_frame_t *frame, xlator_t *this, - loc_t *oldloc, loc_t *newloc, dict_t *xdata) +up_rename(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, + dict_t *xdata) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, newloc, NULL, oldloc->inode, NULL); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, newloc, NULL, oldloc->inode, NULL); + if (!local) { + op_errno = ENOMEM; + goto err; + } - /* copy oldloc */ - loc_copy (&local->rename_oldloc, oldloc); + /* copy oldloc */ + loc_copy(&local->rename_oldloc, oldloc); out: - STACK_WIND (frame, up_rename_cbk, - FIRST_CHILD(this), FIRST_CHILD(this)->fops->rename, - oldloc, newloc, xdata); + STACK_WIND(frame, up_rename_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->rename, oldloc, newloc, xdata); - return 0; + return 0; err: - UPCALL_STACK_UNWIND (rename, frame, -1, op_errno, NULL, - NULL, NULL, NULL, NULL, NULL); + UPCALL_STACK_UNWIND(rename, frame, -1, op_errno, NULL, NULL, NULL, NULL, + NULL, NULL); - return 0; + return 0; } static int32_t -up_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, struct iatt *preparent, - struct iatt *postparent, dict_t *xdata) +up_unlink_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + int op_errno, struct iatt *preparent, struct iatt *postparent, + dict_t *xdata) { - client_t *client = NULL; - uint32_t flags = 0; - upcall_local_t *local = NULL; + client_t *client = NULL; + uint32_t flags = 0; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } - flags = (UP_NLINK_FLAGS | UP_PARENT_DENTRY_FLAGS); - upcall_cache_invalidate (frame, this, client, local->inode, flags, - NULL, postparent, NULL, NULL); + if ((op_ret < 0) || !local) { + goto out; + } + flags = (UP_NLINK_FLAGS | UP_PARENT_DENTRY_FLAGS); + upcall_cache_invalidate(frame, this, client, local->inode, flags, NULL, + postparent, NULL, NULL); - flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, local->loc.parent, - flags, postparent, NULL, NULL, NULL); + flags = UP_UPDATE_CLIENT; + upcall_cache_invalidate(frame, this, client, local->loc.parent, flags, + postparent, NULL, NULL, NULL); out: - UPCALL_STACK_UNWIND (unlink, frame, op_ret, op_errno, - preparent, postparent, xdata); + UPCALL_STACK_UNWIND(unlink, frame, op_ret, op_errno, preparent, postparent, + xdata); - return 0; + return 0; } static int32_t -up_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag, - dict_t *xdata) +up_unlink(call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag, + dict_t *xdata) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, loc, NULL, loc->inode, NULL); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, loc, NULL, loc->inode, NULL); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - STACK_WIND (frame, up_unlink_cbk, - FIRST_CHILD(this), FIRST_CHILD(this)->fops->unlink, - loc, xflag, xdata); + STACK_WIND(frame, up_unlink_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->unlink, loc, xflag, xdata); - return 0; + return 0; err: - UPCALL_STACK_UNWIND (unlink, frame, -1, op_errno, NULL, NULL, NULL); + UPCALL_STACK_UNWIND(unlink, frame, -1, op_errno, NULL, NULL, NULL); - return 0; + return 0; } static int32_t -up_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, inode_t *inode, struct iatt *stbuf, - struct iatt *preparent, struct iatt *postparent, dict_t *xdata) +up_link_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + int op_errno, inode_t *inode, struct iatt *stbuf, + struct iatt *preparent, struct iatt *postparent, dict_t *xdata) { - client_t *client = NULL; - uint32_t flags = 0; - upcall_local_t *local = NULL; + client_t *client = NULL; + uint32_t flags = 0; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } - flags = (UP_NLINK_FLAGS | UP_PARENT_DENTRY_FLAGS); - upcall_cache_invalidate (frame, this, client, local->inode, flags, - stbuf, postparent, NULL, NULL); + if ((op_ret < 0) || !local) { + goto out; + } + flags = (UP_NLINK_FLAGS | UP_PARENT_DENTRY_FLAGS); + upcall_cache_invalidate(frame, this, client, local->inode, flags, stbuf, + postparent, NULL, NULL); - flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, local->loc.parent, - flags, postparent, NULL, NULL, NULL); + flags = UP_UPDATE_CLIENT; + upcall_cache_invalidate(frame, this, client, local->loc.parent, flags, + postparent, NULL, NULL, NULL); out: - UPCALL_STACK_UNWIND (link, frame, op_ret, op_errno, - inode, stbuf, preparent, postparent, xdata); + UPCALL_STACK_UNWIND(link, frame, op_ret, op_errno, inode, stbuf, preparent, + postparent, xdata); - return 0; + return 0; } static int32_t -up_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, - loc_t *newloc, dict_t *xdata) +up_link(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, + dict_t *xdata) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, newloc, NULL, oldloc->inode, NULL); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, newloc, NULL, oldloc->inode, NULL); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - STACK_WIND (frame, up_link_cbk, - FIRST_CHILD(this), FIRST_CHILD(this)->fops->link, - oldloc, newloc, xdata); + STACK_WIND(frame, up_link_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->link, oldloc, newloc, xdata); - return 0; + return 0; err: - UPCALL_STACK_UNWIND (link, frame, -1, op_errno, NULL, - NULL, NULL, NULL, NULL); + UPCALL_STACK_UNWIND(link, frame, -1, op_errno, NULL, NULL, NULL, NULL, + NULL); - return 0; + return 0; } static int32_t -up_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, struct iatt *preparent, - struct iatt *postparent, dict_t *xdata) +up_rmdir_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + int op_errno, struct iatt *preparent, struct iatt *postparent, + dict_t *xdata) { - client_t *client = NULL; - uint32_t flags = 0; - upcall_local_t *local = NULL; + client_t *client = NULL; + uint32_t flags = 0; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } + if ((op_ret < 0) || !local) { + goto out; + } - flags = (UP_NLINK_FLAGS | UP_PARENT_DENTRY_FLAGS); - upcall_cache_invalidate (frame, this, client, local->inode, flags, - NULL, postparent, NULL, NULL); + flags = (UP_NLINK_FLAGS | UP_PARENT_DENTRY_FLAGS); + upcall_cache_invalidate(frame, this, client, local->inode, flags, NULL, + postparent, NULL, NULL); - flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, local->loc.parent, - flags, postparent, NULL, NULL, NULL); + flags = UP_UPDATE_CLIENT; + upcall_cache_invalidate(frame, this, client, local->loc.parent, flags, + postparent, NULL, NULL, NULL); out: - UPCALL_STACK_UNWIND (rmdir, frame, op_ret, op_errno, - preparent, postparent, xdata); + UPCALL_STACK_UNWIND(rmdir, frame, op_ret, op_errno, preparent, postparent, + xdata); - return 0; + return 0; } static int32_t -up_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags, - dict_t *xdata) +up_rmdir(call_frame_t *frame, xlator_t *this, loc_t *loc, int flags, + dict_t *xdata) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, loc, NULL, loc->inode, NULL); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, loc, NULL, loc->inode, NULL); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - STACK_WIND (frame, up_rmdir_cbk, - FIRST_CHILD(this), FIRST_CHILD(this)->fops->rmdir, - loc, flags, xdata); + STACK_WIND(frame, up_rmdir_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->rmdir, loc, flags, xdata); - return 0; + return 0; err: - UPCALL_STACK_UNWIND (rmdir, frame, -1, op_errno, NULL, NULL, NULL); + UPCALL_STACK_UNWIND(rmdir, frame, -1, op_errno, NULL, NULL, NULL); - return 0; + return 0; } static int32_t -up_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, inode_t *inode, - struct iatt *stbuf, struct iatt *preparent, - struct iatt *postparent, dict_t *xdata) +up_mkdir_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + int op_errno, inode_t *inode, struct iatt *stbuf, + struct iatt *preparent, struct iatt *postparent, dict_t *xdata) { - client_t *client = NULL; - uint32_t flags = 0; - upcall_local_t *local = NULL; + client_t *client = NULL; + uint32_t flags = 0; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } + if ((op_ret < 0) || !local) { + goto out; + } - /* invalidate parent's entry too */ - flags = UP_TIMES; - upcall_cache_invalidate (frame, this, client, local->inode, flags, - postparent, NULL, NULL, NULL); + /* invalidate parent's entry too */ + flags = UP_TIMES; + upcall_cache_invalidate(frame, this, client, local->inode, flags, + postparent, NULL, NULL, NULL); - flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, local->loc.inode, flags, - stbuf, NULL, NULL, NULL); + flags = UP_UPDATE_CLIENT; + upcall_cache_invalidate(frame, this, client, local->loc.inode, flags, stbuf, + NULL, NULL, NULL); out: - UPCALL_STACK_UNWIND (mkdir, frame, op_ret, op_errno, - inode, stbuf, preparent, postparent, xdata); + UPCALL_STACK_UNWIND(mkdir, frame, op_ret, op_errno, inode, stbuf, preparent, + postparent, xdata); - return 0; + return 0; } static int32_t -up_mkdir (call_frame_t *frame, xlator_t *this, - loc_t *loc, mode_t mode, mode_t umask, dict_t *params) +up_mkdir(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, + mode_t umask, dict_t *params) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, loc, NULL, loc->parent, NULL); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, loc, NULL, loc->parent, NULL); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - STACK_WIND (frame, up_mkdir_cbk, - FIRST_CHILD(this), FIRST_CHILD(this)->fops->mkdir, - loc, mode, umask, params); + STACK_WIND(frame, up_mkdir_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->mkdir, loc, mode, umask, params); - return 0; + return 0; err: - UPCALL_STACK_UNWIND (mkdir, frame, -1, op_errno, NULL, - NULL, NULL, NULL, NULL); + UPCALL_STACK_UNWIND(mkdir, frame, -1, op_errno, NULL, NULL, NULL, NULL, + NULL); - return 0; + return 0; } static int32_t -up_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, fd_t *fd, inode_t *inode, - struct iatt *stbuf, struct iatt *preparent, - struct iatt *postparent, dict_t *xdata) +up_create_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + int op_errno, fd_t *fd, inode_t *inode, struct iatt *stbuf, + struct iatt *preparent, struct iatt *postparent, dict_t *xdata) { - client_t *client = NULL; - uint32_t flags = 0; - upcall_local_t *local = NULL; + client_t *client = NULL; + uint32_t flags = 0; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } + if ((op_ret < 0) || !local) { + goto out; + } - /* As its a new file create, no need of sending notification - * However invalidate parent's entry and update that fact that the - * client has accessed the newly created entry */ - flags = UP_TIMES; - upcall_cache_invalidate (frame, this, client, local->inode, flags, - postparent, NULL, NULL, NULL); + /* As its a new file create, no need of sending notification + * However invalidate parent's entry and update that fact that the + * client has accessed the newly created entry */ + flags = UP_TIMES; + upcall_cache_invalidate(frame, this, client, local->inode, flags, + postparent, NULL, NULL, NULL); - flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, local->loc.inode, flags, - stbuf, NULL, NULL, NULL); + flags = UP_UPDATE_CLIENT; + upcall_cache_invalidate(frame, this, client, local->loc.inode, flags, stbuf, + NULL, NULL, NULL); out: - UPCALL_STACK_UNWIND (create, frame, op_ret, op_errno, fd, - inode, stbuf, preparent, postparent, xdata); + UPCALL_STACK_UNWIND(create, frame, op_ret, op_errno, fd, inode, stbuf, + preparent, postparent, xdata); - return 0; + return 0; } static int32_t -up_create (call_frame_t *frame, xlator_t *this, - loc_t *loc, int32_t flags, mode_t mode, - mode_t umask, fd_t *fd, dict_t *params) +up_create(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, + mode_t mode, mode_t umask, fd_t *fd, dict_t *params) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, loc, NULL, loc->parent, NULL); + local = upcall_local_init(frame, this, loc, NULL, loc->parent, NULL); - if (!local) { - op_errno = ENOMEM; - goto err; - } + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - STACK_WIND (frame, up_create_cbk, - FIRST_CHILD(this), FIRST_CHILD(this)->fops->create, - loc, flags, mode, umask, fd, params); + STACK_WIND(frame, up_create_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->create, loc, flags, mode, umask, fd, + params); - return 0; + return 0; err: - UPCALL_STACK_UNWIND (create, frame, -1, op_errno, NULL, - NULL, NULL, NULL, NULL, NULL); + UPCALL_STACK_UNWIND(create, frame, -1, op_errno, NULL, NULL, NULL, NULL, + NULL, NULL); - return 0; + return 0; } static int32_t -up_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, - inode_t *inode, struct iatt *stbuf, dict_t *xattr, - struct iatt *postparent) +up_lookup_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + int op_errno, inode_t *inode, struct iatt *stbuf, dict_t *xattr, + struct iatt *postparent) { - client_t *client = NULL; - uint32_t flags = 0; - upcall_local_t *local = NULL; + client_t *client = NULL; + uint32_t flags = 0; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } - flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, local->inode, flags, - stbuf, NULL, NULL, NULL); + if ((op_ret < 0) || !local) { + goto out; + } + flags = UP_UPDATE_CLIENT; + upcall_cache_invalidate(frame, this, client, local->inode, flags, stbuf, + NULL, NULL, NULL); out: - UPCALL_STACK_UNWIND (lookup, frame, op_ret, op_errno, inode, stbuf, - xattr, postparent); + UPCALL_STACK_UNWIND(lookup, frame, op_ret, op_errno, inode, stbuf, xattr, + postparent); - return 0; + return 0; } static int32_t -up_lookup (call_frame_t *frame, xlator_t *this, - loc_t *loc, dict_t *xattr_req) +up_lookup(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xattr_req) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, NULL, NULL, loc->inode, NULL); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, NULL, NULL, loc->inode, NULL); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - STACK_WIND (frame, up_lookup_cbk, - FIRST_CHILD(this), FIRST_CHILD(this)->fops->lookup, - loc, xattr_req); + STACK_WIND(frame, up_lookup_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->lookup, loc, xattr_req); - return 0; + return 0; err: - UPCALL_STACK_UNWIND (lookup, frame, -1, op_errno, NULL, - NULL, NULL, NULL); + UPCALL_STACK_UNWIND(lookup, frame, -1, op_errno, NULL, NULL, NULL, NULL); - return 0; + return 0; } static int32_t -up_stat_cbk (call_frame_t *frame, void *cookie, - xlator_t *this, int32_t op_ret, int32_t op_errno, - struct iatt *buf, dict_t *xdata) +up_stat_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, + int32_t op_errno, struct iatt *buf, dict_t *xdata) { - client_t *client = NULL; - uint32_t flags = 0; - upcall_local_t *local = NULL; + client_t *client = NULL; + uint32_t flags = 0; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } - flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, local->inode, flags, - buf, NULL, NULL, NULL); + if ((op_ret < 0) || !local) { + goto out; + } + flags = UP_UPDATE_CLIENT; + upcall_cache_invalidate(frame, this, client, local->inode, flags, buf, NULL, + NULL, NULL); out: - UPCALL_STACK_UNWIND (stat, frame, op_ret, op_errno, buf, - xdata); + UPCALL_STACK_UNWIND(stat, frame, op_ret, op_errno, buf, xdata); - return 0; + return 0; } static int32_t -up_stat (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) +up_stat(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, NULL, NULL, loc->inode, NULL); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, NULL, NULL, loc->inode, NULL); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - STACK_WIND (frame, up_stat_cbk, - FIRST_CHILD(this), FIRST_CHILD(this)->fops->stat, - loc, xdata); + STACK_WIND(frame, up_stat_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->stat, loc, xdata); - return 0; + return 0; err: - UPCALL_STACK_UNWIND (stat, frame, -1, op_errno, NULL, NULL); + UPCALL_STACK_UNWIND(stat, frame, -1, op_errno, NULL, NULL); - return 0; + return 0; } static int32_t -up_fstat (call_frame_t *frame, xlator_t *this, - fd_t *fd, dict_t *xdata) +up_fstat(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, NULL, NULL, fd->inode, NULL); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, NULL, NULL, fd->inode, NULL); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - STACK_WIND (frame, up_stat_cbk, - FIRST_CHILD(this), FIRST_CHILD(this)->fops->fstat, - fd, xdata); + STACK_WIND(frame, up_stat_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->fstat, fd, xdata); - return 0; + return 0; err: - UPCALL_STACK_UNWIND (fstat, frame, -1, op_errno, NULL, NULL); + UPCALL_STACK_UNWIND(fstat, frame, -1, op_errno, NULL, NULL); - return 0; + return 0; } static int32_t -up_ftruncate (call_frame_t *frame, xlator_t *this, - fd_t *fd, off_t offset, dict_t *xdata) +up_ftruncate(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, + dict_t *xdata) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, NULL, NULL, fd->inode, NULL); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, NULL, NULL, fd->inode, NULL); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - STACK_WIND (frame, up_truncate_cbk, - FIRST_CHILD(this), FIRST_CHILD(this)->fops->ftruncate, - fd, offset, xdata); + STACK_WIND(frame, up_truncate_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->ftruncate, fd, offset, xdata); - return 0; + return 0; err: - UPCALL_STACK_UNWIND (ftruncate, frame, -1, op_errno, NULL, - NULL, NULL); + UPCALL_STACK_UNWIND(ftruncate, frame, -1, op_errno, NULL, NULL, NULL); - return 0; + return 0; } static int32_t -up_access_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, dict_t *xdata) +up_access_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + int op_errno, dict_t *xdata) { - client_t *client = NULL; - uint32_t flags = 0; - upcall_local_t *local = NULL; + client_t *client = NULL; + uint32_t flags = 0; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } - flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, local->inode, flags, - NULL, NULL, NULL, NULL); + if ((op_ret < 0) || !local) { + goto out; + } + flags = UP_UPDATE_CLIENT; + upcall_cache_invalidate(frame, this, client, local->inode, flags, NULL, + NULL, NULL, NULL); out: - UPCALL_STACK_UNWIND (access, frame, op_ret, op_errno, xdata); + UPCALL_STACK_UNWIND(access, frame, op_ret, op_errno, xdata); - return 0; + return 0; } static int32_t -up_access (call_frame_t *frame, xlator_t *this, - loc_t *loc, int32_t mask, dict_t *xdata) +up_access(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t mask, + dict_t *xdata) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, NULL, NULL, loc->inode, NULL); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, NULL, NULL, loc->inode, NULL); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - STACK_WIND (frame, up_access_cbk, - FIRST_CHILD(this), FIRST_CHILD(this)->fops->access, - loc, mask, xdata); + STACK_WIND(frame, up_access_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->access, loc, mask, xdata); - return 0; + return 0; err: - UPCALL_STACK_UNWIND (access, frame, -1, op_errno, NULL); + UPCALL_STACK_UNWIND(access, frame, -1, op_errno, NULL); - return 0; + return 0; } static int32_t -up_readlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, const char *path, - struct iatt *stbuf, dict_t *xdata) +up_readlink_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + int op_errno, const char *path, struct iatt *stbuf, + dict_t *xdata) { - client_t *client = NULL; - uint32_t flags = 0; - upcall_local_t *local = NULL; + client_t *client = NULL; + uint32_t flags = 0; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } - flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, local->inode, flags, - stbuf, NULL, NULL, NULL); + if ((op_ret < 0) || !local) { + goto out; + } + flags = UP_UPDATE_CLIENT; + upcall_cache_invalidate(frame, this, client, local->inode, flags, stbuf, + NULL, NULL, NULL); out: - UPCALL_STACK_UNWIND (readlink, frame, op_ret, op_errno, path, stbuf, - xdata); + UPCALL_STACK_UNWIND(readlink, frame, op_ret, op_errno, path, stbuf, xdata); - return 0; + return 0; } static int32_t -up_readlink (call_frame_t *frame, xlator_t *this, - loc_t *loc, size_t size, dict_t *xdata) +up_readlink(call_frame_t *frame, xlator_t *this, loc_t *loc, size_t size, + dict_t *xdata) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, NULL, NULL, loc->inode, NULL); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, NULL, NULL, loc->inode, NULL); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - STACK_WIND (frame, up_readlink_cbk, - FIRST_CHILD(this), FIRST_CHILD(this)->fops->readlink, - loc, size, xdata); + STACK_WIND(frame, up_readlink_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->readlink, loc, size, xdata); - return 0; + return 0; err: - UPCALL_STACK_UNWIND (readlink, frame, -1, op_errno, NULL, - NULL, NULL); + UPCALL_STACK_UNWIND(readlink, frame, -1, op_errno, NULL, NULL, NULL); - return 0; + return 0; } static int32_t -up_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, inode_t *inode, - struct iatt *buf, struct iatt *preparent, - struct iatt *postparent, dict_t *xdata) +up_mknod_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, + int32_t op_errno, inode_t *inode, struct iatt *buf, + struct iatt *preparent, struct iatt *postparent, dict_t *xdata) { - client_t *client = NULL; - uint32_t flags = 0; - upcall_local_t *local = NULL; + client_t *client = NULL; + uint32_t flags = 0; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } + if ((op_ret < 0) || !local) { + goto out; + } - /* invalidate parent's entry too */ - flags = UP_TIMES; - upcall_cache_invalidate (frame, this, client, local->inode, flags, - postparent, NULL, NULL, NULL); + /* invalidate parent's entry too */ + flags = UP_TIMES; + upcall_cache_invalidate(frame, this, client, local->inode, flags, + postparent, NULL, NULL, NULL); - flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, local->loc.inode, flags, - buf, NULL, NULL, NULL); + flags = UP_UPDATE_CLIENT; + upcall_cache_invalidate(frame, this, client, local->loc.inode, flags, buf, + NULL, NULL, NULL); out: - UPCALL_STACK_UNWIND (mknod, frame, op_ret, op_errno, inode, buf, - preparent, postparent, xdata); + UPCALL_STACK_UNWIND(mknod, frame, op_ret, op_errno, inode, buf, preparent, + postparent, xdata); - return 0; + return 0; } static int32_t -up_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, - mode_t mode, dev_t rdev, mode_t umask, dict_t *xdata) +up_mknod(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, + dev_t rdev, mode_t umask, dict_t *xdata) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, loc, NULL, loc->parent, NULL); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, loc, NULL, loc->parent, NULL); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - STACK_WIND (frame, up_mknod_cbk, - FIRST_CHILD(this), FIRST_CHILD(this)->fops->mknod, - loc, mode, rdev, umask, xdata); + STACK_WIND(frame, up_mknod_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->mknod, loc, mode, rdev, umask, xdata); - return 0; + return 0; err: - UPCALL_STACK_UNWIND (mknod, frame, -1, op_errno, NULL, - NULL, NULL, NULL, NULL); + UPCALL_STACK_UNWIND(mknod, frame, -1, op_errno, NULL, NULL, NULL, NULL, + NULL); - return 0; + return 0; } static int32_t -up_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, inode_t *inode, - struct iatt *buf, struct iatt *preparent, - struct iatt *postparent, dict_t *xdata) +up_symlink_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, inode_t *inode, + struct iatt *buf, struct iatt *preparent, + struct iatt *postparent, dict_t *xdata) { - client_t *client = NULL; - uint32_t flags = 0; - upcall_local_t *local = NULL; + client_t *client = NULL; + uint32_t flags = 0; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } + if ((op_ret < 0) || !local) { + goto out; + } - /* invalidate parent's entry too */ - flags = UP_TIMES; - upcall_cache_invalidate (frame, this, client, local->inode, flags, - postparent, NULL, NULL, NULL); + /* invalidate parent's entry too */ + flags = UP_TIMES; + upcall_cache_invalidate(frame, this, client, local->inode, flags, + postparent, NULL, NULL, NULL); - flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, local->loc.inode, flags, - buf, NULL, NULL, NULL); + flags = UP_UPDATE_CLIENT; + upcall_cache_invalidate(frame, this, client, local->loc.inode, flags, buf, + NULL, NULL, NULL); out: - UPCALL_STACK_UNWIND (symlink, frame, op_ret, op_errno, inode, buf, - preparent, postparent, xdata); + UPCALL_STACK_UNWIND(symlink, frame, op_ret, op_errno, inode, buf, preparent, + postparent, xdata); - return 0; + return 0; } static int32_t -up_symlink (call_frame_t *frame, xlator_t *this, - const char *linkpath, loc_t *loc, mode_t umask, - dict_t *xdata) +up_symlink(call_frame_t *frame, xlator_t *this, const char *linkpath, + loc_t *loc, mode_t umask, dict_t *xdata) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, loc, NULL, loc->parent, NULL); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, loc, NULL, loc->parent, NULL); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - STACK_WIND (frame, up_symlink_cbk, - FIRST_CHILD(this), FIRST_CHILD(this)->fops->symlink, - linkpath, loc, umask, xdata); + STACK_WIND(frame, up_symlink_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->symlink, linkpath, loc, umask, xdata); - return 0; + return 0; err: - UPCALL_STACK_UNWIND (symlink, frame, -1, op_errno, NULL, - NULL, NULL, NULL, NULL); + UPCALL_STACK_UNWIND(symlink, frame, -1, op_errno, NULL, NULL, NULL, NULL, + NULL); - return 0; + return 0; } static int32_t -up_opendir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, fd_t *fd, - dict_t *xdata) +up_opendir_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, fd_t *fd, dict_t *xdata) { - client_t *client = NULL; - uint32_t flags = 0; - upcall_local_t *local = NULL; + client_t *client = NULL; + uint32_t flags = 0; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } - flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, local->inode, flags, - NULL, NULL, NULL, NULL); + if ((op_ret < 0) || !local) { + goto out; + } + flags = UP_UPDATE_CLIENT; + upcall_cache_invalidate(frame, this, client, local->inode, flags, NULL, + NULL, NULL, NULL); out: - UPCALL_STACK_UNWIND (opendir, frame, op_ret, op_errno, fd, xdata); + UPCALL_STACK_UNWIND(opendir, frame, op_ret, op_errno, fd, xdata); - return 0; + return 0; } static int32_t -up_opendir (call_frame_t *frame, xlator_t *this, - loc_t *loc, fd_t *fd, dict_t *xdata) +up_opendir(call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd, + dict_t *xdata) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, NULL, NULL, loc->inode, NULL); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, NULL, NULL, loc->inode, NULL); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - STACK_WIND (frame, up_opendir_cbk, - FIRST_CHILD(this), FIRST_CHILD(this)->fops->opendir, - loc, fd, xdata); + STACK_WIND(frame, up_opendir_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->opendir, loc, fd, xdata); - return 0; + return 0; err: - UPCALL_STACK_UNWIND (opendir, frame, -1, op_errno, NULL, NULL); + UPCALL_STACK_UNWIND(opendir, frame, -1, op_errno, NULL, NULL); - return 0; + return 0; } static int32_t -up_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, struct statvfs *buf, - dict_t *xdata) +up_statfs_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, + int32_t op_errno, struct statvfs *buf, dict_t *xdata) { - client_t *client = NULL; - uint32_t flags = 0; - upcall_local_t *local = NULL; + client_t *client = NULL; + uint32_t flags = 0; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } - flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, local->inode, flags, - NULL, NULL, NULL, NULL); + if ((op_ret < 0) || !local) { + goto out; + } + flags = UP_UPDATE_CLIENT; + upcall_cache_invalidate(frame, this, client, local->inode, flags, NULL, + NULL, NULL, NULL); out: - UPCALL_STACK_UNWIND (statfs, frame, op_ret, op_errno, buf, xdata); + UPCALL_STACK_UNWIND(statfs, frame, op_ret, op_errno, buf, xdata); - return 0; + return 0; } static int32_t -up_statfs (call_frame_t *frame, xlator_t *this, - loc_t *loc, dict_t *xdata) +up_statfs(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, NULL, NULL, loc->inode, NULL); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, NULL, NULL, loc->inode, NULL); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - STACK_WIND (frame, up_statfs_cbk, - FIRST_CHILD(this), FIRST_CHILD(this)->fops->statfs, - loc, xdata); + STACK_WIND(frame, up_statfs_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->statfs, loc, xdata); - return 0; + return 0; err: - UPCALL_STACK_UNWIND (statfs, frame, -1, op_errno, NULL, NULL); + UPCALL_STACK_UNWIND(statfs, frame, -1, op_errno, NULL, NULL); - return 0; + return 0; } static int32_t -up_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, gf_dirent_t *entries, - dict_t *xdata) +up_readdir_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, gf_dirent_t *entries, + dict_t *xdata) { - client_t *client = NULL; - uint32_t flags = 0; - upcall_local_t *local = NULL; + client_t *client = NULL; + uint32_t flags = 0; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } - flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, local->inode, flags, - NULL, NULL, NULL, NULL); + if ((op_ret < 0) || !local) { + goto out; + } + flags = UP_UPDATE_CLIENT; + upcall_cache_invalidate(frame, this, client, local->inode, flags, NULL, + NULL, NULL, NULL); out: - UPCALL_STACK_UNWIND (readdir, frame, op_ret, op_errno, entries, xdata); + UPCALL_STACK_UNWIND(readdir, frame, op_ret, op_errno, entries, xdata); - return 0; + return 0; } static int32_t -up_readdir (call_frame_t *frame, xlator_t *this, - fd_t *fd, size_t size, off_t off, dict_t *xdata) +up_readdir(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, + off_t off, dict_t *xdata) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, NULL, NULL, fd->inode, NULL); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, NULL, NULL, fd->inode, NULL); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - STACK_WIND (frame, up_readdir_cbk, - FIRST_CHILD(this), FIRST_CHILD(this)->fops->readdir, - fd, size, off, xdata); + STACK_WIND(frame, up_readdir_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->readdir, fd, size, off, xdata); - return 0; + return 0; err: - UPCALL_STACK_UNWIND (readdir, frame, -1, op_errno, NULL, NULL); + UPCALL_STACK_UNWIND(readdir, frame, -1, op_errno, NULL, NULL); - return 0; + return 0; } static int32_t -up_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, gf_dirent_t *entries, - dict_t *xdata) +up_readdirp_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, gf_dirent_t *entries, + dict_t *xdata) { - client_t *client = NULL; - uint32_t flags = 0; - upcall_local_t *local = NULL; - gf_dirent_t *entry = NULL; + client_t *client = NULL; + uint32_t flags = 0; + upcall_local_t *local = NULL; + gf_dirent_t *entry = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } - flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, local->inode, flags, - NULL, NULL, NULL, NULL); - - list_for_each_entry (entry, &entries->list, list) { - if (entry->inode == NULL) { - continue; - } - upcall_cache_invalidate (frame, this, client, entry->inode, - flags, &entry->d_stat, NULL, NULL, - NULL); + if ((op_ret < 0) || !local) { + goto out; + } + flags = UP_UPDATE_CLIENT; + upcall_cache_invalidate(frame, this, client, local->inode, flags, NULL, + NULL, NULL, NULL); + + list_for_each_entry(entry, &entries->list, list) + { + if (entry->inode == NULL) { + continue; } + upcall_cache_invalidate(frame, this, client, entry->inode, flags, + &entry->d_stat, NULL, NULL, NULL); + } out: - UPCALL_STACK_UNWIND (readdirp, frame, op_ret, op_errno, entries, xdata); + UPCALL_STACK_UNWIND(readdirp, frame, op_ret, op_errno, entries, xdata); - return 0; + return 0; } static int32_t -up_readdirp (call_frame_t *frame, xlator_t *this, - fd_t *fd, size_t size, off_t off, dict_t *dict) +up_readdirp(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, + off_t off, dict_t *dict) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, NULL, NULL, fd->inode, NULL); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, NULL, NULL, fd->inode, NULL); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - STACK_WIND (frame, up_readdirp_cbk, - FIRST_CHILD(this), FIRST_CHILD(this)->fops->readdirp, - fd, size, off, dict); + STACK_WIND(frame, up_readdirp_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->readdirp, fd, size, off, dict); - return 0; + return 0; err: - UPCALL_STACK_UNWIND (readdirp, frame, -1, op_errno, NULL, NULL); + UPCALL_STACK_UNWIND(readdirp, frame, -1, op_errno, NULL, NULL); - return 0; + return 0; } static int32_t -up_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd, - struct iatt *stbuf, int32_t valid, dict_t *xdata) +up_fsetattr(call_frame_t *frame, xlator_t *this, fd_t *fd, struct iatt *stbuf, + int32_t valid, dict_t *xdata) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, NULL, NULL, fd->inode, NULL); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, NULL, NULL, fd->inode, NULL); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - STACK_WIND (frame, up_setattr_cbk, - FIRST_CHILD(this), FIRST_CHILD(this)->fops->fsetattr, - fd, stbuf, valid, xdata); + STACK_WIND(frame, up_setattr_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->fsetattr, fd, stbuf, valid, xdata); - return 0; + return 0; err: - UPCALL_STACK_UNWIND (fsetattr, frame, -1, op_errno, NULL, - NULL, NULL); + UPCALL_STACK_UNWIND(fsetattr, frame, -1, op_errno, NULL, NULL, NULL); - return 0; + return 0; } static int32_t @@ -1441,56 +1389,54 @@ up_fallocate_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct iatt *pre, struct iatt *post, dict_t *xdata) { - client_t *client = NULL; - uint32_t flags = 0; - upcall_local_t *local = NULL; + client_t *client = NULL; + uint32_t flags = 0; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } - flags = UP_WRITE_FLAGS; - upcall_cache_invalidate (frame, this, client, local->inode, flags, - post, NULL, NULL, NULL); + if ((op_ret < 0) || !local) { + goto out; + } + flags = UP_WRITE_FLAGS; + upcall_cache_invalidate(frame, this, client, local->inode, flags, post, + NULL, NULL, NULL); out: - UPCALL_STACK_UNWIND (fallocate, frame, op_ret, op_errno, pre, - post, xdata); + UPCALL_STACK_UNWIND(fallocate, frame, op_ret, op_errno, pre, post, xdata); - return 0; + return 0; } static int32_t -up_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, - int32_t mode, off_t offset, size_t len, dict_t *xdata) +up_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode, + off_t offset, size_t len, dict_t *xdata) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, NULL, NULL, fd->inode, NULL); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, NULL, NULL, fd->inode, NULL); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - STACK_WIND (frame, up_fallocate_cbk, - FIRST_CHILD(this), FIRST_CHILD(this)->fops->fallocate, - fd, mode, offset, len, xdata); + STACK_WIND(frame, up_fallocate_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->fallocate, fd, mode, offset, len, + xdata); - return 0; + return 0; err: - UPCALL_STACK_UNWIND (fallocate, frame, -1, op_errno, NULL, - NULL, NULL); + UPCALL_STACK_UNWIND(fallocate, frame, -1, op_errno, NULL, NULL, NULL); - return 0; + return 0; } static int32_t @@ -1498,56 +1444,53 @@ up_discard_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct iatt *pre, struct iatt *post, dict_t *xdata) { - client_t *client = NULL; - uint32_t flags = 0; - upcall_local_t *local = NULL; + client_t *client = NULL; + uint32_t flags = 0; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } - flags = UP_WRITE_FLAGS; - upcall_cache_invalidate (frame, this, client, local->inode, flags, - post, NULL, NULL, NULL); + if ((op_ret < 0) || !local) { + goto out; + } + flags = UP_WRITE_FLAGS; + upcall_cache_invalidate(frame, this, client, local->inode, flags, post, + NULL, NULL, NULL); out: - UPCALL_STACK_UNWIND (discard, frame, op_ret, op_errno, pre, - post, xdata); + UPCALL_STACK_UNWIND(discard, frame, op_ret, op_errno, pre, post, xdata); - return 0; + return 0; } static int32_t -up_discard(call_frame_t *frame, xlator_t *this, fd_t *fd, - off_t offset, size_t len, dict_t *xdata) +up_discard(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, + size_t len, dict_t *xdata) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, NULL, NULL, fd->inode, NULL); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, NULL, NULL, fd->inode, NULL); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - STACK_WIND (frame, up_discard_cbk, - FIRST_CHILD(this), FIRST_CHILD(this)->fops->discard, - fd, offset, len, xdata); + STACK_WIND(frame, up_discard_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->discard, fd, offset, len, xdata); - return 0; + return 0; err: - UPCALL_STACK_UNWIND (discard, frame, -1, op_errno, NULL, - NULL, NULL); + UPCALL_STACK_UNWIND(discard, frame, -1, op_errno, NULL, NULL, NULL); - return 0; + return 0; } static int32_t @@ -1555,551 +1498,528 @@ up_zerofill_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct iatt *pre, struct iatt *post, dict_t *xdata) { - client_t *client = NULL; - uint32_t flags = 0; - upcall_local_t *local = NULL; + client_t *client = NULL; + uint32_t flags = 0; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } - flags = UP_WRITE_FLAGS; - upcall_cache_invalidate (frame, this, client, local->inode, flags, - post, NULL, NULL, NULL); + if ((op_ret < 0) || !local) { + goto out; + } + flags = UP_WRITE_FLAGS; + upcall_cache_invalidate(frame, this, client, local->inode, flags, post, + NULL, NULL, NULL); out: - UPCALL_STACK_UNWIND (zerofill, frame, op_ret, op_errno, pre, - post, xdata); + UPCALL_STACK_UNWIND(zerofill, frame, op_ret, op_errno, pre, post, xdata); - return 0; + return 0; } static int -up_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, - off_t offset, off_t len, dict_t *xdata) +up_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, + off_t len, dict_t *xdata) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, NULL, NULL, fd->inode, NULL); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, NULL, NULL, fd->inode, NULL); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - STACK_WIND (frame, up_zerofill_cbk, - FIRST_CHILD(this), FIRST_CHILD(this)->fops->zerofill, - fd, offset, len, xdata); + STACK_WIND(frame, up_zerofill_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->zerofill, fd, offset, len, xdata); - return 0; + return 0; err: - UPCALL_STACK_UNWIND (zerofill, frame, -1, op_errno, NULL, - NULL, NULL); + UPCALL_STACK_UNWIND(zerofill, frame, -1, op_errno, NULL, NULL, NULL); - return 0; + return 0; } - static int32_t -up_seek_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, - int op_errno, off_t offset, dict_t *xdata) +up_seek_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + int op_errno, off_t offset, dict_t *xdata) { - client_t *client = NULL; - uint32_t flags = 0; - upcall_local_t *local = NULL; + client_t *client = NULL; + uint32_t flags = 0; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } - flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, local->inode, flags, - NULL, NULL, NULL, NULL); + if ((op_ret < 0) || !local) { + goto out; + } + flags = UP_UPDATE_CLIENT; + upcall_cache_invalidate(frame, this, client, local->inode, flags, NULL, + NULL, NULL, NULL); out: - UPCALL_STACK_UNWIND (seek, frame, op_ret, op_errno, offset, xdata); + UPCALL_STACK_UNWIND(seek, frame, op_ret, op_errno, offset, xdata); - return 0; + return 0; } - static int32_t -up_seek (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, - gf_seek_what_t what, dict_t *xdata) +up_seek(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, + gf_seek_what_t what, dict_t *xdata) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, NULL, NULL, fd->inode, NULL); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, NULL, NULL, fd->inode, NULL); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - STACK_WIND (frame, up_seek_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->seek, fd, offset, what, xdata); + STACK_WIND(frame, up_seek_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->seek, fd, offset, what, xdata); - return 0; + return 0; err: - UPCALL_STACK_UNWIND (seek, frame, -1, op_errno, 0, NULL); + UPCALL_STACK_UNWIND(seek, frame, -1, op_errno, 0, NULL); - return 0; + return 0; } - static int32_t -up_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, +up_setxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, dict_t *xdata) { - client_t *client = NULL; - uint32_t flags = 0; - upcall_local_t *local = NULL; - int ret = 0; - struct iatt stbuf = {0, }; - upcall_private_t *priv = NULL; + client_t *client = NULL; + uint32_t flags = 0; + upcall_local_t *local = NULL; + int ret = 0; + struct iatt stbuf = { + 0, + }; + upcall_private_t *priv = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - priv = this->private; - GF_VALIDATE_OR_GOTO (this->name, priv, out); + priv = this->private; + GF_VALIDATE_OR_GOTO(this->name, priv, out); - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } + if ((op_ret < 0) || !local) { + goto out; + } - flags = UP_XATTR; + flags = UP_XATTR; - ret = up_filter_xattr (local->xattr, priv->xattrs); - if (ret < 0) { - op_ret = ret; - goto out; - } - if (!up_invalidate_needed (local->xattr)) - goto out; + ret = up_filter_xattr(local->xattr, priv->xattrs); + if (ret < 0) { + op_ret = ret; + goto out; + } + if (!up_invalidate_needed(local->xattr)) + goto out; - ret = dict_get_iatt (xdata, GF_POSTSTAT, &stbuf); - if (ret == 0) - flags |= UP_TIMES; + ret = dict_get_iatt(xdata, GF_POSTSTAT, &stbuf); + if (ret == 0) + flags |= UP_TIMES; - upcall_cache_invalidate (frame, this, client, local->inode, flags, - &stbuf, NULL, NULL, local->xattr); + upcall_cache_invalidate(frame, this, client, local->inode, flags, &stbuf, + NULL, NULL, local->xattr); out: - UPCALL_STACK_UNWIND (setxattr, frame, op_ret, op_errno, xdata); + UPCALL_STACK_UNWIND(setxattr, frame, op_ret, op_errno, xdata); - return 0; + return 0; } - static int32_t -up_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict, - int32_t flags, dict_t *xdata) +up_setxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict, + int32_t flags, dict_t *xdata) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, loc, NULL, loc->inode, dict); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, loc, NULL, loc->inode, dict); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - STACK_WIND (frame, up_setxattr_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->setxattr, loc, dict, flags, - xdata); + STACK_WIND(frame, up_setxattr_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->setxattr, loc, dict, flags, xdata); - return 0; + return 0; err: - UPCALL_STACK_UNWIND (setxattr, frame, -1, op_errno, NULL); + UPCALL_STACK_UNWIND(setxattr, frame, -1, op_errno, NULL); - return 0; + return 0; } - static int32_t -up_fsetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, dict_t *xdata) +up_fsetxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, dict_t *xdata) { - client_t *client = NULL; - uint32_t flags = 0; - upcall_local_t *local = NULL; - int ret = 0; - struct iatt stbuf = {0,}; - upcall_private_t *priv = NULL; + client_t *client = NULL; + uint32_t flags = 0; + upcall_local_t *local = NULL; + int ret = 0; + struct iatt stbuf = { + 0, + }; + upcall_private_t *priv = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - priv = this->private; - GF_VALIDATE_OR_GOTO (this->name, priv, out); + priv = this->private; + GF_VALIDATE_OR_GOTO(this->name, priv, out); - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } + if ((op_ret < 0) || !local) { + goto out; + } - flags = UP_XATTR; + flags = UP_XATTR; - ret = up_filter_xattr (local->xattr, priv->xattrs); - if (ret < 0) { - op_ret = ret; - goto out; - } - if (!up_invalidate_needed (local->xattr)) - goto out; + ret = up_filter_xattr(local->xattr, priv->xattrs); + if (ret < 0) { + op_ret = ret; + goto out; + } + if (!up_invalidate_needed(local->xattr)) + goto out; - ret = dict_get_iatt (xdata, GF_POSTSTAT, &stbuf); - if (ret == 0) - flags |= UP_TIMES; + ret = dict_get_iatt(xdata, GF_POSTSTAT, &stbuf); + if (ret == 0) + flags |= UP_TIMES; - upcall_cache_invalidate (frame, this, client, local->inode, flags, - &stbuf, NULL, NULL, local->xattr); + upcall_cache_invalidate(frame, this, client, local->inode, flags, &stbuf, + NULL, NULL, local->xattr); out: - UPCALL_STACK_UNWIND (fsetxattr, frame, op_ret, op_errno, xdata); + UPCALL_STACK_UNWIND(fsetxattr, frame, op_ret, op_errno, xdata); - return 0; + return 0; } - static int32_t -up_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *dict, - int32_t flags, dict_t *xdata) +up_fsetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *dict, + int32_t flags, dict_t *xdata) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, NULL, fd, fd->inode, dict); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, NULL, fd, fd->inode, dict); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - STACK_WIND (frame, up_fsetxattr_cbk, - FIRST_CHILD(this), FIRST_CHILD(this)->fops->fsetxattr, - fd, dict, flags, xdata); + STACK_WIND(frame, up_fsetxattr_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->fsetxattr, fd, dict, flags, xdata); - return 0; + return 0; err: - UPCALL_STACK_UNWIND (fsetxattr, frame, -1, op_errno, NULL); + UPCALL_STACK_UNWIND(fsetxattr, frame, -1, op_errno, NULL); - return 0; + return 0; } - static int32_t -up_fremovexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, dict_t *xdata) +up_fremovexattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, dict_t *xdata) { - client_t *client = NULL; - uint32_t flags = 0; - upcall_local_t *local = NULL; - struct iatt stbuf = {0,}; - int ret = 0; - upcall_private_t *priv = NULL; + client_t *client = NULL; + uint32_t flags = 0; + upcall_local_t *local = NULL; + struct iatt stbuf = { + 0, + }; + int ret = 0; + upcall_private_t *priv = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - priv = this->private; - GF_VALIDATE_OR_GOTO (this->name, priv, out); + priv = this->private; + GF_VALIDATE_OR_GOTO(this->name, priv, out); - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } - flags = UP_XATTR_RM; + if ((op_ret < 0) || !local) { + goto out; + } + flags = UP_XATTR_RM; - ret = up_filter_xattr (local->xattr, priv->xattrs); - if (ret < 0) { - op_ret = ret; - goto out; - } - if (!up_invalidate_needed (local->xattr)) - goto out; + ret = up_filter_xattr(local->xattr, priv->xattrs); + if (ret < 0) { + op_ret = ret; + goto out; + } + if (!up_invalidate_needed(local->xattr)) + goto out; - ret = dict_get_iatt (xdata, GF_POSTSTAT, &stbuf); - if (ret == 0) - flags |= UP_TIMES; + ret = dict_get_iatt(xdata, GF_POSTSTAT, &stbuf); + if (ret == 0) + flags |= UP_TIMES; - upcall_cache_invalidate (frame, this, client, local->inode, flags, - &stbuf, NULL, NULL, local->xattr); + upcall_cache_invalidate(frame, this, client, local->inode, flags, &stbuf, + NULL, NULL, local->xattr); out: - UPCALL_STACK_UNWIND (fremovexattr, frame, op_ret, op_errno, - xdata); - return 0; + UPCALL_STACK_UNWIND(fremovexattr, frame, op_ret, op_errno, xdata); + return 0; } - static int32_t -up_fremovexattr (call_frame_t *frame, xlator_t *this, fd_t *fd, - const char *name, dict_t *xdata) +up_fremovexattr(call_frame_t *frame, xlator_t *this, fd_t *fd, const char *name, + dict_t *xdata) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; - dict_t *xattr = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; + dict_t *xattr = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - xattr = dict_for_key_value (name, "", 1, _gf_true); - if (!xattr) { - op_errno = ENOMEM; - goto err; - } + xattr = dict_for_key_value(name, "", 1, _gf_true); + if (!xattr) { + op_errno = ENOMEM; + goto err; + } - local = upcall_local_init (frame, this, NULL, fd, fd->inode, xattr); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, NULL, fd, fd->inode, xattr); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - if (xattr) - dict_unref (xattr); + if (xattr) + dict_unref(xattr); - STACK_WIND (frame, up_fremovexattr_cbk, - FIRST_CHILD(this), FIRST_CHILD(this)->fops->fremovexattr, - fd, name, xdata); - return 0; + STACK_WIND(frame, up_fremovexattr_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->fremovexattr, fd, name, xdata); + return 0; err: - if (xattr) - dict_unref (xattr); + if (xattr) + dict_unref(xattr); - UPCALL_STACK_UNWIND (fremovexattr, frame, -1, op_errno, NULL); + UPCALL_STACK_UNWIND(fremovexattr, frame, -1, op_errno, NULL); - return 0; + return 0; } - static int32_t -up_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, dict_t *xdata) +up_removexattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, dict_t *xdata) { - client_t *client = NULL; - uint32_t flags = 0; - upcall_local_t *local = NULL; - struct iatt stbuf = {0,}; - int ret = 0; - upcall_private_t *priv = NULL; + client_t *client = NULL; + uint32_t flags = 0; + upcall_local_t *local = NULL; + struct iatt stbuf = { + 0, + }; + int ret = 0; + upcall_private_t *priv = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - priv = this->private; - GF_VALIDATE_OR_GOTO (this->name, priv, out); + priv = this->private; + GF_VALIDATE_OR_GOTO(this->name, priv, out); - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } - flags = UP_XATTR_RM; + if ((op_ret < 0) || !local) { + goto out; + } + flags = UP_XATTR_RM; - ret = up_filter_xattr (local->xattr, priv->xattrs); - if (ret < 0) { - op_ret = ret; - goto out; - } - if (!up_invalidate_needed (local->xattr)) - goto out; + ret = up_filter_xattr(local->xattr, priv->xattrs); + if (ret < 0) { + op_ret = ret; + goto out; + } + if (!up_invalidate_needed(local->xattr)) + goto out; - ret = dict_get_iatt (xdata, GF_POSTSTAT, &stbuf); - if (ret == 0) - flags |= UP_TIMES; + ret = dict_get_iatt(xdata, GF_POSTSTAT, &stbuf); + if (ret == 0) + flags |= UP_TIMES; - upcall_cache_invalidate (frame, this, client, local->inode, flags, - &stbuf, NULL, NULL, local->xattr); + upcall_cache_invalidate(frame, this, client, local->inode, flags, &stbuf, + NULL, NULL, local->xattr); out: - UPCALL_STACK_UNWIND (removexattr, frame, op_ret, op_errno, - xdata); - return 0; + UPCALL_STACK_UNWIND(removexattr, frame, op_ret, op_errno, xdata); + return 0; } - static int32_t -up_removexattr (call_frame_t *frame, xlator_t *this, loc_t *loc, - const char *name, dict_t *xdata) +up_removexattr(call_frame_t *frame, xlator_t *this, loc_t *loc, + const char *name, dict_t *xdata) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; - dict_t *xattr = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; + dict_t *xattr = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - xattr = dict_for_key_value (name, "", 1, _gf_true); - if (!xattr) { - op_errno = ENOMEM; - goto err; - } + xattr = dict_for_key_value(name, "", 1, _gf_true); + if (!xattr) { + op_errno = ENOMEM; + goto err; + } - local = upcall_local_init (frame, this, loc, NULL, loc->inode, xattr); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, loc, NULL, loc->inode, xattr); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - if (xattr) - dict_unref (xattr); + if (xattr) + dict_unref(xattr); - STACK_WIND (frame, up_removexattr_cbk, - FIRST_CHILD(this), FIRST_CHILD(this)->fops->removexattr, - loc, name, xdata); - return 0; + STACK_WIND(frame, up_removexattr_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->removexattr, loc, name, xdata); + return 0; err: - if (xattr) - dict_unref (xattr); + if (xattr) + dict_unref(xattr); - UPCALL_STACK_UNWIND (removexattr, frame, -1, op_errno, NULL); + UPCALL_STACK_UNWIND(removexattr, frame, -1, op_errno, NULL); - return 0; + return 0; } - static int32_t -up_fgetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, dict_t *dict, - dict_t *xdata) +up_fgetxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, dict_t *dict, dict_t *xdata) { - client_t *client = NULL; - uint32_t flags = 0; - upcall_local_t *local = NULL; + client_t *client = NULL; + uint32_t flags = 0; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } + if ((op_ret < 0) || !local) { + goto out; + } - flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, local->inode, flags, - NULL, NULL, NULL, NULL); + flags = UP_UPDATE_CLIENT; + upcall_cache_invalidate(frame, this, client, local->inode, flags, NULL, + NULL, NULL, NULL); out: - UPCALL_STACK_UNWIND (fgetxattr, frame, op_ret, op_errno, - dict, xdata); - return 0; + UPCALL_STACK_UNWIND(fgetxattr, frame, op_ret, op_errno, dict, xdata); + return 0; } - static int32_t -up_fgetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, - const char *name, dict_t *xdata) +up_fgetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd, const char *name, + dict_t *xdata) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, NULL, NULL, fd->inode, NULL); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, NULL, NULL, fd->inode, NULL); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - STACK_WIND (frame, up_fgetxattr_cbk, - FIRST_CHILD(this), FIRST_CHILD(this)->fops->fgetxattr, - fd, name, xdata); - return 0; + STACK_WIND(frame, up_fgetxattr_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->fgetxattr, fd, name, xdata); + return 0; err: - UPCALL_STACK_UNWIND (fgetxattr, frame, -1, op_errno, - NULL, NULL); - return 0; + UPCALL_STACK_UNWIND(fgetxattr, frame, -1, op_errno, NULL, NULL); + return 0; } - static int32_t -up_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, dict_t *dict, - dict_t *xdata) +up_getxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, dict_t *dict, dict_t *xdata) { - client_t *client = NULL; - uint32_t flags = 0; - upcall_local_t *local = NULL; + client_t *client = NULL; + uint32_t flags = 0; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } + if ((op_ret < 0) || !local) { + goto out; + } - flags = UP_UPDATE_CLIENT; - upcall_cache_invalidate (frame, this, client, local->inode, flags, - NULL, NULL, NULL, NULL); + flags = UP_UPDATE_CLIENT; + upcall_cache_invalidate(frame, this, client, local->inode, flags, NULL, + NULL, NULL, NULL); out: - UPCALL_STACK_UNWIND (getxattr, frame, op_ret, op_errno, - dict, xdata); - return 0; + UPCALL_STACK_UNWIND(getxattr, frame, op_ret, op_errno, dict, xdata); + return 0; } static int32_t -up_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, - const char *name, dict_t *xdata) +up_getxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, const char *name, + dict_t *xdata) { - int32_t op_errno = -1; - upcall_local_t *local = NULL; + int32_t op_errno = -1; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - local = upcall_local_init (frame, this, NULL, NULL, loc->inode, NULL); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, NULL, NULL, loc->inode, NULL); + if (!local) { + op_errno = ENOMEM; + goto err; + } out: - STACK_WIND (frame, up_getxattr_cbk, - FIRST_CHILD(this), FIRST_CHILD(this)->fops->getxattr, - loc, name, xdata); - return 0; + STACK_WIND(frame, up_getxattr_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->getxattr, loc, name, xdata); + return 0; err: - UPCALL_STACK_UNWIND (getxattr, frame, -1, op_errno, - NULL, NULL); - return 0; + UPCALL_STACK_UNWIND(getxattr, frame, -1, op_errno, NULL, NULL); + return 0; } - /* The xattrops here mainly tracks changes in afr pending xattr. * 1. xattrop doesn't carry info saying post op/pre op. * 2. Pre xattrop will have 0 value for all pending xattrs, @@ -2128,499 +2048,482 @@ err: * came in postop and postop cbk, if its same then its the first time. */ static int32_t -up_xattrop_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, dict_t *dict, dict_t *xdata) +up_xattrop_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, dict_t *dict, dict_t *xdata) { - client_t *client = NULL; - upcall_local_t *local = NULL; + client_t *client = NULL; + upcall_local_t *local = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - client = frame->root->client; - local = frame->local; + client = frame->root->client; + local = frame->local; - if ((op_ret < 0) || !local) { - goto out; - } + if ((op_ret < 0) || !local) { + goto out; + } - if (up_invalidate_needed (local->xattr)) { - if (dict_foreach (local->xattr, up_compare_afr_xattr, dict) < 0) - goto out; + if (up_invalidate_needed(local->xattr)) { + if (dict_foreach(local->xattr, up_compare_afr_xattr, dict) < 0) + goto out; - upcall_cache_invalidate (frame, this, client, local->inode, - UP_XATTR, NULL, NULL, NULL, - local->xattr); - } + upcall_cache_invalidate(frame, this, client, local->inode, UP_XATTR, + NULL, NULL, NULL, local->xattr); + } out: - if (frame->root->op == GF_FOP_FXATTROP) { - UPCALL_STACK_UNWIND (fxattrop, frame, op_ret, op_errno, dict, - xdata); - } else { - UPCALL_STACK_UNWIND (xattrop, frame, op_ret, op_errno, dict, - xdata); - } - return 0; + if (frame->root->op == GF_FOP_FXATTROP) { + UPCALL_STACK_UNWIND(fxattrop, frame, op_ret, op_errno, dict, xdata); + } else { + UPCALL_STACK_UNWIND(xattrop, frame, op_ret, op_errno, dict, xdata); + } + return 0; } - static int32_t -up_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, - gf_xattrop_flags_t optype, dict_t *xattr, dict_t *xdata) +up_xattrop(call_frame_t *frame, xlator_t *this, loc_t *loc, + gf_xattrop_flags_t optype, dict_t *xattr, dict_t *xdata) { - int32_t op_errno = EINVAL; - upcall_local_t *local = NULL; - int ret = 0; - upcall_private_t *priv = NULL; + int32_t op_errno = EINVAL; + upcall_local_t *local = NULL; + int ret = 0; + upcall_private_t *priv = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - priv = this->private; - GF_VALIDATE_OR_GOTO (this->name, priv, out); + priv = this->private; + GF_VALIDATE_OR_GOTO(this->name, priv, out); - local = upcall_local_init (frame, this, loc, NULL, loc->inode, xattr); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, loc, NULL, loc->inode, xattr); + if (!local) { + op_errno = ENOMEM; + goto err; + } - ret = up_filter_xattr (local->xattr, priv->xattrs); - if (ret < 0) { - goto err; - } + ret = up_filter_xattr(local->xattr, priv->xattrs); + if (ret < 0) { + goto err; + } out: - STACK_WIND (frame, up_xattrop_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->xattrop, loc, optype, xattr, - xdata); - return 0; + STACK_WIND(frame, up_xattrop_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->xattrop, loc, optype, xattr, xdata); + return 0; err: - UPCALL_STACK_UNWIND (xattrop, frame, -1, op_errno, NULL, NULL); - return 0; + UPCALL_STACK_UNWIND(xattrop, frame, -1, op_errno, NULL, NULL); + return 0; } - static int32_t -up_fxattrop (call_frame_t *frame, xlator_t *this, fd_t *fd, - gf_xattrop_flags_t optype, dict_t *xattr, dict_t *xdata) +up_fxattrop(call_frame_t *frame, xlator_t *this, fd_t *fd, + gf_xattrop_flags_t optype, dict_t *xattr, dict_t *xdata) { - int32_t op_errno = EINVAL; - upcall_local_t *local = NULL; - int ret = 0; - upcall_private_t *priv = NULL; + int32_t op_errno = EINVAL; + upcall_local_t *local = NULL; + int ret = 0; + upcall_private_t *priv = NULL; - EXIT_IF_UPCALL_OFF (this, out); + EXIT_IF_UPCALL_OFF(this, out); - priv = this->private; - GF_VALIDATE_OR_GOTO (this->name, priv, out); + priv = this->private; + GF_VALIDATE_OR_GOTO(this->name, priv, out); - local = upcall_local_init (frame, this, NULL, fd, fd->inode, xattr); - if (!local) { - op_errno = ENOMEM; - goto err; - } + local = upcall_local_init(frame, this, NULL, fd, fd->inode, xattr); + if (!local) { + op_errno = ENOMEM; + goto err; + } - ret = up_filter_xattr (local->xattr, priv->xattrs); - if (ret < 0) { - goto err; - } + ret = up_filter_xattr(local->xattr, priv->xattrs); + if (ret < 0) { + goto err; + } out: - STACK_WIND (frame, up_xattrop_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->fxattrop, fd, optype, xattr, - xdata); - return 0; + STACK_WIND(frame, up_xattrop_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->fxattrop, fd, optype, xattr, xdata); + return 0; err: - STACK_UNWIND_STRICT (fxattrop, frame, -1, op_errno, NULL, NULL); - return 0; + STACK_UNWIND_STRICT(fxattrop, frame, -1, op_errno, NULL, NULL); + return 0; } - int32_t -mem_acct_init (xlator_t *this) +mem_acct_init(xlator_t *this) { - int ret = -1; + int ret = -1; - if (!this) - return ret; - - ret = xlator_mem_acct_init (this, gf_upcall_mt_end + 1); + if (!this) + return ret; - if (ret != 0) { - gf_msg ("upcall", GF_LOG_WARNING, 0, - UPCALL_MSG_NO_MEMORY, - "Memory allocation failed"); - return ret; - } + ret = xlator_mem_acct_init(this, gf_upcall_mt_end + 1); + if (ret != 0) { + gf_msg("upcall", GF_LOG_WARNING, 0, UPCALL_MSG_NO_MEMORY, + "Memory allocation failed"); return ret; + } + + return ret; } void -upcall_local_wipe (xlator_t *this, upcall_local_t *local) -{ - if (local) { - inode_unref (local->inode); - if (local->xattr) - dict_unref (local->xattr); - loc_wipe (&local->rename_oldloc); - loc_wipe (&local->loc); - if (local->fd) - fd_unref (local->fd); - mem_put (local); - } +upcall_local_wipe(xlator_t *this, upcall_local_t *local) +{ + if (local) { + inode_unref(local->inode); + if (local->xattr) + dict_unref(local->xattr); + loc_wipe(&local->rename_oldloc); + loc_wipe(&local->loc); + if (local->fd) + fd_unref(local->fd); + mem_put(local); + } } upcall_local_t * -upcall_local_init (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd, - inode_t *inode, dict_t *xattr) +upcall_local_init(call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd, + inode_t *inode, dict_t *xattr) { - upcall_local_t *local = NULL; + upcall_local_t *local = NULL; - GF_VALIDATE_OR_GOTO ("upcall", this, out); - GF_VALIDATE_OR_GOTO (this->name, frame, out); - GF_VALIDATE_OR_GOTO (this->name, inode, out); + GF_VALIDATE_OR_GOTO("upcall", this, out); + GF_VALIDATE_OR_GOTO(this->name, frame, out); + GF_VALIDATE_OR_GOTO(this->name, inode, out); - local = mem_get0 (THIS->local_pool); + local = mem_get0(THIS->local_pool); - if (!local) - goto out; + if (!local) + goto out; - local->inode = inode_ref (inode); - if (xattr) - local->xattr = dict_copy_with_ref (xattr, NULL); + local->inode = inode_ref(inode); + if (xattr) + local->xattr = dict_copy_with_ref(xattr, NULL); - if (loc) - loc_copy (&local->loc, loc); - if (fd) - local->fd = fd_ref (fd); + if (loc) + loc_copy(&local->loc, loc); + if (fd) + local->fd = fd_ref(fd); - frame->local = local; + frame->local = local; out: - return local; + return local; } static int32_t -update_xattrs (dict_t *dict, char *key, data_t *value, void *data) +update_xattrs(dict_t *dict, char *key, data_t *value, void *data) { - dict_t *xattrs = data; - int ret = 0; + dict_t *xattrs = data; + int ret = 0; - ret = dict_set_int8 (xattrs, key, 0); - return ret; + ret = dict_set_int8(xattrs, key, 0); + return ret; } int32_t -up_ipc (call_frame_t *frame, xlator_t *this, int32_t op, dict_t *xdata) +up_ipc(call_frame_t *frame, xlator_t *this, int32_t op, dict_t *xdata) { - upcall_private_t *priv = NULL; - int ret = 0; + upcall_private_t *priv = NULL; + int ret = 0; - priv = this->private; - GF_VALIDATE_OR_GOTO (this->name, priv, out); + priv = this->private; + GF_VALIDATE_OR_GOTO(this->name, priv, out); - if (op != GF_IPC_TARGET_UPCALL) - goto wind; + if (op != GF_IPC_TARGET_UPCALL) + goto wind; - /* TODO: Bz-1371622 Along with the xattrs also store list of clients - * that are interested in notifications, so that the notification - * can be sent to the clients that have registered. - * Once this implemented there can be unregister of xattrs for - * notifications. Until then there is no unregister of xattrs*/ - if (xdata && priv->xattrs) { - ret = dict_foreach (xdata, update_xattrs, priv->xattrs); - } + /* TODO: Bz-1371622 Along with the xattrs also store list of clients + * that are interested in notifications, so that the notification + * can be sent to the clients that have registered. + * Once this implemented there can be unregister of xattrs for + * notifications. Until then there is no unregister of xattrs*/ + if (xdata && priv->xattrs) { + ret = dict_foreach(xdata, update_xattrs, priv->xattrs); + } out: - STACK_UNWIND_STRICT (ipc, frame, ret, 0, NULL); - return 0; + STACK_UNWIND_STRICT(ipc, frame, ret, 0, NULL); + return 0; wind: - STACK_WIND (frame, default_ipc_cbk, FIRST_CHILD (this), - FIRST_CHILD (this)->fops->ipc, op, xdata); - return 0; + STACK_WIND(frame, default_ipc_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->ipc, op, xdata); + return 0; } int -reconfigure (xlator_t *this, dict_t *options) +reconfigure(xlator_t *this, dict_t *options) { - upcall_private_t *priv = NULL; - int ret = -1; + upcall_private_t *priv = NULL; + int ret = -1; - priv = this->private; - GF_VALIDATE_OR_GOTO (this->name, priv, out); + priv = this->private; + GF_VALIDATE_OR_GOTO(this->name, priv, out); - GF_OPTION_RECONF ("cache-invalidation", priv->cache_invalidation_enabled, - options, bool, out); - GF_OPTION_RECONF ("cache-invalidation-timeout", priv->cache_invalidation_timeout, - options, int32, out); + GF_OPTION_RECONF("cache-invalidation", priv->cache_invalidation_enabled, + options, bool, out); + GF_OPTION_RECONF("cache-invalidation-timeout", + priv->cache_invalidation_timeout, options, int32, out); - ret = 0; + ret = 0; - if (priv->cache_invalidation_enabled && - !priv->reaper_init_done) { - ret = upcall_reaper_thread_init (this); + if (priv->cache_invalidation_enabled && !priv->reaper_init_done) { + ret = upcall_reaper_thread_init(this); - if (ret) { - gf_msg ("upcall", GF_LOG_WARNING, 0, - UPCALL_MSG_INTERNAL_ERROR, - "reaper_thread creation failed (%s)." - " Disabling cache_invalidation", - strerror(errno)); - } - priv->reaper_init_done = _gf_true; + if (ret) { + gf_msg("upcall", GF_LOG_WARNING, 0, UPCALL_MSG_INTERNAL_ERROR, + "reaper_thread creation failed (%s)." + " Disabling cache_invalidation", + strerror(errno)); } + priv->reaper_init_done = _gf_true; + } out: - return ret; + return ret; } int -init (xlator_t *this) +init(xlator_t *this) { - int ret = -1; - upcall_private_t *priv = NULL; + int ret = -1; + upcall_private_t *priv = NULL; - priv = GF_CALLOC (1, sizeof (*priv), - gf_upcall_mt_private_t); - if (!priv) - goto out; + priv = GF_CALLOC(1, sizeof(*priv), gf_upcall_mt_private_t); + if (!priv) + goto out; - priv->xattrs = dict_new (); - if (!priv->xattrs) - goto out; + priv->xattrs = dict_new(); + if (!priv->xattrs) + goto out; - GF_OPTION_INIT ("cache-invalidation", priv->cache_invalidation_enabled, - bool, out); - GF_OPTION_INIT ("cache-invalidation-timeout", - priv->cache_invalidation_timeout, int32, out); + GF_OPTION_INIT("cache-invalidation", priv->cache_invalidation_enabled, bool, + out); + GF_OPTION_INIT("cache-invalidation-timeout", + priv->cache_invalidation_timeout, int32, out); - LOCK_INIT (&priv->inode_ctx_lk); - INIT_LIST_HEAD (&priv->inode_ctx_list); + LOCK_INIT(&priv->inode_ctx_lk); + INIT_LIST_HEAD(&priv->inode_ctx_list); - priv->fini = 0; - priv->reaper_init_done = _gf_false; + priv->fini = 0; + priv->reaper_init_done = _gf_false; + + this->private = priv; + this->local_pool = mem_pool_new(upcall_local_t, 512); + ret = 0; + + if (priv->cache_invalidation_enabled) { + ret = upcall_reaper_thread_init(this); - this->private = priv; - this->local_pool = mem_pool_new (upcall_local_t, 512); - ret = 0; - - if (priv->cache_invalidation_enabled) { - ret = upcall_reaper_thread_init (this); - - if (ret) { - gf_msg ("upcall", GF_LOG_WARNING, 0, - UPCALL_MSG_INTERNAL_ERROR, - "reaper_thread creation failed (%s)." - " Disabling cache_invalidation", - strerror(errno)); - } - priv->reaper_init_done = _gf_true; + if (ret) { + gf_msg("upcall", GF_LOG_WARNING, 0, UPCALL_MSG_INTERNAL_ERROR, + "reaper_thread creation failed (%s)." + " Disabling cache_invalidation", + strerror(errno)); } + priv->reaper_init_done = _gf_true; + } out: - if (ret && priv) { - if (priv->xattrs) - dict_unref (priv->xattrs); + if (ret && priv) { + if (priv->xattrs) + dict_unref(priv->xattrs); - GF_FREE (priv); - } + GF_FREE(priv); + } - return ret; + return ret; } int -fini (xlator_t *this) +fini(xlator_t *this) { - upcall_private_t *priv = NULL; + upcall_private_t *priv = NULL; - priv = this->private; - if (!priv) { - return 0; - } - this->private = NULL; + priv = this->private; + if (!priv) { + return 0; + } + this->private = NULL; - priv->fini = 1; + priv->fini = 1; - if (priv->reaper_thr) { - gf_thread_cleanup_xint (priv->reaper_thr); - priv->reaper_thr = 0; - priv->reaper_init_done = _gf_false; - } + if (priv->reaper_thr) { + gf_thread_cleanup_xint(priv->reaper_thr); + priv->reaper_thr = 0; + priv->reaper_init_done = _gf_false; + } - dict_unref (priv->xattrs); - LOCK_DESTROY (&priv->inode_ctx_lk); + dict_unref(priv->xattrs); + LOCK_DESTROY(&priv->inode_ctx_lk); - /* Do we need to cleanup the inode_ctxs? IMO not required - * as inode_forget would have been done on all the inodes - * before calling xlator_fini */ - GF_FREE (priv); + /* Do we need to cleanup the inode_ctxs? IMO not required + * as inode_forget would have been done on all the inodes + * before calling xlator_fini */ + GF_FREE(priv); - if (this->local_pool) { - mem_pool_destroy (this->local_pool); - this->local_pool = NULL; - } + if (this->local_pool) { + mem_pool_destroy(this->local_pool); + this->local_pool = NULL; + } - return 0; + return 0; } int -upcall_forget (xlator_t *this, inode_t *inode) +upcall_forget(xlator_t *this, inode_t *inode) { - upcall_private_t *priv = this->private; + upcall_private_t *priv = this->private; - if (!priv) - goto out; + if (!priv) + goto out; - upcall_cleanup_inode_ctx (this, inode); + upcall_cleanup_inode_ctx(this, inode); out: - return 0; + return 0; } int -upcall_release (xlator_t *this, fd_t *fd) +upcall_release(xlator_t *this, fd_t *fd) { - return 0; + return 0; } int -notify (xlator_t *this, int32_t event, void *data, ...) +notify(xlator_t *this, int32_t event, void *data, ...) { - int ret = -1; - struct gf_upcall *up_req = NULL; + int ret = -1; + struct gf_upcall *up_req = NULL; - switch (event) { - case GF_EVENT_UPCALL: - { - gf_log (this->name, GF_LOG_DEBUG, "Upcall Notify event = %d", - event); + switch (event) { + case GF_EVENT_UPCALL: { + gf_log(this->name, GF_LOG_DEBUG, "Upcall Notify event = %d", event); - up_req = (struct gf_upcall *) data; + up_req = (struct gf_upcall *)data; - GF_VALIDATE_OR_GOTO(this->name, up_req, out); + GF_VALIDATE_OR_GOTO(this->name, up_req, out); - ret = default_notify (this, event, up_req); + ret = default_notify(this, event, up_req); - if (ret) { - gf_msg (this->name, GF_LOG_WARNING, 0, - UPCALL_MSG_NOTIFY_FAILED, - "Failed to notify cache invalidation" - " to client(%s)", - up_req->client_uid); - goto out; - } - } - break; + if (ret) { + gf_msg(this->name, GF_LOG_WARNING, 0, UPCALL_MSG_NOTIFY_FAILED, + "Failed to notify cache invalidation" + " to client(%s)", + up_req->client_uid); + goto out; + } + } break; default: - default_notify (this, event, data); - break; - } - ret = 0; + default_notify(this, event, data); + break; + } + ret = 0; out: - return ret; + return ret; } struct xlator_fops fops = { - .ipc = up_ipc, - /* fops which change only "ATIME" do not result - * in any cache invalidation. Hence upcall - * notifications are not sent in this case. - * But however, we need to store/update the - * client info in the upcall state to be able - * to notify them in case of any changes done - * to the data. - * - * Below such fops do not trigger upcall - * notifications but will add/update - * clients info in the upcall inode ctx.*/ - .lookup = up_lookup, - .open = up_open, - .statfs = up_statfs, - .opendir = up_opendir, - .readdir = up_readdir, - .readdirp = up_readdirp, - .stat = up_stat, - .fstat = up_fstat, - .access = up_access, - .readlink = up_readlink, - .readv = up_readv, - .lk = up_lk, - .seek = up_seek, - - /* fops doing write */ - .truncate = up_truncate, - .ftruncate = up_ftruncate, - .writev = up_writev, - .zerofill = up_zerofill, - .fallocate = up_fallocate, - .discard = up_discard, - - /* fops changing attributes */ - .fsetattr = up_fsetattr, - .setattr = up_setattr, - - /* fops affecting parent dirent */ - .mknod = up_mknod, - .create = up_create, - .symlink = up_symlink, - .mkdir = up_mkdir, - - /* fops affecting both file and parent - * cache entries */ - .unlink = up_unlink, - .link = up_link, - .rmdir = up_rmdir, - .rename = up_rename, - - .setxattr = up_setxattr, - .fsetxattr = up_fsetxattr, - .getxattr = up_getxattr, - .fgetxattr = up_fgetxattr, - .fremovexattr = up_fremovexattr, - .removexattr = up_removexattr, - .xattrop = up_xattrop, - .fxattrop = up_fxattrop, + .ipc = up_ipc, + /* fops which change only "ATIME" do not result + * in any cache invalidation. Hence upcall + * notifications are not sent in this case. + * But however, we need to store/update the + * client info in the upcall state to be able + * to notify them in case of any changes done + * to the data. + * + * Below such fops do not trigger upcall + * notifications but will add/update + * clients info in the upcall inode ctx.*/ + .lookup = up_lookup, + .open = up_open, + .statfs = up_statfs, + .opendir = up_opendir, + .readdir = up_readdir, + .readdirp = up_readdirp, + .stat = up_stat, + .fstat = up_fstat, + .access = up_access, + .readlink = up_readlink, + .readv = up_readv, + .lk = up_lk, + .seek = up_seek, + + /* fops doing write */ + .truncate = up_truncate, + .ftruncate = up_ftruncate, + .writev = up_writev, + .zerofill = up_zerofill, + .fallocate = up_fallocate, + .discard = up_discard, + + /* fops changing attributes */ + .fsetattr = up_fsetattr, + .setattr = up_setattr, + + /* fops affecting parent dirent */ + .mknod = up_mknod, + .create = up_create, + .symlink = up_symlink, + .mkdir = up_mkdir, + + /* fops affecting both file and parent + * cache entries */ + .unlink = up_unlink, + .link = up_link, + .rmdir = up_rmdir, + .rename = up_rename, + + .setxattr = up_setxattr, + .fsetxattr = up_fsetxattr, + .getxattr = up_getxattr, + .fgetxattr = up_fgetxattr, + .fremovexattr = up_fremovexattr, + .removexattr = up_removexattr, + .xattrop = up_xattrop, + .fxattrop = up_fxattrop, #ifdef NOT_SUPPORTED - /* internal lk fops */ - .inodelk = up_inodelk, - .finodelk = up_finodelk, - .entrylk = up_entrylk, - .fentrylk = up_fentrylk, - - /* Below fops follow 'WRITE' which - * would have already sent upcall - * notifications */ - .flush = up_flush, - .fsync = up_fsync, - .fsyncdir = up_fsyncdir, + /* internal lk fops */ + .inodelk = up_inodelk, + .finodelk = up_finodelk, + .entrylk = up_entrylk, + .fentrylk = up_fentrylk, + + /* Below fops follow 'WRITE' which + * would have already sent upcall + * notifications */ + .flush = up_flush, + .fsync = up_fsync, + .fsyncdir = up_fsyncdir, #endif }; struct xlator_cbks cbks = { - .forget = upcall_forget, - .release = upcall_release, + .forget = upcall_forget, + .release = upcall_release, }; struct volume_options options[] = { - { .key = {"cache-invalidation"}, - .type = GF_OPTION_TYPE_BOOL, - .default_value = "off", - .description = "When \"on\", sends cache-invalidation" - " notifications.", - .op_version = {GD_OP_VERSION_3_7_0}, - .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC, - .tags = {"cache", "cacheconsistency", "upcall"}, - }, - { .key = {"cache-invalidation-timeout"}, - .type = GF_OPTION_TYPE_INT, - .default_value = CACHE_INVALIDATION_TIMEOUT, - .description = "After 'timeout' seconds since the time" - " client accessed any file, cache-invalidation" - " notifications are no longer sent to that client.", - .op_version = {GD_OP_VERSION_3_7_0}, - .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC, - .tags = {"cache", "cachetimeout", "upcall"} - }, - { .key = {NULL} }, + { + .key = {"cache-invalidation"}, + .type = GF_OPTION_TYPE_BOOL, + .default_value = "off", + .description = "When \"on\", sends cache-invalidation" + " notifications.", + .op_version = {GD_OP_VERSION_3_7_0}, + .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC, + .tags = {"cache", "cacheconsistency", "upcall"}, + }, + {.key = {"cache-invalidation-timeout"}, + .type = GF_OPTION_TYPE_INT, + .default_value = CACHE_INVALIDATION_TIMEOUT, + .description = "After 'timeout' seconds since the time" + " client accessed any file, cache-invalidation" + " notifications are no longer sent to that client.", + .op_version = {GD_OP_VERSION_3_7_0}, + .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC, + .tags = {"cache", "cachetimeout", "upcall"}}, + {.key = {NULL}}, }; |