summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5FA.c22
-rw-r--r--src/H5FAcache.c19
-rw-r--r--src/H5FAdbg.c74
-rw-r--r--src/H5FAhdr.c4
-rw-r--r--src/H5FApkg.h1
-rw-r--r--src/H5FAprivate.h2
-rw-r--r--src/H5FAtest.c3
7 files changed, 56 insertions, 69 deletions
diff --git a/src/H5FA.c b/src/H5FA.c
index a8cd36b..7d6a136 100644
--- a/src/H5FA.c
+++ b/src/H5FA.c
@@ -361,16 +361,16 @@ HDfprintf(stderr, "%s: fixed array data block address not defined!\n", FUNC, idx
else { /* paging */
size_t page_idx; /* Index of page within data block */
size_t dblk_page_nelmts; /* # of elements in a data block page */
- hsize_t elmt_idx; /* Element index within the page */
+ size_t elmt_idx; /* Element index within the page */
haddr_t dblk_page_addr; /* Address of data block page */
/* Compute the page & element index */
- page_idx = (size_t)idx / dblock->dblk_page_nelmts;
- elmt_idx = (size_t)idx % dblock->dblk_page_nelmts;
+ page_idx = (size_t)(idx / dblock->dblk_page_nelmts);
+ elmt_idx = (size_t)(idx % dblock->dblk_page_nelmts);
/* Get the address of the data block page */
dblk_page_addr = dblock->addr + H5FA_DBLOCK_PREFIX_SIZE(dblock) +
- (page_idx * dblock->dblk_page_size);
+ ((hsize_t)page_idx * dblock->dblk_page_size);
/* Check for using last page, to set the number of elements on the page */
if((page_idx + 1) == dblock->npages)
@@ -378,7 +378,7 @@ HDfprintf(stderr, "%s: fixed array data block address not defined!\n", FUNC, idx
else
dblk_page_nelmts = dblock->dblk_page_nelmts;
- /* Check if the page has been create yet */
+ /* Check if the page has been created yet */
if(!H5V_bit_get(dblock->dblk_page_init, page_idx)) {
/* Create the data block page */
if(H5FA__dblk_page_create(hdr, dxpl_id, dblk_page_addr, dblk_page_nelmts) < 0)
@@ -468,7 +468,7 @@ HDfprintf(stderr, "%s: Index %Hu\n", FUNC, idx);
size_t page_idx; /* Index of page within data block */
/* Compute the page index */
- page_idx = (size_t)idx / dblock->dblk_page_nelmts;
+ page_idx = (size_t)(idx / dblock->dblk_page_nelmts);
/* Check if the page is defined yet */
if(!H5V_bit_get(dblock->dblk_page_init, page_idx)) {
@@ -480,15 +480,15 @@ HDfprintf(stderr, "%s: Index %Hu\n", FUNC, idx);
H5_LEAVE(SUCCEED)
} /* end if */
else { /* get the page */
- hsize_t elmt_idx; /* Element index within the page */
- haddr_t dblk_page_addr; /* Address of data block page */
- size_t dblk_page_nelmts; /* # of elements in a data block page */
+ size_t dblk_page_nelmts; /* # of elements in a data block page */
+ size_t elmt_idx; /* Element index within the page */
+ haddr_t dblk_page_addr; /* Address of data block page */
/* Compute the element index */
- elmt_idx = (size_t)idx % dblock->dblk_page_nelmts;
+ elmt_idx = (size_t)(idx % dblock->dblk_page_nelmts);
/* Compute the address of the data block */
- dblk_page_addr = dblock->addr + H5FA_DBLOCK_PREFIX_SIZE(dblock) + (page_idx * dblock->dblk_page_size);
+ dblk_page_addr = dblock->addr + H5FA_DBLOCK_PREFIX_SIZE(dblock) + ((hsize_t)page_idx * dblock->dblk_page_size);
/* Check for using last page, to set the number of elements on the page */
if((page_idx + 1) == dblock->npages)
diff --git a/src/H5FAcache.c b/src/H5FAcache.c
index 7a7e867..59a81e2 100644
--- a/src/H5FAcache.c
+++ b/src/H5FAcache.c
@@ -230,6 +230,25 @@ H5FA__cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_cls,
hdr->stats.nelmts = hdr->cparam.nelmts;
hdr->stats.hdr_size = hdr->size = size; /* Size of header in file */
+ /* Check for data block */
+ if(H5F_addr_defined(hdr->dblk_addr)) {
+ H5FA_dblock_t dblock; /* Fake data block for computing size */
+ size_t dblk_page_nelmts; /* # of elements per data block page */
+
+ /* Set up fake data block for computing size on disk */
+ dblock.hdr = hdr;
+ dblock.dblk_page_init_size = 0;
+ dblock.npages = 0;
+ dblk_page_nelmts = (size_t)1 << hdr->cparam.max_dblk_page_nelmts_bits;
+ if(hdr->cparam.nelmts > dblk_page_nelmts) {
+ dblock.npages = (size_t)(((hdr->cparam.nelmts + dblk_page_nelmts) - 1) / dblk_page_nelmts);
+ dblock.dblk_page_init_size = (dblock.npages + 7) / 8;
+ } /* end if */
+
+ /* Compute Fixed Array data block size for hdr statistics */
+ hdr->stats.dblk_size = (size_t)H5FA_DBLOCK_SIZE(&dblock);
+ } /* end if */
+
/* Sanity check */
/* (allow for checksum not decoded yet) */
HDassert((size_t)(p - buf) == (size - H5FA_SIZEOF_CHKSUM));
diff --git a/src/H5FAdbg.c b/src/H5FAdbg.c
index b882c04..c1aa3d4 100644
--- a/src/H5FAdbg.c
+++ b/src/H5FAdbg.c
@@ -53,13 +53,6 @@
/* Local Typedefs */
/******************/
-/* Fixed array create/open user data */
-typedef struct ctx_ud_t {
- const H5F_t *f; /* Pointer to file info */
- const H5O_layout_t *layout; /* Pointer to layout info */
-} ctx_ud_t;
-
-
/********************/
/* Package Typedefs */
/********************/
@@ -105,9 +98,7 @@ H5FA__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
/* Local variables */
H5FA_hdr_t *hdr = NULL; /* Shared fixed array header */
- H5O_loc_t obj_loc; /* Pointer to an object's location */
- H5O_layout_t layout; /* Layout message */
- ctx_ud_t udata; /* User data */
+ void *dbg_ctx = NULL; /* Fixed array debugging context */
/* Check arguments */
HDassert(f);
@@ -118,28 +109,15 @@ H5FA__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
HDassert(fwidth >= 0);
HDassert(cls);
- H5O_loc_reset(&obj_loc);
- obj_loc.file = f;
- obj_loc.addr = obj_addr;
-
- /* Open the object header where the layout message resides */
- if(H5O_open(&obj_loc) < 0)
- H5E_THROW(H5E_CANTPROTECT, "unable to open object header")
-
- /* Read the layout message */
- if(NULL == H5O_msg_read(&obj_loc, H5O_LAYOUT_ID, &layout, dxpl_id))
- H5E_THROW(H5E_CANTPROTECT, "unable to read layout message")
-
- /* close the object header */
- if(H5O_close(&obj_loc) < 0)
- H5E_THROW(H5E_CANTPROTECT, "unable to close object header")
-
- /* Create user data */
- udata.f = f;
- udata.layout = &layout;
+ /* Check for debugging context callback available */
+ if(cls->crt_dbg_ctx) {
+ /* Create debugging context */
+ if(NULL == (dbg_ctx = cls->crt_dbg_ctx(f, dxpl_id, obj_addr)))
+ H5E_THROW(H5E_CANTGET, "unable to create fixed array debugging context")
+ } /* end if */
/* Load the fixed array header */
- if(NULL == (hdr = (H5FA_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_FARRAY_HDR, addr, cls, &udata, H5AC_READ)))
+ if(NULL == (hdr = (H5FA_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_FARRAY_HDR, addr, cls, dbg_ctx, H5AC_READ)))
H5E_THROW(H5E_CANTPROTECT, "unable to load fixed array header")
/* Print opening message */
@@ -170,6 +148,8 @@ H5FA__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
"Fixed Array Data Block Address:", hdr->dblk_addr);
CATCH
+ if(dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0)
+ H5E_THROW(H5E_CANTRELEASE, "unable to release fixed array debugging context")
if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_FARRAY_HDR, addr, hdr, H5AC__NO_FLAGS_SET) < 0)
H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header")
@@ -197,10 +177,8 @@ H5FA__dblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int inde
/* Local variables */
H5FA_hdr_t *hdr = NULL; /* Shared fixed array header */
H5FA_dblock_t *dblock = NULL; /* Fixed array data block */
+ void *dbg_ctx = NULL; /* Fixed array context */
size_t u; /* Local index variable */
- H5O_loc_t obj_loc; /* Pointer to an object's location */
- H5O_layout_t layout; /* Layout message */
- ctx_ud_t udata; /* User data */
/* Check arguments */
HDassert(f);
@@ -212,28 +190,15 @@ H5FA__dblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int inde
HDassert(H5F_addr_defined(hdr_addr));
HDassert(H5F_addr_defined(obj_addr));
- H5O_loc_reset(&obj_loc);
- obj_loc.file = f;
- obj_loc.addr = obj_addr;
-
- /* Open the object header where the layout message resides */
- if(H5O_open(&obj_loc) < 0)
- H5E_THROW(H5E_CANTPROTECT, "unable to open object header")
-
- /* Read the layout message */
- if(NULL == H5O_msg_read(&obj_loc, H5O_LAYOUT_ID, &layout, dxpl_id))
- H5E_THROW(H5E_CANTPROTECT, "unable to read layout message")
-
- /* close the object header */
- if(H5O_close(&obj_loc) < 0)
- H5E_THROW(H5E_CANTPROTECT, "unable to close object header")
-
- /* Create user data */
- udata.f = f;
- udata.layout = &layout;
+ /* Check for debugging context callback available */
+ if(cls->crt_dbg_ctx) {
+ /* Create debugging context */
+ if(NULL == (dbg_ctx = cls->crt_dbg_ctx(f, dxpl_id, obj_addr)))
+ H5E_THROW(H5E_CANTGET, "unable to create fixed array debugging context")
+ } /* end if */
/* Load the fixed array header */
- if(NULL == (hdr = (H5FA_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_FARRAY_HDR, hdr_addr, cls, &udata, H5AC_READ)))
+ if(NULL == (hdr = (H5FA_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_FARRAY_HDR, hdr_addr, cls, dbg_ctx, H5AC_READ)))
H5E_THROW(H5E_CANTPROTECT, "unable to load fixed array header")
/* Protect data block */
@@ -243,7 +208,6 @@ H5FA__dblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int inde
/* Print opening message */
HDfprintf(stream, "%*sFixed Array data Block...\n", indent, "");
-
/* Print the values */
HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
"Array class ID:", hdr->cparam.cls->name);
@@ -312,6 +276,8 @@ H5FA__dblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int inde
} /* end else */
CATCH
+ if(dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0)
+ H5E_THROW(H5E_CANTRELEASE, "unable to release fixed array debugging context")
if(dblock && H5FA__dblock_unprotect(dblock, dxpl_id, H5AC__NO_FLAGS_SET) < 0)
H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block")
if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_FARRAY_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0)
diff --git a/src/H5FAhdr.c b/src/H5FAhdr.c
index 150742d..e6231d4 100644
--- a/src/H5FAhdr.c
+++ b/src/H5FAhdr.c
@@ -167,6 +167,10 @@ HDfprintf(stderr, "%s: Called\n", FUNC);
/* Check for valid parameters */
if(cparam->raw_elmt_size == 0)
H5E_THROW(H5E_BADVALUE, "element size must be greater than zero")
+ if(cparam->max_dblk_page_nelmts_bits == 0)
+ H5E_THROW(H5E_BADVALUE, "max. # of elements bits must be greater than zero")
+ if(cparam->nelmts == 0)
+ H5E_THROW(H5E_BADVALUE, "# of elements must be greater than zero")
}
#endif /* NDEBUG */
diff --git a/src/H5FApkg.h b/src/H5FApkg.h
index 16d2518..1ba8f84 100644
--- a/src/H5FApkg.h
+++ b/src/H5FApkg.h
@@ -203,7 +203,6 @@ typedef struct H5FA_dblk_page_load_ud_t {
} H5FA_dblk_page_load_ud_t;
-
/*****************************/
/* Package Private Variables */
/*****************************/
diff --git a/src/H5FAprivate.h b/src/H5FAprivate.h
index 2450218..16397fd 100644
--- a/src/H5FAprivate.h
+++ b/src/H5FAprivate.h
@@ -70,6 +70,8 @@ typedef struct H5FA_class_t {
herr_t (*encode)(void *raw, const void *elmt, size_t nelmts, void *ctx); /* Encode elements from native form to disk storage form */
herr_t (*decode)(const void *raw, void *elmt, size_t nelmts, void *ctx); /* Decode elements from disk storage form to native form */
herr_t (*debug)(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt); /* Print an element for debugging */
+ void *(*crt_dbg_ctx)(H5F_t *f, hid_t dxpl_id, haddr_t obj_addr); /* Create debugging context */
+ herr_t (*dst_dbg_ctx)(void *dbg_ctx); /* Destroy debugging context */
} H5FA_class_t;
/* Fixed array creation parameters */
diff --git a/src/H5FAtest.c b/src/H5FAtest.c
index c76c80b..70e21dc 100644
--- a/src/H5FAtest.c
+++ b/src/H5FAtest.c
@@ -134,9 +134,6 @@ H5FA__test_crt_context(void UNUSED *udata))
/* Local variables */
H5FA__test_ctx_t *ctx; /* Context for callbacks */
- /* Sanity checks */
- HDassert(udata);
-
/* Allocate new context structure */
if(NULL == (ctx = H5FL_MALLOC(H5FA__test_ctx_t)))
H5E_THROW(H5E_CANTALLOC, "can't allocate fixed array client callback context")