diff options
Diffstat (limited to 'src/H5Dchunk.c')
-rw-r--r-- | src/H5Dchunk.c | 28 |
1 files changed, 16 insertions, 12 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)*/ |