summaryrefslogtreecommitdiffstats
path: root/api/src/glfs-master.c
diff options
context:
space:
mode:
Diffstat (limited to 'api/src/glfs-master.c')
-rw-r--r--api/src/glfs-master.c67
1 files changed, 54 insertions, 13 deletions
diff --git a/api/src/glfs-master.c b/api/src/glfs-master.c
index 0806c3077..c02534c18 100644
--- a/api/src/glfs-master.c
+++ b/api/src/glfs-master.c
@@ -22,26 +22,58 @@
#include "xlator.h"
#include "glusterfs.h"
+
#include "glfs-internal.h"
+#include "glfs-mem-types.h"
int
glfs_graph_setup (struct glfs *fs, glusterfs_graph_t *graph)
{
- if (fs->active_subvol == graph->top)
- return 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);
{
- fs->active_subvol = graph->top;
- pthread_cond_broadcast (&fs->cond);
+ if (new_subvol->switched ||
+ new_subvol == fs->active_subvol ||
+ new_subvol == fs->next_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);
- gf_log ("glfs-master", GF_LOG_INFO, "switched to graph %s (%d)",
- uuid_utoa ((unsigned char *)graph->graph_uuid), graph->id);
+ if (old_subvol)
+ /* wasn't picked up so far, skip */
+ glfs_subvol_done (fs, old_subvol);
- return 0;
+ return ret;
}
@@ -83,6 +115,18 @@ notify (xlator_t *this, int event, void *data, ...)
int
mem_acct_init (xlator_t *this)
{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, glfs_mt_end + 1);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "Failed to initialise "
+ "memory accounting");
+ return ret;
+ }
+
return 0;
}
@@ -101,13 +145,10 @@ fini (xlator_t *this)
}
-struct xlator_dumpops dumpops = {
-};
+struct xlator_dumpops dumpops;
-struct xlator_fops fops = {
-};
+struct xlator_fops fops;
-struct xlator_cbks cbks = {
-};
+struct xlator_cbks cbks;