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 /api/src/glfs-master.c | |
parent | 45a71c0548b6fd2c757aa2e7b7671a1411948894 (diff) |
Land part 2 of clang-format changes
Change-Id: Ia84cc24c8924e6d22d02ac15f611c10e26db99b4
Signed-off-by: Nigel Babu <nigelb@redhat.com>
Diffstat (limited to 'api/src/glfs-master.c')
-rw-r--r-- | api/src/glfs-master.c | 225 |
1 files changed, 106 insertions, 119 deletions
diff --git a/api/src/glfs-master.c b/api/src/glfs-master.c index 9648bbbc03a..969095a8224 100644 --- a/api/src/glfs-master.c +++ b/api/src/glfs-master.c @@ -22,166 +22,153 @@ #include "glfs-mem-types.h" #include "gfapi-messages.h" - int -graph_setup (struct glfs *fs, glusterfs_graph_t *graph) +graph_setup(struct glfs *fs, glusterfs_graph_t *graph) { - xlator_t *new_subvol = NULL; - xlator_t *old_subvol = NULL; - inode_table_t *itable = NULL; - int ret = -1; - - new_subvol = graph->top; - - /* This is called in a bottom-up context, it should specifically - NOT be glfs_lock() - */ - pthread_mutex_lock (&fs->mutex); - { - if (new_subvol->switched || - new_subvol == fs->active_subvol || - new_subvol == fs->next_subvol || - new_subvol == fs->mip_subvol) { - /* Spurious CHILD_UP event on old graph */ - ret = 0; - goto unlock; - } - - if (!new_subvol->itable) { - itable = inode_table_new (131072, new_subvol); - if (!itable) { - errno = ENOMEM; - ret = -1; - goto unlock; - } - - new_subvol->itable = itable; - } - - old_subvol = fs->next_subvol; - fs->next_subvol = new_subvol; - fs->next_subvol->winds++; /* first ref */ - ret = 0; - } + xlator_t *new_subvol = NULL; + xlator_t *old_subvol = NULL; + inode_table_t *itable = NULL; + int ret = -1; + + new_subvol = graph->top; + + /* This is called in a bottom-up context, it should specifically + NOT be glfs_lock() + */ + pthread_mutex_lock(&fs->mutex); + { + if (new_subvol->switched || new_subvol == fs->active_subvol || + new_subvol == fs->next_subvol || new_subvol == fs->mip_subvol) { + /* Spurious CHILD_UP event on old graph */ + ret = 0; + goto unlock; + } + + if (!new_subvol->itable) { + itable = inode_table_new(131072, new_subvol); + if (!itable) { + errno = ENOMEM; + ret = -1; + goto unlock; + } + + new_subvol->itable = itable; + } + + old_subvol = fs->next_subvol; + fs->next_subvol = new_subvol; + fs->next_subvol->winds++; /* first ref */ + ret = 0; + } unlock: - pthread_mutex_unlock (&fs->mutex); + pthread_mutex_unlock(&fs->mutex); - if (old_subvol) - /* wasn't picked up so far, skip */ - glfs_subvol_done (fs, old_subvol); + if (old_subvol) + /* wasn't picked up so far, skip */ + glfs_subvol_done(fs, old_subvol); - return ret; + return ret; } - int -notify (xlator_t *this, int event, void *data, ...) +notify(xlator_t *this, int event, void *data, ...) { - glusterfs_graph_t *graph = NULL; - struct glfs *fs = NULL; - - graph = data; - fs = this->private; - - switch (event) { - case GF_EVENT_GRAPH_NEW: - gf_msg (this->name, GF_LOG_INFO, 0, API_MSG_NEW_GRAPH, - "New graph %s (%d) coming up", - uuid_utoa ((unsigned char *)graph->graph_uuid), - graph->id); - break; - case GF_EVENT_CHILD_UP: - pthread_mutex_lock (&fs->mutex); - { - graph->used = 1; - } - pthread_mutex_unlock (&fs->mutex); - graph_setup (fs, graph); - glfs_init_done (fs, 0); - break; - case GF_EVENT_CHILD_DOWN: - pthread_mutex_lock (&fs->mutex); - { - graph->used = 0; - pthread_cond_broadcast (&fs->child_down_cond); - } - pthread_mutex_unlock (&fs->mutex); - glfs_init_done (fs, 1); - break; - case GF_EVENT_CHILD_CONNECTING: - break; + glusterfs_graph_t *graph = NULL; + struct glfs *fs = NULL; + + graph = data; + fs = this->private; + + switch (event) { + case GF_EVENT_GRAPH_NEW: + gf_msg(this->name, GF_LOG_INFO, 0, API_MSG_NEW_GRAPH, + "New graph %s (%d) coming up", + uuid_utoa((unsigned char *)graph->graph_uuid), graph->id); + break; + case GF_EVENT_CHILD_UP: + pthread_mutex_lock(&fs->mutex); + { + graph->used = 1; + } + pthread_mutex_unlock(&fs->mutex); + graph_setup(fs, graph); + glfs_init_done(fs, 0); + break; + case GF_EVENT_CHILD_DOWN: + pthread_mutex_lock(&fs->mutex); + { + graph->used = 0; + pthread_cond_broadcast(&fs->child_down_cond); + } + pthread_mutex_unlock(&fs->mutex); + glfs_init_done(fs, 1); + break; + case GF_EVENT_CHILD_CONNECTING: + break; case GF_EVENT_UPCALL: - glfs_process_upcall_event (fs, data); - break; - default: - gf_msg_debug (this->name, 0, "got notify event %d", event); - break; - } - - return 0; + glfs_process_upcall_event(fs, data); + break; + default: + gf_msg_debug(this->name, 0, "got notify event %d", event); + break; + } + + return 0; } - int -mem_acct_init (xlator_t *this) +mem_acct_init(xlator_t *this) { - int ret = -1; + int ret = -1; - if (!this) - return ret; + if (!this) + return ret; - ret = xlator_mem_acct_init (this, glfs_mt_end + 1); - if (ret) { - gf_msg (this->name, GF_LOG_ERROR, ENOMEM, - API_MSG_MEM_ACCT_INIT_FAILED, "Failed to initialise " - "memory accounting"); - return ret; - } + ret = xlator_mem_acct_init(this, glfs_mt_end + 1); + if (ret) { + gf_msg(this->name, GF_LOG_ERROR, ENOMEM, API_MSG_MEM_ACCT_INIT_FAILED, + "Failed to initialise " + "memory accounting"); + return ret; + } - return 0; + return 0; } - int -init (xlator_t *this) +init(xlator_t *this) { - return 0; + return 0; } - void -fini (xlator_t *this) +fini(xlator_t *this) { - } /* place-holder fops */ int -glfs_forget (xlator_t *this, inode_t *inode) +glfs_forget(xlator_t *this, inode_t *inode) { - return 0; + return 0; } int -glfs_release (xlator_t *this, fd_t *fd) +glfs_release(xlator_t *this, fd_t *fd) { - return 0; + return 0; } int -glfs_releasedir (xlator_t *this, fd_t *fd) +glfs_releasedir(xlator_t *this, fd_t *fd) { - return 0; + return 0; } struct xlator_dumpops dumpops; - struct xlator_fops fops; - -struct xlator_cbks cbks = { - .forget = glfs_forget, - .release = glfs_release, - .releasedir = glfs_releasedir -}; +struct xlator_cbks cbks = {.forget = glfs_forget, + .release = glfs_release, + .releasedir = glfs_releasedir}; |