? client
? diff
? fs.conf
? nb.patch
? patch-2.6.23.1
? revert.patch
? tmp.conf
? zfill-fix.patch
? doc/REFERENCES.bib.xml
? doc/REFERENCES.xml
? doc/pvfs2-quickstart.tex.1
? src/apps/admin/pvfs2-dspace-dump.c
? src/client/sysint/.sys-getattr.sm.swp
Index: src/io/trove/trove-dbpf/dbpf-dspace.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/io/trove/trove-dbpf/dbpf-dspace.c,v
retrieving revision 1.152
diff -u -a -p -r1.152 dbpf-dspace.c
--- src/io/trove/trove-dbpf/dbpf-dspace.c	8 Nov 2007 21:48:22 -0000	1.152
+++ src/io/trove/trove-dbpf/dbpf-dspace.c	28 Jan 2008 21:55:49 -0000
@@ -31,6 +31,8 @@
 #include "dbpf-attr-cache.h"
 #include "dbpf-open-cache.h"
 
+#define MAX_HANDLE_ALLOC_ATTEMPTS 32
+
 #define TROVE_DEFAULT_DB_PAGESIZE 512
 
 #ifdef __PVFS2_TROVE_THREADED__
@@ -176,6 +178,7 @@ static int dbpf_dspace_create(TROVE_coll
 static int dbpf_dspace_create_op_svc(struct dbpf_op *op_p)
 {
     int ret = -TROVE_EINVAL;
+    int attempts = 0;
     TROVE_ds_storedattr_s s_attr;
     TROVE_ds_attributes attr;
     TROVE_handle new_handle = TROVE_HANDLE_NULL;
@@ -188,90 +191,95 @@ static int dbpf_dspace_create_op_svc(str
 
     cur_extent = op_p->u.d_create.extent_array.extent_array[0];
 
-    /* check if we got a single specific handle */
-    if ((op_p->u.d_create.extent_array.extent_count == 1) &&
-        (cur_extent.first == cur_extent.last))
+    do
     {
-        /*
-          check if we MUST use the exact handle value specified;
-          if caller requests a specific handle, honor it
-        */
-        if (op_p->flags & TROVE_FORCE_REQUESTED_HANDLE)
+        /* check if we got a single specific handle */
+        if ((op_p->u.d_create.extent_array.extent_count == 1) &&
+            (cur_extent.first == cur_extent.last))
         {
-            /*
-              we should probably handle this error nicely;
-              right now, it will fail later (gracefully) if this
-              fails since the handle will already exist, but
-              since we know it here, handle it here ?
-            */
-            new_handle = cur_extent.first;
-            trove_handle_set_used(op_p->coll_p->coll_id, new_handle);
-            gossip_debug(GOSSIP_TROVE_DEBUG, "new_handle was FORCED "
-                         "to be %llu\n", llu(new_handle));
+            if (cur_extent.first == TROVE_HANDLE_NULL)
+            {
+                /*
+                   if we got TROVE_HANDLE_NULL, the caller doesn't care
+                   where the handle comes from
+                   */
+                new_handle = trove_handle_alloc(op_p->coll_p->coll_id);
+            }
+            else
+            {
+                /*
+                   we should probably handle this error nicely;
+                   right now, it will fail later (gracefully) if this
+                   fails since the handle will already exist, but
+                   since we know it here, handle it here ?
+                   */
+                new_handle = cur_extent.first;
+                trove_handle_set_used(op_p->coll_p->coll_id, new_handle);
+                gossip_debug(GOSSIP_TROVE_DEBUG, "new_handle was FORCED "
+                             "to be %llu\n", llu(new_handle));
+            }
         }
-        else if (cur_extent.first == TROVE_HANDLE_NULL)
+        else
         {
             /*
-              if we got TROVE_HANDLE_NULL, the caller doesn't care
-              where the handle comes from
-            */
-            new_handle = trove_handle_alloc(op_p->coll_p->coll_id);
+               otherwise, we have to try to allocate a handle from
+               the specified range that we're given
+               */
+            new_handle = trove_handle_alloc_from_range(
+                op_p->coll_p->coll_id, &op_p->u.d_create.extent_array);
         }
-    }
-    else
-    {
+
+        gossip_debug(GOSSIP_TROVE_DEBUG, "[%d extents] -- new_handle is %llu "
+                     "(cur_extent is %llu - %llu)\n",
+                     op_p->u.d_create.extent_array.extent_count,
+                     llu(new_handle), llu(cur_extent.first),
+                     llu(cur_extent.last));
         /*
-          otherwise, we have to try to allocate a handle from
-          the specified range that we're given
-        */
-        new_handle = trove_handle_alloc_from_range(
-            op_p->coll_p->coll_id, &op_p->u.d_create.extent_array);
-    }
-
-    gossip_debug(GOSSIP_TROVE_DEBUG, "[%d extents] -- new_handle is %llu "
-                 "(cur_extent is %llu - %llu)\n",
-                 op_p->u.d_create.extent_array.extent_count,
-                 llu(new_handle), llu(cur_extent.first),
-                 llu(cur_extent.last));
-    /*
-      if we got a zero handle, we're either completely out of handles
-      -- or else something terrible has happened
-    */
-    if (new_handle == TROVE_HANDLE_NULL)
-    {
-        gossip_err("Error: handle allocator returned a zero handle.\n");
-        ret = -TROVE_ENOSPC;
-        goto return_error;
-    }
+           if we got a zero handle, we're either completely out of handles
+           -- or else something terrible has happened
+           */
+        if (new_handle == TROVE_HANDLE_NULL)
+        {
+            gossip_err("Error: handle allocator returned a zero handle.\n");
+            ret = -TROVE_ENOSPC;
+            goto return_error;
+        }
 
-    memset(&s_attr, 0, sizeof(TROVE_ds_storedattr_s));
-    s_attr.type = op_p->u.d_create.type;
+        memset(&s_attr, 0, sizeof(TROVE_ds_storedattr_s));
+        s_attr.type = op_p->u.d_create.type;
 
-    memset(&key, 0, sizeof(key));
-    key.data = &new_handle;
-    key.size = key.ulen = sizeof(new_handle);
+        memset(&key, 0, sizeof(key));
+        key.data = &new_handle;
+        key.size = key.ulen = sizeof(new_handle);
 
-    memset(&data, 0, sizeof(data));
-    data.data = &s_attr;
-    data.size = data.ulen = sizeof(TROVE_ds_storedattr_s);
-    data.flags |= DB_DBT_USERMEM;
+        memset(&data, 0, sizeof(data));
+        data.data = &s_attr;
+        data.size = data.ulen = sizeof(TROVE_ds_storedattr_s);
+        data.flags |= DB_DBT_USERMEM;
 
-    /* check to see if handle is already used */
-    ret = op_p->coll_p->ds_db->get(op_p->coll_p->ds_db, NULL, &key, &data, 0);
-    if (ret == 0)
-    {
-        gossip_debug(GOSSIP_TROVE_DEBUG, "handle (%llu) already exists.\n",
-                     llu(new_handle));
-        ret = -TROVE_EEXIST;
-        goto return_error;
-    }
-    else if ((ret != DB_NOTFOUND) && (ret != DB_KEYEMPTY))
+        /* check to see if handle is already used */
+        ret = op_p->coll_p->ds_db->get(op_p->coll_p->ds_db, NULL, &key, &data, 0);
+        if (ret == 0 && op_p->flags & TROVE_FORCE_REQUESTED_HANDLE)
+        {
+            gossip_debug(GOSSIP_TROVE_DEBUG, "handle (%llu) already exists.\n",
+                         llu(new_handle));
+            ret = -TROVE_EEXIST;
+            goto return_error;
+        }
+        else if ((ret != DB_NOTFOUND) && (ret != DB_KEYEMPTY))
+        {
+            gossip_err("error in dspace create (db_p->get failed).\n");
+            ret = -dbpf_db_error_to_trove_error(ret);
+            goto return_error;
+        }
+    } while(ret != DB_NOTFOUND && ++attempts > MAX_HANDLE_ALLOC_ATTEMPTS);
+
+    if(ret != DB_NOTFOUND)
     {
-        gossip_err("error in dspace create (db_p->get failed).\n");
-        ret = -dbpf_db_error_to_trove_error(ret);
+        ret = -TROVE_ENOSPC;
         goto return_error;
     }
-    
+
     /* check for old bstream files (these should not exist, but it is
      * possible if the db gets out of sync with the rest of the collection
      * somehow
@@ -621,6 +629,25 @@ static int dbpf_dspace_iterate_handles_o
     op_p->u.d_iterate_handles.handle_array[i] = dummy_handle;
     ++i;
 
+    if(i == *op_p->u.d_iterate_handles.count_p)
+    {
+        /* handle single count case */
+        ret = dbc_p->c_get(dbc_p, &key, &data, DB_NEXT);
+        if (ret == DB_NOTFOUND)
+        {
+            goto return_ok;
+        }
+        else if (ret != 0)
+        {
+            ret = -dbpf_db_error_to_trove_error(ret);
+            gossip_err("failed to set cursor position at handle: %llu\n",
+                       llu(*(TROVE_handle *)op_p->u.d_iterate_handles.position_p));
+            goto return_error;
+        }
+        *op_p->u.d_iterate_handles.position_p = dummy_handle;
+        goto return_ok;
+    }
+
     start_size = ((sizeof(TROVE_handle) + sizeof(s_attr)) *
                   (*op_p->u.d_iterate_handles.count_p - 1));
     /* round up to the nearest 1024 */
@@ -915,21 +942,6 @@ static int dbpf_dspace_getattr(TROVE_col
     gen_mutex_lock(&dbpf_attr_cache_mutex);
     if (dbpf_attr_cache_ds_attr_fetch_cached_data(ref, ds_attr_p) == 0)
     {
-#if 0
-        gossip_debug(
-            GOSSIP_TROVE_DEBUG, "ATTRIB: retrieved "
-            "attributes from CACHE for key %llu\n  uid = %d, mode = %d, "
-            "type = %d, dfile_count = %d, dist_size = %d\n",
-            llu(handle), (int)ds_attr_p->uid, (int)ds_attr_p->mode,
-            (int)ds_attr_p->type, (int)ds_attr_p->dfile_count,
-            (int)ds_attr_p->dist_size);
-#endif
-        gossip_debug(GOSSIP_DBPF_ATTRCACHE_DEBUG, "dspace_getattr fast "
-                     "path attr cache hit on %llu\n (dfile_count=%d | "
-                     "dist_size=%d | data_size=%lld)\n", llu(handle),
-                     ds_attr_p->dfile_count, ds_attr_p->dist_size,
-                     lld(ds_attr_p->b_size));
-
         UPDATE_PERF_METADATA_READ();
         gen_mutex_unlock(&dbpf_attr_cache_mutex);
         return 1;
@@ -988,21 +1000,6 @@ static int dbpf_dspace_getattr_list(TROV
 
         if (dbpf_attr_cache_ds_attr_fetch_cached_data(ref, &ds_attr_p[i]) == 0)
         {
-#if 0
-            gossip_debug(
-                GOSSIP_TROVE_DEBUG, "ATTRIB: retrieved "
-                "attributes from CACHE for key %llu\n  uid = %d, mode = %d, "
-                "type = %d, dfile_count = %d, dist_size = %d\n",
-                llu(handle), (int)ds_attr_p->uid, (int)ds_attr_p->mode,
-                (int)ds_attr_p->type, (int)ds_attr_p->dfile_count,
-                (int)ds_attr_p->dist_size);
-#endif
-            gossip_debug(GOSSIP_DBPF_ATTRCACHE_DEBUG, "dspace_getattr fast "
-                         "path attr cache hit on %llu\n (dfile_count=%d | "
-                         "dist_size=%d | data_size=%lld)\n", llu(handle_array[i]),
-                         ds_attr_p->dfile_count, ds_attr_p->dist_size,
-                         lld(ds_attr_p->b_size));
-
             UPDATE_PERF_METADATA_READ();
             error_array[i] = 0;
             continue;
@@ -1110,15 +1107,6 @@ static int dbpf_dspace_setattr_op_svc(st
 
     trove_ds_attr_to_stored((*op_p->u.d_setattr.attr_p), s_attr);
 
-#if 0
-    gossip_debug(GOSSIP_TROVE_DEBUG, "ATTRIB: dspace_setattr storing "
-                 "attributes (2) on key %llu\n uid = %d, mode = %d, "
-                 "type = %d, dfile_count = %d, dist_size = %d\n",
-                 llu(op_p->handle), (int) s_attr.uid, (int) s_attr.mode,
-                 (int) s_attr.type, (int) s_attr.dfile_count,
-                 (int) s_attr.dist_size);
-#endif
-
     ret = op_p->coll_p->ds_db->put(
         op_p->coll_p->ds_db, NULL, &key, &data, 0);
     if (ret != 0)
@@ -1196,14 +1184,6 @@ static int dbpf_dspace_getattr_op_svc(st
         goto return_error;
     }
 
-    gossip_debug(
-        GOSSIP_TROVE_DEBUG, "ATTRIB: retrieved attributes "
-        "from DISK for key %llu\n\tuid = %d, mode = %d, type = %d, "
-        "dfile_count = %d, dist_size = %d\n\tb_size = %lld\n",
-        llu(op_p->handle), (int)s_attr.uid, (int)s_attr.mode,
-        (int)s_attr.type, (int)s_attr.dfile_count, (int)s_attr.dist_size,
-        llu(b_size));
-
     attr = op_p->u.d_getattr.attr_p;
     trove_ds_stored_to_attr(s_attr, *attr, b_size);
 
@@ -1304,14 +1284,6 @@ static int dbpf_dspace_getattr_list_op_s
             op_p->u.d_getattr_list.error_p[i] = -TROVE_EIO;
             continue;
         }
-
-        gossip_debug(
-            GOSSIP_TROVE_DEBUG, "ATTRIB: retrieved attributes "
-            "from DISK for key %llu\n\tuid = %d, mode = %d, type = %d, "
-            "dfile_count = %d, dist_size = %d\n\tb_size = %lld, k_size = %lld\n",
-            llu(op_p->u.d_getattr_list.handle_array[i]), (int)s_attr.uid, (int)s_attr.mode,
-            (int)s_attr.type, (int)s_attr.dfile_count, (int)s_attr.dist_size,
-            llu(b_size), llu(k_size));
 
         attr = &op_p->u.d_getattr_list.attr_p[i];
         trove_ds_stored_to_attr(s_attr, *attr, b_size);
Index: src/io/trove/trove-handle-mgmt/trove-handle-mgmt.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/io/trove/trove-handle-mgmt/trove-handle-mgmt.c,v
retrieving revision 1.46
diff -u -a -p -r1.46 trove-handle-mgmt.c
--- src/io/trove/trove-handle-mgmt/trove-handle-mgmt.c	15 Aug 2007 18:43:09 -0000	1.46
+++ src/io/trove/trove-handle-mgmt/trove-handle-mgmt.c	28 Jan 2008 21:55:49 -0000
@@ -9,6 +9,9 @@
 #include <string.h>
 #include <assert.h>
 #include <sys/time.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 #include "trove.h"
 #include "quickhash.h"
@@ -18,7 +21,6 @@
 #include "gossip.h"
 #include "gen-locks.h"
 #include "pvfs2-internal.h"
-
 /*
   this is an internal structure and shouldn't be used
   by anyone except this module
@@ -64,6 +66,7 @@ static int trove_check_handle_ranges(TRO
     static TROVE_handle handles[MAX_NUM_VERIFY_HANDLE_COUNT] =
         {TROVE_HANDLE_NULL};
 
+#ifdef TROVE_HANDLE_LEDGER_ENABLED
     if (extent_list && ledger)
     {
         count = MAX_NUM_VERIFY_HANDLE_COUNT;
@@ -137,6 +140,9 @@ static int trove_check_handle_ranges(TRO
         }
     }
     return ret;
+#else
+    return 0;
+#endif
 }
 
 static int trove_map_handle_ranges( PINT_llist *extent_list,
@@ -254,6 +260,9 @@ static int hash_fsid_compare(void *key, 
     return(0);
 }
 
+static struct random_data trove_handle_random_data;
+static char randstate[256];
+
 int trove_handle_mgmt_initialize()
 {
     /*
@@ -261,6 +270,8 @@ int trove_handle_mgmt_initialize()
       unless the hash table initialization really fails.
     */
     int ret = 0;
+    int rfd;
+
     gen_mutex_lock(&trove_handle_mutex);
 
     if (s_fsid_to_ledger_table == NULL)
@@ -270,6 +281,24 @@ int trove_handle_mgmt_initialize()
         ret = (s_fsid_to_ledger_table ? 0 : -1);
     }
     gen_mutex_unlock(&trove_handle_mutex);
+
+#ifndef TROVE_HANDLE_LEDGER_ENABLED
+    rfd = open("/dev/urandom", O_RDONLY, 0);
+    if(rfd < 0)
+    {
+        return -PVFS_EINVAL;
+    }
+    ret = read(rfd, randstate, 256);
+    if(ret < 256)
+    {
+        close(rfd);
+        return -PVFS_EINVAL;
+    }
+    close(rfd);
+    initstate_r((long)time(NULL), randstate, 256, &trove_handle_random_data);
+    ret = 0;
+#endif
+
     return ret;
 }
 
@@ -385,11 +414,14 @@ TROVE_handle trove_handle_alloc_from_ran
     TROVE_coll_id coll_id,
     TROVE_handle_extent_array *extent_array)
 {
-    handle_ledger_t *ledger = NULL;
-    struct qlist_head *hash_link = NULL;
     TROVE_handle handle = TROVE_HANDLE_NULL;
+    TROVE_handle range;
     int i = 0;
+    int32_t r1, r2;
 
+#ifdef TROVE_HANDLE_LEDGER_ENABLED
+    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)
@@ -409,6 +441,25 @@ TROVE_handle trove_handle_alloc_from_ran
         }
     }
     gen_mutex_unlock(&trove_handle_mutex);
