From 09af313fe6b49b03501939dd9e46b783ca4b5416 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Thu, 4 Dec 2014 15:40:52 +0100 Subject: fuse: protect checking/modifying graph->used with a mutex While reviewing http://review.gluster.org/#/c/9060/ we noticed that fuse checks/modifies graph->used in a unlocked way. There is a potential race in case when fuse_graph_setup() gets called from two different threads (currently unlikely, but poller/notify() might change in future?). In libgfapi we came to the conclusion that each glfs structure can be used to protect the checking/updating of graph->used. In fuse this would be the fuse_private_t with sync_mutex. BUG: 1170643 Change-Id: If5ab5468d22fdb92cfb24a469f538f63f12baf78 Signed-off-by: Niels de Vos Reviewed-on: http://review.gluster.org/9237 Tested-by: Gluster Build System Reviewed-by: Raghavendra G --- xlators/mount/fuse/src/fuse-bridge.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'xlators/mount') diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index 1404b148bd5..e61671829e1 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -5032,10 +5032,16 @@ fuse_graph_setup (xlator_t *this, glusterfs_graph_t *graph) if (priv->active_subvol == graph->top) return 0; /* This is a valid case */ - if (graph->used) - return 0; + pthread_mutex_lock (&priv->sync_mutex); + { + if (graph->used) { + pthread_mutex_unlock (&priv->sync_mutex); + return 0; + } - graph->used = 1; + graph->used = 1; + } + pthread_mutex_unlock (&priv->sync_mutex); itable = inode_table_new (0, graph->top); if (!itable) -- cgit