summaryrefslogtreecommitdiffstats
path: root/src/H5Fio.c
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2022-04-13 21:17:29 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2022-04-13 21:17:29 (GMT)
commitcabc39c3e197e2591449d2604bfee26465fb60e1 (patch)
treed5f39f5f5965584bf9bf49646a2af617adfd3e4e /src/H5Fio.c
parent7355f4c505092a7a85474b47f18d5206028e2c95 (diff)
parentab69f5df770ee3cc6cd6c81d905a5317b894a002 (diff)
downloadhdf5-feature/coding_standards.zip
hdf5-feature/coding_standards.tar.gz
hdf5-feature/coding_standards.tar.bz2
Merge branch 'develop' into feature/coding_standardsfeature/coding_standards
Diffstat (limited to 'src/H5Fio.c')
-rw-r--r--src/H5Fio.c227
1 files changed, 147 insertions, 80 deletions
diff --git a/src/H5Fio.c b/src/H5Fio.c
index 34dd0d6..53fec97 100644
--- a/src/H5Fio.c
+++ b/src/H5Fio.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -15,7 +15,7 @@
*
* Created: H5Fio.c
* Jan 10 2008
- * Quincey Koziol <koziol@hdfgroup.org>
+ * Quincey Koziol
*
* Purpose: File I/O routines.
*
@@ -26,56 +26,46 @@
/* Module Setup */
/****************/
-#include "H5Fmodule.h" /* This source code file is part of the H5F module */
-
+#include "H5Fmodule.h" /* This source code file is part of the H5F module */
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5Fpkg.h" /* File access */
-#include "H5FDprivate.h" /* File drivers */
-#include "H5Iprivate.h" /* IDs */
-#include "H5PBprivate.h" /* Page Buffer */
-
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Fpkg.h" /* File access */
+#include "H5FDprivate.h" /* File drivers */
+#include "H5Iprivate.h" /* IDs */
+#include "H5PBprivate.h" /* Page Buffer */
/****************/
/* Local Macros */
/****************/
-
/******************/
/* Local Typedefs */
/******************/
-
/********************/
/* Package Typedefs */
/********************/
-
/********************/
/* Local Prototypes */
/********************/
-
/*********************/
/* Package Variables */
/*********************/
-
/*****************************/
/* Library Private Variables */
/*****************************/
-
/*******************/
/* Local Variables */
/*******************/
-
-
/*-------------------------------------------------------------------------
* Function: H5F_shared_block_read
*
@@ -86,16 +76,15 @@
* Return: Non-negative on success/Negative on failure
*
* Programmer: Robb Matzke
- * matzke@llnl.gov
* Jul 10 1997
*
*-------------------------------------------------------------------------
*/
herr_t
-H5F_shared_block_read(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*out*/)
+H5F_shared_block_read(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, void *buf /*out*/)
{
- H5FD_mem_t map_type; /* Mapped memory type */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5FD_mem_t map_type; /* Mapped memory type */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -105,21 +94,20 @@ H5F_shared_block_read(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t
HDassert(H5F_addr_defined(addr));
/* Check for attempting I/O on 'temporary' file address */
- if(H5F_addr_le(f_sh->tmp_addr, (addr + size)))
+ if (H5F_addr_le(f_sh->tmp_addr, (addr + size)))
HGOTO_ERROR(H5E_IO, H5E_BADRANGE, FAIL, "attempting I/O in temporary file space")
/* Treat global heap as raw data */
map_type = (type == H5FD_MEM_GHEAP) ? H5FD_MEM_DRAW : type;
/* Pass through page buffer layer */
- if(H5PB_read(f_sh, map_type, addr, size, buf) < 0)
+ if (H5PB_read(f_sh, map_type, addr, size, buf) < 0)
HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "read through page buffer failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5F_shared_block_read() */
-
/*-------------------------------------------------------------------------
* Function: H5F_block_read
*
@@ -130,16 +118,15 @@ done:
* Return: Non-negative on success/Negative on failure
*
* Programmer: Robb Matzke
- * matzke@llnl.gov
* Jul 10 1997
*
*-------------------------------------------------------------------------
*/
herr_t
-H5F_block_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*out*/)
+H5F_block_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, void *buf /*out*/)
{
- H5FD_mem_t map_type; /* Mapped memory type */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5FD_mem_t map_type; /* Mapped memory type */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -150,21 +137,20 @@ H5F_block_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*
HDassert(H5F_addr_defined(addr));
/* Check for attempting I/O on 'temporary' file address */
- if(H5F_addr_le(f->shared->tmp_addr, (addr + size)))
+ if (H5F_addr_le(f->shared->tmp_addr, (addr + size)))
HGOTO_ERROR(H5E_IO, H5E_BADRANGE, FAIL, "attempting I/O in temporary file space")
/* Treat global heap as raw data */
map_type = (type == H5FD_MEM_GHEAP) ? H5FD_MEM_DRAW : type;
/* Pass through page buffer layer */
- if(H5PB_read(f->shared, map_type, addr, size, buf) < 0)
+ if (H5PB_read(f->shared, map_type, addr, size, buf) < 0)
HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "read through page buffer failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5F_block_read() */
-
/*-------------------------------------------------------------------------
* Function: H5F_shared_block_write
*
@@ -175,7 +161,6 @@ done:
* Return: Non-negative on success/Negative on failure
*
* Programmer: Robb Matzke
- * matzke@llnl.gov
* Jul 10 1997
*
*-------------------------------------------------------------------------
@@ -183,8 +168,8 @@ done:
herr_t
H5F_shared_block_write(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf)
{
- H5FD_mem_t map_type; /* Mapped memory type */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5FD_mem_t map_type; /* Mapped memory type */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -195,21 +180,20 @@ H5F_shared_block_write(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t
HDassert(H5F_addr_defined(addr));
/* Check for attempting I/O on 'temporary' file address */
- if(H5F_addr_le(f_sh->tmp_addr, (addr + size)))
+ if (H5F_addr_le(f_sh->tmp_addr, (addr + size)))
HGOTO_ERROR(H5E_IO, H5E_BADRANGE, FAIL, "attempting I/O in temporary file space")
/* Treat global heap as raw data */
map_type = (type == H5FD_MEM_GHEAP) ? H5FD_MEM_DRAW : type;
/* Pass through page buffer layer */
- if(H5PB_write(f_sh, map_type, addr, size, buf) < 0)
+ if (H5PB_write(f_sh, map_type, addr, size, buf) < 0)
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "write through page buffer failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5F_shared_block_write() */
-
/*-------------------------------------------------------------------------
* Function: H5F_block_write
*
@@ -220,7 +204,6 @@ done:
* Return: Non-negative on success/Negative on failure
*
* Programmer: Robb Matzke
- * matzke@llnl.gov
* Jul 10 1997
*
*-------------------------------------------------------------------------
@@ -228,8 +211,8 @@ done:
herr_t
H5F_block_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf)
{
- H5FD_mem_t map_type; /* Mapped memory type */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5FD_mem_t map_type; /* Mapped memory type */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -241,21 +224,109 @@ H5F_block_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, const void
HDassert(H5F_addr_defined(addr));
/* Check for attempting I/O on 'temporary' file address */
- if(H5F_addr_le(f->shared->tmp_addr, (addr + size)))
+ if (H5F_addr_le(f->shared->tmp_addr, (addr + size)))
HGOTO_ERROR(H5E_IO, H5E_BADRANGE, FAIL, "attempting I/O in temporary file space")
/* Treat global heap as raw data */
map_type = (type == H5FD_MEM_GHEAP) ? H5FD_MEM_DRAW : type;
/* Pass through page buffer layer */
- if(H5PB_write(f->shared, map_type, addr, size, buf) < 0)
+ if (H5PB_write(f->shared, map_type, addr, size, buf) < 0)
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "write through page buffer failed")
-
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5F_block_write() */
-
+/*-------------------------------------------------------------------------
+ * Function: H5F_shared_select_read
+ *
+ * Purpose: Reads some data from a file/server/etc into a buffer.
+ * The location of the data is defined by the mem_spaces and
+ * file_spaces dataspace arrays, along with the offsets
+ * array. The addresses is relative to the base address for
+ * the file.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Neil Fortner
+ * May 3 2021
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5F_shared_select_read(H5F_shared_t *f_sh, H5FD_mem_t type, uint32_t count, H5S_t **mem_spaces,
+ H5S_t **file_spaces, haddr_t offsets[], size_t element_sizes[], void *bufs[] /* out */)
+{
+ H5FD_mem_t map_type; /* Mapped memory type */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Sanity checks */
+ HDassert(f_sh);
+ HDassert((mem_spaces) || (count == 0));
+ HDassert((file_spaces) || (count == 0));
+ HDassert((offsets) || (count == 0));
+ HDassert((element_sizes) || (count == 0));
+ HDassert((bufs) || (count == 0));
+
+ /* Treat global heap as raw data */
+ map_type = (type == H5FD_MEM_GHEAP) ? H5FD_MEM_DRAW : type;
+
+ /* Pass down to file driver layer (bypass page buffer for now) */
+ if (H5FD_read_selection(f_sh->lf, map_type, count, mem_spaces, file_spaces, offsets, element_sizes,
+ bufs) < 0)
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "selection read through file driver failed")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5F_shared_select_read() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5F_shared_select_write
+ *
+ * Purpose: Writes some data from a buffer to a file/server/etc.
+ * The location of the data is defined by the mem_spaces and
+ * file_spaces dataspace arrays, along with the offsets
+ * array. The addresses is relative to the base address for
+ * the file.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Neil Fortner
+ * May 4 2021
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5F_shared_select_write(H5F_shared_t *f_sh, H5FD_mem_t type, uint32_t count, H5S_t **mem_spaces,
+ H5S_t **file_spaces, haddr_t offsets[], size_t element_sizes[], const void *bufs[])
+{
+ H5FD_mem_t map_type; /* Mapped memory type */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Sanity checks */
+ HDassert(f_sh);
+ HDassert((mem_spaces) || (count == 0));
+ HDassert((file_spaces) || (count == 0));
+ HDassert((offsets) || (count == 0));
+ HDassert((element_sizes) || (count == 0));
+ HDassert((bufs) || (count == 0));
+
+ /* Treat global heap as raw data */
+ map_type = (type == H5FD_MEM_GHEAP) ? H5FD_MEM_DRAW : type;
+
+ /* Pass down to file driver layer (bypass page buffer for now) */
+ if (H5FD_write_selection(f_sh->lf, map_type, count, mem_spaces, file_spaces, offsets, element_sizes,
+ bufs) < 0)
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "selection write through file driver failed")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5F_shared_select_write() */
+
/*-------------------------------------------------------------------------
* Function: H5F_flush_tagged_metadata
*
@@ -277,22 +348,21 @@ H5F_flush_tagged_metadata(H5F_t *f, haddr_t tag)
FUNC_ENTER_NOAPI(FAIL)
/* Use tag to search for and flush associated metadata */
- if(H5AC_flush_tagged_metadata(f, tag) < 0)
+ if (H5AC_flush_tagged_metadata(f, tag) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush tagged metadata")
/* Flush and reset the accumulator */
- if(H5F__accum_reset(f->shared, TRUE) < 0)
+ if (H5F__accum_reset(f->shared, TRUE) < 0)
HGOTO_ERROR(H5E_IO, H5E_CANTRESET, FAIL, "can't reset accumulator")
/* Flush file buffers to disk. */
- if(H5FD_flush(f->shared->lf, FALSE) < 0)
+ if (H5FD_flush(f->shared->lf, FALSE) < 0)
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "low level flush failed")
done:
FUNC_LEAVE_NOAPI(ret_value);
} /* end H5F_flush_tagged_metadata */
-
/*-------------------------------------------------------------------------
* Function: H5F_evict_tagged_metadata
*
@@ -313,14 +383,13 @@ H5F_evict_tagged_metadata(H5F_t *f, haddr_t tag)
FUNC_ENTER_NOAPI(FAIL)
/* Evict the object's metadata */
- if(H5AC_evict_tagged_metadata(f, tag, TRUE) < 0)
+ if (H5AC_evict_tagged_metadata(f, tag, TRUE) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "unable to evict tagged metadata")
done:
FUNC_LEAVE_NOAPI(ret_value);
} /* end H5F_evict_tagged_metadata */
-
/*-------------------------------------------------------------------------
* Function: H5F__evict_cache_entries
*
@@ -344,37 +413,36 @@ H5F__evict_cache_entries(H5F_t *f)
HDassert(f->shared);
/* Evict all except pinned entries in the cache */
- if(H5AC_evict(f) < 0)
+ if (H5AC_evict(f) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "unable to evict all except pinned entries")
#ifndef NDEBUG
-{
- unsigned status = 0;
- uint32_t cur_num_entries;
-
- /* Retrieve status of the superblock */
- if(H5AC_get_entry_status(f, (haddr_t)0, &status) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to get entry status")
-
- /* Verify status of the superblock entry in the cache */
- if(!(status & H5AC_ES__IN_CACHE) || !(status & H5AC_ES__IS_PINNED))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to get entry status")
-
- /* Get the number of cache entries */
- if(H5AC_get_cache_size(f->shared->cache, NULL, NULL, NULL, &cur_num_entries) < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_size() failed.")
-
- /* Should be the only one left in the cache (the superblock) */
- if(cur_num_entries != 1)
- HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "number of cache entries is not correct")
-}
+ {
+ unsigned status = 0;
+ uint32_t cur_num_entries;
+
+ /* Retrieve status of the superblock */
+ if (H5AC_get_entry_status(f, (haddr_t)0, &status) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to get entry status")
+
+ /* Verify status of the superblock entry in the cache */
+ if (!(status & H5AC_ES__IN_CACHE) || !(status & H5AC_ES__IS_PINNED))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to get entry status")
+
+ /* Get the number of cache entries */
+ if (H5AC_get_cache_size(f->shared->cache, NULL, NULL, NULL, &cur_num_entries) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_size() failed.")
+
+ /* Should be the only one left in the cache (the superblock) */
+ if (cur_num_entries != 1)
+ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "number of cache entries is not correct")
+ }
#endif /* NDEBUG */
done:
FUNC_LEAVE_NOAPI(ret_value);
} /* end H5F__evict_cache_entries() */
-
/*-------------------------------------------------------------------------
* Function: H5F_get_checksums
*
@@ -391,7 +459,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5F_get_checksums(const uint8_t *buf, size_t buf_size, uint32_t *s_chksum/*out*/, uint32_t *c_chksum/*out*/)
+H5F_get_checksums(const uint8_t *buf, size_t buf_size, uint32_t *s_chksum /*out*/, uint32_t *c_chksum /*out*/)
{
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -400,8 +468,8 @@ H5F_get_checksums(const uint8_t *buf, size_t buf_size, uint32_t *s_chksum/*out*/
HDassert(buf_size);
/* Return the stored checksum */
- if(s_chksum) {
- const uint8_t *chk_p; /* Pointer into raw data buffer */
+ if (s_chksum) {
+ const uint8_t *chk_p; /* Pointer into raw data buffer */
/* Offset to the checksum in the buffer */
chk_p = buf + buf_size - H5_SIZEOF_CHKSUM;
@@ -411,9 +479,8 @@ H5F_get_checksums(const uint8_t *buf, size_t buf_size, uint32_t *s_chksum/*out*/
} /* end if */
/* Return the computed checksum for the buffer */
- if(c_chksum)
- *c_chksum = H5_checksum_metadata(buf, buf_size - H5_SIZEOF_CHKSUM, 0);
+ if (c_chksum)
+ *c_chksum = H5_checksum_metadata(buf, buf_size - H5_SIZEOF_CHKSUM, 0);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5F_get_chksums() */
-