From b56de1ddcc91e567b0f330f18441b6908956e6e7 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 13 Nov 2009 18:37:10 -0500 Subject: [svn-r17885] Decription: Convert 'huge' fractal heap object management code to use refactored v2 B-tree routines. Also, switch internal representation of 'sizeof_addr' and 'sizeof_size' in files to be uint8_t's instead of size_t's, since they are stored in single bytes in the file format. Various other minor compiler warning cleanups and error call tweaks. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode Mac OS X/32 10.6.2 (amazon) in debug mode Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode --- src/H5B2pkg.h | 4 +- src/H5Fpkg.h | 4 +- src/H5Fprivate.h | 4 +- src/H5Fquery.c | 4 +- src/H5Fsuper_cache.c | 4 +- src/H5Gdense.c | 6 +- src/H5HFcache.c | 12 ++-- src/H5HFhuge.c | 157 +++++++++++++++++++++++++++++++++------------------ src/H5HFpkg.h | 11 ++-- src/H5Pfcpl.c | 92 ++++++++++++++++-------------- 10 files changed, 176 insertions(+), 122 deletions(-) diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h index b8cea53..71e3ac5 100644 --- a/src/H5B2pkg.h +++ b/src/H5B2pkg.h @@ -160,8 +160,8 @@ typedef struct H5B2_hdr_t { size_t rc; /* Reference count of nodes using this header */ size_t file_rc; /* Reference count of files using this header */ hbool_t pending_delete; /* B-tree is pending deletion */ - size_t sizeof_size; /* Size of file sizes */ - size_t sizeof_addr; /* Size of file addresses */ + uint8_t sizeof_size; /* Size of file sizes */ + 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 */ diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 94a24df..d703a80 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -199,8 +199,8 @@ typedef struct H5F_file_t { H5F_mtab_t mtab; /* File mount table */ /* Cached values from FCPL/superblock */ - size_t sizeof_addr; /* Size of addresses in file */ - size_t sizeof_size; /* Size of offsets in file */ + uint8_t sizeof_addr; /* Size of addresses in file */ + uint8_t sizeof_size; /* Size of offsets in file */ haddr_t sohm_addr; /* Relative address of shared object header message table */ unsigned sohm_vers; /* Version of shared message table on disk */ unsigned sohm_nindexes; /* Number of shared messages indexes in the table */ diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 8dae885..13a111d 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -481,8 +481,8 @@ H5_DLL size_t H5F_get_obj_ids(const H5F_t *f, unsigned types, size_t max_objs, h /* Functions than retrieve values set/cached from the superblock/FCPL */ H5_DLL hid_t H5F_get_fcpl(const H5F_t *f); -H5_DLL size_t H5F_sizeof_addr(const H5F_t *f); -H5_DLL size_t H5F_sizeof_size(const H5F_t *f); +H5_DLL uint8_t H5F_sizeof_addr(const H5F_t *f); +H5_DLL uint8_t H5F_sizeof_size(const H5F_t *f); H5_DLL unsigned H5F_sym_leaf_k(const H5F_t *f); H5_DLL unsigned H5F_Kvalue(const H5F_t *f, const struct H5B_class_t *type); H5_DLL size_t H5F_rdcc_nbytes(const H5F_t *f); diff --git a/src/H5Fquery.c b/src/H5Fquery.c index 93f2d6e..70c5ff1 100644 --- a/src/H5Fquery.c +++ b/src/H5Fquery.c @@ -195,7 +195,7 @@ H5F_get_fcpl(const H5F_t *f) * *------------------------------------------------------------------------- */ -size_t +uint8_t H5F_sizeof_addr(const H5F_t *f) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ @@ -222,7 +222,7 @@ H5F_sizeof_addr(const H5F_t *f) * *------------------------------------------------------------------------- */ -size_t +uint8_t H5F_sizeof_size(const H5F_t *f) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ diff --git a/src/H5Fsuper_cache.c b/src/H5Fsuper_cache.c index ada9e57..501e64b 100644 --- a/src/H5Fsuper_cache.c +++ b/src/H5Fsuper_cache.c @@ -121,8 +121,8 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *udata1 H5FD_t *lf; /* file driver part of `shared' */ haddr_t stored_eoa; /*relative end-of-addr in file */ haddr_t eof; /*end of file address */ - size_t sizeof_addr; /* Size of offsets in the file (in bytes) */ - size_t sizeof_size; /* Size of lengths in the file (in bytes) */ + uint8_t sizeof_addr; /* Size of offsets in the file (in bytes) */ + uint8_t sizeof_size; /* Size of lengths in the file (in bytes) */ const size_t fixed_size = H5F_SUPERBLOCK_FIXED_SIZE; /*fixed sizeof superblock */ size_t variable_size; /*variable sizeof superblock */ uint8_t *p; /* Temporary pointer into encoding buffer */ diff --git a/src/H5Gdense.c b/src/H5Gdense.c index 438249c..5e02174 100644 --- a/src/H5Gdense.c +++ b/src/H5Gdense.c @@ -305,7 +305,7 @@ H5G_dense_create(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, /* Retrieve the heap's address in the file */ if(H5HF_get_heap_addr(fheap, &(linfo->fheap_addr)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGETSIZE, FAIL, "can't get fractal heap address") + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get fractal heap address") #ifdef QAK HDfprintf(stderr, "%s: linfo->fheap_addr = %a\n", FUNC, linfo->fheap_addr); #endif /* QAK */ @@ -331,7 +331,7 @@ HDfprintf(stderr, "%s: fheap_id_len = %Zu\n", FUNC, fheap_id_len); /* Retrieve the v2 B-tree's address in the file */ if(H5B2_get_addr(bt2_name, &(linfo->name_bt2_addr)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGETSIZE, FAIL, "can't get v2 B-tree address for name index") + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get v2 B-tree address for name index") #ifdef QAK HDfprintf(stderr, "%s: linfo->name_bt2_addr = %a\n", FUNC, linfo->name_bt2_addr); #endif /* QAK */ @@ -351,7 +351,7 @@ HDfprintf(stderr, "%s: linfo->name_bt2_addr = %a\n", FUNC, linfo->name_bt2_addr) /* Retrieve the v2 B-tree's address in the file */ if(H5B2_get_addr(bt2_corder, &(linfo->corder_bt2_addr)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGETSIZE, FAIL, "can't get v2 B-tree address for creation order index") + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get v2 B-tree address for creation order index") #ifdef QAK HDfprintf(stderr, "%s: linfo->corder_bt2_addr = %a\n", FUNC, linfo->corder_bt2_addr); #endif /* QAK */ diff --git a/src/H5HFcache.c b/src/H5HFcache.c index ffa3840..6669853 100644 --- a/src/H5HFcache.c +++ b/src/H5HFcache.c @@ -294,7 +294,7 @@ HDfprintf(stderr, "%s: Load heap header, addr = %a\n", FUNC, addr); HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, NULL, "can't wrap buffer") /* Compute the 'base' size of the fractal heap header on disk */ - size = H5HF_HEADER_SIZE(hdr); + size = (size_t)H5HF_HEADER_SIZE(hdr); /* Get a pointer to a buffer that's large enough for serialized header */ if(NULL == (buf = (uint8_t *)H5WB_actual(wb, size))) @@ -364,9 +364,9 @@ HDfprintf(stderr, "%s: Load heap header, addr = %a\n", FUNC, addr); filter_info_off = (size_t)(p - buf); /* Compute the size of the extra filter information */ - filter_info_size = hdr->sizeof_size /* Size of size for filtered root direct block */ - + 4 /* Size of filter mask for filtered root direct block */ - + hdr->filter_len; /* Size of encoded I/O filter info */ + filter_info_size = (size_t)(hdr->sizeof_size /* Size of size for filtered root direct block */ + + (unsigned)4 /* Size of filter mask for filtered root direct block */ + + hdr->filter_len); /* Size of encoded I/O filter info */ /* Compute the heap header's size */ hdr->heap_size = size + filter_info_size; @@ -1435,7 +1435,7 @@ HDfprintf(stderr, "%s: nbytes = %Zu, read_size = %Zu, read_buf = %p\n", FUNC, nb } /* end if */ /* Sanity check */ - HDassert((size_t)(p - dblock->blk) == H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr)); + HDassert((size_t)(p - dblock->blk) == (size_t)H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr)); /* Set return value */ ret_value = dblock; @@ -1523,7 +1523,7 @@ H5HF_cache_dblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, } /* end if */ /* Sanity check */ - HDassert((size_t)(p - dblock->blk) == H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr)); + HDassert((size_t)(p - dblock->blk) == (size_t)H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr)); /* Check for I/O filters on this heap */ if(hdr->filter_len > 0) { diff --git a/src/H5HFhuge.c b/src/H5HFhuge.c index 161542b..b8d0057 100644 --- a/src/H5HFhuge.c +++ b/src/H5HFhuge.c @@ -124,31 +124,31 @@ H5HF_huge_bt2_create(H5HF_hdr_t *hdr, hid_t dxpl_id) */ if(hdr->huge_ids_direct) { if(hdr->filter_len > 0) { - bt2_cparam.rrec_size = hdr->sizeof_addr /* Address of object */ + bt2_cparam.rrec_size = (size_t)(hdr->sizeof_addr /* Address of object */ + hdr->sizeof_size /* Length of object */ + 4 /* Filter mask for filtered object */ - + hdr->sizeof_size; /* Size of de-filtered object in memory */ + + hdr->sizeof_size); /* Size of de-filtered object in memory */ bt2_cparam.cls = H5HF_BT2_FILT_DIR; } /* end if */ else { - bt2_cparam.rrec_size = hdr->sizeof_addr /* Address of object */ - + hdr->sizeof_size; /* Length of object */ + bt2_cparam.rrec_size = (size_t)(hdr->sizeof_addr /* Address of object */ + + hdr->sizeof_size); /* Length of object */ bt2_cparam.cls = H5HF_BT2_DIR; } /* end else */ } /* end if */ else { if(hdr->filter_len > 0) { - bt2_cparam.rrec_size = hdr->sizeof_addr /* Address of filtered object */ + bt2_cparam.rrec_size = (size_t)(hdr->sizeof_addr /* Address of filtered object */ + hdr->sizeof_size /* Length of filtered object */ + 4 /* Filter mask for filtered object */ + hdr->sizeof_size /* Size of de-filtered object in memory */ - + hdr->sizeof_size; /* Unique ID for object */ + + hdr->sizeof_size); /* Unique ID for object */ bt2_cparam.cls = H5HF_BT2_FILT_INDIR; } /* end if */ else { - bt2_cparam.rrec_size = hdr->sizeof_addr /* Address of object */ + 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 */ + + hdr->sizeof_size); /* Unique ID for object */ bt2_cparam.cls = H5HF_BT2_INDIR; } /* end else */ } /* end else */ @@ -157,9 +157,13 @@ 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(H5B2_create(hdr->f, dxpl_id, &bt2_cparam, &hdr->huge_bt2_addr/*out*/) < 0) + if(NULL == (hdr->huge_bt2 = H5B2_create_2(hdr->f, dxpl_id, &bt2_cparam))) 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 */ + if(H5B2_get_addr(hdr->huge_bt2, &hdr->huge_bt2_addr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get v2 B-tree address for tracking 'huge' heap objects") + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_huge_bt2_create() */ @@ -199,12 +203,12 @@ HDfprintf(stderr, "%s: hdr->id_len = %u\n", "H5HF_huge_init", (unsigned)hdr->id_ HDfprintf(stderr, "%s: hdr->filter_len = %u\n", "H5HF_huge_init", (unsigned)hdr->filter_len); #endif /* QAK */ if(hdr->filter_len > 0) { - if((hdr->id_len - 1) >= (hdr->sizeof_addr + hdr->sizeof_size + 4 + hdr->sizeof_size)) { + if((hdr->id_len - 1) >= (unsigned)(hdr->sizeof_addr + hdr->sizeof_size + 4 + hdr->sizeof_size)) { /* Indicate that v2 B-tree doesn't have to be used to locate object */ hdr->huge_ids_direct = TRUE; /* Set the size of 'huge' object IDs */ - hdr->huge_id_size = hdr->sizeof_addr + hdr->sizeof_size + hdr->sizeof_size; + hdr->huge_id_size = (uint8_t)(hdr->sizeof_addr + hdr->sizeof_size + hdr->sizeof_size); } /* end if */ else /* Indicate that v2 B-tree must be used to access object */ @@ -216,7 +220,7 @@ HDfprintf(stderr, "%s: hdr->filter_len = %u\n", "H5HF_huge_init", (unsigned)hdr- hdr->huge_ids_direct = TRUE; /* Set the size of 'huge' object IDs */ - hdr->huge_id_size = hdr->sizeof_addr + hdr->sizeof_size; + hdr->huge_id_size = (uint8_t)(hdr->sizeof_addr + hdr->sizeof_size); } /* end if */ else /* Indicate that v2 B-tree must be used to locate object */ @@ -225,7 +229,7 @@ HDfprintf(stderr, "%s: hdr->filter_len = %u\n", "H5HF_huge_init", (unsigned)hdr- if(!hdr->huge_ids_direct) { /* Set the size and maximum value of 'huge' object ID */ if((hdr->id_len - 1) < sizeof(hsize_t)) { - hdr->huge_id_size = hdr->id_len - 1; + hdr->huge_id_size = (uint8_t)(hdr->id_len - 1); hdr->huge_max_id = ((hsize_t)1 << (hdr->huge_id_size * 8)) - 1; } /*end if */ else { @@ -233,6 +237,7 @@ HDfprintf(stderr, "%s: hdr->filter_len = %u\n", "H5HF_huge_init", (unsigned)hdr- hdr->huge_max_id = HSIZET_MAX; } /* end else */ } /* end if */ + hdr->huge_bt2 = NULL; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF_huge_init() */ @@ -325,9 +330,20 @@ HDfprintf(stderr, "%s: obj_size = %Zu\n", FUNC, obj_size); HDassert(id); /* Check if the v2 B-tree for tracking 'huge' heap objects has been created yet */ - if(!H5F_addr_defined(hdr->huge_bt2_addr)) + if(!H5F_addr_defined(hdr->huge_bt2_addr)) { + /* Go create (& open) v2 B-tree */ if(H5HF_huge_bt2_create(hdr, dxpl_id) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCREATE, FAIL, "can't create v2 B-tree for tracking 'huge' heap objects") + } /* end if */ + else { + /* 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))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") + } /* end if */ + } /* end else */ + HDassert(hdr->huge_bt2); /* Check for I/O pipeline filter on heap */ if(hdr->filter_len > 0) { @@ -387,7 +403,7 @@ HDfprintf(stderr, "%s: obj_rec = {%a, %Hu, %x, %Hu}\n", FUNC, obj_rec.addr, obj_ #endif /* QAK */ /* Insert record for object in v2 B-tree */ - if(H5B2_insert(hdr->f, dxpl_id, H5HF_BT2_FILT_DIR, hdr->huge_bt2_addr, &obj_rec) < 0) + if(H5B2_insert_2(hdr->huge_bt2, dxpl_id, &obj_rec) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "couldn't insert object tracking record in v2 B-tree") /* Encode ID for user */ @@ -408,7 +424,7 @@ HDfprintf(stderr, "%s: obj_rec = {%a, %Hu}\n", FUNC, obj_rec.addr, obj_rec.len); #endif /* QAK */ /* Insert record for object in v2 B-tree */ - if(H5B2_insert(hdr->f, dxpl_id, H5HF_BT2_DIR, hdr->huge_bt2_addr, &obj_rec) < 0) + if(H5B2_insert_2(hdr->huge_bt2, dxpl_id, &obj_rec) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "couldn't insert object tracking record in v2 B-tree") /* Encode ID for user */ @@ -420,7 +436,6 @@ HDfprintf(stderr, "%s: obj_rec = {%a, %Hu}\n", FUNC, obj_rec.addr, obj_rec.len); else { H5HF_huge_bt2_filt_indir_rec_t filt_indir_rec; /* Record for tracking filtered object */ H5HF_huge_bt2_indir_rec_t indir_rec; /* Record for tracking non-filtered object */ - const H5B2_class_t *bt2_class; /* v2 B-tree class to use */ void *ins_rec; /* Pointer to record to insert */ hsize_t new_id; /* New ID for object */ @@ -441,7 +456,6 @@ HDfprintf(stderr, "%s: filt_indir_rec = {%a, %Hu, %x, %Hu, %Hu}\n", FUNC, filt_i /* Set pointer to record to insert */ ins_rec = &filt_indir_rec; - bt2_class = H5HF_BT2_FILT_INDIR; } /* end if */ else { /* Initialize record for object in v2 B-tree */ @@ -454,11 +468,10 @@ HDfprintf(stderr, "%s: indir_rec = {%a, %Hu, %Hu}\n", FUNC, indir_rec.addr, indi /* Set pointer to record to insert */ ins_rec = &indir_rec; - bt2_class = H5HF_BT2_INDIR; } /* end else */ /* Insert record for tracking object in v2 B-tree */ - if(H5B2_insert(hdr->f, dxpl_id, bt2_class, hdr->huge_bt2_addr, ins_rec) < 0) + if(H5B2_insert_2(hdr->huge_bt2, dxpl_id, ins_rec) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "couldn't insert object tracking record in v2 B-tree") /* Encode ID for user */ @@ -529,6 +542,13 @@ H5HF_huge_get_obj_len(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id, } /* end else */ } /* end if */ else { + /* 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))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") + } /* end if */ + if(hdr->filter_len > 0) { H5HF_huge_bt2_filt_indir_rec_t found_rec; /* Record found from tracking object */ H5HF_huge_bt2_filt_indir_rec_t search_rec; /* Record for searching for object */ @@ -537,8 +557,7 @@ H5HF_huge_get_obj_len(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id, UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) /* Look up object in v2 B-tree */ - if(H5B2_find(hdr->f, dxpl_id, H5HF_BT2_FILT_INDIR, hdr->huge_bt2_addr, - &search_rec, H5HF_huge_bt2_filt_indir_found, &found_rec) != TRUE) + if(H5B2_find_2(hdr->huge_bt2, dxpl_id, &search_rec, H5HF_huge_bt2_filt_indir_found, &found_rec) != TRUE) HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "can't find object in B-tree") /* Retrieve the object's length */ @@ -552,8 +571,7 @@ H5HF_huge_get_obj_len(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id, UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) /* Look up object in v2 B-tree */ - if(H5B2_find(hdr->f, dxpl_id, H5HF_BT2_INDIR, hdr->huge_bt2_addr, - &search_rec, H5HF_huge_bt2_indir_found, &found_rec) != TRUE) + if(H5B2_find_2(hdr->huge_bt2, dxpl_id, &search_rec, H5HF_huge_bt2_indir_found, &found_rec) != TRUE) HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "can't find object in B-tree") /* Retrieve the object's length */ @@ -612,6 +630,16 @@ H5HF_huge_op_real(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id, UINT32DECODE(id, filter_mask); } /* end if */ else { + /* Sanity check */ + HDassert(H5F_addr_defined(hdr->huge_bt2_addr)); + + /* 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))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") + } /* end if */ + if(hdr->filter_len > 0) { H5HF_huge_bt2_filt_indir_rec_t found_rec; /* Record found from tracking object */ H5HF_huge_bt2_filt_indir_rec_t search_rec; /* Record for searching for object */ @@ -620,8 +648,7 @@ H5HF_huge_op_real(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id, UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) /* Look up object in v2 B-tree */ - if(H5B2_find(hdr->f, dxpl_id, H5HF_BT2_FILT_INDIR, hdr->huge_bt2_addr, - &search_rec, H5HF_huge_bt2_filt_indir_found, &found_rec) != TRUE) + if(H5B2_find_2(hdr->huge_bt2, dxpl_id, &search_rec, H5HF_huge_bt2_filt_indir_found, &found_rec) != TRUE) HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "can't find object in B-tree") /* Retrieve the object's address & length */ @@ -637,8 +664,7 @@ H5HF_huge_op_real(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id, UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) /* Look up object in v2 B-tree */ - if(H5B2_find(hdr->f, dxpl_id, H5HF_BT2_INDIR, hdr->huge_bt2_addr, - &search_rec, H5HF_huge_bt2_indir_found, &found_rec) != TRUE) + if(H5B2_find_2(hdr->huge_bt2, dxpl_id, &search_rec, H5HF_huge_bt2_indir_found, &found_rec) != TRUE) HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "can't find object in B-tree") /* Retrieve the object's address & length */ @@ -752,12 +778,21 @@ H5HF_huge_write(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id, H5HF_huge_bt2_indir_rec_t found_rec; /* Record found from tracking object */ H5HF_huge_bt2_indir_rec_t search_rec; /* Record for searching for object */ + /* Sanity check */ + HDassert(H5F_addr_defined(hdr->huge_bt2_addr)); + + /* 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))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") + } /* end if */ + /* Get ID for looking up 'huge' object in v2 B-tree */ UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) /* Look up object in v2 B-tree */ - if(H5B2_find(hdr->f, dxpl_id, H5HF_BT2_INDIR, hdr->huge_bt2_addr, - &search_rec, H5HF_huge_bt2_indir_found, &found_rec) != TRUE) + if(H5B2_find_2(hdr->huge_bt2, dxpl_id, &search_rec, H5HF_huge_bt2_indir_found, &found_rec) != TRUE) HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "can't find object in B-tree") /* Retrieve the object's address & length */ @@ -873,8 +908,16 @@ H5HF_huge_remove(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id) * Check arguments. */ HDassert(hdr); + HDassert(H5F_addr_defined(hdr->huge_bt2_addr)); HDassert(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))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") + } /* end if */ + /* Skip over the flag byte */ id++; @@ -894,8 +937,7 @@ H5HF_huge_remove(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id) /* Remove the record for tracking the 'huge' object from the v2 B-tree */ /* (space in the file for the object is freed in the 'remove' callback) */ - if(H5B2_remove(hdr->f, dxpl_id, H5HF_BT2_FILT_DIR, hdr->huge_bt2_addr, - &search_rec, H5HF_huge_bt2_filt_dir_remove, &udata) < 0) + if(H5B2_remove_2(hdr->huge_bt2, dxpl_id, &search_rec, H5HF_huge_bt2_filt_dir_remove, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove object from B-tree") } /* end if */ else { @@ -908,8 +950,7 @@ H5HF_huge_remove(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id) /* Remove the record for tracking the 'huge' object from the v2 B-tree */ /* (space in the file for the object is freed in the 'remove' callback) */ - if(H5B2_remove(hdr->f, dxpl_id, H5HF_BT2_DIR, hdr->huge_bt2_addr, - &search_rec, H5HF_huge_bt2_dir_remove, &udata) < 0) + if(H5B2_remove_2(hdr->huge_bt2, dxpl_id, &search_rec, H5HF_huge_bt2_dir_remove, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove object from B-tree") } /* end else */ } /* end if */ @@ -922,8 +963,7 @@ H5HF_huge_remove(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id) /* Remove the record for tracking the 'huge' object from the v2 B-tree */ /* (space in the file for the object is freed in the 'remove' callback) */ - if(H5B2_remove(hdr->f, dxpl_id, H5HF_BT2_FILT_INDIR, hdr->huge_bt2_addr, - &search_rec, H5HF_huge_bt2_filt_indir_remove, &udata) < 0) + if(H5B2_remove_2(hdr->huge_bt2, dxpl_id, &search_rec, H5HF_huge_bt2_filt_indir_remove, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove object from B-tree") } /* end if */ else { @@ -934,8 +974,7 @@ H5HF_huge_remove(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id) /* Remove the record for tracking the 'huge' object from the v2 B-tree */ /* (space in the file for the object is freed in the 'remove' callback) */ - if(H5B2_remove(hdr->f, dxpl_id, H5HF_BT2_INDIR, hdr->huge_bt2_addr, - &search_rec, H5HF_huge_bt2_indir_remove, &udata) < 0) + if(H5B2_remove_2(hdr->huge_bt2, dxpl_id, &search_rec, H5HF_huge_bt2_indir_remove, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove object from B-tree") } /* end else */ } /* end else */ @@ -978,6 +1017,17 @@ H5HF_huge_term(H5HF_hdr_t *hdr, hid_t dxpl_id) */ HDassert(hdr); + /* Check if v2 B-tree index is open */ + if(hdr->huge_bt2) { + /* Sanity check */ + HDassert(H5F_addr_defined(hdr->huge_bt2_addr)); + + /* Close v2 B-tree index */ + if(H5B2_close(hdr->huge_bt2, dxpl_id) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree") + hdr->huge_bt2 = NULL; + } /* end if */ + /* Check if there are no more 'huge' objects in the heap and delete the * v2 B-tree that tracks them, if so */ @@ -1023,6 +1073,7 @@ herr_t H5HF_huge_delete(H5HF_hdr_t *hdr, hid_t dxpl_id) { H5HF_huge_remove_ud1_t udata; /* User callback data for v2 B-tree remove call */ + H5B2_remove_t op; /* Callback for v2 B-tree removal */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5HF_huge_delete) @@ -1039,28 +1090,24 @@ H5HF_huge_delete(H5HF_hdr_t *hdr, hid_t dxpl_id) udata.hdr = hdr; udata.dxpl_id = dxpl_id; - /* Delete the v2 B-tree */ + /* Set the v2 B-tree callback operator */ if(hdr->huge_ids_direct) { - if(hdr->filter_len > 0) { - if(H5B2_delete(hdr->f, dxpl_id, hdr->huge_bt2_addr, H5HF_huge_bt2_filt_dir_remove, &udata) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "can't delete v2 B-tree") - } /* end if */ - else { - if(H5B2_delete(hdr->f, dxpl_id, hdr->huge_bt2_addr, H5HF_huge_bt2_dir_remove, &udata) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "can't delete v2 B-tree") - } /* end else */ + if(hdr->filter_len > 0) + op = H5HF_huge_bt2_filt_dir_remove; + else + op = H5HF_huge_bt2_dir_remove; } /* end if */ else { - if(hdr->filter_len > 0) { - if(H5B2_delete(hdr->f, dxpl_id, hdr->huge_bt2_addr, H5HF_huge_bt2_filt_indir_remove, &udata) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "can't delete v2 B-tree") - } /* end if */ - else { - if(H5B2_delete(hdr->f, dxpl_id, hdr->huge_bt2_addr, H5HF_huge_bt2_indir_remove, &udata) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "can't delete v2 B-tree") - } /* end else */ + if(hdr->filter_len > 0) + op = H5HF_huge_bt2_filt_indir_remove; + else + op = H5HF_huge_bt2_indir_remove; } /* end else */ + /* Delete the v2 B-tree */ + if(H5B2_delete(hdr->f, dxpl_id, hdr->huge_bt2_addr, op, &udata) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "can't delete v2 B-tree") + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_huge_delete() */ diff --git a/src/H5HFpkg.h b/src/H5HFpkg.h index 785a3ff..dac6d39 100644 --- a/src/H5HFpkg.h +++ b/src/H5HFpkg.h @@ -341,18 +341,19 @@ typedef struct H5HF_hdr_t { H5F_t *f; /* Pointer to file for heap */ size_t file_rc; /* Reference count of files using heap header */ hbool_t pending_delete; /* Heap is pending deletion */ - size_t sizeof_size; /* Size of file sizes */ - size_t sizeof_addr; /* Size of file addresses */ + uint8_t sizeof_size; /* Size of file sizes */ + uint8_t sizeof_addr; /* Size of file addresses */ struct H5HF_indirect_t *root_iblock; /* Pointer to pinned root indirect block */ 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_t *huge_bt2; /* v2 B-tree handle for huge objects */ hsize_t huge_max_id; /* Max. 'huge' heap ID before rolling 'huge' heap IDs over */ + uint8_t huge_id_size; /* Size of 'huge' heap IDs (in bytes) */ hbool_t huge_ids_direct; /* Flag to indicate that 'huge' object's offset & length are stored directly in heap ID */ size_t tiny_max_len; /* Max. size of tiny objects for this heap */ hbool_t tiny_len_extended; /* Flag to indicate that 'tiny' object's length is stored in extended form (i.e. w/extra byte) */ - uint8_t huge_id_size; /* Size of 'huge' heap IDs (in bytes) */ - uint8_t heap_off_size; /* Size of heap offsets (in bytes) */ - uint8_t heap_len_size; /* Size of heap ID lengths (in bytes) */ + uint8_t heap_off_size; /* Size of heap offsets (in bytes) */ + uint8_t heap_len_size; /* Size of heap ID lengths (in bytes) */ hbool_t checked_filters; /* TRUE if pipeline passes can_apply checks */ } H5HF_hdr_t; diff --git a/src/H5Pfcpl.c b/src/H5Pfcpl.c index 0653c46..edfded6 100644 --- a/src/H5Pfcpl.c +++ b/src/H5Pfcpl.c @@ -55,10 +55,10 @@ #define H5F_CRT_BTREE_RANK_SIZE sizeof(unsigned[H5B_NUM_BTREE_ID]) #define H5F_CRT_BTREE_RANK_DEF {HDF5_BTREE_SNODE_IK_DEF,HDF5_BTREE_CHUNK_IK_DEF} /* Definitions for byte number in an address */ -#define H5F_CRT_ADDR_BYTE_NUM_SIZE sizeof(size_t) +#define H5F_CRT_ADDR_BYTE_NUM_SIZE sizeof(uint8_t) #define H5F_CRT_ADDR_BYTE_NUM_DEF H5F_OBJ_ADDR_SIZE /* Definitions for byte number for object size */ -#define H5F_CRT_OBJ_BYTE_NUM_SIZE sizeof(size_t) +#define H5F_CRT_OBJ_BYTE_NUM_SIZE sizeof(uint8_t) #define H5F_CRT_OBJ_BYTE_NUM_DEF H5F_OBJ_SIZE_SIZE /* Definitions for version number of the superblock */ #define H5F_CRT_SUPER_VERS_SIZE sizeof(unsigned) @@ -147,8 +147,8 @@ H5P_fcrt_reg_prop(H5P_genclass_t *pclass) hsize_t userblock_size = H5F_CRT_USER_BLOCK_DEF; /* Default userblock size */ unsigned sym_leaf_k = H5F_CRT_SYM_LEAF_DEF; /* Default size for symbol table leaf nodes */ unsigned btree_k[H5B_NUM_BTREE_ID] = H5F_CRT_BTREE_RANK_DEF; /* Default 'K' values for B-trees in file */ - size_t sizeof_addr = H5F_CRT_ADDR_BYTE_NUM_DEF; /* Default size of addresses in the file */ - size_t sizeof_size = H5F_CRT_OBJ_BYTE_NUM_DEF; /* Default size of sizes in the file */ + uint8_t sizeof_addr = H5F_CRT_ADDR_BYTE_NUM_DEF; /* Default size of addresses in the file */ + uint8_t sizeof_size = H5F_CRT_OBJ_BYTE_NUM_DEF; /* Default size of sizes in the file */ unsigned superblock_ver = H5F_CRT_SUPER_VERS_DEF; /* Default superblock version # */ unsigned num_sohm_indexes = H5F_CRT_SHMSG_NINDEXES_DEF; unsigned sohm_index_flags[H5O_SHMESG_MAX_NINDEXES] = H5F_CRT_SHMSG_INDEX_TYPES_DEF; @@ -312,46 +312,48 @@ done: * Programmer: Robb Matzke * Tuesday, January 6, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t H5Pset_sizes(hid_t plist_id, size_t sizeof_addr, size_t sizeof_size) { H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value=SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* return value */ - FUNC_ENTER_API(H5Pset_sizes, FAIL); + FUNC_ENTER_API(H5Pset_sizes, FAIL) H5TRACE3("e", "izz", plist_id, sizeof_addr, sizeof_size); /* Check arguments */ - if (sizeof_addr) { - if (sizeof_addr != 2 && sizeof_addr != 4 && - sizeof_addr != 8 && sizeof_addr != 16) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file haddr_t size is not valid"); - } - if (sizeof_size) { - if (sizeof_size != 2 && sizeof_size != 4 && - sizeof_size != 8 && sizeof_size != 16) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file size_t size is not valid"); - } + if(sizeof_addr) { + if(sizeof_addr != 2 && sizeof_addr != 4 && sizeof_addr != 8 && sizeof_addr != 16) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file haddr_t size is not valid") + } /* end if */ + if(sizeof_size) { + if(sizeof_size != 2 && sizeof_size != 4 && sizeof_size != 8 && sizeof_size != 16) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file size_t size is not valid") + } /* end if */ /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set value */ - if (sizeof_addr) - if(H5P_set(plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &sizeof_addr) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set byte number for an address"); - if (sizeof_size) - if(H5P_set(plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &sizeof_size) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set byte number for object "); + if(sizeof_addr) { + uint8_t tmp_sizeof_addr = (uint8_t)sizeof_addr; + + if(H5P_set(plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &tmp_sizeof_addr) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set byte number for an address") + } /* end if */ + if(sizeof_size) { + uint8_t tmp_sizeof_size = (uint8_t)sizeof_size; + + if(H5P_set(plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &tmp_sizeof_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set byte number for object ") + } /* end if */ done: - FUNC_LEAVE_API(ret_value); -} + FUNC_LEAVE_API(ret_value) +} /* end H5Pset_sizes() */ /*------------------------------------------------------------------------- @@ -362,41 +364,45 @@ done: * even both) SIZEOF_ADDR and SIZEOF_SIZE may be null pointers. * * Return: Success: Non-negative, sizes returned through arguments. - * * Failure: Negative * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t -H5Pget_sizes(hid_t plist_id, - size_t *sizeof_addr /*out */ , size_t *sizeof_size /*out */ ) +H5Pget_sizes(hid_t plist_id, size_t *sizeof_addr, size_t *sizeof_size) { H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value=SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* return value */ - FUNC_ENTER_API(H5Pget_sizes, FAIL); + FUNC_ENTER_API(H5Pget_sizes, FAIL) H5TRACE3("e", "ixx", plist_id, sizeof_addr, sizeof_size); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get values */ - if (sizeof_addr) - if(H5P_get(plist, H5F_CRT_ADDR_BYTE_NUM_NAME, sizeof_addr) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get byte number for an address"); - if (sizeof_size) - if(H5P_get(plist, H5F_CRT_OBJ_BYTE_NUM_NAME, sizeof_size) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get byte number for object "); + if(sizeof_addr) { + uint8_t tmp_sizeof_addr; + + if(H5P_get(plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &tmp_sizeof_addr) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get byte number for an address") + *sizeof_addr = tmp_sizeof_addr; + } /* end if */ + if(sizeof_size) { + uint8_t tmp_sizeof_size; + + if(H5P_get(plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &tmp_sizeof_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get byte number for object ") + *sizeof_size = tmp_sizeof_size; + } /* end if */ done: - FUNC_LEAVE_API(ret_value); -} + FUNC_LEAVE_API(ret_value) +} /* end H5Pget_sizes() */ /*------------------------------------------------------------------------- -- cgit v0.12