From c7ba4f37b048399481e14167a9a649f13a365cf0 Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Mon, 9 Dec 2013 16:10:56 +0530 Subject: mount/fuse: cleanup old graphs. After a graph switch, a PARENT_DOWN event from fuse indicates protocol/client to shutdown all its sockets. However, this event will be sent only when the first fop is received from fuse mount after graph switch. Also, this event is sent only on previously active graph. So, if there are multiple graph switches when there is no activity on mountpoint, we'll be left with a list of graphs with their sockets still open. This patch fixes the issue by sending PARENT_DOWN to previously non-active graph when a new graph is available irrespective of whether there is an activity on mount-point. Change-Id: I9e676658d797c0b2dd3ed5ca5a56271bd94b4bb6 BUG: 924726 Signed-off-by: Raghavendra G Reviewed-on: http://review.gluster.org/4713 Tested-by: Gluster Build System Reviewed-by: Anand Avati Reviewed-on: http://review.gluster.org/6813 Reviewed-by: Vijay Bellur --- xlators/mount/fuse/src/fuse-bridge.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'xlators/mount/fuse/src/fuse-bridge.c') diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index 5e6c7936f..abdecbf48 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -4894,9 +4894,10 @@ dump_history_fuse (circular_buffer_t *cb, void *data) int fuse_graph_setup (xlator_t *this, glusterfs_graph_t *graph) { - inode_table_t *itable = NULL; - int ret = 0; - fuse_private_t *priv = NULL; + inode_table_t *itable = NULL; + int ret = 0, winds = 0; + fuse_private_t *priv = NULL; + glusterfs_graph_t *prev_graph = NULL; priv = this->private; @@ -4917,13 +4918,30 @@ fuse_graph_setup (xlator_t *this, glusterfs_graph_t *graph) pthread_mutex_lock (&priv->sync_mutex); { - priv->next_graph = graph; - priv->event_recvd = 0; + prev_graph = priv->next_graph; + + if ((prev_graph != NULL) && (prev_graph->id > graph->id)) { + /* there was a race and an old graph was initialised + * before new one. + */ + prev_graph = graph; + } else { + priv->next_graph = graph; + priv->event_recvd = 0; - pthread_cond_signal (&priv->sync_cond); + pthread_cond_signal (&priv->sync_cond); + } + + if (prev_graph != NULL) + winds = ((xlator_t *)prev_graph->top)->winds; } pthread_mutex_unlock (&priv->sync_mutex); + if ((prev_graph != NULL) && (winds == 0)) { + xlator_notify (prev_graph->top, GF_EVENT_PARENT_DOWN, + prev_graph->top, NULL); + } + gf_log ("fuse", GF_LOG_INFO, "switched to graph %d", ((graph) ? graph->id : 0)); -- cgit