[Pvfs2-cvs] commit by pcarns in pvfs2-1/src/io/trove/trove-dbpf: dbpf-dspace.c dbpf-mgmt.c dbpf.h

CVS commit program cvs at parl.clemson.edu
Thu Apr 3 13:58:11 EST 2008


Update of /projects/cvsroot/pvfs2-1/src/io/trove/trove-dbpf
In directory parlweb1:/tmp/cvs-serv19446/src/io/trove/trove-dbpf

Modified Files:
      Tag: pvfs-2-7-branch
	dbpf-dspace.c dbpf-mgmt.c dbpf.h 
Log Message:
merging trove getattr_list cleanups from trunk to pvfs-2-7-branch


Index: dbpf-dspace.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/io/trove/trove-dbpf/dbpf-dspace.c,v
diff -p -u -r1.152.2.4 -r1.152.2.5
--- dbpf-dspace.c	1 Apr 2008 23:25:17 -0000	1.152.2.4
+++ dbpf-dspace.c	3 Apr 2008 18:58:10 -0000	1.152.2.5
@@ -99,6 +99,9 @@ static inline void organize_post_op_stat
 
 static int dbpf_dspace_remove_keyval(
     void * args, TROVE_handle handle, TROVE_keyval_s *key, TROVE_keyval_s *val);
+static int getattr_one_handle(TROVE_object_ref ref, 
+    TROVE_ds_attributes *attr, 
+    DB* ds_db);
 
 static int dbpf_dspace_iterate_handles_op_svc(struct dbpf_op *op_p);
 static int dbpf_dspace_create_op_svc(struct dbpf_op *op_p);
