summaryrefslogtreecommitdiffstats
path: root/src/H5Fmount.c
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2018-06-07 04:34:11 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2018-06-07 04:34:11 (GMT)
commit91089de53ffe2b950ed309ee486590ed6d2272c2 (patch)
tree0edd6e8f1feb0b71f303d80517f4705b3a2dbc1a /src/H5Fmount.c
parent1a5e7d821bb13b63132af16b74ab58876cbb6545 (diff)
downloadhdf5-91089de53ffe2b950ed309ee486590ed6d2272c2.zip
hdf5-91089de53ffe2b950ed309ee486590ed6d2272c2.tar.gz
hdf5-91089de53ffe2b950ed309ee486590ed6d2272c2.tar.bz2
Normalization with vol_integration branch.
Diffstat (limited to 'src/H5Fmount.c')
-rw-r--r--src/H5Fmount.c270
1 files changed, 132 insertions, 138 deletions
diff --git a/src/H5Fmount.c b/src/H5Fmount.c
index e3a92fd..e01ad55 100644
--- a/src/H5Fmount.c
+++ b/src/H5Fmount.c
@@ -15,21 +15,18 @@
/* Packages needed by this file... */
-#include "H5private.h" /* Generic Functions */
-#include "H5ACprivate.h" /* Metadata cache */
-#include "H5CXprivate.h" /* API Contexts */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5Fpkg.h" /* File access */
-#include "H5Gprivate.h" /* Groups */
-#include "H5Iprivate.h" /* IDs */
-#include "H5Pprivate.h" /* Property lists */
-#include "H5MMprivate.h" /* Memory management */
+#include "H5private.h" /* Generic Functions */
+#include "H5ACprivate.h" /* Metadata cache */
+#include "H5CXprivate.h" /* API Contexts */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Fpkg.h" /* File access */
+#include "H5Gprivate.h" /* Groups */
+#include "H5Iprivate.h" /* IDs */
+#include "H5MMprivate.h" /* Memory management */
+#include "H5Pprivate.h" /* Property lists */
/* PRIVATE PROTOTYPES */
-static herr_t H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child,
- hid_t plist_id);
-static herr_t H5F__unmount(H5G_loc_t *loc, const char *name);
-static void H5F_mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs);
+static void H5F__mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs);
/*-------------------------------------------------------------------------
@@ -47,16 +44,17 @@ static void H5F_mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigne
herr_t
H5F__close_mounts(H5F_t *f)
{
- unsigned u; /* Local index */
- herr_t ret_value=SUCCEED; /* Return value */
+ unsigned u; /* Local index */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_PACKAGE
HDassert(f);
/* Unmount all child files. Loop backwards to avoid having to adjust u when
* a file is unmounted. Note that we rely on unsigned u "wrapping around"
- * to terminate the loop. */
+ * to terminate the loop.
+ */
for (u = f->shared->mtab.nmounts - 1; u < f->shared->mtab.nmounts; u--) {
/* Only unmount children mounted to this top level file structure */
if(f->shared->mtab.child[u].file->parent == f) {
@@ -77,7 +75,7 @@ H5F__close_mounts(H5F_t *f)
f->shared->mtab.nmounts--;
f->nmounts--;
}
- } /* end if */
+ }
HDassert(f->nmounts == 0);
@@ -100,7 +98,7 @@ done:
*
*-------------------------------------------------------------------------
*/
-static herr_t
+herr_t
H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED plist_id)
{
H5G_t *mount_point = NULL; /*mount point group */
@@ -112,9 +110,9 @@ H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED
H5G_name_t mp_path; /* Mount point group hier. path */
H5O_loc_t mp_oloc; /* Mount point object location */
H5G_loc_t root_loc; /* Group location of root of file to mount */
- herr_t ret_value = SUCCEED; /*return value */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_STATIC_VOL
+ FUNC_ENTER_PACKAGE_VOL
HDassert(loc);
HDassert(name && *name);
@@ -162,9 +160,9 @@ H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED
mp_loc.path = H5G_nameof(mount_point);
HDassert(mp_loc.path);
for(ancestor = parent; ancestor; ancestor = ancestor->parent) {
- if(ancestor->shared == child->shared)
- HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount would introduce a cycle")
- } /* end for */
+ if(ancestor->shared == child->shared)
+ HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount would introduce a cycle")
+ }
/* Make certain that the parent & child files have the same "file close degree" */
if(parent->shared->fc_degree != child->shared->fc_degree)
@@ -181,29 +179,29 @@ H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED
while(lt < rt && cmp) {
H5O_loc_t *oloc; /*temporary symbol table entry */
- md = (lt + rt) / 2;
- oloc = H5G_oloc(parent->shared->mtab.child[md].group);
- cmp = H5F_addr_cmp(mp_loc.oloc->addr, oloc->addr);
- if(cmp < 0)
- rt = md;
- else if(cmp > 0)
- lt = md + 1;
- } /* end while */
+ md = (lt + rt) / 2;
+ oloc = H5G_oloc(parent->shared->mtab.child[md].group);
+ cmp = H5F_addr_cmp(mp_loc.oloc->addr, oloc->addr);
+ if(cmp < 0)
+ rt = md;
+ else if(cmp > 0)
+ lt = md + 1;
+ }
if(cmp > 0)
md++;
if(!cmp)
- HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point is already in use")
+ HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point is already in use")
/* Make room in the table */
if(parent->shared->mtab.nmounts >= parent->shared->mtab.nalloc) {
- unsigned n = MAX(16, 2 * parent->shared->mtab.nalloc);
- H5F_mount_t *x = (H5F_mount_t *)H5MM_realloc(parent->shared->mtab.child, n * sizeof(parent->shared->mtab.child[0]));
+ unsigned n = MAX(16, 2 * parent->shared->mtab.nalloc);
+ H5F_mount_t *x = (H5F_mount_t *)H5MM_realloc(parent->shared->mtab.child, n * sizeof(parent->shared->mtab.child[0]));
- if(!x)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for mount table")
- parent->shared->mtab.child = x;
- parent->shared->mtab.nalloc = n;
- } /* end if */
+ if(!x)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for mount table")
+ parent->shared->mtab.child = x;
+ parent->shared->mtab.nalloc = n;
+ }
/* Insert into table */
HDmemmove(parent->shared->mtab.child + md + 1, parent->shared->mtab.child + md,
@@ -228,19 +226,19 @@ H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED
/* We pass H5G_UNKNOWN as object type; search all IDs */
if(H5G_name_replace(NULL, H5G_NAME_MOUNT, mp_loc.oloc->file,
mp_loc.path->full_path_r, root_loc.oloc->file, root_loc.path->full_path_r) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to replace name")
+ HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to replace name")
done:
if(ret_value < 0) {
if(mount_point) {
if(H5G_close(mount_point) < 0)
HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to close mounted group")
- } /* end if */
+ }
else {
if(H5G_loc_free(&mp_loc) < 0)
HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free mount location")
- } /* end else */
- } /* end if */
+ }
+ }
FUNC_LEAVE_NOAPI_VOL(ret_value)
} /* end H5F__mount() */
@@ -264,7 +262,7 @@ done:
*
*-------------------------------------------------------------------------
*/
-static herr_t
+herr_t
H5F__unmount(H5G_loc_t *loc, const char *name)
{
H5G_t *child_group = NULL; /* Child's group in parent mtab */
@@ -279,7 +277,7 @@ H5F__unmount(H5G_loc_t *loc, const char *name)
int child_idx; /* Index of child in parent's mtab */
herr_t ret_value = SUCCEED; /*return value */
- FUNC_ENTER_STATIC_VOL
+ FUNC_ENTER_PACKAGE_VOL
HDassert(loc);
HDassert(name && *name);
@@ -304,41 +302,43 @@ H5F__unmount(H5G_loc_t *loc, const char *name)
if(child->parent && H5F_addr_eq(mp_oloc.addr, mnt_oloc->addr)) {
unsigned u; /*counters */
- /*
- * We've been given the root group of the child. We do a reverse
- * lookup in the parent's mount table to find the correct entry.
- */
- parent = child->parent;
- for(u = 0; u < parent->shared->mtab.nmounts; u++) {
- if(parent->shared->mtab.child[u].file->shared == child->shared) {
+ /*
+ * We've been given the root group of the child. We do a reverse
+ * lookup in the parent's mount table to find the correct entry.
+ */
+ parent = child->parent;
+ for(u = 0; u < parent->shared->mtab.nmounts; u++) {
+ if(parent->shared->mtab.child[u].file->shared == child->shared) {
/* Found the correct index */
child_idx = (int)u;
break;
- } /* end if */
- } /* end for */
- } else {
+ }
+ }
+ }
+ else {
unsigned lt, rt, md = 0; /*binary search indices */
int cmp; /*binary search comparison value*/
- /*
- * We've been given the mount point in the parent. We use a binary
- * search in the parent to locate the mounted file, if any.
- */
- parent = child; /*we guessed wrong*/
- lt = 0;
- rt = parent->shared->mtab.nmounts;
- cmp = -1;
- while(lt < rt && cmp) {
- md = (lt + rt) / 2;
- mnt_oloc = H5G_oloc(parent->shared->mtab.child[md].group);
- cmp = H5F_addr_cmp(mp_oloc.addr, mnt_oloc->addr);
- if (cmp<0)
- rt = md;
- else
- lt = md + 1;
- } /* end while */
- if(cmp)
- HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "not a mount point")
+ /* We've been given the mount point in the parent. We use a binary
+ * search in the parent to locate the mounted file, if any.
+ */
+ parent = child; /*we guessed wrong*/
+ lt = 0;
+ rt = parent->shared->mtab.nmounts;
+ cmp = -1;
+
+ while(lt < rt && cmp) {
+ md = (lt + rt) / 2;
+ mnt_oloc = H5G_oloc(parent->shared->mtab.child[md].group);
+ cmp = H5F_addr_cmp(mp_oloc.addr, mnt_oloc->addr);
+ if (cmp<0)
+ rt = md;
+ else
+ lt = md + 1;
+ }
+
+ if(cmp)
+ HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "not a mount point")
/* Found the correct index, set the info about the child */
child_idx = (int)md;
@@ -426,15 +426,12 @@ H5F_is_mount(const H5F_t *file)
/*-------------------------------------------------------------------------
- * Function: H5Fmount
+ * Function: H5Fmount
*
- * Purpose: Mount file CHILD_ID onto the group specified by LOC_ID and
- * NAME using mount properties PLIST_ID.
+ * Purpose: Mount file CHILD_ID onto the group specified by LOC_ID and
+ * NAME using mount properties PLIST_ID.
*
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Robb Matzke
- * Tuesday, October 6, 1998
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -443,18 +440,18 @@ H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id)
{
H5G_loc_t loc;
H5F_t *child = NULL;
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE4("e", "i*sii", loc_id, name, child_id, plist_id);
/* Check arguments */
if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
if(!name || !*name)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
if(NULL == (child = (H5F_t *)H5I_object_verify(child_id, H5I_FILE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file")
if(H5P_DEFAULT == plist_id)
plist_id = H5P_FILE_MOUNT_DEFAULT;
else
@@ -465,9 +462,9 @@ H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id)
if(H5CX_set_loc(loc_id) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info")
- /* Do the mount */
+ /* Perform the mount operation */
if(H5F__mount(&loc, name, child, plist_id) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file")
+ HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file")
done:
FUNC_LEAVE_API(ret_value)
@@ -475,21 +472,18 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Funmount
- *
- * Purpose: Given a mount point, dissassociate the mount point's file
- * from the file mounted there. Do not close either file.
+ * Function: H5Funmount
*
- * The mount point can either be the group in the parent or the
- * root group of the mounted file (both groups have the same
- * name). If the mount point was opened before the mount then
- * it's the group in the parent, but if it was opened after the
- * mount then it's the root group of the child.
+ * Purpose: Given a mount point, dissassociate the mount point's file
+ * from the file mounted there. Do not close either file.
*
- * Return: Non-negative on success/Negative on failure
+ * The mount point can either be the group in the parent or the
+ * root group of the mounted file (both groups have the same
+ * name). If the mount point was opened before the mount then
+ * it's the group in the parent, but if it was opened after the
+ * mount then it's the root group of the child.
*
- * Programmer: Robb Matzke
- * Tuesday, October 6, 1998
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -497,16 +491,16 @@ herr_t
H5Funmount(hid_t loc_id, const char *name)
{
H5G_loc_t loc;
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE2("e", "i*s", loc_id, name);
/* Check args */
if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
if(!name || !*name)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
/* Set up collective metadata if appropriate */
if(H5CX_set_loc(loc_id) < 0)
@@ -514,7 +508,7 @@ H5Funmount(hid_t loc_id, const char *name)
/* Unmount */
if(H5F__unmount(&loc, name) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file")
+ HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file")
done:
FUNC_LEAVE_API(ret_value)
@@ -522,12 +516,12 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5F_mount_count_ids_recurse
+ * Function: H5F__mount_count_ids_recurse
*
- * Purpose: Helper routine for counting number of open IDs in mount
+ * Purpose: Helper routine for counting number of open IDs in mount
* hierarchy.
*
- * Return: <none>
+ * Return: void
*
* Programmer: Quincey Koziol
* Tuesday, July 19, 2005
@@ -535,11 +529,11 @@ done:
*-------------------------------------------------------------------------
*/
static void
-H5F_mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs)
+H5F__mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs)
{
unsigned u; /* Local index value */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Sanity check */
HDassert(f);
@@ -564,20 +558,20 @@ H5F_mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_obj
if(H5G_get_shared_count(f->shared->mtab.child[u].group) > 1)
*nopen_objs += 1;
- H5F_mount_count_ids_recurse(f->shared->mtab.child[u].file, nopen_files, nopen_objs);
+ H5F__mount_count_ids_recurse(f->shared->mtab.child[u].file, nopen_files, nopen_objs);
}
- } /* end for */
+ }
FUNC_LEAVE_NOAPI_VOID
-} /* end H5F_mount_count_ids_recurse() */
+} /* end H5F__mount_count_ids_recurse() */
/*-------------------------------------------------------------------------
- * Function: H5F_mount_count_ids
+ * Function: H5F__mount_count_ids
*
- * Purpose: Count the number of open file & object IDs in a mount hierarchy
+ * Purpose: Count the number of open file & object IDs in a mount hierarchy
*
- * Return: SUCCEED/FAIL
+ * Return: SUCCEED/FAIL
*
* Programmer: Quincey Koziol
* Tues, July 19, 2005
@@ -585,9 +579,9 @@ H5F_mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_obj
*-------------------------------------------------------------------------
*/
herr_t
-H5F_mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs)
+H5F__mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_PACKAGE_NOERR
/* Sanity check */
HDassert(f);
@@ -599,10 +593,10 @@ H5F_mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs)
f = f->parent;
/* Count open IDs in the hierarchy */
- H5F_mount_count_ids_recurse(f, nopen_files, nopen_objs);
+ H5F__mount_count_ids_recurse(f, nopen_files, nopen_objs);
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5F_mount_count_ids() */
+} /* end H5F__mount_count_ids() */
/*-------------------------------------------------------------------------
@@ -648,11 +642,11 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5F_flush_mounts
+ * Function: H5F_flush_mounts
*
- * Purpose: Flush a mount hierarchy
+ * Purpose: Flush a mount hierarchy
*
- * Return: SUCCEED/FAIL
+ * Return: SUCCEED/FAIL
*
* Programmer: Quincey Koziol
* Fri, August 21, 2009
@@ -715,22 +709,22 @@ H5F_traverse_mount(H5O_loc_t *oloc/*in,out*/)
* of file2, which is mounted somewhere in file3.
*/
do {
- /*
- * Use a binary search to find the potential mount point in the mount
- * table for the parent
- */
- lt = 0;
- rt = parent->shared->mtab.nmounts;
- cmp = -1;
- while(lt < rt && cmp) {
- md = (lt + rt) / 2;
- mnt_oloc = H5G_oloc(parent->shared->mtab.child[md].group);
- cmp = H5F_addr_cmp(oloc->addr, mnt_oloc->addr);
- if(cmp < 0)
- rt = md;
- else
- lt = md + 1;
- } /* end while */
+ /*
+ * Use a binary search to find the potential mount point in the mount
+ * table for the parent
+ */
+ lt = 0;
+ rt = parent->shared->mtab.nmounts;
+ cmp = -1;
+ while(lt < rt && cmp) {
+ md = (lt + rt) / 2;
+ mnt_oloc = H5G_oloc(parent->shared->mtab.child[md].group);
+ cmp = H5F_addr_cmp(oloc->addr, mnt_oloc->addr);
+ if(cmp < 0)
+ rt = md;
+ else
+ lt = md + 1;
+ }
/* Copy root info over to ENT */
if(0 == cmp) {