From 1a5e8638a177ac90177ae1b749b89c984930c875 Mon Sep 17 00:00:00 2001 From: Anand Avati Date: Tue, 21 May 2013 16:27:09 -0700 Subject: 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 Reviewed-on: http://review.gluster.org/5059 Tested-by: Gluster Build System Reviewed-by: Raghavendra G --- api/src/glfs-master.c | 45 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) (limited to 'api/src/glfs-master.c') 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; } -- cgit