diff options
-rw-r--r-- | MANIFEST | 1 | ||||
-rw-r--r-- | src/H5Abtree2.c | 36 | ||||
-rw-r--r-- | src/H5Adense.c | 32 | ||||
-rw-r--r-- | src/H5Aint.c | 4 | ||||
-rw-r--r-- | src/H5B2.c | 73 | ||||
-rw-r--r-- | src/H5B2cache.c | 13 | ||||
-rw-r--r-- | src/H5B2dbg.c | 42 | ||||
-rw-r--r-- | src/H5B2hdr.c | 34 | ||||
-rw-r--r-- | src/H5B2pkg.h | 9 | ||||
-rw-r--r-- | src/H5B2private.h | 32 | ||||
-rw-r--r-- | src/H5B2test.c | 155 | ||||
-rw-r--r-- | src/H5Fprivate.h | 8 | ||||
-rw-r--r-- | src/H5Gbtree2.c | 36 | ||||
-rw-r--r-- | src/H5Gdense.c | 30 | ||||
-rw-r--r-- | src/H5Gobj.c | 2 | ||||
-rw-r--r-- | src/H5Goh.c | 4 | ||||
-rw-r--r-- | src/H5Gtest.c | 4 | ||||
-rw-r--r-- | src/H5HFbtree2.c | 532 | ||||
-rw-r--r-- | src/H5HFhuge.c | 24 | ||||
-rw-r--r-- | src/H5HFpkg.h | 8 | ||||
-rw-r--r-- | src/H5HFstat.c | 2 | ||||
-rw-r--r-- | src/H5Oattribute.c | 4 | ||||
-rw-r--r-- | src/H5Otest.c | 8 | ||||
-rwxr-xr-x | src/H5SM.c | 101 | ||||
-rwxr-xr-x | src/H5SMbtree2.c | 308 | ||||
-rw-r--r-- | src/H5SMcache.c | 8 | ||||
-rw-r--r-- | src/H5SMmessage.c | 358 | ||||
-rwxr-xr-x | src/H5SMpkg.h | 21 | ||||
-rwxr-xr-x | src/Makefile.am | 6 | ||||
-rw-r--r-- | src/Makefile.in | 5 | ||||
-rw-r--r-- | test/btree2.c | 22 | ||||
-rw-r--r-- | tools/misc/h5debug.c | 8 |
32 files changed, 1268 insertions, 662 deletions
@@ -703,6 +703,7 @@ ./src/H5SM.c ./src/H5SMbtree2.c ./src/H5SMcache.c +./src/H5SMmessage.c ./src/H5SMpkg.h ./src/H5SMprivate.h ./src/H5SMtest.c diff --git a/src/H5Abtree2.c b/src/H5Abtree2.c index 7d0bb4c..eb2c741 100644 --- a/src/H5Abtree2.c +++ b/src/H5Abtree2.c @@ -81,20 +81,20 @@ typedef struct H5A_fh_ud_cmp_t { /* v2 B-tree driver callbacks for 'creation order' index */ static herr_t H5A_dense_btree2_corder_store(void *native, const void *udata); static herr_t H5A_dense_btree2_corder_compare(const void *rec1, const void *rec2); -static herr_t H5A_dense_btree2_corder_encode(const H5F_t *f, uint8_t *raw, - const void *native); -static herr_t H5A_dense_btree2_corder_decode(const H5F_t *f, const uint8_t *raw, - void *native); +static herr_t H5A_dense_btree2_corder_encode(uint8_t *raw, const void *native, + void *ctx); +static herr_t H5A_dense_btree2_corder_decode(const uint8_t *raw, void *native, + void *ctx); static herr_t H5A_dense_btree2_corder_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, int indent, int fwidth, const void *record, const void *_udata); /* v2 B-tree driver callbacks for 'name' index */ static herr_t H5A_dense_btree2_name_store(void *native, const void *udata); static herr_t H5A_dense_btree2_name_compare(const void *rec1, const void *rec2); -static herr_t H5A_dense_btree2_name_encode(const H5F_t *f, uint8_t *raw, - const void *native); -static herr_t H5A_dense_btree2_name_decode(const H5F_t *f, const uint8_t *raw, - void *native); +static herr_t H5A_dense_btree2_name_encode(uint8_t *raw, const void *native, + void *ctx); +static herr_t H5A_dense_btree2_name_decode(const uint8_t *raw, void *native, + void *ctx); static herr_t H5A_dense_btree2_name_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, int indent, int fwidth, const void *record, const void *_udata); @@ -110,11 +110,15 @@ const H5B2_class_t H5A_BT2_NAME[1]={{ /* B-tree class information */ H5B2_ATTR_DENSE_NAME_ID, /* Type of B-tree */ "H5B2_ATTR_DENSE_NAME_ID", /* Name of B-tree class */ sizeof(H5A_dense_bt2_name_rec_t), /* Size of native record */ + NULL, /* Create client callback context */ + NULL, /* Destroy client callback context */ H5A_dense_btree2_name_store, /* Record storage callback */ H5A_dense_btree2_name_compare, /* Record comparison callback */ H5A_dense_btree2_name_encode, /* Record encoding callback */ H5A_dense_btree2_name_decode, /* Record decoding callback */ - H5A_dense_btree2_name_debug /* Record debugging callback */ + H5A_dense_btree2_name_debug, /* Record debugging callback */ + NULL, /* Create debugging context */ + NULL /* Destroy debugging context */ }}; /* v2 B-tree class for indexing 'creation order' field of attributes */ @@ -122,11 +126,15 @@ const H5B2_class_t H5A_BT2_CORDER[1]={{ /* B-tree class information */ H5B2_ATTR_DENSE_CORDER_ID, /* Type of B-tree */ "H5B2_ATTR_DENSE_CORDER_ID", /* Name of B-tree class */ sizeof(H5A_dense_bt2_corder_rec_t),/* Size of native record */ + NULL, /* Create client callback context */ + NULL, /* Destroy client callback context */ H5A_dense_btree2_corder_store, /* Record storage callback */ H5A_dense_btree2_corder_compare, /* Record comparison callback */ H5A_dense_btree2_corder_encode, /* Record encoding callback */ H5A_dense_btree2_corder_decode, /* Record decoding callback */ - H5A_dense_btree2_corder_debug /* Record debugging callback */ + H5A_dense_btree2_corder_debug, /* Record debugging callback */ + NULL, /* Create debugging context */ + NULL /* Destroy debugging context */ }}; @@ -311,7 +319,7 @@ H5A_dense_btree2_name_compare(const void *_bt2_udata, const void *_bt2_rec) *------------------------------------------------------------------------- */ static herr_t -H5A_dense_btree2_name_encode(const H5F_t UNUSED *f, uint8_t *raw, const void *_nrecord) +H5A_dense_btree2_name_encode(uint8_t *raw, const void *_nrecord, void UNUSED *ctx) { const H5A_dense_bt2_name_rec_t *nrecord = (const H5A_dense_bt2_name_rec_t *)_nrecord; @@ -341,7 +349,7 @@ H5A_dense_btree2_name_encode(const H5F_t UNUSED *f, uint8_t *raw, const void *_n *------------------------------------------------------------------------- */ static herr_t -H5A_dense_btree2_name_decode(const H5F_t UNUSED *f, const uint8_t *raw, void *_nrecord) +H5A_dense_btree2_name_decode(const uint8_t *raw, void *_nrecord, void UNUSED *ctx) { H5A_dense_bt2_name_rec_t *nrecord = (H5A_dense_bt2_name_rec_t *)_nrecord; @@ -469,7 +477,7 @@ H5A_dense_btree2_corder_compare(const void *_bt2_udata, const void *_bt2_rec) *------------------------------------------------------------------------- */ static herr_t -H5A_dense_btree2_corder_encode(const H5F_t UNUSED *f, uint8_t *raw, const void *_nrecord) +H5A_dense_btree2_corder_encode(uint8_t *raw, const void *_nrecord, void UNUSED *ctx) { const H5A_dense_bt2_corder_rec_t *nrecord = (const H5A_dense_bt2_corder_rec_t *)_nrecord; @@ -498,7 +506,7 @@ H5A_dense_btree2_corder_encode(const H5F_t UNUSED *f, uint8_t *raw, const void * *------------------------------------------------------------------------- */ static herr_t -H5A_dense_btree2_corder_decode(const H5F_t UNUSED *f, const uint8_t *raw, void *_nrecord) +H5A_dense_btree2_corder_decode(const uint8_t *raw, void *_nrecord, void UNUSED *ctx) { H5A_dense_bt2_corder_rec_t *nrecord = (H5A_dense_bt2_corder_rec_t *)_nrecord; diff --git a/src/H5Adense.c b/src/H5Adense.c index c9da207..889889e 100644 --- a/src/H5Adense.c +++ b/src/H5Adense.c @@ -246,7 +246,7 @@ HDfprintf(stderr, "%s: fheap_id_len = %Zu\n", FUNC, fheap_id_len); H5O_FHEAP_ID_LEN; /* Fractal heap ID */ bt2_cparam.split_percent = H5A_NAME_BT2_SPLIT_PERC; bt2_cparam.merge_percent = H5A_NAME_BT2_MERGE_PERC; - if(NULL == (bt2_name = H5B2_create(f, dxpl_id, &bt2_cparam))) + if(NULL == (bt2_name = H5B2_create(f, dxpl_id, &bt2_cparam, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create v2 B-tree for name index") /* Retrieve the v2 B-tree's address in the file */ @@ -267,7 +267,7 @@ HDfprintf(stderr, "%s: ainfo->name_bt2_addr = %a\n", FUNC, ainfo->name_bt2_addr) H5O_FHEAP_ID_LEN; /* Fractal heap ID */ bt2_cparam.split_percent = H5A_CORDER_BT2_SPLIT_PERC; bt2_cparam.merge_percent = H5A_CORDER_BT2_MERGE_PERC; - if(NULL == (bt2_corder = H5B2_create(f, dxpl_id, &bt2_cparam))) + if(NULL == (bt2_corder = H5B2_create(f, dxpl_id, &bt2_cparam, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create v2 B-tree for creation order index") /* Retrieve the v2 B-tree's address in the file */ @@ -383,7 +383,7 @@ H5A_dense_open(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, const char *na } /* end if */ /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open v2 B-tree for name index") /* Create the "udata" information for v2 B-tree record find */ @@ -528,7 +528,7 @@ H5A_dense_insert(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, H5A_t *attr) } /* end else */ /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Create the callback information for v2 B-tree record insertion */ @@ -552,7 +552,7 @@ H5A_dense_insert(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, H5A_t *attr) if(ainfo->index_corder) { /* Open the creation order index v2 B-tree */ HDassert(H5F_addr_defined(ainfo->corder_bt2_addr)); - if(NULL == (bt2_corder = H5B2_open(f, dxpl_id, ainfo->corder_bt2_addr))) + if(NULL == (bt2_corder = H5B2_open(f, dxpl_id, ainfo->corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Insert the record into the creation order index v2 B-tree */ @@ -660,7 +660,7 @@ H5A_dense_write_bt2_cb(void *_record, void *_op_data, hbool_t *changed) H5A_bt2_ud_common_t udata; /* User data for v2 B-tree modify */ /* Open the creation order index v2 B-tree */ - if(NULL == (bt2_corder = H5B2_open(op_data->f, op_data->dxpl_id, op_data->corder_bt2_addr))) + if(NULL == (bt2_corder = H5B2_open(op_data->f, op_data->dxpl_id, op_data->corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Create the "udata" information for v2 B-tree record modify */ @@ -790,7 +790,7 @@ H5A_dense_write(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, H5A_t *attr) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Create the "udata" information for v2 B-tree record modify */ @@ -936,7 +936,7 @@ H5A_dense_rename(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, const char * HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Create the "udata" information for v2 B-tree record modify */ @@ -1215,7 +1215,7 @@ H5A_dense_iterate(H5F_t *f, hid_t dxpl_id, hid_t loc_id, const H5O_ainfo_t *ainf } /* end if */ /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Construct the user data for v2 B-tree iterator callback */ @@ -1291,7 +1291,7 @@ H5A_dense_remove_bt2_cb(const void *_record, void *_udata) /* Check for removing the link from the creation order index */ if(H5F_addr_defined(udata->corder_bt2_addr)) { /* Open the creation order index v2 B-tree */ - if(NULL == (bt2_corder = H5B2_open(udata->common.f, udata->common.dxpl_id, udata->corder_bt2_addr))) + if(NULL == (bt2_corder = H5B2_open(udata->common.f, udata->common.dxpl_id, udata->corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Set up the user data for the v2 B-tree 'record remove' callback */ @@ -1386,7 +1386,7 @@ H5A_dense_remove(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, const char * } /* end if */ /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Set up the user data for the v2 B-tree 'record remove' callback */ @@ -1500,7 +1500,7 @@ H5A_dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata) } /* end else */ /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(bt2_udata->f, bt2_udata->dxpl_id, bt2_udata->other_bt2_addr))) + if(NULL == (bt2 = H5B2_open(bt2_udata->f, bt2_udata->dxpl_id, bt2_udata->other_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Set the common information for the v2 B-tree remove operation */ @@ -1632,7 +1632,7 @@ H5A_dense_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, } /* end if */ /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Set up the user data for the v2 B-tree 'record remove' callback */ @@ -1735,7 +1735,7 @@ H5A_dense_exists(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, const char * } /* end if */ /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Create the "udata" information for v2 B-tree record 'find' */ @@ -1876,7 +1876,7 @@ H5A_dense_delete(H5F_t *f, hid_t dxpl_id, H5O_ainfo_t *ainfo) udata.found_op_data = NULL; /* Delete name index v2 B-tree */ - if(H5B2_delete(f, dxpl_id, ainfo->name_bt2_addr, H5A_dense_delete_bt2_cb, &udata) < 0) + if(H5B2_delete(f, dxpl_id, ainfo->name_bt2_addr, NULL, H5A_dense_delete_bt2_cb, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree for name index") ainfo->name_bt2_addr = HADDR_UNDEF; @@ -1888,7 +1888,7 @@ H5A_dense_delete(H5F_t *f, hid_t dxpl_id, H5O_ainfo_t *ainfo) /* Check if we should delete the creation order index v2 B-tree */ if(H5F_addr_defined(ainfo->corder_bt2_addr)) { /* Delete the creation order index, without adjusting the ref. count on the attributes */ - if(H5B2_delete(f, dxpl_id, ainfo->corder_bt2_addr, NULL, NULL) < 0) + if(H5B2_delete(f, dxpl_id, ainfo->corder_bt2_addr, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree for creation order index") ainfo->corder_bt2_addr = HADDR_UNDEF; } /* end if */ diff --git a/src/H5Aint.c b/src/H5Aint.c index 10e2b95..ad7e553 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -329,7 +329,7 @@ H5A_dense_build_table(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, HDassert(atable); /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in "name" B-tree */ @@ -725,7 +725,7 @@ H5A_get_ainfo(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_ainfo_t *ainfo) /* Check if we are using "dense" attribute storage */ if(H5F_addr_defined(ainfo->fheap_addr)) { /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in "name" B-tree */ @@ -73,10 +73,10 @@ * client class.. */ extern const H5B2_class_t H5B2_TEST[1]; -extern const H5B2_class_t H5HF_BT2_INDIR[1]; -extern const H5B2_class_t H5HF_BT2_FILT_INDIR[1]; -extern const H5B2_class_t H5HF_BT2_DIR[1]; -extern const H5B2_class_t H5HF_BT2_FILT_DIR[1]; +extern const H5B2_class_t H5HF_HUGE_BT2_INDIR[1]; +extern const H5B2_class_t H5HF_HUGE_BT2_FILT_INDIR[1]; +extern const H5B2_class_t H5HF_HUGE_BT2_DIR[1]; +extern const H5B2_class_t H5HF_HUGE_BT2_FILT_DIR[1]; extern const H5B2_class_t H5G_BT2_NAME[1]; extern const H5B2_class_t H5G_BT2_CORDER[1]; extern const H5B2_class_t H5SM_INDEX[1]; @@ -85,10 +85,10 @@ extern const H5B2_class_t H5A_BT2_CORDER[1]; const H5B2_class_t *const H5B2_client_class_g[] = { H5B2_TEST, /* 0 - H5B2_TEST_ID */ - H5HF_BT2_INDIR, /* 1 - H5B2_FHEAP_HUGE_INDIR_ID */ - H5HF_BT2_FILT_INDIR, /* 2 - H5B2_FHEAP_HUGE_FILT_INDIR_ID */ - H5HF_BT2_DIR, /* 3 - H5B2_FHEAP_HUGE_DIR_ID */ - H5HF_BT2_FILT_DIR, /* 4 - H5B2_FHEAP_HUGE_FILT_DIR_ID */ + H5HF_HUGE_BT2_INDIR, /* 1 - H5B2_FHEAP_HUGE_INDIR_ID */ + H5HF_HUGE_BT2_FILT_INDIR, /* 2 - H5B2_FHEAP_HUGE_FILT_INDIR_ID */ + H5HF_HUGE_BT2_DIR, /* 3 - H5B2_FHEAP_HUGE_DIR_ID */ + H5HF_HUGE_BT2_FILT_DIR, /* 4 - H5B2_FHEAP_HUGE_FILT_DIR_ID */ H5G_BT2_NAME, /* 5 - H5B2_GRP_DENSE_NAME_ID */ H5G_BT2_CORDER, /* 6 - H5B2_GRP_DENSE_CORDER_ID */ H5SM_INDEX, /* 7 - H5B2_SOHM_INDEX_ID */ @@ -126,7 +126,7 @@ H5FL_DEFINE_STATIC(H5B2_t); *------------------------------------------------------------------------- */ H5B2_t * -H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam) +H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, void *ctx_udata) { H5B2_t *bt2 = NULL; /* Pointer to the B-tree */ H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */ @@ -145,7 +145,7 @@ H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam) HDcompile_assert(H5B2_NUM_BTREE_ID == NELMTS(H5B2_client_class_g)); /* Create shared v2 B-tree header */ - if(HADDR_UNDEF == (hdr_addr = H5B2_hdr_create(f, dxpl_id, cparam))) + if(HADDR_UNDEF == (hdr_addr = H5B2_hdr_create(f, dxpl_id, cparam, ctx_udata))) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, NULL, "can't create v2 B-tree header") /* Create v2 B-tree wrapper */ @@ -153,7 +153,7 @@ H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for v2 B-tree info") /* Look up the B-tree header */ - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, NULL, NULL, H5AC_WRITE))) + if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, NULL, ctx_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to load B-tree header") /* Point v2 B-tree wrapper at header and bump it's ref count */ @@ -197,7 +197,7 @@ done: *------------------------------------------------------------------------- */ H5B2_t * -H5B2_open(H5F_t *f, hid_t dxpl_id, haddr_t addr) +H5B2_open(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata) { H5B2_t *bt2 = NULL; /* Pointer to the B-tree */ H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */ @@ -210,7 +210,7 @@ H5B2_open(H5F_t *f, hid_t dxpl_id, haddr_t addr) HDassert(H5F_addr_defined(addr)); /* Look up the B-tree header */ - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, NULL, NULL, H5AC_READ))) + if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, NULL, ctx_udata, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to load B-tree header") /* Check for pending heap deletion */ @@ -1140,13 +1140,6 @@ H5B2_close(H5B2_t *bt2, hid_t dxpl_id) } /* end if */ } /* end if */ - /* Decrement the reference count on the B-tree header */ - /* (don't put in H5B2_hdr_fuse_decr() as the B-tree header may be evicted - * immediately -QAK) - */ - if(H5B2_hdr_decr(bt2->hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTDEC, FAIL, "can't decrement reference count on shared v2 B-tree header") - /* Check for pending v2 B-tree deletion */ if(pending_delete) { H5B2_hdr_t *hdr; /* Another pointer to v2 B-tree header */ @@ -1154,17 +1147,49 @@ H5B2_close(H5B2_t *bt2, hid_t dxpl_id) /* Sanity check */ HDassert(H5F_addr_defined(bt2_addr)); +#ifndef NDEBUG +{ + unsigned hdr_status = 0; /* Header's status in the metadata cache */ + + /* Check the header's status in the metadata cache */ + if(H5AC_get_entry_status(bt2->f, bt2_addr, &hdr_status) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to check metadata cache status for v2 B-tree header, address = %llu", (unsigned long long)bt2_addr) + + /* Sanity checks on header */ + HDassert(hdr_status & H5AC_ES__IN_CACHE); + HDassert(hdr_status & H5AC_ES__IS_PINNED); + HDassert(!(hdr_status & H5AC_ES__IS_PROTECTED)); +} +#endif /* NDEBUG */ + /* Lock the v2 B-tree header into memory */ + /* (OK to pass in NULL for callback context, since we know the header must be in the cache) */ if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(bt2->f, dxpl_id, H5AC_BT2_HDR, bt2_addr, NULL, NULL, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load v2 B-tree header") /* Set the shared v2 B-tree header's file context for this operation */ hdr->f = bt2->f; + /* Decrement the reference count on the B-tree header */ + /* (don't put in H5B2_hdr_fuse_decr() as the B-tree header may be evicted + * immediately -QAK) + */ + if(H5B2_hdr_decr(bt2->hdr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTDEC, FAIL, "can't decrement reference count on shared v2 B-tree header") + /* Delete v2 B-tree, starting with header (unprotects header) */ if(H5B2_hdr_delete(hdr, dxpl_id) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree") } /* end if */ + else { + /* Decrement the reference count on the B-tree header */ + /* (don't put in H5B2_hdr_fuse_decr() as the B-tree header may be evicted + * immediately -QAK) + */ + if(H5B2_hdr_decr(bt2->hdr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTDEC, FAIL, "can't decrement reference count on shared v2 B-tree header") + + } /* end else */ /* Release the v2 B-tree wrapper */ bt2 = H5FL_FREE(H5B2_t, bt2); @@ -1197,8 +1222,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr, H5B2_remove_t op, - void *op_data) +H5B2_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata, + H5B2_remove_t op, void *op_data) { H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1213,8 +1238,8 @@ H5B2_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr, H5B2_remove_t op, #ifdef QAK HDfprintf(stderr, "%s: addr = %a\n", FUNC, addr); #endif /* QAK */ - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, NULL, NULL, H5AC_WRITE))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load v2 B-tree header") + if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, NULL, ctx_udata, H5AC_WRITE))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect v2 B-tree header") /* Remember the callback & context for later */ hdr->remove_op = op; diff --git a/src/H5B2cache.c b/src/H5B2cache.c index c7cfbdb..695252e 100644 --- a/src/H5B2cache.c +++ b/src/H5B2cache.c @@ -144,7 +144,8 @@ const H5AC_class_t H5AC_BT2_LEAF[1] = {{ *------------------------------------------------------------------------- */ static H5B2_hdr_t * -H5B2_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *udata1, void UNUSED *udata2) +H5B2_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *udata1, + void *ctx_udata) { H5B2_create_t cparam; /* B-tree creation parameters */ H5B2_subid_t id; /* ID of B-tree class, as found in file */ @@ -234,7 +235,7 @@ H5B2_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *ud /* Initialize B-tree header info */ cparam.cls = H5B2_client_class_g[id]; - if(H5B2_hdr_init(f, hdr, &cparam, depth) < 0) + if(H5B2_hdr_init(f, hdr, &cparam, ctx_udata, depth) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, NULL, "can't initialize B-tree header info") /* Set the B-tree header's address */ @@ -561,7 +562,7 @@ H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_uda native = internal->int_native; for(u = 0; u < internal->nrec; u++) { /* Decode record */ - if((udata->hdr->cls->decode)(f, p, native) < 0) + if((udata->hdr->cls->decode)(p, native, udata->hdr->cb_ctx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, NULL, "unable to decode B-tree record") /* Move to next record */ @@ -660,7 +661,7 @@ H5B2_cache_internal_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr native = internal->int_native; for(u = 0; u < internal->nrec; u++) { /* Encode record */ - if((internal->hdr->cls->encode)(f, p, native) < 0) + if((internal->hdr->cls->encode)(p, native, internal->hdr->cb_ctx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree record") /* Move to next record */ @@ -913,7 +914,7 @@ H5B2_cache_leaf_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrec, v native = leaf->leaf_native; for(u = 0; u < leaf->nrec; u++) { /* Decode record */ - if((hdr->cls->decode)(f, p, native) < 0) + if((hdr->cls->decode)(p, native, hdr->cb_ctx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, NULL, "unable to decode B-tree record") /* Move to next record */ @@ -996,7 +997,7 @@ H5B2_cache_leaf_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5 native = leaf->leaf_native; for(u = 0; u < leaf->nrec; u++) { /* Encode record */ - if((leaf->hdr->cls->encode)(f, p, native) < 0) + if((leaf->hdr->cls->encode)(p, native, leaf->hdr->cb_ctx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree record") /* Move to next record */ diff --git a/src/H5B2dbg.c b/src/H5B2dbg.c index 17a64cd..f8a1fc9 100644 --- a/src/H5B2dbg.c +++ b/src/H5B2dbg.c @@ -91,6 +91,7 @@ H5B2_hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, const H5B2_class_t *type) { H5B2_hdr_t *hdr = NULL; /* B-tree header info */ + void *dbg_ctx = NULL; /* v2 B-tree debugging context */ unsigned u; /* Local index variable */ char temp_str[128]; /* Temporary string, for formatting */ herr_t ret_value = SUCCEED; /* Return value */ @@ -106,11 +107,20 @@ H5B2_hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, HDassert(indent >= 0); HDassert(fwidth >= 0); HDassert(type); + HDassert((type->crt_dbg_ctx && type->dst_dbg_ctx) || + (NULL == type->crt_dbg_ctx && NULL == type->dst_dbg_ctx)); + + /* Check for debugging context callback available */ + if(type->crt_dbg_ctx) { + /* Create debugging context */ + if(NULL == (dbg_ctx = (type->crt_dbg_ctx)(f, dxpl_id, addr))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to create v2 B-tree debugging context") + } /* end if */ /* * Load the B-tree header. */ - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_READ))) + if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, dbg_ctx, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree header") /* Set file pointer for this B-tree operation */ @@ -162,6 +172,8 @@ H5B2_hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, } /* end for */ done: + if(dbg_ctx && (type->dst_dbg_ctx)(dbg_ctx) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "unable to release v2 B-tree debugging context") if(hdr) { hdr->f = NULL; if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, hdr, H5AC__NO_FLAGS_SET) < 0) @@ -191,6 +203,7 @@ H5B2_int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, { H5B2_hdr_t *hdr = NULL; /* B-tree header */ H5B2_internal_t *internal = NULL; /* B-tree internal node */ + void *dbg_ctx = NULL; /* v2 B-tree debugging context */ unsigned u; /* Local index variable */ char temp_str[128]; /* Temporary string, for formatting */ herr_t ret_value=SUCCEED; /* Return value */ @@ -206,13 +219,22 @@ H5B2_int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, HDassert(indent >= 0); HDassert(fwidth >= 0); HDassert(type); + HDassert((type->crt_dbg_ctx && type->dst_dbg_ctx) || + (NULL == type->crt_dbg_ctx && NULL == type->dst_dbg_ctx)); HDassert(H5F_addr_defined(hdr_addr)); HDassert(nrec > 0); + /* Check for debugging context callback available */ + if(type->crt_dbg_ctx) { + /* Create debugging context */ + if(NULL == (dbg_ctx = (type->crt_dbg_ctx)(f, dxpl_id, addr))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to create v2 B-tree debugging context") + } /* end if */ + /* * Load the B-tree header. */ - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, type, NULL, H5AC_READ))) + if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, type, dbg_ctx, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree header") /* Set file pointer for this B-tree operation */ @@ -276,6 +298,8 @@ H5B2_int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, internal->node_ptrs[u].addr); done: + if(dbg_ctx && (type->dst_dbg_ctx)(dbg_ctx) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "unable to release v2 B-tree debugging context") if(hdr) { hdr->f = NULL; if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) @@ -307,6 +331,7 @@ H5B2_leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, { H5B2_hdr_t *hdr = NULL; /* B-tree header */ H5B2_leaf_t *leaf = NULL; /* B-tree leaf node */ + void *dbg_ctx = NULL; /* v2 B-tree debugging context */ unsigned u; /* Local index variable */ char temp_str[128]; /* Temporary string, for formatting */ herr_t ret_value = SUCCEED; /* Return value */ @@ -322,13 +347,22 @@ H5B2_leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, HDassert(indent >= 0); HDassert(fwidth >= 0); HDassert(type); + HDassert((type->crt_dbg_ctx && type->dst_dbg_ctx) || + (NULL == type->crt_dbg_ctx && NULL == type->dst_dbg_ctx)); HDassert(H5F_addr_defined(hdr_addr)); HDassert(nrec > 0); + /* Check for debugging context callback available */ + if(type->crt_dbg_ctx) { + /* Create debugging context */ + if(NULL == (dbg_ctx = (type->crt_dbg_ctx)(f, dxpl_id, addr))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to create v2 B-tree debugging context") + } /* end if */ + /* * Load the B-tree header. */ - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, type, NULL, H5AC_READ))) + if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, type, dbg_ctx, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree header") /* Set file pointer for this B-tree operation */ @@ -373,6 +407,8 @@ H5B2_leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, } /* end for */ done: + if(dbg_ctx && (type->dst_dbg_ctx)(dbg_ctx) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "unable to release v2 B-tree debugging context") if(hdr) { hdr->f = NULL; if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) diff --git a/src/H5B2hdr.c b/src/H5B2hdr.c index ec46729..f1d5d84 100644 --- a/src/H5B2hdr.c +++ b/src/H5B2hdr.c @@ -108,7 +108,7 @@ H5FL_SEQ_DEFINE(H5B2_node_info_t); */ herr_t H5B2_hdr_init(H5F_t *f, H5B2_hdr_t *hdr, const H5B2_create_t *cparam, - uint16_t depth) + void *ctx_udata, uint16_t depth) { size_t sz_max_nrec; /* Temporary variable for range checking */ unsigned u_max_nrec_size; /* Temporary variable for range checking */ @@ -124,6 +124,8 @@ H5B2_hdr_init(H5F_t *f, H5B2_hdr_t *hdr, const H5B2_create_t *cparam, HDassert(hdr); HDassert(cparam); HDassert(cparam->cls); + HDassert((cparam->cls->crt_context && cparam->cls->dst_context) || + (NULL == cparam->cls->crt_context && NULL == cparam->cls->dst_context)); HDassert(cparam->node_size > 0); HDassert(cparam->rrec_size > 0); HDassert(cparam->merge_percent > 0 && cparam->merge_percent <= 100); @@ -149,14 +151,14 @@ H5B2_hdr_init(H5F_t *f, H5B2_hdr_t *hdr, const H5B2_create_t *cparam, /* Allocate "page" for node I/O */ if(NULL == (hdr->page = H5FL_BLK_MALLOC(node_page, hdr->node_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, FAIL, "memory allocation failed") #ifdef H5_CLEAR_MEMORY HDmemset(hdr->page, 0, hdr->node_size); #endif /* H5_CLEAR_MEMORY */ /* Allocate array of node info structs */ if(NULL == (hdr->node_info = H5FL_SEQ_MALLOC(H5B2_node_info_t, (size_t)(hdr->depth + 1)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize leaf node info */ sz_max_nrec = H5B2_NUM_LEAF_REC(hdr->node_size, hdr->rrec_size); @@ -166,13 +168,13 @@ HDmemset(hdr->page, 0, hdr->node_size); hdr->node_info[0].cum_max_nrec = hdr->node_info[0].max_nrec; hdr->node_info[0].cum_max_nrec_size = 0; if(NULL == (hdr->node_info[0].nat_rec_fac = H5FL_fac_init(hdr->cls->nrec_size * hdr->node_info[0].max_nrec))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create node native key block factory") + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't create node native key block factory") hdr->node_info[0].node_ptr_fac = NULL; /* Allocate array of pointers to internal node native keys */ /* (uses leaf # of records because its the largest) */ if(NULL == (hdr->nat_off = H5FL_SEQ_MALLOC(size_t, (size_t)hdr->node_info[0].max_nrec))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize offsets in native key block */ /* (uses leaf # of records because its the largest) */ @@ -201,12 +203,18 @@ HDmemset(hdr->page, 0, hdr->node_size); H5_ASSIGN_OVERFLOW(/* To: */ hdr->node_info[u].cum_max_nrec_size, /* From: */ u_max_nrec_size, /* From: */ unsigned, /* To: */ uint8_t) if(NULL == (hdr->node_info[u].nat_rec_fac = H5FL_fac_init(hdr->cls->nrec_size * hdr->node_info[u].max_nrec))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create node native key block factory") + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't create node native key block factory") if(NULL == (hdr->node_info[u].node_ptr_fac = H5FL_fac_init(sizeof(H5B2_node_ptr_t) * (hdr->node_info[u].max_nrec + 1)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create internal 'branch' node node pointer block factory") + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't create internal 'branch' node node pointer block factory") } /* end for */ } /* end if */ + /* Create the callback context, if the callback exists */ + if(hdr->cls->crt_context) { + if(NULL == (hdr->cb_ctx = (*hdr->cls->crt_context)(ctx_udata))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTCREATE, FAIL, "unable to create v2 B-tree client callback context") + } /* end if */ + done: if(ret_value < 0) if(H5B2_hdr_free(hdr) < 0) @@ -278,7 +286,8 @@ done: *------------------------------------------------------------------------- */ haddr_t -H5B2_hdr_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam) +H5B2_hdr_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, + void *ctx_udata) { H5B2_hdr_t *hdr = NULL; /* The new v2 B-tree header information */ haddr_t ret_value; /* Return value */ @@ -296,7 +305,7 @@ H5B2_hdr_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, HADDR_UNDEF, "allocation failed for B-tree header") /* Initialize shared B-tree info */ - if(H5B2_hdr_init(f, hdr, cparam, (uint16_t)0) < 0) + if(H5B2_hdr_init(f, hdr, cparam, ctx_udata, (uint16_t)0) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, HADDR_UNDEF, "can't create shared B-tree info") /* Allocate space for the header on disk */ @@ -507,6 +516,13 @@ H5B2_hdr_free(H5B2_hdr_t *hdr) /* Sanity check */ HDassert(hdr); + /* Destroy the callback context */ + if(hdr->cb_ctx) { + if((*hdr->cls->dst_context)(hdr->cb_ctx) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "can't destroy v2 B-tree client callback context") + hdr->cb_ctx = NULL; + } /* end if */ + /* Free the B-tree node buffer */ if(hdr->page) (void)H5FL_BLK_FREE(node_page, hdr->page); diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h index 8b68d1e..c336227 100644 --- a/src/H5B2pkg.h +++ b/src/H5B2pkg.h @@ -168,10 +168,13 @@ typedef struct H5B2_hdr_t { uint8_t sizeof_addr; /* Size of file addresses */ H5B2_remove_t remove_op; /* Callback operator for deleting B-tree */ void *remove_op_data;/* B-tree deletion callback's context */ - const H5B2_class_t *cls; /* Class of B-tree client */ uint8_t *page; /* Common disk page for I/O */ size_t *nat_off; /* Array of offsets of native records */ H5B2_node_info_t *node_info; /* Table of node info structs for current depth of B-tree */ + + /* Client information (not stored) */ + const H5B2_class_t *cls; /* Class of B-tree client */ + void *cb_ctx; /* Client callback context */ } H5B2_hdr_t; /* B-tree leaf node information */ @@ -255,9 +258,9 @@ extern const H5B2_class_t *const H5B2_client_class_g[]; /* Routines for managing B-tree header info */ H5_DLL H5B2_hdr_t *H5B2_hdr_alloc(H5F_t *f); H5_DLL haddr_t H5B2_hdr_create(H5F_t *f, hid_t dxpl_id, - const H5B2_create_t *cparam); + const H5B2_create_t *cparam, void *ctx_udata); H5_DLL herr_t H5B2_hdr_init(H5F_t *f, H5B2_hdr_t *hdr, - const H5B2_create_t *cparam, uint16_t depth); + const H5B2_create_t *cparam, void *ctx_udata, uint16_t depth); H5_DLL herr_t H5B2_hdr_incr(H5B2_hdr_t *hdr); H5_DLL herr_t H5B2_hdr_decr(H5B2_hdr_t *hdr); H5_DLL herr_t H5B2_hdr_fuse_incr(H5B2_hdr_t *hdr); diff --git a/src/H5B2private.h b/src/H5B2private.h index cfdf868..4880ab2 100644 --- a/src/H5B2private.h +++ b/src/H5B2private.h @@ -85,20 +85,17 @@ struct H5B2_class_t { const char *name; /* Name of B-tree class, for debugging */ size_t nrec_size; /* Size of native (memory) record */ - /* Store record from application to B-tree 'native' form */ - herr_t (*store)(void *nrecord, const void *udata); /* Store record in native record table */ - - /* Compare records, according to a key */ - herr_t (*compare)(const void *rec1, const void *rec2); /* Compare two native records */ - - /* Encode & decode record values */ - herr_t (*encode)(const H5F_t *f, uint8_t *raw, const void *record); /* Encode record from native form to disk storage form */ - herr_t (*decode)(const H5F_t *f, const uint8_t *raw, void *record); /* Decode record from disk storage form to native form */ - - /* Debug record values */ - herr_t (*debug)(FILE *stream, const H5F_t *f, hid_t dxpl_id, /* Print a record for debugging */ - int indent, int fwidth, const void *record, - const void *udata); + /* Extensible array client callback methods */ + void *(*crt_context)(void *udata); /* Create context for other client callbacks */ + herr_t (*dst_context)(void *ctx); /* Destroy client callback context */ + herr_t (*store)(void *nrecord, const void *udata); /* Store application record in native record table */ + herr_t (*compare)(const void *rec1, const void *rec2); /* Compare two native records */ + herr_t (*encode)(uint8_t *raw, const void *record, void *ctx); /* Encode record from native form to disk storage form */ + herr_t (*decode)(const uint8_t *raw, void *record, void *ctx); /* Decode record from disk storage form to native form */ + herr_t (*debug)(FILE *stream, const H5F_t *f, hid_t dxpl_id, /* Print a record for debugging */ + int indent, int fwidth, const void *record, const void *udata); + void *(*crt_dbg_ctx)(H5F_t *f, hid_t dxpl_id, haddr_t obj_addr); /* Create debugging context */ + herr_t (*dst_dbg_ctx)(void *dbg_ctx); /* Destroy debugging context */ }; /* v2 B-tree creation parameters */ @@ -128,8 +125,9 @@ typedef struct H5B2_t H5B2_t; /***************************************/ /* Library-private Function Prototypes */ /***************************************/ -H5_DLL H5B2_t *H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam); -H5_DLL H5B2_t *H5B2_open(H5F_t *f, hid_t dxpl_id, haddr_t addr); +H5_DLL H5B2_t *H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, + void *ctx_udata); +H5_DLL H5B2_t *H5B2_open(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata); H5_DLL herr_t H5B2_get_addr(const H5B2_t *bt2, haddr_t *addr/*out*/); H5_DLL herr_t H5B2_insert(H5B2_t *bt2, hid_t dxpl_id, void *udata); H5_DLL herr_t H5B2_iterate(H5B2_t *bt2, hid_t dxpl_id, H5B2_operator_t op, @@ -151,7 +149,7 @@ H5_DLL herr_t H5B2_size(H5B2_t *bt2, hid_t dxpl_id, hsize_t *btree_size); H5_DLL herr_t H5B2_close(H5B2_t *bt2, hid_t dxpl_id); H5_DLL herr_t H5B2_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr, - H5B2_remove_t op, void *op_data); + void *ctx_udata, H5B2_remove_t op, void *op_data); /* Statistics routines */ H5_DLL herr_t H5B2_stat_info(H5B2_t *bt2, H5B2_stat_t *info); diff --git a/src/H5B2test.c b/src/H5B2test.c index a778fe9..222279b 100644 --- a/src/H5B2test.c +++ b/src/H5B2test.c @@ -46,6 +46,11 @@ /* Local Typedefs */ /******************/ +/* v2 B-tree client callback context */ +typedef struct H5B2_test_ctx_t { + uint8_t sizeof_size; /* Size of file sizes */ +} H5B2_test_ctx_t; + /********************/ /* Package Typedefs */ @@ -56,14 +61,15 @@ /* Local Prototypes */ /********************/ +static void *H5B2_test_crt_context(void *udata); +static herr_t H5B2_test_dst_context(void *ctx); static herr_t H5B2_test_store(void *nrecord, const void *udata); static herr_t H5B2_test_compare(const void *rec1, const void *rec2); -static herr_t H5B2_test_encode(const H5F_t *f, uint8_t *raw, - const void *nrecord); -static herr_t H5B2_test_decode(const H5F_t *f, const uint8_t *raw, - void *nrecord); +static herr_t H5B2_test_encode(uint8_t *raw, const void *nrecord, void *ctx); +static herr_t H5B2_test_decode(const uint8_t *raw, void *nrecord, void *ctx); static herr_t H5B2_test_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, int indent, int fwidth, const void *record, const void *_udata); +static void *H5B2_test_crt_dbg_context(H5F_t *f, hid_t dxpl_id, haddr_t addr); /*********************/ @@ -74,11 +80,15 @@ const H5B2_class_t H5B2_TEST[1]={{ /* B-tree class information */ H5B2_TEST_ID, /* Type of B-tree */ "H5B2_TEST_ID", /* Name of B-tree class */ sizeof(hsize_t), /* Size of native record */ + H5B2_test_crt_context, /* Create client callback context */ + H5B2_test_dst_context, /* Destroy client callback context */ H5B2_test_store, /* Record storage callback */ H5B2_test_compare, /* Record comparison callback */ H5B2_test_encode, /* Record encoding callback */ H5B2_test_decode, /* Record decoding callback */ - H5B2_test_debug /* Record debugging callback */ + H5B2_test_debug, /* Record debugging callback */ + H5B2_test_crt_dbg_context, /* Create debugging context */ + H5B2_test_dst_context /* Destroy debugging context */ }}; @@ -92,6 +102,79 @@ const H5B2_class_t H5B2_TEST[1]={{ /* B-tree class information */ /*******************/ +/* Declare a free list to manage the H5B2_test_ctx_t struct */ +H5FL_DEFINE_STATIC(H5B2_test_ctx_t); + + +/*------------------------------------------------------------------------- + * Function: H5B2_test_crt_context + * + * Purpose: Create client callback context + * + * Return: Success: non-NULL + * Failure: NULL + * + * Programmer: Quincey Koziol + * Thursday, November 26, 2009 + * + *------------------------------------------------------------------------- + */ +static void * +H5B2_test_crt_context(void *_f) +{ + H5F_t *f = (H5F_t *)_f; /* User data for building callback context */ + H5B2_test_ctx_t *ctx; /* Callback context structure */ + void *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5B2_test_crt_context) + + /* Sanity check */ + HDassert(f); + + /* Allocate callback context */ + if(NULL == (ctx = H5FL_MALLOC(H5B2_test_ctx_t))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "can't allocate callback context") + + /* Determine the size of lengths in the file */ + ctx->sizeof_size = H5F_SIZEOF_SIZE(f); + + /* Set return value */ + ret_value = ctx; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5B2_test_crt_context() */ + + +/*------------------------------------------------------------------------- + * Function: H5B2_test_dst_context + * + * Purpose: Destroy client callback context + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Quincey Koziol + * Thursday, November 26, 2009 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5B2_test_dst_context(void *_ctx) +{ + H5B2_test_ctx_t *ctx = (H5B2_test_ctx_t *)_ctx; /* Callback context structure */ + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_test_dst_context) + + /* Sanity check */ + HDassert(ctx); + + /* Release callback context */ + ctx = H5FL_FREE(H5B2_test_ctx_t, ctx); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5B2_test_dst_context() */ + /*------------------------------------------------------------------------- * Function: H5B2_test_store @@ -99,7 +182,6 @@ const H5B2_class_t H5B2_TEST[1]={{ /* B-tree class information */ * Purpose: Store native information into record for B-tree * * Return: Success: non-negative - * * Failure: negative * * Programmer: Quincey Koziol @@ -147,7 +229,6 @@ H5B2_test_compare(const void *rec1, const void *rec2) * Purpose: Encode native information into raw form for storing on disk * * Return: Success: non-negative - * * Failure: negative * * Programmer: Quincey Koziol @@ -156,11 +237,16 @@ H5B2_test_compare(const void *rec1, const void *rec2) *------------------------------------------------------------------------- */ static herr_t -H5B2_test_encode(const H5F_t *f, uint8_t *raw, const void *nrecord) +H5B2_test_encode(uint8_t *raw, const void *nrecord, void *_ctx) { + H5B2_test_ctx_t *ctx = (H5B2_test_ctx_t *)_ctx; /* Callback context structure */ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_test_encode) - H5F_ENCODE_LENGTH(f, raw, *(const hsize_t *)nrecord); + /* Sanity check */ + HDassert(ctx); + + H5F_ENCODE_LENGTH_LEN(raw, *(const hsize_t *)nrecord, ctx->sizeof_size); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2_test_encode() */ @@ -172,7 +258,6 @@ H5B2_test_encode(const H5F_t *f, uint8_t *raw, const void *nrecord) * Purpose: Decode raw disk form of record into native form * * Return: Success: non-negative - * * Failure: negative * * Programmer: Quincey Koziol @@ -181,11 +266,16 @@ H5B2_test_encode(const H5F_t *f, uint8_t *raw, const void *nrecord) *------------------------------------------------------------------------- */ static herr_t -H5B2_test_decode(const H5F_t *f, const uint8_t *raw, void *nrecord) +H5B2_test_decode(const uint8_t *raw, void *nrecord, void *_ctx) { + H5B2_test_ctx_t *ctx = (H5B2_test_ctx_t *)_ctx; /* Callback context structure */ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_test_decode) - H5F_DECODE_LENGTH(f, raw, *(hsize_t *)nrecord); + /* Sanity check */ + HDassert(ctx); + + H5F_DECODE_LENGTH_LEN(raw, *(hsize_t *)nrecord, ctx->sizeof_size); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2_test_decode() */ @@ -197,7 +287,6 @@ H5B2_test_decode(const H5F_t *f, const uint8_t *raw, void *nrecord) * Purpose: Debug native form of record * * Return: Success: non-negative - * * Failure: negative * * Programmer: Quincey Koziol @@ -222,6 +311,46 @@ H5B2_test_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED dxpl_id, /*------------------------------------------------------------------------- + * Function: H5B2_test_crt_dbg_context + * + * Purpose: Create context for debugging callback + * + * Return: Success: non-NULL + * Failure: NULL + * + * Programmer: Quincey Koziol + * Tuesday, December 1, 2009 + * + *------------------------------------------------------------------------- + */ +static void * +H5B2_test_crt_dbg_context(H5F_t *f, hid_t UNUSED dxpl_id, haddr_t UNUSED addr) +{ + H5B2_test_ctx_t *ctx; /* Callback context structure */ + void *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5B2_test_crt_dbg_context) + + /* Sanity check */ + HDassert(f); + HDassert(H5F_addr_defined(addr)); + + /* Allocate callback context */ + if(NULL == (ctx = H5FL_MALLOC(H5B2_test_ctx_t))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "can't allocate callback context") + + /* Determine the size of addresses & lengths in the file */ + ctx->sizeof_size = H5F_SIZEOF_SIZE(f); + + /* Set return value */ + ret_value = ctx; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5B2_test_crt_dbg_context() */ + + +/*------------------------------------------------------------------------- * Function: H5B2_get_root_addr_test * * Purpose: Retrieve the root node's address diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 6b086f3..c513d55 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -300,20 +300,24 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t; case 2: UINT16DECODE(p, o); break; \ } -#define H5F_ENCODE_LENGTH(f,p,l) switch(H5F_SIZEOF_SIZE(f)) { \ +#define H5F_ENCODE_LENGTH_LEN(p,l,s) switch(s) { \ case 4: UINT32ENCODE(p,l); break; \ case 8: UINT64ENCODE(p,l); break; \ case 2: UINT16ENCODE(p,l); break; \ default: HDassert("bad sizeof size" && 0); \ } -#define H5F_DECODE_LENGTH(f,p,l) switch(H5F_SIZEOF_SIZE(f)) { \ +#define H5F_ENCODE_LENGTH(f,p,l) H5F_ENCODE_LENGTH_LEN(p,l,H5F_SIZEOF_SIZE(f)) + +#define H5F_DECODE_LENGTH_LEN(p,l,s) switch(s) { \ case 4: UINT32DECODE(p,l); break; \ case 8: UINT64DECODE(p,l); break; \ case 2: UINT16DECODE(p,l); break; \ default: HDassert("bad sizeof size" && 0); \ } +#define H5F_DECODE_LENGTH(f,p,l) H5F_DECODE_LENGTH_LEN(p,l,H5F_SIZEOF_SIZE(f)) + /* * Macros that check for overflows. These are somewhat dangerous to fiddle * with. diff --git a/src/H5Gbtree2.c b/src/H5Gbtree2.c index 8e81efe..9864dd9 100644 --- a/src/H5Gbtree2.c +++ b/src/H5Gbtree2.c @@ -79,20 +79,20 @@ typedef struct H5G_fh_ud_cmp_t { /* v2 B-tree driver callbacks for 'creation order' index */ static herr_t H5G_dense_btree2_corder_store(void *native, const void *udata); static herr_t H5G_dense_btree2_corder_compare(const void *rec1, const void *rec2); -static herr_t H5G_dense_btree2_corder_encode(const H5F_t *f, uint8_t *raw, - const void *native); -static herr_t H5G_dense_btree2_corder_decode(const H5F_t *f, const uint8_t *raw, - void *native); +static herr_t H5G_dense_btree2_corder_encode(uint8_t *raw, const void *native, + void *ctx); +static herr_t H5G_dense_btree2_corder_decode(const uint8_t *raw, void *native, + void *ctx); static herr_t H5G_dense_btree2_corder_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, int indent, int fwidth, const void *record, const void *_udata); /* v2 B-tree driver callbacks for 'name' index */ static herr_t H5G_dense_btree2_name_store(void *native, const void *udata); static herr_t H5G_dense_btree2_name_compare(const void *rec1, const void *rec2); -static herr_t H5G_dense_btree2_name_encode(const H5F_t *f, uint8_t *raw, - const void *native); -static herr_t H5G_dense_btree2_name_decode(const H5F_t *f, const uint8_t *raw, - void *native); +static herr_t H5G_dense_btree2_name_encode(uint8_t *raw, const void *native, + void *ctx); +static herr_t H5G_dense_btree2_name_decode(const uint8_t *raw, void *native, + void *ctx); static herr_t H5G_dense_btree2_name_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, int indent, int fwidth, const void *record, const void *_udata); @@ -108,11 +108,15 @@ const H5B2_class_t H5G_BT2_NAME[1]={{ /* B-tree class information */ H5B2_GRP_DENSE_NAME_ID, /* Type of B-tree */ "H5B2_GRP_DENSE_NAME_ID", /* Name of B-tree class */ sizeof(H5G_dense_bt2_name_rec_t), /* Size of native record */ + NULL, /* Create client callback context */ + NULL, /* Destroy client callback context */ H5G_dense_btree2_name_store, /* Record storage callback */ H5G_dense_btree2_name_compare, /* Record comparison callback */ H5G_dense_btree2_name_encode, /* Record encoding callback */ H5G_dense_btree2_name_decode, /* Record decoding callback */ - H5G_dense_btree2_name_debug /* Record debugging callback */ + H5G_dense_btree2_name_debug, /* Record debugging callback */ + NULL, /* Create debugging context */ + NULL /* Destroy debugging context */ }}; /* v2 B-tree class for indexing 'creation order' field of links */ @@ -120,11 +124,15 @@ const H5B2_class_t H5G_BT2_CORDER[1]={{ /* B-tree class information */ H5B2_GRP_DENSE_CORDER_ID, /* Type of B-tree */ "H5B2_GRP_DENSE_CORDER_ID", /* Name of B-tree class */ sizeof(H5G_dense_bt2_corder_rec_t), /* Size of native record */ + NULL, /* Create client callback context */ + NULL, /* Destroy client callback context */ H5G_dense_btree2_corder_store, /* Record storage callback */ H5G_dense_btree2_corder_compare, /* Record comparison callback */ H5G_dense_btree2_corder_encode, /* Record encoding callback */ H5G_dense_btree2_corder_decode, /* Record decoding callback */ - H5G_dense_btree2_corder_debug /* Record debugging callback */ + H5G_dense_btree2_corder_debug, /* Record debugging callback */ + NULL, /* Create debugging context */ + NULL /* Destroy debugging context */ }}; /*****************************/ @@ -298,7 +306,7 @@ for(u = 0; u < H5G_DENSE_FHEAP_ID_LEN; u++) *------------------------------------------------------------------------- */ static herr_t -H5G_dense_btree2_name_encode(const H5F_t UNUSED *f, uint8_t *raw, const void *_nrecord) +H5G_dense_btree2_name_encode(uint8_t *raw, const void *_nrecord, void UNUSED *ctx) { const H5G_dense_bt2_name_rec_t *nrecord = (const H5G_dense_bt2_name_rec_t *)_nrecord; @@ -326,7 +334,7 @@ H5G_dense_btree2_name_encode(const H5F_t UNUSED *f, uint8_t *raw, const void *_n *------------------------------------------------------------------------- */ static herr_t -H5G_dense_btree2_name_decode(const H5F_t UNUSED *f, const uint8_t *raw, void *_nrecord) +H5G_dense_btree2_name_decode(const uint8_t *raw, void *_nrecord, void UNUSED *ctx) { H5G_dense_bt2_name_rec_t *nrecord = (H5G_dense_bt2_name_rec_t *)_nrecord; @@ -464,7 +472,7 @@ for(u = 0; u < H5G_DENSE_FHEAP_ID_LEN; u++) *------------------------------------------------------------------------- */ static herr_t -H5G_dense_btree2_corder_encode(const H5F_t UNUSED *f, uint8_t *raw, const void *_nrecord) +H5G_dense_btree2_corder_encode(uint8_t *raw, const void *_nrecord, void UNUSED *ctx) { const H5G_dense_bt2_corder_rec_t *nrecord = (const H5G_dense_bt2_corder_rec_t *)_nrecord; @@ -492,7 +500,7 @@ H5G_dense_btree2_corder_encode(const H5F_t UNUSED *f, uint8_t *raw, const void * *------------------------------------------------------------------------- */ static herr_t -H5G_dense_btree2_corder_decode(const H5F_t UNUSED *f, const uint8_t *raw, void *_nrecord) +H5G_dense_btree2_corder_decode(const uint8_t *raw, void *_nrecord, void UNUSED *ctx) { H5G_dense_bt2_corder_rec_t *nrecord = (H5G_dense_bt2_corder_rec_t *)_nrecord; diff --git a/src/H5Gdense.c b/src/H5Gdense.c index f935a74..9a8e764 100644 --- a/src/H5Gdense.c +++ b/src/H5Gdense.c @@ -326,7 +326,7 @@ HDfprintf(stderr, "%s: fheap_id_len = %Zu\n", FUNC, fheap_id_len); fheap_id_len; /* Fractal heap ID */ bt2_cparam.split_percent = H5G_NAME_BT2_SPLIT_PERC; bt2_cparam.merge_percent = H5G_NAME_BT2_MERGE_PERC; - if(NULL == (bt2_name = H5B2_create(f, dxpl_id, &bt2_cparam))) + if(NULL == (bt2_name = H5B2_create(f, dxpl_id, &bt2_cparam, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create v2 B-tree for name index") /* Retrieve the v2 B-tree's address in the file */ @@ -346,7 +346,7 @@ HDfprintf(stderr, "%s: linfo->name_bt2_addr = %a\n", FUNC, linfo->name_bt2_addr) fheap_id_len; /* Fractal heap ID */ bt2_cparam.split_percent = H5G_CORDER_BT2_SPLIT_PERC; bt2_cparam.merge_percent = H5G_CORDER_BT2_MERGE_PERC; - if(NULL == (bt2_corder = H5B2_create(f, dxpl_id, &bt2_cparam))) + if(NULL == (bt2_corder = H5B2_create(f, dxpl_id, &bt2_cparam, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create v2 B-tree for creation order index") /* Retrieve the v2 B-tree's address in the file */ @@ -438,7 +438,7 @@ HDfprintf(stderr, "%s: HDstrlen(lnk->name) = %Zu, link_size = %Zu\n", FUNC, HDst HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert link into fractal heap") /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, linfo->name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, linfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Create the callback information for v2 B-tree record insertion */ @@ -460,7 +460,7 @@ HDfprintf(stderr, "%s: HDstrlen(lnk->name) = %Zu, link_size = %Zu\n", FUNC, HDst if(linfo->index_corder) { /* Open the creation order index v2 B-tree */ HDassert(H5F_addr_defined(linfo->corder_bt2_addr)); - if(NULL == (bt2_corder = H5B2_open(f, dxpl_id, linfo->corder_bt2_addr))) + if(NULL == (bt2_corder = H5B2_open(f, dxpl_id, linfo->corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Insert the record into the creation order index v2 B-tree */ @@ -557,7 +557,7 @@ H5G_dense_lookup(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, linfo->name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, linfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Construct the user data for v2 B-tree callback */ @@ -733,7 +733,7 @@ H5G_dense_lookup_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Construct the user data for v2 B-tree callback */ @@ -1042,7 +1042,7 @@ H5G_dense_iterate(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Construct the user data for v2 B-tree iterator callback */ @@ -1244,7 +1244,7 @@ H5G_dense_get_name_by_idx(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Set up the user data for the v2 B-tree 'record remove' callback */ @@ -1326,7 +1326,7 @@ H5G_dense_remove_fh_cb(const void *obj, size_t UNUSED obj_len, void *_udata) H5G_bt2_ud_common_t bt2_udata; /* Info for B-tree callbacks */ /* Open the creation order index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(udata->f, udata->dxpl_id, udata->corder_bt2_addr))) + if(NULL == (bt2 = H5B2_open(udata->f, udata->dxpl_id, udata->corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Set up the user data for the v2 B-tree 'record remove' callback */ @@ -1440,7 +1440,7 @@ H5G_dense_remove(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the name index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, linfo->name_bt2_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, linfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Set up the user data for the v2 B-tree 'record remove' callback */ @@ -1577,7 +1577,7 @@ H5G_dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata) } /* end else */ /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(bt2_udata->f, bt2_udata->dxpl_id, bt2_udata->other_bt2_addr))) + if(NULL == (bt2 = H5B2_open(bt2_udata->f, bt2_udata->dxpl_id, bt2_udata->other_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for 'other' index") /* Set the common information for the v2 B-tree remove operation */ @@ -1682,7 +1682,7 @@ H5G_dense_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Set up the user data for the v2 B-tree 'remove by index' callback */ @@ -1776,7 +1776,7 @@ H5G_dense_delete(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, hbool_t adj_link) udata.replace_names = FALSE; /* Delete the name index, adjusting the ref. count on links removed */ - if(H5B2_delete(f, dxpl_id, linfo->name_bt2_addr, H5G_dense_remove_bt2_cb, &udata) < 0) + if(H5B2_delete(f, dxpl_id, linfo->name_bt2_addr, NULL, H5G_dense_remove_bt2_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree for name index") /* Close the fractal heap */ @@ -1785,7 +1785,7 @@ H5G_dense_delete(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, hbool_t adj_link) } /* end if */ else { /* Delete the name index, without adjusting the ref. count on the links */ - if(H5B2_delete(f, dxpl_id, linfo->name_bt2_addr, NULL, NULL) < 0) + if(H5B2_delete(f, dxpl_id, linfo->name_bt2_addr, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree for name index") } /* end else */ linfo->name_bt2_addr = HADDR_UNDEF; @@ -1794,7 +1794,7 @@ H5G_dense_delete(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, hbool_t adj_link) if(linfo->index_corder) { /* Delete the creation order index, without adjusting the ref. count on the links */ HDassert(H5F_addr_defined(linfo->corder_bt2_addr)); - if(H5B2_delete(f, dxpl_id, linfo->corder_bt2_addr, NULL, NULL) < 0) + if(H5B2_delete(f, dxpl_id, linfo->corder_bt2_addr, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree for creation order index") linfo->corder_bt2_addr = HADDR_UNDEF; } /* end if */ diff --git a/src/H5Gobj.c b/src/H5Gobj.c index 4281ac0..271501f 100644 --- a/src/H5Gobj.c +++ b/src/H5Gobj.c @@ -331,7 +331,7 @@ H5G_obj_get_linfo(const H5O_loc_t *grp_oloc, H5O_linfo_t *linfo, hid_t dxpl_id) /* Check if we are using "dense" link storage */ if(H5F_addr_defined(linfo->fheap_addr)) { /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(grp_oloc->file, dxpl_id, linfo->name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(grp_oloc->file, dxpl_id, linfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in "name" B-tree */ diff --git a/src/H5Goh.c b/src/H5Goh.c index 2494838..ea51179 100644 --- a/src/H5Goh.c +++ b/src/H5Goh.c @@ -360,7 +360,7 @@ H5O_group_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info) /* Check if name index available */ if(H5F_addr_defined(linfo.name_bt2_addr)) { /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, linfo.name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, linfo.name_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Get name index B-tree size */ @@ -371,7 +371,7 @@ H5O_group_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info) /* Check if creation order index available */ if(H5F_addr_defined(linfo.corder_bt2_addr)) { /* Open the creation order index v2 B-tree */ - if(NULL == (bt2_corder = H5B2_open(f, dxpl_id, linfo.corder_bt2_addr))) + if(NULL == (bt2_corder = H5B2_open(f, dxpl_id, linfo.corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Get creation order index B-tree size */ diff --git a/src/H5Gtest.c b/src/H5Gtest.c index 791c13a..26de267 100644 --- a/src/H5Gtest.c +++ b/src/H5Gtest.c @@ -405,7 +405,7 @@ H5G_new_dense_info_test(hid_t gid, hsize_t *name_count, hsize_t *corder_count) HGOTO_DONE(FAIL) /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(grp->oloc.file, H5AC_dxpl_id, linfo.name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(grp->oloc.file, H5AC_dxpl_id, linfo.name_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in name index */ @@ -415,7 +415,7 @@ H5G_new_dense_info_test(hid_t gid, hsize_t *name_count, hsize_t *corder_count) /* Check if there is a creation order index */ if(H5F_addr_defined(linfo.corder_bt2_addr)) { /* Open the creation order index v2 B-tree */ - if(NULL == (bt2_corder = H5B2_open(grp->oloc.file, H5AC_dxpl_id, linfo.corder_bt2_addr))) + if(NULL == (bt2_corder = H5B2_open(grp->oloc.file, H5AC_dxpl_id, linfo.corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Retrieve # of records in creation order index */ diff --git a/src/H5HFbtree2.c b/src/H5HFbtree2.c index ae50bf3..3f208e7 100644 --- a/src/H5HFbtree2.c +++ b/src/H5HFbtree2.c @@ -49,6 +49,12 @@ /* Local Typedefs */ /******************/ +/* v2 B-tree client callback context */ +typedef struct H5HF_huge_bt2_ctx_t { + uint8_t sizeof_size; /* Size of file sizes */ + uint8_t sizeof_addr; /* Size of file addresses */ +} H5HF_huge_bt2_ctx_t; + /********************/ /* Package Typedefs */ @@ -59,92 +65,114 @@ /* Local Prototypes */ /********************/ + /* v2 B-tree driver callbacks */ -static herr_t H5HF_huge_btree2_indir_store(void *native, const void *udata); -static herr_t H5HF_huge_btree2_indir_compare(const void *rec1, const void *rec2); -static herr_t H5HF_huge_btree2_indir_encode(const H5F_t *f, uint8_t *raw, - const void *native); -static herr_t H5HF_huge_btree2_indir_decode(const H5F_t *f, const uint8_t *raw, - void *native); -static herr_t H5HF_huge_btree2_indir_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, + +static void *H5HF_huge_bt2_crt_context(void *udata); +static herr_t H5HF_huge_bt2_dst_context(void *ctx); +static void *H5HF_huge_bt2_crt_dbg_context(H5F_t *f, hid_t dxpl_id, haddr_t addr); + +static herr_t H5HF_huge_bt2_indir_store(void *native, const void *udata); +static herr_t H5HF_huge_bt2_indir_compare(const void *rec1, const void *rec2); +static herr_t H5HF_huge_bt2_indir_encode(uint8_t *raw, const void *native, + void *ctx); +static herr_t H5HF_huge_bt2_indir_decode(const uint8_t *raw, void *native, + void *ctx); +static herr_t H5HF_huge_bt2_indir_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, int indent, int fwidth, const void *record, const void *_udata); -static herr_t H5HF_huge_btree2_filt_indir_store(void *native, const void *udata); -static herr_t H5HF_huge_btree2_filt_indir_compare(const void *rec1, const void *rec2); -static herr_t H5HF_huge_btree2_filt_indir_encode(const H5F_t *f, uint8_t *raw, - const void *native); -static herr_t H5HF_huge_btree2_filt_indir_decode(const H5F_t *f, const uint8_t *raw, - void *native); -static herr_t H5HF_huge_btree2_filt_indir_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, +static herr_t H5HF_huge_bt2_filt_indir_store(void *native, const void *udata); +static herr_t H5HF_huge_bt2_filt_indir_compare(const void *rec1, const void *rec2); +static herr_t H5HF_huge_bt2_filt_indir_encode(uint8_t *raw, const void *native, + void *ctx); +static herr_t H5HF_huge_bt2_filt_indir_decode(const uint8_t *raw, void *native, + void *ctx); +static herr_t H5HF_huge_bt2_filt_indir_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, int indent, int fwidth, const void *record, const void *_udata); -static herr_t H5HF_huge_btree2_dir_store(void *native, const void *udata); -static herr_t H5HF_huge_btree2_dir_compare(const void *rec1, const void *rec2); -static herr_t H5HF_huge_btree2_dir_encode(const H5F_t *f, uint8_t *raw, - const void *native); -static herr_t H5HF_huge_btree2_dir_decode(const H5F_t *f, const uint8_t *raw, - void *native); -static herr_t H5HF_huge_btree2_dir_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, +static herr_t H5HF_huge_bt2_dir_store(void *native, const void *udata); +static herr_t H5HF_huge_bt2_dir_compare(const void *rec1, const void *rec2); +static herr_t H5HF_huge_bt2_dir_encode(uint8_t *raw, const void *native, + void *ctx); +static herr_t H5HF_huge_bt2_dir_decode(const uint8_t *raw, void *native, + void *ctx); +static herr_t H5HF_huge_bt2_dir_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, int indent, int fwidth, const void *record, const void *_udata); -static herr_t H5HF_huge_btree2_filt_dir_store(void *native, const void *udata); -static herr_t H5HF_huge_btree2_filt_dir_compare(const void *rec1, const void *rec2); -static herr_t H5HF_huge_btree2_filt_dir_encode(const H5F_t *f, uint8_t *raw, - const void *native); -static herr_t H5HF_huge_btree2_filt_dir_decode(const H5F_t *f, const uint8_t *raw, - void *native); -static herr_t H5HF_huge_btree2_filt_dir_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, +static herr_t H5HF_huge_bt2_filt_dir_store(void *native, const void *udata); +static herr_t H5HF_huge_bt2_filt_dir_compare(const void *rec1, const void *rec2); +static herr_t H5HF_huge_bt2_filt_dir_encode(uint8_t *raw, const void *native, + void *ctx); +static herr_t H5HF_huge_bt2_filt_dir_decode(const uint8_t *raw, void *native, + void *ctx); +static herr_t H5HF_huge_bt2_filt_dir_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, int indent, int fwidth, const void *record, const void *_udata); /*********************/ /* Package Variables */ /*********************/ /* v2 B-tree class for indirectly accessed 'huge' objects */ -const H5B2_class_t H5HF_BT2_INDIR[1]={{ /* B-tree class information */ - H5B2_FHEAP_HUGE_INDIR_ID, /* Type of B-tree */ - "H5B2_FHEAP_HUGE_INDIR_ID", /* Name of B-tree class */ - sizeof(H5HF_huge_bt2_indir_rec_t), /* Size of native record */ - H5HF_huge_btree2_indir_store, /* Record storage callback */ - H5HF_huge_btree2_indir_compare, /* Record comparison callback */ - H5HF_huge_btree2_indir_encode, /* Record encoding callback */ - H5HF_huge_btree2_indir_decode, /* Record decoding callback */ - H5HF_huge_btree2_indir_debug /* Record debugging callback */ +const H5B2_class_t H5HF_HUGE_BT2_INDIR[1]={{ /* B-tree class information */ + H5B2_FHEAP_HUGE_INDIR_ID, /* Type of B-tree */ + "H5B2_FHEAP_HUGE_INDIR_ID", /* Name of B-tree class */ + sizeof(H5HF_huge_bt2_indir_rec_t), /* Size of native record */ + H5HF_huge_bt2_crt_context, /* Create client callback context */ + H5HF_huge_bt2_dst_context, /* Destroy client callback context */ + H5HF_huge_bt2_indir_store, /* Record storage callback */ + H5HF_huge_bt2_indir_compare, /* Record comparison callback */ + H5HF_huge_bt2_indir_encode, /* Record encoding callback */ + H5HF_huge_bt2_indir_decode, /* Record decoding callback */ + H5HF_huge_bt2_indir_debug, /* Record debugging callback */ + H5HF_huge_bt2_crt_dbg_context, /* Create debugging context */ + H5HF_huge_bt2_dst_context /* Destroy debugging context */ }}; /* v2 B-tree class for indirectly accessed, filtered 'huge' objects */ -const H5B2_class_t H5HF_BT2_FILT_INDIR[1]={{ /* B-tree class information */ - H5B2_FHEAP_HUGE_FILT_INDIR_ID, /* Type of B-tree */ - "H5B2_FHEAP_HUGE_FILT_INDIR_ID", /* Name of B-tree class */ - sizeof(H5HF_huge_bt2_filt_indir_rec_t), /* Size of native record */ - H5HF_huge_btree2_filt_indir_store, /* Record storage callback */ - H5HF_huge_btree2_filt_indir_compare, /* Record comparison callback */ - H5HF_huge_btree2_filt_indir_encode, /* Record encoding callback */ - H5HF_huge_btree2_filt_indir_decode, /* Record decoding callback */ - H5HF_huge_btree2_filt_indir_debug /* Record debugging callback */ +const H5B2_class_t H5HF_HUGE_BT2_FILT_INDIR[1]={{ /* B-tree class information */ + H5B2_FHEAP_HUGE_FILT_INDIR_ID, /* Type of B-tree */ + "H5B2_FHEAP_HUGE_FILT_INDIR_ID", /* Name of B-tree class */ + sizeof(H5HF_huge_bt2_filt_indir_rec_t), /* Size of native record */ + H5HF_huge_bt2_crt_context, /* Create client callback context */ + H5HF_huge_bt2_dst_context, /* Destroy client callback context */ + H5HF_huge_bt2_filt_indir_store, /* Record storage callback */ + H5HF_huge_bt2_filt_indir_compare, /* Record comparison callback */ + H5HF_huge_bt2_filt_indir_encode, /* Record encoding callback */ + H5HF_huge_bt2_filt_indir_decode, /* Record decoding callback */ + H5HF_huge_bt2_filt_indir_debug, /* Record debugging callback */ + H5HF_huge_bt2_crt_dbg_context, /* Create debugging context */ + H5HF_huge_bt2_dst_context /* Destroy debugging context */ }}; /* v2 B-tree class for directly accessed 'huge' objects */ -const H5B2_class_t H5HF_BT2_DIR[1]={{ /* B-tree class information */ - H5B2_FHEAP_HUGE_DIR_ID, /* Type of B-tree */ - "H5B2_FHEAP_HUGE_DIR_ID", /* Name of B-tree class */ - sizeof(H5HF_huge_bt2_dir_rec_t), /* Size of native record */ - H5HF_huge_btree2_dir_store, /* Record storage callback */ - H5HF_huge_btree2_dir_compare, /* Record comparison callback */ - H5HF_huge_btree2_dir_encode, /* Record encoding callback */ - H5HF_huge_btree2_dir_decode, /* Record decoding callback */ - H5HF_huge_btree2_dir_debug /* Record debugging callback */ +const H5B2_class_t H5HF_HUGE_BT2_DIR[1]={{ /* B-tree class information */ + H5B2_FHEAP_HUGE_DIR_ID, /* Type of B-tree */ + "H5B2_FHEAP_HUGE_DIR_ID", /* Name of B-tree class */ + sizeof(H5HF_huge_bt2_dir_rec_t), /* Size of native record */ + H5HF_huge_bt2_crt_context, /* Create client callback context */ + H5HF_huge_bt2_dst_context, /* Destroy client callback context */ + H5HF_huge_bt2_dir_store, /* Record storage callback */ + H5HF_huge_bt2_dir_compare, /* Record comparison callback */ + H5HF_huge_bt2_dir_encode, /* Record encoding callback */ + H5HF_huge_bt2_dir_decode, /* Record decoding callback */ + H5HF_huge_bt2_dir_debug, /* Record debugging callback */ + H5HF_huge_bt2_crt_dbg_context, /* Create debugging context */ + H5HF_huge_bt2_dst_context /* Destroy debugging context */ }}; /* v2 B-tree class for directly accessed, filtered 'huge' objects */ -const H5B2_class_t H5HF_BT2_FILT_DIR[1]={{ /* B-tree class information */ - H5B2_FHEAP_HUGE_FILT_DIR_ID, /* Type of B-tree */ - "H5B2_FHEAP_HUGE_FILT_DIR_ID", /* Name of B-tree class */ - sizeof(H5HF_huge_bt2_filt_dir_rec_t),/* Size of native record */ - H5HF_huge_btree2_filt_dir_store, /* Record storage callback */ - H5HF_huge_btree2_filt_dir_compare, /* Record comparison callback */ - H5HF_huge_btree2_filt_dir_encode, /* Record encoding callback */ - H5HF_huge_btree2_filt_dir_decode, /* Record decoding callback */ - H5HF_huge_btree2_filt_dir_debug /* Record debugging callback */ +const H5B2_class_t H5HF_HUGE_BT2_FILT_DIR[1]={{ /* B-tree class information */ + H5B2_FHEAP_HUGE_FILT_DIR_ID, /* Type of B-tree */ + "H5B2_FHEAP_HUGE_FILT_DIR_ID", /* Name of B-tree class */ + sizeof(H5HF_huge_bt2_filt_dir_rec_t), /* Size of native record */ + H5HF_huge_bt2_crt_context, /* Create client callback context */ + H5HF_huge_bt2_dst_context, /* Destroy client callback context */ + H5HF_huge_bt2_filt_dir_store, /* Record storage callback */ + H5HF_huge_bt2_filt_dir_compare, /* Record comparison callback */ + H5HF_huge_bt2_filt_dir_encode, /* Record encoding callback */ + H5HF_huge_bt2_filt_dir_decode, /* Record decoding callback */ + H5HF_huge_bt2_filt_dir_debug, /* Record debugging callback */ + H5HF_huge_bt2_crt_dbg_context, /* Create debugging context */ + H5HF_huge_bt2_dst_context /* Destroy debugging context */ }}; /*****************************/ @@ -156,6 +184,126 @@ const H5B2_class_t H5HF_BT2_FILT_DIR[1]={{ /* B-tree class information */ /* Local Variables */ /*******************/ +/* Declare a free list to manage the H5HF_huge_bt2_ctx_t struct */ +H5FL_DEFINE_STATIC(H5HF_huge_bt2_ctx_t); + + + +/*------------------------------------------------------------------------- + * Function: H5HF_huge_bt2_crt_context + * + * Purpose: Create client callback context + * + * Note: Common to all 'huge' v2 B-tree clients + * + * Return: Success: non-NULL + * Failure: NULL + * + * Programmer: Quincey Koziol + * Thursday, November 26, 2009 + * + *------------------------------------------------------------------------- + */ +static void * +H5HF_huge_bt2_crt_context(void *_f) +{ + H5F_t *f = (H5F_t *)_f; /* User data for building callback context */ + H5HF_huge_bt2_ctx_t *ctx; /* Callback context structure */ + void *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5HF_huge_bt2_crt_context) + + /* Sanity check */ + HDassert(f); + + /* Allocate callback context */ + if(NULL == (ctx = H5FL_MALLOC(H5HF_huge_bt2_ctx_t))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate callback context") + + /* Determine the size of addresses & lengths in the file */ + ctx->sizeof_addr = H5F_SIZEOF_ADDR(f); + ctx->sizeof_size = H5F_SIZEOF_SIZE(f); + + /* Set return value */ + ret_value = ctx; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5HF_huge_bt2_crt_context() */ + + +/*------------------------------------------------------------------------- + * Function: H5HF_huge_bt2_dst_context + * + * Purpose: Destroy client callback context + * + * Note: Common to all 'huge' v2 B-tree clients + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Quincey Koziol + * Thursday, November 26, 2009 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5HF_huge_bt2_dst_context(void *_ctx) +{ + H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_dst_context) + + /* Sanity check */ + HDassert(ctx); + + /* Release callback context */ + ctx = H5FL_FREE(H5HF_huge_bt2_ctx_t, ctx); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5HF_huge_bt2_dst_context() */ + + +/*------------------------------------------------------------------------- + * Function: H5HF_huge_bt2_crt_dbg_context + * + * Purpose: Create context for debugging callback + * + * Return: Success: non-NULL + * Failure: NULL + * + * Programmer: Quincey Koziol + * Tuesday, December 1, 2009 + * + *------------------------------------------------------------------------- + */ +static void * +H5HF_huge_bt2_crt_dbg_context(H5F_t *f, hid_t UNUSED dxpl_id, haddr_t UNUSED addr) +{ + H5HF_huge_bt2_ctx_t *ctx; /* Callback context structure */ + void *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5HF_huge_bt2_crt_dbg_context) + + /* Sanity check */ + HDassert(f); + HDassert(H5F_addr_defined(addr)); + + /* Allocate callback context */ + if(NULL == (ctx = H5FL_MALLOC(H5HF_huge_bt2_ctx_t))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate callback context") + + /* Determine the size of addresses & lengths in the file */ + ctx->sizeof_addr = H5F_SIZEOF_ADDR(f); + ctx->sizeof_size = H5F_SIZEOF_SIZE(f); + + /* Set return value */ + ret_value = ctx; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5HF_huge_bt2_crt_dbg_context() */ + /*------------------------------------------------------------------------- * Function: H5HF_huge_bt2_indir_found @@ -223,7 +371,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_indir_store + * Function: H5HF_huge_bt2_indir_store * * Purpose: Store native information into record for v2 B-tree * @@ -236,18 +384,18 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_indir_store(void *nrecord, const void *udata) +H5HF_huge_bt2_indir_store(void *nrecord, const void *udata) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_indir_store) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_indir_store) *(H5HF_huge_bt2_indir_rec_t *)nrecord = *(const H5HF_huge_bt2_indir_rec_t *)udata; FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_indir_store() */ +} /* H5HF_huge_bt2_indir_store() */ /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_indir_compare + * Function: H5HF_huge_bt2_indir_compare * * Purpose: Compare two native information records, according to some key * @@ -261,25 +409,25 @@ H5HF_huge_btree2_indir_store(void *nrecord, const void *udata) *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_indir_compare(const void *_rec1, const void *_rec2) +H5HF_huge_bt2_indir_compare(const void *_rec1, const void *_rec2) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_indir_compare) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_indir_compare) #ifdef QAK { const H5HF_huge_bt2_indir_rec_t *rec1 = (const H5HF_huge_bt2_indir_rec_t *)_rec1; const H5HF_huge_bt2_indir_rec_t *rec2 = (const H5HF_huge_bt2_indir_rec_t *)_rec2; -HDfprintf(stderr, "%s: rec1 = {%a, %Hu, %Hu}\n", "H5HF_huge_btree2_indir_compare", rec1->addr, rec1->len, rec1->id); -HDfprintf(stderr, "%s: rec2 = {%a, %Hu, %Hu}\n", "H5HF_huge_btree2_indir_compare", rec2->addr, rec2->len, rec2->id); +HDfprintf(stderr, "%s: rec1 = {%a, %Hu, %Hu}\n", "H5HF_huge_bt2_indir_compare", rec1->addr, rec1->len, rec1->id); +HDfprintf(stderr, "%s: rec2 = {%a, %Hu, %Hu}\n", "H5HF_huge_bt2_indir_compare", rec2->addr, rec2->len, rec2->id); } #endif /* QAK */ FUNC_LEAVE_NOAPI((herr_t)(((const H5HF_huge_bt2_indir_rec_t *)_rec1)->id - ((const H5HF_huge_bt2_indir_rec_t *)_rec2)->id)) -} /* H5HF_huge_btree2_indir_compare() */ +} /* H5HF_huge_bt2_indir_compare() */ /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_indir_encode + * Function: H5HF_huge_bt2_indir_encode * * Purpose: Encode native information into raw form for storing on disk * @@ -292,23 +440,27 @@ HDfprintf(stderr, "%s: rec2 = {%a, %Hu, %Hu}\n", "H5HF_huge_btree2_indir_compare *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_indir_encode(const H5F_t *f, uint8_t *raw, const void *_nrecord) +H5HF_huge_bt2_indir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) { + H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ const H5HF_huge_bt2_indir_rec_t *nrecord = (const H5HF_huge_bt2_indir_rec_t *)_nrecord; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_indir_encode) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_indir_encode) + + /* Sanity check */ + HDassert(ctx); /* Encode the record's fields */ - H5F_addr_encode(f, &raw, nrecord->addr); - H5F_ENCODE_LENGTH(f, raw, nrecord->len); - H5F_ENCODE_LENGTH(f, raw, nrecord->id); + H5F_addr_encode_len(ctx->sizeof_addr, &raw, nrecord->addr); + H5F_ENCODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size); + H5F_ENCODE_LENGTH_LEN(raw, nrecord->id, ctx->sizeof_size); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_indir_encode() */ +} /* H5HF_huge_bt2_indir_encode() */ /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_indir_decode + * Function: H5HF_huge_bt2_indir_decode * * Purpose: Decode raw disk form of record into native form * @@ -321,23 +473,27 @@ H5HF_huge_btree2_indir_encode(const H5F_t *f, uint8_t *raw, const void *_nrecord *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_indir_decode(const H5F_t *f, const uint8_t *raw, void *_nrecord) +H5HF_huge_bt2_indir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) { + H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ H5HF_huge_bt2_indir_rec_t *nrecord = (H5HF_huge_bt2_indir_rec_t *)_nrecord; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_indir_decode) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_indir_decode) + + /* Sanity check */ + HDassert(ctx); /* Decode the record's fields */ - H5F_addr_decode(f, &raw, &nrecord->addr); - H5F_DECODE_LENGTH(f, raw, nrecord->len); - H5F_DECODE_LENGTH(f, raw, nrecord->id); + H5F_addr_decode_len(ctx->sizeof_addr, &raw, &nrecord->addr); + H5F_DECODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size); + H5F_DECODE_LENGTH_LEN(raw, nrecord->id, ctx->sizeof_size); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_indir_decode() */ +} /* H5HF_huge_bt2_indir_decode() */ /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_indir_debug + * Function: H5HF_huge_bt2_indir_debug * * Purpose: Debug native form of record * @@ -350,19 +506,19 @@ H5HF_huge_btree2_indir_decode(const H5F_t *f, const uint8_t *raw, void *_nrecord *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_indir_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED dxpl_id, +H5HF_huge_bt2_indir_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED dxpl_id, int indent, int fwidth, const void *_nrecord, const void UNUSED *_udata) { const H5HF_huge_bt2_indir_rec_t *nrecord = (const H5HF_huge_bt2_indir_rec_t *)_nrecord; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_indir_debug) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_indir_debug) HDfprintf(stream, "%*s%-*s {%a, %Hu, %Hu}\n", indent, "", fwidth, "Record:", nrecord->addr, nrecord->len, nrecord->id); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_indir_debug() */ +} /* H5HF_huge_bt2_indir_debug() */ /*------------------------------------------------------------------------- @@ -433,7 +589,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_filt_indir_store + * Function: H5HF_huge_bt2_filt_indir_store * * Purpose: Store native information into record for v2 B-tree * @@ -446,18 +602,18 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_filt_indir_store(void *nrecord, const void *udata) +H5HF_huge_bt2_filt_indir_store(void *nrecord, const void *udata) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_filt_indir_store) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_filt_indir_store) *(H5HF_huge_bt2_filt_indir_rec_t *)nrecord = *(const H5HF_huge_bt2_filt_indir_rec_t *)udata; FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_filt_indir_store() */ +} /* H5HF_huge_bt2_filt_indir_store() */ /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_filt_indir_compare + * Function: H5HF_huge_bt2_filt_indir_compare * * Purpose: Compare two native information records, according to some key * @@ -471,25 +627,25 @@ H5HF_huge_btree2_filt_indir_store(void *nrecord, const void *udata) *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_filt_indir_compare(const void *_rec1, const void *_rec2) +H5HF_huge_bt2_filt_indir_compare(const void *_rec1, const void *_rec2) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_filt_indir_compare) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_filt_indir_compare) #ifdef QAK { const H5HF_huge_bt2_filt_indir_rec_t *rec1 = (const H5HF_huge_bt2_filt_indir_rec_t *)_rec1; const H5HF_huge_bt2_filt_indir_rec_t *rec2 = (const H5HF_huge_bt2_filt_indir_rec_t *)_rec2; -HDfprintf(stderr, "%s: rec1 = {%a, %Hu, %x, %Hu, %Hu}\n", "H5HF_huge_btree2_filt_indir_compare", rec1->addr, rec1->len, rec1->filter_mask, rec1->obj_size, rec1->id); -HDfprintf(stderr, "%s: rec2 = {%a, %Hu, %x, %Hu, %Hu}\n", "H5HF_huge_btree2_filt_indir_compare", rec2->addr, rec2->len, rec2->filter_mask, rec2->obj_size, rec2->id); +HDfprintf(stderr, "%s: rec1 = {%a, %Hu, %x, %Hu, %Hu}\n", "H5HF_huge_bt2_filt_indir_compare", rec1->addr, rec1->len, rec1->filter_mask, rec1->obj_size, rec1->id); +HDfprintf(stderr, "%s: rec2 = {%a, %Hu, %x, %Hu, %Hu}\n", "H5HF_huge_bt2_filt_indir_compare", rec2->addr, rec2->len, rec2->filter_mask, rec2->obj_size, rec2->id); } #endif /* QAK */ FUNC_LEAVE_NOAPI((herr_t)(((const H5HF_huge_bt2_filt_indir_rec_t *)_rec1)->id - ((const H5HF_huge_bt2_filt_indir_rec_t *)_rec2)->id)) -} /* H5HF_huge_btree2_filt_indir_compare() */ +} /* H5HF_huge_bt2_filt_indir_compare() */ /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_filt_indir_encode + * Function: H5HF_huge_bt2_filt_indir_encode * * Purpose: Encode native information into raw form for storing on disk * @@ -502,25 +658,29 @@ HDfprintf(stderr, "%s: rec2 = {%a, %Hu, %x, %Hu, %Hu}\n", "H5HF_huge_btree2_filt *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_filt_indir_encode(const H5F_t *f, uint8_t *raw, const void *_nrecord) +H5HF_huge_bt2_filt_indir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) { + H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ const H5HF_huge_bt2_filt_indir_rec_t *nrecord = (const H5HF_huge_bt2_filt_indir_rec_t *)_nrecord; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_filt_indir_encode) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_filt_indir_encode) + + /* Sanity check */ + HDassert(ctx); /* Encode the record's fields */ - H5F_addr_encode(f, &raw, nrecord->addr); - H5F_ENCODE_LENGTH(f, raw, nrecord->len); + H5F_addr_encode_len(ctx->sizeof_addr, &raw, nrecord->addr); + H5F_ENCODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size); UINT32ENCODE(raw, nrecord->filter_mask); - H5F_ENCODE_LENGTH(f, raw, nrecord->obj_size); - H5F_ENCODE_LENGTH(f, raw, nrecord->id); + H5F_ENCODE_LENGTH_LEN(raw, nrecord->obj_size, ctx->sizeof_size); + H5F_ENCODE_LENGTH_LEN(raw, nrecord->id, ctx->sizeof_size); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_filt_indir_encode() */ +} /* H5HF_huge_bt2_filt_indir_encode() */ /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_filt_indir_decode + * Function: H5HF_huge_bt2_filt_indir_decode * * Purpose: Decode raw disk form of record into native form * @@ -533,25 +693,29 @@ H5HF_huge_btree2_filt_indir_encode(const H5F_t *f, uint8_t *raw, const void *_nr *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_filt_indir_decode(const H5F_t *f, const uint8_t *raw, void *_nrecord) +H5HF_huge_bt2_filt_indir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) { + H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ H5HF_huge_bt2_filt_indir_rec_t *nrecord = (H5HF_huge_bt2_filt_indir_rec_t *)_nrecord; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_filt_indir_decode) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_filt_indir_decode) + + /* Sanity check */ + HDassert(ctx); /* Decode the record's fields */ - H5F_addr_decode(f, &raw, &nrecord->addr); - H5F_DECODE_LENGTH(f, raw, nrecord->len); + H5F_addr_decode_len(ctx->sizeof_addr, &raw, &nrecord->addr); + H5F_DECODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size); UINT32DECODE(raw, nrecord->filter_mask); - H5F_DECODE_LENGTH(f, raw, nrecord->obj_size); - H5F_DECODE_LENGTH(f, raw, nrecord->id); + H5F_DECODE_LENGTH_LEN(raw, nrecord->obj_size, ctx->sizeof_size); + H5F_DECODE_LENGTH_LEN(raw, nrecord->id, ctx->sizeof_size); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_filt_indir_decode() */ +} /* H5HF_huge_bt2_filt_indir_decode() */ /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_filt_indir_debug + * Function: H5HF_huge_bt2_filt_indir_debug * * Purpose: Debug native form of record * @@ -564,19 +728,19 @@ H5HF_huge_btree2_filt_indir_decode(const H5F_t *f, const uint8_t *raw, void *_nr *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_filt_indir_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED dxpl_id, +H5HF_huge_bt2_filt_indir_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED dxpl_id, int indent, int fwidth, const void *_nrecord, const void UNUSED *_udata) { const H5HF_huge_bt2_filt_indir_rec_t *nrecord = (const H5HF_huge_bt2_filt_indir_rec_t *)_nrecord; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_filt_indir_debug) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_filt_indir_debug) HDfprintf(stream, "%*s%-*s {%a, %Hu, %x, %Hu, %Hu}\n", indent, "", fwidth, "Record:", nrecord->addr, nrecord->len, nrecord->filter_mask, nrecord->obj_size, nrecord->id); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_filt_indir_debug() */ +} /* H5HF_huge_bt2_filt_indir_debug() */ /*------------------------------------------------------------------------- @@ -614,7 +778,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_dir_store + * Function: H5HF_huge_bt2_dir_store * * Purpose: Store native information into record for v2 B-tree * @@ -627,18 +791,18 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_dir_store(void *nrecord, const void *udata) +H5HF_huge_bt2_dir_store(void *nrecord, const void *udata) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_dir_store) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_dir_store) *(H5HF_huge_bt2_dir_rec_t *)nrecord = *(const H5HF_huge_bt2_dir_rec_t *)udata; FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_dir_store() */ +} /* H5HF_huge_bt2_dir_store() */ /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_dir_compare + * Function: H5HF_huge_bt2_dir_compare * * Purpose: Compare two native information records, according to some key * @@ -652,17 +816,17 @@ H5HF_huge_btree2_dir_store(void *nrecord, const void *udata) *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_dir_compare(const void *_rec1, const void *_rec2) +H5HF_huge_bt2_dir_compare(const void *_rec1, const void *_rec2) { const H5HF_huge_bt2_dir_rec_t *rec1 = (const H5HF_huge_bt2_dir_rec_t *)_rec1; const H5HF_huge_bt2_dir_rec_t *rec2 = (const H5HF_huge_bt2_dir_rec_t *)_rec2; herr_t ret_value; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_dir_compare) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_dir_compare) #ifdef QAK -HDfprintf(stderr, "%s: rec1 = {%a, %Hu}\n", "H5HF_huge_btree2_dir_compare", rec1->addr, rec1->len); -HDfprintf(stderr, "%s: rec2 = {%a, %Hu}\n", "H5HF_huge_btree2_dir_compare", rec2->addr, rec2->len); +HDfprintf(stderr, "%s: rec1 = {%a, %Hu}\n", "H5HF_huge_bt2_dir_compare", rec1->addr, rec1->len); +HDfprintf(stderr, "%s: rec2 = {%a, %Hu}\n", "H5HF_huge_bt2_dir_compare", rec2->addr, rec2->len); #endif /* QAK */ if(rec1->addr < rec2->addr) ret_value = -1; @@ -676,11 +840,11 @@ HDfprintf(stderr, "%s: rec2 = {%a, %Hu}\n", "H5HF_huge_btree2_dir_compare", rec2 ret_value = 0; FUNC_LEAVE_NOAPI(ret_value) -} /* H5HF_huge_btree2_dir_compare() */ +} /* H5HF_huge_bt2_dir_compare() */ /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_dir_encode + * Function: H5HF_huge_bt2_dir_encode * * Purpose: Encode native information into raw form for storing on disk * @@ -693,22 +857,26 @@ HDfprintf(stderr, "%s: rec2 = {%a, %Hu}\n", "H5HF_huge_btree2_dir_compare", rec2 *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_dir_encode(const H5F_t *f, uint8_t *raw, const void *_nrecord) +H5HF_huge_bt2_dir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) { + H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ const H5HF_huge_bt2_dir_rec_t *nrecord = (const H5HF_huge_bt2_dir_rec_t *)_nrecord; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_dir_encode) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_dir_encode) + + /* Sanity check */ + HDassert(ctx); /* Encode the record's fields */ - H5F_addr_encode(f, &raw, nrecord->addr); - H5F_ENCODE_LENGTH(f, raw, nrecord->len); + H5F_addr_encode_len(ctx->sizeof_addr, &raw, nrecord->addr); + H5F_ENCODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_dir_encode() */ +} /* H5HF_huge_bt2_dir_encode() */ /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_dir_decode + * Function: H5HF_huge_bt2_dir_decode * * Purpose: Decode raw disk form of record into native form * @@ -721,22 +889,26 @@ H5HF_huge_btree2_dir_encode(const H5F_t *f, uint8_t *raw, const void *_nrecord) *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_dir_decode(const H5F_t *f, const uint8_t *raw, void *_nrecord) +H5HF_huge_bt2_dir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) { + H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ H5HF_huge_bt2_dir_rec_t *nrecord = (H5HF_huge_bt2_dir_rec_t *)_nrecord; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_dir_decode) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_dir_decode) + + /* Sanity check */ + HDassert(ctx); /* Decode the record's fields */ - H5F_addr_decode(f, &raw, &nrecord->addr); - H5F_DECODE_LENGTH(f, raw, nrecord->len); + H5F_addr_decode_len(ctx->sizeof_addr, &raw, &nrecord->addr); + H5F_DECODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_dir_decode() */ +} /* H5HF_huge_bt2_dir_decode() */ /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_dir_debug + * Function: H5HF_huge_bt2_dir_debug * * Purpose: Debug native form of record * @@ -749,19 +921,19 @@ H5HF_huge_btree2_dir_decode(const H5F_t *f, const uint8_t *raw, void *_nrecord) *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_dir_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED dxpl_id, +H5HF_huge_bt2_dir_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED dxpl_id, int indent, int fwidth, const void *_nrecord, const void UNUSED *_udata) { const H5HF_huge_bt2_dir_rec_t *nrecord = (const H5HF_huge_bt2_dir_rec_t *)_nrecord; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_dir_debug) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_dir_debug) HDfprintf(stream, "%*s%-*s {%a, %Hu}\n", indent, "", fwidth, "Record:", nrecord->addr, nrecord->len); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_dir_debug() */ +} /* H5HF_huge_bt2_dir_debug() */ /*------------------------------------------------------------------------- @@ -831,7 +1003,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_filt_dir_store + * Function: H5HF_huge_bt2_filt_dir_store * * Purpose: Store native information into record for v2 B-tree * @@ -844,18 +1016,18 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_filt_dir_store(void *nrecord, const void *udata) +H5HF_huge_bt2_filt_dir_store(void *nrecord, const void *udata) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_filt_dir_store) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_filt_dir_store) *(H5HF_huge_bt2_filt_dir_rec_t *)nrecord = *(const H5HF_huge_bt2_filt_dir_rec_t *)udata; FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_filt_dir_store() */ +} /* H5HF_huge_bt2_filt_dir_store() */ /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_filt_dir_compare + * Function: H5HF_huge_bt2_filt_dir_compare * * Purpose: Compare two native information records, according to some key * @@ -869,17 +1041,17 @@ H5HF_huge_btree2_filt_dir_store(void *nrecord, const void *udata) *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_filt_dir_compare(const void *_rec1, const void *_rec2) +H5HF_huge_bt2_filt_dir_compare(const void *_rec1, const void *_rec2) { const H5HF_huge_bt2_filt_dir_rec_t *rec1 = (const H5HF_huge_bt2_filt_dir_rec_t *)_rec1; const H5HF_huge_bt2_filt_dir_rec_t *rec2 = (const H5HF_huge_bt2_filt_dir_rec_t *)_rec2; herr_t ret_value; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_filt_dir_compare) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_filt_dir_compare) #ifdef QAK -HDfprintf(stderr, "%s: rec1 = {%a, %Hu, %x, %Hu}\n", "H5HF_huge_btree2_filt_dir_compare", rec1->addr, rec1->len, rec1->filter_mask, rec1->obj_size); -HDfprintf(stderr, "%s: rec2 = {%a, %Hu, %x, %Hu}\n", "H5HF_huge_btree2_filt_dir_compare", rec2->addr, rec2->len, rec2->filter_mask, rec2->obj_size); +HDfprintf(stderr, "%s: rec1 = {%a, %Hu, %x, %Hu}\n", "H5HF_huge_bt2_filt_dir_compare", rec1->addr, rec1->len, rec1->filter_mask, rec1->obj_size); +HDfprintf(stderr, "%s: rec2 = {%a, %Hu, %x, %Hu}\n", "H5HF_huge_bt2_filt_dir_compare", rec2->addr, rec2->len, rec2->filter_mask, rec2->obj_size); #endif /* QAK */ if(rec1->addr < rec2->addr) ret_value = -1; @@ -893,11 +1065,11 @@ HDfprintf(stderr, "%s: rec2 = {%a, %Hu, %x, %Hu}\n", "H5HF_huge_btree2_filt_dir_ ret_value = 0; FUNC_LEAVE_NOAPI(ret_value) -} /* H5HF_huge_btree2_filt_dir_compare() */ +} /* H5HF_huge_bt2_filt_dir_compare() */ /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_filt_dir_encode + * Function: H5HF_huge_bt2_filt_dir_encode * * Purpose: Encode native information into raw form for storing on disk * @@ -910,24 +1082,28 @@ HDfprintf(stderr, "%s: rec2 = {%a, %Hu, %x, %Hu}\n", "H5HF_huge_btree2_filt_dir_ *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_filt_dir_encode(const H5F_t *f, uint8_t *raw, const void *_nrecord) +H5HF_huge_bt2_filt_dir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) { + H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ const H5HF_huge_bt2_filt_dir_rec_t *nrecord = (const H5HF_huge_bt2_filt_dir_rec_t *)_nrecord; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_filt_dir_encode) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_filt_dir_encode) + + /* Sanity check */ + HDassert(ctx); /* Encode the record's fields */ - H5F_addr_encode(f, &raw, nrecord->addr); - H5F_ENCODE_LENGTH(f, raw, nrecord->len); + H5F_addr_encode_len(ctx->sizeof_addr, &raw, nrecord->addr); + H5F_ENCODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size); UINT32ENCODE(raw, nrecord->filter_mask); - H5F_ENCODE_LENGTH(f, raw, nrecord->obj_size); + H5F_ENCODE_LENGTH_LEN(raw, nrecord->obj_size, ctx->sizeof_size); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_filt_dir_encode() */ +} /* H5HF_huge_bt2_filt_dir_encode() */ /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_filt_dir_decode + * Function: H5HF_huge_bt2_filt_dir_decode * * Purpose: Decode raw disk form of record into native form * @@ -940,24 +1116,28 @@ H5HF_huge_btree2_filt_dir_encode(const H5F_t *f, uint8_t *raw, const void *_nrec *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_filt_dir_decode(const H5F_t *f, const uint8_t *raw, void *_nrecord) +H5HF_huge_bt2_filt_dir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) { + H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ H5HF_huge_bt2_filt_dir_rec_t *nrecord = (H5HF_huge_bt2_filt_dir_rec_t *)_nrecord; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_filt_dir_decode) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_filt_dir_decode) + + /* Sanity check */ + HDassert(ctx); /* Decode the record's fields */ - H5F_addr_decode(f, &raw, &nrecord->addr); - H5F_DECODE_LENGTH(f, raw, nrecord->len); + H5F_addr_decode_len(ctx->sizeof_addr, &raw, &nrecord->addr); + H5F_DECODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size); UINT32DECODE(raw, nrecord->filter_mask); - H5F_DECODE_LENGTH(f, raw, nrecord->obj_size); + H5F_DECODE_LENGTH_LEN(raw, nrecord->obj_size, ctx->sizeof_size); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_filt_dir_decode() */ +} /* H5HF_huge_bt2_filt_dir_decode() */ /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_filt_dir_debug + * Function: H5HF_huge_bt2_filt_dir_debug * * Purpose: Debug native form of record * @@ -970,16 +1150,16 @@ H5HF_huge_btree2_filt_dir_decode(const H5F_t *f, const uint8_t *raw, void *_nrec *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_btree2_filt_dir_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED dxpl_id, +H5HF_huge_bt2_filt_dir_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED dxpl_id, int indent, int fwidth, const void *_nrecord, const void UNUSED *_udata) { const H5HF_huge_bt2_filt_dir_rec_t *nrecord = (const H5HF_huge_bt2_filt_dir_rec_t *)_nrecord; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_filt_dir_debug) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_bt2_filt_dir_debug) HDfprintf(stream, "%*s%-*s {%a, %Hu, %x, %Hu}\n", indent, "", fwidth, "Record:", nrecord->addr, nrecord->len, nrecord->filter_mask, nrecord->obj_size); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_filt_dir_debug() */ +} /* H5HF_huge_bt2_filt_dir_debug() */ diff --git a/src/H5HFhuge.c b/src/H5HFhuge.c index 353ceb3..5490c22 100644 --- a/src/H5HFhuge.c +++ b/src/H5HFhuge.c @@ -128,12 +128,12 @@ H5HF_huge_bt2_create(H5HF_hdr_t *hdr, hid_t dxpl_id) + hdr->sizeof_size /* Length of object */ + 4 /* Filter mask for filtered object */ + hdr->sizeof_size); /* Size of de-filtered object in memory */ - bt2_cparam.cls = H5HF_BT2_FILT_DIR; + bt2_cparam.cls = H5HF_HUGE_BT2_FILT_DIR; } /* end if */ else { bt2_cparam.rrec_size = (size_t)(hdr->sizeof_addr /* Address of object */ + hdr->sizeof_size); /* Length of object */ - bt2_cparam.cls = H5HF_BT2_DIR; + bt2_cparam.cls = H5HF_HUGE_BT2_DIR; } /* end else */ } /* end if */ else { @@ -143,13 +143,13 @@ H5HF_huge_bt2_create(H5HF_hdr_t *hdr, hid_t dxpl_id) + 4 /* Filter mask for filtered object */ + hdr->sizeof_size /* Size of de-filtered object in memory */ + hdr->sizeof_size); /* Unique ID for object */ - bt2_cparam.cls = H5HF_BT2_FILT_INDIR; + bt2_cparam.cls = H5HF_HUGE_BT2_FILT_INDIR; } /* end if */ else { bt2_cparam.rrec_size = (size_t)(hdr->sizeof_addr /* Address of object */ + hdr->sizeof_size /* Length of object */ + hdr->sizeof_size); /* Unique ID for object */ - bt2_cparam.cls = H5HF_BT2_INDIR; + bt2_cparam.cls = H5HF_HUGE_BT2_INDIR; } /* end else */ } /* end else */ bt2_cparam.node_size = (size_t)H5HF_HUGE_BT2_NODE_SIZE; @@ -157,7 +157,7 @@ H5HF_huge_bt2_create(H5HF_hdr_t *hdr, hid_t dxpl_id) bt2_cparam.merge_percent = H5HF_HUGE_BT2_MERGE_PERC; /* Create v2 B-tree for tracking 'huge' objects */ - if(NULL == (hdr->huge_bt2 = H5B2_create(hdr->f, dxpl_id, &bt2_cparam))) + if(NULL == (hdr->huge_bt2 = H5B2_create(hdr->f, dxpl_id, &bt2_cparam, hdr->f))) HGOTO_ERROR(H5E_HEAP, H5E_CANTCREATE, FAIL, "can't create v2 B-tree for tracking 'huge' heap objects") /* Retrieve the v2 B-tree's address in the file */ @@ -339,7 +339,7 @@ HDfprintf(stderr, "%s: obj_size = %Zu\n", FUNC, obj_size); /* Check if v2 B-tree is open yet */ if(NULL == hdr->huge_bt2) { /* Open existing v2 B-tree */ - if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr))) + if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f))) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") } /* end if */ } /* end else */ @@ -545,7 +545,7 @@ H5HF_huge_get_obj_len(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id, /* Check if v2 B-tree is open yet */ if(NULL == hdr->huge_bt2) { /* Open existing v2 B-tree */ - if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr))) + if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f))) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") } /* end if */ @@ -636,7 +636,7 @@ H5HF_huge_op_real(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id, /* Check if v2 B-tree is open yet */ if(NULL == hdr->huge_bt2) { /* Open existing v2 B-tree */ - if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr))) + if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f))) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") } /* end if */ @@ -784,7 +784,7 @@ H5HF_huge_write(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id, /* Check if v2 B-tree is open yet */ if(NULL == hdr->huge_bt2) { /* Open existing v2 B-tree */ - if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr))) + if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f))) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") } /* end if */ @@ -914,7 +914,7 @@ H5HF_huge_remove(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id) /* Check if v2 B-tree is open yet */ if(NULL == hdr->huge_bt2) { /* Open existing v2 B-tree */ - if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr))) + if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f))) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") } /* end if */ @@ -1037,7 +1037,7 @@ H5HF_huge_term(H5HF_hdr_t *hdr, hid_t dxpl_id) /* Delete the v2 B-tree */ /* (any v2 B-tree class will work here) */ - if(H5B2_delete(hdr->f, dxpl_id, hdr->huge_bt2_addr, NULL, NULL) < 0) + if(H5B2_delete(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f, NULL, NULL) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "can't delete v2 B-tree") /* Reset the information about 'huge' objects in the file */ @@ -1105,7 +1105,7 @@ H5HF_huge_delete(H5HF_hdr_t *hdr, hid_t dxpl_id) } /* end else */ /* Delete the v2 B-tree */ - if(H5B2_delete(hdr->f, dxpl_id, hdr->huge_bt2_addr, op, &udata) < 0) + if(H5B2_delete(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f, op, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "can't delete v2 B-tree") done: diff --git a/src/H5HFpkg.h b/src/H5HFpkg.h index 5951335..1728248 100644 --- a/src/H5HFpkg.h +++ b/src/H5HFpkg.h @@ -482,16 +482,16 @@ H5_DLLVAR const H5AC_class_t H5AC_FHEAP_IBLOCK[1]; H5_DLLVAR const H5AC_class_t H5AC_FHEAP_DBLOCK[1]; /* The v2 B-tree class for tracking indirectly accessed 'huge' objects */ -H5_DLLVAR const H5B2_class_t H5HF_BT2_INDIR[1]; +H5_DLLVAR const H5B2_class_t H5HF_HUGE_BT2_INDIR[1]; /* The v2 B-tree class for tracking indirectly accessed filtered 'huge' objects */ -H5_DLLVAR const H5B2_class_t H5HF_BT2_FILT_INDIR[1]; +H5_DLLVAR const H5B2_class_t H5HF_HUGE_BT2_FILT_INDIR[1]; /* The v2 B-tree class for tracking directly accessed 'huge' objects */ -H5_DLLVAR const H5B2_class_t H5HF_BT2_DIR[1]; +H5_DLLVAR const H5B2_class_t H5HF_HUGE_BT2_DIR[1]; /* The v2 B-tree class for tracking directly accessed filtered 'huge' objects */ -H5_DLLVAR const H5B2_class_t H5HF_BT2_FILT_DIR[1]; +H5_DLLVAR const H5B2_class_t H5HF_HUGE_BT2_FILT_DIR[1]; /* H5HF single section inherits serializable properties from H5FS_section_class_t */ H5_DLLVAR H5FS_section_class_t H5HF_FSPACE_SECT_CLS_SINGLE[1]; diff --git a/src/H5HFstat.c b/src/H5HFstat.c index fb535b9..2ab5240 100644 --- a/src/H5HFstat.c +++ b/src/H5HFstat.c @@ -155,7 +155,7 @@ H5HF_size(const H5HF_t *fh, hid_t dxpl_id, hsize_t *heap_size) /* Check for B-tree storage of huge objects in fractal heap */ if(H5F_addr_defined(hdr->huge_bt2_addr)) { /* Open the huge object index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr))) + if(NULL == (bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f))) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' objects") /* Get the B-tree storage */ diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c index d6bface..d73727d 100644 --- a/src/H5Oattribute.c +++ b/src/H5Oattribute.c @@ -1881,7 +1881,7 @@ H5O_attr_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info) /* Check if name index available */ if(H5F_addr_defined(ainfo.name_bt2_addr)) { /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo.name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(f, dxpl_id, ainfo.name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Get name index B-tree size */ @@ -1892,7 +1892,7 @@ H5O_attr_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info) /* Check if creation order index available */ if(H5F_addr_defined(ainfo.corder_bt2_addr)) { /* Open the creation order index v2 B-tree */ - if(NULL == (bt2_corder = H5B2_open(f, dxpl_id, ainfo.corder_bt2_addr))) + if(NULL == (bt2_corder = H5B2_open(f, dxpl_id, ainfo.corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Get creation order index B-tree size */ diff --git a/src/H5Otest.c b/src/H5Otest.c index 45ade3a..c7cd8a9 100644 --- a/src/H5Otest.c +++ b/src/H5Otest.c @@ -194,7 +194,7 @@ H5O_is_attr_empty_test(hid_t oid) HDassert(nattrs == 0); /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(oloc->file, H5AC_ind_dxpl_id, ainfo.name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(oloc->file, H5AC_ind_dxpl_id, ainfo.name_bt2_addr, NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in name index */ @@ -281,7 +281,7 @@ H5O_num_attrs_test(hid_t oid, hsize_t *nattrs) HDassert(obj_nattrs == 0); /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(oloc->file, H5AC_ind_dxpl_id, ainfo.name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(oloc->file, H5AC_ind_dxpl_id, ainfo.name_bt2_addr, NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in name index */ @@ -363,7 +363,7 @@ H5O_attr_dense_info_test(hid_t oid, hsize_t *name_count, hsize_t *corder_count) HGOTO_DONE(FAIL) /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(oloc->file, H5AC_ind_dxpl_id, ainfo.name_bt2_addr))) + if(NULL == (bt2_name = H5B2_open(oloc->file, H5AC_ind_dxpl_id, ainfo.name_bt2_addr, NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in name index */ @@ -373,7 +373,7 @@ H5O_attr_dense_info_test(hid_t oid, hsize_t *name_count, hsize_t *corder_count) /* Check if there is a creation order index */ if(H5F_addr_defined(ainfo.corder_bt2_addr)) { /* Open the creation order index v2 B-tree */ - if(NULL == (bt2_corder = H5B2_open(oloc->file, H5AC_ind_dxpl_id, ainfo.corder_bt2_addr))) + if(NULL == (bt2_corder = H5B2_open(oloc->file, H5AC_ind_dxpl_id, ainfo.corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Retrieve # of records in creation order index */ @@ -43,6 +43,7 @@ /******************/ /* Local Typedefs */ /******************/ + /* Udata struct for calls to H5SM_read_iter_op */ typedef struct H5SM_read_udata_t { H5F_t *file; /* File in which sharing is happening (in) */ @@ -475,7 +476,7 @@ H5SM_create_index(H5F_t *f, H5SM_index_header_t *header, hid_t dxpl_id) bt2_cparam.rrec_size = (size_t)H5SM_SOHM_ENTRY_SIZE(f); bt2_cparam.split_percent = H5SM_B2_SPLIT_PERCENT; bt2_cparam.merge_percent = H5SM_B2_MERGE_PERCENT; - if(NULL == (bt2 = H5B2_create(f, dxpl_id, &bt2_cparam))) + if(NULL == (bt2 = H5B2_create(f, dxpl_id, &bt2_cparam, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTCREATE, FAIL, "B-tree creation failed for SOHM index") /* Retrieve the v2 B-tree's address in the file */ @@ -575,7 +576,7 @@ H5SM_delete_index(H5F_t *f, H5SM_index_header_t *header, hid_t dxpl_id, HDassert(header->index_type == H5SM_BTREE); /* Delete the B-tree. */ - if(H5B2_delete(f, dxpl_id, header->index_addr, NULL, NULL) < 0) + if(H5B2_delete(f, dxpl_id, header->index_addr, f, NULL, NULL) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTDELETE, FAIL, "unable to delete B-tree") /* Revert to list unless B-trees can have zero records */ @@ -721,7 +722,7 @@ H5SM_convert_list_to_btree(H5F_t *f, H5SM_index_header_t *header, bt2_cparam.rrec_size = (size_t)H5SM_SOHM_ENTRY_SIZE(f); bt2_cparam.split_percent = H5SM_B2_SPLIT_PERCENT; bt2_cparam.merge_percent = H5SM_B2_MERGE_PERCENT; - if(NULL == (bt2 = H5B2_create(f, dxpl_id, &bt2_cparam))) + if(NULL == (bt2 = H5B2_create(f, dxpl_id, &bt2_cparam, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTCREATE, FAIL, "B-tree creation failed for SOHM index") /* Retrieve the v2 B-tree's address in the file */ @@ -828,7 +829,7 @@ H5SM_convert_btree_to_list(H5F_t * f, H5SM_index_header_t * header, hid_t dxpl_i /* Delete the B-tree and have messages copy themselves to the * list as they're deleted */ - if(H5B2_delete(f, dxpl_id, btree_addr, H5SM_btree_convert_to_list_op, list) < 0) + if(H5B2_delete(f, dxpl_id, btree_addr, f, H5SM_bt2_convert_to_list_op, list) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTDELETE, FAIL, "unable to delete B-tree") done: @@ -1250,7 +1251,7 @@ H5SM_write_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, HDassert(header->index_type == H5SM_BTREE); /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, header->index_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, header->index_addr, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for SOHM index") /* Set up callback info */ @@ -1344,7 +1345,7 @@ H5SM_write_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, /* Open the index v2 B-tree, if it isn't already */ if(NULL == bt2) { - if(NULL == (bt2 = H5B2_open(f, dxpl_id, header->index_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, header->index_addr, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for SOHM index") } /* end if */ @@ -1703,7 +1704,7 @@ H5SM_delete_from_index(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, HDassert(header->index_type == H5SM_BTREE); /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, header->index_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, header->index_addr, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for SOHM index") /* If this returns failure, it means that the message wasn't found. @@ -1733,7 +1734,7 @@ H5SM_delete_from_index(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, else { /* Open the index v2 B-tree, if it isn't already */ if(NULL == bt2) { - if(NULL == (bt2 = H5B2_open(f, dxpl_id, header->index_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, header->index_addr, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for SOHM index") } /* end if */ @@ -1909,86 +1910,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5SM_message_encode - * - * Purpose: Serialize a H5SM_sohm_t struct into a buffer RAW. - * - * Return: Non-negative on success - * Negative on failure - * - * Programmer: James Laird - * Monday, November 6, 2006 - * - *------------------------------------------------------------------------- - */ -herr_t -H5SM_message_encode(const H5F_t *f, uint8_t *raw, const void *_nrecord) -{ - const H5SM_sohm_t *message = (const H5SM_sohm_t *)_nrecord; - - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_message_encode) - - *raw++ = message->location; - UINT32ENCODE(raw, message->hash); - - if(message->location == H5SM_IN_HEAP) { - UINT32ENCODE(raw, message->u.heap_loc.ref_count); - UINT64ENCODE(raw, message->u.heap_loc.fheap_id); - } /* end if */ - else { - HDassert(message->location == H5SM_IN_OH); - - *raw++ = 0; /* reserved (possible flags byte) */ - *raw++ = (uint8_t)message->msg_type_id; - UINT16ENCODE(raw, message->u.mesg_loc.index); - H5F_addr_encode(f, &raw, message->u.mesg_loc.oh_addr); - } /* end else */ - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5SM_message_encode */ - - -/*------------------------------------------------------------------------- - * Function: H5SM_message_decode - * - * Purpose: Read an encoded SOHM message from RAW into an H5SM_sohm_t struct. - * - * Return: Non-negative on success - * Negative on failure - * - * Programmer: James Laird - * Monday, November 6, 2006 - * - *------------------------------------------------------------------------- - */ -herr_t -H5SM_message_decode(const H5F_t UNUSED *f, const uint8_t *raw, void *_nrecord) -{ - H5SM_sohm_t *message = (H5SM_sohm_t *)_nrecord; - - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_message_decode) - - message->location = (H5SM_storage_loc_t)*raw++; - UINT32DECODE(raw, message->hash); - - if(message->location == H5SM_IN_HEAP) { - UINT32DECODE(raw, message->u.heap_loc.ref_count); - UINT64DECODE(raw, message->u.heap_loc.fheap_id); - } /* end if */ - else { - HDassert(message->location == H5SM_IN_OH); - - raw++; /* reserved */ - message->msg_type_id = *raw++; - UINT16DECODE(raw, message->u.mesg_loc.index); - H5F_addr_decode(f, &raw, &message->u.mesg_loc.oh_addr); - } /* end else */ - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5SM_message_decode */ - - -/*------------------------------------------------------------------------- * Function: H5SM_reconstitute * * Purpose: Reconstitute a shared object header message structure from @@ -2140,7 +2061,7 @@ H5SM_get_refcount(H5F_t *f, hid_t dxpl_id, unsigned type_id, HDassert(header->index_type == H5SM_BTREE); /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, header->index_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, header->index_addr, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for SOHM index") /* Look up the message in the v2 B-tree */ @@ -2585,7 +2506,7 @@ H5SM_ih_size(H5F_t *f, hid_t dxpl_id, H5F_info_t *finfo) if(table->indexes[u].index_type == H5SM_BTREE) { if(H5F_addr_defined(table->indexes[u].index_addr)) { /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl_id, table->indexes[u].index_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl_id, table->indexes[u].index_addr, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for SOHM index") if(H5B2_size(bt2, dxpl_id, &(finfo->sohm.msgs_info.index_size)) < 0) diff --git a/src/H5SMbtree2.c b/src/H5SMbtree2.c index 2be7745..95527f9 100755 --- a/src/H5SMbtree2.c +++ b/src/H5SMbtree2.c @@ -20,6 +20,7 @@ #define H5O_PACKAGE /*suppress error about including H5Opkg */ #define H5SM_PACKAGE /*suppress error about including H5SMpkg */ + /***********/ /* Headers */ /***********/ @@ -38,23 +39,18 @@ /* Local Typedefs */ /******************/ -/* Udata struct for calls to H5SM_btree_compare_cb and H5SM_compare_iter_op*/ -typedef struct H5SM_compare_udata_t { - const H5SM_mesg_key_t *key; /* Key; compare this against stored message */ - H5O_msg_crt_idx_t idx; /* Index of the message in the OH, if applicable */ - herr_t ret; /* Return value; set this to result of memcmp */ -} H5SM_compare_udata_t; - /********************/ /* Local Prototypes */ /********************/ /* v2 B-tree callbacks */ -static herr_t H5SM_btree_compare_cb(const void *obj, size_t obj_len, void *_udata); -static herr_t H5SM_btree_store(void *native, const void *udata); -static herr_t H5SM_btree_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, +static void *H5SM_bt2_crt_context(void *udata); +static herr_t H5SM_bt2_dst_context(void *ctx); +static herr_t H5SM_bt2_store(void *native, const void *udata); +static herr_t H5SM_bt2_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, int indent, int fwidth, const void *record, const void *_udata); +static void *H5SM_bt2_crt_dbg_context(H5F_t *f, hid_t dxpl_id, haddr_t addr); /*****************************/ @@ -65,221 +61,99 @@ const H5B2_class_t H5SM_INDEX[1]={{ /* B-tree class information */ H5B2_SOHM_INDEX_ID, /* Type of B-tree */ "H5B2_SOHM_INDEX_ID", /* Name of B-tree class */ sizeof(H5SM_sohm_t), /* Size of native record */ - H5SM_btree_store, /* Record storage callback */ + H5SM_bt2_crt_context, /* Create client callback context */ + H5SM_bt2_dst_context, /* Destroy client callback context */ + H5SM_bt2_store, /* Record storage callback */ H5SM_message_compare, /* Record comparison callback */ H5SM_message_encode, /* Record encoding callback */ H5SM_message_decode, /* Record decoding callback */ - H5SM_btree_debug /* Record debugging callback */ + H5SM_bt2_debug, /* Record debugging callback */ + H5SM_bt2_crt_dbg_context, /* Create debugging context */ + H5SM_bt2_dst_context /* Destroy debugging context */ }}; + /*******************/ /* Local Variables */ /*******************/ +/* Declare a free list to manage the H5SM_bt2_ctx_t struct */ +H5FL_DEFINE_STATIC(H5SM_bt2_ctx_t); + + /*------------------------------------------------------------------------- - * Function: H5SM_btree_compare_cb - * - * Purpose: Callback for H5HF_op, used in H5SM_message_compare below. - * Determines whether the search key passed in in _UDATA is - * equal to OBJ or not. + * Function: H5SM_bt2_crt_context * - * Passes back the result in _UDATA->RET + * Purpose: Create client callback context * - * Return: Negative on error, non-negative on success + * Return: Success: non-NULL + * Failure: NULL * - * Programmer: James Laird - * Monday, January 8, 2007 + * Programmer: Quincey Koziol + * Thursday, November 26, 2009 * *------------------------------------------------------------------------- */ -static herr_t -H5SM_btree_compare_cb(const void *obj, size_t obj_len, void *_udata) +static void * +H5SM_bt2_crt_context(void *_f) { - H5SM_compare_udata_t *udata = (H5SM_compare_udata_t *)_udata; + H5F_t *f = (H5F_t *)_f; /* User data for building callback context */ + H5SM_bt2_ctx_t *ctx; /* Callback context structure */ + void *ret_value; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_btree_compare_cb) + FUNC_ENTER_NOAPI_NOINIT(H5SM_bt2_crt_context) - /* If the encoding sizes are different, it's not the same object */ - if(udata->key->encoding_size > obj_len) - udata->ret = 1; - else if(udata->key->encoding_size < obj_len) - udata->ret = -1; - else - /* Sizes are the same. Return result of memcmp */ - udata->ret = HDmemcmp(udata->key->encoding, obj, obj_len); + /* Sanity check */ + HDassert(f); - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5SM_btree_compare_cb() */ + /* Allocate callback context */ + if(NULL == (ctx = H5FL_MALLOC(H5SM_bt2_ctx_t))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate callback context") - -/*------------------------------------------------------------------------- - * Function: H5SM_compare_iter_op - * - * Purpose: OH iteration callback to compare a key against a message in - * an OH - * - * Return: 0 if this is not the message we're searching for - * 1 if this is the message we're searching for (with memcmp - * result returned in udata) - * negative on error - * - * Programmer: James Laird - * Wednesday, February 7, 2007 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5SM_compare_iter_op(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, - hbool_t UNUSED *oh_modified, void *_udata/*in,out*/) -{ - H5SM_compare_udata_t *udata = (H5SM_compare_udata_t *) _udata; - herr_t ret_value = H5_ITER_CONT; - - FUNC_ENTER_NOAPI_NOINIT(H5SM_compare_iter_op) - - /* - * Check arguments. - */ - HDassert(oh); - HDassert(mesg); - HDassert(udata && udata->key); - - /* Check the creation index for this message */ - if(sequence == udata->idx) { - size_t aligned_encoded_size = H5O_ALIGN_OH(oh, udata->key->encoding_size); - - /* Sanity check the message's length */ - HDassert(mesg->raw_size > 0); - - if(aligned_encoded_size > mesg->raw_size) - udata->ret = 1; - else if(aligned_encoded_size < mesg->raw_size) - udata->ret = -1; - else { - /* Check if the message is dirty & flush it to the object header if so */ - if(mesg->dirty) - if(H5O_msg_flush(udata->key->file, oh, mesg) < 0) - HGOTO_ERROR(H5E_SOHM, H5E_CANTENCODE, H5_ITER_ERROR, "unable to encode object header message") - - HDassert(udata->key->encoding_size <= mesg->raw_size); - udata->ret = HDmemcmp(udata->key->encoding, mesg->raw, udata->key->encoding_size); - } /* end else */ - - /* Indicate that we found the message we were looking for */ - ret_value = H5_ITER_STOP; - } /* end if */ + /* Determine the size of addresses & lengths in the file */ + ctx->sizeof_addr = H5F_SIZEOF_ADDR(f); + + /* Set return value */ + ret_value = ctx; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5SM_compare_iter_op() */ +} /* H5SM_bt2_crt_context() */ /*------------------------------------------------------------------------- - * Function: H5SM_message_compare + * Function: H5SM_bt2_dst_context * - * Purpose: Determine whether the search key rec1 represents a shared - * message that is equal to rec2 or not, and if not, whether - * rec1 is "greater than" or "less than" rec2. + * Purpose: Destroy client callback context * - * Return: 0 if rec1 == rec2 - * Negative if rec1 < rec2 - * Positive if rec1 > rec2 + * Return: Success: non-negative + * Failure: negative * - * Programmer: James Laird - * Monday, November 6, 2006 + * Programmer: Quincey Koziol + * Thursday, November 26, 2009 * *------------------------------------------------------------------------- */ -herr_t -H5SM_message_compare(const void *rec1, const void *rec2) +static herr_t +H5SM_bt2_dst_context(void *_ctx) { - const H5SM_mesg_key_t *key = (const H5SM_mesg_key_t *) rec1; - const H5SM_sohm_t *mesg = (const H5SM_sohm_t *) rec2; - herr_t ret_value = 0; - - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_message_compare) - - /* If the key has an fheap ID, we're looking for a message that's - * already in the index; if the fheap ID matches, we've found the message - * and can stop immediately. - * Likewise, if the message has an OH location that is matched by the - * message in the index, we've found the message. - */ - if(mesg->location == H5SM_IN_HEAP && key->message.location == H5SM_IN_HEAP) { - if(key->message.u.heap_loc.fheap_id == mesg->u.heap_loc.fheap_id) - HGOTO_DONE(0); - } /* end if */ - else if(mesg->location == H5SM_IN_OH && key->message.location == H5SM_IN_OH) { - if(key->message.u.mesg_loc.oh_addr == mesg->u.mesg_loc.oh_addr && - key->message.u.mesg_loc.index == mesg->u.mesg_loc.index && - key->message.msg_type_id == mesg->msg_type_id) - HGOTO_DONE(0); - } /* end if */ - - /* Compare hash values */ - if(key->message.hash > mesg->hash) - ret_value = 1; - else if(key->message.hash < mesg->hash) - ret_value = -1; - /* If the hash values match, make sure the messages are really the same */ - else { - /* Hash values match; compare the encoded message with the one in - * the index. - */ - H5SM_compare_udata_t udata; - herr_t status; - - HDassert(key->message.hash == mesg->hash); - HDassert(key->encoding_size > 0 && key->encoding); - - /* Set up user data for callback */ - udata.key = key; - - /* Compare the encoded message with either the message in the heap or - * the message in an object header. - */ - if(mesg->location == H5SM_IN_HEAP) { - /* Call heap op routine with comparison callback */ - status = H5HF_op(key->fheap, key->dxpl_id, &(mesg->u.heap_loc.fheap_id), H5SM_btree_compare_cb, &udata); - HDassert(status >= 0); - } /* end if */ - else { - H5O_loc_t oloc; /* Object owning the message */ - H5O_mesg_operator_t op; /* Message operator */ - - /* Sanity checks */ - HDassert(key->file); - HDassert(mesg->location == H5SM_IN_OH); - - /* Reset the object location */ - status = H5O_loc_reset(&oloc); - HDassert(status >= 0); - - /* Set up object location */ - oloc.file = key->file; - oloc.addr = mesg->u.mesg_loc.oh_addr; - - /* Finish setting up user data for iterator */ - udata.idx = mesg->u.mesg_loc.index; - - /* Locate the right message and compare with it */ - op.op_type = H5O_MESG_OP_LIB; - op.u.lib_op = H5SM_compare_iter_op; - status = H5O_msg_iterate(&oloc, mesg->msg_type_id, &op, &udata, key->dxpl_id); - HDassert(status >= 0); - } /* end else */ - - ret_value = udata.ret; - } /* end if */ + H5SM_bt2_ctx_t *ctx = (H5SM_bt2_ctx_t *)_ctx; /* Callback context structure */ -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5SM_message_compare */ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_bt2_dst_context) + + /* Sanity check */ + HDassert(ctx); + + /* Release callback context */ + ctx = H5FL_FREE(H5SM_bt2_ctx_t, ctx); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5SM_bt2_dst_context() */ /*------------------------------------------------------------------------- - * Function: H5SM_btree_store + * Function: H5SM_bt2_store * * Purpose: Store a H5SM_sohm_t SOHM message in the B-tree. The message * comes in UDATA as a H5SM_mesg_key_t* and is copied to @@ -294,21 +168,21 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5SM_btree_store(void *native, const void *udata) +H5SM_bt2_store(void *native, const void *udata) { const H5SM_mesg_key_t *key = (const H5SM_mesg_key_t *)udata; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_btree_store) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_bt2_store) /* Copy the source message to the B-tree */ *(H5SM_sohm_t *)native = key->message; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5SM_btree_store */ +} /* end H5SM_bt2_store */ /*------------------------------------------------------------------------- - * Function: H5SM_btree_debug + * Function: H5SM_bt2_debug * * Purpose: Print debugging information for a H5SM_sohm_t. * @@ -321,12 +195,12 @@ H5SM_btree_store(void *native, const void *udata) *------------------------------------------------------------------------- */ static herr_t -H5SM_btree_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED dxpl_id, +H5SM_bt2_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED dxpl_id, int indent, int fwidth, const void *record, const void UNUSED *_udata) { const H5SM_sohm_t *sohm = (const H5SM_sohm_t *)record; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_btree_debug) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_bt2_debug) if(sohm->location == H5SM_IN_HEAP) HDfprintf(stream, "%*s%-*s {%a, %lo, %Hx}\n", indent, "", fwidth, @@ -340,11 +214,51 @@ H5SM_btree_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED dxpl_id, } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5SM_btree_debug */ +} /* end H5SM_bt2_debug */ + + +/*------------------------------------------------------------------------- + * Function: H5SM_bt2_crt_dbg_context + * + * Purpose: Create context for debugging callback + * + * Return: Success: non-NULL + * Failure: NULL + * + * Programmer: Quincey Koziol + * Tuesday, December 1, 2009 + * + *------------------------------------------------------------------------- + */ +static void * +H5SM_bt2_crt_dbg_context(H5F_t *f, hid_t UNUSED dxpl_id, haddr_t UNUSED addr) +{ + H5SM_bt2_ctx_t *ctx; /* Callback context structure */ + void *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5SM_bt2_crt_dbg_context) + + /* Sanity check */ + HDassert(f); + HDassert(H5F_addr_defined(addr)); + + /* Allocate callback context */ + if(NULL == (ctx = H5FL_MALLOC(H5SM_bt2_ctx_t))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate callback context") + + /* Determine the size of addresses & lengths in the file */ + ctx->sizeof_addr = H5F_SIZEOF_ADDR(f); + + /* Set return value */ + ret_value = ctx; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5SM_bt2_crt_dbg_context() */ /*------------------------------------------------------------------------- - * Function: H5SM_btree_convert_to_list_op + * Function: H5SM_bt2_convert_to_list_op * * Purpose: An H5B2_remove_t callback function to convert a SOHM * B-tree index to a list. @@ -360,13 +274,13 @@ H5SM_btree_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED dxpl_id, *------------------------------------------------------------------------- */ herr_t -H5SM_btree_convert_to_list_op(const void * record, void *op_data) +H5SM_bt2_convert_to_list_op(const void * record, void *op_data) { const H5SM_sohm_t *message = (const H5SM_sohm_t *)record; const H5SM_list_t *list = (const H5SM_list_t *)op_data; size_t mesg_idx; /* Index of message to modify */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_btree_convert_to_list_op) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_bt2_convert_to_list_op) /* Sanity checks */ HDassert(record); @@ -382,5 +296,5 @@ H5SM_btree_convert_to_list_op(const void * record, void *op_data) HDmemcpy(&(list->messages[mesg_idx]), message, sizeof(H5SM_sohm_t)); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5SM_btree_convert_to_list_op() */ +} /* end H5SM_bt2_convert_to_list_op() */ diff --git a/src/H5SMcache.c b/src/H5SMcache.c index 98c7362..4b879cb 100644 --- a/src/H5SMcache.c +++ b/src/H5SMcache.c @@ -460,6 +460,7 @@ H5SM_list_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *udata1, { H5SM_list_t *list; /* The SOHM list being read in */ H5SM_index_header_t *header = (H5SM_index_header_t *) udata2; /* Index header for this list */ + H5SM_bt2_ctx_t ctx; /* Message encoding context */ size_t size; /* Size of SOHM list on disk */ H5WB_t *wb = NULL; /* Wrapped buffer for list index data */ uint8_t lst_buf[H5SM_LST_BUF_SIZE]; /* Buffer for list index */ @@ -510,8 +511,9 @@ H5SM_list_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *udata1, p += H5_SIZEOF_MAGIC; /* Read messages into the list array */ + ctx.sizeof_addr = H5F_SIZEOF_ADDR(f); for(x = 0; x < header->num_messages; x++) { - if(H5SM_message_decode(f, p, &(list->messages[x])) < 0) + if(H5SM_message_decode(p, &(list->messages[x]), &ctx) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTLOAD, NULL, "can't decode shared message") p += H5SM_SOHM_ENTRY_SIZE(f); } /* end for */ @@ -578,6 +580,7 @@ H5SM_list_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5SM_lis HDassert(list->header); if(list->cache_info.is_dirty) { + H5SM_bt2_ctx_t ctx; /* Message encoding context */ uint8_t *buf; /* Temporary buffer */ uint8_t *p; /* Pointer into raw data buffer */ size_t size; /* Header size on disk */ @@ -604,9 +607,10 @@ H5SM_list_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5SM_lis /* Write messages from the messages array to disk */ mesgs_written = 0; + ctx.sizeof_addr = H5F_SIZEOF_ADDR(f); for(x = 0; x < list->header->list_max && mesgs_written < list->header->num_messages; x++) { if(list->messages[x].location != H5SM_NO_LOC) { - if(H5SM_message_encode(f, p, &(list->messages[x])) < 0) + if(H5SM_message_encode(p, &(list->messages[x]), &ctx) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTFLUSH, FAIL, "unable to write shared message to disk") p+=H5SM_SOHM_ENTRY_SIZE(f); diff --git a/src/H5SMmessage.c b/src/H5SMmessage.c new file mode 100644 index 0000000..9a214ea --- /dev/null +++ b/src/H5SMmessage.c @@ -0,0 +1,358 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/****************/ +/* Module Setup */ +/****************/ + +#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#define H5SM_PACKAGE /*suppress error about including H5SMpkg */ + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Opkg.h" /* Object Headers */ +#include "H5SMpkg.h" /* Shared object header messages */ + + +/****************/ +/* Local Macros */ +/****************/ + + +/******************/ +/* Local Typedefs */ +/******************/ + +/* Udata struct for calls to H5SM_compare_cb and H5SM_compare_iter_op*/ +typedef struct H5SM_compare_udata_t { + const H5SM_mesg_key_t *key; /* Key; compare this against stored message */ + H5O_msg_crt_idx_t idx; /* Index of the message in the OH, if applicable */ + herr_t ret; /* Return value; set this to result of memcmp */ +} H5SM_compare_udata_t; + + +/********************/ +/* Local Prototypes */ +/********************/ +static herr_t H5SM_compare_cb(const void *obj, size_t obj_len, void *udata); +static herr_t H5SM_compare_iter_op(H5O_t *oh, H5O_mesg_t *mesg, unsigned sequence, + hbool_t *oh_modified, void *udata); + + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + + + +/*------------------------------------------------------------------------- + * Function: H5SM_compare_cb + * + * Purpose: Callback for H5HF_op, used in H5SM_message_compare below. + * Determines whether the search key passed in in _UDATA is + * equal to OBJ or not. + * + * Passes back the result in _UDATA->RET + * + * Return: Negative on error, non-negative on success + * + * Programmer: James Laird + * Monday, January 8, 2007 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5SM_compare_cb(const void *obj, size_t obj_len, void *_udata) +{ + H5SM_compare_udata_t *udata = (H5SM_compare_udata_t *)_udata; + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_compare_cb) + + /* If the encoding sizes are different, it's not the same object */ + if(udata->key->encoding_size > obj_len) + udata->ret = 1; + else if(udata->key->encoding_size < obj_len) + udata->ret = -1; + else + /* Sizes are the same. Return result of memcmp */ + udata->ret = HDmemcmp(udata->key->encoding, obj, obj_len); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5SM_compare_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5SM_compare_iter_op + * + * Purpose: OH iteration callback to compare a key against a message in + * an OH + * + * Return: 0 if this is not the message we're searching for + * 1 if this is the message we're searching for (with memcmp + * result returned in udata) + * negative on error + * + * Programmer: James Laird + * Wednesday, February 7, 2007 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5SM_compare_iter_op(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, + hbool_t UNUSED *oh_modified, void *_udata/*in,out*/) +{ + H5SM_compare_udata_t *udata = (H5SM_compare_udata_t *) _udata; + herr_t ret_value = H5_ITER_CONT; + + FUNC_ENTER_NOAPI_NOINIT(H5SM_compare_iter_op) + + /* + * Check arguments. + */ + HDassert(oh); + HDassert(mesg); + HDassert(udata && udata->key); + + /* Check the creation index for this message */ + if(sequence == udata->idx) { + size_t aligned_encoded_size = H5O_ALIGN_OH(oh, udata->key->encoding_size); + + /* Sanity check the message's length */ + HDassert(mesg->raw_size > 0); + + if(aligned_encoded_size > mesg->raw_size) + udata->ret = 1; + else if(aligned_encoded_size < mesg->raw_size) + udata->ret = -1; + else { + /* Check if the message is dirty & flush it to the object header if so */ + if(mesg->dirty) + if(H5O_msg_flush(udata->key->file, oh, mesg) < 0) + HGOTO_ERROR(H5E_SOHM, H5E_CANTENCODE, H5_ITER_ERROR, "unable to encode object header message") + + HDassert(udata->key->encoding_size <= mesg->raw_size); + udata->ret = HDmemcmp(udata->key->encoding, mesg->raw, udata->key->encoding_size); + } /* end else */ + + /* Indicate that we found the message we were looking for */ + ret_value = H5_ITER_STOP; + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5SM_compare_iter_op() */ + + +/*------------------------------------------------------------------------- + * Function: H5SM_message_compare + * + * Purpose: Determine whether the search key rec1 represents a shared + * message that is equal to rec2 or not, and if not, whether + * rec1 is "greater than" or "less than" rec2. + * + * Return: 0 if rec1 == rec2 + * Negative if rec1 < rec2 + * Positive if rec1 > rec2 + * + * Programmer: James Laird + * Monday, November 6, 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5SM_message_compare(const void *rec1, const void *rec2) +{ + const H5SM_mesg_key_t *key = (const H5SM_mesg_key_t *) rec1; + const H5SM_sohm_t *mesg = (const H5SM_sohm_t *) rec2; + herr_t ret_value = 0; + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_message_compare) + + /* If the key has an fheap ID, we're looking for a message that's + * already in the index; if the fheap ID matches, we've found the message + * and can stop immediately. + * Likewise, if the message has an OH location that is matched by the + * message in the index, we've found the message. + */ + if(mesg->location == H5SM_IN_HEAP && key->message.location == H5SM_IN_HEAP) { + if(key->message.u.heap_loc.fheap_id == mesg->u.heap_loc.fheap_id) + HGOTO_DONE(0); + } /* end if */ + else if(mesg->location == H5SM_IN_OH && key->message.location == H5SM_IN_OH) { + if(key->message.u.mesg_loc.oh_addr == mesg->u.mesg_loc.oh_addr && + key->message.u.mesg_loc.index == mesg->u.mesg_loc.index && + key->message.msg_type_id == mesg->msg_type_id) + HGOTO_DONE(0); + } /* end if */ + + /* Compare hash values */ + if(key->message.hash > mesg->hash) + ret_value = 1; + else if(key->message.hash < mesg->hash) + ret_value = -1; + /* If the hash values match, make sure the messages are really the same */ + else { + /* Hash values match; compare the encoded message with the one in + * the index. + */ + H5SM_compare_udata_t udata; + herr_t status; + + HDassert(key->message.hash == mesg->hash); + HDassert(key->encoding_size > 0 && key->encoding); + + /* Set up user data for callback */ + udata.key = key; + + /* Compare the encoded message with either the message in the heap or + * the message in an object header. + */ + if(mesg->location == H5SM_IN_HEAP) { + /* Call heap op routine with comparison callback */ + status = H5HF_op(key->fheap, key->dxpl_id, &(mesg->u.heap_loc.fheap_id), H5SM_compare_cb, &udata); + HDassert(status >= 0); + } /* end if */ + else { + H5O_loc_t oloc; /* Object owning the message */ + H5O_mesg_operator_t op; /* Message operator */ + + /* Sanity checks */ + HDassert(key->file); + HDassert(mesg->location == H5SM_IN_OH); + + /* Reset the object location */ + status = H5O_loc_reset(&oloc); + HDassert(status >= 0); + + /* Set up object location */ + oloc.file = key->file; + oloc.addr = mesg->u.mesg_loc.oh_addr; + + /* Finish setting up user data for iterator */ + udata.idx = mesg->u.mesg_loc.index; + + /* Locate the right message and compare with it */ + op.op_type = H5O_MESG_OP_LIB; + op.u.lib_op = H5SM_compare_iter_op; + status = H5O_msg_iterate(&oloc, mesg->msg_type_id, &op, &udata, key->dxpl_id); + HDassert(status >= 0); + } /* end else */ + + ret_value = udata.ret; + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5SM_message_compare */ + + +/*------------------------------------------------------------------------- + * Function: H5SM_message_encode + * + * Purpose: Serialize a H5SM_sohm_t struct into a buffer RAW. + * + * Return: Non-negative on success + * Negative on failure + * + * Programmer: James Laird + * Monday, November 6, 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5SM_message_encode(uint8_t *raw, const void *_nrecord, void *_ctx) +{ + H5SM_bt2_ctx_t *ctx = (H5SM_bt2_ctx_t *)_ctx; /* Callback context structure */ + const H5SM_sohm_t *message = (const H5SM_sohm_t *)_nrecord; + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_message_encode) + + /* Sanity check */ + HDassert(ctx); + + *raw++ = message->location; + UINT32ENCODE(raw, message->hash); + + if(message->location == H5SM_IN_HEAP) { + UINT32ENCODE(raw, message->u.heap_loc.ref_count); + UINT64ENCODE(raw, message->u.heap_loc.fheap_id); + } /* end if */ + else { + HDassert(message->location == H5SM_IN_OH); + + *raw++ = 0; /* reserved (possible flags byte) */ + *raw++ = (uint8_t)message->msg_type_id; + UINT16ENCODE(raw, message->u.mesg_loc.index); + H5F_addr_encode_len(ctx->sizeof_addr, &raw, message->u.mesg_loc.oh_addr); + } /* end else */ + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5SM_message_encode */ + + +/*------------------------------------------------------------------------- + * Function: H5SM_message_decode + * + * Purpose: Read an encoded SOHM message from RAW into an H5SM_sohm_t struct. + * + * Return: Non-negative on success + * Negative on failure + * + * Programmer: James Laird + * Monday, November 6, 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5SM_message_decode(const uint8_t *raw, void *_nrecord, void *_ctx) +{ + H5SM_bt2_ctx_t *ctx = (H5SM_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5SM_sohm_t *message = (H5SM_sohm_t *)_nrecord; + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_message_decode) + + message->location = (H5SM_storage_loc_t)*raw++; + UINT32DECODE(raw, message->hash); + + if(message->location == H5SM_IN_HEAP) { + UINT32DECODE(raw, message->u.heap_loc.ref_count); + UINT64DECODE(raw, message->u.heap_loc.fheap_id); + } /* end if */ + else { + HDassert(message->location == H5SM_IN_OH); + + raw++; /* reserved */ + message->msg_type_id = *raw++; + UINT16DECODE(raw, message->u.mesg_loc.index); + H5F_addr_decode_len(ctx->sizeof_addr, &raw, &message->u.mesg_loc.oh_addr); + } /* end else */ + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5SM_message_decode */ + diff --git a/src/H5SMpkg.h b/src/H5SMpkg.h index 093fb04..64f0ccb 100755 --- a/src/H5SMpkg.h +++ b/src/H5SMpkg.h @@ -213,6 +213,11 @@ typedef struct { hid_t dxpl_id; } H5SM_incr_ref_opdata; +/* v2 B-tree client callback context */ +typedef struct H5SM_bt2_ctx_t { + uint8_t sizeof_addr; /* Size of file addresses */ +} H5SM_bt2_ctx_t; + /****************************/ /* Package Variables */ @@ -236,20 +241,12 @@ H5_DLLVAR const H5B2_class_t H5SM_INDEX[1]; H5_DLL ssize_t H5SM_get_index(const H5SM_master_table_t *table, unsigned type_id); /* Encode and decode routines, used for B-tree and cache encoding/decoding */ -H5_DLL herr_t H5SM_message_encode(const H5F_t *f, uint8_t *raw, - const void *native); -H5_DLL herr_t H5SM_message_decode(const H5F_t *f, const uint8_t *raw, - void *native); - -/* Callbacks to give to B-tree traversals */ -/* H5SM_message_compare is in H5SMbtree2.c, but is also used by list code - * in H5SM.c. - */ -H5_DLL herr_t H5SM_message_compare(const void *rec1, - const void *rec2); +H5_DLL herr_t H5SM_message_compare(const void *rec1, const void *rec2); +H5_DLL herr_t H5SM_message_encode(uint8_t *raw, const void *native, void *ctx); +H5_DLL herr_t H5SM_message_decode(const uint8_t *raw, void *native, void *ctx); /* H5B2_remove_t callback to add messages to a list index */ -H5_DLL herr_t H5SM_btree_convert_to_list_op(const void * record, void *op_data); +H5_DLL herr_t H5SM_bt2_convert_to_list_op(const void * record, void *op_data); /* Fractal heap 'op' callback to compute hash value for message "in place" */ H5_DLL herr_t H5SM_get_hash_fh_cb(const void *obj, size_t obj_len, void *_udata); diff --git a/src/Makefile.am b/src/Makefile.am index daf85c8..aa96851 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -87,8 +87,10 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5RC.c \ H5RS.c \ H5S.c H5Sall.c H5Sdbg.c H5Shyper.c H5Smpio.c H5Snone.c H5Spoint.c \ - H5Sselect.c H5Stest.c H5SL.c H5SM.c H5SMbtree2.c \ - H5SMcache.c H5SMtest.c H5ST.c \ + H5Sselect.c H5Stest.c \ + H5SL.c \ + H5SM.c H5SMbtree2.c H5SMcache.c H5SMmessage.c H5SMtest.c \ + H5ST.c \ H5T.c H5Tarray.c H5Tbit.c H5Tcommit.c H5Tcompound.c H5Tconv.c \ H5Tcset.c H5Tdbg.c H5Tdeprec.c H5Tenum.c H5Tfields.c \ H5Tfixed.c \ diff --git a/src/Makefile.in b/src/Makefile.in index 27ec520..78f5961 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -133,7 +133,7 @@ am_libhdf5_la_OBJECTS = H5.lo H5checksum.lo H5dbg.lo H5system.lo \ H5Ptest.lo H5R.lo H5Rdeprec.lo H5RC.lo H5RS.lo H5S.lo \ H5Sall.lo H5Sdbg.lo H5Shyper.lo H5Smpio.lo H5Snone.lo \ H5Spoint.lo H5Sselect.lo H5Stest.lo H5SL.lo H5SM.lo \ - H5SMbtree2.lo H5SMcache.lo H5SMtest.lo H5ST.lo H5T.lo \ + H5SMbtree2.lo H5SMcache.lo H5SMmessage.lo H5SMtest.lo H5ST.lo H5T.lo \ H5Tarray.lo H5Tbit.lo H5Tcommit.lo H5Tcompound.lo H5Tconv.lo \ H5Tcset.lo H5Tdbg.lo H5Tdeprec.lo H5Tenum.lo H5Tfields.lo \ H5Tfixed.lo H5Tfloat.lo H5Tinit.lo H5Tnative.lo H5Toffset.lo \ @@ -498,7 +498,7 @@ libhdf5_la_SOURCES = H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5RS.c \ H5S.c H5Sall.c H5Sdbg.c H5Shyper.c H5Smpio.c H5Snone.c H5Spoint.c \ H5Sselect.c H5Stest.c H5SL.c H5SM.c H5SMbtree2.c \ - H5SMcache.c H5SMtest.c H5ST.c \ + H5SMcache.c H5SMmessage.c H5SMtest.c H5ST.c \ H5T.c H5Tarray.c H5Tbit.c H5Tcommit.c H5Tcompound.c H5Tconv.c \ H5Tcset.c H5Tdbg.c H5Tdeprec.c H5Tenum.c H5Tfields.c \ H5Tfixed.c \ @@ -828,6 +828,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5SM.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5SMbtree2.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5SMcache.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5SMmessage.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5SMtest.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5ST.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Sall.Plo@am__quote@ diff --git a/test/btree2.c b/test/btree2.c index 6006dc8..fb24433 100644 --- a/test/btree2.c +++ b/test/btree2.c @@ -133,7 +133,7 @@ create_btree(H5F_t *f, hid_t dxpl, const H5B2_create_t *cparam, H5B2_t **bt2, haddr_t *bt2_addr) { /* Create the v2 B-tree & get its address */ - if(NULL == (*bt2 = H5B2_create(f, dxpl, cparam))) + if(NULL == (*bt2 = H5B2_create(f, dxpl, cparam, f))) FAIL_STACK_ERROR if(H5B2_get_addr(*bt2, bt2_addr/*out*/) < 0) FAIL_STACK_ERROR @@ -172,7 +172,7 @@ reopen_btree(H5F_t *f, hid_t dxpl, H5B2_t **bt2, haddr_t bt2_addr, FAIL_STACK_ERROR /* Re-open v2 B-tree */ - if(NULL == (*bt2 = H5B2_open(f, dxpl, bt2_addr))) + if(NULL == (*bt2 = H5B2_open(f, dxpl, bt2_addr, f))) FAIL_STACK_ERROR } /* end if */ @@ -2839,7 +2839,7 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); FAIL_STACK_ERROR /* Re-open v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f))) FAIL_STACK_ERROR /* Check up on B-tree after re-open */ @@ -6526,7 +6526,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); } /* end for */ /* Re-open v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f))) FAIL_STACK_ERROR /* Remove all records */ @@ -6606,7 +6606,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); FAIL_STACK_ERROR /* Re-open v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f))) FAIL_STACK_ERROR /* Remove all records */ @@ -6690,7 +6690,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); FAIL_STACK_ERROR /* Re-open v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f))) FAIL_STACK_ERROR /* Remove all records */ @@ -6771,7 +6771,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); FAIL_STACK_ERROR /* Re-open v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr))) + if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f))) FAIL_STACK_ERROR /* Remove all records */ @@ -7128,7 +7128,7 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) /* * Delete v2 B-tree */ - if(H5B2_delete(f, dxpl, bt2_addr, NULL, NULL) < 0) + if(H5B2_delete(f, dxpl, bt2_addr, f, NULL, NULL) < 0) FAIL_STACK_ERROR /* Close the file */ @@ -7181,7 +7181,7 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) /* * Delete v2 B-tree */ - if(H5B2_delete(f, H5P_DATASET_XFER_DEFAULT, bt2_addr, NULL, NULL) < 0) + if(H5B2_delete(f, H5P_DATASET_XFER_DEFAULT, bt2_addr, f, NULL, NULL) < 0) FAIL_STACK_ERROR /* Close file */ @@ -7234,7 +7234,7 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) /* * Delete v2 B-tree */ - if(H5B2_delete(f, dxpl, bt2_addr, NULL, NULL) < 0) + if(H5B2_delete(f, dxpl, bt2_addr, f, NULL, NULL) < 0) FAIL_STACK_ERROR /* Close file */ @@ -7287,7 +7287,7 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) /* * Delete v2 B-tree */ - if(H5B2_delete(f, dxpl, bt2_addr, NULL, NULL) < 0) + if(H5B2_delete(f, dxpl, bt2_addr, f, NULL, NULL) < 0) FAIL_STACK_ERROR /* Close file */ diff --git a/tools/misc/h5debug.c b/tools/misc/h5debug.c index db867ec..1988894 100644 --- a/tools/misc/h5debug.c +++ b/tools/misc/h5debug.c @@ -82,19 +82,19 @@ get_H5B2_class(const uint8_t *sig) break; case H5B2_FHEAP_HUGE_INDIR_ID: - cls = H5HF_BT2_INDIR; + cls = H5HF_HUGE_BT2_INDIR; break; case H5B2_FHEAP_HUGE_FILT_INDIR_ID: - cls = H5HF_BT2_FILT_INDIR; + cls = H5HF_HUGE_BT2_FILT_INDIR; break; case H5B2_FHEAP_HUGE_DIR_ID: - cls = H5HF_BT2_DIR; + cls = H5HF_HUGE_BT2_DIR; break; case H5B2_FHEAP_HUGE_FILT_DIR_ID: - cls = H5HF_BT2_FILT_DIR; + cls = H5HF_HUGE_BT2_FILT_DIR; break; case H5B2_GRP_DENSE_NAME_ID: |