summaryrefslogtreecommitdiffstats
path: root/src/H5FScache.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-05-27 13:10:28 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-05-27 13:10:28 (GMT)
commit037c318770490c07f23e30af26353b68dbf712c0 (patch)
treee1fb9a5233047824bc1405e099e8f85f2e8faf4b /src/H5FScache.c
parent6a183ca20ce41b70feae9a52a4e04913d276be34 (diff)
downloadhdf5-037c318770490c07f23e30af26353b68dbf712c0.zip
hdf5-037c318770490c07f23e30af26353b68dbf712c0.tar.gz
hdf5-037c318770490c07f23e30af26353b68dbf712c0.tar.bz2
[svn-r18910] Description:
Remove 'size' parameter from H5AC2_set()/H5C2_insert_entry(), to align better with trunk. Use the 'image_len' cache client callback to retrieve the size of an inserted entry. Also, add flags to the cache client class structure, to indicate several client behaviors: speculative loads & compressed storage on disk (which were previously dependent on the 'image_len' callback only being used to detect size changes during load (deserialize) operations). Tested on: Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode Mac OS X/32 10.6.3 (amazon) in debug mode Mac OS X/32 10.6.3 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
Diffstat (limited to 'src/H5FScache.c')
-rw-r--r--src/H5FScache.c87
1 files changed, 72 insertions, 15 deletions
diff --git a/src/H5FScache.c b/src/H5FScache.c
index 8d3ae88..68addce 100644
--- a/src/H5FScache.c
+++ b/src/H5FScache.c
@@ -78,6 +78,7 @@ static herr_t H5FS_sinfo_serialize_node_cb(void *_item, void UNUSED *key, void *
static herr_t H5FS_cache_hdr_get_load_size(const void *udata, size_t *image_len);
static void *H5FS_cache_hdr_deserialize(const void *image, size_t len,
void *udata, hbool_t *dirty);
+static herr_t H5FS_cache_hdr_image_len(const void *thing, size_t *image_len);
static herr_t H5FS_cache_hdr_serialize(const H5F_t *f, hid_t dxpl_id,
haddr_t addr, size_t len, void *image, void *thing, unsigned *flags,
haddr_t *new_addr, size_t *new_len, void **new_image);
@@ -86,6 +87,7 @@ static herr_t H5FS_cache_hdr_free_icr(void *thing);
static herr_t H5FS_cache_sinfo_get_load_size(const void *udata, size_t *image_len);
static void *H5FS_cache_sinfo_deserialize(const void *image, size_t len,
void *udata, hbool_t *dirty);
+static herr_t H5FS_cache_sinfo_image_len(const void *thing, size_t *image_len);
static herr_t H5FS_cache_sinfo_serialize(const H5F_t *f, hid_t dxpl_id,
haddr_t addr, size_t len, void *image, void *thing, unsigned *flags,
haddr_t *new_addr, size_t *new_len, void **new_image);
@@ -101,9 +103,10 @@ const H5AC_class_t H5AC_FSPACE_HDR[1] = {{
H5AC_FSPACE_HDR_ID,
"Free space header",
H5FD_MEM_FSPACE_HDR,
+ H5AC__CLASS_NO_FLAGS_SET,
H5FS_cache_hdr_get_load_size,
H5FS_cache_hdr_deserialize,
- NULL,
+ H5FS_cache_hdr_image_len,
H5FS_cache_hdr_serialize,
H5FS_cache_hdr_free_icr,
}};
@@ -113,9 +116,10 @@ const H5AC_class_t H5AC_FSPACE_SINFO[1] = {{
H5AC_FSPACE_SINFO_ID,
"Free space section info",
H5FD_MEM_FSPACE_SINFO,
+ H5AC__CLASS_NO_FLAGS_SET,
H5FS_cache_sinfo_get_load_size,
H5FS_cache_sinfo_deserialize,
- NULL,
+ H5FS_cache_sinfo_image_len,
H5FS_cache_sinfo_serialize,
H5FS_cache_sinfo_free_icr,
}};
@@ -183,7 +187,6 @@ H5FS_cache_hdr_deserialize(const void *image, size_t UNUSED len,
{
H5FS_t *fspace = NULL; /* Free space header info */
H5FS_hdr_cache_ud_t *udata = (H5FS_hdr_cache_ud_t *)_udata; /* user data for callback */
- size_t size; /* Header size */
const uint8_t *p; /* Pointer into raw data buffer */
uint32_t stored_chksum; /* Stored metadata checksum value */
uint32_t computed_chksum; /* Computed metadata checksum value */
@@ -197,15 +200,12 @@ H5FS_cache_hdr_deserialize(const void *image, size_t UNUSED len,
HDassert(udata);
/* Allocate a new free space manager */
- if(NULL == (fspace = H5FS_new(udata->fs_prot->nclasses, udata->fs_prot->classes, udata->fs_prot->cls_init_udata)))
+ if(NULL == (fspace = H5FS_new(udata->f, udata->fs_prot->nclasses, udata->fs_prot->classes, udata->fs_prot->cls_init_udata)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Set free space manager's internal information */
fspace->addr = udata->addr;
- /* Compute the size of the free space header on disk */
- size = H5FS_HEADER_SIZE(udata->f);
-
p = (const uint8_t *)image;
/* Magic number */
@@ -288,6 +288,37 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5FS_cache_hdr_image_len
+ *
+ * Purpose: Compute the size of the data structure on disk.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * May 20, 2010
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5FS_cache_hdr_image_len(const void *_thing, size_t *image_len)
+{
+ H5FS_t *fspace = (H5FS_t *)_thing; /* Pointer to free space header */
+
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FS_cache_hdr_image_len)
+
+ /* Check arguments */
+ HDassert(fspace);
+ HDassert(image_len);
+
+ /* Set the image length size */
+ *image_len = fspace->hdr_size;
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5FS_cache_hdr_image_len() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5FS_cache_hdr_serialize
*
* Purpose: Serializes the data structure for writing to disk.
@@ -309,7 +340,6 @@ H5FS_cache_hdr_serialize(const H5F_t *f, hid_t UNUSED dxpl_id,
H5FS_t *fspace = (H5FS_t *)_thing; /* Pointer to free space header */
uint8_t *p; /* Pointer into raw data buffer */
uint32_t metadata_chksum; /* Computed metadata checksum value */
- size_t size; /* Header size on disk */
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FS_cache_hdr_serialize)
@@ -319,9 +349,6 @@ H5FS_cache_hdr_serialize(const H5F_t *f, hid_t UNUSED dxpl_id,
HDassert(fspace);
HDassert(flags);
- /* Compute the size of the free space header on disk */
- size = H5FS_HEADER_SIZE(f);
-
/* Get temporary pointer to header */
p = (uint8_t *)image;
@@ -713,6 +740,37 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5FS_cache_sinfo_image_len
+ *
+ * Purpose: Compute the size of the data structure on disk.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * May 20, 2010
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5FS_cache_sinfo_image_len(const void *_thing, size_t *image_len)
+{
+ H5FS_sinfo_t *sinfo = (H5FS_sinfo_t *)_thing;
+
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FS_cache_sinfo_image_len)
+
+ /* Check arguments */
+ HDassert(sinfo);
+ HDassert(image_len);
+
+ /* Set the image length size */
+ *image_len = sinfo->fspace->alloc_sect_size;
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5FS_cache_sinfo_image_len() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5FS_cache_sinfo_serialize
*
* Purpose: Serialize the data structure for writing to disk.
@@ -730,12 +788,12 @@ H5FS_cache_sinfo_serialize(const H5F_t * f, hid_t UNUSED dxpl_id, haddr_t UNUSED
size_t UNUSED len, void *image, void *_thing, unsigned *flags,
haddr_t UNUSED *new_addr, size_t UNUSED *new_len, void UNUSED **new_image)
{
- H5FS_sinfo_t * sinfo = (H5FS_sinfo_t *)_thing;
+ H5FS_sinfo_t *sinfo = (H5FS_sinfo_t *)_thing; /* Pointer to section info */
H5FS_iter_ud_t udata; /* User data for callbacks */
uint8_t *p; /* Pointer into raw data buffer */
uint32_t metadata_chksum; /* Computed metadata checksum value */
unsigned bin; /* Current bin we are on */
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5FS_cache_sinfo_serialize)
@@ -751,8 +809,7 @@ H5FS_cache_sinfo_serialize(const H5F_t * f, hid_t UNUSED dxpl_id, haddr_t UNUSED
if(H5F_addr_ne(addr, sinfo->fspace->sect_addr))
HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, FAIL, "incorrect address for free space sections")
- /* Allocate temporary buffer */
-
+ /* Point to disk image buffer */
p = (uint8_t *)image;
/* Magic number */