+#else
+
+    /* pick an extent randomly from the array */
+    random_r(&trove_handle_random_data, &r1);
+    i = r1 % extent_array->extent_count;
+
+    handle = r1;
+    if(sizeof(r1) == 4)
+    {
+        random_r(&trove_handle_random_data, &r2);
+        handle |= ((PVFS_handle)r2) << 32;
+    }
+
+    range = extent_array->extent_array[i].last -
+        extent_array->extent_array[i].first;
+
+    handle = handle % range;
+#endif
+
     return handle;
 }
 
@@ -490,7 +541,7 @@ int trove_handle_peek_from_range(
 
 int trove_handle_set_used(TROVE_coll_id coll_id, TROVE_handle handle)
 {
-    int ret = -1;
+#ifdef TROVE_HANDLE_LEDGER_ENABLED
     handle_ledger_t *ledger = NULL;
     struct qlist_head *hash_link = NULL;
 
@@ -506,11 +557,14 @@ int trove_handle_set_used(TROVE_coll_id 
     }
     gen_mutex_unlock(&trove_handle_mutex);
     return ret;
+#else
+    return 0;
+#endif
 }
 
 int trove_handle_free(TROVE_coll_id coll_id, TROVE_handle handle)
 {
-    int ret = -1;
+#ifdef TROVE_HANDLE_LEDGER_ENABLED
     handle_ledger_t *ledger = NULL;
     struct qlist_head *hash_link = NULL;
 
@@ -526,6 +580,9 @@ int trove_handle_free(TROVE_coll_id coll
     }
     gen_mutex_unlock(&trove_handle_mutex);
     return ret;
+#else
+    return 0;
+#endif
 }
 
 /* trove_handle_get_statistics()
Index: src/io/trove/trove-handle-mgmt/trove-ledger.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/io/trove/trove-handle-mgmt/trove-ledger.c,v
retrieving revision 1.34
diff -u -a -p -r1.34 trove-ledger.c
--- src/io/trove/trove-handle-mgmt/trove-ledger.c	28 Jul 2004 14:32:52 -0000	1.34
+++ src/io/trove/trove-handle-mgmt/trove-ledger.c	28 Jan 2008 21:55:49 -0000
@@ -118,8 +118,28 @@ void trove_handle_ledger_free(struct han
 
 TROVE_handle trove_ledger_handle_alloc(struct handle_ledger *hl)
 {
+    long r1, r2;
+    int i;
+    TROVE_handle handle, range;
+
+#ifdef TROVE_HANDLE_LEDGER_ENABLED
     return (hl ? extentlist_get_and_dec_extent(
                 &(hl->free_list)) : TROVE_HANDLE_NULL);
+#else
+    r1 = random();
+
+    i = r1 % hl->free_list.num_extents;
+    
+    handle = r1;
+    if(sizeof(r1) == 4)
+    {
+        r2 = random();
+        handle |= ((PVFS_handle)r2) << 32;
+    }
+    range = hl->free_list.extents[i].last - hl->free_list.extents[i].first;
+    handle = handle % range;
+    return handle;
+#endif
 }
 
 /* if possible, allocate a handle within the given starting point and
