summaryrefslogtreecommitdiffstats
path: root/src/H5Bcache.c
diff options
context:
space:
mode:
authorNeil Fortner <nfortne2@hdfgroup.org>2012-02-27 16:34:55 (GMT)
committerNeil Fortner <nfortne2@hdfgroup.org>2012-02-27 16:34:55 (GMT)
commit73c139e29b45941dfc4e558d9096a0869a184260 (patch)
tree422cc12e6675238cd92edadc078fa427a4f6bcd0 /src/H5Bcache.c
parente2cd00055204f6b264002e70b21a6e2ca4c98c77 (diff)
downloadhdf5-73c139e29b45941dfc4e558d9096a0869a184260.zip
hdf5-73c139e29b45941dfc4e558d9096a0869a184260.tar.gz
hdf5-73c139e29b45941dfc4e558d9096a0869a184260.tar.bz2
[svn-r21989] Purpose: Add SWMR capability to v1 b-tree
Description: Adds SWMR capability to v1 b-trees, and the chunk index using v1 b-trees. With this implementation, flush dependencies are always on when in the cache. This will allow attritbutes to be used for "checkpointing" data when object header dependencies are fixed - i.e. if a writer writes data before an attribute in that dataset's object header, then if a reader sees the updated attribute the written data is guaranteed to be visible, as long as that dataset's b-tree nodes are evicted from the reader's cache. Also adds support for compression with SWMR. Also fixes earray implementation to not free (reuse) the file space for deleted chunks and outdated versions of compressed chunks when doing SWMR writes. These should eventually be added to a timeout list. Adds testing for these cases. Tested: durandal
Diffstat (limited to 'src/H5Bcache.c')
-rw-r--r--src/H5Bcache.c68
1 files changed, 67 insertions, 1 deletions
diff --git a/src/H5Bcache.c b/src/H5Bcache.c
index 7c006bc..64c8b56 100644
--- a/src/H5Bcache.c
+++ b/src/H5Bcache.c
@@ -60,6 +60,7 @@ static herr_t H5B_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr,
static herr_t H5B_dest(H5F_t *f, H5B_t *bt);
static herr_t H5B_clear(H5F_t *f, H5B_t *b, hbool_t destroy);
static herr_t H5B_compute_size(const H5F_t *f, const H5B_t *bt, size_t *size_ptr);
+static herr_t H5B_notify(H5AC_notify_action_t action, H5B_t *bt);
/*********************/
@@ -73,7 +74,7 @@ const H5AC_class_t H5AC_BT[1] = {{
(H5AC_flush_func_t)H5B_flush,
(H5AC_dest_func_t)H5B_dest,
(H5AC_clear_func_t)H5B_clear,
- (H5AC_notify_func_t)NULL,
+ (H5AC_notify_func_t)H5B_notify,
(H5AC_size_func_t)H5B_compute_size,
}};
@@ -176,6 +177,13 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, NULL, "unable to decode key")
} /* end if */
+ /* Set up flush dependency. The dependency will actually be created in the
+ * "notify" callback. */
+ if(shared->swmr_write) {
+ HDassert(udata->parent);
+ bt->parent = udata->parent;
+ } /* end if */
+
/* Set return value */
ret_value = bt;
@@ -370,6 +378,64 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5B_notify
+ *
+ * Purpose: Handle cache action notifications
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Neil Fortner
+ * nfortne2@hdfgroup.org
+ * Aug 17 2010
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5B_notify(H5AC_notify_action_t action, H5B_t *bt)
+{
+ H5B_shared_t *shared; /* Pointer to shared B-tree info */
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_NOAPI_NOINIT(H5B_notify)
+
+ /*
+ * Check arguments.
+ */
+ HDassert(bt);
+ HDassert(bt->rc_shared);
+ shared = (H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared);
+
+ /* Check if the file was opened with SWMR-write access */
+ if(shared->swmr_write) {
+ HDassert(bt->parent);
+ switch(action) {
+ case H5AC_NOTIFY_ACTION_AFTER_INSERT:
+ /* Create flush dependency on parent */
+ if(H5AC_create_flush_dependency(bt->parent, bt) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency")
+ break;
+
+ case H5AC_NOTIFY_ACTION_BEFORE_EVICT:
+ /* Destroy flush dependency on parent */
+ if(H5AC_destroy_flush_dependency(bt->parent, bt) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency")
+ break;
+
+ default:
+#ifdef NDEBUG
+ HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, FAIL, "unknown action from metadata cache")
+#else /* NDEBUG */
+ HDassert(0 && "Unknown action?!?");
+#endif /* NDEBUG */
+ } /* end switch */
+ } /* end if */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5B_notify() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5B_compute_size
*
* Purpose: Compute the size in bytes of the specified instance of