summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2003-08-28 16:02:21 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2003-08-28 16:02:21 (GMT)
commita3888a3b007e818f4178b053606c8d1b46f0fa1b (patch)
tree315bb1018c4d2bc20b01e9ad7ff82f8d008e7537 /src
parentb89fbdd877c687edb489d02f5f286a33e9af251f (diff)
downloadhdf5-a3888a3b007e818f4178b053606c8d1b46f0fa1b.zip
hdf5-a3888a3b007e818f4178b053606c8d1b46f0fa1b.tar.gz
hdf5-a3888a3b007e818f4178b053606c8d1b46f0fa1b.tar.bz2
[svn-r7426] Purpose:
Bug fix Description: When datasets are deleted from a file, they are removed from the sieve buffer, but instead of invalidating only the part of the sieve buffer affected, the sieve buffer code would throw away the entire sieve buffer, potentially including other raw data in the buffer that hadn't been written to disk yet. Solution: Improve the sieve buffer clearing code to handle partial invalidations. Platforms tested: FreeBSD 4.8 (sleipnir) h5committest
Diffstat (limited to 'src')
-rw-r--r--src/H5Dcontig.c2
-rw-r--r--src/H5Distore.c2
-rw-r--r--src/H5F.c55
-rw-r--r--src/H5Fcontig.c2
-rw-r--r--src/H5Fistore.c2
-rw-r--r--src/H5Fpkg.h2
6 files changed, 55 insertions, 10 deletions
diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c
index 64a4377..5f0c72d 100644
--- a/src/H5Dcontig.c
+++ b/src/H5Dcontig.c
@@ -332,7 +332,7 @@ H5F_contig_delete(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout)
size *= layout->dim[u];
/* Check for overlap with the sieve buffer and reset it */
- if (H5F_sieve_overlap_clear(f, layout->addr, size)<0)
+ if (H5F_sieve_overlap_clear(f, dxpl_id, layout->addr, size)<0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to clear sieve buffer");
/* Free the file space for the chunk */
diff --git a/src/H5Distore.c b/src/H5Distore.c
index 929a3e0..909007a 100644
--- a/src/H5Distore.c
+++ b/src/H5Distore.c
@@ -2662,7 +2662,7 @@ H5F_istore_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key /*in,out
FUNC_ENTER_NOAPI(H5F_istore_remove,H5B_INS_ERROR);
/* Check for overlap with the sieve buffer and reset it */
- if (H5F_sieve_overlap_clear(f, addr, (hsize_t)lt_key->nbytes)<0)
+ if (H5F_sieve_overlap_clear(f, dxpl_id, addr, (hsize_t)lt_key->nbytes)<0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, H5B_INS_ERROR, "unable to clear sieve buffer");
/* Remove raw data chunk from file */
diff --git a/src/H5F.c b/src/H5F.c
index fc3273b..2122ae2 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -4196,7 +4196,7 @@ H5F_addr_decode(const H5F_t *f, const uint8_t **pp/*in,out*/, haddr_t *addr_p/*o
*-------------------------------------------------------------------------
*/
herr_t
-H5F_sieve_overlap_clear(const H5F_t *f, haddr_t addr, hsize_t size)
+H5F_sieve_overlap_clear(const H5F_t *f, hid_t dxpl_id, haddr_t addr, hsize_t size)
{
herr_t ret_value=SUCCEED; /* Return value */
@@ -4207,10 +4207,55 @@ H5F_sieve_overlap_clear(const H5F_t *f, haddr_t addr, hsize_t size)
/* Check for the address range overlapping with the sieve buffer */
if(H5F_addr_overlap(f->shared->sieve_loc,f->shared->sieve_size,addr,size)) {
- /* Reset sieve information */
- f->shared->sieve_loc=HADDR_UNDEF;
- f->shared->sieve_size=0;
- f->shared->sieve_dirty=0;
+ /* Check if only part of the sieve buffer is being invalidated */
+ if(size<f->shared->sieve_size) {
+ /* Check if the portion to invalidate is at the end */
+ if((f->shared->sieve_loc+f->shared->sieve_size)==(addr+size)) {
+ /* Just shorten the buffer */
+ f->shared->sieve_size-=size;
+ } /* end if */
+ /* Check if the portion to invalidate is at the beginning */
+ else if(f->shared->sieve_loc==addr) {
+ /* Advance the start of the sieve buffer (on disk) and shorten the buffer */
+ f->shared->sieve_loc+=size;
+ f->shared->sieve_size-=size;
+
+ /* Move the retained information in the buffer down */
+ HDmemcpy(f->shared->sieve_buf,f->shared->sieve_buf+size,f->shared->sieve_size);
+ } /* end elif */
+ /* Portion to invalidate is in middle */
+ else {
+ size_t invalid_size; /* Portion of sieve buffer to invalidate */
+
+ /* Write out portion at the beginning of the buffer, if buffer is dirty */
+ if(f->shared->sieve_dirty) {
+ size_t start_size; /* Portion of sieve buffer to write */
+
+ /* Compute size of block at beginning of buffer */
+ start_size=(addr-f->shared->sieve_loc);
+
+ /* Write to file */
+ if (H5F_block_write(f, H5FD_MEM_DRAW, f->shared->sieve_loc, start_size, dxpl_id, f->shared->sieve_buf)<0)
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed");
+ } /* end if */
+
+ /* Compute size of block to invalidate */
+ invalid_size=((addr+size)-f->shared->sieve_loc);
+
+ /* Advance the start of the sieve buffer (on disk) and shorten the buffer */
+ f->shared->sieve_loc+=invalid_size;
+ f->shared->sieve_size-=invalid_size;
+
+ /* Move the retained information in the buffer down */
+ HDmemcpy(f->shared->sieve_buf,f->shared->sieve_buf+invalid_size,f->shared->sieve_size);
+ } /* end else */
+ } /* end if */
+ else {
+ /* Reset sieve information */
+ f->shared->sieve_loc=HADDR_UNDEF;
+ f->shared->sieve_size=0;
+ f->shared->sieve_dirty=0;
+ } /* end else */
} /* end if */
done:
diff --git a/src/H5Fcontig.c b/src/H5Fcontig.c
index 64a4377..5f0c72d 100644
--- a/src/H5Fcontig.c
+++ b/src/H5Fcontig.c
@@ -332,7 +332,7 @@ H5F_contig_delete(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout)
size *= layout->dim[u];
/* Check for overlap with the sieve buffer and reset it */
- if (H5F_sieve_overlap_clear(f, layout->addr, size)<0)
+ if (H5F_sieve_overlap_clear(f, dxpl_id, layout->addr, size)<0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to clear sieve buffer");
/* Free the file space for the chunk */
diff --git a/src/H5Fistore.c b/src/H5Fistore.c
index 929a3e0..909007a 100644
--- a/src/H5Fistore.c
+++ b/src/H5Fistore.c
@@ -2662,7 +2662,7 @@ H5F_istore_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key /*in,out
FUNC_ENTER_NOAPI(H5F_istore_remove,H5B_INS_ERROR);
/* Check for overlap with the sieve buffer and reset it */
- if (H5F_sieve_overlap_clear(f, addr, (hsize_t)lt_key->nbytes)<0)
+ if (H5F_sieve_overlap_clear(f, dxpl_id, addr, (hsize_t)lt_key->nbytes)<0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, H5B_INS_ERROR, "unable to clear sieve buffer");
/* Remove raw data chunk from file */
diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h
index 5599fa9..8ba9806 100644
--- a/src/H5Fpkg.h
+++ b/src/H5Fpkg.h
@@ -196,7 +196,7 @@ H5_DLLVAR hbool_t H5_mpiposix_1_metawrite_g;
H5_DLL void H5F_encode_length_unusual(const H5F_t *f, uint8_t **p, uint8_t *l);
#endif /* NOT_YET */
H5_DLL herr_t H5F_mountpoint(struct H5G_entry_t *find/*in,out*/);
-H5_DLL herr_t H5F_sieve_overlap_clear(const H5F_t *f, haddr_t addr, hsize_t size);
+H5_DLL herr_t H5F_sieve_overlap_clear(const H5F_t *f, hid_t dxpl_id, haddr_t addr, hsize_t size);
/* Functions that operate on indexed storage */
H5_DLL herr_t H5F_istore_init (H5F_t *f);