diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2003-01-09 17:20:03 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2003-01-09 17:20:03 (GMT) |
commit | 9a433b99a56dc575f1c0b11f95b744de61859dbb (patch) | |
tree | d8c766537cb9adc364c902bd45477d97f67a4a9f /src/H5F.c | |
parent | 7fd449cb7987772a2881a5ced2ae7ad5231f1fa3 (diff) | |
download | hdf5-9a433b99a56dc575f1c0b11f95b744de61859dbb.zip hdf5-9a433b99a56dc575f1c0b11f95b744de61859dbb.tar.gz hdf5-9a433b99a56dc575f1c0b11f95b744de61859dbb.tar.bz2 |
[svn-r6252] Purpose:
Lots of performance improvements & a couple new internal API interfaces.
Description:
Performance Improvements:
- Cached file offset & length sizes in shared file struct, to avoid
constantly looking them up in the FCPL.
- Generic property improvements:
- Added "revision" number to generic property classes to speed
up comparisons.
- Changed method of storing properties from using a hash-table
to the TBBT routines in the library.
- Share the propery names between classes and the lists derived
from them.
- Removed redundant 'def_value' buffer from each property.
- Switching code to use a "copy on write" strategy for
properties in each list, where the properties in each list
are shared with the properties in the class, until a
property's value is changed in a list.
- Fixed error in layout code which was allocating too many buffers.
- Redefined public macros of the form (H5open()/H5check, <variable>)
internally to only be (<variable>), avoiding innumerable useless
calls to H5open() and H5check_version().
- Reuse already zeroed buffers in H5F_contig_fill instead of
constantly re-zeroing them.
- Don't write fill values if writing entire dataset.
- Use gettimeofday() system call instead of time() system when
checking the modification time of a dataset.
- Added reference counted string API and use it for tracking the
names of objects opening in a file (for the ID->name code).
- Removed redundant H5P_get() calls in B-tree routines.
- Redefine H5T datatype macros internally to the library, to avoid
calling H5check redundantly.
- Keep dataspace information for dataset locally instead of reading
from disk each time. Added new module to track open objects
in a file, to allow this (which will be useful eventually for
some FPH5 metadata caching issues).
- Remove H5AC_find macro which was inlining metadata cache lookups,
and call function instead.
- Remove redundant memset() calls from H5G_namei() routine.
- Remove redundant checking of object type when locating objects
in metadata cache and rely on the address only.
- Create default dataset object to use when default dataset creation
property list is used to create datasets, bypassing querying
for all the property list values.
- Use default I/O vector size when performing raw data with the
default dataset transfer property list, instead of querying for
I/O vector size.
- Remove H5P_DEFAULT internally to the library, replacing it with
more specific default property list based on the type of
property list needed.
- Remove redundant memset() calls in object header message (H5O*)
routines.
- Remove redunant memset() calls in data I/O routines.
- Split free-list allocation routines into malloc() and calloc()-
like routines, instead of one combined routine.
- Remove lots of indirection in H5O*() routines.
- Simplify metadata cache entry comparison routine (used when
flushing entire cache out).
- Only enable metadata cache statistics when H5AC_DEBUG is turned
on, instead of always tracking them.
- Simplify address comparison macro (H5F_addr_eq).
- Remove redundant metadata cache entry protections during dataset
creation by protecting the object header once and making all
the modifications necessary for the dataset creation before
unprotecting it.
- Reduce # of "number of element in extent" computations performed
by computing and storing the value during dataspace creation.
- Simplify checking for group location's file information, when file
has not been involving in file-mounting operations.
- Use binary encoding for modification time, instead of ASCII.
- Hoist H5HL_peek calls (to get information in a local heap)
out of loops in many group routine.
- Use static variable for iterators of selections, instead of
dynamically allocation them each time.
- Lookup & insert new entries in one step, avoiding traversing
group's B-tree twice.
- Fixed memory leak in H5Gget_objname_idx() routine (tangential to
performance improvements, but fixed along the way).
- Use free-list for reference counted strings.
- Don't bother copying object names into cached group entries,
since they are re-created when an object is opened.
The benchmark I used to measure these results created several thousand
small (2K) datasets in a file and wrote out the data for them. This is
Elena's "regular.c" benchmark.
These changes resulted in approximately ~4.3x speedup of the
development branch when compared to the previous code in the
development branch and ~1.4x speedup compared to the release
branch.
Additionally, these changes reduce the total memory used (code and
data) by the development branch by ~800KB, bringing the development
branch back into the same ballpark as the release branch.
I'll send out a more detailed description of the benchmark results
as a followup note.
New internal API routines:
Added "reference counted strings" API for tracking strings that get
used by multiple owners without duplicating the strings.
Added "ternary search tree" API for text->object mappings.
Platforms tested:
Tested h5committest {arabica (fortran), eirene (fortran, C++)
modi4 (parallel, fortran)}
Other platforms/configurations tested?
FreeBSD 4.7 (sleipnir) serial & parallel
Solaris 2.6 (baldric) serial
Diffstat (limited to 'src/H5F.c')
-rw-r--r-- | src/H5F.c | 327 |
1 files changed, 232 insertions, 95 deletions
@@ -243,7 +243,7 @@ H5F_init_interface(void) assert(H5P_CLS_FILE_CREATE_g!=-1); /* Get the pointer to file creation class */ - if(NULL == (crt_pclass = H5I_object_verify(H5P_CLS_FILE_CREATE_g, H5I_GENPROP_CLS))) + if(NULL == (crt_pclass = H5I_object(H5P_CLS_FILE_CREATE_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class"); /* Get the number of properties in the class */ @@ -326,7 +326,7 @@ H5F_init_interface(void) assert(H5P_CLS_FILE_ACCESS_g!=-1); /* Get the pointer to file creation class */ - if(NULL == (acs_pclass = H5I_object_verify(H5P_CLS_FILE_ACCESS_g, H5I_GENPROP_CLS))) + if(NULL == (acs_pclass = H5I_object(H5P_CLS_FILE_ACCESS_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class"); /* Get the number of properties in the class */ @@ -407,7 +407,7 @@ H5F_init_interface(void) assert(H5P_CLS_MOUNT_g!=-1); /* Get the pointer to file mount class */ - if(NULL == (mnt_pclass = H5I_object_verify(H5P_CLS_MOUNT_g, H5I_GENPROP_CLS))) + if(NULL == (mnt_pclass = H5I_object(H5P_CLS_MOUNT_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class"); /* Get the number of properties in the class */ @@ -503,7 +503,7 @@ H5F_acs_create(hid_t fapl_id, void UNUSED *copy_data) FUNC_ENTER_NOAPI(H5F_acs_create, FAIL); /* Check argument */ - if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) + if(NULL == (plist = H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); /* Retrieve properties */ @@ -558,7 +558,7 @@ H5F_acs_close(hid_t fapl_id, void UNUSED *close_data) FUNC_ENTER_NOAPI(H5F_acs_close, FAIL); /* Check argument */ - if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) + if(NULL == (plist = H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); if(H5P_get(plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0) @@ -610,9 +610,9 @@ H5F_acs_copy(hid_t new_fapl_id, hid_t old_fapl_id, void UNUSED *copy_data) FUNC_ENTER_NOAPI(H5F_acs_copy, FAIL); - if(NULL == (new_plist = H5I_object_verify(new_fapl_id, H5I_GENPROP_LST))) + if(NULL == (new_plist = H5I_object(new_fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list"); - if(NULL == (old_plist = H5I_object_verify(old_fapl_id, H5I_GENPROP_LST))) + if(NULL == (old_plist = H5I_object(old_fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list"); /* Get values from old property list */ @@ -1375,7 +1375,7 @@ H5Fis_hdf5(const char *name) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "no file name specified"); /* Open the file at the virtual file layer */ - if (NULL==(file=H5FD_open(name, H5F_ACC_RDONLY, H5P_DEFAULT, HADDR_UNDEF))) + if (NULL==(file=H5FD_open(name, H5F_ACC_RDONLY, H5P_FILE_ACCESS_DEFAULT, HADDR_UNDEF))) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to open file"); /* The file is an hdf5 file if the hdf5 file signature can be found */ @@ -1428,13 +1428,13 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id) FUNC_ENTER_NOINIT(H5F_new); - if (NULL==(f=H5FL_ALLOC(H5F_t,1))) + if (NULL==(f=H5FL_CALLOC(H5F_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); if (shared) { f->shared = shared; } else { - f->shared = H5FL_ALLOC(H5F_file_t,1); + f->shared = H5FL_CALLOC(H5F_file_t); f->shared->boot_addr = HADDR_UNDEF; f->shared->base_addr = HADDR_UNDEF; f->shared->freespace_addr = HADDR_UNDEF; @@ -1445,16 +1445,19 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id) * new file handle. We do this early because some values might need * to change as the file is being opened. */ - if(H5P_DEFAULT == fcpl_id) - fcpl_id = H5P_FILE_CREATE_DEFAULT; - if(NULL == (plist = H5P_object_verify(fcpl_id,H5P_FILE_CREATE))) + if(NULL == (plist = H5I_object(fcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not property list"); f->shared->fcpl_id = H5P_copy_plist(plist); + /* Get the FCPL values to cache */ + if(H5P_get(plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &f->shared->sizeof_addr)<0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get byte number for address"); + if(H5P_get(plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &f->shared->sizeof_size)<0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get byte number for object size"); + if(H5P_get(plist, H5F_CRT_SYM_LEAF_NAME, &f->shared->sym_leaf_k)<0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get byte number for object size"); - if(H5P_DEFAULT == fapl_id) - fapl_id = H5P_FILE_ACCESS_DEFAULT; - if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) + if(NULL == (plist = H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not file access property list"); if(H5P_get(plist, H5F_ACS_META_CACHE_SIZE_NAME, &(f->shared->mdc_nelmts)) < 0) @@ -1486,6 +1489,10 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id) /* Create the chunk cache */ H5F_istore_init(f); + + /* Create the file's "open object" information */ + if(H5FO_create(f)<0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create open object TBBT"); } /* end else */ f->shared->nrefs++; @@ -1561,13 +1568,17 @@ H5F_dest(H5F_t *f) f->shared->root_grp=NULL; } if (H5AC_dest(f)) { - HERROR(H5E_FILE, H5E_CANTINIT, "problems closing file"); + HERROR(H5E_FILE, H5E_CANTRELEASE, "problems closing file"); ret_value = FAIL; /*but keep going*/ } if (H5F_istore_dest (f)<0) { - HERROR(H5E_FILE, H5E_CANTINIT, "problems closing file"); + HERROR(H5E_FILE, H5E_CANTRELEASE, "problems closing file"); ret_value = FAIL; /*but keep going*/ } + if (H5FO_dest(f)<0) { + HERROR(H5E_FILE, H5E_CANTRELEASE, "problems closing file"); + ret_value = FAIL; /*but keep going*/ + } /* end if */ f->shared->cwfs = H5MM_xfree (f->shared->cwfs); /* Free the data sieve buffer, if it's been allocated */ @@ -1837,6 +1848,16 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) * empty or not. */ if (0==H5FD_get_eof(lf) && (flags & H5F_ACC_RDWR)) { + /* Get values to cache from the FCPL */ + if(H5P_get(c_plist, H5F_CRT_ADDR_BYTE_NUM_NAME,&shared->sizeof_addr)<0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set byte number in an address"); + if(H5P_get(c_plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &shared->sizeof_size)<0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set byte number for object size"); + if(H5P_get(c_plist, H5F_CRT_SYM_LEAF_NAME, &shared->sym_leaf_k)<0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set rank for symbol table leaf nodes"); + if(H5P_get(c_plist, H5F_CRT_BTREE_RANK_NAME, &shared->btree_k[0])<0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "unable to get rank for btree internal nodes"); + /* * The superblock starts immediately after the user-defined header, * which we have already insured is a proper size. The base address @@ -1903,6 +1924,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad byte number in an address"); if(H5P_set(c_plist, H5F_CRT_ADDR_BYTE_NUM_NAME,&sizeof_addr)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set byte number in an address"); + shared->sizeof_addr=sizeof_addr; /* Keep a local copy also */ /* Size of file sizes */ sizeof_size = *p++; @@ -1911,6 +1933,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad byte number for object size"); if(H5P_set(c_plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &sizeof_size)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set byte number for object size"); + shared->sizeof_size=sizeof_size; /* Keep a local copy also */ /* Reserved byte */ p++; @@ -1921,6 +1944,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, NULL, "bad symbol table leaf node 1/2 rank"); if(H5P_set(c_plist, H5F_CRT_SYM_LEAF_NAME, &sym_leaf_k)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set rank for symbol table leaf nodes"); + shared->sym_leaf_k=sym_leaf_k; /* Keep a local copy also */ /* Need 'get' call to set other array values */ if(H5P_get(c_plist, H5F_CRT_BTREE_RANK_NAME, btree_k)<0) @@ -1930,6 +1954,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, NULL, "bad 1/2 rank for btree internal nodes"); if(H5P_set(c_plist, H5F_CRT_BTREE_RANK_NAME, btree_k)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set rank for btree internal nodes"); + HDmemcpy(shared->btree_k,btree_k,sizeof(int)*H5B_NUM_BTREE_ID); /* Keep a local copy also */ /* File consistency flags. Not really used yet */ UINT32DECODE(p, shared->consist_flags); @@ -2033,9 +2058,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) * second time or later, verify the access property list value matches * the degree in shared file structure. */ - if(H5P_DEFAULT == fapl_id) - fapl_id = H5P_FILE_ACCESS_DEFAULT; - if(NULL == (a_plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) + if(NULL == (a_plist = H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not file access property list"); if(H5P_get(a_plist, H5F_CLOSE_DEGREE_NAME, &fc_degree) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get file close degree"); @@ -2138,14 +2161,16 @@ H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, /* Check file creation property list */ if(H5P_DEFAULT == fcpl_id) fcpl_id = H5P_FILE_CREATE_DEFAULT; - if(TRUE != H5P_isa_class(fcpl_id, H5P_FILE_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file create property list"); + else + if(TRUE != H5P_isa_class(fcpl_id, H5P_FILE_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file create property list"); /* Check the file access property list */ if(H5P_DEFAULT == fapl_id) fapl_id = H5P_FILE_ACCESS_DEFAULT; - if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list"); + else + if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list"); /* * Adjust bit flags by turning on the creation bit and making sure that @@ -2230,11 +2255,12 @@ H5Fopen(const char *filename, unsigned flags, hid_t fapl_id) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file open flags"); if(H5P_DEFAULT == fapl_id) fapl_id = H5P_FILE_ACCESS_DEFAULT; - if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list"); + else + if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list"); /* Open the file */ - if (NULL==(new_file=H5F_open(filename, flags, H5P_DEFAULT, fapl_id))) + if (NULL==(new_file=H5F_open(filename, flags, H5P_FILE_CREATE_DEFAULT, fapl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to open file"); /* Get an atom for the file */ @@ -2399,8 +2425,6 @@ H5F_flush(H5F_t *f, H5F_scope_t scope, hbool_t invalidate, int freespace_vers; /* Freespace info version */ int obj_dir_vers; /* Object header info version */ int share_head_vers;/* Shared header info version */ - int btree_k[H5B_NUM_BTREE_ID]; /* B-tree size info */ - unsigned sym_leaf_k; /* Number of symbols in B-tree leafs */ H5P_genplist_t *plist; /* Property list */ herr_t ret_value; /* Return value */ @@ -2492,10 +2516,6 @@ H5F_flush(H5F_t *f, H5F_scope_t scope, hbool_t invalidate, HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get object directory version"); if(H5P_get(plist, H5F_CRT_SHARE_HEAD_VERS_NAME, &share_head_vers) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get shared-header format version"); - if(H5P_get(plist, H5F_CRT_SYM_LEAF_NAME, &sym_leaf_k) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get rank for symbol table leaf nodes"); - if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get rank for btree internal nodes"); /* encode the file boot block */ p = sbuf; @@ -2511,8 +2531,8 @@ H5F_flush(H5F_t *f, H5F_scope_t scope, hbool_t invalidate, assert (H5F_SIZEOF_SIZE(f)<=255); *p++ = (uint8_t)H5F_SIZEOF_SIZE(f); *p++ = 0; /*reserved */ - UINT16ENCODE(p, sym_leaf_k); - UINT16ENCODE(p, btree_k[H5B_SNODE_ID]); + UINT16ENCODE(p, f->shared->sym_leaf_k); + UINT16ENCODE(p, f->shared->btree_k[H5B_SNODE_ID]); UINT32ENCODE(p, f->shared->consist_flags); H5F_addr_encode(f, &p, f->shared->base_addr); H5F_addr_encode(f, &p, f->shared->freespace_addr); @@ -2904,6 +2924,7 @@ H5F_mount(H5G_entry_t *loc, const char *name, H5F_t *child, H5F_t *parent = NULL; /*file containing mount point */ int lt, rt, md, cmp; /*binary search indices */ H5G_entry_t *ent = NULL; /*temporary symbol table entry */ + H5RS_str_t *name_r; /* Ref-counted version of name */ herr_t ret_value = SUCCEED; /*return value */ FUNC_ENTER_NOINIT(H5F_mount); @@ -2975,8 +2996,11 @@ H5F_mount(H5G_entry_t *loc, const char *name, H5F_t *child, /* Search the open IDs and replace names for mount operation */ /* We pass H5G_UNKNOWN as object type; search all IDs */ - if (H5G_replace_name( H5G_UNKNOWN, loc, name, NULL, NULL, NULL, OP_MOUNT )<0) + name_r=H5RS_wrap(name); + assert(name_r); + if (H5G_replace_name( H5G_UNKNOWN, loc, name_r, NULL, NULL, NULL, OP_MOUNT )<0) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to replace name"); + H5RS_decr(name_r); done: if (ret_value<0 && mount_point) @@ -3050,7 +3074,7 @@ H5F_unmount(H5G_entry_t *loc, const char *name) for (i=0; i<parent->mtab.nmounts; i++) { if (parent->mtab.child[i].file==child) { /* Search the open IDs replace names to reflect unmount operation */ - if (H5G_replace_name( H5G_UNKNOWN, mnt_ent, mnt_ent->user_path, NULL, NULL, NULL, OP_UNMOUNT )<0) + if (H5G_replace_name( H5G_UNKNOWN, mnt_ent, mnt_ent->user_path_r, NULL, NULL, NULL, OP_UNMOUNT )<0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to replace name "); /* Unmount the child */ @@ -3181,6 +3205,74 @@ done: /*------------------------------------------------------------------------- + * Function: H5F_has_mount + * + * Purpose: Check if a file has mounted files within it. + * + * Return: Success: TRUE/FALSE + * Failure: Negative + * + * Programmer: Quincey Koziol + * Thursday, January 2, 2002 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +htri_t +H5F_has_mount(const H5F_t *file) +{ + htri_t ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(H5F_has_mount, FAIL); + + assert(file); + + if(file->mtab.nmounts>0) + ret_value=TRUE; + else + ret_value=FALSE; + +done: + FUNC_LEAVE(ret_value); +} /* end H5F_has_mount() */ + + +/*------------------------------------------------------------------------- + * Function: H5F_is_mount + * + * Purpose: Check if a file is mounted within another file. + * + * Return: Success: TRUE/FALSE + * Failure: Negative + * + * Programmer: Quincey Koziol + * Thursday, January 2, 2002 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +htri_t +H5F_is_mount(const H5F_t *file) +{ + htri_t ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(H5F_is_mount, FAIL); + + assert(file); + + if(file->mtab.parent!=NULL) + ret_value=TRUE; + else + ret_value=FALSE; + +done: + FUNC_LEAVE(ret_value); +} /* end H5F_is_mount() */ + + +/*------------------------------------------------------------------------- * Function: H5Fmount * * Purpose: Mount file CHILD_ID onto the group specified by LOC_ID and @@ -3214,8 +3306,9 @@ H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file"); if(H5P_DEFAULT == plist_id) plist_id = H5P_MOUNT_DEFAULT; - if(TRUE != H5P_isa_class(plist_id, H5P_MOUNT)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not property list"); + else + if(TRUE != H5P_isa_class(plist_id, H5P_MOUNT)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not property list"); /* Do the mount */ if (H5F_mount(loc, name, child, plist_id)<0) @@ -3307,7 +3400,7 @@ H5Freopen(hid_t file_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file"); /* Get a new "top level" file struct, sharing the same "low level" file struct */ - if (NULL==(new_file=H5F_new(old_file->shared, H5P_DEFAULT, H5P_DEFAULT))) + if (NULL==(new_file=H5F_new(old_file->shared, H5P_FILE_CREATE_DEFAULT, H5P_FILE_ACCESS_DEFAULT))) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file"); /* Keep old file's read/write intent in new file */ @@ -3373,27 +3466,14 @@ H5F_get_intent(const H5F_t *f) size_t H5F_sizeof_addr(const H5F_t *f) { - size_t sizeof_addr = 0; - H5P_genplist_t *plist; /* Property list */ - size_t ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(H5F_sizeof_addr, 0); + /* Use FUNC_ENTER_NOINIT here to avoid performance issues */ + FUNC_ENTER_NOINIT(H5F_sizeof_addr); assert(f); assert(f->shared); - /* Get property list */ - if(NULL == (plist = H5I_object(f->shared->fcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, UFAIL, "not a property list"); - - if(H5P_get(plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &sizeof_addr)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, UFAIL, "can't get byte number for address"); - - /* Set return value */ - ret_value=sizeof_addr; - done: - FUNC_LEAVE(ret_value); + FUNC_LEAVE(f->shared->sizeof_addr); } @@ -3419,31 +3499,88 @@ done: size_t H5F_sizeof_size(const H5F_t *f) { - size_t sizeof_size = 0; - H5P_genplist_t *plist; /* Property list */ - size_t ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(H5F_sizeof_size, 0); + /* Use FUNC_ENTER_NOINIT here to avoid performance issues */ + FUNC_ENTER_NOINIT(H5F_sizeof_size); assert(f); assert(f->shared); - /* Get property list */ - if(NULL == (plist = H5I_object(f->shared->fcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, UFAIL, "not a property list"); +done: + FUNC_LEAVE(f->shared->sizeof_size); +} - if(H5P_get(plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &sizeof_size)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, UFAIL, "can't get byte number for object size"); + +/*------------------------------------------------------------------------- + * Function: H5F_sym_leaf_k + * + * Purpose: Replaced a macro to retrieve the symbol table leaf size, + * now that the generic properties are being used to store + * the values. + * + * Return: Success: Non-negative, and the symbol table leaf size is + * returned. + * + * Failure: Negative (should not happen) + * + * Programmer: Raymond Lu + * slu@ncsa.uiuc.edu + * Oct 14 2001 + * + * Modifications: + * Quincey Koziol, 2001-10-15 + * Added this header and removed unused ret_value variable. + *------------------------------------------------------------------------- + */ +unsigned H5F_sym_leaf_k(const H5F_t *f) +{ + /* Use FUNC_ENTER_NOINIT here to avoid performance issues */ + FUNC_ENTER_NOINIT(H5F_sym_leaf_k); - /* Set return value */ - ret_value=sizeof_size; + assert(f); + assert(f->shared); done: - FUNC_LEAVE(ret_value); + FUNC_LEAVE(f->shared->sym_leaf_k); } /*------------------------------------------------------------------------- + * Function: H5F_Kvalue + * + * Purpose: Replaced a macro to retrieve a B-tree key value for a certain + * type, now that the generic properties are being used to store + * the B-tree values. + * + * Return: Success: Non-negative, and the B-tree key value is + * returned. + * + * Failure: Negative (should not happen) + * + * Programmer: Raymond Lu + * slu@ncsa.uiuc.edu + * Oct 14 2001 + * + * Modifications: + * Quincey Koziol, 2001-10-15 + * Added this header and removed unused ret_value variable. + *------------------------------------------------------------------------- + */ +int +H5F_Kvalue(const H5F_t *f, const H5B_class_t *type) +{ + /* Use FUNC_ENTER_NOINIT here to avoid performance issues */ + FUNC_ENTER_NOINIT(H5F_Kvalue); + + assert(f); + assert(f->shared); + assert(type); + +done: + FUNC_LEAVE(f->shared->btree_k[type->id]); +} /* end H5F_Kvalue() */ + + +/*------------------------------------------------------------------------- * Function: H5F_get_driver_id * * Purpose: Quick and dirty routine to retrieve the file's 'driver_id' value @@ -3509,23 +3646,35 @@ done: FUNC_LEAVE(ret_value); } /* end H5F_get_fileno() */ - + +/*------------------------------------------------------------------------- + * Function: H5F_get_base_addr + * + * Purpose: Quick and dirty routine to retrieve the file's 'base_addr' value + * (Mainly added to stop non-file routines from poking about in the + * H5F_t data structure) + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Raymond Lu <slu@ncsa.uiuc.edu> + * December 20, 2002 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ haddr_t H5F_get_base_addr(const H5F_t *f) { - haddr_t ret_value; - - FUNC_ENTER_NOAPI(H5F_get_base_addr, FAIL); + /* Use FUNC_ENTER_NOINIT here to avoid performance issues */ + FUNC_ENTER_NOINIT(H5F_get_base_addr); assert(f); assert(f->shared); - /* Retrieve the file's base address */ - ret_value = f->shared->base_addr; - done: - FUNC_LEAVE(ret_value); -} + FUNC_LEAVE(f->shared->base_addr); +} /* end H5F_get_bass_addr() */ /*------------------------------------------------------------------------- @@ -3800,9 +3949,6 @@ H5F_debug(H5F_t *f, haddr_t UNUSED addr, FILE * stream, int indent, int fwidth) { hsize_t userblock_size; - int btree_k[H5B_NUM_BTREE_ID]; - unsigned sym_leaf_k; - size_t sizeof_addr, sizeof_size; int boot_vers, freespace_vers, obj_dir_vers, share_head_vers; H5P_genplist_t *plist; /* Property list */ herr_t ret_value=SUCCEED; /* Return value */ @@ -3822,15 +3968,6 @@ H5F_debug(H5F_t *f, haddr_t UNUSED addr, FILE * stream, int indent, if(H5P_get(plist, H5F_CRT_USER_BLOCK_NAME, &userblock_size)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get user block size"); - if(H5P_get(plist, H5F_CRT_SYM_LEAF_NAME, &sym_leaf_k)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for symbol table leaf nodes"); - if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for btree nodes"); - - 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(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 size"); if(H5P_get(plist, H5F_CRT_BOOT_VERS_NAME, &boot_vers)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get boot block version"); @@ -3868,14 +4005,14 @@ H5F_debug(H5F_t *f, haddr_t UNUSED addr, FILE * stream, int indent, HDfprintf(stream, "%*s%-*s %lu bytes\n", indent, "", fwidth, "Size of user block:", (unsigned long) userblock_size); HDfprintf(stream, "%*s%-*s %u bytes\n", indent, "", fwidth, - "Size of file size_t type:", (unsigned) sizeof_size); + "Size of file size_t type:", (unsigned) f->shared->sizeof_size); HDfprintf(stream, "%*s%-*s %u bytes\n", indent, "", fwidth, - "Size of file haddr_t type:", (unsigned) sizeof_addr); + "Size of file haddr_t type:", (unsigned) f->shared->sizeof_addr); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Symbol table leaf node 1/2 rank:", sym_leaf_k); + "Symbol table leaf node 1/2 rank:", f->shared->sym_leaf_k); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Symbol table internal node 1/2 rank:", - (unsigned) (btree_k[H5B_SNODE_ID])); + (unsigned) (f->shared->btree_k[H5B_SNODE_ID])); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Boot block version number:", (unsigned) boot_vers); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, |