[PVFS2-CVS]
commit by pcarns in pvfs2/src/io/trove/trove-handle-mgmt:
trove-extentlist.c trove-handle-mgmt.c
CVS commit program
cvs at parl.clemson.edu
Sun Oct 3 11:43:29 EDT 2004
Update of /projects/cvsroot/pvfs2/src/io/trove/trove-handle-mgmt
In directory parlweb:/tmp/cvs-serv689/src/io/trove/trove-handle-mgmt
Modified Files:
trove-extentlist.c trove-handle-mgmt.c
Log Message:
introduce a mutex lock to serialize all trove-handle-mgmt calls
- simultaneous statfs and remove calls to a server could previously cause
segfaults in the avl traversal when trying to count the number of free
handles for statfs
- req scheduler cannot protect against this
Index: trove-extentlist.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/io/trove/trove-handle-mgmt/trove-extentlist.c,v
diff -p -u -r1.28 -r1.29
--- trove-extentlist.c 28 Jul 2004 14:32:52 -0000 1.28
+++ trove-extentlist.c 3 Oct 2004 14:43:28 -0000 1.29
@@ -470,10 +470,10 @@ void extentlist_show(struct TROVE_handle
void extentlist_count(
struct TROVE_handle_extentlist *elist, uint64_t *count)
{
- /* NOTE: this function is not thread safe at all- we count on the
- * fact that the request scheduler will prevent multiple
- * concurrent callers
+ /* NOTE: this function is not thread safe at all- we count
+ * on the trove-handle-mgmt layer to serialize calls.
*/
+
g_counter = 0;
avldepthfirst(elist->index, extent_count, 0 , 0);
*count = g_counter;
Index: trove-handle-mgmt.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/io/trove/trove-handle-mgmt/trove-handle-mgmt.c,v
diff -p -u -r1.38 -r1.39
--- trove-handle-mgmt.c 28 Jul 2004 14:32:52 -0000 1.38
+++ trove-handle-mgmt.c 3 Oct 2004 14:43:28 -0000 1.39
@@ -18,6 +18,7 @@
#include "trove-ledger.h"
#include "trove-handle-mgmt.h"
#include "gossip.h"
+#include "gen-locks.h"
/*
this is an internal structure and shouldn't be used
@@ -39,6 +40,8 @@ static struct qhash_table *s_fsid_to_led
static int hash_fsid(void *fsid, int table_size);
static int hash_fsid_compare(void *key, struct qlist_head *link);
+static gen_mutex_t trove_handle_mutex = GEN_MUTEX_INITIALIZER;
+
/* trove_check_handle_ranges:
* internal function to verify that handles
* on disk match our assigned handles.
@@ -249,6 +252,7 @@ int trove_handle_mgmt_initialize()
unless the hash table initialization really fails.
*/
int ret = 0;
+ gen_mutex_lock(&trove_handle_mutex);
if (s_fsid_to_ledger_table == NULL)
{
@@ -256,6 +260,7 @@ int trove_handle_mgmt_initialize()
hash_fsid,67);
ret = (s_fsid_to_ledger_table ? 0 : -1);
}
+ gen_mutex_unlock(&trove_handle_mutex);
return ret;
}
@@ -267,6 +272,7 @@ int trove_set_handle_ranges(TROVE_coll_i
PINT_llist *extent_list = NULL;
handle_ledger_t *ledger = NULL;
+ gen_mutex_lock(&trove_handle_mutex);
if (handle_range_str)
{
extent_list = PINT_create_extent_list(handle_range_str);
@@ -287,6 +293,7 @@ int trove_set_handle_ranges(TROVE_coll_i
extent_list, ledger->ledger);
if (ret != 0)
{
+ gen_mutex_unlock(&trove_handle_mutex);
return ret;
}
@@ -294,6 +301,7 @@ int trove_set_handle_ranges(TROVE_coll_i
coll_id,context_id,extent_list,ledger->ledger);
if (ret != 0)
{
+ gen_mutex_unlock(&trove_handle_mutex);
return ret;
}
else
@@ -304,6 +312,7 @@ int trove_set_handle_ranges(TROVE_coll_i
PINT_release_extent_list(extent_list);
}
}
+ gen_mutex_unlock(&trove_handle_mutex);
return ret;
}
@@ -319,6 +328,7 @@ int trove_set_handle_timeout(TROVE_coll_
int ret = -1;
handle_ledger_t *ledger = NULL;
+ gen_mutex_lock(&trove_handle_mutex);
ledger = get_or_add_handle_ledger(coll_id);
if (ledger)
{
@@ -338,6 +348,7 @@ int trove_set_handle_timeout(TROVE_coll_
"timeout to %d seconds (ret=%d)\n",
(int)timeout->tv_sec, ret);
}
+ gen_mutex_unlock(&trove_handle_mutex);
return ret;
}
@@ -347,6 +358,7 @@ TROVE_handle trove_handle_alloc(TROVE_co
struct qlist_head *hash_link = NULL;
TROVE_handle handle = TROVE_HANDLE_NULL;
+ gen_mutex_lock(&trove_handle_mutex);
hash_link = qhash_search(s_fsid_to_ledger_table,&(coll_id));
if (hash_link)
{
@@ -356,6 +368,7 @@ TROVE_handle trove_handle_alloc(TROVE_co
handle = trove_ledger_handle_alloc(ledger->ledger);
}
}
+ gen_mutex_unlock(&trove_handle_mutex);
return handle;
}
@@ -368,6 +381,7 @@ TROVE_handle trove_handle_alloc_from_ran
TROVE_handle handle = TROVE_HANDLE_NULL;
int i = 0;
+ gen_mutex_lock(&trove_handle_mutex);
hash_link = qhash_search(s_fsid_to_ledger_table, &(coll_id));
if (hash_link)
{
@@ -385,6 +399,7 @@ TROVE_handle trove_handle_alloc_from_ran
}
}
}
+ gen_mutex_unlock(&trove_handle_mutex);
return handle;
}
@@ -403,6 +418,7 @@ int trove_handle_peek(
return ret;
}
+ gen_mutex_lock(&trove_handle_mutex);
hash_link = qhash_search(s_fsid_to_ledger_table,&(coll_id));
if (hash_link)
{
@@ -414,6 +430,7 @@ int trove_handle_peek(
max_num_handles, returned_handle_count);
}
}
+ gen_mutex_unlock(&trove_handle_mutex);
return ret;
}
@@ -433,6 +450,7 @@ int trove_handle_peek_from_range(
return ret;
}
+ gen_mutex_lock(&trove_handle_mutex);
hash_link = qhash_search(s_fsid_to_ledger_table,&(coll_id));
if (hash_link)
{
@@ -457,6 +475,7 @@ int trove_handle_peek_from_range(
}
}
}
+ gen_mutex_unlock(&trove_handle_mutex);
return ret;
}
@@ -466,6 +485,7 @@ int trove_handle_set_used(TROVE_coll_id
handle_ledger_t *ledger = NULL;
struct qlist_head *hash_link = NULL;
+ gen_mutex_lock(&trove_handle_mutex);
hash_link = qhash_search(s_fsid_to_ledger_table,&(coll_id));
if (hash_link)
{
@@ -475,6 +495,7 @@ int trove_handle_set_used(TROVE_coll_id
ret = trove_handle_remove(ledger->ledger,handle);
}
}
+ gen_mutex_unlock(&trove_handle_mutex);
return ret;
}
@@ -484,6 +505,7 @@ int trove_handle_free(TROVE_coll_id coll
handle_ledger_t *ledger = NULL;
struct qlist_head *hash_link = NULL;
+ gen_mutex_lock(&trove_handle_mutex);
hash_link = qhash_search(s_fsid_to_ledger_table,&(coll_id));
if (hash_link)
{
@@ -493,6 +515,7 @@ int trove_handle_free(TROVE_coll_id coll
ret = trove_ledger_handle_free(ledger->ledger, handle);
}
}
+ gen_mutex_unlock(&trove_handle_mutex);
return ret;
}
@@ -508,6 +531,7 @@ int trove_handle_get_statistics(TROVE_co
handle_ledger_t *ledger = NULL;
struct qlist_head *hash_link = NULL;
+ gen_mutex_lock(&trove_handle_mutex);
hash_link = qhash_search(s_fsid_to_ledger_table,&(coll_id));
if (hash_link)
{
@@ -516,15 +540,18 @@ int trove_handle_get_statistics(TROVE_co
{
trove_handle_ledger_get_statistics(ledger->ledger,
free_count);
+ gen_mutex_unlock(&trove_handle_mutex);
return(0);
}
else
{
+ gen_mutex_unlock(&trove_handle_mutex);
return(-PVFS_ENOENT);
}
}
else
{
+ gen_mutex_unlock(&trove_handle_mutex);
return(-PVFS_ENOENT);
}
}
@@ -535,6 +562,7 @@ int trove_handle_mgmt_finalize()
handle_ledger_t *ledger = NULL;
struct qlist_head *hash_link = NULL;
+ gen_mutex_lock(&trove_handle_mutex);
/*
this is an exhaustive and slow iterate. speed this up
if 'finalize' is something that will be done frequently.
@@ -558,6 +586,8 @@ int trove_handle_mgmt_finalize()
}
qhash_finalize(s_fsid_to_ledger_table);
s_fsid_to_ledger_table = NULL;
+
+ gen_mutex_unlock(&trove_handle_mutex);
return 0;
}
More information about the PVFS2-CVS
mailing list