diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2001-05-02 15:07:48 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2001-05-02 15:07:48 (GMT) |
commit | d95bfd75dc933c31a5fbd0f6bfb03169f5bf994a (patch) | |
tree | 589e99074f4bf6ae0aca527afeda08bb6b65dfb2 /src/H5Farray.c | |
parent | dff47a20544526c187899523f4c8a4ce9951f30d (diff) | |
download | hdf5-d95bfd75dc933c31a5fbd0f6bfb03169f5bf994a.zip hdf5-d95bfd75dc933c31a5fbd0f6bfb03169f5bf994a.tar.gz hdf5-d95bfd75dc933c31a5fbd0f6bfb03169f5bf994a.tar.bz2 |
[svn-r3887] Purpose:
Bug fix
Description:
IMPORTANT! IMPORTANT! IMPORTANT!
A case where metadata in a file could get corrupted in certain unusual
sitations was detected and fixed.
In certain circumstances, metadata could get cached in the raw data cache,
and if that particular piece of metadata was updated on disk while
incorrectly cached, the new metadata would get overwritten with the stale
metadata from the raw data cache when it was flushed out.
Additionally, I've patched up the raw data cache to be smarter about how
much it caches and how much I/O it triggers, leading to some speedups.
Solution:
Changed the raw data I/O routines which perform caching to require a
parameter with the size of the dataset being accessed and limited the
cache to no more than that many bytes.
Platforms tested:
FreeBSD 4.3 (hawkwind)
Diffstat (limited to 'src/H5Farray.c')
-rw-r--r-- | src/H5Farray.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/H5Farray.c b/src/H5Farray.c index 2c7c9d8..3d9e225 100644 --- a/src/H5Farray.c +++ b/src/H5Farray.c @@ -140,6 +140,7 @@ H5F_arr_read(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout, hsize_t idx[H5O_LAYOUT_NDIMS]; /*multi-dim counter */ size_t mem_start; /*byte offset to start */ hsize_t file_start; /*byte offset to start */ + hsize_t max_data = 0; /*bytes in dataset */ hsize_t elmt_size = 1; /*bytes per element */ size_t nelmts, z; /*number of elements */ uintn ndims; /*stride dimensionality */ @@ -247,6 +248,13 @@ H5F_arr_read(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout, addr = 0; } else { addr = layout->addr; + + /* Compute the size of the dataset in bytes */ + for(u=0, max_data=1; u<layout->ndims; u++) + max_data *= layout->dim[u]; + + /* Adjust the maximum size of the data by the offset into it */ + max_data -= file_start; } addr += file_start; buf += mem_start; @@ -313,7 +321,7 @@ H5F_arr_read(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout, "external data read failed"); } } else { - if (H5F_contig_read(f, H5FD_MEM_DRAW, addr, elmt_size, dxpl_id, buf)<0) { + if (H5F_contig_read(f, max_data, H5FD_MEM_DRAW, addr, elmt_size, dxpl_id, buf)<0) { HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "block read failed"); } @@ -324,6 +332,9 @@ H5F_arr_read(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout, addr += file_stride[j]; buf += mem_stride[j]; + /* Adjust the maximum size of the data by the offset into it */ + max_data -= file_stride[j]; + if (--idx[j]) carray = FALSE; else @@ -411,6 +422,7 @@ H5F_arr_write(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout, hsize_t idx[H5O_LAYOUT_NDIMS]; /*multi-dim counter */ hsize_t mem_start; /*byte offset to start */ hsize_t file_start; /*byte offset to start */ + hsize_t max_data = 0; /*bytes in dataset */ hsize_t elmt_size = 1; /*bytes per element */ size_t nelmts, z; /*number of elements */ uintn ndims; /*dimensionality */ @@ -518,6 +530,13 @@ H5F_arr_write(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout, addr = 0; } else { addr = layout->addr; + + /* Compute the size of the dataset in bytes */ + for(u=0, max_data=1; u<layout->ndims; u++) + max_data *= layout->dim[u]; + + /* Adjust the maximum size of the data by the offset into it */ + max_data -= file_start; } addr += file_start; buf += mem_start; @@ -561,7 +580,7 @@ H5F_arr_write(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout, "external data write failed"); } } else { - if (H5F_contig_write(f, H5FD_MEM_DRAW, addr, elmt_size, dxpl_id, buf)<0) { + if (H5F_contig_write(f, max_data, H5FD_MEM_DRAW, addr, elmt_size, dxpl_id, buf)<0) { HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed"); } @@ -572,6 +591,9 @@ H5F_arr_write(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout, addr += file_stride[j]; buf += mem_stride[j]; + /* Adjust the maximum size of the data by the offset into it */ + max_data -= file_stride[j]; + if (--idx[j]) carray = FALSE; else |