diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2018-03-15 21:54:30 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2018-03-15 21:54:30 (GMT) |
commit | 4a17aff4085ad6ee265b95730aca3f493056dec8 (patch) | |
tree | 8bfb665c6d95a2e3520fa1bb0ff54d95aff3923f /src/H5HFhdr.c | |
parent | 853ae26333592faf69cd8c454ef92ffea8549df5 (diff) | |
download | hdf5-4a17aff4085ad6ee265b95730aca3f493056dec8.zip hdf5-4a17aff4085ad6ee265b95730aca3f493056dec8.tar.gz hdf5-4a17aff4085ad6ee265b95730aca3f493056dec8.tar.bz2 |
Add API context interface and use it throughout the library.
Diffstat (limited to 'src/H5HFhdr.c')
-rw-r--r-- | src/H5HFhdr.c | 109 |
1 files changed, 56 insertions, 53 deletions
diff --git a/src/H5HFhdr.c b/src/H5HFhdr.c index 2f01ce6..9394fc0 100644 --- a/src/H5HFhdr.c +++ b/src/H5HFhdr.c @@ -337,7 +337,7 @@ done: *------------------------------------------------------------------------- */ haddr_t -H5HF_hdr_create(H5F_t *f, hid_t dxpl_id, const H5HF_create_t *cparam) +H5HF_hdr_create(H5F_t *f, const H5HF_create_t *cparam) { H5HF_hdr_t *hdr = NULL; /* The new fractal heap header information */ size_t dblock_overhead; /* Direct block's overhead */ @@ -495,11 +495,11 @@ H5HF_hdr_create(H5F_t *f, hid_t dxpl_id, const H5HF_create_t *cparam) HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "max. direct block size not large enough to hold all managed blocks") /* Allocate space for the header on disk */ - if(HADDR_UNDEF == (hdr->heap_addr = H5MF_alloc(f, H5FD_MEM_FHEAP_HDR, dxpl_id, (hsize_t)hdr->heap_size))) + if(HADDR_UNDEF == (hdr->heap_addr = H5MF_alloc(f, H5FD_MEM_FHEAP_HDR, (hsize_t)hdr->heap_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "file allocation failed for fractal heap header") /* Cache the new fractal heap header */ - if(H5AC_insert_entry(f, dxpl_id, H5AC_FHEAP_HDR, hdr->heap_addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if(H5AC_insert_entry(f, H5AC_FHEAP_HDR, hdr->heap_addr, hdr, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, HADDR_UNDEF, "can't add fractal heap header to cache") /* Set address of heap header to return */ @@ -515,7 +515,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5HF_hdr_protect + * Function: H5HF__hdr_protect * * Purpose: Convenience wrapper around H5AC_protect on an indirect block * @@ -528,13 +528,13 @@ done: *------------------------------------------------------------------------- */ H5HF_hdr_t * -H5HF_hdr_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr, unsigned flags) +H5HF__hdr_protect(H5F_t *f, haddr_t addr, unsigned flags) { H5HF_hdr_cache_ud_t cache_udata; /* User-data for callback */ H5HF_hdr_t *hdr; /* Fractal heap header */ H5HF_hdr_t *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); @@ -545,10 +545,9 @@ H5HF_hdr_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr, unsigned flags) /* Set up userdata for protect call */ cache_udata.f = f; - cache_udata.dxpl_id = dxpl_id; /* Lock the heap header into memory */ - if(NULL == (hdr = (H5HF_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_FHEAP_HDR, addr, &cache_udata, flags))) + if(NULL == (hdr = (H5HF_hdr_t *)H5AC_protect(f, H5AC_FHEAP_HDR, addr, &cache_udata, flags))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to protect fractal heap header") /* Set the header's address */ @@ -562,7 +561,7 @@ H5HF_hdr_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr, unsigned flags) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_hdr_protect() */ +} /* end H5HF__hdr_protect() */ /*------------------------------------------------------------------------- @@ -921,7 +920,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5HF_hdr_skip_blocks + * Function: H5HF__hdr_skip_blocks * * Purpose: Add skipped direct blocks to free space for heap * @@ -934,14 +933,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HF_hdr_skip_blocks(H5HF_hdr_t *hdr, hid_t dxpl_id, H5HF_indirect_t *iblock, +H5HF__hdr_skip_blocks(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, unsigned start_entry, unsigned nentries) { unsigned row, col; /* Row & column of entry */ hsize_t sect_size; /* Size of section in heap space */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -961,16 +960,16 @@ H5HF_hdr_skip_blocks(H5HF_hdr_t *hdr, hid_t dxpl_id, H5HF_indirect_t *iblock, HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't increase allocated heap size") /* Add 'indirect' section for blocks skipped in this row */ - if(H5HF_sect_indirect_add(hdr, dxpl_id, iblock, start_entry, nentries) < 0) + if(H5HF__sect_indirect_add(hdr, iblock, start_entry, nentries) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't create indirect section for indirect block's free space") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_hdr_skip_blocks() */ +} /* end H5HF__hdr_skip_blocks() */ /*------------------------------------------------------------------------- - * Function: H5HF_hdr_update_iter + * Function: H5HF__hdr_update_iter * * Purpose: Update state of heap to account for current iterator * position. @@ -986,11 +985,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HF_hdr_update_iter(H5HF_hdr_t *hdr, hid_t dxpl_id, size_t min_dblock_size) +H5HF__hdr_update_iter(H5HF_hdr_t *hdr, size_t min_dblock_size) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -1000,7 +999,7 @@ H5HF_hdr_update_iter(H5HF_hdr_t *hdr, hid_t dxpl_id, size_t min_dblock_size) /* Check for creating first indirect block */ if(hdr->man_dtable.curr_root_rows == 0) { - if(H5HF_man_iblock_root_create(hdr, dxpl_id, min_dblock_size) < 0) + if(H5HF__man_iblock_root_create(hdr, min_dblock_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTEXTEND, FAIL, "unable to create root indirect block") } /* end if */ else { @@ -1016,7 +1015,7 @@ H5HF_hdr_update_iter(H5HF_hdr_t *hdr, hid_t dxpl_id, size_t min_dblock_size) /* Initialize block iterator, if necessary */ if(!H5HF_man_iter_ready(&hdr->next_block)) { /* Start iterator with previous offset of iterator */ - if(H5HF_man_iter_start_offset(hdr, dxpl_id, &hdr->next_block, hdr->man_iter_off) < 0) + if(H5HF__man_iter_start_offset(hdr, &hdr->next_block, hdr->man_iter_off) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "unable to set block iterator location") } /* end if */ @@ -1037,7 +1036,7 @@ H5HF_hdr_update_iter(H5HF_hdr_t *hdr, hid_t dxpl_id, size_t min_dblock_size) skip_entries = min_entry - next_entry; /* Add skipped direct blocks to heap's free space */ - if(H5HF_hdr_skip_blocks(hdr, dxpl_id, iblock, next_entry, skip_entries) < 0) + if(H5HF__hdr_skip_blocks(hdr, iblock, next_entry, skip_entries) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't add skipped blocks to heap's free space") /* Get information about new iterator location */ @@ -1054,7 +1053,7 @@ H5HF_hdr_update_iter(H5HF_hdr_t *hdr, hid_t dxpl_id, size_t min_dblock_size) while(next_row >= iblock->nrows) { /* Check for needing to expand root indirect block */ if(iblock->parent == NULL) { - if(H5HF_man_iblock_root_double(hdr, dxpl_id, min_dblock_size) < 0) + if(H5HF__man_iblock_root_double(hdr, min_dblock_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTEXTEND, FAIL, "unable to double root indirect block") } /* end if */ else { @@ -1099,7 +1098,7 @@ H5HF_hdr_update_iter(H5HF_hdr_t *hdr, hid_t dxpl_id, size_t min_dblock_size) child_entry = iblock->nrows * hdr->man_dtable.cparam.width; /* Add skipped indirect blocks to heap's free space */ - if(H5HF_hdr_skip_blocks(hdr, dxpl_id, iblock, next_entry, (child_entry - next_entry)) < 0) + if(H5HF__hdr_skip_blocks(hdr, iblock, next_entry, (child_entry - next_entry)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't add skipped blocks to heap's free space") } /* end if */ else { @@ -1108,11 +1107,11 @@ H5HF_hdr_update_iter(H5HF_hdr_t *hdr, hid_t dxpl_id, size_t min_dblock_size) haddr_t new_iblock_addr; /* New indirect block's address */ /* Allocate new indirect block */ - if(H5HF_man_iblock_create(hdr, dxpl_id, iblock, next_entry, child_nrows, child_nrows, &new_iblock_addr) < 0) + if(H5HF__man_iblock_create(hdr, iblock, next_entry, child_nrows, child_nrows, &new_iblock_addr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't allocate fractal heap indirect block") /* Lock new indirect block */ - if(NULL == (new_iblock = H5HF_man_iblock_protect(hdr, dxpl_id, new_iblock_addr, child_nrows, iblock, next_entry, FALSE, H5AC__NO_FLAGS_SET, &did_protect))) + if(NULL == (new_iblock = H5HF__man_iblock_protect(hdr, new_iblock_addr, child_nrows, iblock, next_entry, FALSE, H5AC__NO_FLAGS_SET, &did_protect))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap indirect block") /* Move iterator down one level (pins indirect block) */ @@ -1127,12 +1126,12 @@ H5HF_hdr_update_iter(H5HF_hdr_t *hdr, hid_t dxpl_id, size_t min_dblock_size) new_entry = hdr->man_dtable.cparam.width * min_dblock_row; /* Add skipped blocks to heap's free space */ - if(H5HF_hdr_skip_blocks(hdr, dxpl_id, new_iblock, 0, new_entry) < 0) + if(H5HF__hdr_skip_blocks(hdr, new_iblock, 0, new_entry) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't add skipped blocks to heap's free space") } /* end if */ /* Unprotect child indirect block */ - if(H5HF_man_iblock_unprotect(new_iblock, dxpl_id, H5AC__NO_FLAGS_SET, did_protect) < 0) + if(H5HF__man_iblock_unprotect(new_iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") } /* end else */ @@ -1148,7 +1147,7 @@ H5HF_hdr_update_iter(H5HF_hdr_t *hdr, hid_t dxpl_id, size_t min_dblock_size) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_hdr_update_iter() */ +} /* end H5HF__hdr_update_iter() */ /*------------------------------------------------------------------------- @@ -1191,7 +1190,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5HF_hdr_reverse_iter + * Function: H5HF__hdr_reverse_iter * * Purpose: Walk "next block" iterator backwards until the correct * location to allocate next block from is found @@ -1205,7 +1204,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HF_hdr_reverse_iter(H5HF_hdr_t *hdr, hid_t dxpl_id, haddr_t dblock_addr) +H5HF__hdr_reverse_iter(H5HF_hdr_t *hdr, haddr_t dblock_addr) { H5HF_indirect_t *iblock; /* Indirect block where iterator is located */ unsigned curr_entry; /* Current entry for iterator */ @@ -1213,7 +1212,7 @@ H5HF_hdr_reverse_iter(H5HF_hdr_t *hdr, hid_t dxpl_id, haddr_t dblock_addr) hbool_t walked_up; /* Loop flag */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -1223,7 +1222,7 @@ H5HF_hdr_reverse_iter(H5HF_hdr_t *hdr, hid_t dxpl_id, haddr_t dblock_addr) /* Initialize block iterator, if necessary */ if(!H5HF_man_iter_ready(&hdr->next_block)) /* Start iterator with previous offset of iterator */ - if(H5HF_man_iter_start_offset(hdr, dxpl_id, &hdr->next_block, hdr->man_iter_off) < 0) + if(H5HF__man_iter_start_offset(hdr, &hdr->next_block, hdr->man_iter_off) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "unable to set block iterator location") /* Walk backwards through heap, looking for direct block to place iterator after */ @@ -1306,7 +1305,7 @@ H5HF_hdr_reverse_iter(H5HF_hdr_t *hdr, hid_t dxpl_id, haddr_t dblock_addr) child_nrows = H5HF_dtable_size_to_rows(&hdr->man_dtable, hdr->man_dtable.row_block_size[row]); /* Lock child indirect block */ - if(NULL == (child_iblock = H5HF_man_iblock_protect(hdr, dxpl_id, iblock->ents[curr_entry].addr, child_nrows, iblock, curr_entry, FALSE, H5AC__NO_FLAGS_SET, &did_protect))) + if(NULL == (child_iblock = H5HF__man_iblock_protect(hdr, iblock->ents[curr_entry].addr, child_nrows, iblock, curr_entry, FALSE, H5AC__NO_FLAGS_SET, &did_protect))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap indirect block") /* Set the current location of the iterator */ @@ -1322,7 +1321,7 @@ H5HF_hdr_reverse_iter(H5HF_hdr_t *hdr, hid_t dxpl_id, haddr_t dblock_addr) curr_entry = (child_iblock->nrows * hdr->man_dtable.cparam.width) - 1; /* Unprotect child indirect block */ - if(H5HF_man_iblock_unprotect(child_iblock, dxpl_id, H5AC__NO_FLAGS_SET, did_protect) < 0) + if(H5HF__man_iblock_unprotect(child_iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") /* Note that we walked down */ @@ -1333,11 +1332,11 @@ H5HF_hdr_reverse_iter(H5HF_hdr_t *hdr, hid_t dxpl_id, haddr_t dblock_addr) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_hdr_reverse_iter() */ +} /* end H5HF__hdr_reverse_iter() */ /*------------------------------------------------------------------------- - * Function: H5HF_hdr_empty + * Function: H5HF__hdr_empty * * Purpose: Reset heap header to 'empty heap' state * @@ -1350,11 +1349,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HF_hdr_empty(H5HF_hdr_t *hdr) +H5HF__hdr_empty(H5HF_hdr_t *hdr) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -1369,6 +1368,10 @@ H5HF_hdr_empty(H5HF_hdr_t *hdr) hdr->man_size = 0; hdr->man_alloc_size = 0; + /* Reset root pointer information */ + hdr->man_dtable.curr_root_rows = 0; + hdr->man_dtable.table_addr = HADDR_UNDEF; + /* Reset the 'next block' iterator location */ hdr->man_iter_off = 0; @@ -1381,7 +1384,7 @@ H5HF_hdr_empty(H5HF_hdr_t *hdr) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_hdr_empty() */ +} /* end H5HF__hdr_empty() */ /*------------------------------------------------------------------------- @@ -1427,7 +1430,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5HF_hdr_delete + * Function: H5HF__hdr_delete * * Purpose: Delete a fractal heap, starting with the header * @@ -1440,12 +1443,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HF_hdr_delete(H5HF_hdr_t *hdr, hid_t dxpl_id) +H5HF__hdr_delete(H5HF_hdr_t *hdr) { unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting heap header */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -1471,35 +1474,35 @@ H5HF_hdr_delete(H5HF_hdr_t *hdr, hid_t dxpl_id) /* (must occur before attempting to delete the heap, so indirect blocks * will get unpinned) */ - if(H5F_addr_defined(hdr->fs_addr)) { + if(H5F_addr_defined(hdr->fs_addr)) /* Delete free space manager for heap */ - if(H5HF_space_delete(hdr, dxpl_id) < 0) + if(H5HF__space_delete(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to release fractal heap free space manager") - } /* end if */ /* Check for root direct/indirect block */ if(H5F_addr_defined(hdr->man_dtable.table_addr)) { if(hdr->man_dtable.curr_root_rows == 0) { - hsize_t dblock_size; /* Size of direct block */ + hsize_t dblock_size; /* Size of direct block on disk */ /* Check for I/O filters on this heap */ if(hdr->filter_len > 0) { - dblock_size = (hsize_t)hdr->pline_root_direct_size; + /* Set the dblock's size */ + dblock_size = hdr->pline_root_direct_size; /* Reset the header's pipeline information */ hdr->pline_root_direct_size = 0; hdr->pline_root_direct_filter_mask = 0; - } /* end else */ + } /* end if */ else - dblock_size = (hsize_t)hdr->man_dtable.cparam.start_block_size; + dblock_size = hdr->man_dtable.cparam.start_block_size; /* Delete root direct block */ - if(H5HF_man_dblock_delete(hdr->f, dxpl_id, hdr->man_dtable.table_addr, dblock_size) < 0) + if(H5HF__man_dblock_delete(hdr->f, hdr->man_dtable.table_addr, dblock_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to release fractal heap root direct block") } /* end if */ else { /* Delete root indirect block */ - if(H5HF_man_iblock_delete(hdr, dxpl_id, hdr->man_dtable.table_addr, hdr->man_dtable.curr_root_rows, NULL, 0) < 0) + if(H5HF__man_iblock_delete(hdr, hdr->man_dtable.table_addr, hdr->man_dtable.curr_root_rows, NULL, 0) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to release fractal heap root indirect block") } /* end else */ } /* end if */ @@ -1507,7 +1510,7 @@ H5HF_hdr_delete(H5HF_hdr_t *hdr, hid_t dxpl_id) /* Check for 'huge' objects in heap */ if(H5F_addr_defined(hdr->huge_bt2_addr)) { /* Delete huge objects in heap and their tracker */ - if(H5HF_huge_delete(hdr, dxpl_id) < 0) + if(H5HF__huge_delete(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to release fractal heap 'huge' objects and tracker") } /* end if */ @@ -1516,9 +1519,9 @@ H5HF_hdr_delete(H5HF_hdr_t *hdr, hid_t dxpl_id) done: /* Unprotect the header with appropriate flags */ - if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_FHEAP_HDR, hdr->heap_addr, hdr, cache_flags) < 0) + if(H5AC_unprotect(hdr->f, H5AC_FHEAP_HDR, hdr->heap_addr, hdr, cache_flags) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap header") FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_hdr_delete() */ +} /* end H5HF__hdr_delete() */ |