summaryrefslogtreecommitdiffstats
path: root/src/H5Distore.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Distore.c')
-rw-r--r--src/H5Distore.c491
1 files changed, 246 insertions, 245 deletions
diff --git a/src/H5Distore.c b/src/H5Distore.c
index 9fc906d..bcf384e 100644
--- a/src/H5Distore.c
+++ b/src/H5Distore.c
@@ -92,13 +92,13 @@
* Given a B-tree node return the dimensionality of the chunks pointed to by
* that node.
*/
-#define H5D_ISTORE_NDIMS(X) ((int)(((X)->sizeof_rkey-8)/8))
+#define H5D_ISTORE_NDIMS(X) (((X)->sizeof_rkey-8)/8)
/* Raw data chunks are cached. Each entry in the cache is: */
typedef struct H5D_rdcc_ent_t {
hbool_t locked; /*entry is locked in cache */
hbool_t dirty; /*needs to be written to disk? */
- hssize_t offset[H5O_LAYOUT_NDIMS]; /*chunk name */
+ hsize_t offset[H5O_LAYOUT_NDIMS]; /*chunk name */
size_t rd_count; /*bytes remaining to be read */
size_t wr_count; /*bytes remaining to be written */
size_t chunk_size; /*size of a chunk */
@@ -126,7 +126,7 @@ typedef H5D_rdcc_ent_t *H5D_rdcc_ent_ptr_t; /* For free lists */
*/
typedef struct H5D_istore_key_t {
size_t nbytes; /*size of stored data */
- hssize_t offset[H5O_LAYOUT_NDIMS]; /*logical offset to start*/
+ hsize_t offset[H5O_LAYOUT_NDIMS]; /*logical offset to start*/
unsigned filter_mask; /*excluded filters */
} H5D_istore_key_t;
@@ -148,16 +148,16 @@ static herr_t H5D_istore_shared_create (const H5F_t *f, H5O_layout_t *layout);
static herr_t H5D_istore_shared_free (void *page);
/* B-tree iterator callbacks */
-static int H5D_istore_iter_allocated(H5F_t *f, hid_t dxpl_id, void *left_key, haddr_t addr,
- void *right_key, void *_udata);
-static int H5D_istore_iter_dump(H5F_t *f, hid_t dxpl_id, void *left_key, haddr_t addr,
- void *right_key, void *_udata);
-static int H5D_istore_prune_extent(H5F_t *f, hid_t dxpl_id, void *_lt_key, haddr_t addr,
- void *_rt_key, void *_udata);
+static int H5D_istore_iter_allocated(H5F_t *f, hid_t dxpl_id, const void *left_key, haddr_t addr,
+ const void *right_key, void *_udata);
+static int H5D_istore_iter_dump(H5F_t *f, hid_t dxpl_id, const void *left_key, haddr_t addr,
+ const void *right_key, void *_udata);
+static int H5D_istore_prune_extent(H5F_t *f, hid_t dxpl_id, const void *_lt_key, haddr_t addr,
+ const void *_rt_key, void *_udata);
/* B-tree callbacks */
static size_t H5D_istore_sizeof_rkey(const H5F_t *f, const void *_udata);
-static H5RC_t *H5D_istore_get_shared(H5F_t *f, const void *_udata);
+static H5RC_t *H5D_istore_get_shared(const H5F_t *f, const void *_udata);
static herr_t H5D_istore_new_node(H5F_t *f, hid_t dxpl_id, H5B_ins_t, void *_lt_key,
void *_udata, void *_rt_key,
haddr_t *addr_p /*out*/);
@@ -166,7 +166,7 @@ static int H5D_istore_cmp2(H5F_t *f, hid_t dxpl_id, void *_lt_key, void *_udata,
static int H5D_istore_cmp3(H5F_t *f, hid_t dxpl_id, void *_lt_key, void *_udata,
void *_rt_key);
static herr_t H5D_istore_found(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_lt_key,
- void *_udata, const void *_rt_key);
+ void *_udata);
static H5B_ins_t H5D_istore_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key,
hbool_t *lt_key_changed, void *_md_key,
void *_udata, void *_rt_key,
@@ -175,9 +175,9 @@ static H5B_ins_t H5D_istore_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *
static H5B_ins_t H5D_istore_remove( H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key,
hbool_t *lt_key_changed, void *_udata, void *_rt_key,
hbool_t *rt_key_changed);
-static herr_t H5D_istore_decode_key(H5F_t *f, H5B_t *bt, uint8_t *raw,
+static herr_t H5D_istore_decode_key(const H5F_t *f, const H5B_t *bt, const uint8_t *raw,
void *_key);
-static herr_t H5D_istore_encode_key(H5F_t *f, H5B_t *bt, uint8_t *raw,
+static herr_t H5D_istore_encode_key(const H5F_t *f, const H5B_t *bt, uint8_t *raw,
void *_key);
static herr_t H5D_istore_debug_key(FILE *stream, H5F_t *f, hid_t dxpl_id,
int indent, int fwidth, const void *key,
@@ -240,13 +240,14 @@ H5FL_BLK_DEFINE_STATIC(chunk_page);
*
*-------------------------------------------------------------------------
*/
+/* ARGSUSED */
static size_t
H5D_istore_sizeof_rkey(const H5F_t UNUSED *f, const void *_udata)
{
const H5D_istore_ud1_t *udata = (const H5D_istore_ud1_t *) _udata;
size_t nbytes;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_sizeof_rkey);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_sizeof_rkey)
assert(udata);
assert(udata->mesg->u.chunk.ndims > 0 && udata->mesg->u.chunk.ndims <= H5O_LAYOUT_NDIMS);
@@ -255,7 +256,7 @@ H5D_istore_sizeof_rkey(const H5F_t UNUSED *f, const void *_udata)
4 + /*filter mask */
udata->mesg->u.chunk.ndims*8; /*dimension indices */
- FUNC_LEAVE_NOAPI(nbytes);
+ FUNC_LEAVE_NOAPI(nbytes)
} /* end H5D_istore_sizeof_rkey() */
@@ -275,12 +276,13 @@ H5D_istore_sizeof_rkey(const H5F_t UNUSED *f, const void *_udata)
*
*-------------------------------------------------------------------------
*/
+/* ARGSUSED */
static H5RC_t *
-H5D_istore_get_shared(H5F_t UNUSED *f, const void *_udata)
+H5D_istore_get_shared(const H5F_t UNUSED *f, const void *_udata)
{
const H5D_istore_ud1_t *udata = (const H5D_istore_ud1_t *) _udata;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_get_shared);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_get_shared)
assert(udata);
assert(udata->mesg);
@@ -290,7 +292,7 @@ H5D_istore_get_shared(H5F_t UNUSED *f, const void *_udata)
H5RC_INC(udata->mesg->u.chunk.btree_shared);
/* Return the pointer to the ref-count object */
- FUNC_LEAVE_NOAPI(udata->mesg->u.chunk.btree_shared);
+ FUNC_LEAVE_NOAPI(udata->mesg->u.chunk.btree_shared)
} /* end H5D_istore_get_shared() */
@@ -309,14 +311,14 @@ H5D_istore_get_shared(H5F_t UNUSED *f, const void *_udata)
*-------------------------------------------------------------------------
*/
static herr_t
-H5D_istore_decode_key(H5F_t UNUSED *f, H5B_t *bt, uint8_t *raw, void *_key)
+H5D_istore_decode_key(const H5F_t UNUSED *f, const H5B_t *bt, const uint8_t *raw, void *_key)
{
H5D_istore_key_t *key = (H5D_istore_key_t *) _key;
H5B_shared_t *shared; /* Pointer to shared B-tree info */
+ size_t ndims;
unsigned u;
- unsigned ndims;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_decode_key);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_decode_key)
/* check args */
assert(f);
@@ -334,7 +336,7 @@ H5D_istore_decode_key(H5F_t UNUSED *f, H5B_t *bt, uint8_t *raw, void *_key)
for (u=0; u<ndims; u++)
UINT64DECODE(raw, key->offset[u]);
- FUNC_LEAVE_NOAPI(SUCCEED);
+ FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5D_istore_decode_key() */
@@ -353,14 +355,14 @@ H5D_istore_decode_key(H5F_t UNUSED *f, H5B_t *bt, uint8_t *raw, void *_key)
*-------------------------------------------------------------------------
*/
static herr_t
-H5D_istore_encode_key(H5F_t UNUSED *f, H5B_t *bt, uint8_t *raw, void *_key)
+H5D_istore_encode_key(const H5F_t UNUSED *f, const H5B_t *bt, uint8_t *raw, void *_key)
{
H5D_istore_key_t *key = (H5D_istore_key_t *) _key;
H5B_shared_t *shared; /* Pointer to shared B-tree info */
- unsigned ndims;
+ size_t ndims;
unsigned u;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_encode_key);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_encode_key)
/* check args */
assert(f);
@@ -378,7 +380,7 @@ H5D_istore_encode_key(H5F_t UNUSED *f, H5B_t *bt, uint8_t *raw, void *_key)
for (u=0; u<ndims; u++)
UINT64ENCODE(raw, key->offset[u]);
- FUNC_LEAVE_NOAPI(SUCCEED);
+ FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5D_istore_encode_key() */
@@ -396,6 +398,7 @@ H5D_istore_encode_key(H5F_t UNUSED *f, H5B_t *bt, uint8_t *raw, void *_key)
*
*-------------------------------------------------------------------------
*/
+/* ARGSUSED */
static herr_t
H5D_istore_debug_key (FILE *stream, H5F_t UNUSED *f, hid_t UNUSED dxpl_id, int indent, int fwidth,
const void *_key, const void *_udata)
@@ -404,7 +407,7 @@ H5D_istore_debug_key (FILE *stream, H5F_t UNUSED *f, hid_t UNUSED dxpl_id, int i
const H5D_istore_ud1_t *udata = (const H5D_istore_ud1_t *)_udata;
unsigned u;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_debug_key);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_debug_key)
assert (key);
@@ -418,7 +421,7 @@ H5D_istore_debug_key (FILE *stream, H5F_t UNUSED *f, hid_t UNUSED dxpl_id, int i
HDfprintf (stream, "%s%Hd", u?", ":"", key->offset[u]);
HDfputs ("}\n", stream);
- FUNC_LEAVE_NOAPI(SUCCEED);
+ FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5D_istore_debug_key() */
@@ -443,6 +446,7 @@ H5D_istore_debug_key (FILE *stream, H5F_t UNUSED *f, hid_t UNUSED dxpl_id, int i
*
*-------------------------------------------------------------------------
*/
+/* ARGSUSED */
static int
H5D_istore_cmp2(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key, void *_udata,
void *_rt_key)
@@ -452,7 +456,7 @@ H5D_istore_cmp2(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key, void *_uda
H5D_istore_ud1_t *udata = (H5D_istore_ud1_t *) _udata;
int ret_value;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_cmp2);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_cmp2)
assert(lt_key);
assert(rt_key);
@@ -460,9 +464,9 @@ H5D_istore_cmp2(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key, void *_uda
assert(udata->mesg->u.chunk.ndims > 0 && udata->mesg->u.chunk.ndims <= H5O_LAYOUT_NDIMS);
/* Compare the offsets but ignore the other fields */
- ret_value = H5V_vector_cmp_s(udata->mesg->u.chunk.ndims, lt_key->offset, rt_key->offset);
+ ret_value = H5V_vector_cmp_u(udata->mesg->u.chunk.ndims, lt_key->offset, rt_key->offset);
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_istore_cmp2() */
@@ -495,6 +499,7 @@ H5D_istore_cmp2(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key, void *_uda
*
*-------------------------------------------------------------------------
*/
+/* ARGSUSED */
static int
H5D_istore_cmp3(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key, void *_udata,
void *_rt_key)
@@ -504,7 +509,7 @@ H5D_istore_cmp3(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key, void *_uda
H5D_istore_ud1_t *udata = (H5D_istore_ud1_t *) _udata;
int ret_value = 0;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_cmp3);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_cmp3)
assert(lt_key);
assert(rt_key);
@@ -527,15 +532,15 @@ H5D_istore_cmp3(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key, void *_uda
ret_value=(-1);
} /* end if */
else {
- if (H5V_vector_ge_s(udata->mesg->u.chunk.ndims, udata->key.offset,
+ if (H5V_vector_ge_u(udata->mesg->u.chunk.ndims, udata->key.offset,
rt_key->offset))
ret_value = 1;
- else if (H5V_vector_lt_s(udata->mesg->u.chunk.ndims, udata->key.offset,
+ else if (H5V_vector_lt_u(udata->mesg->u.chunk.ndims, udata->key.offset,
lt_key->offset))
ret_value = -1;
} /* end else */
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_istore_cmp3() */
@@ -570,7 +575,7 @@ H5D_istore_new_node(H5F_t *f, hid_t dxpl_id, H5B_ins_t op,
unsigned u;
herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5D_istore_new_node);
+ FUNC_ENTER_NOAPI_NOINIT(H5D_istore_new_node)
/* check args */
assert(f);
@@ -584,7 +589,7 @@ H5D_istore_new_node(H5F_t *f, hid_t dxpl_id, H5B_ins_t op,
assert (udata->key.nbytes > 0);
H5_CHECK_OVERFLOW( udata->key.nbytes ,size_t, hsize_t);
if (HADDR_UNDEF==(*addr_p=H5MF_alloc(f, H5FD_MEM_DRAW, dxpl_id, (hsize_t)udata->key.nbytes)))
- HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "couldn't allocate new file storage");
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "couldn't allocate new file storage")
udata->addr = *addr_p;
/*
@@ -604,15 +609,14 @@ H5D_istore_new_node(H5F_t *f, hid_t dxpl_id, H5B_ins_t op,
rt_key->nbytes = 0;
rt_key->filter_mask = 0;
for (u=0; u<udata->mesg->u.chunk.ndims; u++) {
- assert (udata->key.offset[u]+(hssize_t)(udata->mesg->u.chunk.dim[u]) >
+ assert (udata->key.offset[u]+udata->mesg->u.chunk.dim[u] >
udata->key.offset[u]);
- rt_key->offset[u] = udata->key.offset[u] +
- (hssize_t)(udata->mesg->u.chunk.dim[u]);
+ rt_key->offset[u] = udata->key.offset[u] + udata->mesg->u.chunk.dim[u];
}
}
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_istore_new_node() */
@@ -643,16 +647,17 @@ done:
* The ADDR argument is passed by value.
*-------------------------------------------------------------------------
*/
+/* ARGSUSED */
static herr_t
H5D_istore_found(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, haddr_t addr, const void *_lt_key,
- void *_udata, const void UNUSED *_rt_key)
+ void *_udata)
{
H5D_istore_ud1_t *udata = (H5D_istore_ud1_t *) _udata;
const H5D_istore_key_t *lt_key = (const H5D_istore_key_t *) _lt_key;
unsigned u;
herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_found);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_found)
/* Check arguments */
assert(f);
@@ -661,10 +666,9 @@ H5D_istore_found(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, haddr_t addr, const void
assert(lt_key);
/* Is this *really* the requested chunk? */
- for (u=0; u<udata->mesg->u.chunk.ndims; u++) {
- if (udata->key.offset[u] >= lt_key->offset[u]+(hssize_t)(udata->mesg->u.chunk.dim[u]))
- HGOTO_DONE(FAIL);
- }
+ for (u=0; u<udata->mesg->u.chunk.ndims; u++)
+ if (udata->key.offset[u] >= lt_key->offset[u]+udata->mesg->u.chunk.dim[u])
+ HGOTO_DONE(FAIL)
/* Initialize return values */
udata->addr = addr;
@@ -675,7 +679,7 @@ H5D_istore_found(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, haddr_t addr, const void
udata->key.offset[u] = lt_key->offset[u];
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_istore_found() */
@@ -711,6 +715,7 @@ done:
* is renamed NEW_NODE_P.
*-------------------------------------------------------------------------
*/
+/* ARGSUSED */
static H5B_ins_t
H5D_istore_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key,
hbool_t *lt_key_changed,
@@ -726,7 +731,7 @@ H5D_istore_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key,
unsigned u;
H5B_ins_t ret_value;
- FUNC_ENTER_NOAPI_NOINIT(H5D_istore_insert);
+ FUNC_ENTER_NOAPI_NOINIT(H5D_istore_insert)
/* check args */
assert(f);
@@ -736,7 +741,6 @@ H5D_istore_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key,
assert(md_key);
assert(udata);
assert(rt_key);
- assert(rt_key_changed);
assert(new_node_p);
cmp = H5D_istore_cmp3(f, dxpl_id, lt_key, udata, rt_key);
@@ -744,10 +748,9 @@ H5D_istore_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key,
if (cmp < 0) {
/* Negative indices not supported yet */
- assert("HDF5 INTERNAL ERROR -- see rpm" && 0);
- HGOTO_ERROR(H5E_STORAGE, H5E_UNSUPPORTED, H5B_INS_ERROR, "internal error");
+ HGOTO_ERROR(H5E_STORAGE, H5E_UNSUPPORTED, H5B_INS_ERROR, "internal error")
- } else if (H5V_vector_eq_s (udata->mesg->u.chunk.ndims,
+ } else if (H5V_vector_eq_u (udata->mesg->u.chunk.ndims,
udata->key.offset, lt_key->offset) &&
lt_key->nbytes>0) {
/*
@@ -767,14 +770,14 @@ H5D_istore_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key,
#ifdef OLD_WAY
if (HADDR_UNDEF==(*new_node_p=H5MF_realloc(f, H5FD_MEM_DRAW, addr,
(hsize_t)lt_key->nbytes, (hsize_t)udata->key.nbytes)))
- HGOTO_ERROR (H5E_STORAGE, H5E_NOSPACE, H5B_INS_ERROR, "unable to reallocate chunk storage");
+ HGOTO_ERROR (H5E_STORAGE, H5E_NOSPACE, H5B_INS_ERROR, "unable to reallocate chunk storage")
#else /* OLD_WAY */
H5_CHECK_OVERFLOW( lt_key->nbytes ,size_t, hsize_t);
if (H5MF_xfree(f, H5FD_MEM_DRAW, dxpl_id, addr, (hsize_t)lt_key->nbytes)<0)
- HGOTO_ERROR(H5E_STORAGE, H5E_CANTFREE, H5B_INS_ERROR, "unable to free chunk");
+ HGOTO_ERROR(H5E_STORAGE, H5E_CANTFREE, H5B_INS_ERROR, "unable to free chunk")
H5_CHECK_OVERFLOW( udata->key.nbytes ,size_t, hsize_t);
if (HADDR_UNDEF==(*new_node_p=H5MF_alloc(f, H5FD_MEM_DRAW, dxpl_id, (hsize_t)udata->key.nbytes)))
- HGOTO_ERROR(H5E_STORAGE, H5E_NOSPACE, H5B_INS_ERROR, "unable to reallocate chunk");
+ HGOTO_ERROR(H5E_STORAGE, H5E_NOSPACE, H5B_INS_ERROR, "unable to reallocate chunk")
#endif /* OLD_WAY */
lt_key->nbytes = udata->key.nbytes;
lt_key->filter_mask = udata->key.filter_mask;
@@ -808,17 +811,16 @@ H5D_istore_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key,
*/
H5_CHECK_OVERFLOW( udata->key.nbytes ,size_t, hsize_t);
if (HADDR_UNDEF==(*new_node_p=H5MF_alloc(f, H5FD_MEM_DRAW, dxpl_id, (hsize_t)udata->key.nbytes)))
- HGOTO_ERROR(H5E_STORAGE, H5E_NOSPACE, H5B_INS_ERROR, "file allocation failed");
+ HGOTO_ERROR(H5E_STORAGE, H5E_NOSPACE, H5B_INS_ERROR, "file allocation failed")
udata->addr = *new_node_p;
ret_value = H5B_INS_RIGHT;
} else {
- assert("HDF5 INTERNAL ERROR -- see rpm" && 0);
- HGOTO_ERROR(H5E_IO, H5E_UNSUPPORTED, H5B_INS_ERROR, "internal error");
+ HGOTO_ERROR(H5E_IO, H5E_UNSUPPORTED, H5B_INS_ERROR, "internal error")
}
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_istore_insert() */
@@ -842,18 +844,19 @@ done:
* Changed to callback from H5B_iterate
*-------------------------------------------------------------------------
*/
+/* ARGSUSED */
static int
-H5D_istore_iter_allocated (H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key, haddr_t UNUSED addr,
- void UNUSED *_rt_key, void *_udata)
+H5D_istore_iter_allocated (H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_lt_key, haddr_t UNUSED addr,
+ const void UNUSED *_rt_key, void *_udata)
{
H5D_istore_ud1_t *bt_udata = (H5D_istore_ud1_t *)_udata;
- H5D_istore_key_t *lt_key = (H5D_istore_key_t *)_lt_key;
+ const H5D_istore_key_t *lt_key = (const H5D_istore_key_t *)_lt_key;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_iter_allocated);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_iter_allocated)
bt_udata->total_storage += lt_key->nbytes;
- FUNC_LEAVE_NOAPI(H5B_ITER_CONT);
+ FUNC_LEAVE_NOAPI(H5B_ITER_CONT)
} /* H5D_istore_iter_allocated() */
@@ -878,15 +881,16 @@ H5D_istore_iter_allocated (H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key,
* Changed to callback from H5B_iterate
*-------------------------------------------------------------------------
*/
+/* ARGSUSED */
static int
-H5D_istore_iter_dump (H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key, haddr_t UNUSED addr,
- void UNUSED *_rt_key, void *_udata)
+H5D_istore_iter_dump (H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_lt_key, haddr_t UNUSED addr,
+ const void UNUSED *_rt_key, void *_udata)
{
H5D_istore_ud1_t *bt_udata = (H5D_istore_ud1_t *)_udata;
- H5D_istore_key_t *lt_key = (H5D_istore_key_t *)_lt_key;
+ const H5D_istore_key_t *lt_key = (const H5D_istore_key_t *)_lt_key;
unsigned u;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_iter_dump);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_iter_dump)
if (bt_udata->stream) {
if (0==bt_udata->total_storage) {
@@ -906,7 +910,7 @@ H5D_istore_iter_dump (H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key, hadd
bt_udata->total_storage++;
}
- FUNC_LEAVE_NOAPI(H5B_ITER_CONT);
+ FUNC_LEAVE_NOAPI(H5B_ITER_CONT)
} /* H5D_istore_iter_dump() */
@@ -926,26 +930,26 @@ H5D_istore_iter_dump (H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key, hadd
*-------------------------------------------------------------------------
*/
herr_t
-H5D_istore_init (const H5F_t *f, H5D_t *dset)
+H5D_istore_init (const H5F_t *f, const H5D_t *dset)
{
H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk);
herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5D_istore_init, FAIL);
+ FUNC_ENTER_NOAPI(H5D_istore_init, FAIL)
if (H5F_RDCC_NBYTES(f)>0 && H5F_RDCC_NELMTS(f)>0) {
rdcc->nbytes=H5F_RDCC_NBYTES(f);
rdcc->nslots = H5F_RDCC_NELMTS(f);
rdcc->slot = H5FL_SEQ_CALLOC (H5D_rdcc_ent_ptr_t,rdcc->nslots);
if (NULL==rdcc->slot)
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
} /* end if */
/* Allocate the shared structure */
if(H5D_istore_shared_create(f, &dset->shared->layout)<0)
HGOTO_ERROR (H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create wrapper for shared B-tree info")
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_istore_init() */
@@ -967,7 +971,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5D_istore_flush_entry(H5D_io_info_t *io_info, H5D_rdcc_ent_t *ent, hbool_t reset)
+H5D_istore_flush_entry(const H5D_io_info_t *io_info, H5D_rdcc_ent_t *ent, hbool_t reset)
{
herr_t ret_value=SUCCEED; /*return value */
unsigned u; /*counters */
@@ -975,7 +979,7 @@ H5D_istore_flush_entry(H5D_io_info_t *io_info, H5D_rdcc_ent_t *ent, hbool_t rese
size_t alloc; /*bytes allocated for BUF */
hbool_t point_of_no_return = FALSE;
- FUNC_ENTER_NOAPI_NOINIT(H5D_istore_flush_entry);
+ FUNC_ENTER_NOAPI_NOINIT(H5D_istore_flush_entry)
assert(io_info);
assert(io_info->dset);
@@ -1004,7 +1008,7 @@ H5D_istore_flush_entry(H5D_io_info_t *io_info, H5D_rdcc_ent_t *ent, hbool_t rese
*/
alloc = ent->chunk_size;
if (NULL==(buf = H5MM_malloc(alloc)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for pipeline");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for pipeline")
HDmemcpy(buf, ent->chunk, ent->chunk_size);
} else {
/*
@@ -1027,9 +1031,9 @@ H5D_istore_flush_entry(H5D_io_info_t *io_info, H5D_rdcc_ent_t *ent, hbool_t rese
* its size changed. Then write the data into the file.
*/
if (H5B_insert(io_info->dset->ent.file, io_info->dxpl_id, H5B_ISTORE, io_info->dset->shared->layout.u.chunk.addr, &udata)<0)
- HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to allocate chunk");
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to allocate chunk")
if (H5F_block_write(io_info->dset->ent.file, H5FD_MEM_DRAW, udata.addr, udata.key.nbytes, io_info->dxpl_id, buf)<0)
- HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write raw data to file");
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write raw data to file")
/* Mark cache entry as clean */
ent->dirty = FALSE;
@@ -1063,7 +1067,7 @@ done:
ent->chunk = H5D_istore_chunk_xfree(ent->chunk,&(io_info->dset->shared->dcpl_cache.pline));
} /* end if */
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_istore_flush_entry() */
@@ -1086,12 +1090,12 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5D_istore_preempt(H5D_io_info_t *io_info, H5D_rdcc_ent_t * ent, hbool_t flush)
+H5D_istore_preempt(const H5D_io_info_t *io_info, H5D_rdcc_ent_t * ent, hbool_t flush)
{
H5D_rdcc_t *rdcc = &(io_info->dset->shared->cache.chunk);
herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5D_istore_preempt);
+ FUNC_ENTER_NOAPI_NOINIT(H5D_istore_preempt)
assert(io_info);
assert(ent);
@@ -1101,7 +1105,7 @@ H5D_istore_preempt(H5D_io_info_t *io_info, H5D_rdcc_ent_t * ent, hbool_t flush)
if(flush) {
/* Flush */
if(H5D_istore_flush_entry(io_info, ent, TRUE) < 0)
- HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "cannot flush indexed storage buffer");
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "cannot flush indexed storage buffer")
}
else {
/* Don't flush, just free chunk */
@@ -1130,7 +1134,7 @@ H5D_istore_preempt(H5D_io_info_t *io_info, H5D_rdcc_ent_t * ent, hbool_t flush)
H5FL_FREE(H5D_rdcc_ent_t, ent);
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_istore_preempt() */
@@ -1162,7 +1166,7 @@ H5D_istore_flush (H5D_t *dset, hid_t dxpl_id, unsigned flags)
H5D_rdcc_ent_t *ent=NULL, *next=NULL;
herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5D_istore_flush, FAIL);
+ FUNC_ENTER_NOAPI(H5D_istore_flush, FAIL)
/* Fill the DXPL cache values for later use */
if (H5D_get_dxpl_cache(dxpl_id,&dxpl_cache)<0)
@@ -1187,10 +1191,10 @@ H5D_istore_flush (H5D_t *dset, hid_t dxpl_id, unsigned flags)
} /* end for */
if (nerrors)
- HGOTO_ERROR (H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks");
+ HGOTO_ERROR (H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks")
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_istore_flush() */
@@ -1222,7 +1226,7 @@ H5D_istore_dest (H5D_t *dset, hid_t dxpl_id)
H5D_rdcc_ent_t *ent=NULL, *next=NULL;
herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5D_istore_dest, FAIL);
+ FUNC_ENTER_NOAPI(H5D_istore_dest, FAIL)
assert(dset);
@@ -1244,17 +1248,18 @@ H5D_istore_dest (H5D_t *dset, hid_t dxpl_id)
nerrors++;
}
if (nerrors)
- HGOTO_ERROR (H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks");
+ HGOTO_ERROR (H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks")
- H5FL_SEQ_FREE (H5D_rdcc_ent_ptr_t,rdcc->slot);
+ if(rdcc->slot)
+ H5FL_SEQ_FREE (H5D_rdcc_ent_ptr_t,rdcc->slot);
HDmemset (rdcc, 0, sizeof(H5D_rdcc_t));
/* Free the raw B-tree node buffer */
if(H5RC_DEC(dset->shared->layout.u.chunk.btree_shared)<0)
- HGOTO_ERROR (H5E_IO, H5E_CANTFREE, FAIL, "unable to decrement ref-counted page");
+ HGOTO_ERROR (H5E_IO, H5E_CANTFREE, FAIL, "unable to decrement ref-counted page")
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_istore_dest() */
@@ -1306,14 +1311,14 @@ HDmemset(shared->page,0,shared->sizeof_rnode);
/* Initialize the offsets into the native key buffer */
for(u=0; u<(2*H5F_KVALUE(f,H5B_ISTORE)+1); u++)
- shared->nkey[u]=u*H5B_ISTORE->sizeof_nkey;
+ shared->nkey[u]=u*H5B_ISTORE[0].sizeof_nkey;
/* Make shared B-tree info reference counted */
if(NULL==(layout->u.chunk.btree_shared=H5RC_create(shared,H5D_istore_shared_free)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't create ref-count wrapper for shared B-tree info")
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_istore_shared_create() */
@@ -1370,7 +1375,7 @@ H5D_istore_shared_free (void *_shared)
*-------------------------------------------------------------------------
*/
static herr_t
-H5D_istore_prune (H5D_io_info_t *io_info, size_t size)
+H5D_istore_prune (const H5D_io_info_t *io_info, size_t size)
{
int i, j, nerrors=0;
const H5D_rdcc_t *rdcc = &(io_info->dset->shared->cache.chunk);
@@ -1381,7 +1386,7 @@ H5D_istore_prune (H5D_io_info_t *io_info, size_t size)
H5D_rdcc_ent_t *n[2]; /*list next pointers */
herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5D_istore_prune);
+ FUNC_ENTER_NOAPI_NOINIT(H5D_istore_prune)
/*
* Preemption is accomplished by having multiple pointers (currently two)
@@ -1462,10 +1467,10 @@ H5D_istore_prune (H5D_io_info_t *io_info, size_t size)
}
if (nerrors)
- HGOTO_ERROR (H5E_IO, H5E_CANTFLUSH, FAIL, "unable to preempt one or more raw data cache entry");
+ HGOTO_ERROR (H5E_IO, H5E_CANTFLUSH, FAIL, "unable to preempt one or more raw data cache entry")
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_istore_prune() */
@@ -1504,7 +1509,7 @@ done:
*-------------------------------------------------------------------------
*/
static void *
-H5D_istore_lock(H5D_io_info_t *io_info,
+H5D_istore_lock(const H5D_io_info_t *io_info,
H5D_istore_ud1_t *udata, hbool_t relax, unsigned *idx_hint/*in,out*/)
{
H5D_t *dset=io_info->dset; /* Local pointer to the dataset info */
@@ -1521,7 +1526,7 @@ H5D_istore_lock(H5D_io_info_t *io_info,
void *chunk=NULL; /*the file chunk */
void *ret_value; /*return value */
- FUNC_ENTER_NOAPI_NOINIT(H5D_istore_lock);
+ FUNC_ENTER_NOAPI_NOINIT(H5D_istore_lock)
assert(io_info);
assert(dset);
@@ -1556,7 +1561,7 @@ H5D_istore_lock(H5D_io_info_t *io_info,
rdcc->nhits++;
#endif /* H5D_ISTORE_DEBUG */
- } else if (!found && relax) {
+ } else if (relax) {
/*
* Not in the cache, but we're about to overwrite the whole thing
* anyway, so just allocate a buffer for it but don't initialize that
@@ -1569,7 +1574,7 @@ H5D_istore_lock(H5D_io_info_t *io_info,
rdcc->nhits++;
#endif
if (NULL==(chunk=H5D_istore_chunk_alloc (chunk_size,pline)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for raw data chunk");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for raw data chunk")
} else {
H5D_istore_ud1_t tmp_udata; /*B-tree pass-through */
@@ -1598,14 +1603,14 @@ H5D_istore_lock(H5D_io_info_t *io_info,
* size in memory, so allocate memory big enough. */
chunk_alloc = udata->key.nbytes;
if (NULL==(chunk = H5D_istore_chunk_alloc (chunk_alloc,pline)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for raw data chunk");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for raw data chunk")
if (H5F_block_read(dset->ent.file, H5FD_MEM_DRAW, chunk_addr, udata->key.nbytes, io_info->dxpl_id, chunk)<0)
- HGOTO_ERROR (H5E_IO, H5E_READERROR, NULL, "unable to read raw data chunk");
+ HGOTO_ERROR (H5E_IO, H5E_READERROR, NULL, "unable to read raw data chunk")
if (pline->nused)
if (H5Z_pipeline(pline, H5Z_FLAG_REVERSE, &(udata->key.filter_mask), io_info->dxpl_cache->err_detect,
io_info->dxpl_cache->filter_cb, &(udata->key.nbytes), &chunk_alloc, &chunk)<0) {
- HGOTO_ERROR(H5E_PLINE, H5E_READERROR, NULL, "data pipeline read failed");
+ HGOTO_ERROR(H5E_PLINE, H5E_READERROR, NULL, "data pipeline read failed")
}
#ifdef H5D_ISTORE_DEBUG
rdcc->nmisses++;
@@ -1621,10 +1626,10 @@ H5D_istore_lock(H5D_io_info_t *io_info,
/* Chunk size on disk isn't [likely] the same size as the final chunk
* size in memory, so allocate memory big enough. */
if (NULL==(chunk = H5D_istore_chunk_alloc (chunk_size,pline)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for raw data chunk");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for raw data chunk")
if (H5P_is_fill_value_defined(fill, &fill_status) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't tell if fill value defined");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't tell if fill value defined")
if(fill_time==H5D_FILL_TIME_ALLOC ||
(fill_time==H5D_FILL_TIME_IFSET && fill_status==H5D_FILL_VALUE_USER_DEFINED)) {
@@ -1666,10 +1671,10 @@ else
HDfflush(stderr);
#endif
if (H5D_istore_preempt(io_info, ent, TRUE)<0)
- HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL, "unable to preempt chunk from cache");
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL, "unable to preempt chunk from cache")
}
if (H5D_istore_prune(io_info, chunk_size)<0)
- HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL, "unable to preempt chunk(s) from cache");
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL, "unable to preempt chunk(s) from cache")
/* Create a new entry */
ent = H5FL_MALLOC(H5D_rdcc_ent_t);
@@ -1710,12 +1715,13 @@ else
ent = NULL;
idx = UINT_MAX;
- } else if (found) {
+ } else {
/*
* The chunk is not at the beginning of the cache; move it backward
* by one slot. This is how we implement the LRU preemption
* algorithm.
*/
+ assert(ent);
if (ent->next) {
if (ent->next->next)
ent->next->next->prev = ent;
@@ -1748,8 +1754,8 @@ else
done:
if (!ret_value)
if(chunk)
- H5D_istore_chunk_xfree (chunk,pline);
- FUNC_LEAVE_NOAPI(ret_value);
+ chunk=H5D_istore_chunk_xfree (chunk,pline);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_istore_lock() */
@@ -1780,29 +1786,20 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5D_istore_unlock(H5D_io_info_t *io_info,
+H5D_istore_unlock(const H5D_io_info_t *io_info,
hbool_t dirty, unsigned idx_hint, uint8_t *chunk, size_t naccessed)
{
const H5O_layout_t *layout=&(io_info->dset->shared->layout); /* Dataset layout */
const H5D_rdcc_t *rdcc = &(io_info->dset->shared->cache.chunk);
H5D_rdcc_ent_t *ent = NULL;
- int found = -1;
unsigned u;
+ herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_unlock);
+ FUNC_ENTER_NOAPI_NOINIT(H5D_istore_unlock)
assert(io_info);
if (UINT_MAX==idx_hint) {
- /*not in cache*/
- } else {
- assert(idx_hint<rdcc->nslots);
- assert(rdcc->slot[idx_hint]);
- assert(rdcc->slot[idx_hint]->chunk==chunk);
- found = idx_hint;
- }
-
- if (found<0) {
/*
* It's not in the cache, probably because it's too big. If it's
* dirty then flush it to disk. In any case, free the chunk.
@@ -1821,16 +1818,22 @@ H5D_istore_unlock(H5D_io_info_t *io_info,
x.alloc_size = x.chunk_size;
x.chunk = chunk;
- H5D_istore_flush_entry (io_info, &x, TRUE);
+ if (H5D_istore_flush_entry(io_info, &x, TRUE)<0)
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "cannot flush indexed storage buffer")
} else {
if(chunk)
- H5D_istore_chunk_xfree (chunk,&(io_info->dset->shared->dcpl_cache.pline));
+ chunk=H5D_istore_chunk_xfree (chunk,&(io_info->dset->shared->dcpl_cache.pline));
}
} else {
+ /* Sanity check */
+ assert(idx_hint<rdcc->nslots);
+ assert(rdcc->slot[idx_hint]);
+ assert(rdcc->slot[idx_hint]->chunk==chunk);
+
/*
* It's in the cache so unlock it.
*/
- ent = rdcc->slot[found];
+ ent = rdcc->slot[idx_hint];
assert (ent->locked);
if (dirty) {
ent->dirty = TRUE;
@@ -1841,7 +1844,8 @@ H5D_istore_unlock(H5D_io_info_t *io_info,
ent->locked = FALSE;
}
- FUNC_LEAVE_NOAPI(SUCCEED);
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_istore_unlock() */
@@ -1861,7 +1865,7 @@ H5D_istore_unlock(H5D_io_info_t *io_info,
*-------------------------------------------------------------------------
*/
ssize_t
-H5D_istore_readvv(H5D_io_info_t *io_info,
+H5D_istore_readvv(const H5D_io_info_t *io_info,
size_t chunk_max_nseq, size_t *chunk_curr_seq, size_t chunk_len_arr[], hsize_t chunk_offset_arr[],
size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[],
void *buf)
@@ -1872,7 +1876,7 @@ H5D_istore_readvv(H5D_io_info_t *io_info,
size_t u; /* Local index variables */
ssize_t ret_value; /* Return value */
- FUNC_ENTER_NOAPI(H5D_istore_readvv, FAIL);
+ FUNC_ENTER_NOAPI(H5D_istore_readvv, FAIL)
/* Check args */
assert(io_info);
@@ -1886,11 +1890,6 @@ H5D_istore_readvv(H5D_io_info_t *io_info,
assert(mem_offset_arr);
assert(buf);
-#ifndef NDEBUG
- for (u=0; u<dset->shared->layout.u.chunk.ndims; u++)
- assert(io_info->store->chunk.offset[u]>=0); /*negative coordinates not supported (yet) */
-#endif
-
/* Get the address of this chunk on disk */
#ifdef QAK
HDfprintf(stderr,"%s: io_info->store->chunk.offset={",FUNC);
@@ -1932,7 +1931,7 @@ HDfprintf(stderr,"%s: buf=%p\n",FUNC,buf);
/* Do I/O directly on chunk without reading it into the cache */
if ((ret_value=H5D_contig_readvv(&chk_io_info, chunk_max_nseq, chunk_curr_seq, chunk_len_arr, chunk_offset_arr, mem_max_nseq, mem_curr_seq, mem_len_arr, mem_offset_arr, buf))<0)
- HGOTO_ERROR (H5E_IO, H5E_READERROR, FAIL, "unable to read raw data to file");
+ HGOTO_ERROR (H5E_IO, H5E_READERROR, FAIL, "unable to read raw data to file")
} /* end if */
else {
uint8_t *chunk; /* Pointer to cached chunk in memory */
@@ -1974,7 +1973,7 @@ HDfprintf(stderr,"%s: buf=%p\n",FUNC,buf);
if(!found) {
/* Check if the fill value is defined */
if (H5P_is_fill_value_defined(fill, &fill_status) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't tell if fill value defined");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't tell if fill value defined")
/* If we are never to return fill values, or if we would return them
* but they aren't set, process the entire set of I/O vectors and
@@ -2014,7 +2013,7 @@ HDfprintf(stderr,"%s: buf=%p\n",FUNC,buf);
*mem_curr_seq=u;
*chunk_curr_seq=v;
- HGOTO_DONE(bytes_processed);
+ HGOTO_DONE(bytes_processed)
} /* end if */
} /* end if */
} /* end if */
@@ -2024,22 +2023,22 @@ HDfprintf(stderr,"%s: buf=%p\n",FUNC,buf);
* chunk.
*/
if (NULL==(chunk=H5D_istore_lock(io_info, &udata, FALSE, &idx_hint)))
- HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "unable to read raw data chunk");
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "unable to read raw data chunk")
/* Use the vectorized memory copy routine to do actual work */
if((naccessed=H5V_memcpyvv(buf,mem_max_nseq,mem_curr_seq,mem_len_arr,mem_offset_arr,chunk,chunk_max_nseq,chunk_curr_seq,chunk_len_arr,chunk_offset_arr))<0)
- HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "vectorized memcpy failed");
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "vectorized memcpy failed")
H5_CHECK_OVERFLOW(naccessed,ssize_t,size_t);
if (H5D_istore_unlock(io_info, FALSE, idx_hint, chunk, (size_t)naccessed)<0)
- HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "unable to unlock raw data chunk");
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "unable to unlock raw data chunk")
/* Set return value */
ret_value=naccessed;
} /* end else */
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* H5D_istore_readvv() */
@@ -2059,7 +2058,7 @@ done:
*-------------------------------------------------------------------------
*/
ssize_t
-H5D_istore_writevv(H5D_io_info_t *io_info,
+H5D_istore_writevv(const H5D_io_info_t *io_info,
size_t chunk_max_nseq, size_t *chunk_curr_seq, size_t chunk_len_arr[], hsize_t chunk_offset_arr[],
size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[],
const void *buf)
@@ -2070,7 +2069,7 @@ H5D_istore_writevv(H5D_io_info_t *io_info,
size_t u; /* Local index variables */
ssize_t ret_value; /* Return value */
- FUNC_ENTER_NOAPI(H5D_istore_writevv, FAIL);
+ FUNC_ENTER_NOAPI(H5D_istore_writevv, FAIL)
/* Check args */
assert(io_info);
@@ -2084,11 +2083,6 @@ H5D_istore_writevv(H5D_io_info_t *io_info,
assert(mem_offset_arr);
assert(buf);
-#ifndef NDEBUG
- for (u=0; u<dset->shared->layout.u.chunk.ndims; u++)
- assert(io_info->store->chunk.offset[u]>=0); /*negative coordinates not supported (yet) */
-#endif
-
/* Get the address of this chunk on disk */
#ifdef QAK
HDfprintf(stderr,"%s: io_info->store->chunk.offset={",FUNC);
@@ -2119,9 +2113,9 @@ HDfprintf(stderr,"%s: mem_offset_arr[%Zu]=%Hu\n",FUNC,*mem_curr_seq,mem_offset_a
/* Additional sanity checks when operating in parallel */
if(IS_H5FD_MPI(dset->ent.file)) {
if (chunk_addr==HADDR_UNDEF)
- HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "unable to locate raw data chunk");
+ HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "unable to locate raw data chunk")
if (dset->shared->dcpl_cache.pline.nused>0)
- HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "cannot write to chunked storage with filters in parallel");
+ HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "cannot write to chunked storage with filters in parallel")
} /* end if */
#endif /* H5_HAVE_PARALLEL */
@@ -2139,7 +2133,7 @@ HDfprintf(stderr,"%s: mem_offset_arr[%Zu]=%Hu\n",FUNC,*mem_curr_seq,mem_offset_a
/* Do I/O directly on chunk without reading it into the cache */
if ((ret_value=H5D_contig_writevv(&chk_io_info, chunk_max_nseq, chunk_curr_seq, chunk_len_arr, chunk_offset_arr, mem_max_nseq, mem_curr_seq, mem_len_arr, mem_offset_arr, buf))<0)
- HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "unable to write raw data to file");
+ HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "unable to write raw data to file")
} /* end if */
else {
uint8_t *chunk; /* Pointer to cached chunk in memory */
@@ -2179,22 +2173,22 @@ HDfprintf(stderr,"%s: mem_offset_arr[%Zu]=%Hu\n",FUNC,*mem_curr_seq,mem_offset_a
#endif /* OLD_WAY */
if (NULL==(chunk=H5D_istore_lock(io_info, &udata, relax, &idx_hint)))
- HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "unable to read raw data chunk");
+ HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "unable to read raw data chunk")
/* Use the vectorized memory copy routine to do actual work */
if((naccessed=H5V_memcpyvv(chunk,chunk_max_nseq,chunk_curr_seq,chunk_len_arr,chunk_offset_arr,buf,mem_max_nseq,mem_curr_seq,mem_len_arr,mem_offset_arr))<0)
- HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "vectorized memcpy failed");
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "vectorized memcpy failed")
H5_CHECK_OVERFLOW(naccessed,ssize_t,size_t);
if (H5D_istore_unlock(io_info, TRUE, idx_hint, chunk, (size_t)naccessed)<0)
- HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "uanble to unlock raw data chunk");
+ HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "uanble to unlock raw data chunk")
/* Set return value */
ret_value=naccessed;
} /* end else */
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* H5D_istore_writevv() */
@@ -2227,7 +2221,7 @@ H5D_istore_create(H5F_t *f, hid_t dxpl_id, H5O_layout_t *layout /*out */ )
#endif
herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5D_istore_create, FAIL);
+ FUNC_ENTER_NOAPI(H5D_istore_create, FAIL)
/* Check args */
assert(f);
@@ -2242,10 +2236,10 @@ H5D_istore_create(H5F_t *f, hid_t dxpl_id, H5O_layout_t *layout /*out */ )
udata.mesg = layout;
if (H5B_create(f, dxpl_id, H5B_ISTORE, &udata, &(layout->u.chunk.addr)/*out*/) < 0)
- HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "can't create B-tree");
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "can't create B-tree")
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_istore_create() */
@@ -2279,7 +2273,7 @@ H5D_istore_allocated(H5D_t *dset, hid_t dxpl_id)
H5D_istore_ud1_t udata;
hsize_t ret_value; /* Return value */
- FUNC_ENTER_NOAPI(H5D_istore_allocated, 0);
+ FUNC_ENTER_NOAPI(H5D_istore_allocated, 0)
assert(dset);
@@ -2294,19 +2288,19 @@ H5D_istore_allocated(H5D_t *dset, hid_t dxpl_id)
for(ent = rdcc->head; ent; ent = ent->next) {
/* Flush the chunk out to disk, to make certain the size is correct later */
if (H5D_istore_flush_entry(&io_info, ent, FALSE)<0)
- HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, 0, "cannot flush indexed storage buffer");
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, 0, "cannot flush indexed storage buffer")
} /* end for */
HDmemset(&udata, 0, sizeof udata);
udata.mesg = &dset->shared->layout;
if (H5B_iterate(dset->ent.file, dxpl_id, H5B_ISTORE, H5D_istore_iter_allocated, dset->shared->layout.u.chunk.addr, &udata)<0)
- HGOTO_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to iterate over chunk B-tree");
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to iterate over chunk B-tree")
/* Set return value */
ret_value=udata.total_storage;
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_istore_allocated() */
@@ -2329,14 +2323,14 @@ done:
*-------------------------------------------------------------------------
*/
haddr_t
-H5D_istore_get_addr(H5D_io_info_t *io_info, H5D_istore_ud1_t *_udata)
+H5D_istore_get_addr(const H5D_io_info_t *io_info, H5D_istore_ud1_t *_udata)
{
H5D_istore_ud1_t tmp_udata; /* Information about a chunk */
H5D_istore_ud1_t *udata; /* Pointer to information about a chunk */
unsigned u;
haddr_t ret_value; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_get_addr);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_get_addr)
assert(io_info);
assert(io_info->dset);
@@ -2361,7 +2355,7 @@ H5D_istore_get_addr(H5D_io_info_t *io_info, H5D_istore_ud1_t *_udata)
#ifdef OLD_WAY
H5E_clear_stack(NULL);
- HGOTO_ERROR(H5E_BTREE,H5E_NOTFOUND,HADDR_UNDEF,"Can't locate chunk info");
+ HGOTO_ERROR(H5E_BTREE,H5E_NOTFOUND,HADDR_UNDEF,"Can't locate chunk info")
#else /* OLD_WAY */
HGOTO_DONE(HADDR_UNDEF)
#endif /* OLD_WAY */
@@ -2371,7 +2365,7 @@ H5D_istore_get_addr(H5D_io_info_t *io_info, H5D_istore_ud1_t *_udata)
ret_value=udata->addr;
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* H5D_istore_get_addr() */
@@ -2396,7 +2390,7 @@ H5D_istore_chunk_alloc(size_t size, const H5O_pline_t *pline)
{
void *ret_value=NULL; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_chunk_alloc);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_chunk_alloc)
assert(size);
assert(pline);
@@ -2406,7 +2400,7 @@ H5D_istore_chunk_alloc(size_t size, const H5O_pline_t *pline)
else
ret_value=H5FL_BLK_MALLOC(chunk,size);
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* H5D_istore_chunk_alloc() */
@@ -2429,7 +2423,7 @@ H5D_istore_chunk_alloc(size_t size, const H5O_pline_t *pline)
static void *
H5D_istore_chunk_xfree(void *chk, const H5O_pline_t *pline)
{
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_chunk_xfree);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_chunk_xfree)
assert(pline);
@@ -2440,7 +2434,7 @@ H5D_istore_chunk_xfree(void *chk, const H5O_pline_t *pline)
H5FL_BLK_FREE(chunk,chk);
} /* end if */
- FUNC_LEAVE_NOAPI(NULL);
+ FUNC_LEAVE_NOAPI(NULL)
} /* H5D_istore_chunk_xfree() */
@@ -2492,10 +2486,11 @@ H5D_istore_allocate(H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite)
{
H5D_io_info_t io_info; /* Dataset I/O info */
H5D_storage_t store; /* Dataset storage information */
- hssize_t chunk_offset[H5O_LAYOUT_NDIMS]; /* Offset of current chunk */
+ hsize_t chunk_offset[H5O_LAYOUT_NDIMS]; /* Offset of current chunk */
hsize_t chunk_size; /* Size of chunk in bytes */
unsigned filter_mask=0; /* Filter mask for chunks that have them */
H5O_pline_t pline; /* I/O pipeline information */
+ hbool_t pline_initialized=FALSE; /* Flag to indicate that pline has valid info */
H5O_fill_t fill; /* Fill value information */
H5D_fill_time_t fill_time; /* When to write fill values */
H5D_fill_value_t fill_status; /* The fill value status */
@@ -2520,7 +2515,7 @@ H5D_istore_allocate(H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite)
hsize_t space_dim[H5O_LAYOUT_NDIMS]; /* Dataset's dataspace dimensions */
herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5D_istore_allocate, FAIL);
+ FUNC_ENTER_NOAPI(H5D_istore_allocate, FAIL)
/* Check args */
assert(dset && H5D_CHUNKED==dset->shared->layout.type);
@@ -2539,11 +2534,12 @@ H5D_istore_allocate(H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite)
/* Get necessary properties from dataset creation property list */
if(H5P_get(dc_plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0)
- HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL, "can't get fill value");
+ HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL, "can't get fill value")
if(H5P_get(dc_plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
- HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL, "can't get data pipeline");
+ HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL, "can't get data pipeline")
+ pline_initialized=TRUE;
if(H5P_get(dc_plist, H5D_CRT_FILL_TIME_NAME, &fill_time) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve fill time");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve fill time")
/* Fill the DXPL cache values for later use */
if (H5D_get_dxpl_cache(dxpl_id,&dxpl_cache)<0)
@@ -2554,11 +2550,11 @@ H5D_istore_allocate(H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite)
if(IS_H5FD_MPI(dset->ent.file)) {
/* Get the MPI communicator */
if (MPI_COMM_NULL == (mpi_comm=H5F_mpi_get_comm(dset->ent.file)))
- HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI communicator");
+ HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI communicator")
/* Get the MPI rank */
if ((mpi_rank=H5F_mpi_get_rank(dset->ent.file))<0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI rank");
+ HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI rank")
/* Set the MPI-capable file driver flag */
using_mpi=1;
@@ -2575,7 +2571,7 @@ H5D_istore_allocate(H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite)
/* Check the dataset's fill-value status */
if (H5P_is_fill_value_defined(&fill, &fill_status) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't tell if fill value defined");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't tell if fill value defined")
/* If we are filling the dataset on allocation or "if set" and
* the fill value _is_ set, _and_ we are not overwriting the new blocks,
@@ -2592,7 +2588,7 @@ H5D_istore_allocate(H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite)
/* Allocate chunk buffer for processes to use when writing fill values */
H5_CHECK_OVERFLOW(chunk_size,hsize_t,size_t);
if (NULL==(chunk = H5D_istore_chunk_alloc((size_t)chunk_size,&pline)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for chunk");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for chunk")
/* Fill the chunk with the proper values */
if(fill.buf) {
@@ -2615,7 +2611,7 @@ H5D_istore_allocate(H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite)
/* Push the chunk through the filters */
if (H5Z_pipeline(&pline, 0, &filter_mask, dxpl_cache->err_detect, dxpl_cache->filter_cb, &nbytes, &buf_size, &chunk)<0)
- HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, "output pipeline failed");
+ HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, "output pipeline failed")
/* Keep the number of bytes the chunk turned in to */
chunk_size=nbytes;
@@ -2661,7 +2657,7 @@ H5D_istore_allocate(H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite)
/* Allocate the chunk with all processes */
if (H5B_insert(dset->ent.file, dxpl_id, H5B_ISTORE, dset->shared->layout.u.chunk.addr, &udata)<0)
- HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to allocate chunk");
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to allocate chunk")
/* Check if fill values should be written to blocks */
if(should_fill) {
@@ -2672,7 +2668,7 @@ H5D_istore_allocate(H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite)
/* !! Use the internal "independent" DXPL!! -QAK */
if(H5_PAR_META_WRITE==mpi_rank) {
if (H5F_block_write(dset->ent.file, H5FD_MEM_DRAW, udata.addr, udata.key.nbytes, H5AC_ind_dxpl_id, chunk)<0)
- HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write raw data to file");
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write raw data to file")
} /* end if */
/* Indicate that blocks are being written */
@@ -2681,7 +2677,7 @@ H5D_istore_allocate(H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite)
else {
#endif /* H5_HAVE_PARALLEL */
if (H5F_block_write(dset->ent.file, H5FD_MEM_DRAW, udata.addr, udata.key.nbytes, dxpl_id, chunk)<0)
- HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write raw data to file");
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write raw data to file")
#ifdef H5_HAVE_PARALLEL
} /* end else */
#endif /* H5_HAVE_PARALLEL */
@@ -2689,9 +2685,9 @@ H5D_istore_allocate(H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite)
} /* end if */
/* Increment indices */
- for (i=dset->shared->layout.u.chunk.ndims-1, carry=1; i>=0 && carry; --i) {
+ for (i=(int)dset->shared->layout.u.chunk.ndims-1, carry=1; i>=0 && carry; --i) {
chunk_offset[i] += dset->shared->layout.u.chunk.dim[i];
- if (chunk_offset[i] >= (hssize_t)(space_dim[i]))
+ if (chunk_offset[i] >= space_dim[i])
chunk_offset[i] = 0;
else
carry = 0;
@@ -2713,10 +2709,10 @@ H5D_istore_allocate(H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite)
done:
/* Free the chunk for fill values */
- if(chunk!=NULL)
- H5D_istore_chunk_xfree(chunk,&pline);
+ if(chunk!=NULL && pline_initialized)
+ chunk=H5D_istore_chunk_xfree(chunk,&pline);
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_istore_allocate() */
@@ -2821,7 +2817,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5D_istore_prune_by_extent(H5D_io_info_t *io_info)
+H5D_istore_prune_by_extent(const H5D_io_info_t *io_info)
{
H5D_t *dset=io_info->dset; /* Local pointer to the dataset info */
const H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /*raw data chunk cache */
@@ -2832,7 +2828,7 @@ H5D_istore_prune_by_extent(H5D_io_info_t *io_info)
hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /*current dataspace dimensions */
herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5D_istore_prune_by_extent, FAIL);
+ FUNC_ENTER_NOAPI(H5D_istore_prune_by_extent, FAIL)
/* Check args */
assert(io_info);
@@ -2842,7 +2838,7 @@ H5D_istore_prune_by_extent(H5D_io_info_t *io_info)
/* Go get the rank & dimensions */
if(H5S_get_simple_extent_dims(dset->shared->space, curr_dims, NULL) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions");
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions")
/*-------------------------------------------------------------------------
* Figure out what chunks are no longer in use for the specified extent
@@ -2870,7 +2866,7 @@ H5D_istore_prune_by_extent(H5D_io_info_t *io_info)
/* Preempt the entry from the cache, but do not flush it to disk */
if(H5D_istore_preempt(io_info, ent, FALSE) < 0)
- HGOTO_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to preempt chunk");
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to preempt chunk")
found=0;
}
@@ -2887,10 +2883,10 @@ H5D_istore_prune_by_extent(H5D_io_info_t *io_info)
udata.dims = curr_dims;
if(H5B_iterate(dset->ent.file, io_info->dxpl_id, H5B_ISTORE, H5D_istore_prune_extent, dset->shared->layout.u.chunk.addr, &udata) < 0)
- HGOTO_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to iterate over B-tree");
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to iterate over B-tree")
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_istore_prune_by_extent() */
@@ -2911,12 +2907,13 @@ done:
*
*-------------------------------------------------------------------------
*/
+/* ARGSUSED */
static int
-H5D_istore_prune_extent(H5F_t *f, hid_t dxpl_id, void *_lt_key, haddr_t UNUSED addr,
- void UNUSED *_rt_key, void *_udata)
+H5D_istore_prune_extent(H5F_t *f, hid_t dxpl_id, const void *_lt_key, haddr_t UNUSED addr,
+ const void UNUSED *_rt_key, void *_udata)
{
H5D_istore_ud1_t *bt_udata = (H5D_istore_ud1_t *)_udata;
- H5D_istore_key_t *lt_key = (H5D_istore_key_t *)_lt_key;
+ const H5D_istore_key_t *lt_key = (const H5D_istore_key_t *)_lt_key;
unsigned u;
H5D_istore_ud1_t udata;
int ret_value=H5B_ITER_CONT; /* Return value */
@@ -2925,7 +2922,7 @@ H5D_istore_prune_extent(H5F_t *f, hid_t dxpl_id, void *_lt_key, haddr_t UNUSED a
* storage that contains the beginning of the logical address space represented by UDATA.
*/
- FUNC_ENTER_NOAPI_NOINIT(H5D_istore_prune_extent);
+ FUNC_ENTER_NOAPI_NOINIT(H5D_istore_prune_extent)
/* Figure out what chunks are no longer in use for the specified extent and release them */
for(u = 0; u < bt_udata->mesg->u.chunk.ndims - 1; u++)
@@ -2943,12 +2940,12 @@ H5D_istore_prune_extent(H5F_t *f, hid_t dxpl_id, void *_lt_key, haddr_t UNUSED a
/* Remove */
if(H5B_remove(f, dxpl_id, H5B_ISTORE, bt_udata->mesg->u.chunk.addr, &udata) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5B_ITER_ERROR, "unable to remove entry");
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5B_ITER_ERROR, "unable to remove entry")
break;
} /* end if */
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_istore_prune_extent() */
@@ -2970,6 +2967,7 @@ done:
*
*-------------------------------------------------------------------------
*/
+/* ARGSUSED */
static H5B_ins_t
H5D_istore_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key /*in,out */ ,
hbool_t *lt_key_changed /*out */ ,
@@ -2978,17 +2976,20 @@ H5D_istore_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key /*in,out
hbool_t *rt_key_changed /*out */ )
{
H5D_istore_key_t *lt_key = (H5D_istore_key_t *)_lt_key;
+ H5B_ins_t ret_value=H5B_INS_REMOVE; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_remove);
+ FUNC_ENTER_NOAPI_NOINIT(H5D_istore_remove)
/* Remove raw data chunk from file */
- H5MF_xfree(f, H5FD_MEM_DRAW, dxpl_id, addr, (hsize_t)lt_key->nbytes);
+ if(H5MF_xfree(f, H5FD_MEM_DRAW, dxpl_id, addr, (hsize_t)lt_key->nbytes)<0)
+ HGOTO_ERROR(H5E_STORAGE, H5E_CANTFREE, H5B_INS_ERROR, "unable to free chunk")
/* Mark keys as unchanged */
*lt_key_changed = FALSE;
*rt_key_changed = FALSE;
- FUNC_LEAVE_NOAPI(H5B_INS_REMOVE);
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_istore_remove() */
@@ -3022,13 +3023,13 @@ H5D_istore_initialize_by_extent(H5D_io_info_t *io_info)
const H5O_layout_t *layout=&(io_info->dset->shared->layout); /* Dataset layout */
uint8_t *chunk = NULL; /*the file chunk */
unsigned idx_hint = 0; /*input value for H5F_istore_lock */
- hssize_t chunk_offset[H5O_LAYOUT_NDIMS]; /*logical location of the chunks */
+ hsize_t chunk_offset[H5O_LAYOUT_NDIMS]; /*logical location of the chunks */
hsize_t idx_cur[H5O_LAYOUT_NDIMS]; /*multi-dimensional counters */
hsize_t idx_max[H5O_LAYOUT_NDIMS];
hsize_t sub_size[H5O_LAYOUT_NDIMS];
hsize_t naccessed; /*bytes accessed in chunk */
hsize_t end_chunk; /*chunk position counter */
- hssize_t start[H5O_LAYOUT_NDIMS]; /*starting location of hyperslab */
+ hsize_t start[H5O_LAYOUT_NDIMS]; /*starting location of hyperslab */
hsize_t count[H5O_LAYOUT_NDIMS]; /*element count of hyperslab */
hsize_t size[H5O_LAYOUT_NDIMS]; /*current size of dimensions */
H5S_t *space_chunk = NULL; /*dataspace for a chunk */
@@ -3048,7 +3049,7 @@ H5D_istore_initialize_by_extent(H5D_io_info_t *io_info)
H5D_storage_t store; /* Dataset storage information */
herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5D_istore_initialize_by_extent, FAIL);
+ FUNC_ENTER_NOAPI(H5D_istore_initialize_by_extent, FAIL)
/* Check args */
assert(io_info);
@@ -3062,11 +3063,11 @@ H5D_istore_initialize_by_extent(H5D_io_info_t *io_info)
/* Get necessary properties from property list */
if(H5P_get(dc_plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get fill value");
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get fill value")
if(H5P_get(dc_plist, H5D_CRT_FILL_TIME_NAME, &fill_time) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get fill time");
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get fill time")
if(H5P_get(dc_plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get data pipeline");
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get data pipeline")
/* Reset start & count arrays */
HDmemset(start, 0, sizeof(start));
@@ -3094,7 +3095,7 @@ H5D_istore_initialize_by_extent(H5D_io_info_t *io_info)
for(u = 0; u < rank; u++)
chunk_dims[u] = layout->u.chunk.dim[u];
if(NULL == (space_chunk = H5S_create_simple(rank,chunk_dims,NULL)))
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace");
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace")
/*
* Set up multi-dimensional counters (idx_max, and idx_cur) and
@@ -3115,7 +3116,7 @@ H5D_istore_initialize_by_extent(H5D_io_info_t *io_info)
while(carry==0) {
for(u = 0, naccessed = 1; u < layout->u.chunk.ndims; u++) {
/* The location and size of the chunk being accessed */
- chunk_offset[u] = idx_cur[u] * (hssize_t)(layout->u.chunk.dim[u]);
+ chunk_offset[u] = idx_cur[u] * layout->u.chunk.dim[u];
sub_size[u] = MIN((idx_cur[u] + 1) * layout->u.chunk.dim[u],
size[u]) - chunk_offset[u];
naccessed *= sub_size[u];
@@ -3125,7 +3126,7 @@ H5D_istore_initialize_by_extent(H5D_io_info_t *io_info)
* Figure out what chunks have to be initialized. These are the chunks where the dataspace
* extent boundary is within the chunk
*/
- for(u = 0, found = 0; u < layout->u.chunk.ndims - 1; u++) {
+ for(u = 0, found = 0; u < rank; u++) {
end_chunk = chunk_offset[u] + layout->u.chunk.dim[u];
if(end_chunk > size[u]) {
found = 1;
@@ -3141,28 +3142,28 @@ H5D_istore_initialize_by_extent(H5D_io_info_t *io_info)
store.chunk.offset=chunk_offset;
if(NULL == (chunk = H5D_istore_lock(io_info, NULL, FALSE, &idx_hint)))
- HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to read raw data chunk");
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to read raw data chunk")
if(H5S_select_all(space_chunk,1) < 0)
- HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to select space");
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to select space")
for(u = 0; u < rank; u++)
count[u] = MIN((idx_cur[u] + 1) * layout->u.chunk.dim[u], size[u] - chunk_offset[u]);
#ifdef H5D_ISTORE_DEBUG
HDfputs("cache:initialize:offset:[", stdout);
- for(u = 0; u < layout->u.chunk.ndims - 1; u++)
+ for(u = 0; u < rank; u++)
HDfprintf(stdout, "%s%Hd", u ? ", " : "", chunk_offset[u]);
HDfputs("]", stdout);
HDfputs(":count:[", stdout);
- for(u = 0; u < layout->u.chunk.ndims - 1; u++)
+ for(u = 0; u < rank; u++)
HDfprintf(stdout, "%s%Hd", u ? ", " : "", count[u]);
HDfputs("]\n", stdout);
#endif
if(H5S_select_hyperslab(space_chunk, H5S_SELECT_NOTB, start, NULL,
count, NULL) < 0)
- HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to select hyperslab");
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to select hyperslab")
/* Fill the selection in the memory buffer */
/* Use the size of the elements in the chunk directly instead of */
@@ -3170,14 +3171,14 @@ H5D_istore_initialize_by_extent(H5D_io_info_t *io_info)
/* no fill-value defined for the dataset -QAK */
H5_CHECK_OVERFLOW(size[rank],hsize_t,size_t);
if(H5S_select_fill(fill.buf, (size_t)size[rank], space_chunk, chunk) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "filling selection failed");
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "filling selection failed")
if(H5D_istore_unlock(io_info, TRUE, idx_hint, chunk, (size_t)naccessed) < 0)
- HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to unlock raw data chunk");
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to unlock raw data chunk")
} /*found */
/* Increment indices */
- for(i = layout->u.chunk.ndims - 1, carry = 1; i >= 0 && carry; --i) {
+ for(i = (int)rank, carry = 1; i >= 0 && carry; --i) {
if(++idx_cur[i] >= idx_max[i])
idx_cur[i] = 0;
else
@@ -3187,9 +3188,10 @@ H5D_istore_initialize_by_extent(H5D_io_info_t *io_info)
done:
if(space_chunk)
- H5S_close(space_chunk);
+ if(H5S_close(space_chunk)<0)
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace")
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_istore_initialize_by_extent() */
@@ -3213,7 +3215,7 @@ H5D_istore_delete(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout)
{
herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5D_istore_delete, FAIL);
+ FUNC_ENTER_NOAPI(H5D_istore_delete, FAIL)
/* Check if the B-tree has been created in the file */
if(H5F_addr_defined(layout->u.chunk.addr)) {
@@ -3230,15 +3232,15 @@ H5D_istore_delete(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout)
/* Delete entire B-tree */
if(H5B_delete(f, dxpl_id, H5B_ISTORE, tmp_layout.u.chunk.addr, &udata)<0)
- HGOTO_ERROR(H5E_IO, H5E_CANTDELETE, 0, "unable to delete chunk B-tree");
+ HGOTO_ERROR(H5E_IO, H5E_CANTDELETE, 0, "unable to delete chunk B-tree")
/* Free the raw B-tree node buffer */
if(H5RC_DEC(tmp_layout.u.chunk.btree_shared)<0)
- HGOTO_ERROR (H5E_IO, H5E_CANTFREE, FAIL, "unable to decrement ref-counted page");
+ HGOTO_ERROR (H5E_IO, H5E_CANTFREE, FAIL, "unable to decrement ref-counted page")
} /* end if */
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_istore_delete() */
@@ -3267,7 +3269,6 @@ H5D_istore_update_cache(H5D_t *dset, hid_t dxpl_id)
H5D_rdcc_ent_t *old_ent; /* Old cache entry */
H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */
H5D_dxpl_cache_t *dxpl_cache=&_dxpl_cache; /* Data transfer property cache */
- int srank; /*current # of dimensions (signed) */
unsigned rank; /*current # of dimensions */
hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /*current dataspace dimensions */
hsize_t chunks[H5O_LAYOUT_NDIMS]; /*current number of chunks in each dimension */
@@ -3277,16 +3278,16 @@ H5D_istore_update_cache(H5D_t *dset, hid_t dxpl_id)
unsigned u; /*counters */
herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5D_istore_update_cache, FAIL);
+ FUNC_ENTER_NOAPI(H5D_istore_update_cache, FAIL)
/* Check args */
assert(dset && H5D_CHUNKED == dset->shared->layout.type);
assert(dset->shared->layout.u.chunk.ndims > 0 && dset->shared->layout.u.chunk.ndims <= H5O_LAYOUT_NDIMS);
/* Go get the rank & dimensions */
- if((srank = H5S_get_simple_extent_dims(dset->shared->space, curr_dims, NULL)) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions");
- H5_ASSIGN_OVERFLOW(rank,srank,int,unsigned);
+ rank = dset->shared->layout.u.chunk.ndims-1;
+ if(H5S_get_simple_extent_dims(dset->shared->space, curr_dims, NULL) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions")
/* Round up to the next integer # of chunks, to accomodate partial chunks */
for(u = 0; u < rank; u++)
@@ -3327,7 +3328,7 @@ H5D_istore_update_cache(H5D_t *dset, hid_t dxpl_id)
/* Remove the old entry from the cache */
if (H5D_istore_preempt(&io_info, old_ent, TRUE )<0)
- HGOTO_ERROR (H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks");
+ HGOTO_ERROR (H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks")
} /* end if */
/* Insert this chunk into correct location in hash table */
@@ -3339,7 +3340,7 @@ H5D_istore_update_cache(H5D_t *dset, hid_t dxpl_id)
} /* end for */
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5F_istore_update_cache() */
@@ -3368,7 +3369,7 @@ H5D_istore_dump_btree(H5F_t *f, hid_t dxpl_id, FILE *stream, unsigned ndims, had
H5D_istore_ud1_t udata;
herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5D_istore_dump_btree, FAIL);
+ FUNC_ENTER_NOAPI(H5D_istore_dump_btree, FAIL)
HDmemset(&udata, 0, sizeof udata);
layout.u.chunk.ndims = ndims;
@@ -3377,10 +3378,10 @@ H5D_istore_dump_btree(H5F_t *f, hid_t dxpl_id, FILE *stream, unsigned ndims, had
if(stream)
HDfprintf(stream, " Address: %a\n",addr);
if(H5B_iterate(f, dxpl_id, H5B_ISTORE, H5D_istore_iter_dump, addr, &udata)<0)
- HGOTO_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to iterate over chunk B-tree");
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to iterate over chunk B-tree")
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_istore_dump_btree() */
#ifdef H5D_ISTORE_DEBUG
@@ -3409,10 +3410,10 @@ H5D_istore_stats (H5D_t *dset, hbool_t headers)
char ascii[32];
herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5D_istore_stats, FAIL);
+ FUNC_ENTER_NOAPI(H5D_istore_stats, FAIL)
if (!H5DEBUG(AC))
- HGOTO_DONE(SUCCEED);
+ HGOTO_DONE(SUCCEED)
if (headers) {
fprintf(H5DEBUG(AC), "H5D: raw data cache statistics\n");
@@ -3445,7 +3446,7 @@ H5D_istore_stats (H5D_t *dset, hbool_t headers)
}
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_istore_stats() */
#endif /* H5D_ISTORE_DEBUG */
@@ -3467,13 +3468,13 @@ done:
*/
herr_t
H5D_istore_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent,
- int fwidth, int ndims)
+ int fwidth, unsigned ndims)
{
H5O_layout_t layout;
H5D_istore_ud1_t udata;
herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5D_istore_debug,FAIL);
+ FUNC_ENTER_NOAPI(H5D_istore_debug,FAIL)
layout.u.chunk.ndims = ndims;
HDmemset (&udata, 0, sizeof udata);
@@ -3483,12 +3484,12 @@ H5D_istore_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int inden
if(H5D_istore_shared_create(f, &layout)<0)
HGOTO_ERROR (H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create wrapper for shared B-tree info")
- H5B_debug (f, dxpl_id, addr, stream, indent, fwidth, H5B_ISTORE, &udata);
+ (void)H5B_debug (f, dxpl_id, addr, stream, indent, fwidth, H5B_ISTORE, &udata);
/* Free the raw B-tree node buffer */
if(H5RC_DEC(layout.u.chunk.btree_shared)<0)
- HGOTO_ERROR (H5E_IO, H5E_CANTFREE, FAIL, "unable to decrement ref-counted page");
+ HGOTO_ERROR (H5E_IO, H5E_CANTFREE, FAIL, "unable to decrement ref-counted page")
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_istore_debug() */