summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5Dchunk.c28
-rw-r--r--src/H5Dio.c31
-rw-r--r--src/H5Dprivate.h4
-rw-r--r--src/H5Dpublic.h4
-rw-r--r--src/H5F.c6
-rw-r--r--src/H5FDsec2.c2
-rw-r--r--src/H5Fpkg.h3
-rw-r--r--src/H5Fprivate.h2
-rw-r--r--src/H5Fpublic.h1
-rw-r--r--src/H5Fquery.c29
10 files changed, 56 insertions, 54 deletions
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c
index e9a50ef..7cde7b6 100644
--- a/src/H5Dchunk.c
+++ b/src/H5Dchunk.c
@@ -60,8 +60,6 @@
#include "H5Iprivate.h" /* IDs */
#include "H5MMprivate.h" /* Memory management */
#include "H5Vprivate.h" /* Vector and array functions */
-#include "H5Fprivate.h"
-#include "H5FDprivate.h"
/****************/
@@ -298,8 +296,8 @@ H5FL_BLK_DEFINE_STATIC(chunk);
*-------------------------------------------------------------------------
*/
herr_t
-H5D__direct_write(const H5D_t *dset, hid_t dxpl_id, size_t *offset, size_t buf_size,
- const void *buf)
+H5D__chunk_direct_write(const H5D_t *dset, hid_t dxpl_id, unsigned filters, hsize_t *offset,
+ size_t data_size, const void *buf)
{
const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset layout */
H5D_chunk_ud_t udata; /* User data for querying chunk info */
@@ -337,8 +335,12 @@ H5D__direct_write(const H5D_t *dset, hid_t dxpl_id, size_t *offset, size_t buf_s
&udata) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address")
- /* If the chunk hasn't been allocated on disk, do so now. */
- if(!H5F_addr_defined(udata.addr)) {
+ udata.filter_mask = filters;
+
+ /* Check if the chunk needs to be 'inserted' (could exist already and
+ * the 'insert' operation could resize it)
+ */
+ {
H5D_chk_idx_info_t idx_info; /* Chunked index info */
/* Compose chunked index info struct */
@@ -349,9 +351,11 @@ H5D__direct_write(const H5D_t *dset, hid_t dxpl_id, size_t *offset, size_t buf_s
idx_info.storage = &(dset->shared->layout.storage.u.chunk);
/* Set up the size of chunk for user data */
- udata.nbytes = buf_size;
+ udata.nbytes = data_size;
- /* Create the chunk */
+ /* Create the chunk it if it doesn't exist, or reallocate the chunk
+ * if its size changed.
+ */
if((dset->shared->layout.storage.u.chunk.ops->insert)(&idx_info, &udata) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert/resize chunk")
@@ -372,10 +376,10 @@ H5D__direct_write(const H5D_t *dset, hid_t dxpl_id, size_t *offset, size_t buf_s
HGOTO_ERROR(H5E_DATASET, H5E_CANTREMOVE, FAIL, "unable to evict chunk")
} /* end if */
- /* Write the data to the file driver, instead of H5F_block_write */
- lf = H5F_DRIVER(dset->oloc.file);
- if(H5FD_write(lf, dxpl_id, H5FD_MEM_DRAW, udata.addr, buf_size, buf) < 0)
- HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed")
+ /* Write the data to the file */
+ if(H5F_block_write(dset->oloc.file, H5FD_MEM_DRAW, udata.addr, data_size, dxpl_id, buf) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to write raw data to file")
+
done:
/*FUNC_LEAVE_NOAPI(ret_value)*/
diff --git a/src/H5Dio.c b/src/H5Dio.c
index accb948..9576177 100644
--- a/src/H5Dio.c
+++ b/src/H5Dio.c
@@ -28,6 +28,7 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5FLprivate.h" /* Free Lists */
#include "H5Iprivate.h" /* IDs */
+#include "H5Sprivate.h" /* Dataspace */
#ifdef H5_HAVE_PARALLEL
/* Remove this if H5R_DATASET_REGION is no longer used in this file */
@@ -284,10 +285,13 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5PSIdirect_write(hid_t dset_id, hid_t dxpl_id, size_t *offset, size_t buf_size,
- const void *buf)
+H5PSIdirect_write(hid_t dset_id, hid_t dxpl_id, unsigned filters, hsize_t *offset,
+ size_t data_size, const void *buf)
{
H5D_t *dset = NULL;
+ int ndims;
+ hsize_t *dims;
+ int i;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -298,6 +302,9 @@ H5PSIdirect_write(hid_t dset_id, hid_t dxpl_id, size_t *offset, size_t buf_size,
if(NULL == dset->oloc.file)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
+ if(H5D_CHUNKED != dset->shared->layout.type)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset")
+
/* Get the default dataset transfer property list if the user didn't provide one */
if(H5P_DEFAULT == dxpl_id)
dxpl_id= H5P_DATASET_XFER_DEFAULT;
@@ -308,8 +315,26 @@ H5PSIdirect_write(hid_t dset_id, hid_t dxpl_id, size_t *offset, size_t buf_size,
if(!buf)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer")
+ ndims = (int)H5S_GET_EXTENT_NDIMS(dset->shared->space);
+ dims = (hsize_t *)HDmalloc(ndims*sizeof(hsize_t));
+
+ if(H5S_get_simple_extent_dims(dset->shared->space, dims, NULL) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't retrieve dataspace extent dims")
+
+ /* Make sure the offset doesn't exceed the dataset's dimensions */
+ for(i=0; i<ndims; i++)
+ if(offset[i] > dims[i])
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "offset exceeds dimensions of dataset")
+
+ /* Make sure the offset fall right on a chunk's boundary */
+ for(i=0; i<ndims; i++)
+ if(offset[i] % dset->shared->layout.u.chunk.dim[i])
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "offset doesn't fall on chunks's boundary")
+
+ HDfree(dims);
+
/* write raw data */
- if(H5D__direct_write(dset, dxpl_id, offset, buf_size, buf) < 0)
+ if(H5D__chunk_direct_write(dset, dxpl_id, filters, offset, data_size, buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data")
done:
diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h
index b52800b..342c284 100644
--- a/src/H5Dprivate.h
+++ b/src/H5Dprivate.h
@@ -176,8 +176,8 @@ H5_DLL herr_t H5D_chunk_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_ad
H5_DLL herr_t H5D_btree_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream,
int indent, int fwidth, unsigned ndims);
-H5_DLL herr_t H5D__direct_write(const H5D_t *dset, hid_t dxpl_id, size_t *offset,
- size_t buf_size, const void *buf);
+H5_DLL herr_t H5D__chunk_direct_write(const H5D_t *dset, hid_t dxpl_id, unsigned filters,
+ hsize_t *offset, size_t data_size, const void *buf);
#endif /* _H5Dprivate_H */
diff --git a/src/H5Dpublic.h b/src/H5Dpublic.h
index b072e64..58c2a2b 100644
--- a/src/H5Dpublic.h
+++ b/src/H5Dpublic.h
@@ -118,8 +118,8 @@ H5_DLL herr_t H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
hid_t file_space_id, hid_t plist_id, void *buf/*out*/);
H5_DLL herr_t H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
hid_t file_space_id, hid_t plist_id, const void *buf);
-H5_DLL herr_t H5PSIdirect_write(hid_t dset_id, hid_t dxpl_id, size_t *offset, size_t buf_size,
- const void *buf);
+H5_DLL herr_t H5PSIdirect_write(hid_t dset_id, hid_t dxpl_id, unsigned filters, hsize_t *offset,
+ size_t data_size, const void *buf);
H5_DLL herr_t H5Diterate(void *buf, hid_t type_id, hid_t space_id,
H5D_operator_t op, void *operator_data);
H5_DLL herr_t H5Dvlen_reclaim(hid_t type_id, hid_t space_id, hid_t plist_id, void *buf);
diff --git a/src/H5F.c b/src/H5F.c
index 5d13ea6..b1f052d 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -1251,7 +1251,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id,
* way for us to detect it here anyway).
*/
if(drvr->cmp)
- tent_flags = flags & ~(H5F_ACC_CREAT|H5F_ACC_TRUNC|H5F_ACC_EXCL);
+ tent_flags = flags & ~(H5F_ACC_CREAT|H5F_ACC_TRUNC|H5F_ACC_EXCL|H5F_ACC_SYNC);
else
tent_flags = flags;
@@ -1454,9 +1454,9 @@ H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id)
if(!filename || !*filename)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file name")
/* In this routine, we only accept the following flags:
- * H5F_ACC_EXCL, H5F_ACC_TRUNC and H5F_ACC_DEBUG
+ * H5F_ACC_SYNC, H5F_ACC_EXCL, H5F_ACC_TRUNC and H5F_ACC_DEBUG
*/
- if(flags & ~(H5F_ACC_EXCL | H5F_ACC_TRUNC | H5F_ACC_DEBUG))
+ if(flags & ~(H5F_ACC_SYNC | H5F_ACC_EXCL | H5F_ACC_TRUNC | H5F_ACC_DEBUG))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid flags")
/* The H5F_ACC_EXCL and H5F_ACC_TRUNC flags are mutually exclusive */
if((flags & H5F_ACC_EXCL) && (flags & H5F_ACC_TRUNC))
diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c
index 4201e07..085465c 100644
--- a/src/H5FDsec2.c
+++ b/src/H5FDsec2.c
@@ -357,6 +357,8 @@ H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
o_flags |= O_CREAT;
if(H5F_ACC_EXCL & flags)
o_flags |= O_EXCL;
+ if(H5F_ACC_SYNC & flags)
+ o_flags |= O_SYNC;
/* Open the file */
if((fd = HDopen(name, o_flags, 0666)) < 0) {
diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h
index 334879c..2d4678b 100644
--- a/src/H5Fpkg.h
+++ b/src/H5Fpkg.h
@@ -63,7 +63,8 @@
#define H5F_SUPER_ALL_FLAGS (H5F_SUPER_WRITE_ACCESS | H5F_SUPER_FILE_OK)
/* Mask for removing private file access flags */
-#define H5F_ACC_PUBLIC_FLAGS 0x001fu
+/* #define H5F_ACC_PUBLIC_FLAGS 0x001fu */
+#define H5F_ACC_PUBLIC_FLAGS 0x003fu
/* Free space section+aggregator merge flags */
#define H5F_FS_MERGE_METADATA 0x01 /* Section can merge with metadata aggregator */
diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h
index 3b3af49..1ef40b0 100644
--- a/src/H5Fprivate.h
+++ b/src/H5Fprivate.h
@@ -234,7 +234,6 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t;
#define H5F_FILE_ID(F) ((F)->file_id)
#define H5F_PARENT(F) ((F)->parent)
#define H5F_NMOUNTS(F) ((F)->nmounts)
-#define H5F_DRIVER(F) ((F)->shared->lf)
#define H5F_DRIVER_ID(F) ((F)->shared->lf->driver_id)
#define H5F_GET_FILENO(F,FILENUM) ((FILENUM) = (F)->shared->lf->fileno)
#define H5F_HAS_FEATURE(F,FL) ((F)->shared->lf->feature_flags & (FL))
@@ -277,7 +276,6 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t;
#define H5F_FILE_ID(F) (H5F_get_file_id(F))
#define H5F_PARENT(F) (H5F_get_parent(F))
#define H5F_NMOUNTS(F) (H5F_get_nmounts(F))
-#define H5F_DRIVER(F) (H5F_get_driver(F))
#define H5F_DRIVER_ID(F) (H5F_get_driver_id(F))
#define H5F_GET_FILENO(F,FILENUM) (H5F_get_fileno((F), &(FILENUM)))
#define H5F_HAS_FEATURE(F,FL) (H5F_has_feature(F,FL))
diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h
index f32b3e0..7b7acb4 100644
--- a/src/H5Fpublic.h
+++ b/src/H5Fpublic.h
@@ -48,6 +48,7 @@
#define H5F_ACC_EXCL (H5CHECK 0x0004u) /*fail if file already exists*/
#define H5F_ACC_DEBUG (H5CHECK 0x0008u) /*print debug info */
#define H5F_ACC_CREAT (H5CHECK 0x0010u) /*create non-existing files */
+#define H5F_ACC_SYNC (H5CHECK 0x0020u) /*no filesystem caching */
/* Value passed to H5Pset_elink_acc_flags to cause flags to be taken from the
* parent file. */
diff --git a/src/H5Fquery.c b/src/H5Fquery.c
index 1be5c50..c04ba24 100644
--- a/src/H5Fquery.c
+++ b/src/H5Fquery.c
@@ -919,35 +919,6 @@ H5F_get_driver_id(const H5F_t *f)
/*-------------------------------------------------------------------------
- * Function: H5F_get_driver
- *
- * Purpose: Quick and dirty routine to retrieve the file's 'driver' structure
- * (Mainly added to stop non-file routines from poking about in the
- * H5F_t data structure)
- *
- * Return: 'driver' structure on success/abort on failure (shouldn't fail)
- *
- * Programmer: Raymond Lu
- * 30 July 2012
- *
- *-------------------------------------------------------------------------
- */
-H5FD_t *
-H5F_get_driver(const H5F_t *f)
-{
- /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
- HDassert(f);
- HDassert(f->shared);
- HDassert(f->shared->lf);
-
- FUNC_LEAVE_NOAPI(f->shared->lf)
-} /* end H5F_get_driver() */
-
-
-
-/*-------------------------------------------------------------------------
* Function: H5F_get_fileno
*
* Purpose: Quick and dirty routine to retrieve the file's 'fileno' value