summaryrefslogtreecommitdiffstats
path: root/api/src/glfs-master.c
diff options
context:
space:
mode:
authorAnand Avati <avati@redhat.com>2013-05-21 16:27:09 -0700
committerAnand Avati <avati@redhat.com>2013-05-28 00:08:57 -0700
commit1a5e8638a177ac90177ae1b749b89c984930c875 (patch)
treef2951d593682d497c1c61303be3a44456e4810af /api/src/glfs-master.c
parentcb50f94f4299856046e1f1677ad1c8152de06136 (diff)
gfapi: handle graph switch (cwd, fds, locks)
- Migrate open fds to new graph - Migrate locks held in open fd to new fd - Refresh CWD, so resolution of relative paths happens on refreshed inode (on new graph). Change-Id: I4b18083b9b290107ebda1f917fc85b635ab72fb4 BUG: 953694 Signed-off-by: Anand Avati <avati@redhat.com> Reviewed-on: http://review.gluster.org/5059 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Raghavendra G <raghavendra@gluster.com>
Diffstat (limited to 'api/src/glfs-master.c')
-rw-r--r--api/src/glfs-master.c45
1 files changed, 38 insertions, 7 deletions
diff --git a/api/src/glfs-master.c b/api/src/glfs-master.c
index e6c46e361..09a92b7f0 100644
--- a/api/src/glfs-master.c
+++ b/api/src/glfs-master.c
@@ -22,26 +22,57 @@
#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;
+ 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;
}