summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-07-22 17:02:26 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-07-22 17:02:26 (GMT)
commit3e48f9be0067b9df317d000aa83e6ad8ed6f583a (patch)
tree2f3fc77453c39d8c9daf28152547570e5a6aa69a
parent06763537dabab2043d7df4cf05ed21f7d01977c0 (diff)
downloadhdf5-3e48f9be0067b9df317d000aa83e6ad8ed6f583a.zip
hdf5-3e48f9be0067b9df317d000aa83e6ad8ed6f583a.tar.gz
hdf5-3e48f9be0067b9df317d000aa83e6ad8ed6f583a.tar.bz2
[svn-r19122] Description:
Bring metadata journaling branch closer to trunk by bringing back updates to internal error reporting macros, routines that deal with writing object header messages to the superblock extension, and some object header query routines. Also cleanups to journaling code & tests to use this code and to clean up in general. Tested on: Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode (h5committest not required on this branch)
-rw-r--r--src/H5AC.c5
-rw-r--r--src/H5Cjournal.c274
-rw-r--r--src/H5Cpkg.h31
-rw-r--r--src/H5Cprivate.h9
-rw-r--r--src/H5Eint.c101
-rw-r--r--src/H5Eprivate.h41
-rw-r--r--src/H5Fpkg.h7
-rw-r--r--src/H5Fsuper.c437
-rw-r--r--src/H5O.c179
-rw-r--r--src/H5Opublic.h35
-rw-r--r--test/cache_journal.c53
11 files changed, 687 insertions, 485 deletions
diff --git a/src/H5AC.c b/src/H5AC.c
index de3defb..a173d8d 100644
--- a/src/H5AC.c
+++ b/src/H5AC.c
@@ -1564,6 +1564,7 @@ herr_t
H5AC_insert_entry(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr,
void *thing, unsigned int flags)
{
+ herr_t result;
#ifdef H5_HAVE_PARALLEL
H5AC_aux_t * aux_ptr = NULL;
#endif /* H5_HAVE_PARALLEL */
@@ -2154,6 +2155,7 @@ H5AC_unprotect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr,
{
herr_t result;
hbool_t dirtied;
+ hbool_t deleted;
#ifdef H5_HAVE_PARALLEL
H5AC_aux_t * aux_ptr = NULL;
#endif /* H5_HAVE_PARALLEL */
@@ -2194,6 +2196,7 @@ H5AC_unprotect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr,
dirtied = (hbool_t)( ( (flags & H5AC__DIRTIED_FLAG) == H5AC__DIRTIED_FLAG ) ||
( ((H5AC_info_t *)thing)->dirtied ) );
+ deleted = (hbool_t)( (flags & H5C__DELETED_FLAG) == H5C__DELETED_FLAG );
#ifdef H5_HAVE_PARALLEL
if ( ( dirtied ) && ( ((H5AC_info_t *)thing)->is_dirty == FALSE ) &&
@@ -2202,7 +2205,7 @@ H5AC_unprotect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr,
HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "can't log dirtied entry")
}
- if ( ( (flags & H5C__DELETED_FLAG) != 0 ) &&
+ if ( ( deleted ) &&
( NULL != (aux_ptr = f->shared->cache->aux_ptr) ) &&
( aux_ptr->mpi_rank == 0 ) ) {
diff --git a/src/H5Cjournal.c b/src/H5Cjournal.c
index e021b49..05e2de0 100644
--- a/src/H5Cjournal.c
+++ b/src/H5Cjournal.c
@@ -76,6 +76,14 @@ static herr_t H5C_call_mdjsc_callbacks(H5C_t * cache_ptr,
static herr_t H5C_get_journaling_in_progress(const H5F_t * f,
H5C_t * cache_ptr);
+static herr_t H5C_mark_journaling_in_progress(H5F_t * f,
+ hid_t dxpl_id,
+ const int32_t journal_magic,
+ const char * journal_file_name_ptr);
+
+static herr_t H5C_unmark_journaling_in_progress(H5F_t * f,
+ hid_t dxpl_id);
+
static herr_t H5C_grow_mdjsc_callback_table(H5C_t * cache_ptr);
static herr_t H5C_jb_aio__await_buffer_write_completion(
@@ -490,13 +498,8 @@ H5C_end_journaling(H5F_t * f,
* extension. In passing, also discard the cache's copies of the
* metadata journaling magic, and the journal file name.
*/
- result = H5C_unmark_journaling_in_progress(f, dxpl_id, cache_ptr);
-
- if ( result < 0 ) {
-
- HGOTO_ERROR(H5E_CACHE, H5E_CANTJOURNAL, FAIL, \
- "H5C_unmark_journaling_in_progress() failed.")
- }
+ if(H5C_unmark_journaling_in_progress(f, dxpl_id) < 0 )
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTMODIFY, FAIL, "can't mark file as not being journaled")
result = H5C_jb__takedown(&(cache_ptr->mdj_jbrb));
@@ -1217,6 +1220,7 @@ done:
/************* superblock journaling message management code **************/
/**************************************************************************/
+
/*-------------------------------------------------------------------------
* Function: H5C_check_for_journaling()
*
@@ -1242,7 +1246,6 @@ done:
*
*-------------------------------------------------------------------------
*/
-
herr_t
H5C_check_for_journaling(H5F_t * f,
hid_t dxpl_id,
@@ -1257,71 +1260,38 @@ H5C_check_for_journaling(H5F_t * f,
"journal recovery tool on this file. The journal was written \n";
const char * l3 = "to \"";
const char * l4 = "\".\n";
- herr_t result;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5C_check_for_journaling, FAIL)
- HDassert( f );
- HDassert( cache_ptr );
- HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC );
- HDassert( cache_ptr->jnl_magic == 0 );
- HDassert( cache_ptr->jnl_file_name_len == 0 );
-
- if ( H5C__check_for_journaling ) {
-
- result = H5C_get_journaling_in_progress(f, cache_ptr);
-
- if ( result != SUCCEED ) {
-
- HGOTO_ERROR(H5E_CACHE, H5E_CANTJOURNAL, FAIL, \
- "H5C_get_journaling_in_progress() failed.")
- }
-
- if ( cache_ptr->jnl_file_name_len > 0 ) { /* journaling was in */
- /* progress */
-
- if ( journal_recovered ) {
-
- /* Just forget that we were journaling. Do this by
- * deleting the superblock extension message that says
- * we were.
- */
-
- result = H5C_unmark_journaling_in_progress(f,
- dxpl_id,
- cache_ptr);
-
- if ( result != SUCCEED ) {
-
- HGOTO_ERROR(H5E_CACHE, H5E_CANTJOURNAL, FAIL, \
- "H5C_unmark_journaling_in_progress() failed.")
- }
- } else {
-
- /* we have to play some games here to set up an error message
- * that contains the journal file path. In essence, what
- * follows is a somewhat modified version of the HGOTO_ERROR()
- * macro.
- */
- (void)H5Epush2(H5E_DEFAULT, __FILE__, FUNC, __LINE__,
- H5E_ERR_CLS_g, H5E_CACHE, H5E_CANTJOURNAL,
- "%s%s%s%s%s%s", l0, l1, l2, l3,
- cache_ptr->jnl_file_name, l4);
- (void)H5E_dump_api_stack((int)H5_IS_API(FUNC));
- HGOTO_DONE(FAIL)
-
- }
- }
- }
+ HDassert(f);
+ HDassert(cache_ptr);
+ HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC);
+ HDassert(cache_ptr->jnl_magic == 0);
+ HDassert(cache_ptr->jnl_file_name_len == 0);
+
+ if(H5C__check_for_journaling ) {
+ if(H5C_get_journaling_in_progress(f, cache_ptr) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "H5C_get_journaling_in_progress() failed.")
+
+ /* Check if journaling was in progress */
+ if(cache_ptr->jnl_file_name_len > 0) {
+ if(journal_recovered) {
+ /* Forget that we were journaling */
+ if(H5C_unmark_journaling_in_progress(f, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTMODIFY, FAIL, "can't mark file as not being journaled")
+ } /* end if */
+ else
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTJOURNAL, FAIL, \
+ "%s%s%s%s%s%s", l0, l1, l2, l3, cache_ptr->jnl_file_name, l4)
+ } /* end if */
+ } /* end if */
done:
-
FUNC_LEAVE_NOAPI(ret_value)
-
} /* H5C_check_for_journaling() */
-
+
/*-------------------------------------------------------------------------
* Function: H5C_get_journaling_in_progress()
*
@@ -1360,7 +1330,6 @@ done:
*
*-------------------------------------------------------------------------
*/
-
herr_t
H5C_get_journaling_in_progress(const H5F_t * f,
H5C_t * cache_ptr)
@@ -1412,7 +1381,7 @@ done:
} /* H5C_get_journaling_in_progress() */
-
+
/*-------------------------------------------------------------------------
* Function: H5C_mark_journaling_in_progress()
*
@@ -1443,88 +1412,86 @@ done:
*
*-------------------------------------------------------------------------
*/
-
-herr_t
+static herr_t
H5C_mark_journaling_in_progress(H5F_t * f,
hid_t dxpl_id,
const int32_t journal_magic,
const char * journal_file_name_ptr)
{
+ H5O_mdj_msg_t mdj_msg; /* Metadata journaling message to insert in superblock extension */
H5C_t * cache_ptr;
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5C_mark_journaling_in_progress, FAIL)
-
- HDassert( f != NULL );
- HDassert( f->shared != NULL );
- HDassert( ! f->shared->mdc_jnl_enabled );
+ FUNC_ENTER_NOAPI_NOINIT(H5C_mark_journaling_in_progress)
+ HDassert(f != NULL);
+ HDassert(f->shared != NULL);
+ HDassert(! f->shared->mdc_jnl_enabled);
cache_ptr = f->shared->cache;
-
- HDassert( cache_ptr );
- HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC );
- HDassert( cache_ptr->jnl_file_name_len == 0 );
- HDassert( journal_file_name_ptr != NULL );
+ HDassert(cache_ptr);
+ HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC);
+ HDassert(cache_ptr->jnl_file_name_len == 0);
+ HDassert(journal_file_name_ptr != NULL);
/* Can't journal a read only file, so verify that we are
* opened read/write and fail if we are not.
*/
- if ( (f->shared->flags & H5F_ACC_RDWR) == 0 ) {
-
- HGOTO_ERROR(H5E_CACHE, H5E_CANTJOURNAL, FAIL, \
- "File is opened read only.")
- }
+ if((f->shared->flags & H5F_ACC_RDWR) == 0 )
+ HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "file is opened read only.")
cache_ptr->jnl_magic = journal_magic;
- cache_ptr->jnl_file_name_len = (int32_t)HDstrlen(journal_file_name_ptr);
-
- if ( cache_ptr->jnl_file_name_len <= 0 ) {
-
- HGOTO_ERROR(H5E_CACHE, H5E_CANTJOURNAL, FAIL, \
- "length of journal file name is zero.")
- }
-
- if ( cache_ptr->jnl_file_name_len > H5C__MAX_JOURNAL_FILE_NAME_LEN ) {
-
- HGOTO_ERROR(H5E_CACHE, H5E_CANTJOURNAL, FAIL, \
- "journal file name too long.")
- }
-
- HDstrncpy(cache_ptr->jnl_file_name,
- journal_file_name_ptr,
- (size_t)(cache_ptr->jnl_file_name_len + 1));
-
- /* now, load the journaling information into shared, and then call
- * H5F_super_write_mdj_msg() to write the metadata journaling
- * superblock extension message to file.
+ cache_ptr->jnl_file_name_len = HDstrlen(journal_file_name_ptr);
+ if(0 == cache_ptr->jnl_file_name_len)
+ HGOTO_ERROR(H5E_CACHE, H5E_BADRANGE, FAIL, "length of journal file name is zero.")
+ if(cache_ptr->jnl_file_name_len > H5C__MAX_JOURNAL_FILE_NAME_LEN)
+ HGOTO_ERROR(H5E_CACHE, H5E_BADRANGE, FAIL, "journal file name too long.")
+ HDstrncpy(cache_ptr->jnl_file_name, journal_file_name_ptr,
+ (cache_ptr->jnl_file_name_len + 1));
+
+ /* now, load the journaling information into shared, and then
+ * write the metadata journaling superblock extension message to file.
*/
f->shared->mdc_jnl_enabled = TRUE;
f->shared->mdc_jnl_magic = journal_magic;
f->shared->mdc_jnl_file_name_len = (size_t)(cache_ptr->jnl_file_name_len);
- HDstrncpy(f->shared->mdc_jnl_file_name,
- journal_file_name_ptr,
- (size_t)(cache_ptr->jnl_file_name_len + 1));
+ HDstrncpy(f->shared->mdc_jnl_file_name, journal_file_name_ptr,
+ (cache_ptr->jnl_file_name_len + 1));
- if ( H5F_super_write_mdj_msg(f, dxpl_id) < 0 ) {
+ /* create a metadata journaling message and insert it in
+ * the superblock extension.
+ */
+ mdj_msg.mdc_jnl_enabled = f->shared->mdc_jnl_enabled;
+ mdj_msg.mdc_jnl_magic = f->shared->mdc_jnl_magic;
+ mdj_msg.mdc_jnl_file_name_len = f->shared->mdc_jnl_file_name_len;
- HGOTO_ERROR(H5E_CACHE, H5E_CANTJOURNAL, FAIL, \
- "H5F_super_write_mdj_msg() failed.")
- }
+ /* Sanity check journal file name */
+ if(f->shared->mdc_jnl_file_name_len == 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_BADRANGE, FAIL, "journaling enabled, but journal file path empty?!?")
+ if(f->shared->mdc_jnl_file_name_len > H5C__MAX_JOURNAL_FILE_NAME_LEN)
+ HGOTO_ERROR(H5E_CACHE, H5E_BADRANGE, FAIL, "journal file path too long?!?")
- /* Finally, flush the file to ensure that changes made it to disk. */
+ /* Copy journal file name into message to store */
+ HDstrncpy(mdj_msg.mdc_jnl_file_name, f->shared->mdc_jnl_file_name,
+ f->shared->mdc_jnl_file_name_len + 1);
- if ( H5F_flush(f, dxpl_id, H5F_SCOPE_GLOBAL, H5F_FLUSH_NONE) < 0 ) {
+ /* Sanity check copied name */
+ if(((mdj_msg.mdc_jnl_file_name)[mdj_msg.mdc_jnl_file_name_len] != '\0')
+ || (HDstrlen(mdj_msg.mdc_jnl_file_name) != mdj_msg.mdc_jnl_file_name_len))
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "bad journal file path and/or path len???")
- HGOTO_ERROR(H5E_CACHE, H5E_CANTJOURNAL, FAIL, "H5F_flush() failed.")
- }
+ /* Write metadata journaling message to superblock extension */
+ if(H5F_super_ext_write_msg(f, dxpl_id, &mdj_msg, H5O_MDJ_MSG_ID, TRUE) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_WRITEERROR, FAIL, "can't write metadata journaling message to superblock extension")
-done:
+ /* Finally, flush the file to ensure that changes made it to disk. */
+ if(H5F_flush(f, dxpl_id, H5F_SCOPE_GLOBAL, H5F_FLUSH_NONE) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't flush file")
+done:
FUNC_LEAVE_NOAPI(ret_value)
-
} /* H5C_mark_journaling_in_progress() */
-
+
/*-------------------------------------------------------------------------
* Function: H5C_unmark_journaling_in_progress()
*
@@ -1556,37 +1523,28 @@ done:
*
*-------------------------------------------------------------------------
*/
-
-herr_t
+static herr_t
H5C_unmark_journaling_in_progress(H5F_t * f,
- hid_t dxpl_id,
-#ifndef NDEBUG
- H5C_t * cache_ptr)
-#else /* NDEBUG */
- H5C_t UNUSED * cache_ptr)
-#endif /* NDEBUG */
+ hid_t dxpl_id)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ H5C_t * cache_ptr; /* Pointer to metadata cache */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5C_unmark_journaling_in_progress, FAIL)
-
- HDassert( f != NULL );
- HDassert( f->shared != NULL );
- HDassert( f->shared->mdc_jnl_enabled );
- HDassert( f->shared->cache == cache_ptr );
- HDassert( cache_ptr );
- HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC );
- HDassert( cache_ptr->jnl_file_name_len > 0 );
+ FUNC_ENTER_NOAPI_NOINIT(H5C_unmark_journaling_in_progress)
+ HDassert(f != NULL);
+ HDassert(f->shared != NULL);
+ HDassert(f->shared->mdc_jnl_enabled);
+ cache_ptr = f->shared->cache;
+ HDassert(cache_ptr);
+ HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC);
+ HDassert(cache_ptr->jnl_file_name_len > 0);
/* Can't journal a read only file, so verify that we are
* opened read/write and fail if we are not.
*/
- if ( (f->shared->flags & H5F_ACC_RDWR) == 0 ) {
-
- HGOTO_ERROR(H5E_CACHE, H5E_CANTJOURNAL, FAIL, \
- "File is opened read only.")
- }
+ if((f->shared->flags & H5F_ACC_RDWR) == 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "file is opened read only.")
/* Discard the journal file name and magic in *cache_ptr */
cache_ptr->jnl_magic = 0;
@@ -1594,31 +1552,23 @@ H5C_unmark_journaling_in_progress(H5F_t * f,
(cache_ptr->jnl_file_name)[0] = '\0';
/* now, mark f->shared to indicate that journaling is not in
- * progress, and then call H5F_super_write_mdj_msg() to write
- * the changes to disk.
+ * progress.
*/
f->shared->mdc_jnl_enabled = FALSE;
f->shared->mdc_jnl_magic = 0;
f->shared->mdc_jnl_file_name_len = 0;
(f->shared->mdc_jnl_file_name)[0] = '\0';
- if ( H5F_super_write_mdj_msg(f, dxpl_id) < 0 ) {
-
- HGOTO_ERROR(H5E_CACHE, H5E_CANTJOURNAL, FAIL, \
- "H5F_super_write_mdj_msg() failed.")
- }
+ /* Delete the metadata journaling message from the superblock extension */
+ if(H5F_super_ext_remove_msg(f, dxpl_id, H5O_MDJ_MSG_ID) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove metadata journaling message from superblock extension")
/* Finally, flush the file to ensure that changes made it to disk. */
-
- if ( H5F_flush(f, dxpl_id, H5F_SCOPE_GLOBAL, H5F_FLUSH_NONE) < 0 ) {
-
- HGOTO_ERROR(H5E_CACHE, H5E_CANTJOURNAL, FAIL, "H5F_flush() failed.")
- }
+ if(H5F_flush(f, dxpl_id, H5F_SCOPE_GLOBAL, H5F_FLUSH_NONE) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't flush file")
done:
-
FUNC_LEAVE_NOAPI(ret_value)
-
} /* H5C_unmark_journaling_in_progress() */
@@ -1851,21 +1801,13 @@ H5C_deregister_mdjsc_callback(H5C_t * cache_ptr,
( cache_ptr->mdjsc_cb_tbl_len > H5C__MIN_MDJSC_CB_TBL_LEN ) &&
( cache_ptr->mdjsc_cb_tbl_max_idx_in_use <
(cache_ptr->mdjsc_cb_tbl_len / 2) ) ) {
- herr_t result;
-
- result = H5C_shrink_mdjsc_callback_table(cache_ptr);
-
- if ( result != SUCCEED ) {
- HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \
- "H5C_shrink_mdjsc_callback_table() failed.");
- }
- }
+ if(H5C_shrink_mdjsc_callback_table(cache_ptr) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTSHRINK, FAIL, "can't reduce metadata journaling callback table")
+ } /* end if */
done:
-
FUNC_LEAVE_NOAPI(ret_value)
-
} /* H5C_deregister_mdjsc_callback() */
diff --git a/src/H5Cpkg.h b/src/H5Cpkg.h
index b8e6072..8dc024e 100644
--- a/src/H5Cpkg.h
+++ b/src/H5Cpkg.h
@@ -1021,6 +1021,18 @@ typedef struct H5C_mdjsc_record_t
* remaining fields in this section are undefined if
* mdj_enabled is FALSE.
*
+ * jnl_magic: Randomly selected int32_t used to reduce the possibility
+ * of running the wrong journal on an HDF5 file. The basic
+ * idea is to pick a random number, store it in both the HDF5
+ * file and the journal file, and then refuse to run the
+ * journal unless the numbers match.
+ *
+ * jnl_file_name_len: Length of the journal file name, or zero if the
+ * journal file name is undefined.
+ *
+ * jnl_file_name: Array of char of length H5C__MAX_JOURNAL_FILE_NAME_LEN
+ * + 1 used to store the journal file path.
+ *
* trans_in_progress Boolean flag used to indicate whether a metadata
* transaction is in progress.
*
@@ -1051,18 +1063,6 @@ typedef struct H5C_mdjsc_record_t
* been modified have been written to disk in the journal
* file.
*
- * jnl_magic: Randomly selected int32_t used to reduce the possibility
- * of running the wrong journal on an HDF5 file. The basic
- * idea is to pick a random number, store it in both the HDF5
- * file and the journal file, and then refuse to run the
- * journal unless the numbers match.
- *
- * jnl_file_name_len: Length of the journal file name, or zero if the
- * journal file name is undefined.
- *
- * jnl_file_name: Array of char of length H5C__MAX_JOURNAL_FILE_NAME_LEN
- * + 1 used to store the journal file path.
- *
* mdj_jbrb: Instance of H5C_jbrb_t used to manage logging of journal
* entries to the journal file.
*
@@ -1455,14 +1455,13 @@ struct H5C_t
int64_t cache_accesses;
hbool_t mdj_enabled;
+ int32_t jnl_magic;
+ size_t jnl_file_name_len;
+ char jnl_file_name[H5C__MAX_JOURNAL_FILE_NAME_LEN + 1];
hbool_t trans_in_progress;
char trans_api_name[H5C__MAX_API_NAME_LEN];
uint64_t trans_num;
uint64_t last_trans_on_disk;
- int32_t jnl_magic;
- int32_t jnl_file_name_len;
- char jnl_file_name[H5C__MAX_JOURNAL_FILE_NAME_LEN
- + 1];
struct H5C_jbrb_t mdj_jbrb;
int32_t tl_len;
size_t tl_size;
diff --git a/src/H5Cprivate.h b/src/H5Cprivate.h
index be7e076..9b744da 100644
--- a/src/H5Cprivate.h
+++ b/src/H5Cprivate.h
@@ -1616,15 +1616,6 @@ H5_DLL herr_t H5C_check_for_journaling(H5F_t * f,
H5C_t * cache_ptr,
hbool_t journal_recovered);
-H5_DLL herr_t H5C_mark_journaling_in_progress(H5F_t * f,
- hid_t dxpl_id,
- const int32_t journal_magic,
- const char * journal_file_name_ptr);
-
-H5_DLL herr_t H5C_unmark_journaling_in_progress(H5F_t * f,
- hid_t dxpl_id,
- H5C_t * cache_ptr);
-
/**************************************************************************/
/****** metadata journaling status change callback management code ********/
diff --git a/src/H5Eint.c b/src/H5Eint.c
index e0fa482..92c36a4 100644
--- a/src/H5Eint.c
+++ b/src/H5Eint.c
@@ -660,6 +660,107 @@ H5E_set_auto(H5E_t *estack, const H5E_auto_op_t *op, void *client_data)
/*-------------------------------------------------------------------------
+ * Function: H5E_printf_stack
+ *
+ * Purpose: Printf-like wrapper around H5E_push_stack.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, August 12, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned line,
+ hid_t cls_id, hid_t maj_id, hid_t min_id, const char *fmt, ...)
+{
+ va_list ap; /* Varargs info */
+#ifndef H5_HAVE_VASPRINTF
+ int tmp_len; /* Current size of description buffer */
+ int desc_len; /* Actual length of description when formatted */
+#endif /* H5_HAVE_VASPRINTF */
+ char *tmp = NULL; /* Buffer to place formatted description in */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ /*
+ * WARNING: We cannot call HERROR() from within this function or else we
+ * could enter infinite recursion. Furthermore, we also cannot
+ * call any other HDF5 macro or function which might call
+ * HERROR(). HERROR() is called by HRETURN_ERROR() which could
+ * be called by FUNC_ENTER().
+ */
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5E_printf_stack)
+
+ /* Sanity check */
+ HDassert(cls_id > 0);
+ HDassert(maj_id > 0);
+ HDassert(min_id > 0);
+ HDassert(fmt);
+
+/* Note that the variable-argument parsing for the format is identical in
+ * the H5Epush2() routine - correct errors and make changes in both
+ * places. -QAK
+ */
+
+ /* Start the variable-argument parsing */
+ va_start(ap, fmt);
+
+#ifdef H5_HAVE_VASPRINTF
+ /* Use the vasprintf() routine, since it does what we're trying to do below */
+ if(HDvasprintf(&tmp, fmt, ap) < 0)
+ HGOTO_DONE(FAIL)
+#else /* H5_HAVE_VASPRINTF */
+ /* Allocate space for the formatted description buffer */
+ tmp_len = 128;
+ if(NULL == (tmp = H5MM_malloc((size_t)tmp_len)))
+ HGOTO_DONE(FAIL)
+
+ /* If the description doesn't fit into the initial buffer size, allocate more space and try again */
+ while((desc_len = HDvsnprintf(tmp, (size_t)tmp_len, fmt, ap))
+#ifdef H5_VSNPRINTF_WORKS
+ >
+#else /* H5_VSNPRINTF_WORKS */
+ >=
+#endif /* H5_VSNPRINTF_WORKS */
+ (tmp_len - 1)
+#ifndef H5_VSNPRINTF_WORKS
+ || (desc_len < 0)
+#endif /* H5_VSNPRINTF_WORKS */
+ ) {
+ /* shutdown & restart the va_list */
+ va_end(ap);
+ va_start(ap, fmt);
+
+ /* Release the previous description, it's too small */
+ H5MM_xfree(tmp);
+
+ /* Allocate a description of the appropriate length */
+#ifdef H5_VSNPRINTF_WORKS
+ tmp_len = desc_len + 1;
+#else /* H5_VSNPRINTF_WORKS */
+ tmp_len = 2 * tmp_len;
+#endif /* H5_VSNPRINTF_WORKS */
+ if(NULL == (tmp = H5MM_malloc((size_t)tmp_len)))
+ HGOTO_DONE(FAIL)
+ } /* end while */
+#endif /* H5_HAVE_VASPRINTF */
+
+ va_end(ap);
+
+ /* Push the error on the stack */
+ if(H5E_push_stack(estack, file, func, line, cls_id, maj_id, min_id, tmp) < 0)
+ HGOTO_DONE(FAIL)
+
+done:
+ if(tmp)
+ H5MM_xfree(tmp);
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5E_printf_stack() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5E_push_stack
*
* Purpose: Pushes a new error record onto error stack for the current
diff --git a/src/H5Eprivate.h b/src/H5Eprivate.h
index 05ce10e..0f4cb35 100644
--- a/src/H5Eprivate.h
+++ b/src/H5Eprivate.h
@@ -32,14 +32,14 @@ typedef struct H5E_t H5E_t;
* and a FUNC_LEAVE() within a function body. The arguments are the major
* error number, the minor error number, and a description of the error.
*/
-#define HERROR(maj_id, min_id, str) H5E_push_stack(NULL, __FILE__, FUNC, __LINE__, H5E_ERR_CLS_g, maj_id, min_id, str)
+#define HERROR(maj_id, min_id, ...) H5E_printf_stack(NULL, __FILE__, FUNC, __LINE__, H5E_ERR_CLS_g, maj_id, min_id, __VA_ARGS__)
/*
* HCOMMON_ERROR macro, used by HDONE_ERROR and HGOTO_ERROR
* (Shouldn't need to be used outside this header file)
*/
-#define HCOMMON_ERROR(maj, min, str) \
- HERROR(maj, min, str); \
+#define HCOMMON_ERROR(maj, min, ...) \
+ HERROR(maj, min, __VA_ARGS__); \
(void)H5E_dump_api_stack((int)H5_IS_API(FUNC));
/*
@@ -51,8 +51,8 @@ typedef struct H5E_t H5E_t;
* (This macro can also be used to push an error and set the return value
* without jumping to any labels)
*/
-#define HDONE_ERROR(maj, min, ret_val, str) { \
- HCOMMON_ERROR(maj, min, str); \
+#define HDONE_ERROR(maj, min, ret_val, ...) { \
+ HCOMMON_ERROR(maj, min, __VA_ARGS__); \
ret_value = ret_val; \
}
@@ -63,8 +63,8 @@ typedef struct H5E_t H5E_t;
* error string. The return value is assigned to a variable `ret_value' and
* control branches to the `done' label.
*/
-#define HGOTO_ERROR(maj, min, ret_val, str) { \
- HCOMMON_ERROR(maj, min, str); \
+#define HGOTO_ERROR(maj, min, ret_val, ...) { \
+ HCOMMON_ERROR(maj, min, __VA_ARGS__); \
HGOTO_DONE(ret_val) \
}
@@ -76,13 +76,6 @@ typedef struct H5E_t H5E_t;
*/
#define HGOTO_DONE(ret_val) {ret_value = ret_val; goto done;}
-/* Library-private functions defined in H5E package */
-H5_DLL herr_t H5E_init(void);
-H5_DLL herr_t H5E_push_stack(H5E_t *estack, const char *file, const char *func, unsigned line,
- hid_t cls_id, hid_t maj_id, hid_t min_id, const char *desc);
-H5_DLL herr_t H5E_clear_stack(H5E_t *estack);
-H5_DLL herr_t H5E_dump_api_stack(int is_api);
-
/*
* Macros handling system error messages as described in C standard.
* These macros assume errnum is a valid system error code.
@@ -91,16 +84,13 @@ H5_DLL herr_t H5E_dump_api_stack(int is_api);
/* Retrieve the error code description string and push it onto the error
* stack.
*/
-#define HSYS_ERROR(errnum) { \
- HERROR(H5E_INTERNAL, H5E_SYSERRSTR, HDstrerror(errnum)); \
-}
#define HSYS_DONE_ERROR(majorcode, minorcode, retcode, str) { \
- HSYS_ERROR(errno); \
- HDONE_ERROR(majorcode, minorcode, retcode, str); \
+ int myerrno = errno; \
+ HDONE_ERROR(majorcode, minorcode, retcode, "%s, errno = %d, error message = '%s'", str, myerrno, HDstrerror(myerrno)); \
}
#define HSYS_GOTO_ERROR(majorcode, minorcode, retcode, str) { \
- HSYS_ERROR(errno); \
- HGOTO_ERROR(majorcode, minorcode, retcode, str); \
+ int myerrno = errno; \
+ HGOTO_ERROR(majorcode, minorcode, retcode, "%s, errno = %d, error message = '%s'", str, myerrno, HDstrerror(myerrno)); \
}
#ifdef H5_HAVE_PARALLEL
@@ -125,5 +115,14 @@ extern int H5E_mpi_error_str_len;
}
#endif /* H5_HAVE_PARALLEL */
+/* Library-private functions defined in H5E package */
+H5_DLL herr_t H5E_init(void);
+H5_DLL herr_t H5E_push_stack(H5E_t *estack, const char *file, const char *func,
+ unsigned line, hid_t cls_id, hid_t maj_id, hid_t min_id, const char *desc);
+H5_DLL herr_t H5E_printf_stack(H5E_t *estack, const char *file, const char *func,
+ unsigned line, hid_t cls_id, hid_t maj_id, hid_t min_id, const char *fmt, ...);
+H5_DLL herr_t H5E_clear_stack(H5E_t *estack);
+H5_DLL herr_t H5E_dump_api_stack(int is_api);
+
#endif /* _H5Eprivate_H */
diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h
index 2f6ff27..219d6e3 100644
--- a/src/H5Fpkg.h
+++ b/src/H5Fpkg.h
@@ -100,7 +100,6 @@ typedef struct H5F_file_t {
size_t sizeof_size; /* Size of offsets in file */
haddr_t super_addr; /* Absolute address of super block */
haddr_t base_addr; /* Absolute base address for rel.addrs. */
- hbool_t extension_ok; /* TRUE iff version permits SB extensions */
haddr_t extension_addr; /* Relative address of superblock extension */
haddr_t sohm_addr; /* Relative address of shared object header message table */
unsigned sohm_vers; /* Version of shared message table on disk */
@@ -191,10 +190,12 @@ H5_DLL herr_t H5F_mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nop
/* Superblock related routines */
H5_DLL herr_t H5F_super_init(H5F_t *f, hid_t dxpl_id);
H5_DLL herr_t H5F_super_write(H5F_t *f, hid_t dxpl_id);
-H5_DLL herr_t H5F_super_write_mdj_msg(H5F_t *f, hid_t dxpl_id);
H5_DLL herr_t H5F_super_read(H5F_t *f, hid_t dxpl_id, H5G_loc_t *root_loc);
-H5_DLL herr_t H5F_super_ext_size(H5F_t *f, hid_t dxpl_id, hsize_t *super_ext_info);
+/* Superblock extension related routines */
+H5_DLL herr_t H5F_super_ext_size(H5F_t *f, hid_t dxpl_id, hsize_t *super_ext_info);
+H5_DLL herr_t H5F_super_ext_write_msg(H5F_t *f, hid_t dxpl_id, void *mesg, unsigned id, hbool_t may_create);
+H5_DLL herr_t H5F_super_ext_remove_msg(H5F_t *f, hid_t dxpl_id, unsigned id);
/* Shared file list related routines */
H5_DLL herr_t H5F_sfile_add(H5F_file_t *shared);
diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c
index ca14ec1..a5fc75a 100644
--- a/src/H5Fsuper.c
+++ b/src/H5Fsuper.c
@@ -108,8 +108,9 @@
/********************/
/* Local Prototypes */
/********************/
-
-static herr_t H5F_super_create_extension(H5F_t *f, hid_t dxpl_id, H5O_loc_t *ext_loc_ptr);
+static herr_t H5F_super_ext_create(H5F_t *f, hid_t dxpl_id, H5O_loc_t *ext_ptr);
+static herr_t H5F_super_ext_open(H5F_t *f, haddr_t ext_addr, H5O_loc_t *ext_ptr);
+static herr_t H5F_super_ext_close(H5F_t *f, H5O_loc_t *ext_ptr);
/*********************/
@@ -215,47 +216,41 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5F_super_create_extension()
- *
- * Purpose: Create a superblock extension for the superblock.
- *
- * This method will be called either on superblock
- * initialization, or if journaling is enabled, and there
- * is no superblock extension to put the journaling
- * configuration data into.
+ * Function: H5F_super_ext_create
*
- * The code in this function was hacked from existing
- * code in H5F_super_init().
+ * Purpose: Create the superblock extension
*
- * The method should fail if a superblock extension
- * exists on entry.
- *
- * Return: Success: SUCCEED
- * Failure: FAIL
+ * Return: Success: non-negative on success
+ * Failure: Negative
*
- * Programmer: John Mainzer
- * 2/29/08
+ * Programmer: Vailin Choi; Feb 2009
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5F_super_create_extension(H5F_t *f, hid_t dxpl_id, H5O_loc_t *ext_loc_ptr)
+H5F_super_ext_create(H5F_t *f, hid_t dxpl_id, H5O_loc_t *ext_ptr)
{
- H5O_loc_t ext_loc; /* Superblock extension object location */
- H5O_loc_t *elp;
- herr_t ret_value = SUCCEED;
+ H5P_genplist_t *plist; /* File creation property list */
+ unsigned super_vers; /* Superblock version */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5F_super_create_extension, FAIL)
+ FUNC_ENTER_NOAPI_NOINIT(H5F_super_ext_create)
- HDassert(f != NULL);
- HDassert(f->shared != NULL);
+ /* Sanity check */
+ HDassert(f);
+ HDassert(f->shared);
+ HDassert(ext_ptr);
- if(ext_loc_ptr != NULL)
- elp = ext_loc_ptr;
- else
- elp = &ext_loc;
+ /* Get the shared file creation property list */
+ if(NULL == (plist = H5I_object(f->shared->fcpl_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
+
+ /* Grab values from property list */
+ if(H5P_get(plist, H5F_CRT_SUPER_VERS_NAME, &super_vers) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get superblock version")
- if(!f->shared->extension_ok)
+ /* Check for older version of superblock format */
+ if(super_vers < HDF5_SUPERBLOCK_VERSION_2)
HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "superblock extension not permitted?!?!")
else if(f->shared->extension_addr != HADDR_UNDEF)
HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "superblock extension already exists?!?!")
@@ -268,17 +263,89 @@ H5F_super_create_extension(H5F_t *f, hid_t dxpl_id, H5O_loc_t *ext_loc_ptr)
* be tuned if more information is added to the superblock
* extension.
*/
- H5O_loc_reset(elp);
- if(H5O_create(f, dxpl_id, 0, H5P_GROUP_CREATE_DEFAULT, elp) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "unable to create superblock extension")
+ H5O_loc_reset(ext_ptr);
+ if(H5O_create(f, dxpl_id, 0, H5P_GROUP_CREATE_DEFAULT, ext_ptr) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "unable to create superblock extension")
/* Record the address of the superblock extension */
- f->shared->extension_addr = elp->addr;
+ f->shared->extension_addr = ext_ptr->addr;
} /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5F_super_create_extension() */
+} /* H5F_super_ext_create() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5F_super_ext_open
+ *
+ * Purpose: Open an existing superblock extension
+ *
+ * Return: Success: non-negative on success
+ * Failure: Negative
+ *
+ * Programmer: Vailin Choi; Feb 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5F_super_ext_open(H5F_t *f, haddr_t ext_addr, H5O_loc_t *ext_ptr)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5F_super_ext_open)
+
+ /* Sanity check */
+ HDassert(f);
+ HDassert(H5F_addr_defined(ext_addr));
+ HDassert(ext_ptr);
+
+ /* Set up "fake" object location for superblock extension */
+ H5O_loc_reset(ext_ptr);
+ ext_ptr->file = f;
+ ext_ptr->addr = ext_addr;
+
+ /* Open the superblock extension object header */
+ if(H5O_open(ext_ptr) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open superblock extension")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5F_super_ext_open() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5F_super_ext_close
+ *
+ * Purpose: Close superblock extension
+ *
+ * Return: Success: non-negative on success
+ * Failure: Negative
+ *
+ * Programmer: Vailin Choi; Feb 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5F_super_ext_close(H5F_t *f, H5O_loc_t *ext_ptr)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5F_super_ext_close)
+
+ /* Sanity check */
+ HDassert(f);
+ HDassert(ext_ptr);
+
+ /* Twiddle the number of open objects to avoid closing the file. */
+ f->nopen_objs++;
+ if(H5O_close(ext_ptr) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to close superblock extension")
+ f->nopen_objs--;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5F_super_ext_close() */
/*-------------------------------------------------------------------------
@@ -543,8 +610,6 @@ H5F_super_read(H5F_t *f, hid_t dxpl_id, H5G_loc_t *root_loc)
uint32_t computed_chksum; /* Computed checksum */
uint32_t read_chksum; /* Checksum read from file */
- shared->extension_ok = TRUE;
-
/* Size of file addresses */
sizeof_addr = *p++;
if(sizeof_addr != 2 && sizeof_addr != 4 &&
@@ -641,14 +706,9 @@ H5F_super_read(H5F_t *f, hid_t dxpl_id, H5G_loc_t *root_loc)
*/
HDassert(super_vers >= HDF5_SUPERBLOCK_VERSION_2);
- /* Set up "fake" object location for superblock extension */
- H5O_loc_reset(&ext_loc);
- ext_loc.file = f;
- ext_loc.addr = shared->extension_addr;
-
/* Open the superblock extension */
- if(H5O_open(&ext_loc) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to open superblock extension")
+ if(H5F_super_ext_open(f, shared->extension_addr, &ext_loc) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENOBJ, FAIL, "unable to open file's superblock extension")
/* Read in the shared OH message information if there is any */
if(H5SM_get_info(&ext_loc, c_plist, dxpl_id) < 0)
@@ -736,13 +796,9 @@ H5F_super_read(H5F_t *f, hid_t dxpl_id, H5G_loc_t *root_loc)
H5O_msg_reset(H5O_MDJ_MSG_ID, &mdj_msg);
} /* end else */
- /* Close the extension. Twiddle the number of open objects to avoid
- * closing the file (since this will be the only open object).
- */
- f->nopen_objs++;
- if(H5O_close(&ext_loc) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to close superblock extension")
- f->nopen_objs--;
+ /* Close superblock extension */
+ if(H5F_super_ext_close(f, &ext_loc) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to close file's superblock extension")
} /* end if */
done:
@@ -839,7 +895,6 @@ H5F_super_init(H5F_t *f, hid_t dxpl_id)
/* Files with SOHM indices always need the superblock extension */
if(f->shared->sohm_nindexes > 0) {
HDassert(super_vers >= HDF5_SUPERBLOCK_VERSION_2);
- f->shared->extension_ok = TRUE;
need_ext = TRUE;
} /* end if */
/* If we're going to use a version of the superblock format which allows
@@ -847,11 +902,6 @@ H5F_super_init(H5F_t *f, hid_t dxpl_id)
* in it.
*/
else if(super_vers >= HDF5_SUPERBLOCK_VERSION_2) {
- /* make note of the fact that we can construct a superblock
- * extension later if we wish.
- */
- f->shared->extension_ok = TRUE;
-
/* Check for non-default v1 B-tree 'K' values to store */
if(f->shared->btree_k[H5B_SNODE_ID] != HDF5_BTREE_SNODE_IK_DEF ||
f->shared->btree_k[H5B_ISTORE_ID] != HDF5_BTREE_ISTORE_IK_DEF ||
@@ -878,7 +928,7 @@ H5F_super_init(H5F_t *f, hid_t dxpl_id)
* be tuned if more information is added to the superblock
* extension.
*/
- if(H5F_super_create_extension(f, dxpl_id, &ext_loc) < 0)
+ if(H5F_super_ext_create(f, dxpl_id, &ext_loc) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "unable to create superblock extension")
/* Create the Shared Object Header Message table and register it with
@@ -950,13 +1000,9 @@ H5F_super_init(H5F_t *f, hid_t dxpl_id)
f->shared->mdc_jnl_file_name_len = 0;
(f->shared->mdc_jnl_file_name)[0] = '\0';
- /* Twiddle the number of open objects to avoid closing the file
- * (since this will be the only open object currently).
- */
- f->nopen_objs++;
- if(H5O_close(&ext_loc) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to close superblock extension")
- f->nopen_objs--;
+ /* Close superblock extension */
+ if(H5F_super_ext_close(f, &ext_loc) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to close file's superblock extension")
} /* end if */
done:
@@ -1115,133 +1161,6 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5F_super_write_mdj_msg
- *
- * If journaling is enabled, create a superblock extension
- * if necessary and then write the current contents of
- * the mdc_jnl_enabled, mdc_jnl_magic, mdc_jnl_file_name_lenand
- * mdc_jnl_file_name fields of the shared structure to the
- * mdj_msg in the superblock extention, overwriting the old
- * message if it exists.
- *
- * If journaling is not enabled, remove the old mdj message
- * from the superblock extension (if it exists).
- *
- * Recall that the absence of a mdj message indicates that
- * metadata journaling is not enabled.
- *
- * Return: Success: non-negative on success
- * Failure: Negative
- *
- * Programmer: John Mainzer
- * 3/3/08
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5F_super_write_mdj_msg(H5F_t *f, hid_t dxpl_id)
-{
- H5O_loc_t ext_loc; /* Superblock extension object location */
- htri_t msg_exists; /* Whether the metadata journaling message exists already in the superblock extension */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(H5F_super_write_mdj_msg, FAIL)
-
- /* Sanity check */
- HDassert(f != NULL);
- HDassert(f->shared != NULL);
- HDassert(f->shared->extension_ok);
-
- /* Open the superblock extension, or create it if it doesn't exist */
- if(!H5F_addr_defined(f->shared->extension_addr)) {
- if(H5F_super_create_extension(f, dxpl_id, &ext_loc) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_SYSERRSTR, FAIL, "unable to create superblock extension?!?!")
- } /* end if */
- else {
- /* Set up "fake" object location for superblock extension */
- H5O_loc_reset(&ext_loc);
- ext_loc.file = f;
- ext_loc.addr = f->shared->extension_addr;
-
- /* Open the superblock extension */
- if(H5O_open(&ext_loc) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_SYSERRSTR, FAIL, "unable to open superblock extension?!?!")
- } /* end else */
-
- /* The metadata journaling message is a variable length message.
- * This raises the question of how to deal with any pre-existing
- * message.
- *
- * While in theory we could try to re-size it, after looking through
- * the code and talking to Quincey, it appears that the standard
- * practice in such cases seems to be to delete the old message,
- * and then replace it with a new message.
- *
- * Add to this the fact that the metadata journaling message
- * should not exist unless journaling is enabled (or to put it
- * another way, the message should never appear in a valid HDF5
- * file).
- *
- * Thus, here we check to see if a metadata jouraling message exists,
- * and delete it if it does. If metadata data journaling is enabled,
- * we will replace it with a new message shortly.
- */
- if((msg_exists = H5O_msg_exists(&ext_loc, H5O_MDJ_MSG_ID, dxpl_id)) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to determine if metadata journaling message exists?!?!")
- if(msg_exists == TRUE) {
- /* metadata journaling message exists -- delete it from the
- * super block extension now. We will replace it later if
- * metadata journaling is enabled.
- */
- if(H5O_msg_remove(&ext_loc, H5O_MDJ_MSG_ID, H5O_ALL, FALSE, dxpl_id) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTREMOVE, FAIL, "unable to remove metadata journaling message")
- } /* end if */
-
- if(f->shared->mdc_jnl_enabled) {
- H5O_mdj_msg_t mdj_msg; /* Metadata journaling message to insert in superblock extension */
-
- /* create a metadata journaling message and insert it in
- * the superblock extension.
- */
- mdj_msg.mdc_jnl_enabled = f->shared->mdc_jnl_enabled;
- mdj_msg.mdc_jnl_magic = f->shared->mdc_jnl_magic;
- mdj_msg.mdc_jnl_file_name_len = f->shared->mdc_jnl_file_name_len;
-
- /* Sanity check journal file name */
- if(f->shared->mdc_jnl_file_name_len == 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "journaling enabled, but journal file path empty?!?")
- if(f->shared->mdc_jnl_file_name_len > H5C__MAX_JOURNAL_FILE_NAME_LEN)
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "journal file path too long?!?")
-
- /* Copy journal file name into message to store */
- HDstrncpy(mdj_msg.mdc_jnl_file_name,
- f->shared->mdc_jnl_file_name,
- f->shared->mdc_jnl_file_name_len + 1);
-
- /* Sanity check copied name */
- if(((mdj_msg.mdc_jnl_file_name)[mdj_msg.mdc_jnl_file_name_len] != '\0')
- || (HDstrlen(mdj_msg.mdc_jnl_file_name) != mdj_msg.mdc_jnl_file_name_len))
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "bad journal file path and/or path len???")
-
- /* Store the metadata journaling message in the superblock extension */
- if(H5O_msg_create(&ext_loc, H5O_MDJ_MSG_ID, H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, &mdj_msg, dxpl_id) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_SYSERRSTR, FAIL, "unable to add mdj_msg to superblock extension?!?!")
- } /* end if */
-
- /* Close the extension. Twiddle the number of open objects to avoid
- * closing the file (since this may be the only open object).
- */
- f->nopen_objs++;
- if(H5O_close(&ext_loc) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to close superblock extension")
- f->nopen_objs--;
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5F_super_write_mdj_msg() */
-
-
-/*-------------------------------------------------------------------------
* Function: H5F_super_ext_size
* Get storage size of the superblock extension
*
@@ -1282,3 +1201,135 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5F_super_ext_size() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5F_super_ext_write_msg()
+ *
+ * Purpose: Write the message with ID to the superblock extension
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Vailin Choi; Feb 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5F_super_ext_write_msg(H5F_t *f, hid_t dxpl_id, void *mesg, unsigned id, hbool_t may_create)
+{
+ H5O_loc_t ext_loc; /* "Object location" for superblock extension */
+ htri_t status; /* Indicate whether the message exists or not */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5F_super_ext_write_msg, FAIL)
+
+ /* Sanity checks */
+ HDassert(f);
+ HDassert(f->shared);
+ HDassert(f->shared->extension_addr);
+
+ /* Open/create the superblock extension object header */
+ if(H5F_addr_defined(f->shared->extension_addr)) {
+ if(H5F_super_ext_open(f, f->shared->extension_addr, &ext_loc) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENOBJ, FAIL, "unable to open file's superblock extension")
+ } /* end if */
+ else {
+ HDassert(may_create);
+ if(H5F_super_ext_create(f, dxpl_id, &ext_loc) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "unable to create file's superblock extension")
+ } /* end else */
+ HDassert(H5F_addr_defined(ext_loc.addr));
+
+ /* Check if message with ID does not exist in the object header */
+ if((status = H5O_msg_exists(&ext_loc, id, dxpl_id)) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to check object header for message or message exists")
+
+ /* Check for creating vs. writing */
+ if(may_create) {
+ if(status)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "Message should not exist")
+
+ /* Create the message with ID in the superblock extension */
+ if(H5O_msg_create(&ext_loc, id, H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, mesg, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to create the message in object header")
+ } /* end if */
+ else {
+ if(!status)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "Message should exist")
+
+ /* Update the message with ID in the superblock extension */
+ if(H5O_msg_write(&ext_loc, id, H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, mesg, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to write the message in object header")
+ } /* end else */
+
+ /* Close the superblock extension object header */
+ if(H5F_super_ext_close(f, &ext_loc) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to close file's superblock extension")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5F_super_ext_write_msg() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5F_super_ext_remove_msg
+ *
+ * Purpose: Remove the message with ID from the superblock extension
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Vailin Choi; Feb 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5F_super_ext_remove_msg(H5F_t *f, hid_t dxpl_id, unsigned id)
+{
+ htri_t status; /* Indicate whether the message exists or not */
+ H5O_loc_t ext_loc; /* "Object location" for superblock extension */
+ int null_count = 0; /* # of null messages */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5F_super_ext_remove_msg, FAIL)
+
+ /* Make sure that the superblock extension object header exists */
+ HDassert(H5F_addr_defined(f->shared->extension_addr));
+
+ /* Open superblock extension object header */
+ if(H5F_super_ext_open(f, f->shared->extension_addr, &ext_loc) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "error in starting file's superblock extension")
+
+ /* Check if message with ID exists in the object header */
+ if((status = H5O_msg_exists(&ext_loc, id, dxpl_id)) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to check object header for message")
+ else if(status) { /* message exists */
+ H5O_hdr_info_t hdr_info; /* Object header info for superblock extension */
+
+ /* Remove the message */
+ if(H5O_msg_remove(&ext_loc, id, H5O_ALL, TRUE, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete free-space manager info message")
+
+ /* Get info for the superblock extension's object header */
+ if(H5O_get_hdr_info(&ext_loc, dxpl_id, &hdr_info) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve superblock extension info")
+
+ /* If the object header is an empty base chunk, remove superblock extension */
+ if(hdr_info.nchunks == 1) {
+ if((null_count = H5O_msg_count(&ext_loc, H5O_NULL_ID, dxpl_id)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "unable to count messages")
+ else if((unsigned)null_count == hdr_info.nmesgs) {
+ HDassert(H5F_addr_defined(ext_loc.addr));
+ if(H5O_delete(f, dxpl_id, ext_loc.addr) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "unable to count messages")
+ f->shared->extension_addr = HADDR_UNDEF;
+ } /* end if */
+ } /* end if */
+ } /* end if */
+
+ /* Close superblock extension object header */
+ if(H5F_super_ext_close(f, &ext_loc) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to close file's superblock extension")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5F_super_ext_remove_msg() */
+
diff --git a/src/H5O.c b/src/H5O.c
index ddd4382..5a494eb 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -84,6 +84,7 @@ static herr_t H5O_obj_type_real(H5O_t *oh, H5O_type_t *obj_type);
static herr_t H5O_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t lapl_id,
hid_t dxpl_id);
+static herr_t H5O_get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr);
/*********************/
@@ -2513,6 +2514,131 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5O_get_hdr_info
+ *
+ * Purpose: Retrieve the object header information for an object
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * September 22 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_get_hdr_info(const H5O_loc_t *loc, hid_t dxpl_id, H5O_hdr_info_t *hdr)
+{
+ H5O_t *oh = NULL; /* Object header */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5O_get_hdr_info, FAIL)
+
+ /* Check args */
+ HDassert(loc);
+ HDassert(hdr);
+
+ /* Reset the object header info structure */
+ HDmemset(hdr, 0, sizeof(*hdr));
+
+ /* Get the object header */
+ if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC_READ)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header")
+
+ /* Get the information for the object header */
+ if(H5O_get_hdr_info_real(oh, hdr) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object header info")
+
+done:
+ if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_get_hdr_info() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_get_hdr_info_real
+ *
+ * Purpose: Internal routine to retrieve the object header information for an object
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * September 22 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O_get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr)
+{
+ const H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */
+ const H5O_chunk_t *curr_chunk; /* Pointer to current message being operated on */
+ unsigned u; /* Local index variable */
+
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_get_hdr_info_real)
+
+ /* Check args */
+ HDassert(oh);
+ HDassert(hdr);
+
+ /* Set the version for the object header */
+ hdr->version = oh->version;
+
+ /* Set the number of messages & chunks */
+ hdr->nmesgs = oh->nmesgs;
+ hdr->nchunks = oh->nchunks;
+
+ /* Set the status flags */
+ hdr->flags = oh->flags;
+
+ /* Iterate over all the messages, accumulating message size & type information */
+ hdr->space.meta = H5O_SIZEOF_HDR(oh) + (H5O_SIZEOF_CHKHDR_OH(oh) * (oh->nchunks - 1));
+ hdr->space.mesg = 0;
+ hdr->space.free = 0;
+ hdr->mesg.present = 0;
+ hdr->mesg.shared = 0;
+ for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) {
+ uint64_t type_flag; /* Flag for message type */
+
+ /* Accumulate space usage information, based on the type of message */
+ if(H5O_NULL_ID == curr_msg->type->id)
+ hdr->space.free += H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg->raw_size;
+ else if(H5O_CONT_ID == curr_msg->type->id)
+ hdr->space.meta += H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg->raw_size;
+ else {
+ hdr->space.meta += H5O_SIZEOF_MSGHDR_OH(oh);
+ hdr->space.mesg += curr_msg->raw_size;
+ } /* end else */
+
+ /* Set flag to indicate presence of message type */
+ type_flag = ((uint64_t)1) << curr_msg->type->id;
+ hdr->mesg.present |= type_flag;
+
+ /* Set flag if the message is shared in some way */
+ if(curr_msg->flags & H5O_MSG_FLAG_SHARED) \
+ hdr->mesg.shared |= type_flag;
+ } /* end for */
+
+ /* Iterate over all the chunks, adding any gaps to the free space */
+ hdr->space.total = 0;
+ for(u = 0, curr_chunk = &oh->chunk[0]; u < oh->nchunks; u++, curr_chunk++) {
+ /* Accumulate the size of the header on disk */
+ hdr->space.total += curr_chunk->size;
+
+ /* If the chunk has a gap, add it to the free space */
+ hdr->space.free += curr_chunk->gap;
+ } /* end for */
+
+ /* Sanity check that all the bytes are accounted for */
+ HDassert(hdr->space.total == (hdr->space.free + hdr->space.meta + hdr->space.mesg));
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5O_get_hdr_info_real() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5O_get_info
*
* Purpose: Retrieve the information for an object
@@ -2598,43 +2724,9 @@ H5O_get_info(const H5O_loc_t *loc, hid_t dxpl_id, hbool_t want_ih_info, H5O_info
} /* end if */
} /* end else */
- /* Set the version for the object header */
- oinfo->hdr.version = oh->version;
-
- /* Set the number of messages & chunks */
- oinfo->hdr.nmesgs = oh->nmesgs;
- oinfo->hdr.nchunks = oh->nchunks;
-
- /* Set the status flags */
- oinfo->hdr.flags = oh->flags;
-
- /* Iterate over all the messages, accumulating message size & type information */
- oinfo->hdr.space.meta = H5O_SIZEOF_HDR(oh) + (H5O_SIZEOF_CHKHDR_OH(oh) * (oh->nchunks - 1));
- oinfo->hdr.space.mesg = 0;
- oinfo->hdr.space.free = 0;
- oinfo->hdr.mesg.present = 0;
- oinfo->hdr.mesg.shared = 0;
- for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) {
- uint64_t type_flag; /* Flag for message type */
-
- /* Accumulate space usage information, based on the type of message */
- if(H5O_NULL_ID == curr_msg->type->id)
- oinfo->hdr.space.free += H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg->raw_size;
- else if(H5O_CONT_ID == curr_msg->type->id)
- oinfo->hdr.space.meta += H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg->raw_size;
- else {
- oinfo->hdr.space.meta += H5O_SIZEOF_MSGHDR_OH(oh);
- oinfo->hdr.space.mesg += curr_msg->raw_size;
- } /* end else */
-
- /* Set flag to indicate presence of message type */
- type_flag = ((uint64_t)1) << curr_msg->type->id;
- oinfo->hdr.mesg.present |= type_flag;
-
- /* Set flag if the message is shared in some way */
- if(curr_msg->flags & H5O_MSG_FLAG_SHARED) \
- oinfo->hdr.mesg.shared |= type_flag;
- } /* end for */
+ /* Get the information for the object header */
+ if(H5O_get_hdr_info_real(oh, &oinfo->hdr) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object header info")
/* Retrieve # of attributes */
oinfo->num_attrs = H5O_attr_count_real(loc->file, dxpl_id, oh);
@@ -2645,19 +2737,6 @@ H5O_get_info(const H5O_loc_t *loc, hid_t dxpl_id, hbool_t want_ih_info, H5O_info
HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't retrieve attribute btree & heap info")
} /* end if */
- /* Iterate over all the chunks, adding any gaps to the free space */
- oinfo->hdr.space.total = 0;
- for(u = 0, curr_chunk = &oh->chunk[0]; u < oh->nchunks; u++, curr_chunk++) {
- /* Accumulate the size of the header on disk */
- oinfo->hdr.space.total += curr_chunk->size;
-
- /* If the chunk has a gap, add it to the free space */
- oinfo->hdr.space.free += curr_chunk->gap;
- } /* end for */
-
- /* Sanity check that all the bytes are accounted for */
- HDassert(oinfo->hdr.space.total == (oinfo->hdr.space.free + oinfo->hdr.space.meta + oinfo->hdr.space.mesg));
-
done:
if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
diff --git a/src/H5Opublic.h b/src/H5Opublic.h
index ddf1a93..84fdecc 100644
--- a/src/H5Opublic.h
+++ b/src/H5Opublic.h
@@ -87,6 +87,24 @@ typedef enum H5O_type_t {
H5O_TYPE_NTYPES /* Number of different object types (must be last!) */
} H5O_type_t;
+/* Information struct for object header metadata (for H5Oget_info/H5Oget_info_by_name/H5Oget_info_by_idx) */
+typedef struct H5O_hdr_info_t {
+ unsigned version; /* Version number of header format in file */
+ unsigned nmesgs; /* Number of object header messages */
+ unsigned nchunks; /* Number of object header chunks */
+ unsigned flags; /* Object header status flags */
+ struct {
+ hsize_t total; /* Total space for storing object header in file */
+ hsize_t meta; /* Space within header for object header metadata information */
+ hsize_t mesg; /* Space within header for actual message information */
+ hsize_t free; /* Free space within object header */
+ } space;
+ struct {
+ uint64_t present; /* Flags to indicate presence of message type in header */
+ uint64_t shared; /* Flags to indicate message type is shared in header */
+ } mesg;
+} H5O_hdr_info_t;
+
/* Information struct for object (for H5Oget_info/H5Oget_info_by_name/H5Oget_info_by_idx) */
typedef struct H5O_info_t {
unsigned long fileno; /* File number that object is located in */
@@ -98,22 +116,7 @@ typedef struct H5O_info_t {
time_t ctime; /* Change time */
time_t btime; /* Birth time */
hsize_t num_attrs; /* # of attributes attached to object */
- struct {
- unsigned version; /* Version number of header format in file */
- unsigned nmesgs; /* Number of object header messages */
- unsigned nchunks; /* Number of object header chunks */
- unsigned flags; /* Object header status flags */
- struct {
- hsize_t total; /* Total space for storing object header in file */
- hsize_t meta; /* Space within header for object header metadata information */
- hsize_t mesg; /* Space within header for actual message information */
- hsize_t free; /* Free space within object header */
- } space;
- struct {
- uint64_t present; /* Flags to indicate presence of message type in header */
- uint64_t shared; /* Flags to indicate message type is shared in header */
- } mesg;
- } hdr;
+ H5O_hdr_info_t hdr; /* Object header information */
/* Extra metadata storage for obj & attributes */
struct {
H5_ih_info_t obj; /* v1/v2 B-tree & local/fractal heap for groups, B-tree for chunked datasets */
diff --git a/test/cache_journal.c b/test/cache_journal.c
index d4ddf2d..491181d 100644
--- a/test/cache_journal.c
+++ b/test/cache_journal.c
@@ -6628,6 +6628,7 @@ check_superblock_extensions(void)
*/
if ( pass ) {
+ H5O_mdj_msg_t mdj_msg; /* Metadata journaling message to insert in superblock extension */
file_ptr->shared->mdc_jnl_enabled = TRUE;
file_ptr->shared->mdc_jnl_magic = 123;
@@ -6648,10 +6649,20 @@ check_superblock_extensions(void)
file_ptr->shared->mdc_jnl_file_name);
}
- if ( H5F_super_write_mdj_msg(file_ptr, -1) < 0 ) {
+ /* create a metadata journaling message and insert it in
+ * the superblock extension.
+ */
+ mdj_msg.mdc_jnl_enabled = file_ptr->shared->mdc_jnl_enabled;
+ mdj_msg.mdc_jnl_magic = file_ptr->shared->mdc_jnl_magic;
+ mdj_msg.mdc_jnl_file_name_len = file_ptr->shared->mdc_jnl_file_name_len;
+ HDstrncpy(mdj_msg.mdc_jnl_file_name, file_ptr->shared->mdc_jnl_file_name,
+ file_ptr->shared->mdc_jnl_file_name_len + 1);
+
+ /* Write metadata journaling message to superblock extension */
+ if(H5F_super_ext_write_msg(file_ptr, -1, &mdj_msg, H5O_MDJ_MSG_ID, TRUE) < 0) {
pass = FALSE;
- failure_mssg = "H5F_super_write_mdj_msg failed (1).";
+ failure_mssg = "H5F_super_ext_write_msg failed (1).";
}
}
@@ -6743,10 +6754,10 @@ check_superblock_extensions(void)
file_ptr->shared->mdc_jnl_enabled = FALSE;
- if ( H5F_super_write_mdj_msg(file_ptr, -1) < 0 ) {
+ if(H5F_super_ext_remove_msg(file_ptr, -1, H5O_MDJ_MSG_ID) < 0) {
pass = FALSE;
- failure_mssg = "H5F_super_write_mdj_msg failed (2).";
+ failure_mssg = "H5F_super_ext_remove_msg failed (2).";
}
}
@@ -6813,6 +6824,7 @@ check_superblock_extensions(void)
/*******************************************************************/
if ( pass ) {
+ H5O_mdj_msg_t mdj_msg; /* Metadata journaling message to insert in superblock extension */
file_ptr->shared->mdc_jnl_enabled = TRUE;
file_ptr->shared->mdc_jnl_magic = 456;
@@ -6821,16 +6833,27 @@ check_superblock_extensions(void)
"qrst",
file_ptr->shared->mdc_jnl_file_name_len + 1);
- if ( H5F_super_write_mdj_msg(file_ptr, -1) < 0 ) {
+ /* create a metadata journaling message and insert it in
+ * the superblock extension.
+ */
+ mdj_msg.mdc_jnl_enabled = file_ptr->shared->mdc_jnl_enabled;
+ mdj_msg.mdc_jnl_magic = file_ptr->shared->mdc_jnl_magic;
+ mdj_msg.mdc_jnl_file_name_len = file_ptr->shared->mdc_jnl_file_name_len;
+ HDstrncpy(mdj_msg.mdc_jnl_file_name, file_ptr->shared->mdc_jnl_file_name,
+ file_ptr->shared->mdc_jnl_file_name_len + 1);
+
+ /* Write metadata journaling message to superblock extension */
+ if(H5F_super_ext_write_msg(file_ptr, -1, &mdj_msg, H5O_MDJ_MSG_ID, TRUE) < 0) {
pass = FALSE;
- failure_mssg = "H5F_super_write_mdj_msg failed (3).";
+ failure_mssg = "H5F_super_ext_write_msg failed (3).";
}
}
if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
if ( pass ) {
+ H5O_mdj_msg_t mdj_msg; /* Metadata journaling message to insert in superblock extension */
file_ptr->shared->mdc_jnl_enabled = TRUE;
file_ptr->shared->mdc_jnl_magic = 789;
@@ -6839,10 +6862,20 @@ check_superblock_extensions(void)
"z",
file_ptr->shared->mdc_jnl_file_name_len + 1);
- if ( H5F_super_write_mdj_msg(file_ptr, -1) < 0 ) {
+ /* create a metadata journaling message and insert it in
+ * the superblock extension.
+ */
+ mdj_msg.mdc_jnl_enabled = file_ptr->shared->mdc_jnl_enabled;
+ mdj_msg.mdc_jnl_magic = file_ptr->shared->mdc_jnl_magic;
+ mdj_msg.mdc_jnl_file_name_len = file_ptr->shared->mdc_jnl_file_name_len;
+ HDstrncpy(mdj_msg.mdc_jnl_file_name, file_ptr->shared->mdc_jnl_file_name,
+ file_ptr->shared->mdc_jnl_file_name_len + 1);
+
+ /* Write metadata journaling message to superblock extension */
+ if(H5F_super_ext_write_msg(file_ptr, -1, &mdj_msg, H5O_MDJ_MSG_ID, FALSE) < 0) {
pass = FALSE;
- failure_mssg = "H5F_super_write_mdj_msg failed (4).";
+ failure_mssg = "H5F_super_ext_write_msg failed (4).";
}
}
@@ -6935,10 +6968,10 @@ check_superblock_extensions(void)
file_ptr->shared->mdc_jnl_enabled = FALSE;
- if ( H5F_super_write_mdj_msg(file_ptr, -1) < 0 ) {
+ if(H5F_super_ext_remove_msg(file_ptr, -1, H5O_MDJ_MSG_ID) < 0) {
pass = FALSE;
- failure_mssg = "H5F_super_write_mdj_msg failed (5).";
+ failure_mssg = "H5F_super_ext_remove_msg failed (5).";
}
}