summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5O.c26
-rw-r--r--src/H5Ocache.c58
-rw-r--r--src/H5Opkg.h11
-rw-r--r--src/H5Opublic.h10
-rw-r--r--test/stab.c8
-rw-r--r--tools/testfiles/h5mkgrp_nested_latest.ls4
-rw-r--r--tools/testfiles/h5mkgrp_nested_mult_latest.ls8
-rw-r--r--tools/testfiles/h5mkgrp_several_latest.ls4
-rw-r--r--tools/testfiles/h5mkgrp_single_latest.ls2
9 files changed, 102 insertions, 29 deletions
diff --git a/src/H5O.c b/src/H5O.c
index 9ac1dd1..775ee4d 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -677,6 +677,8 @@ H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, hid_t ocpl_id,
/* Initialize version-specific fields */
if(oh->version > H5O_VERSION_1) {
+ size_t tent_oh_size; /* Tentative size of object header */
+
/* Initialize all time fields with current time, if we are storing them */
if(oh->flags & H5O_HDR_STORE_TIMES)
oh->atime = oh->mtime = oh->ctime = oh->btime = H5_now();
@@ -698,6 +700,30 @@ H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, hid_t ocpl_id,
/* Check for non-default attribute storage phase change values */
if(oh->max_compact != H5O_CRT_ATTR_MAX_COMPACT_DEF || oh->min_dense != H5O_CRT_ATTR_MIN_DENSE_DEF)
oh->flags |= H5O_HDR_ATTR_STORE_PHASE_CHANGE;
+
+ /* Determine correct value for chunk #0 size bits */
+
+ /* See if only 1 byte is enough */
+ tent_oh_size = H5O_SIZEOF_HDR(oh) + size_hint;
+ if(tent_oh_size > 255) {
+ uint8_t old_oh_flags = oh->flags; /* Temporary object header flags */
+
+ /* Need more than 1 byte, see if 2 bytes is enough */
+ oh->flags |= H5O_HDR_CHUNK0_2;
+ tent_oh_size = H5O_SIZEOF_HDR(oh) + size_hint;
+ if(tent_oh_size > 65535) {
+ /* Need more than 2 bytes, see if 4 bytes is enough */
+ oh->flags = old_oh_flags;
+ oh->flags |= H5O_HDR_CHUNK0_4;
+ tent_oh_size = H5O_SIZEOF_HDR(oh) + size_hint;
+ if(tent_oh_size > 4294967295) {
+ /* Use 8 bytes */
+ /* (Should probably have check for using more than 8 bytes... :-) */
+ oh->flags = old_oh_flags;
+ oh->flags |= H5O_HDR_CHUNK0_8;
+ } /* end if */
+ } /* end if */
+ } /* end if */
} /* end if */
else {
/* Reset unused time fields */
diff --git a/src/H5Ocache.c b/src/H5Ocache.c
index 706497f..16e6278 100644
--- a/src/H5Ocache.c
+++ b/src/H5Ocache.c
@@ -279,7 +279,7 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1,
/* Flags */
oh->flags = *p++;
if(oh->flags & ~H5O_HDR_ALL_FLAGS)
- HGOTO_ERROR(H5E_OHDR, H5E_VERSION, NULL, "unknown object header status flag(s)")
+ HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "unknown object header status flag(s)")
/* Number of messages (to allocate initially) */
nmesgs = 1;
@@ -324,6 +324,28 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1,
oh->max_compact = H5O_CRT_ATTR_MAX_COMPACT_DEF;
oh->min_dense = H5O_CRT_ATTR_MIN_DENSE_DEF;
} /* end else */
+
+ /* First chunk size */
+ switch(oh->flags & H5O_HDR_CHUNK0_SIZE) {
+ case 0: /* 1 byte size */
+ chunk_size = *p++;
+ break;
+
+ case 1: /* 2 byte size */
+ UINT16DECODE(p, chunk_size);
+ break;
+
+ case 2: /* 4 byte size */
+ UINT32DECODE(p, chunk_size);
+ break;
+
+ case 3: /* 8 byte size */
+ UINT64DECODE(p, chunk_size);
+ break;
+
+ default:
+ HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "bad size for chunk 0")
+ } /* end switch */
} /* end if */
else {
/* Reset unused time fields */
@@ -332,10 +354,10 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1,
/* Reset unused attribute fields */
oh->max_compact = 0;
oh->min_dense = 0;
- } /* end else */
- /* First chunk size */
- UINT32DECODE(p, chunk_size);
+ /* First chunk size */
+ UINT32DECODE(p, chunk_size);
+ } /* end else */
/* Reserved, in version 1 */
if(H5O_VERSION_1 == oh->version)
@@ -412,8 +434,7 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1,
} /* end if */
else {
/* Read the chunk raw data */
- if(H5F_block_read(f, H5FD_MEM_OHDR, chunk_addr, chunk_size,
- dxpl_id, oh->chunk[chunkno].image) < 0)
+ if(H5F_block_read(f, H5FD_MEM_OHDR, chunk_addr, chunk_size, dxpl_id, oh->chunk[chunkno].image) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "unable to read object header data")
/* Point into chunk image to decode */
@@ -649,6 +670,8 @@ H5O_assert(oh);
* on the entire block of memory needs to be updated if anything is
* modified */
if(oh->version > H5O_VERSION_1) {
+ uint64_t chunk0_size = oh->chunk[0].size - H5O_SIZEOF_HDR(oh); /* Size of chunk 0's data */
+
/* Verify magic number */
HDassert(!HDmemcmp(p, H5O_HDR_MAGIC, H5O_SIZEOF_MAGIC));
p += H5O_SIZEOF_MAGIC;
@@ -676,8 +699,27 @@ H5O_assert(oh);
UINT16ENCODE(p, oh->min_dense);
} /* end if */
- /* Chunk size */
- UINT32ENCODE(p, (oh->chunk[0].size - H5O_SIZEOF_HDR(oh)));
+ /* First chunk size */
+ switch(oh->flags & H5O_HDR_CHUNK0_SIZE) {
+ case 0: /* 1 byte size */
+ *p++ = chunk0_size;
+ break;
+
+ case 1: /* 2 byte size */
+ UINT16ENCODE(p, chunk0_size);
+ break;
+
+ case 2: /* 4 byte size */
+ UINT32ENCODE(p, chunk0_size);
+ break;
+
+ case 3: /* 8 byte size */
+ UINT64ENCODE(p, chunk0_size);
+ break;
+
+ default:
+ HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "bad size for chunk 0")
+ } /* end switch */
} /* end if */
else {
/* Version */
diff --git a/src/H5Opkg.h b/src/H5Opkg.h
index 65d4914..17532e0 100644
--- a/src/H5Opkg.h
+++ b/src/H5Opkg.h
@@ -88,6 +88,12 @@
#define H5O_CRT_ATTR_MIN_DENSE_DEF 6
#define H5O_CRT_OHDR_FLAGS_DEF H5O_HDR_STORE_TIMES
+/* Object header status flag definitions */
+#define H5O_HDR_CHUNK0_1 0x00
+#define H5O_HDR_CHUNK0_2 0x01
+#define H5O_HDR_CHUNK0_4 0x02
+#define H5O_HDR_CHUNK0_8 0x03
+
/*
* Size of object header prefix.
*/
@@ -114,7 +120,7 @@
2 + /*max compact attributes */ \
2 /*min dense attributes */ \
) : 0) + \
- 4 + /*chunk data size */ \
+ (1 << ((O)->flags & H5O_HDR_CHUNK0_SIZE)) + /*chunk 0 data size */ \
H5O_SIZEOF_CHKSUM) /*checksum size */ \
)
@@ -188,9 +194,6 @@
} /* end if */ \
} /* end if */
-/* All the object header status flags that this version of the library knows about */
-#define H5O_HDR_ALL_FLAGS (H5O_HDR_ATTR_CRT_ORDER_TRACKED | H5O_HDR_ATTR_CRT_ORDER_INDEXED | H5O_HDR_ATTR_STORE_PHASE_CHANGE | H5O_HDR_STORE_TIMES)
-
/* The "message class" type */
struct H5O_msg_class_t {
diff --git a/src/H5Opublic.h b/src/H5Opublic.h
index 73c4581..b3d0c36 100644
--- a/src/H5Opublic.h
+++ b/src/H5Opublic.h
@@ -61,10 +61,12 @@
#define H5O_MESG_ALL_FLAG (H5O_MESG_SDSPACE_FLAG | H5O_MESG_DTYPE_FLAG | H5O_MESG_FILL_FLAG | H5O_MESG_PLINE_FLAG | H5O_MESG_ATTR_FLAG)
/* Object header status flag definitions */
-#define H5O_HDR_ATTR_CRT_ORDER_TRACKED 0x01 /* Attribute creation order is tracked */
-#define H5O_HDR_ATTR_CRT_ORDER_INDEXED 0x02 /* Attribute creation order has index */
-#define H5O_HDR_ATTR_STORE_PHASE_CHANGE 0x04 /* Non-default attribute storage phase change values stored */
-#define H5O_HDR_STORE_TIMES 0x08 /* Store access, modification, change & birth times for object */
+#define H5O_HDR_CHUNK0_SIZE 0x03 /* 2-bit field indicating # of bytes to store the size of chunk 0's data */
+#define H5O_HDR_ATTR_CRT_ORDER_TRACKED 0x04 /* Attribute creation order is tracked */
+#define H5O_HDR_ATTR_CRT_ORDER_INDEXED 0x08 /* Attribute creation order has index */
+#define H5O_HDR_ATTR_STORE_PHASE_CHANGE 0x10 /* Non-default attribute storage phase change values stored */
+#define H5O_HDR_STORE_TIMES 0x20 /* Store access, modification, change & birth times for object */
+#define H5O_HDR_ALL_FLAGS (H5O_HDR_CHUNK0_SIZE | H5O_HDR_ATTR_CRT_ORDER_TRACKED | H5O_HDR_ATTR_CRT_ORDER_INDEXED | H5O_HDR_ATTR_STORE_PHASE_CHANGE | H5O_HDR_STORE_TIMES)
/* Maximum shared message values. Number of indexes is 8 to allow room to add
* new types of messages.
diff --git a/test/stab.c b/test/stab.c
index 5275454..b8044ae 100644
--- a/test/stab.c
+++ b/test/stab.c
@@ -427,9 +427,9 @@ lifecycle(hid_t fapl)
/* Check that the object header is only one chunk and the space has been allocated correctly */
if(H5Gget_objinfo(gid, ".", FALSE, &obj_stat) < 0) TEST_ERROR
#ifdef H5_HAVE_LARGE_HSIZET
- if(obj_stat.ohdr.size != 190) TEST_ERROR
+ if(obj_stat.ohdr.size != 187) TEST_ERROR
#else /* H5_HAVE_LARGE_HSIZET */
- if(obj_stat.ohdr.size != 170) TEST_ERROR
+ if(obj_stat.ohdr.size != 167) TEST_ERROR
#endif /* H5_HAVE_LARGE_HSIZET */
if(obj_stat.ohdr.free != 0) TEST_ERROR
if(obj_stat.ohdr.nmesgs != 6) TEST_ERROR
@@ -453,9 +453,9 @@ lifecycle(hid_t fapl)
/* Check that the object header is still one chunk and the space has been allocated correctly */
if(H5Gget_objinfo(gid, ".", FALSE, &obj_stat) < 0) TEST_ERROR
#ifdef H5_HAVE_LARGE_HSIZET
- if(obj_stat.ohdr.size != 190) TEST_ERROR
+ if(obj_stat.ohdr.size != 187) TEST_ERROR
#else /* H5_HAVE_LARGE_HSIZET */
- if(obj_stat.ohdr.size != 170) TEST_ERROR
+ if(obj_stat.ohdr.size != 167) TEST_ERROR
#endif /* H5_HAVE_LARGE_HSIZET */
if(obj_stat.ohdr.free != 112) TEST_ERROR
if(obj_stat.ohdr.nmesgs != 3) TEST_ERROR
diff --git a/tools/testfiles/h5mkgrp_nested_latest.ls b/tools/testfiles/h5mkgrp_nested_latest.ls
index 4ac4374..efe8551 100644
--- a/tools/testfiles/h5mkgrp_nested_latest.ls
+++ b/tools/testfiles/h5mkgrp_nested_latest.ls
@@ -3,10 +3,10 @@ Expected output for 'h5ls ../testfiles/h5mkgrp_nested_latest.h5'
#############################
Opened "../testfiles/h5mkgrp_nested_latest.h5" with sec2 driver.
/one Group
- Location: 1:428
+ Location: 1:422
Links: 1
Modified: XXXX-XX-XX XX:XX:XX XXX
/one/two Group
- Location: 1:238
+ Location: 1:235
Links: 1
Modified: XXXX-XX-XX XX:XX:XX XXX
diff --git a/tools/testfiles/h5mkgrp_nested_mult_latest.ls b/tools/testfiles/h5mkgrp_nested_mult_latest.ls
index 54ca444..2771497 100644
--- a/tools/testfiles/h5mkgrp_nested_mult_latest.ls
+++ b/tools/testfiles/h5mkgrp_nested_mult_latest.ls
@@ -3,18 +3,18 @@ Expected output for 'h5ls ../testfiles/h5mkgrp_nested_mult_latest.h5'
#############################
Opened "../testfiles/h5mkgrp_nested_mult_latest.h5" with sec2 driver.
/one Group
- Location: 1:428
+ Location: 1:422
Links: 1
Modified: XXXX-XX-XX XX:XX:XX XXX
/one/two Group
- Location: 1:238
+ Location: 1:235
Links: 1
Modified: XXXX-XX-XX XX:XX:XX XXX
/three Group
- Location: 1:808
+ Location: 1:796
Links: 1
Modified: XXXX-XX-XX XX:XX:XX XXX
/three/four Group
- Location: 1:618
+ Location: 1:609
Links: 1
Modified: XXXX-XX-XX XX:XX:XX XXX
diff --git a/tools/testfiles/h5mkgrp_several_latest.ls b/tools/testfiles/h5mkgrp_several_latest.ls
index 9e238ba..fbe9aa5 100644
--- a/tools/testfiles/h5mkgrp_several_latest.ls
+++ b/tools/testfiles/h5mkgrp_several_latest.ls
@@ -3,10 +3,10 @@ Expected output for 'h5ls ../testfiles/h5mkgrp_several_latest.h5'
#############################
Opened "../testfiles/h5mkgrp_several_latest.h5" with sec2 driver.
/one Group
- Location: 1:238
+ Location: 1:235
Links: 1
Modified: XXXX-XX-XX XX:XX:XX XXX
/two Group
- Location: 1:428
+ Location: 1:422
Links: 1
Modified: XXXX-XX-XX XX:XX:XX XXX
diff --git a/tools/testfiles/h5mkgrp_single_latest.ls b/tools/testfiles/h5mkgrp_single_latest.ls
index 085d182..4838dfc 100644
--- a/tools/testfiles/h5mkgrp_single_latest.ls
+++ b/tools/testfiles/h5mkgrp_single_latest.ls
@@ -3,6 +3,6 @@ Expected output for 'h5ls ../testfiles/h5mkgrp_single_latest.h5'
#############################
Opened "../testfiles/h5mkgrp_single_latest.h5" with sec2 driver.
/latest Group
- Location: 1:238
+ Location: 1:235
Links: 1
Modified: XXXX-XX-XX XX:XX:XX XXX