summaryrefslogtreecommitdiffstats
path: root/src/H5Fsuper_cache.c
diff options
context:
space:
mode:
authorMike McGreevy <mamcgree@hdfgroup.org>2012-03-02 16:18:38 (GMT)
committerMike McGreevy <mamcgree@hdfgroup.org>2012-03-02 16:18:38 (GMT)
commitfdf48fa1bf003446c449852b4e1c895fa601ad72 (patch)
tree018ec41e859c02fb66ebf996dec0d70f52a2cd98 /src/H5Fsuper_cache.c
parent0a18a098eabbdeb20382b044130b7ef998a3918e (diff)
downloadhdf5-fdf48fa1bf003446c449852b4e1c895fa601ad72.zip
hdf5-fdf48fa1bf003446c449852b4e1c895fa601ad72.tar.gz
hdf5-fdf48fa1bf003446c449852b4e1c895fa601ad72.tar.bz2
[svn-r22016] Purpose:
- Switch avoid_truncate from bool to enum - Enable 'EOA' message with latest format. Description: Switched the 'avoid truncate' property from a bool (on/off) to an enum with the following states (for now): H5F_AVOID_TRUNCATE_OFF : file will always be truncated at file close H5F_AVOID_TRUNCATE_EXTEND: file will only be truncated on file close if that truncation results in a smaller file. H5F_AVOID_TRUNCATE_ALL: file will never be truncated on file close. These may be renamed after RFC discussion ... This also resulted in a change in the API controlling the property, as well as the internal querying function. Also, using the latest format in a fapl when creating a file will now also trigger writing of an 'EOA' message and usage of avoid truncate feature. The default setting in this case is H5F_AVOID_TRUNCATE_EXTEND, as this will still allow files to reduce in size when space can be reclaimed. The above required some changes to expected test cases since the file format when the latest format is used now includes an 'EOA' message. A handful of the h5mkgrp test files had their locations updated, and the cache_tagging test was updated to account for superblock extension in the latest case. The change to an 'enum' required an update to the 'EOA' message, since there is no longer a one-to-one correspondence between the avoid truncate property setting and whether or not to store an EOA. As such, the avoid truncate property setting has been added into the EOA message, and a new EOA message struct created, H5O_eoa_t, to house it along with the EOA value. (message previously consisted of just the EOA value). The above change was propogated as needed, including changes made to the h5extend tool in order to account for the changes needed in acquiring the EOA value from the message stored in the superblock extension. Finally, the test file trunc_detect was renamed 'truncation' since it does more than just test truncation detection. It was also refactored to account for the enumerated setting, and divided into three distinct parts: testing of setting the avoid truncate property, testing truncation occurence, and testing truncation detection. Additionally, in passing: - Removed unused udata argument from H5FDcoordinate. - Updated trace file for H5F_avoid_truncate_t type. Tested: h5committest and manually on jam w/ check-vfd.
Diffstat (limited to 'src/H5Fsuper_cache.c')
-rw-r--r--src/H5Fsuper_cache.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/H5Fsuper_cache.c b/src/H5Fsuper_cache.c
index 3b22262..05bcf33 100644
--- a/src/H5Fsuper_cache.c
+++ b/src/H5Fsuper_cache.c
@@ -525,18 +525,18 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata)
if((status = H5O_msg_exists(&ext_loc, H5O_EOA_ID, dxpl_id)) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "unable to read object header")
if(status) {
- haddr_t eoa;
+ H5O_eoa_t eoa_msg;
unsigned mesg_flags;
- f->shared->avoid_truncate = TRUE;
-
- /* Set 'avoid truncate' feature in the property list */
- if(H5P_set(c_plist, H5F_CRT_AVOID_TRUNCATE_NAME, &f->shared->avoid_truncate) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set avoid truncate feature")
/* Retrieve 'EOA' message */
- if(NULL == H5O_msg_read(&ext_loc, H5O_EOA_ID, &eoa, dxpl_id))
+ if(NULL == H5O_msg_read(&ext_loc, H5O_EOA_ID, &eoa_msg, dxpl_id))
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "'EOA' message not present")
+ /* Set 'Avoid Truncate' mode in shared file & creation properties */
+ f->shared->avoid_truncate = eoa_msg.avoid_truncate;
+ if(H5P_set(c_plist, H5F_CRT_AVOID_TRUNCATE_NAME, &f->shared->avoid_truncate) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set avoid truncate feature")
+
/* Get the 'EOA' messages flags */
if (H5O_msg_flags(&ext_loc, H5O_EOA_ID, &mesg_flags, dxpl_id) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "Cannot retrieve object header message flags")
@@ -555,7 +555,7 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata)
} /* end if */
else {
/* Set 'EOA' value in file driver */
- if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, eoa - sblock->base_addr) < 0)
+ if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, eoa_msg.eoa - sblock->base_addr) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to set end-of-address marker for file")
} /* end else */
@@ -812,8 +812,11 @@ H5F_sblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t UNUSED addr,
/* Encode the address of the superblock extension */
H5F_addr_encode(f, &p, sblock->ext_addr);
- /* Encode the end-of-file address */
- if(H5F_AVOID_TRUNCATE(f)) {
+ /* Encode the end-of-file address if the file will not be truncated
+ at file close */
+ if(((H5F_AVOID_TRUNCATE(f)==H5F_AVOID_TRUNCATE_ALL)) ||
+ ((H5F_AVOID_TRUNCATE(f)==H5F_AVOID_TRUNCATE_EXTEND) &&
+ (H5FD_get_eof(f->shared->lf)<H5FD_get_eoa(f->shared->lf, H5FD_MEM_SUPER)))) {
/* If we're avoiding truncating the file, then we need to
* store the file's size in the superblock. We will only be
* in this routine in this case when all other metadata
@@ -828,7 +831,7 @@ H5F_sblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t UNUSED addr,
if (H5FD_flush(f->shared->lf, dxpl_id, FALSE) <0)
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "low level flush failed")
#ifdef H5_HAVE_PARALLEL
- if(H5FD_coordinate(f->shared->lf, dxpl_id, H5FD_COORD_EOF, NULL) < 0)
+ if(H5FD_coordinate(f->shared->lf, dxpl_id, H5FD_COORD_EOF) < 0)
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "low level coordinate failed")
#endif
if (HADDR_UNDEF == (rel_eof = H5FD_get_eof(f->shared->lf)))
@@ -887,10 +890,12 @@ H5F_sblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t UNUSED addr,
if((status = H5O_msg_exists(&ext_loc, H5O_EOA_ID, dxpl_id)) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to read object header")
if(status) {
- haddr_t eoa = HADDR_UNDEF;
+ H5O_eoa_t eoa_msg;
- if ((eoa = H5FD_get_eoa(f->shared->lf, H5FD_MEM_SUPER)) == HADDR_UNDEF)
+ if ((eoa_msg.eoa = H5FD_get_eoa(f->shared->lf, H5FD_MEM_SUPER)) == HADDR_UNDEF)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "driver get_eoa request failed")
+
+ eoa_msg.avoid_truncate = f->shared->avoid_truncate;
/* If the 'EOA' message is the same as the 'EOF' message, then
older versions of HDF5 can read the file provided they just
@@ -899,12 +904,12 @@ H5F_sblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t UNUSED addr,
older versions will be unable to correctly predict if the file
has been truncated, so we write this message with a 'fail if
unknown' flag'. */
- if (eoa == rel_eof) {
- if(H5O_msg_write(&ext_loc, H5O_EOA_ID, H5O_MSG_FLAG_MARK_IF_UNKNOWN, H5O_UPDATE_TIME, &eoa, dxpl_id) < 0)
+ if (eoa_msg.eoa == rel_eof) {
+ if(H5O_msg_write(&ext_loc, H5O_EOA_ID, H5O_MSG_FLAG_MARK_IF_UNKNOWN, H5O_UPDATE_TIME, &eoa_msg, dxpl_id) < 0)
HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "unable to update driver info header message")
} /* end if */
else {
- if(H5O_msg_write(&ext_loc, H5O_EOA_ID, H5O_MSG_FLAG_FAIL_IF_UNKNOWN, H5O_UPDATE_TIME, &eoa, dxpl_id) < 0)
+ if(H5O_msg_write(&ext_loc, H5O_EOA_ID, H5O_MSG_FLAG_FAIL_IF_UNKNOWN, H5O_UPDATE_TIME, &eoa_msg, dxpl_id) < 0)
HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "unable to update driver info header message")
} /* end else */
} /* end if */