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

CVS commit program cvs at parl.clemson.edu
Tue Dec 16 13:49:48 EST 2008


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

Modified Files:
	dbpf-open-cache.c dbpf-open-cache.h 
Log Message:
truncate o_direct files when fd is closed to keep underlying bstream size consistent


Index: dbpf-open-cache.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/io/trove/trove-dbpf/dbpf-open-cache.c,v
diff -p -u -r1.25 -r1.26
--- dbpf-open-cache.c	15 Dec 2008 22:08:25 -0000	1.25
+++ dbpf-open-cache.c	16 Dec 2008 18:49:48 -0000	1.26
@@ -88,7 +88,9 @@ static int open_fd(
 
 static void close_fd(
     int fd, 
-    enum open_cache_open_type type);
+    enum open_cache_open_type type,
+    TROVE_handle handle,
+    TROVE_coll_id coll_id);
 
 inline static struct open_cache_entry * dbpf_open_cache_find_entry(
     struct qlist_head * list, 
@@ -205,6 +207,8 @@ int dbpf_open_cache_get(
 	}
         out_ref->fd = tmp_entry->fd;
         out_ref->type = type;
+        out_ref->handle = handle;
+        out_ref->coll_id = coll_id;
 
 	out_ref->internal = tmp_entry;
 	tmp_entry->ref_ct++;
@@ -251,7 +255,8 @@ int dbpf_open_cache_get(
 
 	if (tmp_entry->fd > -1)
 	{
-            close_fd(tmp_entry->fd, tmp_entry->type);
+            close_fd(tmp_entry->fd, tmp_entry->type, tmp_entry->handle,
+                tmp_entry->coll_id);
 	    tmp_entry->fd = -1;
 	}
     }
@@ -277,6 +282,8 @@ int dbpf_open_cache_get(
         tmp_entry->type = type;
         out_ref->type = type;
         out_ref->fd = tmp_entry->fd;
+        out_ref->handle = handle;
+        out_ref->coll_id = coll_id;
 
 	out_ref->internal = tmp_entry;
 	gossip_debug(GOSSIP_DBPF_OPEN_CACHE_DEBUG,
@@ -303,6 +310,8 @@ int dbpf_open_cache_get(
         return ret;
     }
     out_ref->type = type;
+    out_ref->handle = handle;
+    out_ref->coll_id = coll_id;
 
     out_ref->internal = NULL;
     gen_mutex_unlock(&cache_mutex);
@@ -351,7 +360,7 @@ void dbpf_open_cache_put(
 	/* this wasn't cached; go ahead and close up */
 	if(in_ref->fd > -1)
 	{
-            close_fd(in_ref->fd, in_ref->type);
+            close_fd(in_ref->fd, in_ref->type, in_ref->handle, in_ref->coll_id);
 	    in_ref->fd = -1;
 	}
     }
@@ -413,7 +422,8 @@ int dbpf_open_cache_remove(
 	    "dbpf_open_cache_remove: unused entry.\n");
 	if (tmp_entry->fd > -1)
 	{
-            close_fd(tmp_entry->fd, tmp_entry->type);
+            close_fd(tmp_entry->fd, tmp_entry->type, tmp_entry->handle,
+                tmp_entry->coll_id);
 	    tmp_entry->fd = -1;
 	}
 	qlist_add(&tmp_entry->queue_link, &free_list);
@@ -492,7 +502,7 @@ static void dbpf_open_cache_entries_fina
         entry = qlist_entry(list_entry, struct open_cache_entry, queue_link);
         if(entry->fd > -1)
         {
-            close_fd(entry->fd, entry->type);
+            close_fd(entry->fd, entry->type, entry->handle, entry->coll_id);
 	    entry->fd = -1;
 	}
         qlist_del(&entry->queue_link);
@@ -623,8 +633,44 @@ static void* unlink_bstream(void *contex
 
 static void close_fd(
     int fd, 
-    enum open_cache_open_type type)
+    enum open_cache_open_type type,
+    TROVE_handle handle,
+    TROVE_coll_id coll_id)
 {
+    TROVE_object_ref ref;
+    TROVE_ds_attributes attr;
+    struct dbpf_collection *coll_p = NULL;
+    int ret;
+
+    /* truncate O_DIRECT files at close time to keep size consistent */
+    if(type == DBPF_FD_DIRECT_READ || type == DBPF_FD_DIRECT_WRITE)
+    {
+        gossip_err("dbpf_open_cache truncating fd %d for handle %llu at close time.\n",
+            fd, llu(handle));
+        
+        coll_p = dbpf_collection_find_registered(coll_id);
+        if (coll_p == NULL)
+        {
+            return;
+        }
+
+        ref.handle = handle;
+        ref.fs_id = coll_id;
+
+        ret = dbpf_dspace_attr_get(coll_p, ref, &attr);
+        if(ret != 0)
+        {
+            return;
+        }
+
+        ret = DBPF_RESIZE(fd, attr.u.datafile.b_size);
+        if(ret < 0)
+        {
+            gossip_err("Error: failed to truncate fd %d for handle %llu at close time.\n",
+                fd, llu(handle));
+        }
+    }
+
     gossip_debug(GOSSIP_DBPF_OPEN_CACHE_DEBUG,
         "dbpf_open_cache closing fd %d of type %d\n", fd, type);
     DBPF_CLOSE(fd);

Index: dbpf-open-cache.h
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/io/trove/trove-dbpf/dbpf-open-cache.h,v
diff -p -u -r1.9 -r1.10
--- dbpf-open-cache.h	15 Dec 2008 22:08:25 -0000	1.9
+++ dbpf-open-cache.h	16 Dec 2008 18:49:48 -0000	1.10
@@ -24,6 +24,8 @@ struct open_cache_ref
 {
     int fd;
     enum open_cache_open_type type;
+    TROVE_handle handle;
+    TROVE_coll_id coll_id;
     void* internal; /* pointer to underlying data structure */
 };
 



More information about the Pvfs2-cvs mailing list