hdf5/src/H5Dbtree2.c

1517 lines
54 KiB
C
Raw Normal View History

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2020-04-21 07:12:00 +08:00
/*
*
* Purpose: v2 B-tree indexing for chunked datasets with > 1 unlimited dimensions.
* Each dataset chunk in the b-tree is identified by its dimensional offset.
*
*/
/****************/
/* Module Setup */
/****************/
2020-09-30 22:27:10 +08:00
#include "H5Dmodule.h" /* This source code file is part of the H5D module */
/***********/
/* Headers */
/***********/
2020-09-30 22:27:10 +08:00
#include "H5private.h" /* Generic Functions */
#include "H5Dpkg.h" /* Datasets */
#include "H5FLprivate.h" /* Free Lists */
#include "H5MFprivate.h" /* File space management */
#include "H5MMprivate.h" /* Memory management */
#include "H5VMprivate.h" /* Vector and array functions */
/****************/
/* Local Macros */
/****************/
/******************/
/* Local Typedefs */
/******************/
/* User data for creating callback context */
typedef struct H5D_bt2_ctx_ud_t {
2020-09-30 22:27:10 +08:00
const H5F_t *f; /* Pointer to file info */
uint32_t chunk_size; /* Size of chunk (bytes; for filtered object) */
unsigned ndims; /* Number of dimensions */
uint32_t * dim; /* Size of chunk in elements */
} H5D_bt2_ctx_ud_t;
/* The callback context */
typedef struct H5D_bt2_ctx_t {
2020-09-30 22:27:10 +08:00
uint32_t chunk_size; /* Size of chunk (bytes; constant for unfiltered object) */
size_t sizeof_addr; /* Size of file addresses in the file (bytes) */
size_t chunk_size_len; /* Size of chunk sizes in the file (bytes) */
unsigned ndims; /* Number of dimensions in chunk */
uint32_t *dim; /* Size of chunk in elements */
} H5D_bt2_ctx_t;
/* Callback info for iteration over chunks in v2 B-tree */
typedef struct H5D_bt2_it_ud_t {
2020-09-30 22:27:10 +08:00
H5D_chunk_cb_func_t cb; /* Callback routine for the chunk */
void * udata; /* User data for the chunk's callback routine */
} H5D_bt2_it_ud_t;
/* User data for compare callback */
typedef struct H5D_bt2_ud_t {
2020-09-30 22:27:10 +08:00
H5D_chunk_rec_t rec; /* The record to search for */
unsigned ndims; /* Number of dimensions for the chunked dataset */
} H5D_bt2_ud_t;
/********************/
/* Local Prototypes */
/********************/
/* Shared v2 B-tree methods for indexing filtered and non-filtered chunked datasets */
2020-09-30 22:27:10 +08:00
static void * H5D__bt2_crt_context(void *udata);
static herr_t H5D__bt2_dst_context(void *ctx);
static herr_t H5D__bt2_store(void *native, const void *udata);
static herr_t H5D__bt2_compare(const void *rec1, const void *rec2, int *result);
/* v2 B-tree class for indexing non-filtered chunked datasets */
static herr_t H5D__bt2_unfilt_encode(uint8_t *raw, const void *native, void *ctx);
static herr_t H5D__bt2_unfilt_decode(const uint8_t *raw, void *native, void *ctx);
2020-09-30 22:27:10 +08:00
static herr_t H5D__bt2_unfilt_debug(FILE *stream, int indent, int fwidth, const void *record,
const void *u_ctx);
/* v2 B-tree class for indexing filtered chunked datasets */
static herr_t H5D__bt2_filt_encode(uint8_t *raw, const void *native, void *ctx);
static herr_t H5D__bt2_filt_decode(const uint8_t *raw, void *native, void *ctx);
2020-09-30 22:27:10 +08:00
static herr_t H5D__bt2_filt_debug(FILE *stream, int indent, int fwidth, const void *record,
const void *u_ctx);
/* Helper routine */
static herr_t H5D__bt2_idx_open(const H5D_chk_idx_info_t *idx_info);
static herr_t H5D__btree2_idx_depend(const H5D_chk_idx_info_t *idx_info);
/* Callback for H5B2_iterate() which is called in H5D__bt2_idx_iterate() */
static int H5D__bt2_idx_iterate_cb(const void *_record, void *_udata);
/* Callback for H5B2_find() which is called in H5D__bt2_idx_get_addr() */
static herr_t H5D__bt2_found_cb(const void *nrecord, void *op_data);
2020-04-21 07:12:00 +08:00
/*
* Callback for H5B2_remove() and H5B2_delete() which is called
* in H5D__bt2_idx_remove() and H5D__bt2_idx_delete().
*/
static herr_t H5D__bt2_remove_cb(const void *nrecord, void *_udata);
/* Callback for H5B2_update() which is called in H5D__bt2_idx_insert() */
static herr_t H5D__bt2_mod_cb(void *_record, void *_op_data, hbool_t *changed);
/* Chunked layout indexing callbacks for v2 B-tree indexing */
2020-09-30 22:27:10 +08:00
static herr_t H5D__bt2_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t *space,
haddr_t dset_ohdr_addr);
static herr_t H5D__bt2_idx_create(const H5D_chk_idx_info_t *idx_info);
static hbool_t H5D__bt2_idx_is_space_alloc(const H5O_storage_chunk_t *storage);
2020-09-30 22:27:10 +08:00
static herr_t H5D__bt2_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata,
const H5D_t *dset);
static herr_t H5D__bt2_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata);
static int H5D__bt2_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb,
void *chunk_udata);
static herr_t H5D__bt2_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *udata);
static herr_t H5D__bt2_idx_delete(const H5D_chk_idx_info_t *idx_info);
static herr_t H5D__bt2_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src,
const H5D_chk_idx_info_t *idx_info_dst);
static herr_t H5D__bt2_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, H5O_storage_chunk_t *storage_dst);
static herr_t H5D__bt2_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *size);
static herr_t H5D__bt2_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr);
static herr_t H5D__bt2_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream);
static herr_t H5D__bt2_idx_dest(const H5D_chk_idx_info_t *idx_info);
/*********************/
/* Package Variables */
/*********************/
/* Chunked dataset I/O ops for v2 B-tree indexing */
const H5D_chunk_ops_t H5D_COPS_BT2[1] = {{
2020-09-30 22:27:10 +08:00
TRUE, /* Fixed array indices support SWMR access */
H5D__bt2_idx_init, /* init */
H5D__bt2_idx_create, /* create */
H5D__bt2_idx_is_space_alloc, /* is_space_alloc */
H5D__bt2_idx_insert, /* insert */
H5D__bt2_idx_get_addr, /* get_addr */
NULL, /* resize */
H5D__bt2_idx_iterate, /* iterate */
H5D__bt2_idx_remove, /* remove */
H5D__bt2_idx_delete, /* delete */
H5D__bt2_idx_copy_setup, /* copy_setup */
H5D__bt2_idx_copy_shutdown, /* copy_shutdown */
H5D__bt2_idx_size, /* size */
H5D__bt2_idx_reset, /* reset */
H5D__bt2_idx_dump, /* dump */
H5D__bt2_idx_dest /* destroy */
}};
/*****************************/
/* Library Private Variables */
/*****************************/
/* v2 B-tree class for indexing non-filtered chunked datasets */
2020-09-30 22:27:10 +08:00
const H5B2_class_t H5D_BT2[1] = {{
/* B-tree class information */
H5B2_CDSET_ID, /* Type of B-tree */
"H5B2_CDSET_ID", /* Name of B-tree class */
sizeof(H5D_chunk_rec_t), /* Size of native record */
H5D__bt2_crt_context, /* Create client callback context */
H5D__bt2_dst_context, /* Destroy client callback context */
H5D__bt2_store, /* Record storage callback */
H5D__bt2_compare, /* Record comparison callback */
H5D__bt2_unfilt_encode, /* Record encoding callback */
H5D__bt2_unfilt_decode, /* Record decoding callback */
H5D__bt2_unfilt_debug /* Record debugging callback */
}};
/* v2 B-tree class for indexing filtered chunked datasets */
2020-09-30 22:27:10 +08:00
const H5B2_class_t H5D_BT2_FILT[1] = {{
/* B-tree class information */
H5B2_CDSET_FILT_ID, /* Type of B-tree */
"H5B2_CDSET_FILT_ID", /* Name of B-tree class */
sizeof(H5D_chunk_rec_t), /* Size of native record */
H5D__bt2_crt_context, /* Create client callback context */
H5D__bt2_dst_context, /* Destroy client callback context */
H5D__bt2_store, /* Record storage callback */
H5D__bt2_compare, /* Record comparison callback */
H5D__bt2_filt_encode, /* Record encoding callback */
H5D__bt2_filt_decode, /* Record decoding callback */
H5D__bt2_filt_debug /* Record debugging callback */
}};
/*******************/
/* Local Variables */
/*******************/
/* Declare a free list to manage the H5D_bt2_ctx_t struct */
H5FL_DEFINE_STATIC(H5D_bt2_ctx_t);
/* Declare a free list to manage the page elements */
H5FL_ARR_DEFINE_STATIC(uint32_t, H5O_LAYOUT_NDIMS);
/*-------------------------------------------------------------------------
* Function: H5D__bt2_crt_context
*
* Purpose: Create client callback context
*
* Return: Success: non-NULL
* Failure: NULL
*
* Programmer: Vailin Choi; June 2010
*
*-------------------------------------------------------------------------
*/
static void *
H5D__bt2_crt_context(void *_udata)
{
H5D_bt2_ctx_ud_t *udata = (H5D_bt2_ctx_ud_t *)_udata; /* User data for building callback context */
2020-09-30 22:27:10 +08:00
H5D_bt2_ctx_t * ctx; /* Callback context structure */
uint32_t * my_dim = NULL; /* Pointer to copy of chunk dimension size */
void * ret_value = NULL; /* Return value */
FUNC_ENTER_PACKAGE
/* Sanity check */
HDassert(udata);
HDassert(udata->f);
HDassert(udata->ndims > 0 && udata->ndims < H5O_LAYOUT_NDIMS);
/* Allocate callback context */
2020-09-30 22:27:10 +08:00
if (NULL == (ctx = H5FL_MALLOC(H5D_bt2_ctx_t)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, NULL, "can't allocate callback context")
/* Determine the size of addresses and set the chunk size and # of dimensions for the dataset */
ctx->sizeof_addr = H5F_SIZEOF_ADDR(udata->f);
2020-09-30 22:27:10 +08:00
ctx->chunk_size = udata->chunk_size;
ctx->ndims = udata->ndims;
/* Set up the "local" information for this dataset's chunk dimension sizes */
2020-09-30 22:27:10 +08:00
if (NULL == (my_dim = (uint32_t *)H5FL_ARR_MALLOC(uint32_t, H5O_LAYOUT_NDIMS)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, NULL, "can't allocate chunk dims")
H5MM_memcpy(my_dim, udata->dim, H5O_LAYOUT_NDIMS * sizeof(uint32_t));
ctx->dim = my_dim;
2020-04-21 07:12:00 +08:00
/*
* Compute the size required for encoding the size of a chunk,
* allowing for an extra byte, in case the filter makes the chunk larger.
*/
ctx->chunk_size_len = 1 + ((H5VM_log2_gen((uint64_t)udata->chunk_size) + 8) / 8);
2020-09-30 22:27:10 +08:00
if (ctx->chunk_size_len > 8)
ctx->chunk_size_len = 8;
/* Set return value */
ret_value = ctx;
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5D__bt2_crt_context() */
/*-------------------------------------------------------------------------
* Function: H5D__bt2_dst_context
*
* Purpose: Destroy client callback context
*
* Return: Success: non-negative
* Failure: negative
*
* Programmer: Vailin Choi; June 2010
*
*-------------------------------------------------------------------------
*/
static herr_t
H5D__bt2_dst_context(void *_ctx)
{
2020-09-30 22:27:10 +08:00
H5D_bt2_ctx_t *ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */
FUNC_ENTER_PACKAGE_NOERR
/* Sanity check */
HDassert(ctx);
/* Free array for chunk dimension sizes */
2020-09-30 22:27:10 +08:00
if (ctx->dim)
H5FL_ARR_FREE(uint32_t, ctx->dim);
/* Release callback context */
ctx = H5FL_FREE(H5D_bt2_ctx_t, ctx);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5D__bt2_dst_context() */
/*-------------------------------------------------------------------------
* Function: H5D__bt2_store
*
* Purpose: Store native information into record for v2 B-tree
* (non-filtered)
*
* Return: Success: non-negative
* Failure: negative
*
* Programmer: Vailin Choi; June 2010
*
*-------------------------------------------------------------------------
*/
static herr_t
H5D__bt2_store(void *record, const void *_udata)
{
2020-09-30 22:27:10 +08:00
const H5D_bt2_ud_t *udata = (const H5D_bt2_ud_t *)_udata; /* User data */
FUNC_ENTER_PACKAGE_NOERR
*(H5D_chunk_rec_t *)record = udata->rec;
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5D__bt2_store() */
/*-------------------------------------------------------------------------
* Function: H5D__bt2_compare
*
* Purpose: Compare two native information records, according to some key
* (non-filtered)
*
* Return: <0 if rec1 < rec2
* =0 if rec1 == rec2
* >0 if rec1 > rec2
*
* Programmer: Vailin Choi; June 2010
*
*-------------------------------------------------------------------------
*/
static herr_t
H5D__bt2_compare(const void *_udata, const void *_rec2, int *result)
{
2020-09-30 22:27:10 +08:00
const H5D_bt2_ud_t * udata = (const H5D_bt2_ud_t *)_udata; /* User data */
const H5D_chunk_rec_t *rec1 = &(udata->rec); /* The search record */
const H5D_chunk_rec_t *rec2 = (const H5D_chunk_rec_t *)_rec2; /* The native record */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE_NOERR
/* Sanity checks */
HDassert(rec1);
HDassert(rec2);
/* Compare the offsets but ignore the other fields */
*result = H5VM_vector_cmp_u(udata->ndims, rec1->scaled, rec2->scaled);
FUNC_LEAVE_NOAPI(ret_value)
} /* H5D__bt2_compare() */
/*-------------------------------------------------------------------------
* Function: H5D__bt2_unfilt_encode
*
* Purpose: Encode native information into raw form for storing on disk
* (non-filtered)
*
* Return: Success: non-negative
* Failure: negative
*
* Programmer: Vailin Choi; June 2010
*
*-------------------------------------------------------------------------
*/
static herr_t
H5D__bt2_unfilt_encode(uint8_t *raw, const void *_record, void *_ctx)
{
2020-09-30 22:27:10 +08:00
H5D_bt2_ctx_t * ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */
const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* The native record */
2020-09-30 22:27:10 +08:00
unsigned u; /* Local index variable */
FUNC_ENTER_PACKAGE_NOERR
/* Sanity check */
HDassert(ctx);
/* Encode the record's fields */
H5F_addr_encode_len(ctx->sizeof_addr, &raw, record->chunk_addr);
/* (Don't encode the chunk size & filter mask for non-filtered B-tree records) */
2020-09-30 22:27:10 +08:00
for (u = 0; u < ctx->ndims; u++)
UINT64ENCODE(raw, record->scaled[u]);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5D__bt2_unfilt_encode() */
/*-------------------------------------------------------------------------
* Function: H5D__bt2_unfilt_decode
*
* Purpose: Decode raw disk form of record into native form
* (non-filtered)
*
* Return: Success: non-negative
* Failure: negative
*
* Programmer: Vailin Choi; June 2010
*
*-------------------------------------------------------------------------
*/
static herr_t
H5D__bt2_unfilt_decode(const uint8_t *raw, void *_record, void *_ctx)
{
2020-09-30 22:27:10 +08:00
H5D_bt2_ctx_t * ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */
H5D_chunk_rec_t *record = (H5D_chunk_rec_t *)_record; /* The native record */
unsigned u; /* Local index variable */
FUNC_ENTER_PACKAGE_NOERR
/* Sanity check */
HDassert(ctx);
/* Decode the record's fields */
H5F_addr_decode_len(ctx->sizeof_addr, &raw, &record->chunk_addr);
2020-09-30 22:27:10 +08:00
record->nbytes = ctx->chunk_size;
record->filter_mask = 0;
2020-09-30 22:27:10 +08:00
for (u = 0; u < ctx->ndims; u++)
UINT64DECODE(raw, record->scaled[u]);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5D__bt2_unfilt_decode() */
/*-------------------------------------------------------------------------
* Function: H5D__bt2_unfilt_debug
*
* Purpose: Debug native form of record (non-filtered)
*
* Return: Success: non-negative
* Failure: negative
*
* Programmer: Vailin Choi; June 2010
*
*-------------------------------------------------------------------------
*/
static herr_t
2020-09-30 22:27:10 +08:00
H5D__bt2_unfilt_debug(FILE *stream, int indent, int fwidth, const void *_record, const void *_ctx)
{
const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* The native record */
2020-09-30 22:27:10 +08:00
const H5D_bt2_ctx_t * ctx = (const H5D_bt2_ctx_t *)_ctx; /* Callback context */
unsigned u; /* Local index variable */
FUNC_ENTER_PACKAGE_NOERR
/* Sanity checks */
HDassert(record);
HDassert(ctx->chunk_size == record->nbytes);
HDassert(0 == record->filter_mask);
Squash my changes on branch `fprintf-experiment` into one commit for reapplication to my new warnings branch, `warnings-again`. These changes are included: commit 915551b7bf64e777dd2007386ec77b1d117770da Merge: 63858c2 a8892bb Author: David Young <dyoung@hdfgroup.org> Date: Mon Nov 25 17:39:49 2019 -0600 Merge remote-tracking branch 'hdf5/develop' into fprintf-experiment commit a8892bb42d6f6e4fbc30fae0eb2b957f81c938b9 Merge: 5c911d8 f907b51 Author: David Young <dyoung@hdfgroup.org> Date: Mon Nov 25 17:33:54 2019 -0600 Merge pull request #2055 in HDFFV/hdf5 from ~DYOUNG/vchoi_fork:add-werror-and-squash-some to develop * commit 'f907b511d06612dafc7814a7c30f2f3d2b76d52b': Oops, remove more C99 designated initializers for VS 2010 compatibility. commit 63858c22e168acaec0af8ced6641f26102cc6bb0 Merge: 20ae787 5c911d8 Author: David Young <dyoung@hdfgroup.org> Date: Mon Nov 25 17:04:42 2019 -0600 Merge remote-tracking branch 'hdf5/develop' into fprintf-experiment commit 5c911d8baf3ee7fe654269088eebdf07f59a8192 Merge: b8a5671 62208b0 Author: David Young <dyoung@hdfgroup.org> Date: Mon Nov 25 16:58:27 2019 -0600 Merge pull request #2030 in HDFFV/hdf5 from ~DYOUNG/vchoi_fork:add-werror-and-squash-some to develop * commit '62208b056a09c01855fbac7f75146be58ad6bfe5': (44 commits) Add an #include to get a function declaration. Don't use C99 designated initializers, they're not compatible with Visual Studio 2010. Quiet some more maybe-uninitialized warnings---each is a false positive, *sigh*. This is more code that may not compile with VS2010, *sigh sigh*. Always warn on maybe-uninitialized. -Wincompatible-pointer-types was not available until GCC 5, so enable it only if that's the GCC version we're using. Only promote maybe-uninitialized warnings to errors on GCC 8. Even on GCC 8, there may be false positives at low optimization levels? I need to check. Only use -Werror=cast-function-type with GCC 8 and later. Put all of the -W options back into the order I found them in so that it's easier to compare old and new config/gnu-flags. Add new source files to CMakeLists.txt. Mention the -Werror= flags in libhdf5.settings.in. free -> HDfree Promote decleration-after-statement warnings to errors. Quiet decleration-after-statement warnings. Move a statement under some declarations since some vintages of Visual Studio don't like declarations after statements. Document H5D__chunk_mem_xfree_wrapper(). Undo accidental test deletion. Oops, delete a debug printf that snuck in here. Undo my changes to the HD macros, hadn't really intended those to be on this branch.... Make errors of some more warnings. Move disabled warnings to DEVELOPER_WARNING_CFLAGS. Put just one warning option on a line, and sort some of the options. Cast to the parameter type, H5VL_token_t *, instead of to unsigned char *. Change hdset_reg_ref_t and H5R_ref_t from arrays of unsigned char to structs containing those arrays. Encapsulating the arrays in this way makes it easier to write and think about pointers to these types, casts to/from these types, etc. ... commit 20ae7877e33931b95e8c3502b027d6c3fe94a11f Merge: 46f8c61 edd5297 Author: David Young <dyoung@hdfgroup.org> Date: Fri Nov 22 15:34:09 2019 -0600 Merge remote-tracking branch 'origin/add-werror-and-squash-some' into fprintf-experiment commit 46f8c613d5117a8be5bc8385a072daa0b4262f06 Author: David Young <dyoung@hdfgroup.org> Date: Fri Nov 22 15:29:00 2019 -0600 GCC really wants us to use `ll` to format `long long`, so try to make that work before any other format modifier. Seems like we're not compiling the autoconf test program with -Werror=format ? Probably should. commit eee35b8ef3759c391327cd48a9b3c56b6f8abc99 Author: David Young <dyoung@hdfgroup.org> Date: Fri Nov 22 15:28:05 2019 -0600 It's hard to know just how wide an HDoff_t will be, and I don't think POSIX or C standards provide a PRI macro for it, so cast to intmax_t and format using PRIdMAX. commit 86eab12df7a89b546a38e99f8178dd2adbcb3433 Author: David Young <dyoung@hdfgroup.org> Date: Fri Nov 22 15:26:25 2019 -0600 URemove some casts.se the right format string for the argument. Here and there stop casting a printf argument. commit f722f7cbecbaa99449941484b014426f62f1bed5 Merge: 58e3743 6d5ec83 Author: David Young <dyoung@hdfgroup.org> Date: Fri Nov 22 14:44:16 2019 -0600 Merge branch 'add-werror-and-squash-some' into fprintf-experiment commit 58e3743b7faa9836606ee91798fe80dfc0040da7 Author: David Young <dyoung@hdfgroup.org> Date: Wed Nov 20 21:07:21 2019 -0600 Remove custom HDfprintf implementation, using the standard library's, instead. Take a swipe at repairing fprintf format strings, mainly replacing "%Hu" with "%" PRIuHSIZE, "%a" with "%" PRIuHADDR, "%Zu" with "%zu". Here and there remove an awkward cast of a printf argument to `long long` and use PRI[doux]8, PRI[doux]32, or PRI[doux]64, instead. Change occurrences of "%t" to "%s" and perform a suitable change of argument, `cond` -> `cond ? "TRUE" : "FALSE"`. Some occurrences of %Hu, %a, and %t remain, they just weren't flagged by the compiler because of #ifdef'age. commit d4366909293fa970c23512ac80e5d865d76cddbf Author: David Young <dyoung@hdfgroup.org> Date: Wed Nov 20 20:54:32 2019 -0600 Promote format-string warnigns to errors.
2019-11-28 03:58:43 +08:00
HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, "Chunk address:", record->chunk_addr);
HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Logical offset:");
2020-09-30 22:27:10 +08:00
for (u = 0; u < ctx->ndims; u++)
HDfprintf(stream, "%s%" PRIuHSIZE, u ? ", " : "", record->scaled[u] * ctx->dim[u]);
HDfputs("}\n", stream);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5D__bt2_unfilt_debug() */
/*-------------------------------------------------------------------------
* Function: H5D__bt2_filt_encode
*
* Purpose: Encode native information into raw form for storing on disk
* (filtered)
*
* Return: Success: non-negative
* Failure: negative
*
* Programmer: Vailin Choi; June 2010
*
*-------------------------------------------------------------------------
*/
static herr_t
H5D__bt2_filt_encode(uint8_t *raw, const void *_record, void *_ctx)
{
2020-09-30 22:27:10 +08:00
H5D_bt2_ctx_t * ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */
const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* The native record */
unsigned u; /* Local index variable */
FUNC_ENTER_PACKAGE_NOERR
/* Sanity check */
HDassert(ctx);
HDassert(record);
HDassert(H5F_addr_defined(record->chunk_addr));
HDassert(0 != record->nbytes);
/* Encode the record's fields */
H5F_addr_encode_len(ctx->sizeof_addr, &raw, record->chunk_addr);
UINT64ENCODE_VAR(raw, record->nbytes, ctx->chunk_size_len);
UINT32ENCODE(raw, record->filter_mask);
2020-09-30 22:27:10 +08:00
for (u = 0; u < ctx->ndims; u++)
UINT64ENCODE(raw, record->scaled[u]);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5D__bt2_filt_encode() */
/*-------------------------------------------------------------------------
* Function: H5D__bt2_filt_decode
*
* Purpose: Decode raw disk form of record into native form
* (filtered)
*
* Return: Success: non-negative
* Failure: negative
*
* Programmer: Vailin Choi; June 2010
*
*-------------------------------------------------------------------------
*/
static herr_t
H5D__bt2_filt_decode(const uint8_t *raw, void *_record, void *_ctx)
{
2020-09-30 22:27:10 +08:00
H5D_bt2_ctx_t * ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */
H5D_chunk_rec_t *record = (H5D_chunk_rec_t *)_record; /* The native record */
unsigned u; /* Local index variable */
FUNC_ENTER_PACKAGE_NOERR
/* Sanity check */
HDassert(ctx);
HDassert(record);
/* Decode the record's fields */
H5F_addr_decode_len(ctx->sizeof_addr, &raw, &record->chunk_addr);
UINT64DECODE_VAR(raw, record->nbytes, ctx->chunk_size_len);
UINT32DECODE(raw, record->filter_mask);
2020-09-30 22:27:10 +08:00
for (u = 0; u < ctx->ndims; u++)
UINT64DECODE(raw, record->scaled[u]);
/* Sanity checks */
HDassert(H5F_addr_defined(record->chunk_addr));
HDassert(0 != record->nbytes);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5D__bt2_filt_decode() */
/*-------------------------------------------------------------------------
* Function: H5D__bt2_filt_debug
*
* Purpose: Debug native form of record (filtered)
*
* Return: Success: non-negative
* Failure: negative
*
* Programmer: Vailin Choi; June 2010
*
*-------------------------------------------------------------------------
*/
static herr_t
2020-09-30 22:27:10 +08:00
H5D__bt2_filt_debug(FILE *stream, int indent, int fwidth, const void *_record, const void *_ctx)
{
2020-09-30 22:27:10 +08:00
const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* The native record */
const H5D_bt2_ctx_t * ctx = (const H5D_bt2_ctx_t *)_ctx; /* Callback context */
unsigned u; /* Local index variable */
2020-04-21 07:12:00 +08:00
FUNC_ENTER_PACKAGE_NOERR
/* Sanity checks */
HDassert(record);
HDassert(H5F_addr_defined(record->chunk_addr));
HDassert(0 != record->nbytes);
Squash my changes on branch `fprintf-experiment` into one commit for reapplication to my new warnings branch, `warnings-again`. These changes are included: commit 915551b7bf64e777dd2007386ec77b1d117770da Merge: 63858c2 a8892bb Author: David Young <dyoung@hdfgroup.org> Date: Mon Nov 25 17:39:49 2019 -0600 Merge remote-tracking branch 'hdf5/develop' into fprintf-experiment commit a8892bb42d6f6e4fbc30fae0eb2b957f81c938b9 Merge: 5c911d8 f907b51 Author: David Young <dyoung@hdfgroup.org> Date: Mon Nov 25 17:33:54 2019 -0600 Merge pull request #2055 in HDFFV/hdf5 from ~DYOUNG/vchoi_fork:add-werror-and-squash-some to develop * commit 'f907b511d06612dafc7814a7c30f2f3d2b76d52b': Oops, remove more C99 designated initializers for VS 2010 compatibility. commit 63858c22e168acaec0af8ced6641f26102cc6bb0 Merge: 20ae787 5c911d8 Author: David Young <dyoung@hdfgroup.org> Date: Mon Nov 25 17:04:42 2019 -0600 Merge remote-tracking branch 'hdf5/develop' into fprintf-experiment commit 5c911d8baf3ee7fe654269088eebdf07f59a8192 Merge: b8a5671 62208b0 Author: David Young <dyoung@hdfgroup.org> Date: Mon Nov 25 16:58:27 2019 -0600 Merge pull request #2030 in HDFFV/hdf5 from ~DYOUNG/vchoi_fork:add-werror-and-squash-some to develop * commit '62208b056a09c01855fbac7f75146be58ad6bfe5': (44 commits) Add an #include to get a function declaration. Don't use C99 designated initializers, they're not compatible with Visual Studio 2010. Quiet some more maybe-uninitialized warnings---each is a false positive, *sigh*. This is more code that may not compile with VS2010, *sigh sigh*. Always warn on maybe-uninitialized. -Wincompatible-pointer-types was not available until GCC 5, so enable it only if that's the GCC version we're using. Only promote maybe-uninitialized warnings to errors on GCC 8. Even on GCC 8, there may be false positives at low optimization levels? I need to check. Only use -Werror=cast-function-type with GCC 8 and later. Put all of the -W options back into the order I found them in so that it's easier to compare old and new config/gnu-flags. Add new source files to CMakeLists.txt. Mention the -Werror= flags in libhdf5.settings.in. free -> HDfree Promote decleration-after-statement warnings to errors. Quiet decleration-after-statement warnings. Move a statement under some declarations since some vintages of Visual Studio don't like declarations after statements. Document H5D__chunk_mem_xfree_wrapper(). Undo accidental test deletion. Oops, delete a debug printf that snuck in here. Undo my changes to the HD macros, hadn't really intended those to be on this branch.... Make errors of some more warnings. Move disabled warnings to DEVELOPER_WARNING_CFLAGS. Put just one warning option on a line, and sort some of the options. Cast to the parameter type, H5VL_token_t *, instead of to unsigned char *. Change hdset_reg_ref_t and H5R_ref_t from arrays of unsigned char to structs containing those arrays. Encapsulating the arrays in this way makes it easier to write and think about pointers to these types, casts to/from these types, etc. ... commit 20ae7877e33931b95e8c3502b027d6c3fe94a11f Merge: 46f8c61 edd5297 Author: David Young <dyoung@hdfgroup.org> Date: Fri Nov 22 15:34:09 2019 -0600 Merge remote-tracking branch 'origin/add-werror-and-squash-some' into fprintf-experiment commit 46f8c613d5117a8be5bc8385a072daa0b4262f06 Author: David Young <dyoung@hdfgroup.org> Date: Fri Nov 22 15:29:00 2019 -0600 GCC really wants us to use `ll` to format `long long`, so try to make that work before any other format modifier. Seems like we're not compiling the autoconf test program with -Werror=format ? Probably should. commit eee35b8ef3759c391327cd48a9b3c56b6f8abc99 Author: David Young <dyoung@hdfgroup.org> Date: Fri Nov 22 15:28:05 2019 -0600 It's hard to know just how wide an HDoff_t will be, and I don't think POSIX or C standards provide a PRI macro for it, so cast to intmax_t and format using PRIdMAX. commit 86eab12df7a89b546a38e99f8178dd2adbcb3433 Author: David Young <dyoung@hdfgroup.org> Date: Fri Nov 22 15:26:25 2019 -0600 URemove some casts.se the right format string for the argument. Here and there stop casting a printf argument. commit f722f7cbecbaa99449941484b014426f62f1bed5 Merge: 58e3743 6d5ec83 Author: David Young <dyoung@hdfgroup.org> Date: Fri Nov 22 14:44:16 2019 -0600 Merge branch 'add-werror-and-squash-some' into fprintf-experiment commit 58e3743b7faa9836606ee91798fe80dfc0040da7 Author: David Young <dyoung@hdfgroup.org> Date: Wed Nov 20 21:07:21 2019 -0600 Remove custom HDfprintf implementation, using the standard library's, instead. Take a swipe at repairing fprintf format strings, mainly replacing "%Hu" with "%" PRIuHSIZE, "%a" with "%" PRIuHADDR, "%Zu" with "%zu". Here and there remove an awkward cast of a printf argument to `long long` and use PRI[doux]8, PRI[doux]32, or PRI[doux]64, instead. Change occurrences of "%t" to "%s" and perform a suitable change of argument, `cond` -> `cond ? "TRUE" : "FALSE"`. Some occurrences of %Hu, %a, and %t remain, they just weren't flagged by the compiler because of #ifdef'age. commit d4366909293fa970c23512ac80e5d865d76cddbf Author: David Young <dyoung@hdfgroup.org> Date: Wed Nov 20 20:54:32 2019 -0600 Promote format-string warnigns to errors.
2019-11-28 03:58:43 +08:00
HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, "Chunk address:", record->chunk_addr);
HDfprintf(stream, "%*s%-*s %u bytes\n", indent, "", fwidth, "Chunk size:", (unsigned)record->nbytes);
HDfprintf(stream, "%*s%-*s 0x%08x\n", indent, "", fwidth, "Filter mask:", record->filter_mask);
HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Logical offset:");
2020-09-30 22:27:10 +08:00
for (u = 0; u < ctx->ndims; u++)
HDfprintf(stream, "%s%" PRIuHSIZE, u ? ", " : "", record->scaled[u] * ctx->dim[u]);
HDfputs("}\n", stream);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5D__bt2_filt_debug() */
/*-------------------------------------------------------------------------
* Function: H5D__bt2_idx_init
*
* Purpose: Initialize the indexing information for a dataset.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Neil Fortner
* Wednesday, May 23, 2012
*
*-------------------------------------------------------------------------
*/
static herr_t
2020-09-30 22:27:10 +08:00
H5D__bt2_idx_init(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info, const H5S_t H5_ATTR_UNUSED *space,
haddr_t dset_ohdr_addr)
{
FUNC_ENTER_PACKAGE_NOERR
/* Check args */
HDassert(H5F_addr_defined(dset_ohdr_addr));
idx_info->storage->u.btree2.dset_ohdr_addr = dset_ohdr_addr;
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5D__bt2_idx_init() */
/*-------------------------------------------------------------------------
* Function: H5D__btree2_idx_depend
*
* Purpose: Create flush dependency between v2 B-tree and dataset's
* object header.
*
* Return: Success: non-negative
* Failure: negative
*
* Programmer: Quincey Koziol
* Friday, December 18, 2015
*
*-------------------------------------------------------------------------
*/
static herr_t
H5D__btree2_idx_depend(const H5D_chk_idx_info_t *idx_info)
{
2020-09-30 22:27:10 +08:00
H5O_t * oh = NULL; /* Object header */
H5O_loc_t oloc; /* Temporary object header location for dataset */
H5AC_proxy_entry_t *oh_proxy; /* Dataset's object header proxy */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Check args */
HDassert(idx_info);
HDassert(idx_info->f);
HDassert(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE);
HDassert(idx_info->pline);
HDassert(idx_info->layout);
HDassert(H5D_CHUNK_IDX_BT2 == idx_info->layout->idx_type);
HDassert(idx_info->storage);
HDassert(H5D_CHUNK_IDX_BT2 == idx_info->storage->idx_type);
HDassert(H5F_addr_defined(idx_info->storage->idx_addr));
HDassert(idx_info->storage->u.btree2.bt2);
/* Set up object header location for dataset */
H5O_loc_reset(&oloc);
oloc.file = idx_info->f;
oloc.addr = idx_info->storage->u.btree.dset_ohdr_addr;
/* Get header */
2020-09-30 22:27:10 +08:00
if (NULL == (oh = H5O_protect(&oloc, H5AC__READ_ONLY_FLAG, TRUE)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTPROTECT, FAIL, "unable to protect object header")
/* Retrieve the dataset's object header proxy */
2020-09-30 22:27:10 +08:00
if (NULL == (oh_proxy = H5O_get_proxy(oh)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get dataset object header proxy")
/* Make the v2 B-tree a child flush dependency of the dataset's object header proxy */
2020-09-30 22:27:10 +08:00
if (H5B2_depend(idx_info->storage->u.btree2.bt2, oh_proxy) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL,
"unable to create flush dependency on object header proxy")
done:
/* Release the object header from the cache */
2020-09-30 22:27:10 +08:00
if (oh && H5O_unprotect(&oloc, oh, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__btree2_idx_depend() */
/*-------------------------------------------------------------------------
* Function: H5D__bt2_idx_open()
*
* Purpose: Opens an existing v2 B-tree.
*
* Note: This information is passively initialized from each index
* operation callback because those abstract chunk index operations
* are designed to work with the v2 B-tree chunk indices also,
* which don't require an 'open' for the data structure.
*
* Return: Success: non-negative
* Failure: negative
*
* Programmer: Vailin Choi; June 2010
*
*-------------------------------------------------------------------------
*/
static herr_t
H5D__bt2_idx_open(const H5D_chk_idx_info_t *idx_info)
{
2020-09-30 22:27:10 +08:00
H5D_bt2_ctx_ud_t u_ctx; /* user data for creating context */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Check args */
HDassert(idx_info);
HDassert(idx_info->f);
HDassert(idx_info->pline);
HDassert(idx_info->layout);
HDassert(H5D_CHUNK_IDX_BT2 == idx_info->layout->idx_type);
HDassert(idx_info->storage);
HDassert(H5F_addr_defined(idx_info->storage->idx_addr));
HDassert(NULL == idx_info->storage->u.btree2.bt2);
/* Set up the user data */
2020-09-30 22:27:10 +08:00
u_ctx.f = idx_info->f;
u_ctx.ndims = idx_info->layout->ndims - 1;
u_ctx.chunk_size = idx_info->layout->size;
2020-09-30 22:27:10 +08:00
u_ctx.dim = idx_info->layout->dim;
/* Open v2 B-tree for the chunk index */
2020-09-30 22:27:10 +08:00
if (NULL ==
(idx_info->storage->u.btree2.bt2 = H5B2_open(idx_info->f, idx_info->storage->idx_addr, &u_ctx)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't open v2 B-tree for tracking chunked dataset")
/* Check for SWMR writes to the file */
2020-09-30 22:27:10 +08:00
if (H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE)
if (H5D__btree2_idx_depend(idx_info) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL,
"unable to create flush dependency on object header")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__bt2_idx_open() */
/*-------------------------------------------------------------------------
2020-04-21 07:12:00 +08:00
* Function: H5D__bt2_idx_create
*
2020-04-21 07:12:00 +08:00
* Purpose: Create the v2 B-tree for tracking dataset chunks
*
* Return: SUCCEED/FAIL
*
* Programmer: Vailin Choi; June 2010
*
*-------------------------------------------------------------------------
*/
static herr_t
H5D__bt2_idx_create(const H5D_chk_idx_info_t *idx_info)
{
2020-09-30 22:27:10 +08:00
H5B2_create_t bt2_cparam; /* v2 B-tree creation parameters */
H5D_bt2_ctx_ud_t u_ctx; /* data for context call */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Check args */
HDassert(idx_info);
HDassert(idx_info->f);
HDassert(idx_info->pline);
HDassert(idx_info->layout);
HDassert(idx_info->storage);
HDassert(!H5F_addr_defined(idx_info->storage->idx_addr));
2020-09-30 22:27:10 +08:00
bt2_cparam.rrec_size = H5F_SIZEOF_ADDR(idx_info->f) /* Address of chunk */
+ (idx_info->layout->ndims - 1) * 8; /* # of dimensions x 64-bit chunk offsets */
/* General parameters */
2020-09-30 22:27:10 +08:00
if (idx_info->pline->nused > 0) {
unsigned chunk_size_len; /* Size of encoded chunk size */
2020-04-21 07:12:00 +08:00
/*
2020-09-30 22:27:10 +08:00
* Compute the size required for encoding the size of a chunk,
* allowing for an extra byte, in case the filter makes the chunk larger.
*/
chunk_size_len = 1 + ((H5VM_log2_gen((uint64_t)idx_info->layout->size) + 8) / 8);
2020-09-30 22:27:10 +08:00
if (chunk_size_len > 8)
chunk_size_len = 8;
2020-09-30 22:27:10 +08:00
bt2_cparam.rrec_size += chunk_size_len + 4; /* Size of encoded chunk size & filter mask */
bt2_cparam.cls = H5D_BT2_FILT;
} /* end if */
else
2020-09-30 22:27:10 +08:00
bt2_cparam.cls = H5D_BT2;
2020-09-30 22:27:10 +08:00
bt2_cparam.node_size = idx_info->layout->u.btree2.cparam.node_size;
bt2_cparam.split_percent = idx_info->layout->u.btree2.cparam.split_percent;
bt2_cparam.merge_percent = idx_info->layout->u.btree2.cparam.merge_percent;
2020-09-30 22:27:10 +08:00
u_ctx.f = idx_info->f;
u_ctx.ndims = idx_info->layout->ndims - 1;
u_ctx.chunk_size = idx_info->layout->size;
2020-09-30 22:27:10 +08:00
u_ctx.dim = idx_info->layout->dim;
/* Create the v2 B-tree for the chunked dataset */
2020-09-30 22:27:10 +08:00
if (NULL == (idx_info->storage->u.btree2.bt2 = H5B2_create(idx_info->f, &bt2_cparam, &u_ctx)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "can't create v2 B-tree for tracking chunked dataset")
/* Retrieve the v2 B-tree's address in the file */
2020-09-30 22:27:10 +08:00
if (H5B2_get_addr(idx_info->storage->u.btree2.bt2, &(idx_info->storage->idx_addr)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL,
"can't get v2 B-tree address for tracking chunked dataset")
/* Check for SWMR writes to the file */
2020-09-30 22:27:10 +08:00
if (H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE)
if (H5D__btree2_idx_depend(idx_info) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL,
"unable to create flush dependency on object header")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__bt2_idx_create() */
/*-------------------------------------------------------------------------
* Function: H5D__bt2_idx_is_space_alloc
*
* Purpose: Query if space is allocated for index method
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Vailin Choi; June 2010
*
*-------------------------------------------------------------------------
*/
static hbool_t
H5D__bt2_idx_is_space_alloc(const H5O_storage_chunk_t *storage)
{
FUNC_ENTER_PACKAGE_NOERR
/* Check args */
HDassert(storage);
FUNC_LEAVE_NOAPI((hbool_t)H5F_addr_defined(storage->idx_addr))
} /* end H5D__bt2_idx_is_space_alloc() */
/*-------------------------------------------------------------------------
* Function: H5D__bt2_mod_cb
*
* Purpose: Modify record for dataset chunk when it is found in a v2 B-tree.
* This is the callback for H5B2_update() which is called in
* H5D__bt2_idx_insert().
*
* Return: Success: non-negative
* Failure: negative
*
* Programmer: Vailin Choi; June 2010
*
*-------------------------------------------------------------------------
*/
static herr_t
H5D__bt2_mod_cb(void *_record, void *_op_data, hbool_t *changed)
{
2020-09-30 22:27:10 +08:00
H5D_bt2_ud_t * op_data = (H5D_bt2_ud_t *)_op_data; /* User data for v2 B-tree calls */
H5D_chunk_rec_t *record = (H5D_chunk_rec_t *)_record; /* Chunk record */
FUNC_ENTER_PACKAGE_NOERR
/* Sanity check */
#ifndef NDEBUG
2020-09-30 22:27:10 +08:00
{
unsigned u; /* Local index variable */
2020-09-30 22:27:10 +08:00
for (u = 0; u < op_data->ndims; u++)
HDassert(record->scaled[u] == op_data->rec.scaled[u]);
}
#endif /* NDEBUG */
/* Modify record */
*record = op_data->rec;
/* Note that the record changed */
*changed = TRUE;
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5D__bt2_mod_cb() */
/*-------------------------------------------------------------------------
* Function: H5D__bt2_idx_insert
*
* Purpose: Insert chunk address into the indexing structure.
2020-04-21 07:12:00 +08:00
* A non-filtered chunk:
* Should not exist
* Allocate the chunk and pass chunk address back up
* A filtered chunk:
* If it was not found, create the chunk and pass chunk address back up
* If it was found but its size changed, reallocate the chunk and pass chunk address back up
* If it was found but its size was the same, pass chunk address back up
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Vailin Choi; June 2010
*
*-------------------------------------------------------------------------
*/
static herr_t
H5D__bt2_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata,
2020-09-30 22:27:10 +08:00
const H5D_t H5_ATTR_UNUSED *dset)
{
2020-09-30 22:27:10 +08:00
H5B2_t * bt2; /* v2 B-tree handle for indexing chunks */
H5D_bt2_ud_t bt2_udata; /* User data for v2 B-tree calls */
unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Sanity checks */
HDassert(idx_info);
HDassert(idx_info->f);
HDassert(idx_info->pline);
HDassert(idx_info->layout);
HDassert(idx_info->storage);
HDassert(H5F_addr_defined(idx_info->storage->idx_addr));
HDassert(udata);
HDassert(H5F_addr_defined(udata->chunk_block.offset));
/* Check if the v2 B-tree is open yet */
2020-09-30 22:27:10 +08:00
if (NULL == idx_info->storage->u.btree2.bt2) {
/* Open existing v2 B-tree */
if (H5D__bt2_idx_open(idx_info) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open v2 B-tree")
2020-09-30 22:27:10 +08:00
} /* end if */
else /* Patch the top level file pointer contained in bt2 if needed */
if (H5B2_patch_file(idx_info->storage->u.btree2.bt2, idx_info->f) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch v2 B-tree file pointer")
/* Set convenience pointer to v2 B-tree structure */
bt2 = idx_info->storage->u.btree2.bt2;
/* Set up callback info */
2020-09-30 22:27:10 +08:00
bt2_udata.ndims = idx_info->layout->ndims - 1;
bt2_udata.rec.chunk_addr = udata->chunk_block.offset;
2020-09-30 22:27:10 +08:00
if (idx_info->pline->nused > 0) { /* filtered chunk */
H5_CHECKED_ASSIGN(bt2_udata.rec.nbytes, uint32_t, udata->chunk_block.length, hsize_t);
bt2_udata.rec.filter_mask = udata->filter_mask;
2020-09-30 22:27:10 +08:00
} /* end if */
else { /* non-filtered chunk */
2020-09-30 22:27:10 +08:00
bt2_udata.rec.nbytes = idx_info->layout->size;
bt2_udata.rec.filter_mask = 0;
} /* end else */
2020-09-30 22:27:10 +08:00
for (u = 0; u < (idx_info->layout->ndims - 1); u++)
bt2_udata.rec.scaled[u] = udata->common.scaled[u];
/* Update record for v2 B-tree (could be insert or modify) */
2020-09-30 22:27:10 +08:00
if (H5B2_update(bt2, &bt2_udata, H5D__bt2_mod_cb, &bt2_udata) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTUPDATE, FAIL, "unable to update record in v2 B-tree")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5D__bt2_idx_insert() */
/*-------------------------------------------------------------------------
* Function: H5D__bt2_found_cb
*
* Purpose: Retrieve record for dataset chunk when it is found in a v2 B-tree.
2020-04-21 07:12:00 +08:00
* This is the callback for H5B2_find() which is called in
* H5D__bt2_idx_get_addr() and H5D__bt2_idx_insert().
*
* Return: Success: non-negative
* Failure: negative
*
* Programmer: Vailin Choi; June 2010
*
*-------------------------------------------------------------------------
*/
static herr_t
H5D__bt2_found_cb(const void *nrecord, void *op_data)
{
FUNC_ENTER_PACKAGE_NOERR
*(H5D_chunk_rec_t *)op_data = *(const H5D_chunk_rec_t *)nrecord;
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5D__bt2_found_cb() */
/*-------------------------------------------------------------------------
* Function: H5D__bt2_idx_get_addr
*
* Purpose: Get the file address of a chunk if file space has been
* assigned. Save the retrieved information in the udata
* supplied.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Vailin Choi; June 2010
*
*-------------------------------------------------------------------------
*/
static herr_t
H5D__bt2_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata)
{
2020-09-30 22:27:10 +08:00
H5B2_t * bt2; /* v2 B-tree handle for indexing chunks */
H5D_bt2_ud_t bt2_udata; /* User data for v2 B-tree calls */
H5D_chunk_rec_t found_rec; /* Record found from searching for object */
unsigned u; /* Local index variable */
Bring async branch to develop (#166) * Add H5Fwait, H5Dwait, and other changes for async vol connector * Revert temporary testing changes * Add H5Fwait to header file * Add H5VLreset_lib_state() routine. * Correct VOL wrap context when retrieving library state for file open & create. * Manage the API context's VOL connector state as part of the library state. * Set the 'VOL connector property valid' flag when restoring the library state. * Don't push new API context on stack when retrieving "current" one. * Check for NULL VOL wrap context before decrementing refcount on it, when freeing the API context state. * Manage recount of underlying connector for VOL wrap context. * Add H5TSmutex_acquire() and H5TSmutex_release() routines to acquire and release the global lock on the HDF5 library. * Update library with new functions related to library global lock * Add asynchronous token API * Add new lightweight FUNC_ENTER / LEAVE macros for helping to structure the threadsafety (H5TS*) routines. * Sync w/develop * Initial event set code framework. * Elaborate on the H5ES routines, starting to add API routines. Update the "close ID" callbacks to allow asynchronous request tokens to be passed in from an asynchronous close API call. Refactor current asynchronous API routines (H5Fopen/H5Fclose and H5Dread/H5Dread) to use event sets instead of directly working with request tokens from the application. Clean up a few other minor warnings & code style issues. * Implement H5EScreate, H5ESget_count, and H5ESclose. It should be possible to write a simple application that creates an event set and uses it with H5Fopen_async, H5Dread_async, H5Dwrite_async, and H5Fclose_async, then calls H5ESclose (which waits for all async events to complete). * Add source file for event set test. * Refactor sync & async API routines to call common routine. Move dataset API read / write routines to src/H5D.c, along with all the other API routines. Progress on "fake" async VOL connector, for testing. * Modify async implementation to wrap async requests in a H5VL_object_t struct so the VOL layer can find the connector when accessing the request at a later point. * Free the requests is H5ESclose. Remove comments implying that request wait, notify, and cancel callbacks should free the request. * Fix bug in error handling in H5Fclose. * Fix bugs in async file routines. Rename H5VL_create_object_generic to H5VL_create_object. * Add explicit async version of H5Fcreate. * Add more _async routines * Correct typo for return value from H5Awrite changes * Add H5EStest and H5ESwait routines * Updated with API tracing info * Fix NULL pointer dereference in H5ES__wait * Add H5is_library_terminating() routine, so that VOL connectors can detect when the library is shutting down. * Fix typo * Remove event from event set's linked list * Move block of code so that vol_obj is valid * Avoid setting properties in the DXPL when reseting the library state (and in the test code). * Refactor argument tracing to implement new capability for tracing arguments of non-API routines, with the H5ARG_TRACE macro. This macro is updated automatically with the bin/trace script that runs as part of the autogen.sh process. Major changes were in src/H5trace.c and bin/trace, with the other changes being cleanups to the argument lists, to improve their presentation in the tracing output. Also - added the "managed string" routines, which can dynamically allocate strings, appending printf-formatted output to the string efficiently. * Release memory for managed strings * Fix printf() formats. * More printf() format fixes. * Add H5Eappend_stack routine and regression tests * Clean up a few missed merge conflicts and update the error stacks. * Remove unnecessary fork() operations and ten second sleep(). * Restore commented out attribute out, to better enable tracking down the previous failure * Allow multiple H5ARG_TRACE macros within a routine to be updated * Switch to using "new" H5ES_insert (which takes the arguments for the caller routine) for all event set operations. Renames H5ES_insert_new to H5ES_insert and removes the previous H5ES_insert. * Merge "managed" string routines into "ref-counted" strings, and refactor code to use them. * Add missing file. * Add caller's name and arguments to event, for error reporting * Refactor event set setup for "API common" internal routines * Checkin async API routines for H5A* and H5G* modules as listed in ID-283. Fix couple h5dump expected output files due to the changes. * Add some of the error query routines needed for event sets. * Refactor to make async setup / teardown and "common" routines cleaner * (1) Add async APIs to H5L, H5F, and H5D modules (2) Fix errors in previous checkins of async APIs in H5A and H5G modules (3) h5dump expected output changes * Enhance event info, for better error handling * Change name of temporary vol_obj variable, to help reduce coding errors * Fix oversight with vol_obj pointer * Minor code cleanup * Add missing \'valid\' flag for VOL wrapper context, when restoring the library\'s state * Run source formatter * Change H5TSmutex lock and release to include a lock count * Update error reporting ideas * Minor updates to improve sanity checking for retrieving / restoring library state * Updated with feedback from h5py team members * Refactor internal event set list and event handling, add implementation for H5ESget_err_info * Change the VOL request subclass callbacks that switch from using "H5ES_status_t" to "H5VL_request_status_t", and also add a H5VL_request_status_t* parameter to the 'cancel' callback in the request subclass. Also more code quality cleanups to add iterator callbacks to internal event set routines. * Update API tracing for new H5VL_request_status_t typedef * Finish converting internal event set operations to use list iterator callbacks, instead of directly accessing the list structure * Add H5VL_REQUEST_GET_ERR_STACK operation to request subclass, for retrieving a copy of the error stack for a failed asynchronous operation * Remove 'canceled' event status from Java constants * Be safer about releasing resources when inserting a newly opened/created object or file into an event set * Remove H5EStest, add H5ES_WAIT_NONE for 0 timeout, and revise parameters to H5ESwait, to make it more "aggregate". * Remove H5ES_STATUS_CANCELED from Java wrappers also * (a) Add async APIs for H5O module as listed in jira issue ID-283. (b) Remove verification of name parameter in async related routines for H55A and H5L modules because it is checked in H5VL_setup* routine. (c) Modify h5dump expected output due to the async changes. * Corrections based on PR feedback. * Further changes to make based on PR feedback. * Fix missed merge marker, and reformatted line * Clean up some warnings * Correct level of indirection * Relocate prototype (and doxygen info) for H5Aclose * Change non-static function declarations to be static * Ensure that H5TSpublic.h header gets installed (#129) * Add 'wrapper' versions of async calls, to allow language wrappers and layers on top of HDF5 to pass in their application information. * Switch H5Aexists\*_async and H5Lexists\*_async to use flag to return status, instead of return value. Make the corresponding changes through most of the v1 and v2 B-tree code. Clean up warnings in H5public.h and cmpd_dtransform.c. * Add H5Iregister_future routine and tests. * Correct return value for H5Lexists_async * Add H5_DLL macro to public H5ES API routines * Update supported -> flags parameter for introspect_query callback * Remove my email address. Update passthrough VOL connector ID. * Fix comment for post_open_api_common * Remove unused non-blocking VOL connector * Minor cleanup in async branch in preparation for merge to develop * Update CMake and the Autotools to use the new pass-through VOL ID * Fix for SWMR daily test failures (#160) The H5I_register_using_existing_id() call did not initialize the future ID callbacks, causing the library to segfault when it tried to resolve those function pointers. * Added selective async APIs (#150) * Added selective async APIs Description: Added the following APIs: H5Ropen_attr_async H5Ropen_object_async H5Ropen_region_async H5Mcreate_async H5Mopen_async H5Mput_async H5Mget_async H5Mclose_async H5Tcommit_async H5Topen_async H5Tcopy_async H5Tclose_async - Updated an expected output file to include a new internal function in the error stack for the failure case. * Updated async APIs per reviews, including removing async version of H5Tcopy. * Removed statements that were added by mistake in the previous commit. * Fix compile issues in H5M and warnings elsewhere * Reformat code * Brings VOL_LIST changes from develop. (#163) Co-authored-by: Houjun Tang <htang4@lbl.gov> Co-authored-by: Neil Fortner <nfortne2@hdfgroup.org> Co-authored-by: vchoi <vchoi@jelly.ad.hdfgroup.org> Co-authored-by: vchoi-hdfgroup <55293060+vchoi-hdfgroup@users.noreply.github.com> Co-authored-by: jhendersonHDF <jhenderson@hdfgroup.org> Co-authored-by: Dana Robinson <derobins@hdfgroup.org> Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com> Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com>
2020-12-14 08:02:17 +08:00
hbool_t found; /* Whether chunk was found */
2020-09-30 22:27:10 +08:00
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Sanity checks */
HDassert(idx_info);
HDassert(idx_info->f);
HDassert(idx_info->pline);
HDassert(idx_info->layout);
HDassert(idx_info->layout->ndims > 0);
HDassert(idx_info->storage);
HDassert(H5F_addr_defined(idx_info->storage->idx_addr));
HDassert(udata);
/* Check if the v2 B-tree is open yet */
2020-09-30 22:27:10 +08:00
if (NULL == idx_info->storage->u.btree2.bt2) {
/* Open existing v2 B-tree */
if (H5D__bt2_idx_open(idx_info) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open v2 B-tree")
2020-09-30 22:27:10 +08:00
} /* end if */
else /* Patch the top level file pointer contained in bt2 if needed */
if (H5B2_patch_file(idx_info->storage->u.btree2.bt2, idx_info->f) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch v2 B-tree file pointer")
/* Set convenience pointer to v2 B-tree structure */
bt2 = idx_info->storage->u.btree2.bt2;
/* Clear the found record */
2020-09-30 22:27:10 +08:00
found_rec.chunk_addr = HADDR_UNDEF;
found_rec.nbytes = 0;
found_rec.filter_mask = 0;
/* Prepare user data for compare callback */
bt2_udata.rec.chunk_addr = HADDR_UNDEF;
2020-09-30 22:27:10 +08:00
bt2_udata.ndims = idx_info->layout->ndims - 1;
/* Set the chunk offset to be searched for */
2020-09-30 22:27:10 +08:00
for (u = 0; u < (idx_info->layout->ndims - 1); u++)
bt2_udata.rec.scaled[u] = udata->common.scaled[u];
/* Go get chunk information from v2 B-tree */
Bring async branch to develop (#166) * Add H5Fwait, H5Dwait, and other changes for async vol connector * Revert temporary testing changes * Add H5Fwait to header file * Add H5VLreset_lib_state() routine. * Correct VOL wrap context when retrieving library state for file open & create. * Manage the API context's VOL connector state as part of the library state. * Set the 'VOL connector property valid' flag when restoring the library state. * Don't push new API context on stack when retrieving "current" one. * Check for NULL VOL wrap context before decrementing refcount on it, when freeing the API context state. * Manage recount of underlying connector for VOL wrap context. * Add H5TSmutex_acquire() and H5TSmutex_release() routines to acquire and release the global lock on the HDF5 library. * Update library with new functions related to library global lock * Add asynchronous token API * Add new lightweight FUNC_ENTER / LEAVE macros for helping to structure the threadsafety (H5TS*) routines. * Sync w/develop * Initial event set code framework. * Elaborate on the H5ES routines, starting to add API routines. Update the "close ID" callbacks to allow asynchronous request tokens to be passed in from an asynchronous close API call. Refactor current asynchronous API routines (H5Fopen/H5Fclose and H5Dread/H5Dread) to use event sets instead of directly working with request tokens from the application. Clean up a few other minor warnings & code style issues. * Implement H5EScreate, H5ESget_count, and H5ESclose. It should be possible to write a simple application that creates an event set and uses it with H5Fopen_async, H5Dread_async, H5Dwrite_async, and H5Fclose_async, then calls H5ESclose (which waits for all async events to complete). * Add source file for event set test. * Refactor sync & async API routines to call common routine. Move dataset API read / write routines to src/H5D.c, along with all the other API routines. Progress on "fake" async VOL connector, for testing. * Modify async implementation to wrap async requests in a H5VL_object_t struct so the VOL layer can find the connector when accessing the request at a later point. * Free the requests is H5ESclose. Remove comments implying that request wait, notify, and cancel callbacks should free the request. * Fix bug in error handling in H5Fclose. * Fix bugs in async file routines. Rename H5VL_create_object_generic to H5VL_create_object. * Add explicit async version of H5Fcreate. * Add more _async routines * Correct typo for return value from H5Awrite changes * Add H5EStest and H5ESwait routines * Updated with API tracing info * Fix NULL pointer dereference in H5ES__wait * Add H5is_library_terminating() routine, so that VOL connectors can detect when the library is shutting down. * Fix typo * Remove event from event set's linked list * Move block of code so that vol_obj is valid * Avoid setting properties in the DXPL when reseting the library state (and in the test code). * Refactor argument tracing to implement new capability for tracing arguments of non-API routines, with the H5ARG_TRACE macro. This macro is updated automatically with the bin/trace script that runs as part of the autogen.sh process. Major changes were in src/H5trace.c and bin/trace, with the other changes being cleanups to the argument lists, to improve their presentation in the tracing output. Also - added the "managed string" routines, which can dynamically allocate strings, appending printf-formatted output to the string efficiently. * Release memory for managed strings * Fix printf() formats. * More printf() format fixes. * Add H5Eappend_stack routine and regression tests * Clean up a few missed merge conflicts and update the error stacks. * Remove unnecessary fork() operations and ten second sleep(). * Restore commented out attribute out, to better enable tracking down the previous failure * Allow multiple H5ARG_TRACE macros within a routine to be updated * Switch to using "new" H5ES_insert (which takes the arguments for the caller routine) for all event set operations. Renames H5ES_insert_new to H5ES_insert and removes the previous H5ES_insert. * Merge "managed" string routines into "ref-counted" strings, and refactor code to use them. * Add missing file. * Add caller's name and arguments to event, for error reporting * Refactor event set setup for "API common" internal routines * Checkin async API routines for H5A* and H5G* modules as listed in ID-283. Fix couple h5dump expected output files due to the changes. * Add some of the error query routines needed for event sets. * Refactor to make async setup / teardown and "common" routines cleaner * (1) Add async APIs to H5L, H5F, and H5D modules (2) Fix errors in previous checkins of async APIs in H5A and H5G modules (3) h5dump expected output changes * Enhance event info, for better error handling * Change name of temporary vol_obj variable, to help reduce coding errors * Fix oversight with vol_obj pointer * Minor code cleanup * Add missing \'valid\' flag for VOL wrapper context, when restoring the library\'s state * Run source formatter * Change H5TSmutex lock and release to include a lock count * Update error reporting ideas * Minor updates to improve sanity checking for retrieving / restoring library state * Updated with feedback from h5py team members * Refactor internal event set list and event handling, add implementation for H5ESget_err_info * Change the VOL request subclass callbacks that switch from using "H5ES_status_t" to "H5VL_request_status_t", and also add a H5VL_request_status_t* parameter to the 'cancel' callback in the request subclass. Also more code quality cleanups to add iterator callbacks to internal event set routines. * Update API tracing for new H5VL_request_status_t typedef * Finish converting internal event set operations to use list iterator callbacks, instead of directly accessing the list structure * Add H5VL_REQUEST_GET_ERR_STACK operation to request subclass, for retrieving a copy of the error stack for a failed asynchronous operation * Remove 'canceled' event status from Java constants * Be safer about releasing resources when inserting a newly opened/created object or file into an event set * Remove H5EStest, add H5ES_WAIT_NONE for 0 timeout, and revise parameters to H5ESwait, to make it more "aggregate". * Remove H5ES_STATUS_CANCELED from Java wrappers also * (a) Add async APIs for H5O module as listed in jira issue ID-283. (b) Remove verification of name parameter in async related routines for H55A and H5L modules because it is checked in H5VL_setup* routine. (c) Modify h5dump expected output due to the async changes. * Corrections based on PR feedback. * Further changes to make based on PR feedback. * Fix missed merge marker, and reformatted line * Clean up some warnings * Correct level of indirection * Relocate prototype (and doxygen info) for H5Aclose * Change non-static function declarations to be static * Ensure that H5TSpublic.h header gets installed (#129) * Add 'wrapper' versions of async calls, to allow language wrappers and layers on top of HDF5 to pass in their application information. * Switch H5Aexists\*_async and H5Lexists\*_async to use flag to return status, instead of return value. Make the corresponding changes through most of the v1 and v2 B-tree code. Clean up warnings in H5public.h and cmpd_dtransform.c. * Add H5Iregister_future routine and tests. * Correct return value for H5Lexists_async * Add H5_DLL macro to public H5ES API routines * Update supported -> flags parameter for introspect_query callback * Remove my email address. Update passthrough VOL connector ID. * Fix comment for post_open_api_common * Remove unused non-blocking VOL connector * Minor cleanup in async branch in preparation for merge to develop * Update CMake and the Autotools to use the new pass-through VOL ID * Fix for SWMR daily test failures (#160) The H5I_register_using_existing_id() call did not initialize the future ID callbacks, causing the library to segfault when it tried to resolve those function pointers. * Added selective async APIs (#150) * Added selective async APIs Description: Added the following APIs: H5Ropen_attr_async H5Ropen_object_async H5Ropen_region_async H5Mcreate_async H5Mopen_async H5Mput_async H5Mget_async H5Mclose_async H5Tcommit_async H5Topen_async H5Tcopy_async H5Tclose_async - Updated an expected output file to include a new internal function in the error stack for the failure case. * Updated async APIs per reviews, including removing async version of H5Tcopy. * Removed statements that were added by mistake in the previous commit. * Fix compile issues in H5M and warnings elsewhere * Reformat code * Brings VOL_LIST changes from develop. (#163) Co-authored-by: Houjun Tang <htang4@lbl.gov> Co-authored-by: Neil Fortner <nfortne2@hdfgroup.org> Co-authored-by: vchoi <vchoi@jelly.ad.hdfgroup.org> Co-authored-by: vchoi-hdfgroup <55293060+vchoi-hdfgroup@users.noreply.github.com> Co-authored-by: jhendersonHDF <jhenderson@hdfgroup.org> Co-authored-by: Dana Robinson <derobins@hdfgroup.org> Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com> Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com>
2020-12-14 08:02:17 +08:00
found = FALSE;
if (H5B2_find(bt2, &bt2_udata, &found, H5D__bt2_found_cb, &found_rec) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTFIND, FAIL, "can't check for chunk in v2 B-tree")
Bring async branch to develop (#166) * Add H5Fwait, H5Dwait, and other changes for async vol connector * Revert temporary testing changes * Add H5Fwait to header file * Add H5VLreset_lib_state() routine. * Correct VOL wrap context when retrieving library state for file open & create. * Manage the API context's VOL connector state as part of the library state. * Set the 'VOL connector property valid' flag when restoring the library state. * Don't push new API context on stack when retrieving "current" one. * Check for NULL VOL wrap context before decrementing refcount on it, when freeing the API context state. * Manage recount of underlying connector for VOL wrap context. * Add H5TSmutex_acquire() and H5TSmutex_release() routines to acquire and release the global lock on the HDF5 library. * Update library with new functions related to library global lock * Add asynchronous token API * Add new lightweight FUNC_ENTER / LEAVE macros for helping to structure the threadsafety (H5TS*) routines. * Sync w/develop * Initial event set code framework. * Elaborate on the H5ES routines, starting to add API routines. Update the "close ID" callbacks to allow asynchronous request tokens to be passed in from an asynchronous close API call. Refactor current asynchronous API routines (H5Fopen/H5Fclose and H5Dread/H5Dread) to use event sets instead of directly working with request tokens from the application. Clean up a few other minor warnings & code style issues. * Implement H5EScreate, H5ESget_count, and H5ESclose. It should be possible to write a simple application that creates an event set and uses it with H5Fopen_async, H5Dread_async, H5Dwrite_async, and H5Fclose_async, then calls H5ESclose (which waits for all async events to complete). * Add source file for event set test. * Refactor sync & async API routines to call common routine. Move dataset API read / write routines to src/H5D.c, along with all the other API routines. Progress on "fake" async VOL connector, for testing. * Modify async implementation to wrap async requests in a H5VL_object_t struct so the VOL layer can find the connector when accessing the request at a later point. * Free the requests is H5ESclose. Remove comments implying that request wait, notify, and cancel callbacks should free the request. * Fix bug in error handling in H5Fclose. * Fix bugs in async file routines. Rename H5VL_create_object_generic to H5VL_create_object. * Add explicit async version of H5Fcreate. * Add more _async routines * Correct typo for return value from H5Awrite changes * Add H5EStest and H5ESwait routines * Updated with API tracing info * Fix NULL pointer dereference in H5ES__wait * Add H5is_library_terminating() routine, so that VOL connectors can detect when the library is shutting down. * Fix typo * Remove event from event set's linked list * Move block of code so that vol_obj is valid * Avoid setting properties in the DXPL when reseting the library state (and in the test code). * Refactor argument tracing to implement new capability for tracing arguments of non-API routines, with the H5ARG_TRACE macro. This macro is updated automatically with the bin/trace script that runs as part of the autogen.sh process. Major changes were in src/H5trace.c and bin/trace, with the other changes being cleanups to the argument lists, to improve their presentation in the tracing output. Also - added the "managed string" routines, which can dynamically allocate strings, appending printf-formatted output to the string efficiently. * Release memory for managed strings * Fix printf() formats. * More printf() format fixes. * Add H5Eappend_stack routine and regression tests * Clean up a few missed merge conflicts and update the error stacks. * Remove unnecessary fork() operations and ten second sleep(). * Restore commented out attribute out, to better enable tracking down the previous failure * Allow multiple H5ARG_TRACE macros within a routine to be updated * Switch to using "new" H5ES_insert (which takes the arguments for the caller routine) for all event set operations. Renames H5ES_insert_new to H5ES_insert and removes the previous H5ES_insert. * Merge "managed" string routines into "ref-counted" strings, and refactor code to use them. * Add missing file. * Add caller's name and arguments to event, for error reporting * Refactor event set setup for "API common" internal routines * Checkin async API routines for H5A* and H5G* modules as listed in ID-283. Fix couple h5dump expected output files due to the changes. * Add some of the error query routines needed for event sets. * Refactor to make async setup / teardown and "common" routines cleaner * (1) Add async APIs to H5L, H5F, and H5D modules (2) Fix errors in previous checkins of async APIs in H5A and H5G modules (3) h5dump expected output changes * Enhance event info, for better error handling * Change name of temporary vol_obj variable, to help reduce coding errors * Fix oversight with vol_obj pointer * Minor code cleanup * Add missing \'valid\' flag for VOL wrapper context, when restoring the library\'s state * Run source formatter * Change H5TSmutex lock and release to include a lock count * Update error reporting ideas * Minor updates to improve sanity checking for retrieving / restoring library state * Updated with feedback from h5py team members * Refactor internal event set list and event handling, add implementation for H5ESget_err_info * Change the VOL request subclass callbacks that switch from using "H5ES_status_t" to "H5VL_request_status_t", and also add a H5VL_request_status_t* parameter to the 'cancel' callback in the request subclass. Also more code quality cleanups to add iterator callbacks to internal event set routines. * Update API tracing for new H5VL_request_status_t typedef * Finish converting internal event set operations to use list iterator callbacks, instead of directly accessing the list structure * Add H5VL_REQUEST_GET_ERR_STACK operation to request subclass, for retrieving a copy of the error stack for a failed asynchronous operation * Remove 'canceled' event status from Java constants * Be safer about releasing resources when inserting a newly opened/created object or file into an event set * Remove H5EStest, add H5ES_WAIT_NONE for 0 timeout, and revise parameters to H5ESwait, to make it more "aggregate". * Remove H5ES_STATUS_CANCELED from Java wrappers also * (a) Add async APIs for H5O module as listed in jira issue ID-283. (b) Remove verification of name parameter in async related routines for H55A and H5L modules because it is checked in H5VL_setup* routine. (c) Modify h5dump expected output due to the async changes. * Corrections based on PR feedback. * Further changes to make based on PR feedback. * Fix missed merge marker, and reformatted line * Clean up some warnings * Correct level of indirection * Relocate prototype (and doxygen info) for H5Aclose * Change non-static function declarations to be static * Ensure that H5TSpublic.h header gets installed (#129) * Add 'wrapper' versions of async calls, to allow language wrappers and layers on top of HDF5 to pass in their application information. * Switch H5Aexists\*_async and H5Lexists\*_async to use flag to return status, instead of return value. Make the corresponding changes through most of the v1 and v2 B-tree code. Clean up warnings in H5public.h and cmpd_dtransform.c. * Add H5Iregister_future routine and tests. * Correct return value for H5Lexists_async * Add H5_DLL macro to public H5ES API routines * Update supported -> flags parameter for introspect_query callback * Remove my email address. Update passthrough VOL connector ID. * Fix comment for post_open_api_common * Remove unused non-blocking VOL connector * Minor cleanup in async branch in preparation for merge to develop * Update CMake and the Autotools to use the new pass-through VOL ID * Fix for SWMR daily test failures (#160) The H5I_register_using_existing_id() call did not initialize the future ID callbacks, causing the library to segfault when it tried to resolve those function pointers. * Added selective async APIs (#150) * Added selective async APIs Description: Added the following APIs: H5Ropen_attr_async H5Ropen_object_async H5Ropen_region_async H5Mcreate_async H5Mopen_async H5Mput_async H5Mget_async H5Mclose_async H5Tcommit_async H5Topen_async H5Tcopy_async H5Tclose_async - Updated an expected output file to include a new internal function in the error stack for the failure case. * Updated async APIs per reviews, including removing async version of H5Tcopy. * Removed statements that were added by mistake in the previous commit. * Fix compile issues in H5M and warnings elsewhere * Reformat code * Brings VOL_LIST changes from develop. (#163) Co-authored-by: Houjun Tang <htang4@lbl.gov> Co-authored-by: Neil Fortner <nfortne2@hdfgroup.org> Co-authored-by: vchoi <vchoi@jelly.ad.hdfgroup.org> Co-authored-by: vchoi-hdfgroup <55293060+vchoi-hdfgroup@users.noreply.github.com> Co-authored-by: jhendersonHDF <jhenderson@hdfgroup.org> Co-authored-by: Dana Robinson <derobins@hdfgroup.org> Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com> Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com>
2020-12-14 08:02:17 +08:00
/* Check if chunk was found */
if (found) {
/* Sanity check */
HDassert(0 != found_rec.nbytes);
Bring async branch to develop (#166) * Add H5Fwait, H5Dwait, and other changes for async vol connector * Revert temporary testing changes * Add H5Fwait to header file * Add H5VLreset_lib_state() routine. * Correct VOL wrap context when retrieving library state for file open & create. * Manage the API context's VOL connector state as part of the library state. * Set the 'VOL connector property valid' flag when restoring the library state. * Don't push new API context on stack when retrieving "current" one. * Check for NULL VOL wrap context before decrementing refcount on it, when freeing the API context state. * Manage recount of underlying connector for VOL wrap context. * Add H5TSmutex_acquire() and H5TSmutex_release() routines to acquire and release the global lock on the HDF5 library. * Update library with new functions related to library global lock * Add asynchronous token API * Add new lightweight FUNC_ENTER / LEAVE macros for helping to structure the threadsafety (H5TS*) routines. * Sync w/develop * Initial event set code framework. * Elaborate on the H5ES routines, starting to add API routines. Update the "close ID" callbacks to allow asynchronous request tokens to be passed in from an asynchronous close API call. Refactor current asynchronous API routines (H5Fopen/H5Fclose and H5Dread/H5Dread) to use event sets instead of directly working with request tokens from the application. Clean up a few other minor warnings & code style issues. * Implement H5EScreate, H5ESget_count, and H5ESclose. It should be possible to write a simple application that creates an event set and uses it with H5Fopen_async, H5Dread_async, H5Dwrite_async, and H5Fclose_async, then calls H5ESclose (which waits for all async events to complete). * Add source file for event set test. * Refactor sync & async API routines to call common routine. Move dataset API read / write routines to src/H5D.c, along with all the other API routines. Progress on "fake" async VOL connector, for testing. * Modify async implementation to wrap async requests in a H5VL_object_t struct so the VOL layer can find the connector when accessing the request at a later point. * Free the requests is H5ESclose. Remove comments implying that request wait, notify, and cancel callbacks should free the request. * Fix bug in error handling in H5Fclose. * Fix bugs in async file routines. Rename H5VL_create_object_generic to H5VL_create_object. * Add explicit async version of H5Fcreate. * Add more _async routines * Correct typo for return value from H5Awrite changes * Add H5EStest and H5ESwait routines * Updated with API tracing info * Fix NULL pointer dereference in H5ES__wait * Add H5is_library_terminating() routine, so that VOL connectors can detect when the library is shutting down. * Fix typo * Remove event from event set's linked list * Move block of code so that vol_obj is valid * Avoid setting properties in the DXPL when reseting the library state (and in the test code). * Refactor argument tracing to implement new capability for tracing arguments of non-API routines, with the H5ARG_TRACE macro. This macro is updated automatically with the bin/trace script that runs as part of the autogen.sh process. Major changes were in src/H5trace.c and bin/trace, with the other changes being cleanups to the argument lists, to improve their presentation in the tracing output. Also - added the "managed string" routines, which can dynamically allocate strings, appending printf-formatted output to the string efficiently. * Release memory for managed strings * Fix printf() formats. * More printf() format fixes. * Add H5Eappend_stack routine and regression tests * Clean up a few missed merge conflicts and update the error stacks. * Remove unnecessary fork() operations and ten second sleep(). * Restore commented out attribute out, to better enable tracking down the previous failure * Allow multiple H5ARG_TRACE macros within a routine to be updated * Switch to using "new" H5ES_insert (which takes the arguments for the caller routine) for all event set operations. Renames H5ES_insert_new to H5ES_insert and removes the previous H5ES_insert. * Merge "managed" string routines into "ref-counted" strings, and refactor code to use them. * Add missing file. * Add caller's name and arguments to event, for error reporting * Refactor event set setup for "API common" internal routines * Checkin async API routines for H5A* and H5G* modules as listed in ID-283. Fix couple h5dump expected output files due to the changes. * Add some of the error query routines needed for event sets. * Refactor to make async setup / teardown and "common" routines cleaner * (1) Add async APIs to H5L, H5F, and H5D modules (2) Fix errors in previous checkins of async APIs in H5A and H5G modules (3) h5dump expected output changes * Enhance event info, for better error handling * Change name of temporary vol_obj variable, to help reduce coding errors * Fix oversight with vol_obj pointer * Minor code cleanup * Add missing \'valid\' flag for VOL wrapper context, when restoring the library\'s state * Run source formatter * Change H5TSmutex lock and release to include a lock count * Update error reporting ideas * Minor updates to improve sanity checking for retrieving / restoring library state * Updated with feedback from h5py team members * Refactor internal event set list and event handling, add implementation for H5ESget_err_info * Change the VOL request subclass callbacks that switch from using "H5ES_status_t" to "H5VL_request_status_t", and also add a H5VL_request_status_t* parameter to the 'cancel' callback in the request subclass. Also more code quality cleanups to add iterator callbacks to internal event set routines. * Update API tracing for new H5VL_request_status_t typedef * Finish converting internal event set operations to use list iterator callbacks, instead of directly accessing the list structure * Add H5VL_REQUEST_GET_ERR_STACK operation to request subclass, for retrieving a copy of the error stack for a failed asynchronous operation * Remove 'canceled' event status from Java constants * Be safer about releasing resources when inserting a newly opened/created object or file into an event set * Remove H5EStest, add H5ES_WAIT_NONE for 0 timeout, and revise parameters to H5ESwait, to make it more "aggregate". * Remove H5ES_STATUS_CANCELED from Java wrappers also * (a) Add async APIs for H5O module as listed in jira issue ID-283. (b) Remove verification of name parameter in async related routines for H55A and H5L modules because it is checked in H5VL_setup* routine. (c) Modify h5dump expected output due to the async changes. * Corrections based on PR feedback. * Further changes to make based on PR feedback. * Fix missed merge marker, and reformatted line * Clean up some warnings * Correct level of indirection * Relocate prototype (and doxygen info) for H5Aclose * Change non-static function declarations to be static * Ensure that H5TSpublic.h header gets installed (#129) * Add 'wrapper' versions of async calls, to allow language wrappers and layers on top of HDF5 to pass in their application information. * Switch H5Aexists\*_async and H5Lexists\*_async to use flag to return status, instead of return value. Make the corresponding changes through most of the v1 and v2 B-tree code. Clean up warnings in H5public.h and cmpd_dtransform.c. * Add H5Iregister_future routine and tests. * Correct return value for H5Lexists_async * Add H5_DLL macro to public H5ES API routines * Update supported -> flags parameter for introspect_query callback * Remove my email address. Update passthrough VOL connector ID. * Fix comment for post_open_api_common * Remove unused non-blocking VOL connector * Minor cleanup in async branch in preparation for merge to develop * Update CMake and the Autotools to use the new pass-through VOL ID * Fix for SWMR daily test failures (#160) The H5I_register_using_existing_id() call did not initialize the future ID callbacks, causing the library to segfault when it tried to resolve those function pointers. * Added selective async APIs (#150) * Added selective async APIs Description: Added the following APIs: H5Ropen_attr_async H5Ropen_object_async H5Ropen_region_async H5Mcreate_async H5Mopen_async H5Mput_async H5Mget_async H5Mclose_async H5Tcommit_async H5Topen_async H5Tcopy_async H5Tclose_async - Updated an expected output file to include a new internal function in the error stack for the failure case. * Updated async APIs per reviews, including removing async version of H5Tcopy. * Removed statements that were added by mistake in the previous commit. * Fix compile issues in H5M and warnings elsewhere * Reformat code * Brings VOL_LIST changes from develop. (#163) Co-authored-by: Houjun Tang <htang4@lbl.gov> Co-authored-by: Neil Fortner <nfortne2@hdfgroup.org> Co-authored-by: vchoi <vchoi@jelly.ad.hdfgroup.org> Co-authored-by: vchoi-hdfgroup <55293060+vchoi-hdfgroup@users.noreply.github.com> Co-authored-by: jhendersonHDF <jhenderson@hdfgroup.org> Co-authored-by: Dana Robinson <derobins@hdfgroup.org> Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com> Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com>
2020-12-14 08:02:17 +08:00
/* Set common info for the chunk */
udata->chunk_block.offset = found_rec.chunk_addr;
/* Set other info for the chunk */
2020-09-30 22:27:10 +08:00
if (idx_info->pline->nused > 0) { /* filtered chunk */
udata->chunk_block.length = found_rec.nbytes;
2020-09-30 22:27:10 +08:00
udata->filter_mask = found_rec.filter_mask;
} /* end if */
else { /* non-filtered chunk */
udata->chunk_block.length = idx_info->layout->size;
2020-09-30 22:27:10 +08:00
udata->filter_mask = 0;
} /* end else */
2020-09-30 22:27:10 +08:00
} /* end if */
else {
Bring async branch to develop (#166) * Add H5Fwait, H5Dwait, and other changes for async vol connector * Revert temporary testing changes * Add H5Fwait to header file * Add H5VLreset_lib_state() routine. * Correct VOL wrap context when retrieving library state for file open & create. * Manage the API context's VOL connector state as part of the library state. * Set the 'VOL connector property valid' flag when restoring the library state. * Don't push new API context on stack when retrieving "current" one. * Check for NULL VOL wrap context before decrementing refcount on it, when freeing the API context state. * Manage recount of underlying connector for VOL wrap context. * Add H5TSmutex_acquire() and H5TSmutex_release() routines to acquire and release the global lock on the HDF5 library. * Update library with new functions related to library global lock * Add asynchronous token API * Add new lightweight FUNC_ENTER / LEAVE macros for helping to structure the threadsafety (H5TS*) routines. * Sync w/develop * Initial event set code framework. * Elaborate on the H5ES routines, starting to add API routines. Update the "close ID" callbacks to allow asynchronous request tokens to be passed in from an asynchronous close API call. Refactor current asynchronous API routines (H5Fopen/H5Fclose and H5Dread/H5Dread) to use event sets instead of directly working with request tokens from the application. Clean up a few other minor warnings & code style issues. * Implement H5EScreate, H5ESget_count, and H5ESclose. It should be possible to write a simple application that creates an event set and uses it with H5Fopen_async, H5Dread_async, H5Dwrite_async, and H5Fclose_async, then calls H5ESclose (which waits for all async events to complete). * Add source file for event set test. * Refactor sync & async API routines to call common routine. Move dataset API read / write routines to src/H5D.c, along with all the other API routines. Progress on "fake" async VOL connector, for testing. * Modify async implementation to wrap async requests in a H5VL_object_t struct so the VOL layer can find the connector when accessing the request at a later point. * Free the requests is H5ESclose. Remove comments implying that request wait, notify, and cancel callbacks should free the request. * Fix bug in error handling in H5Fclose. * Fix bugs in async file routines. Rename H5VL_create_object_generic to H5VL_create_object. * Add explicit async version of H5Fcreate. * Add more _async routines * Correct typo for return value from H5Awrite changes * Add H5EStest and H5ESwait routines * Updated with API tracing info * Fix NULL pointer dereference in H5ES__wait * Add H5is_library_terminating() routine, so that VOL connectors can detect when the library is shutting down. * Fix typo * Remove event from event set's linked list * Move block of code so that vol_obj is valid * Avoid setting properties in the DXPL when reseting the library state (and in the test code). * Refactor argument tracing to implement new capability for tracing arguments of non-API routines, with the H5ARG_TRACE macro. This macro is updated automatically with the bin/trace script that runs as part of the autogen.sh process. Major changes were in src/H5trace.c and bin/trace, with the other changes being cleanups to the argument lists, to improve their presentation in the tracing output. Also - added the "managed string" routines, which can dynamically allocate strings, appending printf-formatted output to the string efficiently. * Release memory for managed strings * Fix printf() formats. * More printf() format fixes. * Add H5Eappend_stack routine and regression tests * Clean up a few missed merge conflicts and update the error stacks. * Remove unnecessary fork() operations and ten second sleep(). * Restore commented out attribute out, to better enable tracking down the previous failure * Allow multiple H5ARG_TRACE macros within a routine to be updated * Switch to using "new" H5ES_insert (which takes the arguments for the caller routine) for all event set operations. Renames H5ES_insert_new to H5ES_insert and removes the previous H5ES_insert. * Merge "managed" string routines into "ref-counted" strings, and refactor code to use them. * Add missing file. * Add caller's name and arguments to event, for error reporting * Refactor event set setup for "API common" internal routines * Checkin async API routines for H5A* and H5G* modules as listed in ID-283. Fix couple h5dump expected output files due to the changes. * Add some of the error query routines needed for event sets. * Refactor to make async setup / teardown and "common" routines cleaner * (1) Add async APIs to H5L, H5F, and H5D modules (2) Fix errors in previous checkins of async APIs in H5A and H5G modules (3) h5dump expected output changes * Enhance event info, for better error handling * Change name of temporary vol_obj variable, to help reduce coding errors * Fix oversight with vol_obj pointer * Minor code cleanup * Add missing \'valid\' flag for VOL wrapper context, when restoring the library\'s state * Run source formatter * Change H5TSmutex lock and release to include a lock count * Update error reporting ideas * Minor updates to improve sanity checking for retrieving / restoring library state * Updated with feedback from h5py team members * Refactor internal event set list and event handling, add implementation for H5ESget_err_info * Change the VOL request subclass callbacks that switch from using "H5ES_status_t" to "H5VL_request_status_t", and also add a H5VL_request_status_t* parameter to the 'cancel' callback in the request subclass. Also more code quality cleanups to add iterator callbacks to internal event set routines. * Update API tracing for new H5VL_request_status_t typedef * Finish converting internal event set operations to use list iterator callbacks, instead of directly accessing the list structure * Add H5VL_REQUEST_GET_ERR_STACK operation to request subclass, for retrieving a copy of the error stack for a failed asynchronous operation * Remove 'canceled' event status from Java constants * Be safer about releasing resources when inserting a newly opened/created object or file into an event set * Remove H5EStest, add H5ES_WAIT_NONE for 0 timeout, and revise parameters to H5ESwait, to make it more "aggregate". * Remove H5ES_STATUS_CANCELED from Java wrappers also * (a) Add async APIs for H5O module as listed in jira issue ID-283. (b) Remove verification of name parameter in async related routines for H55A and H5L modules because it is checked in H5VL_setup* routine. (c) Modify h5dump expected output due to the async changes. * Corrections based on PR feedback. * Further changes to make based on PR feedback. * Fix missed merge marker, and reformatted line * Clean up some warnings * Correct level of indirection * Relocate prototype (and doxygen info) for H5Aclose * Change non-static function declarations to be static * Ensure that H5TSpublic.h header gets installed (#129) * Add 'wrapper' versions of async calls, to allow language wrappers and layers on top of HDF5 to pass in their application information. * Switch H5Aexists\*_async and H5Lexists\*_async to use flag to return status, instead of return value. Make the corresponding changes through most of the v1 and v2 B-tree code. Clean up warnings in H5public.h and cmpd_dtransform.c. * Add H5Iregister_future routine and tests. * Correct return value for H5Lexists_async * Add H5_DLL macro to public H5ES API routines * Update supported -> flags parameter for introspect_query callback * Remove my email address. Update passthrough VOL connector ID. * Fix comment for post_open_api_common * Remove unused non-blocking VOL connector * Minor cleanup in async branch in preparation for merge to develop * Update CMake and the Autotools to use the new pass-through VOL ID * Fix for SWMR daily test failures (#160) The H5I_register_using_existing_id() call did not initialize the future ID callbacks, causing the library to segfault when it tried to resolve those function pointers. * Added selective async APIs (#150) * Added selective async APIs Description: Added the following APIs: H5Ropen_attr_async H5Ropen_object_async H5Ropen_region_async H5Mcreate_async H5Mopen_async H5Mput_async H5Mget_async H5Mclose_async H5Tcommit_async H5Topen_async H5Tcopy_async H5Tclose_async - Updated an expected output file to include a new internal function in the error stack for the failure case. * Updated async APIs per reviews, including removing async version of H5Tcopy. * Removed statements that were added by mistake in the previous commit. * Fix compile issues in H5M and warnings elsewhere * Reformat code * Brings VOL_LIST changes from develop. (#163) Co-authored-by: Houjun Tang <htang4@lbl.gov> Co-authored-by: Neil Fortner <nfortne2@hdfgroup.org> Co-authored-by: vchoi <vchoi@jelly.ad.hdfgroup.org> Co-authored-by: vchoi-hdfgroup <55293060+vchoi-hdfgroup@users.noreply.github.com> Co-authored-by: jhendersonHDF <jhenderson@hdfgroup.org> Co-authored-by: Dana Robinson <derobins@hdfgroup.org> Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com> Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com>
2020-12-14 08:02:17 +08:00
udata->chunk_block.offset = HADDR_UNDEF;
udata->chunk_block.length = 0;
2020-09-30 22:27:10 +08:00
udata->filter_mask = 0;
} /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5D__bt2_idx_get_addr() */
/*-------------------------------------------------------------------------
* Function: H5D__bt2_idx_iterate_cb
*
* Purpose: Translate the B-tree specific chunk record into a generic
* form and make the callback to the generic chunk callback
* routine.
2020-04-21 07:12:00 +08:00
* This is the callback for H5B2_iterate() which is called in
* H5D__bt2_idx_iterate().
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Vailin Choi; June 2010
*
*-------------------------------------------------------------------------
*/
static int
H5D__bt2_idx_iterate_cb(const void *_record, void *_udata)
{
2020-09-30 22:27:10 +08:00
H5D_bt2_it_ud_t * udata = (H5D_bt2_it_ud_t *)_udata; /* User data */
const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* Native record */
int ret_value = -1; /* Return value */
FUNC_ENTER_PACKAGE_NOERR
/* Make "generic chunk" callback */
2020-09-30 22:27:10 +08:00
if ((ret_value = (udata->cb)(record, udata->udata)) < 0)
HERROR(H5E_DATASET, H5E_CALLBACK, "failure in generic chunk iterator callback");
FUNC_LEAVE_NOAPI(ret_value)
} /* H5D__bt2_idx_iterate_cb() */
/*-------------------------------------------------------------------------
* Function: H5D__bt2_idx_iterate
*
* Purpose: Iterate over the chunks in an index, making a callback
* for each one.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Vailin Choi; June 2010
*
*-------------------------------------------------------------------------
*/
static int
2020-09-30 22:27:10 +08:00
H5D__bt2_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, void *chunk_udata)
{
2020-09-30 22:27:10 +08:00
H5B2_t * bt2; /* v2 B-tree handle for indexing chunks */
H5D_bt2_it_ud_t udata; /* User data for B-tree iterator callback */
int ret_value = FAIL; /* Return value */
FUNC_ENTER_PACKAGE
/* Sanity checks */
HDassert(idx_info);
HDassert(idx_info->f);
HDassert(idx_info->pline);
HDassert(idx_info->layout);
HDassert(idx_info->storage);
HDassert(H5F_addr_defined(idx_info->storage->idx_addr));
HDassert(chunk_cb);
HDassert(chunk_udata);
/* Check if the v2 B-tree is open yet */
2020-09-30 22:27:10 +08:00
if (NULL == idx_info->storage->u.btree2.bt2) {
/* Open existing v2 B-tree */
if (H5D__bt2_idx_open(idx_info) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open v2 B-tree")
2020-09-30 22:27:10 +08:00
} /* end if */
else /* Patch the top level file pointer contained in bt2 if needed */
if (H5B2_patch_file(idx_info->storage->u.btree2.bt2, idx_info->f) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch v2 B-tree file pointer")
/* Set convenience pointer to v2 B-tree structure */
bt2 = idx_info->storage->u.btree2.bt2;
/* Prepare user data for iterate callback */
2020-09-30 22:27:10 +08:00
udata.cb = chunk_cb;
udata.udata = chunk_udata;
/* Iterate over the records in the v2 B-tree */
2020-09-30 22:27:10 +08:00
if ((ret_value = H5B2_iterate(bt2, H5D__bt2_idx_iterate_cb, &udata)) < 0)
HERROR(H5E_DATASET, H5E_BADITER, "unable to iterate over chunk v2 B-tree");
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__bt2_idx_iterate() */
/*-------------------------------------------------------------------------
* Function: H5D__bt2_remove_cb()
*
* Purpose: Free space for 'dataset chunk' object as v2 B-tree
* is being deleted or v2 B-tree node is removed.
2020-04-21 07:12:00 +08:00
* This is the callback for H5B2_remove() and H5B2_delete() which
* which are called in H5D__bt2_idx_remove() and H5D__bt2_idx_delete().
*
* Return: Success: non-negative
* Failure: negative
*
* Programmer: Vailin Choi; June 2010
*
*-------------------------------------------------------------------------
*/
static herr_t
H5D__bt2_remove_cb(const void *_record, void *_udata)
{
2020-09-30 22:27:10 +08:00
const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* The native record */
H5F_t * f = (H5F_t *)_udata; /* User data for removal callback */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Sanity checks */
HDassert(f);
/* Free the space in the file for the object being removed */
H5_CHECK_OVERFLOW(record->nbytes, uint32_t, hsize_t);
2020-09-30 22:27:10 +08:00
if (H5MF_xfree(f, H5FD_MEM_DRAW, record->chunk_addr, (hsize_t)record->nbytes) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to free chunk")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5D__bt2_remove_cb() */
/*-------------------------------------------------------------------------
* Function: H5D__bt2_idx_remove
*
* Purpose: Remove chunk from index.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Vailin Choi; June 2010
*
*-------------------------------------------------------------------------
*/
static herr_t
H5D__bt2_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *udata)
{
2020-09-30 22:27:10 +08:00
H5B2_t * bt2; /* v2 B-tree handle for indexing chunks */
H5D_bt2_ud_t bt2_udata; /* User data for v2 B-tree find call */
unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Sanity checks */
HDassert(idx_info);
HDassert(idx_info->f);
HDassert(idx_info->pline);
HDassert(idx_info->layout);
HDassert(idx_info->storage);
HDassert(H5F_addr_defined(idx_info->storage->idx_addr));
HDassert(udata);
/* Check if the v2 B-tree is open yet */
2020-09-30 22:27:10 +08:00
if (NULL == idx_info->storage->u.btree2.bt2) {
/* Open existing v2 B-tree */
if (H5D__bt2_idx_open(idx_info) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open v2 B-tree")
2020-09-30 22:27:10 +08:00
} /* end if */
else /* Patch the top level file pointer contained in bt2 if needed */
if (H5B2_patch_file(idx_info->storage->u.btree2.bt2, idx_info->f) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch v2 B-tree file pointer")
/* Set convenience pointer to v2 B-tree structure */
bt2 = idx_info->storage->u.btree2.bt2;
/* Prepare user data for compare callback */
bt2_udata.ndims = idx_info->layout->ndims - 1;
/* Initialize the record to search for */
2020-09-30 22:27:10 +08:00
for (u = 0; u < (idx_info->layout->ndims - 1); u++)
bt2_udata.rec.scaled[u] = udata->scaled[u];
/* Remove the record for the "dataset chunk" object from the v2 B-tree */
/* (space in the file for the object is freed in the 'remove' callback) */
2020-09-30 22:27:10 +08:00
if (H5B2_remove(bt2, &bt2_udata,
(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) ? NULL : H5D__bt2_remove_cb,
idx_info->f) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTREMOVE, FAIL, "can't remove object from B-tree")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5D__bt2_idx_remove() */
/*-------------------------------------------------------------------------
* Function: H5D__bt2_idx_delete
*
* Purpose: Delete index and raw data storage for entire dataset
* (i.e. all chunks)
*
* Return: Success: Non-negative
* Failure: negative
*
* Programmer: Vailin Choi; June 2010
*
*-------------------------------------------------------------------------
*/
static herr_t
H5D__bt2_idx_delete(const H5D_chk_idx_info_t *idx_info)
{
2020-09-30 22:27:10 +08:00
H5B2_remove_t remove_op; /* The removal callback */
H5D_bt2_ctx_ud_t u_ctx; /* data for context call */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Sanity checks */
HDassert(idx_info);
HDassert(idx_info->f);
HDassert(idx_info->pline);
HDassert(idx_info->layout);
HDassert(idx_info->storage);
/* Check if the index data structure has been allocated */
2020-09-30 22:27:10 +08:00
if (H5F_addr_defined(idx_info->storage->idx_addr)) {
/* Set up user data for creating context */
u_ctx.f = idx_info->f;
u_ctx.ndims = idx_info->layout->ndims - 1;
u_ctx.chunk_size = idx_info->layout->size;
u_ctx.dim = idx_info->layout->dim;
/* Set remove operation. Do not remove chunks in SWMR_WRITE mode */
if (H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE)
remove_op = NULL;
else
remove_op = H5D__bt2_remove_cb;
2020-09-30 22:27:10 +08:00
/* Delete the v2 B-tree */
/*(space in the file for each object is freed in the 'remove' callback) */
if (H5B2_delete(idx_info->f, idx_info->storage->idx_addr, &u_ctx, remove_op, idx_info->f) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "can't delete v2 B-tree")
2020-09-30 22:27:10 +08:00
idx_info->storage->idx_addr = HADDR_UNDEF;
} /* end if */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__bt2_idx_delete() */
/*-------------------------------------------------------------------------
* Function: H5D__bt2_idx_copy_setup
*
* Purpose: Set up any necessary information for copying chunks
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Vailin Choi; June 2010
*
*-------------------------------------------------------------------------
*/
static herr_t
2020-09-30 22:27:10 +08:00
H5D__bt2_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, const H5D_chk_idx_info_t *idx_info_dst)
{
2020-09-30 22:27:10 +08:00
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Source file */
HDassert(idx_info_src);
HDassert(idx_info_src->f);
HDassert(idx_info_src->pline);
HDassert(idx_info_src->layout);
HDassert(idx_info_src->storage);
/* Destination file */
HDassert(idx_info_dst);
HDassert(idx_info_dst->f);
HDassert(idx_info_dst->pline);
HDassert(idx_info_dst->layout);
HDassert(idx_info_dst->storage);
HDassert(!H5F_addr_defined(idx_info_dst->storage->idx_addr));
/* Check if the source v2 B-tree is open yet */
2020-09-30 22:27:10 +08:00
if (NULL == idx_info_src->storage->u.btree2.bt2)
if (H5D__bt2_idx_open(idx_info_src) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open v2 B-tree")
/* Set copied metadata tag */
H5_BEGIN_TAG(H5AC__COPIED_TAG);
/* Create v2 B-tree that describes the chunked dataset in the destination file */
2020-09-30 22:27:10 +08:00
if (H5D__bt2_idx_create(idx_info_dst) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize chunked storage")
HDassert(H5F_addr_defined(idx_info_dst->storage->idx_addr));
/* Reset metadata tag */
H5_END_TAG
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__bt2_idx_copy_setup() */
/*-------------------------------------------------------------------------
* Function: H5D__bt2_idx_copy_shutdown
*
* Purpose: Shutdown any information from copying chunks
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Vailin Choi; June 2010
*
*-------------------------------------------------------------------------
*/
static herr_t
2020-09-30 22:27:10 +08:00
H5D__bt2_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, H5O_storage_chunk_t *storage_dst)
{
2020-09-30 22:27:10 +08:00
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Check args */
HDassert(storage_src);
HDassert(storage_src->u.btree2.bt2);
HDassert(storage_dst);
HDassert(storage_dst->u.btree2.bt2);
/* Close v2 B-tree for source file */
2020-09-30 22:27:10 +08:00
if (H5B2_close(storage_src->u.btree2.bt2) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to close v2 B-tree")
storage_src->u.btree2.bt2 = NULL;
/* Close v2 B-tree for destination file */
2020-09-30 22:27:10 +08:00
if (H5B2_close(storage_dst->u.btree2.bt2) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to close v2 B-tree")
storage_dst->u.btree2.bt2 = NULL;
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__bt2_idx_copy_shutdown() */
/*-------------------------------------------------------------------------
* Function: H5D__bt2_idx_size
*
* Purpose: Retrieve the amount of index storage for chunked dataset
*
* Return: Success: Non-negative
* Failure: negative
*
* Programmer: Vailin Choi; June 2010
*
*-------------------------------------------------------------------------
*/
static herr_t
H5D__bt2_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size)
{
2020-09-30 22:27:10 +08:00
H5B2_t *bt2_cdset = NULL; /* Pointer to v2 B-tree structure */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Check args */
HDassert(idx_info);
HDassert(idx_info->f);
HDassert(idx_info->pline);
HDassert(idx_info->layout);
HDassert(idx_info->storage);
HDassert(H5F_addr_defined(idx_info->storage->idx_addr));
HDassert(index_size);
/* Open v2 B-tree */
2020-09-30 22:27:10 +08:00
if (H5D__bt2_idx_open(idx_info) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open v2 B-tree")
/* Set convenience pointer to v2 B-tree structure */
bt2_cdset = idx_info->storage->u.btree2.bt2;
/* Get v2 B-tree size for indexing chunked dataset */
2020-09-30 22:27:10 +08:00
if (H5B2_size(bt2_cdset, index_size) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve v2 B-tree storage info for chunked dataset")
done:
/* Close v2 B-tree index */
2020-09-30 22:27:10 +08:00
if (bt2_cdset && H5B2_close(bt2_cdset) < 0)
HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for tracking chunked dataset")
idx_info->storage->u.btree2.bt2 = NULL;
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__bt2_idx_size() */
/*-------------------------------------------------------------------------
* Function: H5D__bt2_idx_reset
*
* Purpose: Reset indexing information.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Vailin Choi; June 2010
*
*-------------------------------------------------------------------------
*/
static herr_t
H5D__bt2_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr)
{
FUNC_ENTER_PACKAGE_NOERR
/* Sanity checks */
HDassert(storage);
/* Reset index info */
2020-09-30 22:27:10 +08:00
if (reset_addr)
storage->idx_addr = HADDR_UNDEF;
storage->u.btree2.bt2 = NULL;
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5D__bt2_idx_reset() */
/*-------------------------------------------------------------------------
* Function: H5D__bt2_idx_dump
*
* Purpose: Dump indexing information to a stream.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Vailin Choi; June 2010
*
*-------------------------------------------------------------------------
*/
static herr_t
H5D__bt2_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream)
{
FUNC_ENTER_PACKAGE_NOERR
/* Sanity checks */
HDassert(storage);
HDassert(stream);
Squash my changes on branch `fprintf-experiment` into one commit for reapplication to my new warnings branch, `warnings-again`. These changes are included: commit 915551b7bf64e777dd2007386ec77b1d117770da Merge: 63858c2 a8892bb Author: David Young <dyoung@hdfgroup.org> Date: Mon Nov 25 17:39:49 2019 -0600 Merge remote-tracking branch 'hdf5/develop' into fprintf-experiment commit a8892bb42d6f6e4fbc30fae0eb2b957f81c938b9 Merge: 5c911d8 f907b51 Author: David Young <dyoung@hdfgroup.org> Date: Mon Nov 25 17:33:54 2019 -0600 Merge pull request #2055 in HDFFV/hdf5 from ~DYOUNG/vchoi_fork:add-werror-and-squash-some to develop * commit 'f907b511d06612dafc7814a7c30f2f3d2b76d52b': Oops, remove more C99 designated initializers for VS 2010 compatibility. commit 63858c22e168acaec0af8ced6641f26102cc6bb0 Merge: 20ae787 5c911d8 Author: David Young <dyoung@hdfgroup.org> Date: Mon Nov 25 17:04:42 2019 -0600 Merge remote-tracking branch 'hdf5/develop' into fprintf-experiment commit 5c911d8baf3ee7fe654269088eebdf07f59a8192 Merge: b8a5671 62208b0 Author: David Young <dyoung@hdfgroup.org> Date: Mon Nov 25 16:58:27 2019 -0600 Merge pull request #2030 in HDFFV/hdf5 from ~DYOUNG/vchoi_fork:add-werror-and-squash-some to develop * commit '62208b056a09c01855fbac7f75146be58ad6bfe5': (44 commits) Add an #include to get a function declaration. Don't use C99 designated initializers, they're not compatible with Visual Studio 2010. Quiet some more maybe-uninitialized warnings---each is a false positive, *sigh*. This is more code that may not compile with VS2010, *sigh sigh*. Always warn on maybe-uninitialized. -Wincompatible-pointer-types was not available until GCC 5, so enable it only if that's the GCC version we're using. Only promote maybe-uninitialized warnings to errors on GCC 8. Even on GCC 8, there may be false positives at low optimization levels? I need to check. Only use -Werror=cast-function-type with GCC 8 and later. Put all of the -W options back into the order I found them in so that it's easier to compare old and new config/gnu-flags. Add new source files to CMakeLists.txt. Mention the -Werror= flags in libhdf5.settings.in. free -> HDfree Promote decleration-after-statement warnings to errors. Quiet decleration-after-statement warnings. Move a statement under some declarations since some vintages of Visual Studio don't like declarations after statements. Document H5D__chunk_mem_xfree_wrapper(). Undo accidental test deletion. Oops, delete a debug printf that snuck in here. Undo my changes to the HD macros, hadn't really intended those to be on this branch.... Make errors of some more warnings. Move disabled warnings to DEVELOPER_WARNING_CFLAGS. Put just one warning option on a line, and sort some of the options. Cast to the parameter type, H5VL_token_t *, instead of to unsigned char *. Change hdset_reg_ref_t and H5R_ref_t from arrays of unsigned char to structs containing those arrays. Encapsulating the arrays in this way makes it easier to write and think about pointers to these types, casts to/from these types, etc. ... commit 20ae7877e33931b95e8c3502b027d6c3fe94a11f Merge: 46f8c61 edd5297 Author: David Young <dyoung@hdfgroup.org> Date: Fri Nov 22 15:34:09 2019 -0600 Merge remote-tracking branch 'origin/add-werror-and-squash-some' into fprintf-experiment commit 46f8c613d5117a8be5bc8385a072daa0b4262f06 Author: David Young <dyoung@hdfgroup.org> Date: Fri Nov 22 15:29:00 2019 -0600 GCC really wants us to use `ll` to format `long long`, so try to make that work before any other format modifier. Seems like we're not compiling the autoconf test program with -Werror=format ? Probably should. commit eee35b8ef3759c391327cd48a9b3c56b6f8abc99 Author: David Young <dyoung@hdfgroup.org> Date: Fri Nov 22 15:28:05 2019 -0600 It's hard to know just how wide an HDoff_t will be, and I don't think POSIX or C standards provide a PRI macro for it, so cast to intmax_t and format using PRIdMAX. commit 86eab12df7a89b546a38e99f8178dd2adbcb3433 Author: David Young <dyoung@hdfgroup.org> Date: Fri Nov 22 15:26:25 2019 -0600 URemove some casts.se the right format string for the argument. Here and there stop casting a printf argument. commit f722f7cbecbaa99449941484b014426f62f1bed5 Merge: 58e3743 6d5ec83 Author: David Young <dyoung@hdfgroup.org> Date: Fri Nov 22 14:44:16 2019 -0600 Merge branch 'add-werror-and-squash-some' into fprintf-experiment commit 58e3743b7faa9836606ee91798fe80dfc0040da7 Author: David Young <dyoung@hdfgroup.org> Date: Wed Nov 20 21:07:21 2019 -0600 Remove custom HDfprintf implementation, using the standard library's, instead. Take a swipe at repairing fprintf format strings, mainly replacing "%Hu" with "%" PRIuHSIZE, "%a" with "%" PRIuHADDR, "%Zu" with "%zu". Here and there remove an awkward cast of a printf argument to `long long` and use PRI[doux]8, PRI[doux]32, or PRI[doux]64, instead. Change occurrences of "%t" to "%s" and perform a suitable change of argument, `cond` -> `cond ? "TRUE" : "FALSE"`. Some occurrences of %Hu, %a, and %t remain, they just weren't flagged by the compiler because of #ifdef'age. commit d4366909293fa970c23512ac80e5d865d76cddbf Author: David Young <dyoung@hdfgroup.org> Date: Wed Nov 20 20:54:32 2019 -0600 Promote format-string warnigns to errors.
2019-11-28 03:58:43 +08:00
HDfprintf(stream, " Address: %" PRIuHADDR "\n", storage->idx_addr);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5D__bt2_idx_dump() */
/*-------------------------------------------------------------------------
* Function: H5D__bt2_idx_dest
*
* Purpose: Release indexing information in memory.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Vailin Choi; June 2010
*
*-------------------------------------------------------------------------
*/
static herr_t
H5D__bt2_idx_dest(const H5D_chk_idx_info_t *idx_info)
{
2020-09-30 22:27:10 +08:00
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Check args */
HDassert(idx_info);
HDassert(idx_info->f);
HDassert(idx_info->storage);
/* Check if the v2-btree is open */
2020-09-30 22:27:10 +08:00
if (idx_info->storage->u.btree2.bt2) {
2020-09-30 22:27:10 +08:00
/* Patch the top level file pointer contained in bt2 if needed */
if (H5B2_patch_file(idx_info->storage->u.btree2.bt2, idx_info->f) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch v2 B-tree file pointer")
/* Close v2 B-tree */
2020-09-30 22:27:10 +08:00
if (H5B2_close(idx_info->storage->u.btree2.bt2) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree")
idx_info->storage->u.btree2.bt2 = NULL;
} /* end if */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__bt2_idx_dest() */