summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2008-11-11 23:30:37 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2008-11-11 23:30:37 (GMT)
commit164a8426ea4d10ba2bca71d0a91dacec72cd79e9 (patch)
tree707ee57516158c4d821bb1f78e365c95069371a3
parent05e559c9ec89fc50e7b6b03b5109c22adeb2bfc9 (diff)
downloadhdf5-164a8426ea4d10ba2bca71d0a91dacec72cd79e9.zip
hdf5-164a8426ea4d10ba2bca71d0a91dacec72cd79e9.tar.gz
hdf5-164a8426ea4d10ba2bca71d0a91dacec72cd79e9.tar.bz2
[svn-r16061] Description:
Store extra information about each block in the metadata for the block, in the hope that a corrupted file will be easier to recover. (Similar to the information stored for fractal heaps) Tested on: Mac OS X/32 10.5.5 (amazon) in debug mode Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode 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 production mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
-rw-r--r--src/H5EA.c8
-rw-r--r--src/H5EAcache.c39
-rw-r--r--src/H5EAdblock.c8
-rw-r--r--src/H5EAhdr.c1
-rw-r--r--src/H5EApkg.h13
-rw-r--r--src/H5EAsblock.c6
6 files changed, 71 insertions, 4 deletions
diff --git a/src/H5EA.c b/src/H5EA.c
index 060ee7a..427eb48 100644
--- a/src/H5EA.c
+++ b/src/H5EA.c
@@ -408,9 +408,11 @@ HDfprintf(stderr, "%s: dblk_idx = %u, iblock->ndblk_addrs = %Zu\n", FUNC, dblk_i
/* Check if the data block has been allocated on disk yet */
if(!H5F_addr_defined(iblock->dblk_addrs[dblk_idx])) {
haddr_t dblk_addr; /* Address of data block created */
+ hsize_t dblk_off; /* Offset of data block in array */
/* Create data block */
- dblk_addr = H5EA__dblock_create(hdr, dxpl_id, hdr->sblk_info[sblk_idx].dblk_nelmts);
+ dblk_off = hdr->sblk_info[sblk_idx].start_idx + (dblk_idx * hdr->sblk_info[sblk_idx].dblk_nelmts);
+ dblk_addr = H5EA__dblock_create(hdr, dxpl_id, dblk_off, hdr->sblk_info[sblk_idx].dblk_nelmts);
if(!H5F_addr_defined(dblk_addr))
H5E_THROW(H5E_CANTCREATE, "unable to create extensible array data block")
@@ -476,9 +478,11 @@ HDfprintf(stderr, "%s: dblk_idx = %u, sblock->ndblks = %Zu\n", FUNC, dblk_idx, s
/* Check if the data block has been allocated on disk yet */
if(!H5F_addr_defined(sblock->dblk_addrs[dblk_idx])) {
haddr_t dblk_addr; /* Address of data block created */
+ hsize_t dblk_off; /* Offset of data block in array */
/* Create data block */
- dblk_addr = H5EA__dblock_create(hdr, dxpl_id, sblock->dblk_nelmts);
+ dblk_off = hdr->sblk_info[sblk_idx].start_idx + (dblk_idx * hdr->sblk_info[sblk_idx].dblk_nelmts);
+ dblk_addr = H5EA__dblock_create(hdr, dxpl_id, dblk_off, sblock->dblk_nelmts);
if(!H5F_addr_defined(dblk_addr))
H5E_THROW(H5E_CANTCREATE, "unable to create extensible array data block")
diff --git a/src/H5EAcache.c b/src/H5EAcache.c
index fe64d05..0f454bc 100644
--- a/src/H5EAcache.c
+++ b/src/H5EAcache.c
@@ -519,6 +519,7 @@ H5EA__cache_iblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr,
const uint8_t *p; /* Pointer into raw data buffer */
uint32_t stored_chksum; /* Stored metadata checksum value */
uint32_t computed_chksum; /* Computed metadata checksum value */
+ haddr_t arr_addr; /* Address of array header in the file */
/* Sanity check */
HDassert(f);
@@ -559,6 +560,11 @@ H5EA__cache_iblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr,
if(*p++ != H5EA_IBLOCK_VERSION)
H5E_THROW(H5E_VERSION, "wrong extensible array index block version")
+ /* Address of header for array that owns this block (just for file integrity checks) */
+ H5F_addr_decode(f, &p, &arr_addr);
+ if(H5F_addr_ne(arr_addr, hdr->addr))
+ H5E_THROW(H5E_BADVALUE, "wrong extensible array header address")
+
/* Extensible array type */
if(*p++ != (uint8_t)hdr->cparam.cls->id)
H5E_THROW(H5E_BADTYPE, "incorrect extensible array class")
@@ -681,6 +687,9 @@ H5EA__cache_iblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr,
/* Version # */
*p++ = H5EA_IBLOCK_VERSION;
+ /* Address of array header for array which owns this block */
+ H5F_addr_encode(f, &p, iblock->hdr->addr);
+
/* Extensible array type */
*p++ = iblock->hdr->cparam.cls->id;
@@ -880,6 +889,7 @@ H5EA__cache_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr,
const uint8_t *p; /* Pointer into raw data buffer */
uint32_t stored_chksum; /* Stored metadata checksum value */
uint32_t computed_chksum; /* Computed metadata checksum value */
+ haddr_t arr_addr; /* Address of array header in the file */
/* Sanity check */
HDassert(f);
@@ -921,6 +931,14 @@ H5EA__cache_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr,
if(*p++ != H5EA_SBLOCK_VERSION)
H5E_THROW(H5E_VERSION, "wrong extensible array super block version")
+ /* Address of header for array that owns this block (just for file integrity checks) */
+ H5F_addr_decode(f, &p, &arr_addr);
+ if(H5F_addr_ne(arr_addr, hdr->addr))
+ H5E_THROW(H5E_BADVALUE, "wrong extensible array header address")
+
+ /* Offset of block within the array's address space */
+ UINT64DECODE_VAR(p, sblock->block_off, hdr->arr_off_size);
+
/* Extensible array type */
if(*p++ != (uint8_t)hdr->cparam.cls->id)
H5E_THROW(H5E_BADTYPE, "incorrect extensible array class")
@@ -1026,6 +1044,12 @@ H5EA__cache_sblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr,
/* Version # */
*p++ = H5EA_SBLOCK_VERSION;
+ /* Address of array header for array which owns this block */
+ H5F_addr_encode(f, &p, sblock->hdr->addr);
+
+ /* Offset of block in array */
+ UINT64ENCODE_VAR(p, sblock->block_off, sblock->hdr->arr_off_size);
+
/* Extensible array type */
*p++ = sblock->hdr->cparam.cls->id;
@@ -1207,6 +1231,7 @@ H5EA__cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr,
const uint8_t *p; /* Pointer into raw data buffer */
uint32_t stored_chksum; /* Stored metadata checksum value */
uint32_t computed_chksum; /* Computed metadata checksum value */
+ haddr_t arr_addr; /* Address of array header in the file */
/* Sanity check */
HDassert(f);
@@ -1248,6 +1273,14 @@ H5EA__cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr,
if(*p++ != H5EA_DBLOCK_VERSION)
H5E_THROW(H5E_VERSION, "wrong extensible array data block version")
+ /* Address of header for array that owns this block (just for file integrity checks) */
+ H5F_addr_decode(f, &p, &arr_addr);
+ if(H5F_addr_ne(arr_addr, hdr->addr))
+ H5E_THROW(H5E_BADVALUE, "wrong extensible array header address")
+
+ /* Offset of block within the array's address space */
+ UINT64DECODE_VAR(p, dblock->block_off, hdr->arr_off_size);
+
/* Extensible array type */
if(*p++ != (uint8_t)hdr->cparam.cls->id)
H5E_THROW(H5E_BADTYPE, "incorrect extensible array class")
@@ -1350,6 +1383,12 @@ H5EA__cache_dblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr,
/* Version # */
*p++ = H5EA_DBLOCK_VERSION;
+ /* Address of array header for array which owns this block */
+ H5F_addr_encode(f, &p, dblock->hdr->addr);
+
+ /* Offset of block in array */
+ UINT64ENCODE_VAR(p, dblock->block_off, dblock->hdr->arr_off_size);
+
/* Extensible array type */
*p++ = dblock->hdr->cparam.cls->id;
diff --git a/src/H5EAdblock.c b/src/H5EAdblock.c
index 2d0d241..12897bf 100644
--- a/src/H5EAdblock.c
+++ b/src/H5EAdblock.c
@@ -152,7 +152,7 @@ END_FUNC(PKG) /* end H5EA__dblock_alloc() */
*/
BEGIN_FUNC(PKG, ERR,
haddr_t, HADDR_UNDEF, HADDR_UNDEF,
-H5EA__dblock_create(H5EA_hdr_t *hdr, hid_t dxpl_id, size_t nelmts))
+H5EA__dblock_create(H5EA_hdr_t *hdr, hid_t dxpl_id, hsize_t dblk_off, size_t nelmts))
/* Local variables */
H5EA_dblock_t *dblock = NULL; /* Extensible array data block */
@@ -175,6 +175,12 @@ HDfprintf(stderr, "%s: Called\n", FUNC);
HDfprintf(stderr, "%s: dblock->size = %Zu\n", FUNC, dblock->size);
#endif /* QAK */
+ /* Set offset of block in array's address space */
+ dblock->block_off = dblk_off;
+#ifdef QAK
+HDfprintf(stderr, "%s: dblock->block_off = %Hu\n", FUNC, dblock->block_off);
+#endif /* QAK */
+
/* Allocate space for the data block on disk */
if(HADDR_UNDEF == (dblock->addr = H5MF_alloc(hdr->f, H5FD_MEM_EARRAY_DBLOCK, dxpl_id, (hsize_t)dblock->size)))
H5E_THROW(H5E_CANTALLOC, "file allocation failed for extensible array data block")
diff --git a/src/H5EAhdr.c b/src/H5EAhdr.c
index 9fb3c73..3e98263 100644
--- a/src/H5EAhdr.c
+++ b/src/H5EAhdr.c
@@ -197,6 +197,7 @@ H5EA__hdr_init(H5EA_hdr_t *hdr))
/* Compute general information */
hdr->nsblks = 1 + (hdr->cparam.max_nelmts_bits - H5V_log2_of2(hdr->cparam.data_blk_min_elmts));
+ hdr->arr_off_size = H5EA_SIZEOF_OFFSET_BITS(hdr->cparam.max_nelmts_bits);
#ifdef QAK
HDfprintf(stderr, "%s: hdr->nsblks = %Zu\n", FUNC, hdr->nsblks);
#endif /* QAK */
diff --git a/src/H5EApkg.h b/src/H5EApkg.h
index 2c0930c..9fded70 100644
--- a/src/H5EApkg.h
+++ b/src/H5EApkg.h
@@ -386,6 +386,7 @@ func_init_failed: \
H5EA_METADATA_PREFIX_SIZE(TRUE) \
\
/* Extensible Array Index Block specific fields */ \
+ + (i)->hdr->sizeof_addr /* File address of array owning the block */ \
+ ((size_t)(i)->hdr->cparam.idx_blk_elmts * (size_t)(i)->hdr->cparam.raw_elmt_size) /* Elements in index block */ \
+ ((i)->ndblk_addrs * (i)->hdr->sizeof_addr) /* Data block addresses in index block */ \
+ ((i)->nsblk_addrs * (i)->hdr->sizeof_addr) /* Super block addresses in index block */ \
@@ -397,6 +398,8 @@ func_init_failed: \
H5EA_METADATA_PREFIX_SIZE(TRUE) \
\
/* Extensible Array Super Block specific fields */ \
+ + (s)->hdr->sizeof_addr /* File address of array owning the block */ \
+ + (s)->hdr->arr_off_size /* Offset of the block in the array */ \
+ ((s)->ndblks * (s)->hdr->sizeof_addr) /* Data block addresses in super block */ \
)
@@ -406,9 +409,14 @@ func_init_failed: \
H5EA_METADATA_PREFIX_SIZE(TRUE) \
\
/* Extensible Array Data Block specific fields */ \
+ + (d)->hdr->sizeof_addr /* File address of array owning the block */ \
+ + (d)->hdr->arr_off_size /* Offset of the block in the array */ \
+ ((d)->nelmts * (size_t)(d)->hdr->cparam.raw_elmt_size) /* Elements in index block */ \
)
+/* Compute the # of bytes required to store an offset into a given buffer size */
+#define H5EA_SIZEOF_OFFSET_BITS(b) (((b) + 7) / 8)
+
/****************************/
/* Package Private Typedefs */
@@ -454,6 +462,7 @@ typedef struct H5EA_hdr_t {
hbool_t pending_delete; /* Array is pending deletion */
size_t sizeof_addr; /* Size of file addresses */
size_t sizeof_size; /* Size of file sizes */
+ unsigned char arr_off_size; /* Size of array offsets (in bytes) */
/* Super block information (not stored) */
size_t nsblks; /* Number of superblocks needed for array */
@@ -488,6 +497,7 @@ typedef struct H5EA_sblock_t {
H5AC_info_t cache_info;
/* Extensible array information (stored) */
+ hsize_t block_off; /* Offset of the block within the array's address space */
haddr_t *dblk_addrs; /* Buffer for addresses of data blocks in super block */
/* Internal array information (not stored) */
@@ -508,6 +518,7 @@ typedef struct H5EA_dblock_t {
H5AC_info_t cache_info;
/* Extensible array information (stored) */
+ hsize_t block_off; /* Offset of the block within the array's address space */
void *elmts; /* Buffer for elements stored in data block */
/* Internal array information (not stored) */
@@ -590,7 +601,7 @@ H5_DLL herr_t H5EA__sblock_dest(H5F_t *f, H5EA_sblock_t *sblock);
/* Data block routines */
H5_DLL H5EA_dblock_t *H5EA__dblock_alloc(H5EA_hdr_t *hdr, size_t nelmts);
H5_DLL haddr_t H5EA__dblock_create(H5EA_hdr_t *hdr, hid_t dxpl_id,
- size_t nelmts);
+ hsize_t dblk_off, size_t nelmts);
H5_DLL unsigned H5EA__dblock_sblk_idx(const H5EA_hdr_t *hdr, hsize_t idx);
H5_DLL H5EA_dblock_t *H5EA__dblock_protect(H5EA_hdr_t *hdr, hid_t dxpl_id,
haddr_t dblk_addr, size_t dblk_nelmts, H5AC_protect_t rw);
diff --git a/src/H5EAsblock.c b/src/H5EAsblock.c
index b774812..8ce46ac 100644
--- a/src/H5EAsblock.c
+++ b/src/H5EAsblock.c
@@ -185,6 +185,12 @@ HDfprintf(stderr, "%s: Called\n", FUNC);
HDfprintf(stderr, "%s: sblock->size = %Zu\n", FUNC, sblock->size);
#endif /* QAK */
+ /* Set offset of block in array's address space */
+ sblock->block_off = hdr->sblk_info[sblk_idx].start_idx;
+#ifdef QAK
+HDfprintf(stderr, "%s: sblock->block_off = %Hu\n", FUNC, sblock->block_off);
+#endif /* QAK */
+
/* Allocate space for the super block on disk */
if(HADDR_UNDEF == (sblock->addr = H5MF_alloc(hdr->f, H5FD_MEM_EARRAY_SBLOCK, dxpl_id, (hsize_t)sblock->size)))
H5E_THROW(H5E_CANTALLOC, "file allocation failed for extensible array super block")