summaryrefslogtreecommitdiffstats
path: root/src/H5HFman.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2006-12-18 17:52:43 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2006-12-18 17:52:43 (GMT)
commitddbc06fce64bc49ff6b3e83da3ff74d08251fc2c (patch)
tree2fd1ab62b539b7c05a2adf461006e1c07d6f3535 /src/H5HFman.c
parent9236c9a148aaf206294be0554cf78e7ab769bd51 (diff)
downloadhdf5-ddbc06fce64bc49ff6b3e83da3ff74d08251fc2c.zip
hdf5-ddbc06fce64bc49ff6b3e83da3ff74d08251fc2c.tar.gz
hdf5-ddbc06fce64bc49ff6b3e83da3ff74d08251fc2c.tar.bz2
[svn-r13067] Description:
Add [quite] limited ability to update (ie. write) data for objects in fractal heap. Limited to just updating objects in managed heap blocks (i.e. not 'tiny' or 'huge' objects) and must be updated with data of the same length as the object in the heap. Updating objects in compressed heaps does work though [as long as the data isn't 'tiny' or 'huge']. Needed for changing the data value or the name of an attribute that is stored in dense or shared storage. Tested on: Linux/32 2.6 (chicago) Linux/64 2.6 (chicago2)
Diffstat (limited to 'src/H5HFman.c')
-rw-r--r--src/H5HFman.c68
1 files changed, 59 insertions, 9 deletions
diff --git a/src/H5HFman.c b/src/H5HFman.c
index 6270905..43c248b 100644
--- a/src/H5HFman.c
+++ b/src/H5HFman.c
@@ -58,7 +58,7 @@
/* Local Prototypes */
/********************/
static herr_t H5HF_man_op_real(H5HF_hdr_t *hdr, hid_t dxpl_id,
- const uint8_t *id, H5HF_operator_t op, void *op_data);
+ const uint8_t *id, H5HF_operator_t op, void *op_data, unsigned op_flags);
/*********************/
/* Package Variables */
@@ -246,15 +246,17 @@ done:
*/
static herr_t
H5HF_man_op_real(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id,
- H5HF_operator_t op, void *op_data)
+ H5HF_operator_t op, void *op_data, unsigned op_flags)
{
H5HF_direct_t *dblock = NULL; /* Pointer to direct block to query */
+ H5AC_protect_t dblock_access; /* Access method for direct block */
+ haddr_t dblock_addr; /* Direct block address */
+ size_t dblock_size; /* Direct block size */
+ unsigned dblock_cache_flags; /* Flags for unprotecting direct block */
hsize_t obj_off; /* Object's offset in heap */
size_t obj_len; /* Object's length in heap */
size_t blk_off; /* Offset of object in block */
uint8_t *p; /* Temporary pointer to obj info in block */
- haddr_t dblock_addr; /* Direct block address */
- size_t dblock_size; /* Direct block size */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5HF_man_op_real)
@@ -266,6 +268,16 @@ H5HF_man_op_real(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id,
HDassert(id);
HDassert(op);
+ /* Set the access mode for the direct block */
+ if(op_flags & H5HF_OP_MODIFY) {
+ dblock_access = H5AC_WRITE;
+ dblock_cache_flags = H5AC__DIRTIED_FLAG;
+ } /* end if */
+ else {
+ dblock_access = H5AC_READ;
+ dblock_cache_flags = H5AC__NO_FLAGS_SET;
+ } /* end else */
+
/* Skip over the flag byte */
id++;
@@ -298,7 +310,7 @@ HDfprintf(stderr, "%s: hdr->man_dtable.cparam.max_direct_size = %Zu\n", FUNC, hd
dblock_size = hdr->man_dtable.cparam.start_block_size;
/* Lock direct block */
- if(NULL == (dblock = H5HF_man_dblock_protect(hdr, dxpl_id, dblock_addr, dblock_size, NULL, 0, H5AC_READ)))
+ if(NULL == (dblock = H5HF_man_dblock_protect(hdr, dxpl_id, dblock_addr, dblock_size, NULL, 0, dblock_access)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap direct block")
} /* end if */
else {
@@ -327,7 +339,7 @@ HDfprintf(stderr, "%s: entry address = %a\n", FUNC, iblock->ents[entry].addr);
} /* end if */
/* Lock direct block */
- if(NULL == (dblock = H5HF_man_dblock_protect(hdr, dxpl_id, dblock_addr, dblock_size, iblock, entry, H5AC_READ))) {
+ if(NULL == (dblock = H5HF_man_dblock_protect(hdr, dxpl_id, dblock_addr, dblock_size, iblock, entry, dblock_access))) {
/* Unlock indirect block */
if(H5HF_man_iblock_unprotect(iblock, dxpl_id, H5AC__NO_FLAGS_SET, did_protect) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block")
@@ -365,7 +377,7 @@ HDfprintf(stderr, "%s: dblock_addr = %a, dblock_size = %Zu\n", FUNC, dblock_addr
done:
/* Unlock direct block */
- if(dblock && H5AC_unprotect(hdr->f, dxpl_id, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, H5AC__NO_FLAGS_SET) < 0)
+ if(dblock && H5AC_unprotect(hdr->f, dxpl_id, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, dblock_cache_flags) < 0)
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap direct block")
FUNC_LEAVE_NOAPI(ret_value)
@@ -400,7 +412,7 @@ H5HF_man_read(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id, void *obj)
HDassert(obj);
/* Call the internal 'op' routine routine */
- if(H5HF_man_op_real(hdr, dxpl_id, id, H5HF_op_memcpy, obj) < 0)
+ if(H5HF_man_op_real(hdr, dxpl_id, id, H5HF_op_read, obj, 0) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "unable to operate on heap object")
done:
@@ -409,6 +421,44 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5HF_man_write
+ *
+ * Purpose: Write an object to a managed heap
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Dec 18 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5HF_man_write(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id,
+ const void *obj)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5HF_man_write)
+
+ /*
+ * Check arguments.
+ */
+ HDassert(hdr);
+ HDassert(id);
+ HDassert(obj);
+
+ /* Call the internal 'op' routine routine */
+ /* (Casting away const OK - QAK) */
+ if(H5HF_man_op_real(hdr, dxpl_id, id, H5HF_op_write, (void *)obj, H5HF_OP_MODIFY) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "unable to operate on heap object")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5HF_man_write() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5HF_man_op
*
* Purpose: Operate directly on an object from a managed heap
@@ -437,7 +487,7 @@ H5HF_man_op(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id,
HDassert(op);
/* Call the internal 'op' routine routine */
- if(H5HF_man_op_real(hdr, dxpl_id, id, op, op_data) < 0)
+ if(H5HF_man_op_real(hdr, dxpl_id, id, op, op_data, 0) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "unable to operate on heap object")
done: