From 82130d7ef5e4e4842dba44f0283336d98035a590 Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Wed, 10 Jun 2009 06:59:34 +0000 Subject: libglusterfsclient: make glusterfs_umount thread safe Signed-off-by: Anand V. Avati --- libglusterfsclient/src/libglusterfsclient.c | 60 ++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 18 deletions(-) (limited to 'libglusterfsclient') diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c index ddfc8b4d27a..26d9a5234dc 100755 --- a/libglusterfsclient/src/libglusterfsclient.c +++ b/libglusterfsclient/src/libglusterfsclient.c @@ -1418,39 +1418,64 @@ out: return ret; } -int -glusterfs_umount (char *vmp) -{ +inline int +_libgf_umount (char *vmp) +{ struct vmp_entry *entry= NULL; - int ret = -1; - char *vmp_resolved = NULL; - - GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, vmp, out); - - vmp_resolved = libgf_resolve_path_light (vmp); - if (!vmp_resolved) - goto out; + int ret = -1; - entry = libgf_vmp_search_entry (vmp_resolved); + entry = _libgf_vmp_search_entry (vmp); if (entry == NULL) { gf_log ("libglusterfsclient", GF_LOG_ERROR, - "path (%s) not mounted", vmp_resolved); + "path (%s) not mounted", vmp); goto out; } - /* FIXME: make this thread safe */ - list_del_init (&entry->list); - if (entry->handle == NULL) { gf_log ("libglusterfsclient", GF_LOG_ERROR, "path (%s) has no corresponding glusterfs handle", - vmp_resolved); + vmp); goto out; } ret = glusterfs_fini (entry->handle); libgf_free_vmp_entry (entry); + list_del_init (&entry->list); + vmplist.entries--; + +out: + return ret; +} + +inline int +libgf_umount (char *vmp) +{ + int ret = -1; + + pthread_mutex_lock (&lock); + { + ret = _libgf_umount (vmp); + } + pthread_mutex_unlock (&lock); + + return ret; +} + +int +glusterfs_umount (char *vmp) +{ + int ret = -1; + char *vmp_resolved = NULL; + + GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, vmp, out); + + vmp_resolved = libgf_resolve_path_light (vmp); + if (!vmp_resolved) + goto out; + + ret = libgf_umount (vmp_resolved); + out: if (vmp_resolved) FREE (vmp_resolved); @@ -1464,7 +1489,6 @@ glusterfs_reset (void) first_fini = first_init = 1; } - void glusterfs_log_lock (void) { -- cgit