summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-08-06 14:40:36 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-08-06 14:40:36 (GMT)
commit2f0dd6b2495428fc923a5c16fe02c33af509b396 (patch)
treead5716331bd67eddd51204914e451adffae19e9d
parent53f99e09662bdfe282b940a7111e4336ec14fed2 (diff)
downloadhdf5-2f0dd6b2495428fc923a5c16fe02c33af509b396.zip
hdf5-2f0dd6b2495428fc923a5c16fe02c33af509b396.tar.gz
hdf5-2f0dd6b2495428fc923a5c16fe02c33af509b396.tar.bz2
[svn-r17306] Description:
Stabilize file format changes for layout object header message and add new "storage" object header message. This version of the layout message (& future ones) will contain the constant information for a dataset's layout and the new storage message will contain information that can change over the course of a dataset's lifetime. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode Mac OS X/32 10.5.7 (amazon) in debug mode Mac OS X/32 10.5.7 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
-rw-r--r--MANIFEST1
-rwxr-xr-xconfigure2
-rw-r--r--src/H5Dchunk.c12
-rw-r--r--src/H5Dcompact.c16
-rw-r--r--src/H5Dlayout.c76
-rw-r--r--src/H5Doh.c13
-rw-r--r--src/H5Dprivate.h3
-rw-r--r--src/H5O.c1
-rw-r--r--src/H5Olayout.c312
-rw-r--r--src/H5Opkg.h5
-rw-r--r--src/H5Oprivate.h9
-rw-r--r--src/H5Ostorage.c738
-rwxr-xr-xsrc/Makefile.am7
-rw-r--r--src/Makefile.in66
14 files changed, 1076 insertions, 185 deletions
diff --git a/MANIFEST b/MANIFEST
index b6352ba..8094b38 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -691,6 +691,7 @@
./src/H5Oshared.h
./src/H5Oshmesg.c
./src/H5Ostab.c
+./src/H5Ostorage.c
./src/H5Otest.c
./src/H5Ounknown.c
./src/H5P.c
diff --git a/configure b/configure
index a46186c..85b7e3f 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
#! /bin/sh
-# From configure.in Id: configure.in 17159 2009-07-06 15:42:14Z lrknox .
+# From configure.in Id: configure.in 17210 2009-07-21 19:39:40Z koziol .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for HDF5 1.9.44-FA_a2.
#
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c
index 5a6634b..59c2e5d 100644
--- a/src/H5Dchunk.c
+++ b/src/H5Dchunk.c
@@ -4019,12 +4019,12 @@ H5D_chunk_addrmap(const H5D_io_info_t *io_info, haddr_t chunk_addr[])
HDassert(dset);
HDassert(dset->shared);
- HDassert((H5D_CHUNK_IDX_EARRAY == dset->shared->layout.u.chunk.idx_type &&
- H5D_COPS_EARRAY == dset->shared->layout.u.chunk.ops) ||
- (H5D_CHUNK_IDX_FARRAY == dset->shared->layout.u.chunk.idx_type &&
- H5D_COPS_FARRAY == dset->shared->layout.u.chunk.ops) ||
- (H5D_CHUNK_IDX_BTREE == dset->shared->layout.u.chunk.idx_type &&
- H5D_COPS_BTREE == dset->shared->layout.u.chunk.ops));
+ HDassert((H5D_CHUNK_IDX_EARRAY == dset->shared->layout.storage.u.chunk.idx_type &&
+ H5D_COPS_EARRAY == dset->shared->layout.storage.u.chunk.ops) ||
+ (H5D_CHUNK_IDX_FARRAY == dset->shared->layout.storage.u.chunk.idx_type &&
+ H5D_COPS_FARRAY == dset->shared->layout.storage.u.chunk.ops) ||
+ (H5D_CHUNK_IDX_BTREE == dset->shared->layout.storage.u.chunk.idx_type &&
+ H5D_COPS_BTREE == dset->shared->layout.storage.u.chunk.ops));
HDassert(chunk_addr);
/* Set up user data for B-tree callback */
diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c
index 831ab13..a33a62e 100644
--- a/src/H5Dcompact.c
+++ b/src/H5Dcompact.c
@@ -192,7 +192,10 @@ H5D_compact_construct(H5F_t *f, H5D_t *dset)
/* Verify data size is smaller than maximum header message size
* (64KB) minus other layout message fields.
*/
- max_comp_data_size = H5O_MESG_MAX_SIZE - H5D_layout_meta_size(f, &(dset->shared->layout), FALSE);
+ if(dset->shared->layout.version < H5O_LAYOUT_VERSION_4)
+ max_comp_data_size = H5O_MESG_MAX_SIZE - H5D_layout_meta_size(f, &(dset->shared->layout), FALSE);
+ else
+ max_comp_data_size = H5O_MESG_MAX_SIZE - H5O_storage_meta_size(f, &(dset->shared->layout.storage), FALSE);
if(dset->shared->layout.storage.u.compact.size > max_comp_data_size)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "compact dataset size is bigger than header message maximum size")
@@ -358,8 +361,15 @@ H5D_compact_flush(H5D_t *dset, hid_t dxpl_id, unsigned UNUSED flags)
/* Check if the buffered compact information is dirty */
if(dset->shared->layout.storage.u.compact.dirty) {
- if(H5O_msg_write(&(dset->oloc), H5O_LAYOUT_ID, 0, H5O_UPDATE_TIME, &(dset->shared->layout), dxpl_id) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to update layout message")
+ /* Check whether compact data is storage in layout or storage message */
+ if(dset->shared->layout.version < H5O_LAYOUT_VERSION_4) {
+ if(H5O_msg_write(&(dset->oloc), H5O_LAYOUT_ID, 0, H5O_UPDATE_TIME, &(dset->shared->layout), dxpl_id) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to update layout message")
+ } /* end if */
+ else {
+ if(H5O_msg_write(&(dset->oloc), H5O_STORAGE_ID, 0, H5O_UPDATE_TIME, &(dset->shared->layout.storage), dxpl_id) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to update layout message")
+ } /* end else */
dset->shared->layout.storage.u.compact.dirty = FALSE;
} /* end if */
diff --git a/src/H5Dlayout.c b/src/H5Dlayout.c
index 7f2fe1f..4453735 100644
--- a/src/H5Dlayout.c
+++ b/src/H5Dlayout.c
@@ -159,15 +159,21 @@ H5D_layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t include
switch(layout->type) {
case H5D_COMPACT:
- /* Size of raw data */
- ret_value += 2;
- if(include_compact_data)
- ret_value += layout->storage.u.compact.size;/* data for compact dataset */
+ /* This information only present in older versions of message */
+ if(layout->version < H5O_LAYOUT_VERSION_4) {
+ /* Size of raw data */
+ ret_value += 2;
+ if(include_compact_data)
+ ret_value += layout->storage.u.compact.size;/* data for compact dataset */
+ } /* end if */
break;
case H5D_CONTIGUOUS:
- ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */
- ret_value += H5F_SIZEOF_SIZE(f); /* Length of data */
+ /* This information only present in older versions of message */
+ if(layout->version < H5O_LAYOUT_VERSION_4) {
+ ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */
+ ret_value += H5F_SIZEOF_SIZE(f); /* Length of data */
+ } /* end if */
break;
case H5D_CHUNKED:
@@ -202,24 +208,17 @@ H5D_layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t include
switch(layout->u.chunk.idx_type) {
case H5D_CHUNK_IDX_BTREE: /* Remove this when v2 B-tree indices added */
- /* B-tree address */
- ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */
+ /* Nothing to do */
break;
case H5D_CHUNK_IDX_FARRAY:
/* Fixed array creation parameters */
ret_value += 1;
-
- /* Fixed array header address */
- ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */
break;
case H5D_CHUNK_IDX_EARRAY:
/* Extensible array creation parameters */
ret_value += 5;
-
- /* Extensible array header address */
- ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */
break;
default:
@@ -444,11 +443,24 @@ H5D_layout_oh_create(H5F_t *file, hid_t dxpl_id, H5O_t *oh, H5D_t *dset,
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update external file list message")
} /* end if */
- /* Create layout message */
- /* (Don't make layout message constant unless allocation time is early, since space may not be allocated) */
- /* (Note: this is relying on H5D_alloc_storage not calling H5O_msg_write during dataset creation) */
- if(H5O_msg_append_oh(file, dxpl_id, oh, H5O_LAYOUT_ID, ((fill_prop->alloc_time == H5D_ALLOC_TIME_EARLY && H5D_COMPACT != layout->type) ? H5O_MSG_FLAG_CONSTANT : 0), 0, layout) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update layout")
+ /* Check what version of the layout message to write */
+ if(layout->version < H5O_LAYOUT_VERSION_4) {
+ /* Create layout message */
+ /* (Don't make layout message constant unless allocation time is early, since space may not be allocated) */
+ /* (Note: this is relying on H5D_alloc_storage not calling H5O_msg_write during dataset creation) */
+ if(H5O_msg_append_oh(file, dxpl_id, oh, H5O_LAYOUT_ID, ((fill_prop->alloc_time == H5D_ALLOC_TIME_EARLY && H5D_COMPACT != layout->type) ? H5O_MSG_FLAG_CONSTANT : 0), 0, layout) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update layout")
+ } /* end if */
+ else {
+ /* Create layout message */
+ /* (Note: this is relying on H5D_alloc_storage not calling H5O_msg_write during dataset creation) */
+ if(H5O_msg_append_oh(file, dxpl_id, oh, H5O_LAYOUT_ID, H5O_MSG_FLAG_CONSTANT, 0, layout) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update layout")
+
+ /* Create storage message */
+ if(H5O_msg_append_oh(file, dxpl_id, oh, H5O_STORAGE_ID, 0, 0, &layout->storage) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update storage")
+ } /* end else */
done:
/* Error cleanup */
@@ -510,6 +522,15 @@ H5D_layout_oh_read(H5D_t *dataset, hid_t dxpl_id, hid_t dapl_id, H5P_genplist_t
if(NULL == H5O_msg_read(&(dataset->oloc), H5O_LAYOUT_ID, &(dataset->shared->layout), dxpl_id))
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read data layout message")
+ /* Check for newer version of the layout message, which indicates that some
+ * information is stored in the 'storage' message.
+ */
+ if(dataset->shared->layout.version >= H5O_LAYOUT_VERSION_4) {
+ /* Retrieve the storage information */
+ if(NULL == H5O_msg_read(&(dataset->oloc), H5O_STORAGE_ID, &(dataset->shared->layout.storage), dxpl_id))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read data storage message")
+ } /* end if */
+
/* Check for external file list message (which might not exist) */
if((msg_exists = H5O_msg_exists(&(dataset->oloc), H5O_EFL_ID, dxpl_id)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't check if message exists")
@@ -596,7 +617,7 @@ done:
/*-------------------------------------------------------------------------
* Function: H5D_layout_oh_write
*
- * Purpose: Read layout/pline/efl information for dataset
+ * Purpose: Write layout/pline/efl information for dataset
*
* Return: Success: SUCCEED
* Failure: FAIL
@@ -617,9 +638,18 @@ H5D_layout_oh_write(H5D_t *dataset, hid_t dxpl_id, H5O_t *oh, unsigned update_fl
HDassert(dataset);
HDassert(oh);
- /* Write the layout message to the dataset's header */
- if(H5O_msg_write_oh(dataset->oloc.file, dxpl_id, oh, H5O_LAYOUT_ID, H5O_MSG_FLAG_CONSTANT, update_flags, &dataset->shared->layout) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update layout message")
+ /* Determine which message to write, based on the version of the layout info */
+ if(dataset->shared->layout.version < H5O_LAYOUT_VERSION_4) {
+ /* Write the layout message to the dataset's header */
+ if(H5O_msg_write_oh(dataset->oloc.file, dxpl_id, oh, H5O_LAYOUT_ID, H5O_MSG_FLAG_CONSTANT, update_flags, &dataset->shared->layout) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update layout message")
+ } /* end if */
+ else {
+ /* Write the storage message to the dataset's header */
+ if(H5O_msg_write_oh(dataset->oloc.file, dxpl_id, oh, H5O_STORAGE_ID, 0, update_flags, &dataset->shared->layout.storage) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update storage message")
+ } /* end else */
+
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5Doh.c b/src/H5Doh.c
index d2649f7..e1d9827 100644
--- a/src/H5Doh.c
+++ b/src/H5Doh.c
@@ -155,6 +155,10 @@ H5O_dset_free_copy_file_udata(void *_udata)
if(udata->src_pline)
H5O_msg_free(H5O_PLINE_ID, udata->src_pline);
+ /* Release copy of dataset's layout, if it was set */
+ if(udata->src_layout)
+ H5O_msg_free(H5O_LAYOUT_ID, udata->src_layout);
+
/* Release space for 'copy file' user data */
(void)H5FL_FREE(H5D_copy_file_ud_t, udata);
@@ -375,6 +379,15 @@ H5O_dset_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info)
if(NULL == H5O_msg_read_oh(f, dxpl_id, oh, H5O_LAYOUT_ID, &layout))
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't find layout message")
+ /* Check for newer version of the layout message, which indicates that some
+ * information is stored in the 'storage' message.
+ */
+ if(layout.version >= H5O_LAYOUT_VERSION_4) {
+ /* Retrieve the storage information */
+ if(NULL == H5O_msg_read_oh(f, dxpl_id, oh, H5O_STORAGE_ID, &(layout.storage)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to read data storage message")
+ } /* end if */
+
/* Check for chunked dataset storage */
if(layout.type == H5D_CHUNKED && H5D_chunk_is_space_alloc(&layout.storage)) {
H5O_pline_t pline; /* I/O pipeline message */
diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h
index 4c6ed79..d5a1d16 100644
--- a/src/H5Dprivate.h
+++ b/src/H5Dprivate.h
@@ -143,7 +143,8 @@ typedef struct H5D_dcpl_cache_t {
typedef struct H5D_copy_file_ud_t {
struct H5S_extent_t *src_space_extent; /* Copy of dataspace extent for dataset */
H5T_t *src_dtype; /* Copy of datatype for dataset */
- H5O_pline_t *src_pline; /* Copy of filter pipeline for dataet */
+ H5O_pline_t *src_pline; /* Copy of filter pipeline for dataset */
+ H5O_layout_t *src_layout; /* Copy of layout for dataset */
} H5D_copy_file_ud_t;
diff --git a/src/H5O.c b/src/H5O.c
index 2017e1c..749f9ec 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -125,6 +125,7 @@ const H5O_msg_class_t *const H5O_msg_class_g[] = {
H5O_MSG_AINFO, /*0x0015 Attribute information */
H5O_MSG_REFCOUNT, /*0x0016 Object's ref. count */
H5O_MSG_UNKNOWN, /*0x0017 Placeholder for unknown message */
+ H5O_MSG_STORAGE, /*0x0018 Placeholder for unknown message */
};
/* Header object ID to class mapping */
diff --git a/src/H5Olayout.c b/src/H5Olayout.c
index 0156b2c..ce0e539 100644
--- a/src/H5Olayout.c
+++ b/src/H5Olayout.c
@@ -64,6 +64,8 @@ static herr_t H5O_layout_reset(void *_mesg);
static herr_t H5O_layout_free(void *_mesg);
static herr_t H5O_layout_delete(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh,
void *_mesg);
+static herr_t H5O_layout_pre_copy_file(H5F_t *file_src,
+ const void *mesg_src, hbool_t *deleted, const H5O_copy_t *cpy_info, void *_udata);
static void *H5O_layout_copy_file(H5F_t *file_src, void *mesg_src,
H5F_t *file_dst, hbool_t *recompute_size, H5O_copy_t *cpy_info,
void *udata, hid_t dxpl_id);
@@ -80,15 +82,15 @@ const H5O_msg_class_t H5O_MSG_LAYOUT[1] = {{
H5O_layout_encode, /*encode message */
H5O_layout_copy, /*copy the native value */
H5O_layout_size, /*size of message on disk */
- H5O_layout_reset, /*reset method */
+ H5O_layout_reset, /*reset method */
H5O_layout_free, /*free the struct */
H5O_layout_delete, /* file delete method */
NULL, /* link method */
NULL, /*set share method */
NULL, /*can share method */
- NULL, /* pre copy native value to file */
- H5O_layout_copy_file, /* copy native value to file */
- NULL, /* post copy native value to file */
+ H5O_layout_pre_copy_file, /* pre copy native value to file */
+ H5O_layout_copy_file, /* copy native value to file */
+ NULL, /* post copy native value to file */
NULL, /* get creation index */
NULL, /* set creation index */
H5O_layout_debug /*debug the message */
@@ -131,6 +133,7 @@ H5O_layout_decode(H5F_t *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh,
/* decode */
if(NULL == (mesg = H5FL_CALLOC(H5O_layout_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+ mesg->storage.type = H5D_LAYOUT_ERROR;
mesg->version = *p++;
if(mesg->version < H5O_LAYOUT_VERSION_1 || mesg->version > H5O_LAYOUT_VERSION_4)
@@ -148,6 +151,9 @@ H5O_layout_decode(H5F_t *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh,
mesg->type = (H5D_layout_t)*p++;
assert(H5D_CONTIGUOUS == mesg->type || H5D_CHUNKED == mesg->type || H5D_COMPACT == mesg->type);
+ /* Set the storage type */
+ mesg->storage.type = mesg->type;
+
/* Reserved bytes */
p += 5;
@@ -166,7 +172,7 @@ H5O_layout_decode(H5F_t *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh,
/* Set the chunk operations */
/* (Only "btree" indexing type currently supported in this version) */
- mesg->storage.u.chunk.idx_type = H5D_CHUNK_BTREE;
+ mesg->storage.u.chunk.idx_type = H5D_CHUNK_IDX_BTREE;
mesg->storage.u.chunk.ops = H5D_COPS_BTREE;
} /* end if */
else {
@@ -214,12 +220,21 @@ H5O_layout_decode(H5F_t *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh,
/* Interpret the rest of the message according to the layout class */
switch(mesg->type) {
case H5D_COMPACT:
- UINT16DECODE(p, mesg->storage.u.compact.size);
- if(mesg->storage.u.compact.size > 0) {
- if(NULL == (mesg->storage.u.compact.buf = H5MM_malloc(mesg->storage.u.compact.size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for compact data buffer")
- HDmemcpy(mesg->storage.u.compact.buf, p, mesg->storage.u.compact.size);
- p += mesg->storage.u.compact.size;
+ /* Check which version to decode */
+ /* (layout versions >= 4 have the compact data in the 'storage' message) */
+ if(mesg->version < H5O_LAYOUT_VERSION_4) {
+ /* Set the storage type */
+ mesg->storage.type = mesg->type;
+
+ /* Compact data size */
+ UINT16DECODE(p, mesg->storage.u.compact.size);
+
+ if(mesg->storage.u.compact.size > 0) {
+ if(NULL == (mesg->storage.u.compact.buf = H5MM_malloc(mesg->storage.u.compact.size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for compact data buffer")
+ HDmemcpy(mesg->storage.u.compact.buf, p, mesg->storage.u.compact.size);
+ p += mesg->storage.u.compact.size;
+ } /* end if */
} /* end if */
/* Set the layout operations */
@@ -227,8 +242,18 @@ H5O_layout_decode(H5F_t *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh,
break;
case H5D_CONTIGUOUS:
- H5F_addr_decode(f, &p, &(mesg->storage.u.contig.addr));
- H5F_DECODE_LENGTH(f, p, mesg->storage.u.contig.size);
+ /* Check which version to decode */
+ /* (layout versions >= 4 have the contiguous storage address in the 'storage' message) */
+ if(mesg->version < H5O_LAYOUT_VERSION_4) {
+ /* Set the storage type */
+ mesg->storage.type = mesg->type;
+
+ /* Contiguous storage address */
+ H5F_addr_decode(f, &p, &(mesg->storage.u.contig.addr));
+
+ /* Contiguous storage size */
+ H5F_DECODE_LENGTH(f, p, mesg->storage.u.contig.size);
+ } /* end if */
/* Set the layout operations */
mesg->ops = H5D_LOPS_CONTIG;
@@ -236,6 +261,9 @@ H5O_layout_decode(H5F_t *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh,
case H5D_CHUNKED:
if(mesg->version < H5O_LAYOUT_VERSION_4) {
+ /* Set the storage type */
+ mesg->storage.type = mesg->type;
+
/* Dimensionality */
mesg->u.chunk.ndims = *p++;
if(mesg->u.chunk.ndims > H5O_LAYOUT_NDIMS)
@@ -294,13 +322,9 @@ H5O_layout_decode(H5F_t *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh,
HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "unknown chunk index type")
mesg->storage.u.chunk.idx_type = mesg->u.chunk.idx_type;
- /* Chunk index address */
- H5F_addr_decode(f, &p, &(mesg->storage.u.chunk.idx_addr));
-
switch(mesg->u.chunk.idx_type) {
case H5D_CHUNK_IDX_BTREE: /* Remove this when v2 B-tree indices added */
- /* Set the chunk operations */
- mesg->storage.u.chunk.ops = H5D_COPS_BTREE;
+ /* Nothing to do */
break;
case H5D_CHUNK_IDX_FARRAY:
@@ -308,9 +332,6 @@ H5O_layout_decode(H5F_t *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh,
mesg->u.chunk.u.farray.cparam.max_dblk_page_nelmts_bits = *p++;
if(0 == mesg->u.chunk.u.farray.cparam.max_dblk_page_nelmts_bits)
HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "invalid fixed array creation parameter")
-
- /* Set the chunk operations */
- mesg->storage.u.chunk.ops = H5D_COPS_FARRAY;
break;
case H5D_CHUNK_IDX_EARRAY:
@@ -330,9 +351,6 @@ H5O_layout_decode(H5F_t *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh,
mesg->u.chunk.u.earray.cparam.max_dblk_page_nelmts_bits = *p++;
if(0 == mesg->u.chunk.u.earray.cparam.max_dblk_page_nelmts_bits)
HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "invalid extensible array creation parameter")
-
- /* Set the chunk operations */
- mesg->storage.u.chunk.ops = H5D_COPS_EARRAY;
break;
default:
@@ -419,22 +437,31 @@ H5O_layout_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const voi
/* Write out layout class specific information */
switch(mesg->type) {
case H5D_COMPACT:
- /* Size of raw data */
- UINT16ENCODE(p, mesg->storage.u.compact.size);
+ /* This information is stored in 'storage' message when version >= 4 */
+ if(mesg->version < H5O_LAYOUT_VERSION_4) {
+ /* Size of raw data */
+ UINT16ENCODE(p, mesg->storage.u.compact.size);
- /* Raw data */
- if(mesg->storage.u.compact.size > 0) {
- if(mesg->storage.u.compact.buf)
- HDmemcpy(p, mesg->storage.u.compact.buf, mesg->storage.u.compact.size);
- else
- HDmemset(p, 0, mesg->storage.u.compact.size);
- p += mesg->storage.u.compact.size;
+ /* Raw data */
+ if(mesg->storage.u.compact.size > 0) {
+ if(mesg->storage.u.compact.buf)
+ HDmemcpy(p, mesg->storage.u.compact.buf, mesg->storage.u.compact.size);
+ else
+ HDmemset(p, 0, mesg->storage.u.compact.size);
+ p += mesg->storage.u.compact.size;
+ } /* end if */
} /* end if */
break;
case H5D_CONTIGUOUS:
- H5F_addr_encode(f, &p, mesg->storage.u.contig.addr);
- H5F_ENCODE_LENGTH(f, p, mesg->storage.u.contig.size);
+ /* This information is stored in 'storage' message when version >= 4 */
+ if(mesg->version < H5O_LAYOUT_VERSION_4) {
+ /* Contiguous storage address */
+ H5F_addr_encode(f, &p, mesg->storage.u.contig.addr);
+
+ /* Contiguous storage size */
+ H5F_ENCODE_LENGTH(f, p, mesg->storage.u.contig.size);
+ } /* end if */
break;
case H5D_CHUNKED:
@@ -469,9 +496,6 @@ H5O_layout_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const voi
/* Chunk index type */
*p++ = (uint8_t)mesg->u.chunk.idx_type;
- /* Chunk index address */
- H5F_addr_encode(f, &p, mesg->storage.u.chunk.idx_addr);
-
switch(mesg->u.chunk.idx_type) {
case H5D_CHUNK_IDX_BTREE: /* Remove this when v2 B-tree indices added */
/* Nothing to do */
@@ -617,19 +641,23 @@ static herr_t
H5O_layout_reset(void *_mesg)
{
H5O_layout_t *mesg = (H5O_layout_t *)_mesg;
+ herr_t ret_value = SUCCEED;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_layout_reset)
+ FUNC_ENTER_NOAPI_NOINIT(H5O_layout_reset)
if(mesg) {
- /* Free the compact storage buffer */
- if(H5D_COMPACT == mesg->type)
- mesg->storage.u.compact.buf = H5MM_xfree(mesg->storage.u.compact.buf);
+ /* Reset associated storage information, if it's been initialized */
+ if(H5D_LAYOUT_ERROR != mesg->storage.type) {
+ if(H5O_storage_reset(&mesg->storage) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free message resources")
+ } /* end if */
/* Reset the message */
mesg->type = H5D_CONTIGUOUS;
} /* end if */
- FUNC_LEAVE_NOAPI(SUCCEED)
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_layout_reset() */
@@ -691,27 +719,30 @@ H5O_layout_delete(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, void *_mesg)
HDassert(open_oh);
HDassert(mesg);
- /* Perform different actions, depending on the type of storage */
- switch(mesg->type) {
- case H5D_COMPACT: /* Compact data storage */
- /* Nothing required */
- break;
+ /* Check version #, older versions are in charge of storage also */
+ if(mesg->version < H5O_LAYOUT_VERSION_4) {
+ /* Perform different actions, depending on the type of storage */
+ switch(mesg->type) {
+ case H5D_COMPACT: /* Compact data storage */
+ /* Nothing required */
+ break;
- case H5D_CONTIGUOUS: /* Contiguous block on disk */
- /* Free the file space for the raw data */
- if(H5D_contig_delete(f, dxpl_id, &mesg->storage) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free raw data")
- break;
+ case H5D_CONTIGUOUS: /* Contiguous block on disk */
+ /* Free the file space for the raw data */
+ if(H5D_contig_delete(f, dxpl_id, &mesg->storage) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free raw data")
+ break;
- case H5D_CHUNKED: /* Chunked blocks on disk */
- /* Free the file space for the index & chunk raw data */
- if(H5D_chunk_delete(f, dxpl_id, open_oh, &mesg->storage) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free raw data")
- break;
+ case H5D_CHUNKED: /* Chunked blocks on disk */
+ /* Free the file space for the index & chunk raw data */
+ if(H5D_chunk_delete(f, dxpl_id, open_oh, &mesg->storage) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free raw data")
+ break;
- default:
- HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, FAIL, "not valid storage type")
- } /* end switch */
+ default:
+ HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, FAIL, "not valid storage type")
+ } /* end switch */
+ } /* end if */
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -719,6 +750,47 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5O_layout_pre_copy_file
+ *
+ * Purpose: Perform any necessary actions before copying message between
+ * files
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * July 30, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O_layout_pre_copy_file(H5F_t UNUSED *file_src, const void *mesg_src,
+ hbool_t UNUSED *deleted, const H5O_copy_t UNUSED *cpy_info, void *_udata)
+{
+ const H5O_layout_t *layout_src = (const H5O_layout_t *)mesg_src; /* Source layout */
+ H5D_copy_file_ud_t *udata = (H5D_copy_file_ud_t *)_udata; /* Dataset copying user data */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5O_layout_pre_copy_file)
+
+ /* check args */
+ HDassert(layout_src);
+
+ /* If the user data is non-NULL, assume we are copying a dataset
+ * and make a copy of the layout for later in the object copying process,
+ * if the layout version is late enough that we know it will be needed
+ * by the 'storage' message.
+ */
+ if(udata && layout_src->version >= H5O_LAYOUT_VERSION_4)
+ if(NULL == (udata->src_layout = (H5O_layout_t *)H5O_layout_copy(layout_src, NULL)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy layout")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_layout_pre_copy_file() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5O_layout_copy_file
*
* Purpose: Copies a message from _MESG to _DEST in file
@@ -730,10 +802,6 @@ done:
* Programmer: Peter Cao
* July 23, 2005
*
- * Modifications:
- * Vailin Choi; April 2009
- * Reset address and pointer of the array struct for the chunked storage index
- *
*-------------------------------------------------------------------------
*/
static void *
@@ -749,56 +817,62 @@ H5O_layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst,
FUNC_ENTER_NOAPI_NOINIT(H5O_layout_copy_file)
/* check args */
+ HDassert(file_src);
HDassert(layout_src);
HDassert(file_dst);
- /* Allocate space for the destination layout */
- if(NULL == (layout_dst = H5FL_MALLOC(H5O_layout_t)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "memory allocation failed")
+ /* Copy the layout information */
+ if(NULL == (layout_dst = (H5O_layout_t *)H5O_layout_copy(layout_src, NULL)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy layout")
- /* Copy the "top level" information */
- *layout_dst = *layout_src;
-
- /* Copy the layout type specific information */
- switch(layout_src->type) {
- case H5D_COMPACT:
- if(layout_src->storage.u.compact.buf) {
- /* copy compact raw data */
- if(H5D_compact_copy(file_src, &layout_src->storage.u.compact, file_dst, &layout_dst->storage.u.compact, udata->src_dtype, cpy_info, dxpl_id) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy chunked storage")
- } /* end if */
- break;
+ /* Check if using version of layout message that encodes storage info */
+ if(layout_src->version < H5O_LAYOUT_VERSION_4) {
+ /* Copy the layout type specific information */
+ switch(layout_src->type) {
+ case H5D_COMPACT:
+ if(layout_src->storage.u.compact.buf) {
+ /* copy compact raw data */
+ if(H5D_compact_copy(file_src, &layout_src->storage.u.compact, file_dst, &layout_dst->storage.u.compact, udata->src_dtype, cpy_info, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy chunked storage")
+ } /* end if */
+ break;
- case H5D_CONTIGUOUS:
- /* Compute the size of the contiguous storage for versions of the
- * layout message less than version 3 because versions 1 & 2 would
- * truncate the dimension sizes to 32-bits of information. - QAK 5/26/04
- */
- if(layout_src->version < 3)
- layout_dst->storage.u.contig.size = H5S_extent_nelem(udata->src_space_extent) *
- H5T_get_size(udata->src_dtype);
-
- if(H5D_contig_is_space_alloc(&layout_src->storage)) {
- /* copy contiguous raw data */
- if(H5D_contig_copy(file_src, &layout_src->storage.u.contig, file_dst, &layout_dst->storage.u.contig, udata->src_dtype, cpy_info, dxpl_id) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy contiguous storage")
- } /* end if */
- break;
+ case H5D_CONTIGUOUS:
+ /* Compute the size of the contiguous storage for versions of the
+ * layout message less than version 3 because versions 1 & 2 would
+ * truncate the dimension sizes to 32-bits of information. - QAK 5/26/04
+ */
+ if(layout_src->version < 3)
+ layout_dst->storage.u.contig.size = H5S_extent_nelem(udata->src_space_extent) *
+ H5T_get_size(udata->src_dtype);
+
+ if(H5D_contig_is_space_alloc(&layout_src->storage)) {
+ /* copy contiguous raw data */
+ if(H5D_contig_copy(file_src, &layout_src->storage.u.contig, file_dst, &layout_dst->storage.u.contig, udata->src_dtype, cpy_info, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy contiguous storage")
+ } /* end if */
+ break;
- case H5D_CHUNKED:
- if(H5D_chunk_is_space_alloc(&layout_src->storage)) {
- /* Create chunked layout */
- if(H5D_chunk_copy(file_src, &layout_src->storage.u.chunk, &layout_src->u.chunk, file_dst, &layout_dst->storage.u.chunk, udata->src_space_extent, udata->src_dtype, udata->src_pline, cpy_info, dxpl_id) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy chunked storage")
- } /* end if */
- break;
+ case H5D_CHUNKED:
+ if(H5D_chunk_is_space_alloc(&layout_src->storage)) {
+ /* Create chunked layout */
+ if(H5D_chunk_copy(file_src, &layout_src->storage.u.chunk, &layout_src->u.chunk, file_dst, &layout_dst->storage.u.chunk, udata->src_space_extent, udata->src_dtype, udata->src_pline, cpy_info, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy chunked storage")
+ } /* end if */
+ break;
- default:
- HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "Invalid layout class")
- } /* end switch */
+ default:
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "Invalid layout class")
+ } /* end switch */
- /* Freed by copy routine */
- udata->src_dtype = NULL;
+ /* Freed by copy routine */
+ udata->src_dtype = NULL;
+ } /* end if */
+ else {
+ /* Dataset's raw data will be copied using the 'storage' message, reset storage her */
+ if(H5O_storage_reset(&layout_dst->storage) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, NULL, "unable to free message resources")
+ } /* end else */
/* Set return value */
ret_value = layout_dst;
@@ -859,7 +933,7 @@ H5O_layout_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg,
HDfprintf(stream, "}\n");
/* Index information */
- switch(mesg->storage.u.chunk.idx_type) {
+ switch(mesg->u.chunk.idx_type) {
case H5D_CHUNK_IDX_BTREE:
HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
"Index Type:", "v1 B-tree");
@@ -877,27 +951,31 @@ H5O_layout_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg,
default:
HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth,
- "Index Type:", "Unknown", (unsigned)mesg->storage.u.chunk.idx_type);
+ "Index Type:", "Unknown", (unsigned)mesg->u.chunk.idx_type);
break;
} /* end switch */
- HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,
- "Index address:", mesg->storage.u.chunk.idx_addr);
+ if(mesg->version < H5O_LAYOUT_VERSION_4)
+ HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,
+ "Index address:", mesg->storage.u.chunk.idx_addr);
break;
case H5D_CONTIGUOUS:
HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
"Type:", "Contiguous");
- HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,
- "Data address:", mesg->storage.u.contig.addr);
- HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth,
- "Data Size:", mesg->storage.u.contig.size);
+ if(mesg->version < H5O_LAYOUT_VERSION_4) {
+ HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,
+ "Data address:", mesg->storage.u.contig.addr);
+ HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth,
+ "Data Size:", mesg->storage.u.contig.size);
+ } /* end if */
break;
case H5D_COMPACT:
HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
"Type:", "Compact");
- HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth,
- "Data Size:", mesg->storage.u.compact.size);
+ if(mesg->version < H5O_LAYOUT_VERSION_4)
+ HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth,
+ "Data Size:", mesg->storage.u.compact.size);
break;
default:
diff --git a/src/H5Opkg.h b/src/H5Opkg.h
index c2e58dd..90f3997 100644
--- a/src/H5Opkg.h
+++ b/src/H5Opkg.h
@@ -30,7 +30,7 @@
#define H5O_NMESGS 8 /*initial number of messages */
#define H5O_NCHUNKS 2 /*initial number of chunks */
#define H5O_MIN_SIZE 22 /* Min. obj header data size (must be big enough for a message prefix and a continuation message) */
-#define H5O_MSG_TYPES 24 /* # of types of messages */
+#define H5O_MSG_TYPES 25 /* # of types of messages */
#define H5O_MAX_CRT_ORDER_IDX 65535 /* Max. creation order index value */
/* Versions of object header structure */
@@ -454,6 +454,9 @@ H5_DLLVAR const H5O_msg_class_t H5O_MSG_REFCOUNT[1];
/* Placeholder for unknown message. (0x0017) */
H5_DLLVAR const H5O_msg_class_t H5O_MSG_UNKNOWN[1];
+/* Data Storage Message. (0x0018) */
+H5_DLLVAR const H5O_msg_class_t H5O_MSG_STORAGE[1];
+
/*
* Object header "object" types
diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h
index 251e770..21362b0 100644
--- a/src/H5Oprivate.h
+++ b/src/H5Oprivate.h
@@ -150,7 +150,7 @@ typedef struct H5O_copy_t {
#define H5O_FILL_NEW_ID 0x0005 /* Fill Value Message. (New) */
#define H5O_LINK_ID 0x0006 /* Link Message. */
#define H5O_EFL_ID 0x0007 /* External File List Message */
-#define H5O_LAYOUT_ID 0x0008 /* Data Storage Layout Message. */
+#define H5O_LAYOUT_ID 0x0008 /* Data Layout Message. */
#define H5O_BOGUS_ID 0x0009 /* "Bogus" Message. */
#define H5O_GINFO_ID 0x000a /* Group info Message. */
#define H5O_PLINE_ID 0x000b /* Filter pipeline message. */
@@ -167,6 +167,7 @@ typedef struct H5O_copy_t {
#define H5O_REFCOUNT_ID 0x0016 /* Reference count message. */
#define H5O_UNKNOWN_ID 0x0017 /* Placeholder message ID for unknown message. */
/* (this should never exist in a file) */
+#define H5O_STORAGE_ID 0x0018 /* Data Storage message. */
/* Shared object message types.
@@ -728,6 +729,12 @@ H5_DLL herr_t H5O_loc_copy(H5O_loc_t *dst, const H5O_loc_t *src, H5_copy_depth_t
H5_DLL herr_t H5O_loc_hold_file(H5O_loc_t *loc);
H5_DLL herr_t H5O_loc_free(H5O_loc_t *loc);
+/* Storage operators */
+H5_DLL void *H5O_storage_copy(const void *mesg, void *dest);
+H5_DLL herr_t H5O_storage_reset(void *mesg);
+H5_DLL size_t H5O_storage_meta_size(const H5F_t *f, const H5O_storage_t *storage,
+ hbool_t include_compact_data);
+
/* EFL operators */
H5_DLL hsize_t H5O_efl_total_size(H5O_efl_t *efl);
diff --git a/src/H5Ostorage.c b/src/H5Ostorage.c
new file mode 100644
index 0000000..0229677
--- /dev/null
+++ b/src/H5Ostorage.c
@@ -0,0 +1,738 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/* Programmer: Quincey Koziol <koziol@hdfgroup.org>
+ * Wednesday, July 29, 2009
+ *
+ * Purpose: Message related to data storage.
+ */
+
+#define H5D_PACKAGE /*suppress error about including H5Dpkg */
+#define H5O_PACKAGE /*suppress error about including H5Opkg */
+
+#include "H5private.h" /* Generic Functions */
+#include "H5Dpkg.h" /* Dataset functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5FLprivate.h" /* Free Lists */
+#include "H5MMprivate.h" /* Memory management */
+#include "H5Opkg.h" /* Object headers */
+
+
+/* Local macros */
+
+/* Current version of storage information */
+#define H5O_STORAGE_VERSION 0
+
+/* Flags for chunked storage feature encoding */
+#ifdef NOT_YET
+#define H5O_STORAGE_CHUNK_HAVE_ELEM_INDEX 0x02
+#define H5O_STORAGE_ALL_CHUNK_FLAGS ( \
+ H5O_STORAGE_CHUNK_HAVE_ELEM_INDEX \
+ | H5O_STORAGE_CHUNK_HAVE_CHUNK_INDEX \
+ )
+#else /* NOT_YET */
+#define H5O_STORAGE_CHUNK_HAVE_CHUNK_INDEX 0x01
+#define H5O_STORAGE_ALL_CHUNK_FLAGS H5O_STORAGE_CHUNK_HAVE_CHUNK_INDEX
+#endif /* NOT_YET */
+
+
+/* PRIVATE PROTOTYPES */
+static void *H5O_storage_decode(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh,
+ unsigned mesg_flags, unsigned *ioflags, const uint8_t *p);
+static herr_t H5O_storage_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg);
+static size_t H5O_storage_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg);
+static herr_t H5O_storage_free(void *_mesg);
+static herr_t H5O_storage_delete(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh,
+ void *_mesg);
+static void *H5O_storage_copy_file(H5F_t *file_src, void *mesg_src,
+ H5F_t *file_dst, hbool_t *recompute_size, H5O_copy_t *cpy_info,
+ void *udata, hid_t dxpl_id);
+static herr_t H5O_storage_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream,
+ int indent, int fwidth);
+
+/* This message derives from H5O message class */
+const H5O_msg_class_t H5O_MSG_STORAGE[1] = {{
+ H5O_STORAGE_ID, /*message id number */
+ "storage", /*message name for debugging */
+ sizeof(H5O_storage_t), /*native message size */
+ 0, /* messages are sharable? */
+ H5O_storage_decode, /*decode message */
+ H5O_storage_encode, /*encode message */
+ H5O_storage_copy, /*copy the native value */
+ H5O_storage_size, /*size of message on disk */
+ H5O_storage_reset, /*reset method */
+ H5O_storage_free, /*free the struct */
+ H5O_storage_delete, /* file delete method */
+ NULL, /* link method */
+ NULL, /*set share method */
+ NULL, /*can share method */
+ NULL, /* pre copy native value to file */
+ H5O_storage_copy_file, /* copy native value to file */
+ NULL, /* post copy native value to file */
+ NULL, /* get creation index */
+ NULL, /* set creation index */
+ H5O_storage_debug /*debug the message */
+}};
+
+
+/* Declare a free list to manage the H5O_storage_t struct */
+H5FL_DEFINE_STATIC(H5O_storage_t);
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_storage_decode
+ *
+ * Purpose: Decode a data storage message and return a pointer to a
+ * new one created with malloc().
+ *
+ * Return: Success: Ptr to new message in native order.
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Wednesday, July 29, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static void *
+H5O_storage_decode(H5F_t *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh,
+ unsigned UNUSED mesg_flags, unsigned UNUSED *ioflags, const uint8_t *p)
+{
+ H5O_storage_t *mesg = NULL; /* Message decoded */
+ uint8_t version; /* Version of message decoded */
+ void *ret_value; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5O_storage_decode)
+
+ /* check args */
+ HDassert(f);
+ HDassert(p);
+
+ /* Allocate new message */
+ if(NULL == (mesg = H5FL_CALLOC(H5O_storage_t)))
+ HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "memory allocation failed")
+
+ /* decode */
+ version = *p++;
+ if(H5O_STORAGE_VERSION != version)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for message")
+
+ /* Layout class */
+ mesg->type = (H5D_layout_t)*p++;
+
+ /* Interpret the rest of the message according to the layout class */
+ switch(mesg->type) {
+ case H5D_COMPACT:
+ /* Compact data size */
+ UINT16DECODE(p, mesg->u.compact.size);
+
+ /* Check for any data stored */
+ if(mesg->u.compact.size > 0) {
+ /* Allocate space for compact data */
+ if(NULL == (mesg->u.compact.buf = H5MM_malloc(mesg->u.compact.size)))
+ HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "memory allocation failed for compact data buffer")
+
+ /* Compact data */
+ HDmemcpy(mesg->u.compact.buf, p, mesg->u.compact.size);
+ p += mesg->u.compact.size;
+ } /* end if */
+ break;
+
+ case H5D_CONTIGUOUS:
+ /* Contiguous storage address */
+ H5F_addr_decode(f, &p, &(mesg->u.contig.addr));
+
+ /* Contiguous storage size */
+ H5F_DECODE_LENGTH(f, p, mesg->u.contig.size);
+ break;
+
+ case H5D_CHUNKED:
+ {
+ uint8_t flags; /* Flags for decoding chunk feature info */
+
+ /* Get the chunked layout flags */
+ flags = *p++;
+
+ /* Check for valid flags */
+ if(flags & ~H5O_STORAGE_ALL_CHUNK_FLAGS)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad flag value for message")
+
+ /* Check for chunk index */
+ if(flags & H5O_STORAGE_CHUNK_HAVE_CHUNK_INDEX) {
+ /* Chunk index type */
+ mesg->u.chunk.idx_type = (H5D_chunk_index_t)*p++;
+ switch(mesg->u.chunk.idx_type) {
+ case H5D_CHUNK_IDX_BTREE: /* Remove this when v2 B-tree indices added */
+ /* Set the chunk operations */
+ mesg->u.chunk.ops = H5D_COPS_BTREE;
+ break;
+
+ case H5D_CHUNK_IDX_FARRAY:
+ /* Set the chunk operations */
+ mesg->u.chunk.ops = H5D_COPS_FARRAY;
+ break;
+
+ case H5D_CHUNK_IDX_EARRAY:
+ /* Set the chunk operations */
+ mesg->u.chunk.ops = H5D_COPS_EARRAY;
+ break;
+
+ default:
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "Invalid chunk index type")
+ } /* end switch */
+
+ /* Chunk index address */
+ H5F_addr_decode(f, &p, &(mesg->u.chunk.idx_addr));
+ } /* end if */
+ } /* end block */
+ break;
+
+ default:
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "Invalid layout class")
+ } /* end switch */
+
+ /* Set return value */
+ ret_value = mesg;
+
+done:
+ if(ret_value == NULL)
+ if(mesg)
+ (void)H5FL_FREE(H5O_storage_t, mesg);
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_storage_decode() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_storage_encode
+ *
+ * Purpose: Encodes a message.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Wednesday, July 29, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O_storage_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p,
+ const void *_mesg)
+{
+ const H5O_storage_t *mesg = (const H5O_storage_t *) _mesg;
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5O_storage_encode)
+
+ /* check args */
+ HDassert(f);
+ HDassert(mesg);
+ HDassert(p);
+
+ /* Message version */
+ *p++ = (uint8_t)H5O_STORAGE_VERSION;
+
+ /* Layout class */
+ *p++ = mesg->type;
+
+ /* Write out layout class specific information */
+ switch(mesg->type) {
+ case H5D_COMPACT:
+ /* Size of raw data */
+ UINT16ENCODE(p, mesg->u.compact.size);
+
+ /* Raw data */
+ if(mesg->u.compact.size > 0) {
+ if(mesg->u.compact.buf)
+ HDmemcpy(p, mesg->u.compact.buf, mesg->u.compact.size);
+ else
+ HDmemset(p, 0, mesg->u.compact.size);
+ p += mesg->u.compact.size;
+ } /* end if */
+ break;
+
+ case H5D_CONTIGUOUS:
+ /* Contiguous storage address */
+ H5F_addr_encode(f, &p, mesg->u.contig.addr);
+
+ /* Contiguous storage size */
+ H5F_ENCODE_LENGTH(f, p, mesg->u.contig.size);
+ break;
+
+ case H5D_CHUNKED:
+ {
+ /* Chunk feature flags */
+ *p++ = (uint8_t)H5O_STORAGE_CHUNK_HAVE_CHUNK_INDEX;
+
+ /* Chunk index type */
+ *p++ = (uint8_t)mesg->u.chunk.idx_type;
+
+ /* Chunk index address */
+ H5F_addr_encode(f, &p, mesg->u.chunk.idx_addr);
+ } /* end block */
+ break;
+
+ default:
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "Invalid layout class")
+ } /* end switch */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_storage_encode() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_storage_copy
+ *
+ * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if
+ * necessary.
+ *
+ * Return: Success: Ptr to _DEST
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Wednesday, July 29, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+void *
+H5O_storage_copy(const void *_mesg, void *_dest)
+{
+ const H5O_storage_t *mesg = (const H5O_storage_t *) _mesg;
+ H5O_storage_t *dest = (H5O_storage_t *) _dest;
+ void *ret_value; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5O_storage_copy)
+
+ /* check args */
+ HDassert(mesg);
+ if(!dest && NULL == (dest = H5FL_MALLOC(H5O_storage_t)))
+ HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "memory allocation failed")
+
+ /* copy */
+ *dest = *mesg;
+
+ /* Deep copy the buffer for compact datasets also */
+ if(mesg->type == H5D_COMPACT) {
+ if(mesg->u.compact.size > 0) {
+ /* Allocate memory for the raw data */
+ if(NULL == (dest->u.compact.buf = H5MM_malloc(dest->u.compact.size)))
+ HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "unable to allocate memory for compact dataset")
+
+ /* Copy over the raw data */
+ HDmemcpy(dest->u.compact.buf, mesg->u.compact.buf, dest->u.compact.size);
+ } /* end if */
+ else
+ HDassert(dest->u.compact.buf == NULL);
+ } /* end if */
+
+ /* Reset the pointer of the chunked storage index but not the address */
+ if(dest->type == H5D_CHUNKED && dest->u.chunk.ops)
+ H5D_chunk_idx_reset(&dest->u.chunk, FALSE);
+
+ /* Set return value */
+ ret_value = dest;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_storage_copy() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_storage_size
+ *
+ * Purpose: Returns the size of the raw message in bytes. If it's
+ * compact dataset, the data part is also included.
+ * This function doesn't take into account message alignment.
+ *
+ * Return: Success: Message data size in bytes
+ * Failure: 0
+ *
+ * Programmer: Quincey Koziol
+ * Wednesday, July 29, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static size_t
+H5O_storage_size(const H5F_t *f, hbool_t UNUSED disable_shared, const void *_mesg)
+{
+ const H5O_storage_t *mesg = (const H5O_storage_t *) _mesg;
+ size_t ret_value;
+
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_storage_size)
+
+ /* check args */
+ HDassert(f);
+ HDassert(mesg);
+
+ /* Compute the storage message's encoded size in the file */
+ /* (including possible compact data) */
+ ret_value = H5O_storage_meta_size(f, mesg, TRUE);
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_storage_size() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_storage_reset
+ *
+ * Purpose: Frees resources within a message, but doesn't free
+ * the message itself.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Wednesday, July 29, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_storage_reset(void *_mesg)
+{
+ H5O_storage_t *mesg = (H5O_storage_t *)_mesg;
+
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_storage_reset)
+
+ if(mesg) {
+ /* Free the compact storage buffer */
+ if(H5D_COMPACT == mesg->type)
+ mesg->u.compact.buf = H5MM_xfree(mesg->u.compact.buf);
+
+ /* Reset the message */
+ mesg->type = H5D_CONTIGUOUS;
+ } /* end if */
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5O_storage_reset() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_storage_free
+ *
+ * Purpose: Free's the message
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Wednesday, July 29, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O_storage_free(void *_mesg)
+{
+ H5O_storage_t *mesg = (H5O_storage_t *) _mesg;
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_NOAPI_NOINIT(H5O_storage_free)
+
+ HDassert(mesg);
+
+ /* Free resources within the message */
+ if(H5O_storage_reset(mesg) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free message resources")
+
+ (void)H5FL_FREE(H5O_storage_t, mesg);
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_storage_free() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_storage_delete
+ *
+ * Purpose: Free file space referenced by message
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, July 30, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O_storage_delete(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, void *_mesg)
+{
+ H5O_storage_t *mesg = (H5O_storage_t *) _mesg;
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5O_storage_delete)
+
+ /* check args */
+ HDassert(f);
+ HDassert(open_oh);
+ HDassert(mesg);
+
+ /* Perform different actions, depending on the type of storage */
+ switch(mesg->type) {
+ case H5D_COMPACT: /* Compact data storage */
+ /* Nothing required */
+ break;
+
+ case H5D_CONTIGUOUS: /* Contiguous block on disk */
+ /* Free the file space for the raw data */
+ if(H5D_contig_delete(f, dxpl_id, mesg) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free raw data")
+ break;
+
+ case H5D_CHUNKED: /* Chunked blocks on disk */
+ /* Free the file space for the index & chunk raw data */
+ if(H5D_chunk_delete(f, dxpl_id, open_oh, mesg) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free raw data")
+ break;
+
+ default:
+ HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, FAIL, "not valid storage type")
+ } /* end switch */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_storage_delete() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_storage_copy_file
+ *
+ * Purpose: Copies a message from _MESG to _DEST in file
+ *
+ * Return: Success: Ptr to _DEST
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, July 30, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static void *
+H5O_storage_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst,
+ hbool_t UNUSED *recompute_size, H5O_copy_t *cpy_info, void *_udata,
+ hid_t dxpl_id)
+{
+ H5D_copy_file_ud_t *udata = (H5D_copy_file_ud_t *)_udata; /* Dataset copying user data */
+ H5O_storage_t *storage_src = (H5O_storage_t *)mesg_src;
+ H5O_storage_t *storage_dst = NULL;
+ void *ret_value; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5O_storage_copy_file)
+
+ /* check args */
+ HDassert(file_src);
+ HDassert(storage_src);
+ HDassert(file_dst);
+ HDassert(cpy_info);
+ HDassert(udata);
+ HDassert(udata->src_layout);
+ HDassert(udata->src_layout->version >= H5O_LAYOUT_VERSION_4 );
+
+ /* Allocate space for the destination storage */
+ if(NULL == (storage_dst = H5FL_MALLOC(H5O_storage_t)))
+ HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "memory allocation failed")
+
+ /* Copy the "top level" information */
+ *storage_dst = *storage_src;
+
+ /* Copy the storage type specific information */
+ switch(storage_src->type) {
+ case H5D_COMPACT:
+ if(storage_src->u.compact.buf) {
+ if(NULL == (storage_dst->u.compact.buf = H5MM_malloc(storage_src->u.compact.size)))
+ HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "unable to allocate memory for compact dataset")
+
+ /* Copy compact raw data */
+ if(H5D_compact_copy(file_src, &storage_src->u.compact, file_dst, &storage_dst->u.compact, udata->src_dtype, cpy_info, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy chunked storage")
+
+ storage_dst->u.compact.dirty = TRUE;
+ } /* end if */
+ break;
+
+ case H5D_CONTIGUOUS:
+ if(H5D_contig_is_space_alloc(storage_src)) {
+ /* Copy contiguous raw data */
+ if(H5D_contig_copy(file_src, &storage_src->u.contig, file_dst, &storage_dst->u.contig, udata->src_dtype, cpy_info, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy contiguous storage")
+ } /* end if */
+ break;
+
+ case H5D_CHUNKED:
+ if(H5D_chunk_is_space_alloc(storage_src)) {
+ /* Create chunked layout */
+ if(H5D_chunk_copy(file_src, &storage_src->u.chunk, &udata->src_layout->u.chunk, file_dst, &storage_dst->u.chunk, udata->src_space_extent, udata->src_dtype, udata->src_pline, cpy_info, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy chunked storage")
+ } /* end if */
+ break;
+
+ default:
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "Invalid layout class")
+ } /* end switch */
+
+ /* Freed by copy routine */
+ udata->src_dtype = NULL;
+
+ /* Set return value */
+ ret_value = storage_dst;
+
+done:
+ if(!ret_value)
+ if(storage_dst)
+ (void)H5FL_FREE(H5O_storage_t, storage_dst);
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_storage_copy_file() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_storage_debug
+ *
+ * Purpose: Prints debugging info for a message.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, July 30, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O_storage_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg,
+ FILE * stream, int indent, int fwidth)
+{
+ const H5O_storage_t *mesg = (const H5O_storage_t *) _mesg;
+
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_storage_debug)
+
+ /* check args */
+ HDassert(f);
+ HDassert(mesg);
+ HDassert(stream);
+ HDassert(indent >= 0);
+ HDassert(fwidth >= 0);
+
+ HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
+ "Version:", (unsigned)H5O_STORAGE_VERSION);
+ switch(mesg->type) {
+ case H5D_CHUNKED:
+ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Type:", "Chunked");
+
+ /* Index information */
+ switch(mesg->u.chunk.idx_type) {
+ case H5D_CHUNK_IDX_BTREE:
+ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Index Type:", "v1 B-tree");
+ break;
+
+ case H5D_CHUNK_IDX_FARRAY:
+ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Index Type:", "Fixed Array");
+ break;
+
+ case H5D_CHUNK_IDX_EARRAY:
+ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Index Type:", "Extensible Array");
+ break;
+
+ default:
+ HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth,
+ "Index Type:", "Unknown", (unsigned)mesg->u.chunk.idx_type);
+ break;
+ } /* end switch */
+ HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,
+ "Index address:", mesg->u.chunk.idx_addr);
+ break;
+
+ case H5D_CONTIGUOUS:
+ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Type:", "Contiguous");
+ HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,
+ "Data address:", mesg->u.contig.addr);
+ HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth,
+ "Data Size:", mesg->u.contig.size);
+ break;
+
+ case H5D_COMPACT:
+ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Type:", "Compact");
+ HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth,
+ "Data Size:", mesg->u.compact.size);
+ break;
+
+ default:
+ HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth,
+ "Type:", "Unknown", (unsigned)mesg->type);
+ break;
+ } /* end switch */
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5O_storage_debug() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_storage_meta_size
+ *
+ * Purpose: Returns the size of the raw message in bytes except raw data
+ * part for compact dataset. This function doesn't take into
+ * account message alignment.
+ *
+ * Return: Success: Message data size in bytes
+ * Failure: 0
+ *
+ * Programmer: Quincey Koziol
+ * July 29, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+size_t
+H5O_storage_meta_size(const H5F_t *f, const H5O_storage_t *storage,
+ hbool_t include_compact_data)
+{
+ size_t ret_value;
+
+ FUNC_ENTER_NOAPI_NOINIT(H5O_storage_meta_size)
+
+ /* check args */
+ HDassert(f);
+ HDassert(storage);
+
+ ret_value = 1 + /* Version number */
+ 1; /* Layout class type */
+
+ switch(storage->type) {
+ case H5D_COMPACT:
+ /* Size of raw data */
+ ret_value += 2;
+ if(include_compact_data)
+ ret_value += storage->u.compact.size;/* data for compact dataset */
+ break;
+
+ case H5D_CONTIGUOUS:
+ ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */
+ ret_value += H5F_SIZEOF_SIZE(f); /* Length of data */
+ break;
+
+ case H5D_CHUNKED:
+ ret_value += 1 + /* Chunk feature flags */
+ 1; /* Chunk index type */
+ ret_value += H5F_SIZEOF_ADDR(f); /* Chunk index address */
+ break;
+
+ default:
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, 0, "Invalid layout class")
+ } /* end switch */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_storage_meta_size() */
+
diff --git a/src/Makefile.am b/src/Makefile.am
index ce15dd9..8610c16 100755
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -81,8 +81,11 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \
H5Olayout.c \
H5Olinfo.c H5Olink.c H5Omessage.c H5Omtime.c \
H5Oname.c H5Onull.c H5Opline.c H5Orefcount.c \
- H5Osdspace.c H5Oshared.c H5Ostab.c \
- H5Oshmesg.c H5Otest.c H5Ounknown.c \
+ H5Osdspace.c H5Oshared.c \
+ H5Oshmesg.c \
+ H5Ostab.c \
+ H5Ostorage.c \
+ H5Otest.c H5Ounknown.c \
H5P.c H5Pacpl.c H5Pdapl.c H5Pdcpl.c \
H5Pdeprec.c H5Pdxpl.c H5Pfapl.c H5Pfcpl.c H5Pfmpl.c \
H5Pgcpl.c H5Pint.c \
diff --git a/src/Makefile.in b/src/Makefile.in
index 50a9e33..b6c0ac0 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -85,19 +85,20 @@ am_libhdf5_la_OBJECTS = H5.lo H5checksum.lo H5dbg.lo H5system.lo \
H5B2stat.lo H5B2test.lo H5C.lo H5CS.lo H5D.lo H5Dbtree.lo \
H5Dchunk.lo H5Dcompact.lo H5Dcontig.lo H5Ddbg.lo H5Ddeprec.lo \
H5Dearray.lo H5Defl.lo H5Dfarray.lo H5Dfill.lo H5Dint.lo \
- H5Dio.lo H5Dlayout.lo H5Dmpio.lo H5Doh.lo H5Dproxy.lo H5Dscatgath.lo \
- H5Dselect.lo H5Dtest.lo H5E.lo H5Edeprec.lo H5Eint.lo H5EA.lo \
- H5EAcache.lo H5EAdbg.lo H5EAdblkpage.lo H5EAdblock.lo \
- H5EAhdr.lo H5EAiblock.lo H5EAint.lo H5EAsblock.lo H5EAstat.lo \
- H5EAtest.lo H5F.lo H5Faccum.lo H5Fdbg.lo H5Ffake.lo H5Fio.lo \
- H5Fmount.lo H5Fmpi.lo H5Fquery.lo H5Fsfile.lo H5Fsuper.lo \
- H5Ftest.lo H5FA.lo H5FAcache.lo H5FAdbg.lo H5FAdblock.lo \
- H5FAdblkpage.lo H5FAhdr.lo H5FAstat.lo H5FAtest.lo H5FD.lo \
- H5FDcore.lo H5FDdirect.lo H5FDfamily.lo H5FDint.lo H5FDlog.lo \
- H5FDmpi.lo H5FDmpio.lo H5FDmpiposix.lo H5FDmulti.lo \
- H5FDsec2.lo H5FDspace.lo H5FDstdio.lo H5FL.lo H5FO.lo H5FS.lo \
- H5FScache.lo H5FSdbg.lo H5FSsection.lo H5FSstat.lo H5FStest.lo \
- H5G.lo H5Gbtree2.lo H5Gcache.lo H5Gcompact.lo H5Gdense.lo \
+ H5Dio.lo H5Dlayout.lo H5Dmpio.lo H5Doh.lo H5Dproxy.lo \
+ H5Dscatgath.lo H5Dselect.lo H5Dtest.lo H5E.lo H5Edeprec.lo \
+ H5Eint.lo H5EA.lo H5EAcache.lo H5EAdbg.lo H5EAdblkpage.lo \
+ H5EAdblock.lo H5EAhdr.lo H5EAiblock.lo H5EAint.lo \
+ H5EAsblock.lo H5EAstat.lo H5EAtest.lo H5F.lo H5Faccum.lo \
+ H5Fdbg.lo H5Ffake.lo H5Fio.lo H5Fmount.lo H5Fmpi.lo \
+ H5Fquery.lo H5Fsfile.lo H5Fsuper.lo H5Ftest.lo H5FA.lo \
+ H5FAcache.lo H5FAdbg.lo H5FAdblock.lo H5FAdblkpage.lo \
+ H5FAhdr.lo H5FAstat.lo H5FAtest.lo H5FD.lo H5FDcore.lo \
+ H5FDdirect.lo H5FDfamily.lo H5FDint.lo H5FDlog.lo H5FDmpi.lo \
+ H5FDmpio.lo H5FDmpiposix.lo H5FDmulti.lo H5FDsec2.lo \
+ H5FDspace.lo H5FDstdio.lo H5FL.lo H5FO.lo H5FS.lo H5FScache.lo \
+ H5FSdbg.lo H5FSsection.lo H5FSstat.lo H5FStest.lo H5G.lo \
+ H5Gbtree2.lo H5Gcache.lo H5Gcompact.lo H5Gdense.lo \
H5Gdeprec.lo H5Gent.lo H5Gint.lo H5Glink.lo H5Gloc.lo \
H5Gname.lo H5Gnode.lo H5Gobj.lo H5Goh.lo H5Groot.lo H5Gstab.lo \
H5Gtest.lo H5Gtraverse.lo H5HF.lo H5HFbtree2.lo H5HFcache.lo \
@@ -112,21 +113,22 @@ am_libhdf5_la_OBJECTS = H5.lo H5checksum.lo H5dbg.lo H5system.lo \
H5Odrvinfo.lo H5Odtype.lo H5Oefl.lo H5Ofill.lo H5Oginfo.lo \
H5Olayout.lo H5Olinfo.lo H5Olink.lo H5Omessage.lo H5Omtime.lo \
H5Oname.lo H5Onull.lo H5Opline.lo H5Orefcount.lo H5Osdspace.lo \
- H5Oshared.lo H5Ostab.lo H5Oshmesg.lo H5Otest.lo H5Ounknown.lo \
- H5P.lo H5Pacpl.lo H5Pdapl.lo H5Pdcpl.lo H5Pdeprec.lo \
- H5Pdxpl.lo H5Pfapl.lo H5Pfcpl.lo H5Pfmpl.lo H5Pgcpl.lo \
- H5Pint.lo H5Plapl.lo H5Plcpl.lo H5Pocpl.lo H5Pocpypl.lo \
- H5Pstrcpl.lo H5Ptest.lo H5R.lo H5Rdeprec.lo H5RC.lo H5RS.lo \
- H5S.lo H5Sall.lo H5Sdbg.lo H5Shyper.lo H5Smpio.lo H5Snone.lo \
- H5Spoint.lo H5Sselect.lo H5Stest.lo H5SL.lo H5SM.lo \
- H5SMbtree2.lo H5SMcache.lo H5SMtest.lo H5ST.lo H5T.lo \
- H5Tarray.lo H5Tbit.lo H5Tcommit.lo H5Tcompound.lo H5Tconv.lo \
- H5Tcset.lo H5Tdbg.lo H5Tdeprec.lo H5Tenum.lo H5Tfields.lo \
- H5Tfixed.lo H5Tfloat.lo H5Tinit.lo H5Tnative.lo H5Toffset.lo \
- H5Toh.lo H5Topaque.lo H5Torder.lo H5Tpad.lo H5Tprecis.lo \
- H5Tstrpad.lo H5Tvisit.lo H5Tvlen.lo H5TS.lo H5V.lo H5WB.lo \
- H5Z.lo H5Zdeflate.lo H5Zfletcher32.lo H5Znbit.lo H5Zshuffle.lo \
- H5Zszip.lo H5Zscaleoffset.lo H5Ztrans.lo
+ H5Oshared.lo H5Oshmesg.lo H5Ostab.lo H5Ostorage.lo H5Otest.lo \
+ H5Ounknown.lo H5P.lo H5Pacpl.lo H5Pdapl.lo H5Pdcpl.lo \
+ H5Pdeprec.lo H5Pdxpl.lo H5Pfapl.lo H5Pfcpl.lo H5Pfmpl.lo \
+ H5Pgcpl.lo H5Pint.lo H5Plapl.lo H5Plcpl.lo H5Pocpl.lo \
+ H5Pocpypl.lo H5Pstrcpl.lo H5Ptest.lo H5R.lo H5Rdeprec.lo \
+ H5RC.lo H5RS.lo H5S.lo H5Sall.lo H5Sdbg.lo H5Shyper.lo \
+ H5Smpio.lo H5Snone.lo H5Spoint.lo H5Sselect.lo H5Stest.lo \
+ H5SL.lo H5SM.lo H5SMbtree2.lo H5SMcache.lo H5SMtest.lo H5ST.lo \
+ H5T.lo H5Tarray.lo H5Tbit.lo H5Tcommit.lo H5Tcompound.lo \
+ H5Tconv.lo H5Tcset.lo H5Tdbg.lo H5Tdeprec.lo H5Tenum.lo \
+ H5Tfields.lo H5Tfixed.lo H5Tfloat.lo H5Tinit.lo H5Tnative.lo \
+ H5Toffset.lo H5Toh.lo H5Topaque.lo H5Torder.lo H5Tpad.lo \
+ H5Tprecis.lo H5Tstrpad.lo H5Tvisit.lo H5Tvlen.lo H5TS.lo \
+ H5V.lo H5WB.lo H5Z.lo H5Zdeflate.lo H5Zfletcher32.lo \
+ H5Znbit.lo H5Zshuffle.lo H5Zszip.lo H5Zscaleoffset.lo \
+ H5Ztrans.lo
libhdf5_la_OBJECTS = $(am_libhdf5_la_OBJECTS)
libhdf5_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
@@ -467,8 +469,11 @@ libhdf5_la_SOURCES = H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \
H5Olayout.c \
H5Olinfo.c H5Olink.c H5Omessage.c H5Omtime.c \
H5Oname.c H5Onull.c H5Opline.c H5Orefcount.c \
- H5Osdspace.c H5Oshared.c H5Ostab.c \
- H5Oshmesg.c H5Otest.c H5Ounknown.c \
+ H5Osdspace.c H5Oshared.c \
+ H5Oshmesg.c \
+ H5Ostab.c \
+ H5Ostorage.c \
+ H5Otest.c H5Ounknown.c \
H5P.c H5Pacpl.c H5Pdapl.c H5Pdcpl.c \
H5Pdeprec.c H5Pdxpl.c H5Pfapl.c H5Pfcpl.c H5Pfmpl.c \
H5Pgcpl.c H5Pint.c \
@@ -793,6 +798,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Oshared.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Oshmesg.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Ostab.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Ostorage.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Otest.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Ounknown.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5P.Plo@am__quote@