@@ -984,9 +987,10 @@ static int dbpf_dspace_getattr_list(TROV
     struct dbpf_collection *coll_p = NULL;
     TROVE_object_ref ref;
     int i;
+    int cache_hits = 0; 
 
-    /* fast path cache hit; skips queueing */
     gen_mutex_lock(&dbpf_attr_cache_mutex);
+    /* go ahead and try to hit attr cache for all handles up front */ 
     for (i = 0; i < nhandles; i++) 
     {
         ref.handle = handle_array[i];
@@ -1003,21 +1007,30 @@ static int dbpf_dspace_getattr_list(TROV
                 (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 "
+            gossip_debug(GOSSIP_DBPF_ATTRCACHE_DEBUG, "dspace_getattr_list 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));
+                         ds_attr_p[i].dfile_count, ds_attr_p[i].dist_size,
+                         lld(ds_attr_p[i].b_size));
 
             UPDATE_PERF_METADATA_READ();
             error_array[i] = 0;
-            continue;
+            cache_hits++;
+        }
+        else
+        {
+            /* no hit; mark attr entry so that we can detect that in the
+             * service routine
+             */
+            ds_attr_p[i].type = PVFS_TYPE_NONE;
         }
-        break;
     }
     gen_mutex_unlock(&dbpf_attr_cache_mutex);
+
     /* All handles hit in the cache, return */
-    if (i == nhandles) {
+    if (cache_hits == nhandles) 
+    {
+        gossip_debug(GOSSIP_DBPF_ATTRCACHE_DEBUG, "dspace_getattr_list serviced entirely from attr cache.\n");
         return 1;
     }
 
@@ -1043,10 +1056,10 @@ static int dbpf_dspace_getattr_list(TROV
                         context_id);
 
     /* initialize op-specific members */
-    q_op_p->op.u.d_getattr_list.count = (nhandles - i);
-    q_op_p->op.u.d_getattr_list.handle_array = &handle_array[i];
-    q_op_p->op.u.d_getattr_list.attr_p = &ds_attr_p[i];
-    q_op_p->op.u.d_getattr_list.error_p = &error_array[i];
+    q_op_p->op.u.d_getattr_list.count = nhandles;
+    q_op_p->op.u.d_getattr_list.handle_array = handle_array;
+    q_op_p->op.u.d_getattr_list.attr_p = ds_attr_p;
+    q_op_p->op.u.d_getattr_list.error_p = error_array;
 
     *out_op_id_p = dbpf_queued_op_queue(q_op_p);
 
@@ -1150,20 +1163,20 @@ return_error:
     return ret;
 }
 
-static int dbpf_dspace_getattr_op_svc(struct dbpf_op *op_p)
+static int getattr_one_handle(TROVE_object_ref ref, 
+    TROVE_ds_attributes *attr, 
+    DB* ds_db)
 {
     int ret = -TROVE_EINVAL;
     DBT key, data;
     TROVE_ds_storedattr_s s_attr;
-    TROVE_ds_attributes *attr = NULL;
     TROVE_size b_size;
     struct stat b_stat;
-    TROVE_object_ref ref = {op_p->handle, op_p->coll_p->coll_id};
     struct open_cache_ref tmp_ref;
 
     /* get an fd for the bstream so we can check size */
     ret = dbpf_open_cache_get(
-        op_p->coll_p->coll_id, op_p->handle, 0, &tmp_ref);
+        ref.fs_id, ref.handle, 0, &tmp_ref);
     if (ret < 0)
     {
         b_size = 0;
@@ -1174,14 +1187,13 @@ static int dbpf_dspace_getattr_op_svc(st
         dbpf_open_cache_put(&tmp_ref);
         if (ret < 0)
         {
-            ret = -TROVE_EBADF;
-            goto return_error;
+            return(-TROVE_EBADF);
         }
         b_size = (TROVE_size)b_stat.st_size;
     }
 
     memset(&key, 0, sizeof(key));
-    key.data = &op_p->handle;
+    key.data = &ref.handle;
     key.size = key.ulen = sizeof(TROVE_handle);
 
     memset(&data, 0, sizeof(data));
@@ -1190,27 +1202,24 @@ static int dbpf_dspace_getattr_op_svc(st
     data.size = data.ulen = sizeof(TROVE_ds_storedattr_s);
     data.flags |= DB_DBT_USERMEM;
 
-    ret = op_p->coll_p->ds_db->get(op_p->coll_p->ds_db, 
-                                   NULL, &key, &data, 0);
+    ret = ds_db->get(ds_db, NULL, &key, &data, 0);
     if (ret != 0)
     {
         if(ret != DB_NOTFOUND)
         {
-            op_p->coll_p->ds_db->err(op_p->coll_p->ds_db, ret, "DB->get");
+            ds_db->err(ds_db, ret, "DB->get");
         }
-        ret = -dbpf_db_error_to_trove_error(ret);
-        goto return_error;
+        return(-dbpf_db_error_to_trove_error(ret));
     }
 
     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,
+        llu(ref.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);
 
     /* add retrieved ds_attr to dbpf_attr cache here */
@@ -1218,115 +1227,49 @@ static int dbpf_dspace_getattr_op_svc(st
     dbpf_attr_cache_insert(ref, attr);
     gen_mutex_unlock(&dbpf_attr_cache_mutex);
 
+    return 0;
+}
+
+static int dbpf_dspace_getattr_op_svc(struct dbpf_op *op_p)
+{
+    int ret = -TROVE_EINVAL;
+    TROVE_object_ref ref = {op_p->handle, op_p->coll_p->coll_id};
+
+    ret = getattr_one_handle(ref, 
+        op_p->u.d_getattr.attr_p, 
+        op_p->coll_p->ds_db);
+
+    if(ret < 0)
+    {
+        return(ret);
+    }
+
     return 1;
-    
-return_error:
-    return ret;
 }
 
 static int dbpf_dspace_getattr_list_op_svc(struct dbpf_op *op_p)
 {
     int i;
+    TROVE_object_ref ref;
 
     for (i = 0; i < op_p->u.d_getattr_list.count; i++)
     {
-        int ret;
-        TROVE_ds_storedattr_s s_attr;
-        TROVE_ds_attributes *attr = NULL;
-        struct stat b_stat;
-        DBT key, data;
-        struct open_cache_ref tmp_ref;
-        TROVE_object_ref ref;
-        TROVE_size b_size = 0, k_size = 0;
-        DB_BTREE_STAT *k_stat_p = NULL;
-
-        ref.handle = op_p->u.d_getattr_list.handle_array[i];
-        ref.fs_id = op_p->coll_p->coll_id;
-        /* It is still possible that we could hit in the attribute cache because of the way
-         * we do queueing in the getattr_list operation 
-         */
-        if (dbpf_attr_cache_ds_attr_fetch_cached_data(ref, &op_p->u.d_getattr_list.attr_p[i]) == 0)
-        {
-            UPDATE_PERF_METADATA_READ();
-            op_p->u.d_getattr_list.error_p[i] = 0;
-            continue;
-        }
-
-        /* get an fd for the bstream so we can check size */
-        ret = dbpf_open_cache_get(
-            op_p->coll_p->coll_id, op_p->u.d_getattr_list.handle_array[i], 0, &tmp_ref);
-        if (ret < 0)
-        {
-        }
-        else
-        {
-            ret = DBPF_FSTAT(tmp_ref.fd, &b_stat);
-            dbpf_open_cache_put(&tmp_ref);
-            if (ret < 0)
-            {
-                op_p->u.d_getattr_list.error_p[i] = -TROVE_EBADF;
-                continue;
-            }
-            b_size = (TROVE_size)b_stat.st_size;
-        }
-
-        ret = op_p->coll_p->ds_db->stat(op_p->coll_p->ds_db,
-#ifdef HAVE_TXNID_PARAMETER_TO_DB_STAT
-                                        (DB_TXN *) NULL,
-#endif
-                                        &k_stat_p,
-#ifdef HAVE_UNKNOWN_PARAMETER_TO_DB_STAT
-                                        NULL,
-#endif
-                                        0);
-        if (ret == 0)
+        if(op_p->u.d_getattr_list.attr_p[i].type != PVFS_TYPE_NONE)
         {
-            k_size = (TROVE_size) k_stat_p->bt_ndata;
-            free(k_stat_p);
-        }
-        else
-        {
-            gossip_err("Error: unable to stat handle %llu (%llx).\n",
-                       llu(op_p->handle), llu(op_p->handle));
-            op_p->u.d_getattr_list.error_p[i] = -TROVE_EIO;
+            /* we already serviced this one from the cache at post time;
+             * skip to the next element
+             */
+            gossip_debug(GOSSIP_TROVE_DEBUG, 
+                "dbpf_dspace_getattr_list_op_svc() skipping element %d resolved from cache.\n", i);
             continue;
         }
 
-        memset(&key, 0, sizeof(key));
-        key.data = &op_p->u.d_getattr_list.handle_array[i];
-        key.size = key.ulen = sizeof(TROVE_handle);
-
-        memset(&data, 0, sizeof(data));
-        memset(&s_attr, 0, sizeof(TROVE_ds_storedattr_s));
-        data.data = &s_attr;
-        data.size = data.ulen = sizeof(TROVE_ds_storedattr_s);
-        data.flags |= DB_DBT_USERMEM;
-
-        ret = op_p->coll_p->ds_db->get(op_p->coll_p->ds_db, 
-                                       NULL, &key, &data, 0);
-        if (ret != 0)
-        {
-            op_p->coll_p->ds_db->err(op_p->coll_p->ds_db, ret, "DB->get");
-            op_p->u.d_getattr_list.error_p[i] = -TROVE_EIO;
-            continue;
-        }
+        ref.handle = op_p->u.d_getattr_list.handle_array[i];
+        ref.fs_id = op_p->coll_p->coll_id;
 
-        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);
-
-        /* add retrieved ds_attr to dbpf_attr cache here */
-        gen_mutex_lock(&dbpf_attr_cache_mutex);
-        dbpf_attr_cache_insert(ref, attr);
-        gen_mutex_unlock(&dbpf_attr_cache_mutex);
-        op_p->u.d_getattr_list.error_p[i] = 0;
+        op_p->u.d_getattr_list.error_p[i] = getattr_one_handle(ref,
+           &op_p->u.d_getattr_list.attr_p[i],
+           op_p->coll_p->ds_db);
     }
 
     return 1;

Index: dbpf-mgmt.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/io/trove/trove-dbpf/dbpf-mgmt.c,v
diff -p -u -r1.99.2.1 -r1.99.2.2
--- dbpf-mgmt.c	28 Jan 2008 20:07:24 -0000	1.99.2.1
+++ dbpf-mgmt.c	3 Apr 2008 18:58:10 -0000	1.99.2.2
@@ -1900,12 +1900,17 @@ static __dbpf_op_type_str_map_t s_dbpf_o
     { KEYVAL_READ_LIST, "KEYVAL_READ_LIST" },
     { KEYVAL_WRITE_LIST, "KEYVAL_WRITE_LIST" },
     { KEYVAL_FLUSH, "KEYVAL_FLUSH" },
+    { KEYVAL_GET_HANDLE_INFO, "KEYVAL_GET_HANDLE_INFO" },
     { DSPACE_CREATE, "DSPACE_CREATE" },
     { DSPACE_REMOVE, "DSPACE_REMOVE" },
     { DSPACE_ITERATE_HANDLES, "DSPACE_ITERATE_HANDLES" },
     { DSPACE_VERIFY, "DSPACE_VERIFY" },
     { DSPACE_GETATTR, "DSPACE_GETATTR" },
-    { DSPACE_SETATTR, "DSPACE_SETATTR" }
+    { DSPACE_SETATTR, "DSPACE_SETATTR" },
+    { DSPACE_GETATTR_LIST, "DSPACE_GETATTR_LIST" }
+    /* NOTE: this list should be kept in sync with enum dbpf_op_type 
+     * from dbpf.h 
+     */ 
 };
 
 char *dbpf_op_type_to_str(enum dbpf_op_type op_type)

Index: dbpf.h
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/io/trove/trove-dbpf/dbpf.h,v
diff -p -u -r1.82.4.1 -r1.82.4.2
--- dbpf.h	2 Apr 2008 15:49:15 -0000	1.82.4.1
+++ dbpf.h	3 Apr 2008 18:58:10 -0000	1.82.4.2
@@ -455,6 +455,9 @@ enum dbpf_op_type
     DSPACE_GETATTR,
     DSPACE_SETATTR,
     DSPACE_GETATTR_LIST,
+    /* NOTE: if you change or add items to this list, please update
+     * s_dbpf_op_type_str_map[] accordingly (dbpf-mgmt.c)
+     */
 };
 
 #define DBPF_OP_DOES_SYNC(__op)    \



More information about the Pvfs2-cvs mailing list