summaryrefslogtreecommitdiffstats
path: root/src/H5FAcache.c
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2012-09-18 21:10:36 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2012-09-18 21:10:36 (GMT)
commit3427f6b172a675d7fa25c11aa3b7ec6b284e9534 (patch)
treec20003d1dfae5c1fbef57d4cbc66e1ae3008ad5f /src/H5FAcache.c
parent495b8de00214c9f99d6f10fd91de0feef55cefa8 (diff)
downloadhdf5-3427f6b172a675d7fa25c11aa3b7ec6b284e9534.zip
hdf5-3427f6b172a675d7fa25c11aa3b7ec6b284e9534.tar.gz
hdf5-3427f6b172a675d7fa25c11aa3b7ec6b284e9534.tar.bz2
[svn-r22784] Purpose:
Add flush dependencies to the fixed array code. Description: Added basic flush dependency wiring to the fixed array code. Does not include the test code, which will be added soon. NOTE: The Makefile.in change in test/ is not due to any changes made here. It appears to be from a missing bin/reconfigure in a prior checkin. Tested: jam (there is an existing flush/refresh test error)
Diffstat (limited to 'src/H5FAcache.c')
-rw-r--r--src/H5FAcache.c322
1 files changed, 186 insertions, 136 deletions
diff --git a/src/H5FAcache.c b/src/H5FAcache.c
index 14df4c8..5c567a2 100644
--- a/src/H5FAcache.c
+++ b/src/H5FAcache.c
@@ -76,21 +76,22 @@
/* Metadata cache (H5AC) callbacks */
static H5FA_hdr_t *H5FA__cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata);
static herr_t H5FA__cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5FA_hdr_t *hdr, unsigned * flags_ptr);
+static herr_t H5FA__cache_hdr_dest(H5F_t *f, H5FA_hdr_t *hdr);
static herr_t H5FA__cache_hdr_clear(H5F_t *f, H5FA_hdr_t *hdr, hbool_t destroy);
static herr_t H5FA__cache_hdr_size(const H5F_t *f, const H5FA_hdr_t *hdr, size_t *size_ptr);
-static herr_t H5FA__cache_hdr_dest(H5F_t *f, H5FA_hdr_t *hdr);
static H5FA_dblock_t *H5FA__cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata);
static herr_t H5FA__cache_dblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5FA_dblock_t *dblock, unsigned * flags_ptr);
+static herr_t H5FA__cache_dblock_dest(H5F_t *f, H5FA_dblock_t *dblock);
static herr_t H5FA__cache_dblock_clear(H5F_t *f, H5FA_dblock_t *dblock, hbool_t destroy);
+static herr_t H5FA__cache_dblock_notify(H5AC_notify_action_t action, H5FA_dblock_t *dblock);
static herr_t H5FA__cache_dblock_size(const H5F_t *f, const H5FA_dblock_t *dblock, size_t *size_ptr);
-static herr_t H5FA__cache_dblock_dest(H5F_t *f, H5FA_dblock_t *dblock);
static H5FA_dblk_page_t *H5FA__cache_dblk_page_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata);
static herr_t H5FA__cache_dblk_page_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5FA_dblk_page_t *dblk_page, unsigned * flags_ptr);
+static herr_t H5FA__cache_dblk_page_dest(H5F_t *f, H5FA_dblk_page_t *dblk_page);
static herr_t H5FA__cache_dblk_page_clear(H5F_t *f, H5FA_dblk_page_t *dblk_page, hbool_t destroy);
static herr_t H5FA__cache_dblk_page_size(const H5F_t *f, const H5FA_dblk_page_t *dblk_page, size_t *size_ptr);
-static herr_t H5FA__cache_dblk_page_dest(H5F_t *f, H5FA_dblk_page_t *dblk_page);
/*********************/
@@ -116,7 +117,7 @@ const H5AC_class_t H5AC_FARRAY_DBLOCK[1] = {{
(H5AC_flush_func_t)H5FA__cache_dblock_flush,
(H5AC_dest_func_t)H5FA__cache_dblock_dest,
(H5AC_clear_func_t)H5FA__cache_dblock_clear,
- (H5AC_notify_func_t)NULL,
+ (H5AC_notify_func_t)H5FA__cache_dblock_notify,
(H5AC_size_func_t)H5FA__cache_dblock_size,
}};
@@ -377,6 +378,53 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_flush() */
/*-------------------------------------------------------------------------
+ * Function: H5FA__cache_hdr_dest
+ *
+ * Purpose: Destroys a fixed array header in memory.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Vailin Choi
+ * Thursday, April 30, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+/* ARGSUSED */
+BEGIN_FUNC(STATIC, ERR,
+herr_t, SUCCEED, FAIL,
+H5FA__cache_hdr_dest(H5F_t *f, H5FA_hdr_t *hdr))
+
+ /* Check arguments */
+ HDassert(f);
+ HDassert(hdr);
+
+ /* Verify that header is clean */
+ HDassert(hdr->cache_info.is_dirty == FALSE);
+
+ /* If we're going to free the space on disk, the address must be valid */
+ HDassert(!hdr->cache_info.free_file_space_on_destroy || H5F_addr_defined(hdr->cache_info.addr));
+
+ /* Check for freeing file space for fixed array header */
+ if(hdr->cache_info.free_file_space_on_destroy) {
+ /* Sanity check address */
+ HDassert(H5F_addr_eq(hdr->addr, hdr->cache_info.addr));
+
+ /* Release the space on disk */
+ /* (XXX: Nasty usage of internal DXPL value! -QAK) */
+ if(H5MF_xfree(f, H5FD_MEM_FARRAY_HDR, H5AC_dxpl_id, hdr->cache_info.addr, (hsize_t)hdr->size) < 0)
+ H5E_THROW(H5E_CANTFREE, "unable to free fixed array header")
+ } /* end if */
+
+ /* Release the fixed array header */
+ if(H5FA__hdr_dest(hdr) < 0)
+ H5E_THROW(H5E_CANTFREE, "can't free fixed array header")
+
+CATCH
+
+END_FUNC(STATIC) /* end H5FA__cache_hdr_dest() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5FA__cache_hdr_clear
*
* Purpose: Mark a fixed array header in memory as non-dirty.
@@ -439,53 +487,6 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_size() */
/*-------------------------------------------------------------------------
- * Function: H5FA__cache_hdr_dest
- *
- * Purpose: Destroys a fixed array header in memory.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Vailin Choi
- * Thursday, April 30, 2009
- *
- *-------------------------------------------------------------------------
- */
-/* ARGSUSED */
-BEGIN_FUNC(STATIC, ERR,
-herr_t, SUCCEED, FAIL,
-H5FA__cache_hdr_dest(H5F_t *f, H5FA_hdr_t *hdr))
-
- /* Check arguments */
- HDassert(f);
- HDassert(hdr);
-
- /* Verify that header is clean */
- HDassert(hdr->cache_info.is_dirty == FALSE);
-
- /* If we're going to free the space on disk, the address must be valid */
- HDassert(!hdr->cache_info.free_file_space_on_destroy || H5F_addr_defined(hdr->cache_info.addr));
-
- /* Check for freeing file space for fixed array header */
- if(hdr->cache_info.free_file_space_on_destroy) {
- /* Sanity check address */
- HDassert(H5F_addr_eq(hdr->addr, hdr->cache_info.addr));
-
- /* Release the space on disk */
- /* (XXX: Nasty usage of internal DXPL value! -QAK) */
- if(H5MF_xfree(f, H5FD_MEM_FARRAY_HDR, H5AC_dxpl_id, hdr->cache_info.addr, (hsize_t)hdr->size) < 0)
- H5E_THROW(H5E_CANTFREE, "unable to free fixed array header")
- } /* end if */
-
- /* Release the fixed array header */
- if(H5FA__hdr_dest(hdr) < 0)
- H5E_THROW(H5E_CANTFREE, "can't free fixed array header")
-
-CATCH
-
-END_FUNC(STATIC) /* end H5FA__cache_hdr_dest() */
-
-
-/*-------------------------------------------------------------------------
* Function: H5FA__cache_dblock_load
*
* Purpose: Loads a fixed array data block from the disk.
@@ -724,6 +725,54 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_flush() */
/*-------------------------------------------------------------------------
+ * Function: H5FA__cache_dblock_dest
+ *
+ * Purpose: Destroys a fixed array data block in memory.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Vailin Choi
+ * Thursday, April 30, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+/* ARGSUSED */
+BEGIN_FUNC(STATIC, ERR,
+herr_t, SUCCEED, FAIL,
+H5FA__cache_dblock_dest(H5F_t *f, H5FA_dblock_t *dblock))
+
+ /* Sanity check */
+ HDassert(f);
+ HDassert(dblock);
+
+ /* Verify that data block is clean */
+ HDassert(dblock->cache_info.is_dirty == FALSE);
+
+ /* If we're going to free the space on disk, the address must be valid */
+ HDassert(!dblock->cache_info.free_file_space_on_destroy || H5F_addr_defined(dblock->cache_info.addr));
+
+ /* Check for freeing file space for fixed array data block */
+ if(dblock->cache_info.free_file_space_on_destroy) {
+ /* Sanity check address */
+ HDassert(H5F_addr_eq(dblock->addr, dblock->cache_info.addr));
+
+ /* Release the space on disk */
+ /* (Includes space for pages!) */
+ /* (XXX: Nasty usage of internal DXPL value! -QAK) */
+ if(H5MF_xfree(f, H5FD_MEM_FARRAY_DBLOCK, H5AC_dxpl_id, dblock->cache_info.addr, (hsize_t)dblock->size) < 0)
+ H5E_THROW(H5E_CANTFREE, "unable to free fixed array data block")
+ } /* end if */
+
+ /* Release the data block */
+ if(H5FA__dblock_dest(dblock) < 0)
+ H5E_THROW(H5E_CANTFREE, "can't free fixed array data block")
+
+CATCH
+
+END_FUNC(STATIC) /* end H5FA__cache_dblock_dest() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5FA__cache_dblock_clear
*
* Purpose: Mark a fixed array data block in memory as non-dirty.
@@ -755,6 +804,56 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_clear() */
/*-------------------------------------------------------------------------
+ * Function: H5FA__cache_dblock_notify
+ *
+ * Purpose: Handle cache action notifications
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Dana Robinson
+ * derobins@hdfgroup.org
+ * Fall 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+BEGIN_FUNC(STATIC, ERR,
+herr_t, SUCCEED, FAIL,
+H5FA__cache_dblock_notify(H5AC_notify_action_t action, H5FA_dblock_t *dblock))
+
+ /* Sanity check */
+ HDassert(dblock);
+
+ /* Check if the file was opened with SWMR-write access */
+ if(dblock->hdr->swmr_write) {
+ /* Determine which action to take */
+ switch(action) {
+ case H5AC_NOTIFY_ACTION_AFTER_INSERT:
+ /* Create flush dependency on extensible array header */
+ if(H5FA__create_flush_depend((H5AC_info_t *)dblock->hdr, (H5AC_info_t *)dblock) < 0)
+ H5E_THROW(H5E_CANTDEPEND, "unable to create flush dependency between data block and header, address = %llu", (unsigned long long)dblock->addr)
+ break;
+
+ case H5AC_NOTIFY_ACTION_BEFORE_EVICT:
+ /* Destroy flush dependency on extensible array header */
+ if(H5FA__destroy_flush_depend((H5AC_info_t *)dblock->hdr, (H5AC_info_t *)dblock) < 0)
+ H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between data block and header, address = %llu", (unsigned long long)dblock->addr)
+ break;
+
+ default:
+#ifdef NDEBUG
+ H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache")
+#else /* NDEBUG */
+ HDassert(0 && "Unknown action?!?");
+#endif /* NDEBUG */
+ } /* end switch */
+ } /* end if */
+
+CATCH
+
+END_FUNC(STATIC) /* end H5FA__cache_dblock_notify() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5FA__cache_dblock_size
*
* Purpose: Compute the size in bytes of a fixed array data block
@@ -789,54 +888,6 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_size() */
/*-------------------------------------------------------------------------
- * Function: H5FA__cache_dblock_dest
- *
- * Purpose: Destroys a fixed array data block in memory.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Vailin Choi
- * Thursday, April 30, 2009
- *
- *-------------------------------------------------------------------------
- */
-/* ARGSUSED */
-BEGIN_FUNC(STATIC, ERR,
-herr_t, SUCCEED, FAIL,
-H5FA__cache_dblock_dest(H5F_t *f, H5FA_dblock_t *dblock))
-
- /* Sanity check */
- HDassert(f);
- HDassert(dblock);
-
- /* Verify that data block is clean */
- HDassert(dblock->cache_info.is_dirty == FALSE);
-
- /* If we're going to free the space on disk, the address must be valid */
- HDassert(!dblock->cache_info.free_file_space_on_destroy || H5F_addr_defined(dblock->cache_info.addr));
-
- /* Check for freeing file space for fixed array data block */
- if(dblock->cache_info.free_file_space_on_destroy) {
- /* Sanity check address */
- HDassert(H5F_addr_eq(dblock->addr, dblock->cache_info.addr));
-
- /* Release the space on disk */
- /* (Includes space for pages!) */
- /* (XXX: Nasty usage of internal DXPL value! -QAK) */
- if(H5MF_xfree(f, H5FD_MEM_FARRAY_DBLOCK, H5AC_dxpl_id, dblock->cache_info.addr, (hsize_t)dblock->size) < 0)
- H5E_THROW(H5E_CANTFREE, "unable to free fixed array data block")
- } /* end if */
-
- /* Release the data block */
- if(H5FA__dblock_dest(dblock) < 0)
- H5E_THROW(H5E_CANTFREE, "can't free fixed array data block")
-
-CATCH
-
-END_FUNC(STATIC) /* end H5FA__cache_dblock_dest() */
-
-
-/*-------------------------------------------------------------------------
* Function: H5FA__cache_dblk_page_load
*
* Purpose: Loads a fixed array data block page from the disk.
@@ -1024,6 +1075,42 @@ END_FUNC(STATIC) /* end H5FA__cache_dblk_page_flush() */
/*-------------------------------------------------------------------------
+ * Function: H5FA__cache_dblk_page_dest
+ *
+ * Purpose: Destroys a fixed array data block page in memory.
+ *
+ * Note: Does _not_ free the space for the page on disk, that is
+ * handled through the data block that "owns" the page.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Vailin Choi
+ * Thursday, April 30, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+/* ARGSUSED */
+BEGIN_FUNC(STATIC, ERR,
+herr_t, SUCCEED, FAIL,
+H5FA__cache_dblk_page_dest(H5F_t UNUSED *f, H5FA_dblk_page_t *dblk_page))
+
+ /* Sanity check */
+ HDassert(f);
+ HDassert(dblk_page);
+
+ /* Verify that data block page is clean */
+ HDassert(dblk_page->cache_info.is_dirty == FALSE);
+
+ /* Release the data block page */
+ if(H5FA__dblk_page_dest(dblk_page) < 0)
+ H5E_THROW(H5E_CANTFREE, "can't free fixed array data block page")
+
+CATCH
+
+END_FUNC(STATIC) /* end H5FA__cache_dblk_page_dest() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5FA__cache_dblk_page_clear
*
* Purpose: Mark a fixed array data block page in memory as non-dirty.
@@ -1083,40 +1170,3 @@ H5FA__cache_dblk_page_size(const H5F_t UNUSED *f, const H5FA_dblk_page_t *dblk_p
*size_ptr = dblk_page->size;
END_FUNC(STATIC) /* end H5FA__cache_dblk_page_size() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5FA__cache_dblk_page_dest
- *
- * Purpose: Destroys a fixed array data block page in memory.
- *
- * Note: Does _not_ free the space for the page on disk, that is
- * handled through the data block that "owns" the page.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Vailin Choi
- * Thursday, April 30, 2009
- *
- *-------------------------------------------------------------------------
- */
-/* ARGSUSED */
-BEGIN_FUNC(STATIC, ERR,
-herr_t, SUCCEED, FAIL,
-H5FA__cache_dblk_page_dest(H5F_t UNUSED *f, H5FA_dblk_page_t *dblk_page))
-
- /* Sanity check */
- HDassert(f);
- HDassert(dblk_page);
-
- /* Verify that data block page is clean */
- HDassert(dblk_page->cache_info.is_dirty == FALSE);
-
- /* Release the data block page */
- if(H5FA__dblk_page_dest(dblk_page) < 0)
- H5E_THROW(H5E_CANTFREE, "can't free fixed array data block page")
-
-CATCH
-
-END_FUNC(STATIC) /* end H5FA__cache_dblk_page_dest() */
-