diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5HF.c | 5 | ||||
-rw-r--r-- | src/H5HFcache.c | 6 | ||||
-rw-r--r-- | src/H5HFhdr.c | 116 | ||||
-rw-r--r-- | src/H5HFhuge.c | 3 | ||||
-rw-r--r-- | src/H5HFpkg.h | 14 | ||||
-rw-r--r-- | src/H5HFprivate.h | 4 |
6 files changed, 126 insertions, 22 deletions
@@ -112,12 +112,11 @@ H5HF_create(H5F_t *f, hid_t dxpl_id, const H5HF_create_t *cparam) HDassert(f); HDassert(cparam); - /* Initialize shared fractal heap header */ - /* (This routine is only called for newly created heaps) */ + /* Create shared fractal heap header */ if(HADDR_UNDEF == (hdr_addr = H5HF_hdr_create(f, dxpl_id, cparam))) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, NULL, "can't create fractal heap header") - /* Create fractal heap wrapper */ + /* Allocate fractal heap wrapper */ if(NULL == (fh = H5FL_MALLOC(H5HF_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fractal heap info") diff --git a/src/H5HFcache.c b/src/H5HFcache.c index 4915533..e174260 100644 --- a/src/H5HFcache.c +++ b/src/H5HFcache.c @@ -309,6 +309,9 @@ HDfprintf(stderr, "%s: Load heap header, addr = %a\n", FUNC, addr); if(metadata_chksum != 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "incorrect metadata checksum for fractal heap header") + /* Heap ID length */ + UINT16DECODE(p, hdr->id_len); + /* Heap status flags */ /* (bit 0: "huge" object IDs have wrapped) */ heap_flags = *p++; @@ -419,6 +422,9 @@ HDfprintf(stderr, "%s: Flushing heap header, addr = %a, destroy = %u\n", FUNC, a HDmemset(p, 0, (size_t)4); p += 4; + /* Heap ID length */ + UINT16ENCODE(p, hdr->id_len); + /* Heap status flags */ /* (bit 0: "huge" object IDs have wrapped) */ heap_flags = 0; diff --git a/src/H5HFhdr.c b/src/H5HFhdr.c index 7d36291..a0af4b1 100644 --- a/src/H5HFhdr.c +++ b/src/H5HFhdr.c @@ -193,25 +193,24 @@ H5HF_hdr_compute_free_space(H5HF_hdr_t *hdr, unsigned iblock_row) /*------------------------------------------------------------------------- - * Function: H5HF_hdr_finish_init + * Function: H5HF_hdr_finish_init_phase1 * - * Purpose: Finish initializing info in shared heap header + * Purpose: First phase to finish initializing info in shared heap header * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Mar 21 2006 + * koziol@hdfgroup.org + * Aug 12 2006 * *------------------------------------------------------------------------- */ herr_t -H5HF_hdr_finish_init(H5HF_hdr_t *hdr) +H5HF_hdr_finish_init_phase1(H5HF_hdr_t *hdr) { - unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5HF_hdr_finish_init) + FUNC_ENTER_NOAPI_NOINIT(H5HF_hdr_finish_init_phase1) /* * Check arguments. @@ -226,7 +225,37 @@ H5HF_hdr_finish_init(H5HF_hdr_t *hdr) /* Set the size of heap IDs */ hdr->heap_len_size = MIN(hdr->man_dtable.max_dir_blk_off_size, ((H5V_log2_gen((hsize_t)hdr->max_man_size) + 7) / 8)); - hdr->id_len = H5HF_ID_SIZE(hdr); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HF_hdr_finish_init_phase1() */ + + +/*------------------------------------------------------------------------- + * Function: H5HF_hdr_finish_init_pahse2 + * + * Purpose: Second phase to finish initializing info in shared heap header + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Aug 12 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5HF_hdr_finish_init_phase2(H5HF_hdr_t *hdr) +{ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5HF_hdr_finish_init_phase2) + + /* + * Check arguments. + */ + HDassert(hdr); /* Set the free space in direct blocks */ for(u = 0; u < hdr->man_dtable.max_root_rows; u++) { @@ -256,6 +285,44 @@ HDfprintf(stderr, "%s: row_max_dblock_free[%Zu] = %Zu\n", FUNC, u, hdr->man_dtab done: FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HF_hdr_finish_init_phase2() */ + + +/*------------------------------------------------------------------------- + * Function: H5HF_hdr_finish_init + * + * Purpose: Finish initializing info in shared heap header + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Mar 21 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5HF_hdr_finish_init(H5HF_hdr_t *hdr) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5HF_hdr_finish_init) + + /* + * Check arguments. + */ + HDassert(hdr); + + /* First phase of header final initialization */ + if(H5HF_hdr_finish_init_phase1(hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't finish phase #1 of header final initialization") + + /* Second phase of header final initialization */ + if(H5HF_hdr_finish_init_phase2(hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't finish phase #2 of header final initialization") + +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_hdr_finish_init() */ @@ -342,9 +409,36 @@ H5HF_hdr_create(H5F_t *f, hid_t dxpl_id, const H5HF_create_t *cparam) /* Note that the shared info is dirty (it's not written to the file yet) */ hdr->dirty = TRUE; - /* Finish fractal heap header initialization */ - if(H5HF_hdr_finish_init(hdr) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "can't create ref-count wrapper for shared fractal heap header") + /* First phase of header final initialization */ + if(H5HF_hdr_finish_init_phase1(hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, "can't finish phase #1 of header final initialization") + + /* Set the length of IDs in the heap */ + /* (This code is not in the "finish init phase" routines because those + * routines are also called from the cache 'load' callback, and the ID + * length is already set in that case (its stored in the header on disk)) + */ + switch(cparam->id_len) { + case 0: /* Set the length of heap IDs to just enough to hold the offset & length of 'normal' objects in the heap */ + hdr->id_len = 1 + hdr->heap_off_size + hdr->heap_len_size; + break; + + case 1: /* Set the length of heap IDs to just enough to hold the file offset & length of 'huge' objects in the heap */ + hdr->id_len = 1 + hdr->sizeof_size + hdr->sizeof_addr; + break; + + default: /* Use the requested size for the heap ID */ +/* XXX: Limit heap ID length to 4096 + 1, due to # of bits required to store + * length of 'tiny' objects (12 bits) + */ +HDfprintf(stderr, "%s: Varying size of heap IDs not supported yet!\n", FUNC); +HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, HADDR_UNDEF, "varying size of heap IDs not supported yet") + break; + } /* end switch */ + + /* Second phase of header final initialization */ + if(H5HF_hdr_finish_init_phase2(hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, "can't finish phase #2 of header final initialization") #ifdef QAK HDfprintf(stderr, "%s: hdr->id_len = %Zu\n", FUNC, hdr->id_len); diff --git a/src/H5HFhuge.c b/src/H5HFhuge.c index ca256e6..7a47dba 100644 --- a/src/H5HFhuge.c +++ b/src/H5HFhuge.c @@ -158,6 +158,9 @@ H5HF_huge_init(H5HF_hdr_t *hdr) /* Check if we can completely hold the 'huge' object's offset & length in * the file in the heap ID (which will speed up accessing it) */ +#ifdef QAK +HDfprintf(stderr, "%s: hdr->id_len = %u\n", "H5HF_huge_init", (unsigned)hdr->id_len); +#endif /* QAK */ if((hdr->sizeof_addr + hdr->sizeof_size) <= (hdr->id_len - 1)) { /* Indicate that v2 B-tree doesn't have to be used to locate object */ hdr->huge_ids_direct = TRUE; diff --git a/src/H5HFpkg.h b/src/H5HFpkg.h index 209eeed..21e5468 100644 --- a/src/H5HFpkg.h +++ b/src/H5HFpkg.h @@ -79,6 +79,7 @@ /* Fractal Heap Header specific fields */ \ \ /* General heap information */ \ + + 2 /* Heap ID len */ \ + 1 /* Status flags */ \ \ /* "Huge" object fields */ \ @@ -154,13 +155,6 @@ UINT64DECODE_VAR((i), (o), (h)->heap_off_size); \ UINT64DECODE_VAR((i), (l), (h)->heap_len_size) -/* Size of ID for heap */ -#define H5HF_ID_SIZE(h) ( \ - 1 /* ID flag byte */ \ - + (h)->heap_off_size /* Space for managed object offset */ \ - + (h)->heap_len_size /* Space for managed object length */ \ - ) - /* Free space section types for fractal heap */ /* (values stored in free space data structures in file) */ #define H5HF_FSPACE_SECT_SINGLE 0 /* Section is a range of actual bytes in a direct block */ @@ -293,6 +287,9 @@ typedef struct H5HF_hdr_t { /* Information for H5AC cache functions, _must_ be first field in structure */ H5AC_info_t cache_info; + /* General header information (stored in header) */ + unsigned id_len; /* Size of heap IDs (in bytes) */ + /* Flags for heap settings (stored in status byte in header) */ hbool_t debug_objs; /* Is the heap storing objects in 'debug' format */ hbool_t have_io_filter; /* Does the heap have I/O filters for the direct blocks? */ @@ -328,7 +325,6 @@ typedef struct H5HF_hdr_t { H5F_t *f; /* Pointer to file for heap */ size_t sizeof_size; /* Size of file sizes */ size_t sizeof_addr; /* Size of file addresses */ - size_t id_len; /* Size of heap IDs (in bytes) */ H5FS_t *fspace; /* Free space list for objects in heap */ H5HF_block_iter_t next_block; /* Block iterator for searching for next block with space */ H5B2_class_t huge_bt2_class; /* v2 B-tree class information for "huge" object tracking */ @@ -465,6 +461,8 @@ H5FL_SEQ_EXTERN(H5HF_indirect_ent_t); /* Routines for managing shared fractal heap header */ H5_DLL H5HF_hdr_t * H5HF_hdr_alloc(H5F_t *f); H5_DLL haddr_t H5HF_hdr_create(H5F_t *f, hid_t dxpl_id, const H5HF_create_t *cparam); +H5_DLL herr_t H5HF_hdr_finish_init_phase1(H5HF_hdr_t *hdr); +H5_DLL herr_t H5HF_hdr_finish_init_phase2(H5HF_hdr_t *hdr); H5_DLL herr_t H5HF_hdr_finish_init(H5HF_hdr_t *hdr); /* Doubling table routines */ diff --git a/src/H5HFprivate.h b/src/H5HFprivate.h index 3461500..1c9a3ba 100644 --- a/src/H5HFprivate.h +++ b/src/H5HFprivate.h @@ -58,6 +58,10 @@ typedef struct H5HF_create_t { H5HF_dtable_cparam_t managed;/* Mapped object doubling-table creation parameters */ uint32_t max_man_size; /* Max. size of object to manage in doubling table */ /* (i.e. min. size of object to store standalone) */ + uint16_t id_len; /* Length of IDs to use for heap objects */ + /* (0 - make ID just large enough to hold length & offset of object in the heap) */ + /* (1 - make ID just large enough to allow 'huge' objects to hold the file address & length of the 'huge' object) */ + /* (n - make ID 'n' bytes in size) */ } H5HF_create_t; /* Fractal heap metadata statistics info */ |