From 2475e0193c4b4a37028bd8168113d6cd6949fe0e Mon Sep 17 00:00:00 2001 From: Anand Avati Date: Thu, 12 Jul 2012 15:37:38 -0700 Subject: gfapi: API/library for accessing gluster volumes Change-Id: Ie4cbcf91b58218bebf23cf951c313aceeb29f311 BUG: 839950 Signed-off-by: Anand Avati Reviewed-on: http://review.gluster.com/3664 Tested-by: Gluster Build System Reviewed-by: Jeff Darcy Reviewed-by: Kaleb KEITHLEY Reviewed-by: Bharata B Rao --- api/src/glfs-master.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 api/src/glfs-master.c (limited to 'api/src/glfs-master.c') diff --git a/api/src/glfs-master.c b/api/src/glfs-master.c new file mode 100644 index 000000000..0806c3077 --- /dev/null +++ b/api/src/glfs-master.c @@ -0,0 +1,113 @@ +/* + Copyright (c) 2012 Red Hat, Inc. + This file is part of GlusterFS. + + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. +*/ + +#include +#include +#include +#include +#include +#include + +#ifndef _CONFIG_H +#define _CONFIG_H +#include "config.h" +#endif + +#include "xlator.h" +#include "glusterfs.h" +#include "glfs-internal.h" + + +int +glfs_graph_setup (struct glfs *fs, glusterfs_graph_t *graph) +{ + if (fs->active_subvol == graph->top) + return 0; + + pthread_mutex_lock (&fs->mutex); + { + fs->active_subvol = graph->top; + pthread_cond_broadcast (&fs->cond); + } + pthread_mutex_unlock (&fs->mutex); + + gf_log ("glfs-master", GF_LOG_INFO, "switched to graph %s (%d)", + uuid_utoa ((unsigned char *)graph->graph_uuid), graph->id); + + return 0; +} + + +int +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_log (this->name, GF_LOG_INFO, "New graph %s (%d) coming up", + uuid_utoa ((unsigned char *)graph->graph_uuid), + graph->id); + break; + case GF_EVENT_CHILD_UP: + glfs_graph_setup (fs, graph); + glfs_init_done (fs, 0); + break; + case GF_EVENT_CHILD_DOWN: + glfs_graph_setup (fs, graph); + glfs_init_done (fs, 1); + break; + case GF_EVENT_CHILD_CONNECTING: + break; + default: + gf_log (this->name, GF_LOG_DEBUG, + "got notify event %d", event); + break; + } + + return 0; +} + + +int +mem_acct_init (xlator_t *this) +{ + return 0; +} + + +int +init (xlator_t *this) +{ + return 0; +} + + +void +fini (xlator_t *this) +{ + +} + + +struct xlator_dumpops dumpops = { +}; + + +struct xlator_fops fops = { +}; + + +struct xlator_cbks cbks = { +}; -- cgit