summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authormainzer <mainzer#hdfgroup.org>2020-08-13 16:31:16 (GMT)
committermainzer <mainzer#hdfgroup.org>2020-08-13 16:31:16 (GMT)
commit32024169364ddf031df8da879c45c3647a4d6135 (patch)
tree1dc1fa889c8ddba83b9794734e7d7e67b8fe7ab6 /src
parent33f35183cbfdde70ee8f803acb5b735ad4dfe086 (diff)
parente291fd31fd480dc4900d056e0e08df002e85a3f2 (diff)
downloadhdf5-32024169364ddf031df8da879c45c3647a4d6135.zip
hdf5-32024169364ddf031df8da879c45c3647a4d6135.tar.gz
hdf5-32024169364ddf031df8da879c45c3647a4d6135.tar.bz2
Merge branch 'develop' into mdc_sl_opt
Diffstat (limited to 'src')
-rw-r--r--src/H5AC.c72
-rw-r--r--src/H5EAdbg.c2
-rw-r--r--src/H5F.c149
-rw-r--r--src/H5FD.c10
-rw-r--r--src/H5FDcore.c42
-rw-r--r--src/H5FDdirect.c59
-rw-r--r--src/H5FDfamily.c6
-rw-r--r--src/H5FDlog.c48
-rw-r--r--src/H5FDmulti.c4
-rw-r--r--src/H5FDsec2.c60
-rw-r--r--src/H5FDsplitter.c31
-rw-r--r--src/H5FDstdio.c53
-rw-r--r--src/H5Fint.c266
-rw-r--r--src/H5Fpkg.h7
-rw-r--r--src/H5Fprivate.h2
-rw-r--r--src/H5Ftest.c33
-rw-r--r--src/H5I.c120
-rw-r--r--src/H5Oattr.c29
-rw-r--r--src/H5Odtype.c7
-rw-r--r--src/H5Ofsinfo.c2
-rw-r--r--src/H5PLpkg.h2
-rw-r--r--src/H5Pfapl.c127
-rw-r--r--src/H5Ppublic.h2
-rw-r--r--src/H5Rint.c4
-rw-r--r--src/H5Spoint.c2
-rw-r--r--src/H5T.c4
-rw-r--r--src/H5Tconv.c2
-rw-r--r--src/H5Tdbg.c12
-rw-r--r--src/H5Tpkg.h2
-rw-r--r--src/H5Tref.c31
-rw-r--r--src/H5VLint.c20
-rw-r--r--src/H5Z.c126
-rw-r--r--src/H5err.txt2
-rw-r--r--src/H5private.h4
-rw-r--r--src/H5public.h16
-rw-r--r--src/H5system.c14
-rw-r--r--src/H5trace.c86
-rw-r--r--src/libhdf5.settings.in1
38 files changed, 967 insertions, 492 deletions
diff --git a/src/H5AC.c b/src/H5AC.c
index 59cabde..52f45c3 100644
--- a/src/H5AC.c
+++ b/src/H5AC.c
@@ -138,7 +138,7 @@ static const H5AC_class_t *const H5AC_class_s[] = {
/*-------------------------------------------------------------------------
* Function: H5AC_init
*
- * Purpose: Initialize the interface from some other layer.
+ * Purpose: Initialize the interface from some other layer.
*
* Return: Success: non-negative
* Failure: negative
@@ -983,9 +983,10 @@ H5AC_mark_entry_dirty(void *thing)
done:
/* If currently logging, generate a message */
- if(cache_ptr->log_info->logging)
- if(H5C_log_write_mark_entry_dirty_msg(cache_ptr, entry_ptr, ret_value) < 0)
- HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
+ if(cache_ptr != NULL && cache_ptr->log_info != NULL)
+ if(cache_ptr->log_info->logging)
+ if(H5C_log_write_mark_entry_dirty_msg(cache_ptr, entry_ptr, ret_value) < 0)
+ HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
FUNC_LEAVE_NOAPI(ret_value)
} /* H5AC_mark_entry_dirty() */
@@ -1036,9 +1037,10 @@ H5AC_mark_entry_clean(void *thing)
done:
/* If currently logging, generate a message */
- if(cache_ptr->log_info->logging)
- if(H5C_log_write_mark_entry_clean_msg(cache_ptr, entry_ptr, ret_value) < 0)
- HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
+ if(cache_ptr != NULL && cache_ptr->log_info != NULL)
+ if(cache_ptr->log_info->logging)
+ if(H5C_log_write_mark_entry_clean_msg(cache_ptr, entry_ptr, ret_value) < 0)
+ HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
FUNC_LEAVE_NOAPI(ret_value)
} /* H5AC_mark_entry_clean() */
@@ -1078,9 +1080,10 @@ H5AC_mark_entry_unserialized(void *thing)
done:
/* If currently logging, generate a message */
- if(cache_ptr->log_info->logging)
- if(H5C_log_write_mark_unserialized_entry_msg(cache_ptr, entry_ptr, ret_value) < 0)
- HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
+ if(cache_ptr != NULL && cache_ptr->log_info != NULL)
+ if(cache_ptr->log_info->logging)
+ if(H5C_log_write_mark_unserialized_entry_msg(cache_ptr, entry_ptr, ret_value) < 0)
+ HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
FUNC_LEAVE_NOAPI(ret_value)
} /* H5AC_mark_entry_unserialized() */
@@ -1119,9 +1122,10 @@ H5AC_mark_entry_serialized(void *thing)
done:
/* If currently logging, generate a message */
- if(cache_ptr->log_info->logging)
- if(H5C_log_write_mark_serialized_entry_msg(cache_ptr, entry_ptr, ret_value) < 0)
- HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
+ if(cache_ptr != NULL && cache_ptr->log_info != NULL)
+ if(cache_ptr->log_info->logging)
+ if(H5C_log_write_mark_serialized_entry_msg(cache_ptr, entry_ptr, ret_value) < 0)
+ HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
FUNC_LEAVE_NOAPI(ret_value)
} /* H5AC_mark_entry_serialized() */
@@ -1221,9 +1225,10 @@ H5AC_pin_protected_entry(void *thing)
done:
/* If currently logging, generate a message */
- if(cache_ptr->log_info->logging)
- if(H5C_log_write_pin_entry_msg(cache_ptr, entry_ptr, ret_value) < 0)
- HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
+ if(cache_ptr != NULL && cache_ptr->log_info != NULL)
+ if(cache_ptr->log_info->logging)
+ if(H5C_log_write_pin_entry_msg(cache_ptr, entry_ptr, ret_value) < 0)
+ HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
FUNC_LEAVE_NOAPI(ret_value)
} /* H5AC_pin_protected_entry() */
@@ -1406,9 +1411,10 @@ H5AC_create_flush_dependency(void * parent_thing, void * child_thing)
done:
/* If currently logging, generate a message */
- if(cache_ptr->log_info->logging)
- if(H5C_log_write_create_fd_msg(cache_ptr, (H5AC_info_t *)parent_thing, (H5AC_info_t *)child_thing, ret_value) < 0)
- HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
+ if(cache_ptr != NULL && cache_ptr->log_info != NULL)
+ if(cache_ptr->log_info->logging)
+ if(H5C_log_write_create_fd_msg(cache_ptr, (H5AC_info_t *)parent_thing, (H5AC_info_t *)child_thing, ret_value) < 0)
+ HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
FUNC_LEAVE_NOAPI(ret_value)
} /* H5AC_create_flush_dependency() */
@@ -1541,9 +1547,10 @@ H5AC_resize_entry(void *thing, size_t new_size)
done:
/* If currently logging, generate a message */
- if(cache_ptr->log_info->logging)
- if(H5C_log_write_resize_entry_msg(cache_ptr, entry_ptr, new_size, ret_value) < 0)
- HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
+ if(cache_ptr != NULL && cache_ptr->log_info != NULL)
+ if(cache_ptr->log_info->logging)
+ if(H5C_log_write_resize_entry_msg(cache_ptr, entry_ptr, new_size, ret_value) < 0)
+ HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
FUNC_LEAVE_NOAPI(ret_value)
} /* H5AC_resize_entry() */
@@ -1584,9 +1591,10 @@ H5AC_unpin_entry(void *thing)
done:
/* If currently logging, generate a message */
- if(cache_ptr->log_info->logging)
- if(H5C_log_write_unpin_entry_msg(cache_ptr, entry_ptr, ret_value) < 0)
- HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
+ if(cache_ptr != NULL && cache_ptr->log_info != NULL)
+ if(cache_ptr->log_info->logging)
+ if(H5C_log_write_unpin_entry_msg(cache_ptr, entry_ptr, ret_value) < 0)
+ HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
FUNC_LEAVE_NOAPI(ret_value)
} /* H5AC_unpin_entry() */
@@ -1627,9 +1635,10 @@ H5AC_destroy_flush_dependency(void * parent_thing, void * child_thing)
done:
/* If currently logging, generate a message */
- if(cache_ptr->log_info->logging)
- if(H5C_log_write_destroy_fd_msg(cache_ptr, (H5AC_info_t *)parent_thing, (H5AC_info_t *)child_thing, ret_value) < 0)
- HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
+ if(cache_ptr != NULL && cache_ptr->log_info != NULL)
+ if(cache_ptr->log_info->logging)
+ if(H5C_log_write_destroy_fd_msg(cache_ptr, (H5AC_info_t *)parent_thing, (H5AC_info_t *)child_thing, ret_value) < 0)
+ HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
FUNC_LEAVE_NOAPI(ret_value)
} /* H5AC_destroy_flush_dependency() */
@@ -2805,9 +2814,10 @@ H5AC_remove_entry(void *_entry)
done:
/* If currently logging, generate a message */
- if(cache->log_info->logging)
- if(H5C_log_write_remove_entry_msg(cache, entry, ret_value) < 0)
- HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
+ if(cache != NULL && cache->log_info != NULL)
+ if(cache->log_info->logging)
+ if(H5C_log_write_remove_entry_msg(cache, entry, ret_value) < 0)
+ HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
FUNC_LEAVE_NOAPI(ret_value)
} /* H5AC_remove_entry() */
diff --git a/src/H5EAdbg.c b/src/H5EAdbg.c
index 20c6a4d..e5b68be 100644
--- a/src/H5EAdbg.c
+++ b/src/H5EAdbg.c
@@ -295,7 +295,7 @@ CATCH
END_FUNC(PKG) /* end H5EA__iblock_debug() */
-
+
/*-------------------------------------------------------------------------
* Function: H5EA__sblock_debug
*
diff --git a/src/H5F.c b/src/H5F.c
index 9d426ac..c6db109 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -73,8 +73,6 @@ typedef struct {
/* Local Prototypes */
/********************/
-static herr_t H5F__close_cb(H5VL_object_t *file_vol_obj);
-
/* Callback for getting object counts in a file */
static int H5F__get_all_count_cb(void H5_ATTR_UNUSED *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void *key);
@@ -86,9 +84,6 @@ static int H5F__get_all_ids_cb(void H5_ATTR_UNUSED *obj_ptr, hid_t obj_id, void
/* Package Variables */
/*********************/
-/* Package initialization variable */
-hbool_t H5_PKG_INIT_VAR = FALSE;
-
/*****************************/
/* Library Private Variables */
@@ -105,150 +100,6 @@ H5FL_EXTERN(H5VL_t);
/* Declare a free list to manage the H5VL_object_t struct */
H5FL_EXTERN(H5VL_object_t);
-/* File ID class */
-static const H5I_class_t H5I_FILE_CLS[1] = {{
- H5I_FILE, /* ID class value */
- 0, /* Class flags */
- 0, /* # of reserved IDs for class */
- (H5I_free_t)H5F__close_cb /* Callback routine for closing objects of this class */
-}};
-
-
-
-/*-------------------------------------------------------------------------
- * Function: H5F_init
- *
- * Purpose: Initialize the interface from some other layer.
- *
- * Return: Success: non-negative
- *
- * Failure: negative
- *-------------------------------------------------------------------------
- */
-herr_t
-H5F_init(void)
-{
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
- /* FUNC_ENTER() does all the work */
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5F_init() */
-
-
-/*--------------------------------------------------------------------------
-NAME
- H5F__init_package -- Initialize interface-specific information
-USAGE
- herr_t H5F__init_package()
-RETURNS
- Non-negative on success/Negative on failure
-DESCRIPTION
- Initializes any interface-specific data or routines.
-
---------------------------------------------------------------------------*/
-herr_t
-H5F__init_package(void)
-{
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_PACKAGE
-
- /*
- * Initialize the atom group for the file IDs.
- */
- if(H5I_register_type(H5I_FILE_CLS) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to initialize interface")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* H5F__init_package() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5F_term_package
- *
- * Purpose: Terminate this interface: free all memory and reset global
- * variables to their initial values. Release all ID groups
- * associated with this interface.
- *
- * Return: Success: Positive if anything was done that might
- * have affected other interfaces;
- * zero otherwise.
- *
- * Failure: Never fails
- *
- *-------------------------------------------------------------------------
- */
-int
-H5F_term_package(void)
-{
- int n = 0;
-
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
- if(H5_PKG_INIT_VAR) {
- if(H5I_nmembers(H5I_FILE) > 0) {
- (void)H5I_clear_type(H5I_FILE, FALSE, FALSE);
- n++; /*H5I*/
- } /* end if */
- else {
- /* Make certain we've cleaned up all the shared file objects */
- H5F_sfile_assert_num(0);
-
- /* Destroy the file object id group */
- n += (H5I_dec_type_ref(H5I_FILE) > 0);
-
- /* Mark closed */
- if(0 == n)
- H5_PKG_INIT_VAR = FALSE;
- } /* end else */
- } /* end if */
-
- FUNC_LEAVE_NOAPI(n)
-} /* end H5F_term_package() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5F__close_cb
- *
- * Purpose: Closes a file or causes the close operation to be pended.
- * This function is called from the API and gets called
- * by H5Fclose->H5I_dec_ref->H5F__close_cb when H5I_dec_ref()
- * decrements the file ID reference count to zero. The file ID
- * is removed from the H5I_FILE group by H5I_dec_ref() just
- * before H5F__close_cb() is called. If there are open object
- * headers then the close is pended by moving the file to the
- * H5I_FILE_CLOSING ID group (the f->closing contains the ID
- * assigned to file).
- *
- * Return: SUCCEED/FAIL
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5F__close_cb(H5VL_object_t *file_vol_obj)
-{
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_STATIC
-
- /* Sanity check */
- HDassert(file_vol_obj);
-
- /* Close the file */
- if(H5VL_file_close(file_vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close file")
-
- /* Free the VOL object */
- if(H5VL_free_object(file_vol_obj) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to free VOL object")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5F__close_cb() */
/*-------------------------------------------------------------------------
diff --git a/src/H5FD.c b/src/H5FD.c
index 2e80c7f..991b7b7 100644
--- a/src/H5FD.c
+++ b/src/H5FD.c
@@ -1436,7 +1436,7 @@ done:
* constant H5P_DEFAULT). The bytes to be written come from the
* buffer BUF.
*
- * Return: SNon-negative on success/Negative on failure
+ * Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
@@ -1642,7 +1642,7 @@ H5FDlock(H5FD_t *file, hbool_t rw)
/* Call private function */
if(H5FD_lock(file, rw) < 0)
- HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "file lock request failed")
+ HGOTO_ERROR(H5E_VFL, H5E_CANTLOCKFILE, FAIL, "file lock request failed")
done:
FUNC_LEAVE_API(ret_value)
@@ -1672,7 +1672,7 @@ H5FD_lock(H5FD_t *file, hbool_t rw)
/* Dispatch to driver */
if(file->cls->lock && (file->cls->lock)(file, rw) < 0)
- HGOTO_ERROR(H5E_VFL, H5E_CANTUPDATE, FAIL, "driver lock request failed")
+ HGOTO_ERROR(H5E_VFL, H5E_CANTLOCKFILE, FAIL, "driver lock request failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1704,7 +1704,7 @@ H5FDunlock(H5FD_t *file)
/* Call private function */
if(H5FD_unlock(file) < 0)
- HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "file unlock request failed")
+ HGOTO_ERROR(H5E_VFL, H5E_CANTUNLOCKFILE, FAIL, "file unlock request failed")
done:
FUNC_LEAVE_API(ret_value)
@@ -1733,7 +1733,7 @@ H5FD_unlock(H5FD_t *file)
/* Dispatch to driver */
if(file->cls->unlock && (file->cls->unlock)(file) < 0)
- HGOTO_ERROR(H5E_VFL, H5E_CANTUPDATE, FAIL, "driver unlock request failed")
+ HGOTO_ERROR(H5E_VFL, H5E_CANTUNLOCKFILE, FAIL, "driver unlock request failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5FDcore.c b/src/H5FDcore.c
index 0551dd0..9a82e2b 100644
--- a/src/H5FDcore.c
+++ b/src/H5FDcore.c
@@ -36,6 +36,9 @@
/* The driver identification number, initialized at runtime */
static hid_t H5FD_CORE_g = 0;
+/* Whether to ignore file locks when disabled (env var value) */
+static htri_t ignore_disabled_file_locks_s = FAIL;
+
/* The skip list node type. Represents a region in the file. */
typedef struct H5FD_core_region_t {
haddr_t start; /* Start address of the region */
@@ -56,6 +59,7 @@ typedef struct H5FD_core_t {
hbool_t backing_store; /* write to file name on flush */
hbool_t write_tracking; /* Whether to track writes */
size_t bstore_page_size; /* backing store page size */
+ hbool_t ignore_disabled_file_locks;
int fd; /* backing store file descriptor */
/* Information for determining uniqueness of a file with a backing store */
#ifndef H5_HAVE_WIN32_API
@@ -412,10 +416,20 @@ done:
static herr_t
H5FD__init_package(void)
{
+ char *lock_env_var = NULL; /* Environment variable pointer */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI_NOINIT
+ /* Check the use disabled file locks environment variable */
+ lock_env_var = HDgetenv("HDF5_USE_FILE_LOCKING");
+ if(lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT"))
+ ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */
+ else if(lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1")))
+ ignore_disabled_file_locks_s = FALSE; /* Override: Don't ignore disabled locks */
+ else
+ ignore_disabled_file_locks_s = FAIL; /* Environment variable not set, or not set correctly */
+
if(H5FD_core_init() < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize core VFD")
@@ -798,6 +812,16 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr
/* Save file image callbacks */
file->fi_callbacks = file_image_info.callbacks;
+ /* Check the file locking flags in the fapl */
+ if(ignore_disabled_file_locks_s != FAIL)
+ /* The environment variable was set, so use that preferentially */
+ file->ignore_disabled_file_locks = ignore_disabled_file_locks_s;
+ else {
+ /* Use the value in the property list */
+ if(H5P_get(plist, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_NAME, &file->ignore_disabled_file_locks) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "can't get ignore disabled file locks property")
+ }
+
if(fd >= 0) {
/* Retrieve information for determining uniqueness of file */
#ifdef H5_HAVE_WIN32_API
@@ -1615,8 +1639,12 @@ H5FD_core_lock(H5FD_t *_file, hbool_t rw)
/* Place a non-blocking lock on the file */
if(HDflock(file->fd, lock_flags | LOCK_NB) < 0) {
- if(ENOSYS == errno)
- HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING environment variable to override)")
+ if(file->ignore_disabled_file_locks && ENOSYS == errno) {
+ /* When errno is set to ENOSYS, the file system does not support
+ * locking, so ignore it.
+ */
+ errno = 0;
+ }
else
HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to lock file")
} /* end if */
@@ -1652,11 +1680,15 @@ H5FD_core_unlock(H5FD_t *_file)
if(file->fd >= 0) {
if(HDflock(file->fd, LOCK_UN) < 0) {
- if(ENOSYS == errno)
- HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING environment variable to override)")
+ if(file->ignore_disabled_file_locks && ENOSYS == errno) {
+ /* When errno is set to ENOSYS, the file system does not support
+ * locking, so ignore it.
+ */
+ errno = 0;
+ }
else
HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to unlock file")
- } /* end if */
+ }
} /* end if */
diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c
index 34c4346..9839269 100644
--- a/src/H5FDdirect.c
+++ b/src/H5FDdirect.c
@@ -38,6 +38,9 @@
/* The driver identification number, initialized at runtime */
static hid_t H5FD_DIRECT_g = 0;
+/* Whether to ignore file locks when disabled (env var value) */
+static htri_t ignore_disabled_file_locks_s = FAIL;
+
/* File operations */
#define OP_UNKNOWN 0
#define OP_READ 1
@@ -71,6 +74,7 @@ typedef struct H5FD_direct_t {
haddr_t pos; /*current file I/O position */
int op; /*last operation */
H5FD_direct_fapl_t fa; /*file access properties */
+ hbool_t ignore_disabled_file_locks;
#ifndef H5_HAVE_WIN32_API
/*
* On most systems the combination of device and i-node number uniquely
@@ -193,10 +197,20 @@ DESCRIPTION
static herr_t
H5FD__init_package(void)
{
+ char *lock_env_var = NULL; /* Environment variable pointer */
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
+ /* Check the use disabled file locks environment variable */
+ lock_env_var = HDgetenv("HDF5_USE_FILE_LOCKING");
+ if(lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT"))
+ ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */
+ else if(lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1")))
+ ignore_disabled_file_locks_s = FALSE; /* Override: Don't ignore disabled locks */
+ else
+ ignore_disabled_file_locks_s = FAIL; /* Environment variable not set, or not set correctly */
+
if(H5FD_direct_init() < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize direct VFD")
@@ -518,6 +532,16 @@ H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxadd
file->fa.fbsize = fa->fbsize;
file->fa.cbsize = fa->cbsize;
+ /* Check the file locking flags in the fapl */
+ if(ignore_disabled_file_locks_s != FAIL)
+ /* The environment variable was set, so use that preferentially */
+ file->ignore_disabled_file_locks = ignore_disabled_file_locks_s;
+ else {
+ /* Use the value in the property list */
+ if(H5P_get(plist, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_NAME, &file->ignore_disabled_file_locks) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "can't get ignore disabled file locks property")
+ }
+
/* Try to decide if data alignment is required. The reason to check it here
* is to handle correctly the case that the file is in a different file system
* than the one where the program is running.
@@ -1334,17 +1358,28 @@ done:
static herr_t
H5FD_direct_lock(H5FD_t *_file, hbool_t rw)
{
- H5FD_direct_t *file = (H5FD_direct_t*)_file; /* VFD file struct */
- const int lock = rw ? LOCK_EX : LOCK_SH;
- herr_t ret_value = SUCCEED; /* Return value */
+ H5FD_direct_t *file = (H5FD_direct_t*)_file; /* VFD file struct */
+ int lock_flags; /* file locking flags */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
HDassert(file);
- /* Place the lock with non-blocking */
- if(HDflock(file->fd, lock | LOCK_NB) < 0)
- HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to flock file")
+ /* Set exclusive or shared lock based on rw status */
+ lock_flags = rw ? LOCK_EX : LOCK_SH;
+
+ /* Place a non-blocking lock on the file */
+ if(HDflock(file->fd, lock_flags | LOCK_NB) < 0) {
+ if(file->ignore_disabled_file_locks && ENOSYS == errno) {
+ /* When errno is set to ENOSYS, the file system does not support
+ * locking, so ignore it.
+ */
+ errno = 0;
+ }
+ else
+ HSYS_GOTO_ERROR(H5E_VFL, H5E_CANTLOCKFILE, FAIL, "unable to lock file")
+ }
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1372,8 +1407,16 @@ H5FD_direct_unlock(H5FD_t *_file)
HDassert(file);
- if(HDflock(file->fd, LOCK_UN) < 0)
- HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to flock (unlock) file")
+ if(HDflock(file->fd, LOCK_UN) < 0) {
+ if(file->ignore_disabled_file_locks && ENOSYS == errno) {
+ /* When errno is set to ENOSYS, the file system does not support
+ * locking, so ignore it.
+ */
+ errno = 0;
+ }
+ else
+ HSYS_GOTO_ERROR(H5E_VFL, H5E_CANTUNLOCKFILE, FAIL, "unable to unlock file")
+ }
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c
index d110ef7..154878e 100644
--- a/src/H5FDfamily.c
+++ b/src/H5FDfamily.c
@@ -1372,9 +1372,9 @@ H5FD_family_lock(H5FD_t *_file, hbool_t rw)
for(v = 0; v < u; v++) {
if(H5FD_unlock(file->memb[v]) < 0)
/* Push error, but keep going */
- HDONE_ERROR(H5E_IO, H5E_CANTUNLOCK, FAIL, "unable to unlock member files")
+ HDONE_ERROR(H5E_IO, H5E_CANTUNLOCKFILE, FAIL, "unable to unlock member files")
} /* end for */
- HGOTO_ERROR(H5E_IO, H5E_CANTLOCK, FAIL, "unable to lock member files")
+ HGOTO_ERROR(H5E_IO, H5E_CANTLOCKFILE, FAIL, "unable to lock member files")
} /* end if */
done:
@@ -1406,7 +1406,7 @@ H5FD_family_unlock(H5FD_t *_file)
for(u = 0; u < file->nmembs; u++)
if(file->memb[u])
if(H5FD_unlock(file->memb[u]) < 0)
- HGOTO_ERROR(H5E_IO, H5E_CANTUNLOCK, FAIL, "unable to unlock member files")
+ HGOTO_ERROR(H5E_IO, H5E_CANTUNLOCKFILE, FAIL, "unable to unlock member files")
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5FDlog.c b/src/H5FDlog.c
index 78b7742..c0506e9 100644
--- a/src/H5FDlog.c
+++ b/src/H5FDlog.c
@@ -40,6 +40,9 @@
/* The driver identification number, initialized at runtime */
static hid_t H5FD_LOG_g = 0;
+/* Whether to ignore file locks when disabled (env var value) */
+static htri_t ignore_disabled_file_locks_s = FAIL;
+
/* Driver-specific file access properties */
typedef struct H5FD_log_fapl_t {
char *logfile; /* Allocated log file name */
@@ -80,6 +83,7 @@ typedef struct H5FD_log_t {
haddr_t eof; /* end of file; current file size */
haddr_t pos; /* current file I/O position */
H5FD_file_op_t op; /* last operation */
+ hbool_t ignore_disabled_file_locks;
char filename[H5FD_MAX_FILENAME_LEN]; /* Copy of file name from open operation */
#ifndef H5_HAVE_WIN32_API
/* On most systems the combination of device and i-node number uniquely
@@ -234,10 +238,20 @@ H5FL_DEFINE_STATIC(H5FD_log_t);
static herr_t
H5FD__init_package(void)
{
+ char *lock_env_var = NULL; /* Environment variable pointer */
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
+ /* Check the use disabled file locks environment variable */
+ lock_env_var = HDgetenv("HDF5_USE_FILE_LOCKING");
+ if(lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT"))
+ ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */
+ else if(lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1")))
+ ignore_disabled_file_locks_s = FALSE; /* Override: Don't ignore disabled locks */
+ else
+ ignore_disabled_file_locks_s = FAIL; /* Environment variable not set, or not set correctly */
+
if(H5FD_log_init() < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize log VFD")
@@ -625,6 +639,16 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
} /* end if */
} /* end if */
+ /* Check the file locking flags in the fapl */
+ if(ignore_disabled_file_locks_s != FAIL)
+ /* The environment variable was set, so use that preferentially */
+ file->ignore_disabled_file_locks = ignore_disabled_file_locks_s;
+ else {
+ /* Use the value in the property list */
+ if(H5P_get(plist, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_NAME, &file->ignore_disabled_file_locks) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "can't get ignore disabled file locks property")
+ }
+
/* Check for non-default FAPL */
if(H5P_FILE_ACCESS_DEFAULT != fapl_id) {
/* This step is for h5repart tool only. If user wants to change file driver from
@@ -1671,11 +1695,15 @@ H5FD_log_lock(H5FD_t *_file, hbool_t rw)
/* Place a non-blocking lock on the file */
if(HDflock(file->fd, lock_flags | LOCK_NB) < 0) {
- if(ENOSYS == errno)
- HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING environment variable to override)")
+ if(file->ignore_disabled_file_locks && ENOSYS == errno) {
+ /* When errno is set to ENOSYS, the file system does not support
+ * locking, so ignore it.
+ */
+ errno = 0;
+ }
else
- HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to lock file")
- } /* end if */
+ HSYS_GOTO_ERROR(H5E_VFL, H5E_CANTLOCKFILE, FAIL, "unable to lock file")
+ }
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1704,11 +1732,15 @@ H5FD_log_unlock(H5FD_t *_file)
HDassert(file);
if(HDflock(file->fd, LOCK_UN) < 0) {
- if(ENOSYS == errno)
- HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING environment variable to override)")
+ if(file->ignore_disabled_file_locks && ENOSYS == errno) {
+ /* When errno is set to ENOSYS, the file system does not support
+ * locking, so ignore it.
+ */
+ errno = 0;
+ }
else
- HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to unlock file")
- } /* end if */
+ HSYS_GOTO_ERROR(H5E_VFL, H5E_CANTUNLOCKFILE, FAIL, "unable to unlock file")
+ }
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c
index 72f4da5..f80cac5 100644
--- a/src/H5FDmulti.c
+++ b/src/H5FDmulti.c
@@ -1856,7 +1856,7 @@ H5FD_multi_lock(H5FD_t *_file, hbool_t rw)
} /* end if */
if(nerrors)
- H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error locking member files", -1)
+ H5Epush_ret(func, H5E_ERR_CLS, H5E_VFL, H5E_CANTLOCKFILE, "error locking member files", -1)
return 0;
} /* H5FD_multi_lock() */
@@ -1893,7 +1893,7 @@ H5FD_multi_unlock(H5FD_t *_file)
} END_MEMBERS;
if(nerrors)
- H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error unlocking member files", -1)
+ H5Epush_ret(func, H5E_ERR_CLS, H5E_VFL, H5E_CANTUNLOCKFILE, "error unlocking member files", -1)
return 0;
} /* H5FD_multi_unlock() */
diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c
index 3551905..12e107f 100644
--- a/src/H5FDsec2.c
+++ b/src/H5FDsec2.c
@@ -39,6 +39,9 @@
/* The driver identification number, initialized at runtime */
static hid_t H5FD_SEC2_g = 0;
+/* Whether to ignore file locks when disabled (env var value) */
+static htri_t ignore_disabled_file_locks_s = FAIL;
+
/* The description of a file belonging to this driver. The 'eoa' and 'eof'
* determine the amount of hdf5 address space in use and the high-water mark
* of the file (the current size of the underlying filesystem file). The
@@ -57,6 +60,7 @@ typedef struct H5FD_sec2_t {
haddr_t eof; /* end of file; current file size */
haddr_t pos; /* current file I/O position */
H5FD_file_op_t op; /* last operation */
+ hbool_t ignore_disabled_file_locks;
char filename[H5FD_MAX_FILENAME_LEN]; /* Copy of file name from open operation */
#ifndef H5_HAVE_WIN32_API
/* On most systems the combination of device and i-node number uniquely
@@ -190,10 +194,20 @@ H5FL_DEFINE_STATIC(H5FD_sec2_t);
static herr_t
H5FD__init_package(void)
{
+ char *lock_env_var = NULL; /* Environment variable pointer */
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
+ /* Check the use disabled file locks environment variable */
+ lock_env_var = HDgetenv("HDF5_USE_FILE_LOCKING");
+ if(lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT"))
+ ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */
+ else if(lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1")))
+ ignore_disabled_file_locks_s = FALSE; /* Override: Don't ignore disabled locks */
+ else
+ ignore_disabled_file_locks_s = FAIL; /* Environment variable not set, or not set correctly */
+
if(H5FD_sec2_init() < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize sec2 VFD")
@@ -219,7 +233,7 @@ done:
hid_t
H5FD_sec2_init(void)
{
- hid_t ret_value = H5I_INVALID_HID; /* Return value */
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
FUNC_ENTER_NOAPI(H5I_INVALID_HID)
@@ -316,6 +330,7 @@ H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
struct _BY_HANDLE_FILE_INFORMATION fileinfo;
#endif
h5_stat_t sb;
+ H5P_genplist_t *plist; /* Property list pointer */
H5FD_t *ret_value = NULL; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -373,17 +388,26 @@ H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
file->inode = sb.st_ino;
#endif /* H5_HAVE_WIN32_API */
+ /* Get the FAPL */
+ if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
+ HGOTO_ERROR(H5E_VFL, H5E_BADTYPE, NULL, "not a file access property list")
+
+ /* Check the file locking flags in the fapl */
+ if(ignore_disabled_file_locks_s != FAIL)
+ /* The environment variable was set, so use that preferentially */
+ file->ignore_disabled_file_locks = ignore_disabled_file_locks_s;
+ else {
+ /* Use the value in the property list */
+ if(H5P_get(plist, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_NAME, &file->ignore_disabled_file_locks) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "can't get ignore disabled file locks property")
+ }
+
/* Retain a copy of the name used to open the file, for possible error reporting */
HDstrncpy(file->filename, name, sizeof(file->filename));
file->filename[sizeof(file->filename) - 1] = '\0';
/* Check for non-default FAPL */
if(H5P_FILE_ACCESS_DEFAULT != fapl_id) {
- H5P_genplist_t *plist; /* Property list pointer */
-
- /* Get the FAPL */
- if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
- HGOTO_ERROR(H5E_VFL, H5E_BADTYPE, NULL, "not a file access property list")
/* This step is for h5repart tool only. If user wants to change file driver from
* family to one that uses single files (sec2, etc.) while using h5repart, this
@@ -961,11 +985,15 @@ H5FD_sec2_lock(H5FD_t *_file, hbool_t rw)
/* Place a non-blocking lock on the file */
if(HDflock(file->fd, lock_flags | LOCK_NB) < 0) {
- if(ENOSYS == errno)
- HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING environment variable to override)")
+ if(file->ignore_disabled_file_locks && ENOSYS == errno) {
+ /* When errno is set to ENOSYS, the file system does not support
+ * locking, so ignore it.
+ */
+ errno = 0;
+ }
else
- HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to lock file")
- } /* end if */
+ HSYS_GOTO_ERROR(H5E_VFL, H5E_CANTLOCKFILE, FAIL, "unable to lock file")
+ }
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -994,11 +1022,15 @@ H5FD_sec2_unlock(H5FD_t *_file)
HDassert(file);
if(HDflock(file->fd, LOCK_UN) < 0) {
- if(ENOSYS == errno)
- HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING environment variable to override)")
+ if(file->ignore_disabled_file_locks && ENOSYS == errno) {
+ /* When errno is set to ENOSYS, the file system does not support
+ * locking, so ignore it.
+ */
+ errno = 0;
+ }
else
- HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to unlock file")
- } /* end if */
+ HSYS_GOTO_ERROR(H5E_VFL, H5E_CANTUNLOCKFILE, FAIL, "unable to unlock file")
+ }
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5FDsplitter.c b/src/H5FDsplitter.c
index 4ed3c4a..eb30b1f 100644
--- a/src/H5FDsplitter.c
+++ b/src/H5FDsplitter.c
@@ -1221,16 +1221,12 @@ H5FD_splitter_lock(H5FD_t *_file, hbool_t rw)
HDassert(file->rw_file);
/* Place the lock on each file */
- if (H5FD_lock(file->rw_file, rw) < 0) {
- HGOTO_ERROR(H5E_VFL, H5E_CANTLOCK, FAIL, "unable to lock R/W file")
- }
- if (file->wo_file != NULL) {
- if (H5FD_lock(file->wo_file, rw) < 0) {
- H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_lock",
- H5E_VFL, H5E_CANTLOCK, FAIL,
- "unable to lock W/O file")
- }
- }
+ if (H5FD_lock(file->rw_file, rw) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTLOCKFILE, FAIL, "unable to lock R/W file")
+
+ if (file->wo_file != NULL)
+ if (H5FD_lock(file->wo_file, rw) < 0)
+ H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_lock", H5E_VFL, H5E_CANTLOCKFILE, FAIL, "unable to lock W/O file")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1260,15 +1256,12 @@ H5FD_splitter_unlock(H5FD_t *_file)
HDassert(file->rw_file);
/* Remove the lock on each file */
- if (H5FD_unlock(file->rw_file) < 0) {
- HGOTO_ERROR(H5E_VFL, H5E_CANTUNLOCK, FAIL, "unable to unlock R/W file")
- }
- if (file->wo_file != NULL) {
- if (H5FD_unlock(file->wo_file) < 0) {
- HGOTO_ERROR(H5E_VFL, H5E_CANTUNLOCK, FAIL,
- "unable to unlock W/O file")
- }
- }
+ if (H5FD_unlock(file->rw_file) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTUNLOCKFILE, FAIL, "unable to unlock R/W file")
+
+ if (file->wo_file != NULL)
+ if (H5FD_unlock(file->wo_file) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTUNLOCKFILE, FAIL, "unable to unlock W/O file")
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c
index d29a1b4..a769e86 100644
--- a/src/H5FDstdio.c
+++ b/src/H5FDstdio.c
@@ -52,6 +52,9 @@
/* The driver identification number, initialized at runtime */
static hid_t H5FD_STDIO_g = 0;
+/* Whether to ignore file locks when disabled (env var value) */
+static htri_t ignore_disabled_file_locks_s = -1;
+
/* The maximum number of bytes which can be written in a single I/O operation */
static size_t H5_STDIO_MAX_IO_BYTES_g = (size_t)-1;
@@ -82,6 +85,7 @@ typedef struct H5FD_stdio_t {
haddr_t eof; /* end of file; current file size */
haddr_t pos; /* current file I/O position */
unsigned write_access; /* Flag to indicate the file was opened with write access */
+ hbool_t ignore_disabled_file_locks;
H5FD_stdio_file_op op; /* last operation */
#ifndef H5_HAVE_WIN32_API
/* On most systems the combination of device and i-node number uniquely
@@ -231,11 +235,23 @@ static const H5FD_class_t H5FD_stdio_g = {
hid_t
H5FD_stdio_init(void)
{
+ char *lock_env_var = NULL; /* Environment variable pointer */
+
/* Clear the error stack */
H5Eclear2(H5E_DEFAULT);
- if (H5I_VFL!=H5Iget_type(H5FD_STDIO_g))
+ /* Check the use disabled file locks environment variable */
+ lock_env_var = getenv("HDF5_USE_FILE_LOCKING");
+ if(lock_env_var && !strcmp(lock_env_var, "BEST_EFFORT"))
+ ignore_disabled_file_locks_s = 1; /* Override: Ignore disabled locks */
+ else if(lock_env_var && (!strcmp(lock_env_var, "TRUE") || !strcmp(lock_env_var, "1")))
+ ignore_disabled_file_locks_s = 0; /* Override: Don't ignore disabled locks */
+ else
+ ignore_disabled_file_locks_s = -1; /* Environment variable not set, or not set correctly */
+
+ if (H5I_VFL != H5Iget_type(H5FD_STDIO_g))
H5FD_STDIO_g = H5FDregister(&H5FD_stdio_g);
+
return H5FD_STDIO_g;
} /* end H5FD_stdio_init() */
@@ -318,7 +334,7 @@ H5Pset_fapl_stdio(hid_t fapl_id)
*-------------------------------------------------------------------------
*/
static H5FD_t *
-H5FD_stdio_open( const char *name, unsigned flags, hid_t /*UNUSED*/ fapl_id,
+H5FD_stdio_open( const char *name, unsigned flags, hid_t fapl_id,
haddr_t maxaddr)
{
FILE *f = NULL;
@@ -396,6 +412,21 @@ H5FD_stdio_open( const char *name, unsigned flags, hid_t /*UNUSED*/ fapl_id,
file->eof = (haddr_t)x;
}
+ /* Check the file locking flags in the fapl */
+ if(ignore_disabled_file_locks_s != -1)
+ /* The environment variable was set, so use that preferentially */
+ file->ignore_disabled_file_locks = ignore_disabled_file_locks_s;
+ else {
+ hbool_t unused;
+
+ /* Use the value in the property list */
+ if(H5Pget_file_locking(fapl_id, &unused, &file->ignore_disabled_file_locks) < 0) {
+ free(file);
+ fclose(f);
+ H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTGET, "unable to get use disabled file locks property", NULL);
+ }
+ }
+
/* Get the file descriptor (needed for truncate and some Windows information) */
#ifdef H5_HAVE_WIN32_API
file->fd = _fileno(file->fp);
@@ -1104,10 +1135,13 @@ H5FD_stdio_lock(H5FD_t *_file, hbool_t rw)
/* Place a non-blocking lock on the file */
if(flock(file->fd, lock_flags | LOCK_NB) < 0) {
- if(ENOSYS == errno)
- H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_FCNTL, "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING environment variable to override)", -1)
+ if(file->ignore_disabled_file_locks && ENOSYS == errno)
+ /* When errno is set to ENOSYS, the file system does not support
+ * locking, so ignore it.
+ */
+ errno = 0;
else
- H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_FCNTL, "file lock failed", -1)
+ H5Epush_ret(func, H5E_ERR_CLS, H5E_VFL, H5E_CANTLOCKFILE, "file lock failed", -1)
} /* end if */
/* Flush the stream */
@@ -1152,10 +1186,13 @@ H5FD_stdio_unlock(H5FD_t *_file)
/* Place a non-blocking lock on the file */
if(flock(file->fd, LOCK_UN) < 0) {
- if(ENOSYS == errno)
- H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_FCNTL, "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING environment variable to override)", -1)
+ if(file->ignore_disabled_file_locks && ENOSYS == errno)
+ /* When errno is set to ENOSYS, the file system does not support
+ * locking, so ignore it.
+ */
+ errno = 0;
else
- H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_FCNTL, "file unlock failed", -1)
+ H5Epush_ret(func, H5E_ERR_CLS, H5E_VFL, H5E_CANTUNLOCKFILE, "file unlock failed", -1)
} /* end if */
#endif /* H5_HAVE_FLOCK */
diff --git a/src/H5Fint.c b/src/H5Fint.c
index 4a4b8b6..d08162e 100644
--- a/src/H5Fint.c
+++ b/src/H5Fint.c
@@ -76,12 +76,14 @@ typedef struct H5F_olist_t {
/* Local Prototypes */
/********************/
+static herr_t H5F__close_cb(H5VL_object_t *file_vol_obj);
static herr_t H5F__set_vol_conn(H5F_t *file);
static herr_t H5F__get_objects(const H5F_t *f, unsigned types, size_t max_index, hid_t *obj_id_list, hbool_t app_ref, size_t *obj_id_count_ptr);
static int H5F__get_objects_cb(void *obj_ptr, hid_t obj_id, void *key);
static herr_t H5F__build_name(const char *prefix, const char *file_name, char **full_name/*out*/);
static char *H5F__getenv_prefix_name(char **env_prefix/*in,out*/);
static H5F_t *H5F__new(H5F_shared_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf);
+static herr_t H5F__check_if_using_file_locks(H5P_genplist_t *fapl, hbool_t *use_file_locking);
static herr_t H5F__build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, const char *name, char ** /*out*/ actual_name);
static herr_t H5F__flush_phase1(H5F_t *f);
static herr_t H5F__flush_phase2(H5F_t *f, hbool_t closing);
@@ -91,6 +93,15 @@ static herr_t H5F__flush_phase2(H5F_t *f, hbool_t closing);
/* Package Variables */
/*********************/
+/* Package initialization variable */
+hbool_t H5_PKG_INIT_VAR = FALSE;
+
+/* Based on the value of the HDF5_USE_FILE_LOCKING environment variable.
+ * TRUE/FALSE have obvious meanings. FAIL means the environment variable was
+ * not set, so the code should ignore it and use the fapl value instead.
+ */
+htri_t use_locks_env_g = FAIL;
+
/*****************************/
/* Library Private Variables */
@@ -107,6 +118,186 @@ H5FL_DEFINE(H5F_t);
/* Declare a free list to manage the H5F_shared_t struct */
H5FL_DEFINE(H5F_shared_t);
+/* File ID class */
+static const H5I_class_t H5I_FILE_CLS[1] = {{
+ H5I_FILE, /* ID class value */
+ 0, /* Class flags */
+ 0, /* # of reserved IDs for class */
+ (H5I_free_t)H5F__close_cb /* Callback routine for closing objects of this class */
+}};
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5F_init
+ *
+ * Purpose: Initialize the interface from some other layer.
+ *
+ * Return: Success: non-negative
+ *
+ * Failure: negative
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5F_init(void)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+ /* FUNC_ENTER() does all the work */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5F_init() */
+
+
+/*--------------------------------------------------------------------------
+NAME
+ H5F__init_package -- Initialize interface-specific information
+USAGE
+ herr_t H5F__init_package()
+RETURNS
+ Non-negative on success/Negative on failure
+DESCRIPTION
+ Initializes any interface-specific data or routines.
+
+--------------------------------------------------------------------------*/
+herr_t
+H5F__init_package(void)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_PACKAGE
+
+ /*
+ * Initialize the atom group for the file IDs.
+ */
+ if(H5I_register_type(H5I_FILE_CLS) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to initialize interface")
+
+ /* Check the file locking environment variable */
+ if(H5F__parse_file_lock_env_var(&use_locks_env_g) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to parse file locking environment variable")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5F__init_package() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5F_term_package
+ *
+ * Purpose: Terminate this interface: free all memory and reset global
+ * variables to their initial values. Release all ID groups
+ * associated with this interface.
+ *
+ * Return: Success: Positive if anything was done that might
+ * have affected other interfaces;
+ * zero otherwise.
+ *
+ * Failure: Never fails
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+H5F_term_package(void)
+{
+ int n = 0;
+
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
+
+ if(H5_PKG_INIT_VAR) {
+ if(H5I_nmembers(H5I_FILE) > 0) {
+ (void)H5I_clear_type(H5I_FILE, FALSE, FALSE);
+ n++; /*H5I*/
+ } /* end if */
+ else {
+ /* Make certain we've cleaned up all the shared file objects */
+ H5F_sfile_assert_num(0);
+
+ /* Destroy the file object id group */
+ n += (H5I_dec_type_ref(H5I_FILE) > 0);
+
+ /* Mark closed */
+ if(0 == n)
+ H5_PKG_INIT_VAR = FALSE;
+ } /* end else */
+ } /* end if */
+
+ FUNC_LEAVE_NOAPI(n)
+} /* end H5F_term_package() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5F__close_cb
+ *
+ * Purpose: Closes a file or causes the close operation to be pended.
+ * This function is called from the API and gets called
+ * by H5Fclose->H5I_dec_ref->H5F__close_cb when H5I_dec_ref()
+ * decrements the file ID reference count to zero. The file ID
+ * is removed from the H5I_FILE group by H5I_dec_ref() just
+ * before H5F__close_cb() is called. If there are open object
+ * headers then the close is pended by moving the file to the
+ * H5I_FILE_CLOSING ID group (the f->closing contains the ID
+ * assigned to file).
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5F__close_cb(H5VL_object_t *file_vol_obj)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ /* Sanity check */
+ HDassert(file_vol_obj);
+
+ /* Close the file */
+ if(H5VL_file_close(file_vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close file")
+
+ /* Free the VOL object */
+ if(H5VL_free_object(file_vol_obj) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to free VOL object")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5F__close_cb() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5F__parse_file_lock_env_var
+ *
+ * Purpose: Parses the HDF5_USE_FILE_LOCKING environment variable.
+ *
+ * NOTE: This is done in a separate function so we can call it from
+ * the test code.
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5F__parse_file_lock_env_var(htri_t *use_locks)
+{
+ char *lock_env_var = NULL; /* Environment variable pointer */
+
+ FUNC_ENTER_PACKAGE_NOERR
+
+ /* Check the file locking environment variable */
+ lock_env_var = HDgetenv("HDF5_USE_FILE_LOCKING");
+ if(lock_env_var && (!HDstrcmp(lock_env_var, "FALSE") || !HDstrcmp(lock_env_var, "0")))
+ *use_locks = FALSE; /* Override: Never use locks */
+ else if(lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "BEST_EFFORT") || !HDstrcmp(lock_env_var, "1")))
+ *use_locks = TRUE; /* Override: Always use locks */
+ else
+ *use_locks = FAIL; /* Environment variable not set, or not set correctly */
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5F__parse_file_lock_env_var() */
/*-------------------------------------------------------------------------
@@ -1426,6 +1617,52 @@ H5F__dest(H5F_t *f, hbool_t flush)
/*-------------------------------------------------------------------------
+ * Function: H5F__check_if_using_file_locks
+ *
+ * Purpose: Determines if this file will use file locks.
+ *
+ * There are three ways that file locking can be controlled:
+ *
+ * 1) The configure/cmake option that sets the H5_USE_FILE_LOCKING
+ * symbol (which is used as the default fapl value).
+ *
+ * 2) The H5Pset_file_locking() API call, which will override
+ * the configuration default.
+ *
+ * 3) The HDF5_USE_FILE_LOCKING environment variable, which overrides
+ * everything above.
+ *
+ * The main reason to disable file locking is to prevent errors on file
+ * systems where locking is not supported or has been disabled (as is
+ * often the case in parallel file systems).
+ *
+ * Return: SUCCEED/FAIL
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5F__check_if_using_file_locks(H5P_genplist_t *fapl, hbool_t *use_file_locking)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ /* Make sure the out parameter has a value */
+ *use_file_locking = TRUE;
+
+ /* Check the fapl property */
+ if(H5P_get(fapl, H5F_ACS_USE_FILE_LOCKING_NAME, use_file_locking) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get use file locking flag")
+
+ /* Check the environment variable */
+ if(use_locks_env_g != FAIL)
+ *use_file_locking = (use_locks_env_g == TRUE) ? TRUE : FALSE;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5F__check_if_using_file_locks() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5F_open
*
* Purpose: Opens (or creates) a file. This function understands the
@@ -1514,8 +1751,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id)
hbool_t set_flag = FALSE; /*set the status_flags in the superblock */
hbool_t clear = FALSE; /*clear the status_flags */
hbool_t evict_on_close; /* evict on close value from plist */
- char *lock_env_var = NULL;/*env var pointer */
- hbool_t use_file_locking; /*read from env var */
+ hbool_t use_file_locking = TRUE; /* Using file locks? */
hbool_t ci_load = FALSE; /* whether MDC ci load requested */
hbool_t ci_write = FALSE; /* whether MDC CI write requested */
H5F_t *ret_value = NULL; /*actual return value */
@@ -1533,15 +1769,13 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id)
if(NULL == (drvr = H5FD_get_class(fapl_id)))
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "unable to retrieve VFL class")
- /* Check the environment variable that determines if we care
- * about file locking. File locking should be used unless explicitly
- * disabled.
- */
- lock_env_var = HDgetenv("HDF5_USE_FILE_LOCKING");
- if(lock_env_var && !HDstrcmp(lock_env_var, "FALSE"))
- use_file_locking = FALSE;
- else
- use_file_locking = TRUE;
+ /* Get the file access property list, for future queries */
+ if(NULL == (a_plist = (H5P_genplist_t *)H5I_object(fapl_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not file access property list")
+
+ /* Check if we are using file locking */
+ if (H5F__check_if_using_file_locks(a_plist, &use_file_locking) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "unable to get file locking flag")
/*
* Opening a file is a two step process. First we try to open the
@@ -1618,8 +1852,8 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id)
if(H5FD_lock(lf, (hbool_t)((flags & H5F_ACC_RDWR) ? TRUE : FALSE)) < 0) {
/* Locking failed - Closing will remove the lock */
if(H5FD_close(lf) < 0)
- HDONE_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to close low-level file info")
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to lock the file")
+ HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "unable to close low-level file info")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTLOCKFILE, NULL, "unable to lock the file")
} /* end if */
/* Create the 'top' file structure */
@@ -1651,10 +1885,6 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id)
shared = file->shared;
lf = shared->lf;
- /* Get the file access property list, for future queries */
- if(NULL == (a_plist = (H5P_genplist_t *)H5I_object(fapl_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not file access property list")
-
/* Check if page buffering is enabled */
if(H5P_get(a_plist, H5F_ACS_PAGE_BUFFER_SIZE_NAME, &page_buf_size) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get page buffer size")
@@ -1795,7 +2025,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id)
/* Remove the file lock for SWMR_WRITE */
if(use_file_locking && (H5F_INTENT(file) & H5F_ACC_SWMR_WRITE)) {
if(H5FD_unlock(file->shared->lf) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to unlock the file")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTUNLOCKFILE, NULL, "unable to unlock the file")
} /* end if */
} /* end if */
else { /* H5F_ACC_RDONLY: check consistency of status_flags */
diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h
index 46185ff..3a39e67 100644
--- a/src/H5Fpkg.h
+++ b/src/H5Fpkg.h
@@ -384,6 +384,7 @@ struct H5F_t {
unsigned nmounts; /* Number of children mounted to this file */
};
+
/*****************************/
/* Package Private Variables */
/*****************************/
@@ -394,6 +395,10 @@ H5FL_EXTERN(H5F_t);
/* Declare a free list to manage the H5F_shared_t struct */
H5FL_EXTERN(H5F_shared_t);
+/* Whether or not to use file locking (based on the environment variable)
+ * FAIL means ignore the environment variable.
+ */
+H5_DLLVAR htri_t use_locks_env_g;
/******************************/
/* Package Private Prototypes */
@@ -412,6 +417,7 @@ H5_DLL herr_t H5F__start_swmr_write(H5F_t *f);
H5_DLL herr_t H5F__close(H5F_t *f);
H5_DLL herr_t H5F__set_libver_bounds(H5F_t *f, H5F_libver_t low, H5F_libver_t high);
H5_DLL herr_t H5F__get_cont_info(const H5F_t *f, H5VL_file_cont_info_t *info);
+H5_DLL herr_t H5F__parse_file_lock_env_var(htri_t *use_locks);
/* File mount related routines */
H5_DLL herr_t H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t plist_id);
@@ -472,6 +478,7 @@ H5_DLL herr_t H5F__check_cached_stab_test(hid_t file_id);
H5_DLL herr_t H5F__get_maxaddr_test(hid_t file_id, haddr_t *maxaddr);
H5_DLL herr_t H5F__get_sbe_addr_test(hid_t file_id, haddr_t *sbe_addr);
H5_DLL htri_t H5F__same_file_test(hid_t file_id1, hid_t file_id2);
+H5_DLL herr_t H5F__reparse_file_lock_variable_test(void);
#endif /* H5F_TESTING */
#endif /* _H5Fpkg_H */
diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h
index c5d4c89..5fa4f7f 100644
--- a/src/H5Fprivate.h
+++ b/src/H5Fprivate.h
@@ -518,6 +518,8 @@ typedef struct H5F_t H5F_t;
#define H5F_ACS_PAGE_BUFFER_SIZE_NAME "page_buffer_size" /* the maximum size for the page buffer cache */
#define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME "page_buffer_min_meta_perc" /* the min metadata percentage for the page buffer cache */
#define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME "page_buffer_min_raw_perc" /* the min raw data percentage for the page buffer cache */
+#define H5F_ACS_USE_FILE_LOCKING_NAME "use_file_locking" /* whether or not we use file locks for SWMR control and to prevent multiple writers */
+#define H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_NAME "ignore_disabled_file_locks" /* whether or not we ignore "locks disabled" errors */
#ifdef H5_HAVE_PARALLEL
#define H5F_ACS_MPI_PARAMS_COMM_NAME "mpi_params_comm" /* the MPI communicator */
#define H5F_ACS_MPI_PARAMS_INFO_NAME "mpi_params_info" /* the MPI info struct */
diff --git a/src/H5Ftest.c b/src/H5Ftest.c
index 49a2a22..f17af2f 100644
--- a/src/H5Ftest.c
+++ b/src/H5Ftest.c
@@ -267,3 +267,36 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5F__same_file_test() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5F__reparse_file_lock_variable_test
+ *
+ * Purpose: Re-parse the file locking environment variable.
+ *
+ * Since getenv(3) is fairly expensive, we only parse it once,
+ * when the library opens. This test function is used to
+ * re-parse the environment variable after we've changed it
+ * with setnev(3).
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Dana Robinson
+ * Summer 2020
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5F__reparse_file_lock_variable_test(void)
+{
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_PACKAGE
+
+ /* Check the file locking environment variable */
+ if(H5F__parse_file_lock_env_var(&use_locks_env_g) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to parse file locking environment variable")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5F__reparse_file_lock_variable_test() */
+
diff --git a/src/H5I.c b/src/H5I.c
index 11209d6..a739c4e 100644
--- a/src/H5I.c
+++ b/src/H5I.c
@@ -33,9 +33,9 @@
#include "H5ACprivate.h" /* Metadata cache */
#include "H5CXprivate.h" /* API Contexts */
#include "H5Dprivate.h" /* Datasets */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5Fprivate.h" /* File access */
-#include "H5FLprivate.h" /* Free Lists */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Fprivate.h" /* File access */
+#include "H5FLprivate.h" /* Free Lists */
#include "H5Gprivate.h" /* Groups */
#include "H5Ipkg.h" /* IDs */
#include "H5MMprivate.h" /* Memory management */
@@ -145,7 +145,7 @@ static int H5I__iterate_pub_cb(void *obj, hid_t id, void *udata);
static int H5I__find_id_cb(void *_item, void *_key, void *_udata);
static int H5I__id_dump_cb(void *_item, void *_key, void *_udata);
-
+
/*-------------------------------------------------------------------------
* Function: H5I_term_package
*
@@ -197,7 +197,7 @@ H5I_term_package(void)
FUNC_LEAVE_NOAPI(n)
} /* end H5I_term_package() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Iregister_type
*
@@ -278,7 +278,7 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Iregister_type() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I_register_type
*
@@ -339,7 +339,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I_register_type() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Itype_exists
*
@@ -371,7 +371,7 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Itype_exists() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Inmembers
*
@@ -421,7 +421,7 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Inmembers() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I_nmembers
*
@@ -458,7 +458,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I_nmembers() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I__unwrap
*
@@ -502,7 +502,7 @@ H5I__unwrap(void *obj_ptr, H5I_type_t type)
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I__unwrap() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Iclear_type
*
@@ -535,7 +535,7 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Iclear_type() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I_clear_type
*
@@ -577,7 +577,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I_clear_type() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I__clear_type_cb
*
@@ -643,7 +643,7 @@ H5I__clear_type_cb(void *_id, void H5_ATTR_UNUSED *key, void *_udata)
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I__clear_type_cb() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Idestroy_type
*
@@ -677,7 +677,7 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Idestroy_type() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I__destroy_type
*
@@ -729,7 +729,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I__destroy_type() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Iregister
*
@@ -757,7 +757,7 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Iregister() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I_register
*
@@ -819,7 +819,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I_register() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I_register_using_existing_id
*
@@ -890,7 +890,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I_register_using_existing_id() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I_subst
*
@@ -927,7 +927,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I_subst() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I_object
*
@@ -957,7 +957,7 @@ H5I_object(hid_t id)
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I_object() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Iobject_verify
*
@@ -991,7 +991,7 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Iobject_verify() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I_object_verify
*
@@ -1026,7 +1026,7 @@ H5I_object_verify(hid_t id, H5I_type_t id_type)
FUNC_LEAVE_NOAPI(ret_value)
} /* H5I_object_verify() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I_get_type
*
@@ -1060,7 +1060,7 @@ H5I_get_type(hid_t id)
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I_get_type() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Iget_type
*
@@ -1087,13 +1087,13 @@ H5Iget_type(hid_t id)
ret_value = H5I_get_type(id);
if(ret_value <= H5I_BADID || (int)ret_value >= H5I_next_type || NULL == H5I_object(id))
- HGOTO_DONE(H5I_BADID);
+ HGOTO_DONE(H5I_BADID);
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Iget_type() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I_is_file_object
*
@@ -1144,7 +1144,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value);
} /* H5I_is_file_object() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Iremove_verify
*
@@ -1180,7 +1180,7 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Iremove_verify() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I__remove_verify
*
@@ -1213,7 +1213,7 @@ H5I__remove_verify(hid_t id, H5I_type_t id_type)
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I__remove_verify() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I__remove_common
*
@@ -1258,7 +1258,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I__remove_common() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I_remove
*
@@ -1298,7 +1298,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I_remove() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Idec_ref
*
@@ -1334,7 +1334,7 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Idec_ref() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I_dec_ref
*
@@ -1404,7 +1404,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I_dec_ref() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I_dec_app_ref
*
@@ -1452,7 +1452,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I_dec_app_ref() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I_dec_app_ref_always_close
*
@@ -1494,7 +1494,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I_dec_app_ref_always_close() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Iinc_ref
*
@@ -1525,7 +1525,7 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Iinc_ref() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I_inc_ref
*
@@ -1563,7 +1563,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I_inc_ref() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Iget_ref
*
@@ -1594,7 +1594,7 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Iget_ref() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I_get_ref
*
@@ -1627,7 +1627,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I_get_ref() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Iinc_type_ref
*
@@ -1660,7 +1660,7 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Iinc_ref() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I__inc_type_ref
*
@@ -1694,14 +1694,14 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I__inc_type_ref() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Idec_type_ref
*
* Purpose: Decrements the reference count on an entire type of IDs.
* If the type reference count becomes zero then the type is
* destroyed along with all atoms in that type regardless of
- * their reference counts. Destroying IDs involves calling
+ * their reference counts. Destroying IDs involves calling
* the free-func for each ID's object and then adding the ID
* struct to the ID free list. Public interface to
* H5I_dec_type_ref.
@@ -1736,14 +1736,14 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Idec_type_ref() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I_dec_type_ref
*
* Purpose: Decrements the reference count on an entire type of IDs.
* If the type reference count becomes zero then the type is
* destroyed along with all atoms in that type regardless of
- * their reference counts. Destroying IDs involves calling
+ * their reference counts. Destroying IDs involves calling
* the free-func for each ID's object and then adding the ID
* struct to the ID free list.
* Returns the number of references to the type on success; a
@@ -1789,7 +1789,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I_dec_type_ref() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Iget_type_ref
*
@@ -1822,7 +1822,7 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Iget_ref() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I__get_type_ref
*
@@ -1857,7 +1857,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I__get_type_ref() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Iis_valid
*
@@ -1887,7 +1887,7 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Iis_valid() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I__search_cb
*
@@ -1922,7 +1922,7 @@ H5I__search_cb(void *obj, hid_t id, void *_udata)
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I__search_cb() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Isearch
*
@@ -1973,7 +1973,7 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Isearch() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I__iterate_pub_cb
*
@@ -2013,7 +2013,7 @@ H5I__iterate_pub_cb(void H5_ATTR_UNUSED *obj, hid_t id, void *_udata)
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I__iterate_pub_cb() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Iiterate
*
@@ -2060,7 +2060,7 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Iiterate() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I__iterate_cb
*
@@ -2108,7 +2108,7 @@ H5I__iterate_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata)
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I__iterate_cb() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I_iterate
*
@@ -2167,7 +2167,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I_iterate() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I__find_id
*
@@ -2212,7 +2212,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I__find_id() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Iget_name
*
@@ -2263,7 +2263,7 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Iget_name() */
-
+
/*-------------------------------------------------------------------------
* Function: H5Iget_file_id
*
@@ -2307,7 +2307,7 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Iget_file_id() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I__find_id_cb
*
@@ -2345,7 +2345,7 @@ H5I__find_id_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata)
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I__find_id_cb() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I_find_id
*
@@ -2394,7 +2394,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I_find_id() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I__id_dump_cb
*
@@ -2482,7 +2482,7 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata)
FUNC_LEAVE_NOAPI(H5_ITER_CONT)
} /* end H5I__id_dump_cb() */
-
+
/*-------------------------------------------------------------------------
* Function: H5I_dump_ids_for_type
*
diff --git a/src/H5Oattr.c b/src/H5Oattr.c
index e38ef5c..6123949 100644
--- a/src/H5Oattr.c
+++ b/src/H5Oattr.c
@@ -108,8 +108,11 @@ H5FL_EXTERN(H5S_extent_t);
with the decoded information
USAGE
void *H5O_attr_decode(f, mesg_flags, p)
- H5F_t *f; IN: pointer to the HDF5 file struct
- unsigned mesg_flags; IN: Message flags to influence decoding
+ H5F_t *f; IN: pointer to the HDF5 file struct
+ H5O_t *open_oh; IN: pointer to the object header
+ unsigned mesg_flags; IN: message flags to influence decoding
+ unsigned *ioflags; IN/OUT: flags for decoding
+ size_t p_size; IN: size of buffer *p
const uint8_t *p; IN: the raw information buffer
RETURNS
Pointer to the new message in native order on success, NULL on failure
@@ -120,16 +123,16 @@ H5FL_EXTERN(H5S_extent_t);
--------------------------------------------------------------------------*/
static void *
H5O_attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags,
- unsigned *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p)
+ unsigned *ioflags, size_t p_size, const uint8_t *p)
{
- H5A_t *attr = NULL;
- H5S_extent_t *extent; /*extent dimensionality information */
- size_t name_len; /*attribute name length */
- size_t dt_size; /* Datatype size */
- hssize_t sds_size; /* Signed Dataspace size */
- hsize_t ds_size; /* Dataspace size */
- unsigned flags = 0; /* Attribute flags */
- H5A_t *ret_value = NULL; /* Return value */
+ H5A_t *attr = NULL;
+ H5S_extent_t *extent; /*extent dimensionality information */
+ size_t name_len; /*attribute name length */
+ size_t dt_size; /* Datatype size */
+ hssize_t sds_size; /* Signed Dataspace size */
+ hsize_t ds_size; /* Dataspace size */
+ unsigned flags = 0; /* Attribute flags */
+ H5A_t *ret_value = NULL; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -138,7 +141,7 @@ H5O_attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags,
HDassert(p);
if(NULL == (attr = H5FL_CALLOC(H5A_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
if(NULL == (attr->shared = H5FL_CALLOC(H5A_shared_t)))
HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate shared attr structure")
@@ -146,7 +149,7 @@ H5O_attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags,
/* Version number */
attr->shared->version = *p++;
if(attr->shared->version < H5O_ATTR_VERSION_1 || attr->shared->version > H5O_ATTR_VERSION_LATEST)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTLOAD, NULL, "bad version number for attribute message")
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTLOAD, NULL, "bad version number for attribute message")
/* Get the flags byte if we have a later version of the attribute */
if(attr->shared->version >= H5O_ATTR_VERSION_2) {
diff --git a/src/H5Odtype.c b/src/H5Odtype.c
index 6eaaae9..92a8ee3 100644
--- a/src/H5Odtype.c
+++ b/src/H5Odtype.c
@@ -1094,9 +1094,12 @@ done:
with the decoded information
USAGE
void *H5O_dtype_decode(f, mesg_flags, p)
- H5F_t *f; IN: pointer to the HDF5 file struct
+ H5F_t *f; IN: pointer to the HDF5 file struct
+ H5O_t *open_oh; IN: pointer to the object header
unsigned mesg_flags; IN: Message flags to influence decoding
- const uint8 *p; IN: the raw information buffer
+ unsigned *ioflags; IN/OUT: flags for decoding
+ size_t p_size; IN: size of buffer *p
+ const uint8_t *p; IN: the raw information buffer
RETURNS
Pointer to the new message in native order on success, NULL on failure
DESCRIPTION
diff --git a/src/H5Ofsinfo.c b/src/H5Ofsinfo.c
index 78e8e19..e2fa4e5 100644
--- a/src/H5Ofsinfo.c
+++ b/src/H5Ofsinfo.c
@@ -110,7 +110,7 @@ H5O_fsinfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh,
/* Allocate space for message */
if(NULL == (fsinfo = H5FL_CALLOC(H5O_fsinfo_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
for(ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++)
fsinfo->fs_addr[ptype - 1] = HADDR_UNDEF;
diff --git a/src/H5PLpkg.h b/src/H5PLpkg.h
index 8c2367f..a086a2c 100644
--- a/src/H5PLpkg.h
+++ b/src/H5PLpkg.h
@@ -95,7 +95,7 @@
# define H5PL_HANDLE void *
/* Get a handle to a plugin library. Windows: TEXT macro handles Unicode strings */
-# define H5PL_OPEN_DLIB(S) dlopen(S, RTLD_LAZY)
+# define H5PL_OPEN_DLIB(S) dlopen(S, RTLD_LAZY | RTLD_LOCAL)
/* Get the address of a symbol in dynamic library */
# define H5PL_GET_LIB_FUNC(H,N) dlsym(H,N)
diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c
index 30b590f..7b332d0 100644
--- a/src/H5Pfapl.c
+++ b/src/H5Pfapl.c
@@ -281,6 +281,29 @@
#define H5F_ACS_VOL_CONN_COPY H5P__facc_vol_copy
#define H5F_ACS_VOL_CONN_CMP H5P__facc_vol_cmp
#define H5F_ACS_VOL_CONN_CLOSE H5P__facc_vol_close
+/* Definition for using file locking or not. The default is set
+ * via the configure step.
+ */
+#define H5F_ACS_USE_FILE_LOCKING_SIZE sizeof(hbool_t)
+#if defined H5_USE_FILE_LOCKING && H5_USE_FILE_LOCKING
+#define H5F_ACS_USE_FILE_LOCKING_DEF TRUE
+#else
+#define H5F_ACS_USE_FILE_LOCKING_DEF FALSE
+#endif
+#define H5F_ACS_USE_FILE_LOCKING_ENC H5P__encode_hbool_t
+#define H5F_ACS_USE_FILE_LOCKING_DEC H5P__decode_hbool_t
+/* Definition for whether we ignore file locking errors when we can
+ * tell that file locking has been disabled on the file system.
+ * The default is set via the configure step.
+ */
+#define H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_SIZE sizeof(hbool_t)
+#if defined H5_IGNORE_DISABLED_FILE_LOCKS && H5_IGNORE_DISABLED_FILE_LOCKS
+#define H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_DEF TRUE
+#else
+#define H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_DEF FALSE
+#endif
+#define H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_ENC H5P__encode_hbool_t
+#define H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_DEC H5P__decode_hbool_t
/******************/
@@ -447,6 +470,8 @@ static const H5AC_cache_image_config_t H5F_def_mdc_initCacheImageCfg_g = H5F_ACS
static const size_t H5F_def_page_buf_size_g = H5F_ACS_PAGE_BUFFER_SIZE_DEF; /* Default page buffer size */
static const unsigned H5F_def_page_buf_min_meta_perc_g = H5F_ACS_PAGE_BUFFER_MIN_META_PERC_DEF; /* Default page buffer minimum metadata size */
static const unsigned H5F_def_page_buf_min_raw_perc_g = H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEF; /* Default page buffer mininum raw data size */
+static const hbool_t H5F_def_use_file_locking_g = H5F_ACS_USE_FILE_LOCKING_DEF; /* Default use file locking flag */
+static const hbool_t H5F_def_ignore_disabled_file_locks_g = H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_DEF; /* Default ignore disabled file locks flag */
/*-------------------------------------------------------------------------
@@ -705,6 +730,16 @@ H5P__facc_reg_prop(H5P_genclass_t *pclass)
H5F_ACS_VOL_CONN_DEL, H5F_ACS_VOL_CONN_COPY, H5F_ACS_VOL_CONN_CMP, H5F_ACS_VOL_CONN_CLOSE) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
+ /* Register the use file locking flag */
+ if(H5P__register_real(pclass, H5F_ACS_USE_FILE_LOCKING_NAME, H5F_ACS_USE_FILE_LOCKING_SIZE, &H5F_def_use_file_locking_g,
+ NULL, NULL, NULL, H5F_ACS_USE_FILE_LOCKING_ENC, H5F_ACS_USE_FILE_LOCKING_DEC, NULL, NULL, NULL, NULL) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
+
+ /* Register the ignore disabled file locks flag */
+ if(H5P__register_real(pclass, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_NAME, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_SIZE, &H5F_def_ignore_disabled_file_locks_g,
+ NULL, NULL, NULL, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_ENC, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_DEC, NULL, NULL, NULL, NULL) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
+
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P__facc_reg_prop() */
@@ -4551,6 +4586,98 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Pget_evict_on_close() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5Pset_file_locking
+ *
+ * Purpose: Sets the file locking property values.
+ *
+ * Overrides the default file locking flag setting that was
+ * set when the library was configured.
+ *
+ * Can be overridden by the HDF5_USE_FILE_LOCKING environment
+ * variable.
+ *
+ * File locking is used when creating/opening a file to prevent
+ * problematic file accesses.
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Dana Robinson
+ * Spring 2020
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Pset_file_locking(hid_t fapl_id, hbool_t use_file_locking, hbool_t ignore_when_disabled)
+{
+ H5P_genplist_t *plist; /* property list pointer */
+ herr_t ret_value = SUCCEED; /* return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE3("e", "ibb", fapl_id, use_file_locking, ignore_when_disabled);
+
+ /* Make sure this is a fapl */
+ if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS))
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not a file access plist")
+
+ /* Get the plist structure */
+ if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
+
+ /* Set values */
+ if(H5P_set(plist, H5F_ACS_USE_FILE_LOCKING_NAME, &use_file_locking) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set use file locking property")
+ if(H5P_set(plist, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_NAME, &ignore_when_disabled) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set ignore disabled file locks property")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Pset_file_locking() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Pget_file_locking
+ *
+ * Purpose: Gets the file locking property values.
+ *
+ * File locking is used when creating/opening a file to prevent
+ * problematic file accesses.
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Dana Robinson
+ * Spring 2020
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Pget_file_locking(hid_t fapl_id, hbool_t *use_file_locking, hbool_t *ignore_when_disabled)
+{
+ H5P_genplist_t *plist; /* property list pointer */
+ herr_t ret_value = SUCCEED; /* return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE3("e", "i*b*b", fapl_id, use_file_locking, ignore_when_disabled);
+
+ /* Make sure this is a fapl */
+ if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS))
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not an access plist")
+
+ /* Get the plist structure */
+ if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
+
+ /* Get values */
+ if(H5P_get(plist, H5F_ACS_USE_FILE_LOCKING_NAME, use_file_locking) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get use file locking property")
+ if(H5P_get(plist, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_NAME, ignore_when_disabled) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get ignore disabled file locks property")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Pget_file_locking() */
+
#ifdef H5_HAVE_PARALLEL
/*-------------------------------------------------------------------------
diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h
index bb33561..9dfa050 100644
--- a/src/H5Ppublic.h
+++ b/src/H5Ppublic.h
@@ -380,6 +380,8 @@ H5_DLL herr_t H5Pset_mdc_log_options(hid_t plist_id, hbool_t is_enabled, const c
H5_DLL herr_t H5Pget_mdc_log_options(hid_t plist_id, hbool_t *is_enabled, char *location, size_t *location_size, hbool_t *start_on_access);
H5_DLL herr_t H5Pset_evict_on_close(hid_t fapl_id, hbool_t evict_on_close);
H5_DLL herr_t H5Pget_evict_on_close(hid_t fapl_id, hbool_t *evict_on_close);
+H5_DLL herr_t H5Pset_file_locking(hid_t fapl_id, hbool_t use_file_locking, hbool_t ignore_when_disabled);
+H5_DLL herr_t H5Pget_file_locking(hid_t fapl_id, hbool_t *use_file_locking, hbool_t *ignore_when_disabled);
#ifdef H5_HAVE_PARALLEL
H5_DLL herr_t H5Pset_all_coll_metadata_ops(hid_t plist_id, hbool_t is_collective);
H5_DLL herr_t H5Pget_all_coll_metadata_ops(hid_t plist_id, hbool_t *is_collective);
diff --git a/src/H5Rint.c b/src/H5Rint.c
index 6dfbf2b..ae72b47 100644
--- a/src/H5Rint.c
+++ b/src/H5Rint.c
@@ -86,7 +86,7 @@
} while(0)
/* Debug */
-//#define H5R_DEBUG
+// #define H5R_DEBUG
#ifdef H5R_DEBUG
#define H5R_LOG_DEBUG(...) do { \
HDfprintf(stdout, " # %s(): ", __func__); \
@@ -822,7 +822,7 @@ H5R__set_obj_token(H5R_ref_priv_t *ref, const H5O_token_t *obj_token,
HDassert(token_size);
HDassert(token_size <= H5O_MAX_TOKEN_SIZE);
- H5MM_memcpy(&ref->info.obj.token, obj_token, sizeof(H5O_token_t));
+ H5MM_memcpy(&ref->info.obj.token, obj_token, token_size);
HDassert(token_size <= 255);
ref->token_size = (uint8_t)token_size;
diff --git a/src/H5Spoint.c b/src/H5Spoint.c
index be9015f..f53033b 100644
--- a/src/H5Spoint.c
+++ b/src/H5Spoint.c
@@ -12,7 +12,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
+ * Programmer: Quincey Koziol
* Tuesday, June 16, 1998
*
* Purpose: Point selection dataspace I/O functions.
diff --git a/src/H5T.c b/src/H5T.c
index 25c1f75..991095d 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -5718,9 +5718,9 @@ H5T_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc)
break;
case H5T_VLEN: /* Recurse on the VL information if it's VL, compound or array, then free VL sequence */
- /* Recurse if it's VL, compound, enum or array */
+ /* Recurse if it's VL, compound, enum or array (ignore references here so that we can encode them as part of the same blob)*/
/* (If the force_conv flag is _not_ set, the type cannot change in size, so don't recurse) */
- if(dt->shared->parent->shared->force_conv && H5T_IS_COMPLEX(dt->shared->parent->shared->type)) {
+ if(dt->shared->parent->shared->force_conv && H5T_IS_COMPLEX(dt->shared->parent->shared->type) && (dt->shared->parent->shared->type != H5T_REFERENCE)) {
if((changed = H5T_set_loc(dt->shared->parent, file, loc)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location");
if(changed > 0)
diff --git a/src/H5Tconv.c b/src/H5Tconv.c
index 15658cc..8bf36f0 100644
--- a/src/H5Tconv.c
+++ b/src/H5Tconv.c
@@ -3641,7 +3641,7 @@ H5T__conv_ref(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
if(0 == (buf_size = src->shared->u.atomic.u.r.cls->getsize(
src->shared->u.atomic.u.r.file, s, src->shared->size,
dst->shared->u.atomic.u.r.file, &dst_copy)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "incorrect size")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unable to obtain size of reference")
/* Check if conversion buffer is large enough, resize if necessary. */
if(conv_buf_size < buf_size) {
diff --git a/src/H5Tdbg.c b/src/H5Tdbg.c
index 7af736a..6188138 100644
--- a/src/H5Tdbg.c
+++ b/src/H5Tdbg.c
@@ -13,11 +13,11 @@
/*-------------------------------------------------------------------------
*
- * Created: H5Tdbg.c
- * Jul 19 2007
- * Quincey Koziol <koziol@hdfgroup.org>
+ * Created: H5Tdbg.c
+ * Jul 19 2007
+ * Quincey Koziol
*
- * Purpose: Dump debugging information about a datatype
+ * Purpose: Dump debugging information about a datatype
*
*-------------------------------------------------------------------------
*/
@@ -72,7 +72,7 @@
/*******************/
-
+
/*-------------------------------------------------------------------------
* Function: H5T__print_stats
*
@@ -137,7 +137,7 @@ H5T__print_stats(H5T_path_t H5_ATTR_UNUSED * path, int H5_ATTR_UNUSED * nprint/*
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5T__print_stats() */
-
+
/*-------------------------------------------------------------------------
* Function: H5T_debug
*
diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h
index 600d7aa..3eaec8c 100644
--- a/src/H5Tpkg.h
+++ b/src/H5Tpkg.h
@@ -49,7 +49,7 @@
#define H5T_NAMELEN 32
/* Macro to ease detecting "complex" datatypes (i.e. those with base types or fields) */
-#define H5T_IS_COMPLEX(t) ((t) == H5T_COMPOUND || (t) == H5T_ENUM || (t) == H5T_VLEN || (t) == H5T_ARRAY)
+#define H5T_IS_COMPLEX(t) ((t) == H5T_COMPOUND || (t) == H5T_ENUM || (t) == H5T_VLEN || (t) == H5T_ARRAY || (t) == H5T_REFERENCE)
/* Macro to ease detecting fixed "string" datatypes */
#define H5T_IS_FIXED_STRING(dt) (H5T_STRING == (dt)->type)
diff --git a/src/H5Tref.c b/src/H5Tref.c
index 7c59e75..42e3da2 100644
--- a/src/H5Tref.c
+++ b/src/H5Tref.c
@@ -40,6 +40,19 @@
#define H5T_REF_OBJ_DISK_SIZE(f) (H5F_SIZEOF_ADDR(f))
#define H5T_REF_DSETREG_DISK_SIZE(f) (H5HG_HEAP_ID_SIZE(f))
+/* Debug */
+// #define H5T_REF_DEBUG
+#ifdef H5T_REF_DEBUG
+#define H5T_REF_LOG_DEBUG(...) do { \
+ HDfprintf(stdout, " # %s(): ", __func__); \
+ HDfprintf(stdout, __VA_ARGS__); \
+ HDfprintf(stdout, "\n"); \
+ HDfflush(stdout); \
+ } while (0)
+#else
+#define H5T_REF_LOG_DEBUG(...) do { } while (0)
+#endif
+
/******************/
/* Local Typedefs */
/******************/
@@ -133,6 +146,7 @@ H5T__ref_set_loc(const H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc)
htri_t ret_value = FALSE; /* Indicate success, but no location change */
FUNC_ENTER_PACKAGE
+ H5T_REF_LOG_DEBUG("loc=%d", (int)loc);
HDassert(dt);
/* f is NULL when loc == H5T_LOC_MEMORY */
@@ -319,6 +333,7 @@ H5T__ref_mem_isnull(const H5VL_object_t H5_ATTR_UNUSED *src_file,
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC_NOERR
+ H5T_REF_LOG_DEBUG("");
/* Check parameters */
HDassert(src_buf);
@@ -346,6 +361,7 @@ H5T__ref_mem_setnull(H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf,
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC_NOERR
+ H5T_REF_LOG_DEBUG("");
HDmemset(dst_buf, 0, H5T_REF_MEM_SIZE);
@@ -373,6 +389,7 @@ H5T__ref_mem_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf
size_t ret_value = 0; /* Return value */
FUNC_ENTER_STATIC
+ H5T_REF_LOG_DEBUG("");
/* Sanity check */
HDassert(src_buf);
@@ -471,6 +488,7 @@ H5T__ref_mem_read(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf,
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
+ H5T_REF_LOG_DEBUG("");
/* Sanity check */
HDassert(src_buf);
@@ -557,6 +575,7 @@ H5T__ref_mem_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
+ H5T_REF_LOG_DEBUG("");
/* Sanity check */
HDassert(src_buf);
@@ -670,6 +689,7 @@ H5T__ref_disk_isnull(const H5VL_object_t *src_file, const void *src_buf,
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
+ H5T_REF_LOG_DEBUG("");
/* Check parameters */
HDassert(src_file);
@@ -712,6 +732,7 @@ H5T__ref_disk_setnull(H5VL_object_t *dst_file, void *dst_buf, void *bg_buf)
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
+ H5T_REF_LOG_DEBUG("");
HDassert(dst_file);
HDassert(dst_buf);
@@ -761,6 +782,7 @@ H5T__ref_disk_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_bu
size_t ret_value = 0;
FUNC_ENTER_STATIC
+ H5T_REF_LOG_DEBUG("");
HDassert(src_buf);
@@ -810,6 +832,7 @@ H5T__ref_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t H5_ATTR_
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
+ H5T_REF_LOG_DEBUG("");
HDassert(src_file);
HDassert(src_buf);
@@ -856,6 +879,7 @@ H5T__ref_disk_write(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf,
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
+ H5T_REF_LOG_DEBUG("");
HDassert(src_buf);
HDassert(src_size);
@@ -915,6 +939,7 @@ static herr_t H5T__ref_obj_disk_isnull(const H5VL_object_t *src_file,
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
+ H5T_REF_LOG_DEBUG("");
/* Check parameters */
HDassert(src_file);
@@ -967,6 +992,7 @@ H5T__ref_obj_disk_getsize(H5VL_object_t *src_file, const void H5_ATTR_UNUSED *sr
size_t ret_value = 0;
FUNC_ENTER_STATIC
+ H5T_REF_LOG_DEBUG("");
HDassert(src_file);
HDassert(src_buf);
@@ -1014,6 +1040,7 @@ H5T__ref_obj_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t src_
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
+ H5T_REF_LOG_DEBUG("");
HDassert(src_file);
HDassert(src_buf);
@@ -1068,6 +1095,7 @@ H5T__ref_dsetreg_disk_isnull(const H5VL_object_t *src_file, const void *src_buf,
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
+ H5T_REF_LOG_DEBUG("");
/* Check parameters */
HDassert(src_file);
@@ -1123,6 +1151,7 @@ H5T__ref_dsetreg_disk_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file,
#else
FUNC_ENTER_STATIC_NOERR
#endif
+ H5T_REF_LOG_DEBUG("");
HDassert(src_buf);
@@ -1171,6 +1200,7 @@ H5T__ref_dsetreg_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
+ H5T_REF_LOG_DEBUG("");
HDassert(src_file);
HDassert(src_buf);
@@ -1221,6 +1251,7 @@ H5T_ref_reclaim(void *elem, const H5T_t *dt)
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
+ H5T_REF_LOG_DEBUG("");
/* Sanity checks */
HDassert(elem);
diff --git a/src/H5VLint.c b/src/H5VLint.c
index 861629f..98785f8 100644
--- a/src/H5VLint.c
+++ b/src/H5VLint.c
@@ -2363,23 +2363,25 @@ H5VL_wrap_register(H5I_type_t type, void *obj, hbool_t app_ref)
/* Sanity check */
HDassert(obj);
+ /* Retrieve the VOL object wrapping context */
+ if(H5CX_get_vol_wrap_ctx((void **)&vol_wrap_ctx) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL object wrap context")
+ if(NULL == vol_wrap_ctx || NULL == vol_wrap_ctx->connector)
+ HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, H5I_INVALID_HID, "VOL object wrap context or its connector is NULL???")
+
/* If the datatype is already VOL-managed, the datatype's vol_obj
* field will get clobbered later, so disallow this.
*/
- if(type == H5I_DATATYPE)
- if(TRUE == H5T_already_vol_managed((const H5T_t *)obj))
- HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, H5I_INVALID_HID, "can't wrap an uncommitted datatype")
+ if(type == H5I_DATATYPE) {
+ if(vol_wrap_ctx->connector->id == H5VL_NATIVE)
+ if(TRUE == H5T_already_vol_managed((const H5T_t *)obj))
+ HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, H5I_INVALID_HID, "can't wrap an uncommitted datatype")
+ }
/* Wrap the object with VOL connector info */
if(NULL == (new_obj = H5VL__wrap_obj(obj, type)))
HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, H5I_INVALID_HID, "can't wrap library object")
- /* Retrieve the VOL object wrapping context */
- if(H5CX_get_vol_wrap_ctx((void **)&vol_wrap_ctx) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL object wrap context")
- if(NULL == vol_wrap_ctx || NULL == vol_wrap_ctx->connector)
- HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, H5I_INVALID_HID, "VOL object wrap context or its connector is NULL???")
-
/* Get an ID for the object */
if((ret_value = H5VL_register_using_vol_id(type, new_obj, vol_wrap_ctx->connector->id, app_ref)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to get an ID for the object")
diff --git a/src/H5Z.c b/src/H5Z.c
index af5b888..3bd4bcb 100644
--- a/src/H5Z.c
+++ b/src/H5Z.c
@@ -35,10 +35,10 @@
#ifdef H5Z_DEBUG
typedef struct H5Z_stats_t {
struct {
- hsize_t total; /* total number of bytes processed */
- hsize_t errors; /* bytes of total attributable to errors */
+ hsize_t total; /* total number of bytes processed */
+ hsize_t errors; /* bytes of total attributable to errors */
H5_timevals_t times; /* execution time including errors */
- } stats[2]; /* 0 = output, 1 = input */
+ } stats[2]; /* 0 = output, 1 = input */
} H5Z_stats_t;
#endif /* H5Z_DEBUG */
@@ -132,9 +132,9 @@ H5Z_term_package(void)
if(H5_PKG_INIT_VAR) {
#ifdef H5Z_DEBUG
- char comment[16], bandwidth[32];
- int dir, nprint = 0;
- size_t i;
+ char comment[16], bandwidth[32];
+ int dir, nprint = 0;
+ size_t i;
if(H5DEBUG(Z)) {
for(i = 0; i < H5Z_table_used_g; i++) {
@@ -142,33 +142,34 @@ H5Z_term_package(void)
if(0 == H5Z_stat_table_g[i].stats[dir].total)
continue;
- if(0 == nprint++) {
- /* Print column headers */
- HDfprintf(H5DEBUG(Z), "H5Z: filter statistics "
- "accumulated over life of library:\n");
- HDfprintf(H5DEBUG(Z),
- " %-16s %10s %10s %8s %8s %8s %10s\n",
- "Filter", "Total", "Errors", "User",
- "System", "Elapsed", "Bandwidth");
- HDfprintf(H5DEBUG(Z),
- " %-16s %10s %10s %8s %8s %8s %10s\n",
- "------", "-----", "------", "----",
- "------", "-------", "---------");
- } /* end if */
-
- /* Truncate the comment to fit in the field */
- HDstrncpy(comment, H5Z_table_g[i].name, sizeof comment);
- comment[sizeof(comment) - 1] = '\0';
-
- /*
- * Format bandwidth to have four significant digits and
- * units of `B/s', `kB/s', `MB/s', `GB/s', or `TB/s' or
- * the word `Inf' if the elapsed time is zero.
- */
- H5_bandwidth(bandwidth, (double)(H5Z_stat_table_g[i].stats[dir].total),
+ if(0 == nprint++) {
+ /* Print column headers */
+ HDfprintf(H5DEBUG(Z), "H5Z: filter statistics "
+ "accumulated over life of library:\n");
+ HDfprintf(H5DEBUG(Z),
+ " %-16s %10s %10s %8s %8s %8s %10s\n",
+ "Filter", "Total", "Errors", "User",
+ "System", "Elapsed", "Bandwidth");
+ HDfprintf(H5DEBUG(Z),
+ " %-16s %10s %10s %8s %8s %8s %10s\n",
+ "------", "-----", "------", "----",
+ "------", "-------", "---------");
+ } /* end if */
+
+ /* Truncate the comment to fit in the field */
+ HDstrncpy(comment, H5Z_table_g[i].name, sizeof comment);
+ comment[sizeof(comment) - 1] = '\0';
+
+ /*
+ * Format bandwidth to have four significant digits and
+ * units of `B/s', `kB/s', `MB/s', `GB/s', or `TB/s' or
+ * the word `Inf' if the elapsed time is zero.
+ */
+ H5_bandwidth(bandwidth,
+ (double)(H5Z_stat_table_g[i].stats[dir].total),
H5Z_stat_table_g[i].stats[dir].times.elapsed);
- /* Print the statistics */
+ /* Print the statistics */
HDfprintf(H5DEBUG(Z), " %s%-15s %10Hd %10Hd %8T %8T %8T %10s\n",
(dir ? "<" : ">"), comment,
H5Z_stat_table_g[i].stats[dir].total,
@@ -177,12 +178,12 @@ H5Z_term_package(void)
H5Z_stat_table_g[i].stats[dir].times.system,
H5Z_stat_table_g[i].stats[dir].times.elapsed,
bandwidth);
- } /* end for */
- } /* end for */
- } /* end if */
+ } /* end for */
+ } /* end for */
+ } /* end if */
#endif /* H5Z_DEBUG */
- /* Free the table of filters */
+ /* Free the table of filters */
if(H5Z_table_g) {
H5Z_table_g = (H5Z_class2_t *)H5MM_xfree(H5Z_table_g);
@@ -1256,7 +1257,7 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags,
int fclass_idx; /* Index of filter class in global table */
H5Z_class2_t *fclass = NULL; /* Filter class pointer */
#ifdef H5Z_DEBUG
- H5Z_stats_t *fstats = NULL; /* Filter stats pointer */
+ H5Z_stats_t *fstats = NULL; /* Filter stats pointer */
H5_timer_t timer; /* Timer for filter operations */
H5_timevals_t times; /* Elapsed time for each operation */
#endif
@@ -1278,12 +1279,12 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags,
H5_timer_init(&timer);
#endif
if(pline && (flags & H5Z_FLAG_REVERSE)) { /* Read */
- for(i = pline->nused; i > 0; --i) {
- idx = i - 1;
- if(*filter_mask & ((unsigned)1 << idx)) {
- failed |= (unsigned)1 << idx;
- continue; /* filter excluded */
- } /* end if */
+ for(i = pline->nused; i > 0; --i) {
+ idx = i - 1;
+ if(*filter_mask & ((unsigned)1 << idx)) {
+ failed |= (unsigned)1 << idx;
+ continue; /* filter excluded */
+ }
/* If the filter isn't registered and the application doesn't
* indicate no plugin through HDF5_PRELOAD_PLUG (using the symbol "::"),
@@ -1304,7 +1305,7 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags,
/* Search in the table of registered filters again to find the dynamic filter just loaded and registered */
if((fclass_idx = H5Z_find_idx(pline->filter[idx].id)) < 0)
issue_error = TRUE;
- } /* end if */
+ }
else
issue_error = TRUE;
@@ -1353,24 +1354,25 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags,
*nbytes = *buf_size;
failed |= (unsigned)1 << idx;
H5E_clear_stack(NULL);
- } /* end if */
+ }
else
*nbytes = new_nbytes;
- } /* end for */
- } else if (pline) { /* Write */
- for(idx = 0; idx < pline->nused; idx++) {
- if(*filter_mask & ((unsigned)1 << idx)) {
- failed |= (unsigned)1 << idx;
- continue; /* filter excluded */
- } /* end if */
- if((fclass_idx = H5Z_find_idx(pline->filter[idx].id)) < 0) {
+ }
+ }
+ else if(pline) { /* Write */
+ for(idx = 0; idx < pline->nused; idx++) {
+ if(*filter_mask & ((unsigned)1 << idx)) {
+ failed |= (unsigned)1 << idx;
+ continue; /* filter excluded */
+ }
+ if((fclass_idx = H5Z_find_idx(pline->filter[idx].id)) < 0) {
/* Check if filter is optional -- If it isn't, then error */
- if((pline->filter[idx].flags & H5Z_FLAG_OPTIONAL) == 0)
- HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, "required filter is not registered")
- failed |= (unsigned)1 << idx;
+ if((pline->filter[idx].flags & H5Z_FLAG_OPTIONAL) == 0)
+ HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, "required filter is not registered")
+ failed |= (unsigned)1 << idx;
H5E_clear_stack(NULL);
- continue; /* filter excluded */
- } /* end if */
+ continue; /* filter excluded */
+ } /* end if */
fclass = &H5Z_table_g[fclass_idx];
@@ -1390,25 +1392,25 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags,
fstats->stats[0].times.system += times.system;
fstats->stats[0].times.user += times.user;
- fstats->stats[0].total += MAX(*nbytes, new_nbytes);
+ fstats->stats[0].total += MAX(*nbytes, new_nbytes);
if(0 == new_nbytes)
fstats->stats[0].errors += *nbytes;
#endif
if(0 == new_nbytes) {
if(0 == (pline->filter[idx].flags & H5Z_FLAG_OPTIONAL)) {
- if((cb_struct.func && (H5Z_CB_FAIL==cb_struct.func(pline->filter[idx].id, *buf, *nbytes, cb_struct.op_data)))
+ if((cb_struct.func && (H5Z_CB_FAIL == cb_struct.func(pline->filter[idx].id, *buf, *nbytes, cb_struct.op_data)))
|| !cb_struct.func)
HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, "filter returned failure")
*nbytes = *buf_size;
- } /* end if */
+ }
failed |= (unsigned)1 << idx;
H5E_clear_stack(NULL);
- } /* end if */
+ }
else
*nbytes = new_nbytes;
- } /* end for */
+ } /* end for */
}
*filter_mask = failed;
diff --git a/src/H5err.txt b/src/H5err.txt
index 9fec521..24ac2ac 100644
--- a/src/H5err.txt
+++ b/src/H5err.txt
@@ -136,6 +136,8 @@ MINOR, FILEACC, H5E_BADFILE, Bad file ID accessed
MINOR, FILEACC, H5E_TRUNCATED, File has been truncated
MINOR, FILEACC, H5E_MOUNT, File mount error
MINOR, FILEACC, H5E_CANTDELETEFILE, Unable to delete file
+MINOR, FILEACC, H5E_CANTLOCKFILE, Unable to lock file
+MINOR, FILEACC, H5E_CANTUNLOCKFILE, Unable to unlock file
# Generic low-level file I/O errors
MINOR, FILE, H5E_SEEKERROR, Seek failed
diff --git a/src/H5private.h b/src/H5private.h
index 836d7d5..08aebdf 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -888,8 +888,8 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation);
#ifndef HDflock
/* NOTE: flock(2) is not present on all POSIX systems.
* If it is not present, we try a flock() equivalent based on
- * fcntl(2), then fall back to a function that always fails if
- * it is not present at all (Windows uses a separate Wflock()
+ * fcntl(2), then fall back to a function that always succeeds
+ * if it is not present at all (Windows uses a separate Wflock()
* function).
*/
#if defined(H5_HAVE_FLOCK)
diff --git a/src/H5public.h b/src/H5public.h
index 93cb2ea..d3edd23 100644
--- a/src/H5public.h
+++ b/src/H5public.h
@@ -38,7 +38,7 @@
#include <sys/types.h>
#endif
#ifdef H5_STDC_HEADERS
-# include <limits.h> /*for H5T_NATIVE_CHAR defn in H5Tpublic.h */
+# include <limits.h> /*for H5T_NATIVE_CHAR defn in H5Tpublic.h */
# include <stdarg.h> /*for variadic functions in H5VLpublic.h */
#endif
#ifndef __cplusplus
@@ -183,7 +183,7 @@ typedef long long ssize_t;
*/
#if H5_SIZEOF_LONG_LONG >= 8
H5_GCC_DIAG_OFF(long-long)
-typedef unsigned long long hsize_t;
+typedef unsigned long long hsize_t;
typedef signed long long hssize_t;
H5_GCC_DIAG_ON(long-long)
# define H5_SIZEOF_HSIZE_T H5_SIZEOF_LONG_LONG
@@ -229,7 +229,7 @@ H5_GCC_DIAG_ON(long-long)
#else
# error "nothing appropriate for H5_PRINTF_HADDR_FMT"
#endif
-#define HADDR_MAX (HADDR_UNDEF-1)
+#define HADDR_MAX (HADDR_UNDEF-1)
/* uint32_t type is used for creation order field for messages. It may be
* defined in Posix.1g, otherwise it is defined here.
@@ -297,7 +297,7 @@ typedef enum {
H5_ITER_INC, /* Increasing order */
H5_ITER_DEC, /* Decreasing order */
H5_ITER_NATIVE, /* No particular order, whatever is fastest */
- H5_ITER_N /* Number of iteration orders */
+ H5_ITER_N /* Number of iteration orders */
} H5_iter_order_t;
/* Iteration callback values */
@@ -314,10 +314,10 @@ typedef enum {
* links in groups/attributes on objects.
*/
typedef enum H5_index_t {
- H5_INDEX_UNKNOWN = -1, /* Unknown index type */
- H5_INDEX_NAME, /* Index on names */
- H5_INDEX_CRT_ORDER, /* Index on creation order */
- H5_INDEX_N /* Number of indices defined */
+ H5_INDEX_UNKNOWN = -1, /* Unknown index type */
+ H5_INDEX_NAME, /* Index on names */
+ H5_INDEX_CRT_ORDER, /* Index on creation order */
+ H5_INDEX_N /* Number of indices defined */
} H5_index_t;
/*
diff --git a/src/H5system.c b/src/H5system.c
index b3db39c..fbfd500 100644
--- a/src/H5system.c
+++ b/src/H5system.c
@@ -13,11 +13,11 @@
/*-------------------------------------------------------------------------
*
- * Created: H5system.c
- * Aug 21 2006
- * Quincey Koziol <koziol@hdfgroup.org>
+ * Created: H5system.c
+ * Aug 21 2006
+ * Quincey Koziol
*
- * Purpose: System call wrapper implementations.
+ * Purpose: System call wrapper implementations.
*
*-------------------------------------------------------------------------
*/
@@ -689,14 +689,14 @@ Pflock(int fd, int operation) {
* Purpose: Wrapper function for systems where no file locking is
* available.
*
- * Return: Failure: -1 (always fails)
+ * Return: 0 (success)
*
*-------------------------------------------------------------------------
*/
int H5_ATTR_CONST
Nflock(int H5_ATTR_UNUSED fd, int H5_ATTR_UNUSED operation) {
- /* just fail */
- return -1;
+ /* just succeed */
+ return 0;
} /* end Nflock() */
diff --git a/src/H5trace.c b/src/H5trace.c
index 91019a4..db33673 100644
--- a/src/H5trace.c
+++ b/src/H5trace.c
@@ -311,7 +311,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 'a':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -764,7 +764,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
break;
default:
- HDfprintf (out, "BADTYPE(D%c)", type[1]);
+ HDfprintf(out, "BADTYPE(D%c)", type[1]);
goto error;
} /* end switch */
break;
@@ -1149,7 +1149,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 's':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -1226,7 +1226,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
break;
default:
- HDfprintf (out, "BADTYPE(H%c)", type[1]);
+ HDfprintf(out, "BADTYPE(H%c)", type[1]);
goto error;
} /* end switch */
break;
@@ -1414,7 +1414,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
break;
case H5I_NTYPES:
- HDfprintf (out, "%ld (ntypes - error)", (long)obj);
+ HDfprintf(out, "%ld (ntypes - error)", (long)obj);
break;
default:
@@ -1518,7 +1518,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
else {
int is = HDva_arg(ap, int);
- HDfprintf (out, "%d", is);
+ HDfprintf(out, "%d", is);
asize[argno] = is;
} /* end else */
break;
@@ -1638,7 +1638,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
break;
default:
- HDfprintf (out, "BADTYPE(I%c)", type[1]);
+ HDfprintf(out, "BADTYPE(I%c)", type[1]);
goto error;
} /* end switch */
break;
@@ -1664,7 +1664,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 'l':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -1808,7 +1808,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
else {
off_t offset = HDva_arg(ap, off_t);
- HDfprintf (out, "%ld", (long)offset);
+ HDfprintf(out, "%ld", (long)offset);
} /* end else */
break;
@@ -2517,7 +2517,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
break;
default:
- HDfprintf (out, "BADTYPE(T%c)", type[1]);
+ HDfprintf(out, "BADTYPE(T%c)", type[1]);
goto error;
} /* end switch */
break;
@@ -2533,9 +2533,9 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
htri_t tri_var = HDva_arg (ap, htri_t);
if(tri_var>0)
- HDfprintf (out, "TRUE");
+ HDfprintf(out, "TRUE");
else if(!tri_var)
- HDfprintf (out, "FALSE");
+ HDfprintf(out, "FALSE");
else
HDfprintf(out, "FAIL(%d)", (int)tri_var);
} /* end else */
@@ -2592,7 +2592,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
break;
default:
- HDfprintf (out, "BADTYPE(U%c)", type[1]);
+ HDfprintf(out, "BADTYPE(U%c)", type[1]);
goto error;
} /* end switch */
break;
@@ -2602,7 +2602,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 'a':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -2638,7 +2638,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 'A':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -2656,7 +2656,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 'b':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -2686,7 +2686,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 'B':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -2716,7 +2716,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 'C':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -2733,7 +2733,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 'c':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -2769,7 +2769,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 'd':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -2796,7 +2796,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 'e':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -2820,7 +2820,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 'f':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -2844,7 +2844,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 'g':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -2886,7 +2886,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 'h':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -2925,7 +2925,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 'i':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -2949,7 +2949,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 'j':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -2973,7 +2973,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 'k':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -3000,7 +3000,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 'l':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -3027,7 +3027,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 'L':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -3051,7 +3051,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 'm':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -3078,7 +3078,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 'n':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -3108,7 +3108,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 'o':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -3144,7 +3144,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 'r':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -3171,7 +3171,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 's':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -3194,7 +3194,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 'S':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -3251,7 +3251,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 't':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -3299,7 +3299,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 'u':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -3317,7 +3317,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 'v':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -3422,7 +3422,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 'w':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -3448,7 +3448,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 'x':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -3466,7 +3466,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 'y':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -3502,7 +3502,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case 'z':
if(ptr) {
if(vp)
- HDfprintf (out, "0x%p", vp);
+ HDfprintf(out, "0x%p", vp);
else
HDfprintf(out, "NULL");
} /* end if */
@@ -3712,7 +3712,7 @@ error:
HDfprintf(out, ";\n");
else {
last_call_depth = current_depth++;
- HDfprintf (out, ")");
+ HDfprintf(out, ")");
} /* end else */
HDfflush(out);
diff --git a/src/libhdf5.settings.in b/src/libhdf5.settings.in
index fb9deec..98390b8 100644
--- a/src/libhdf5.settings.in
+++ b/src/libhdf5.settings.in
@@ -89,5 +89,6 @@ Parallel Filtered Dataset Writes: @PARALLEL_FILTERED_WRITES@
Using memory checker: @USINGMEMCHECKER@
Memory allocation sanity checks: @MEMORYALLOCSANITYCHECK@
Function stack tracing: @CODESTACK@
+ Use file locking: @DESIRED_FILE_LOCKING@
Strict file format checks: @STRICT_FORMAT_CHECKS@
Optimization instrumentation: @INSTRUMENT_LIBRARY@