diff options
-rw-r--r-- | src/H5AC2.c | 2 | ||||
-rw-r--r-- | src/H5AC2private.h | 2 | ||||
-rw-r--r-- | src/H5C2journal.c | 32 | ||||
-rw-r--r-- | src/H5C2private.h | 10 | ||||
-rw-r--r-- | src/H5Dint.c | 60 | ||||
-rw-r--r-- | src/H5Dpkg.h | 1 | ||||
-rw-r--r-- | test/cache2_journal.c | 2 |
7 files changed, 88 insertions, 21 deletions
diff --git a/src/H5AC2.c b/src/H5AC2.c index c66096d..7dcb57a 100644 --- a/src/H5AC2.c +++ b/src/H5AC2.c @@ -2478,7 +2478,7 @@ done: */ herr_t -H5AC2_register_mdjsc_callback(H5F_t * file_ptr, +H5AC2_register_mdjsc_callback(const H5F_t * file_ptr, H5C2_mdj_status_change_func_t fcn_ptr, void * data_ptr, int32_t * idx_ptr, diff --git a/src/H5AC2private.h b/src/H5AC2private.h index c9d3beb..97b20e2 100644 --- a/src/H5AC2private.h +++ b/src/H5AC2private.h @@ -360,7 +360,7 @@ H5_DLL herr_t H5AC2_get_cache_hit_rate(H5AC2_t * cache_ptr, H5_DLL herr_t H5AC2_get_jnl_config(H5AC2_t * cache_ptr, H5AC2_jnl_config_t * config_ptr); -H5_DLL herr_t H5AC2_register_mdjsc_callback(H5F_t * file_ptr, +H5_DLL herr_t H5AC2_register_mdjsc_callback(const H5F_t * file_ptr, H5C2_mdj_status_change_func_t fcn_ptr, void * data_ptr, int32_t * idx_ptr, diff --git a/src/H5C2journal.c b/src/H5C2journal.c index 2908428..0f97e82 100644 --- a/src/H5C2journal.c +++ b/src/H5C2journal.c @@ -59,6 +59,19 @@ hbool_t H5C2__check_for_journaling = TRUE; +/**************************************************************************/ +/***************************** local prototypes ***************************/ +/**************************************************************************/ + +static herr_t H5C2_call_mdjsc_callbacks(H5C2_t * cache_ptr, + hid_t dxpl_id, + H5C2_mdj_config_t * config_ptr); + +static herr_t H5C2_grow_mdjsc_callback_table(H5C2_t * cache_ptr); + +static herr_t H5C2_shrink_mdjsc_callback_table(H5C2_t * cache_ptr); + + /**************************************************************************/ /************************* journaling code proper *************************/ @@ -193,7 +206,7 @@ H5C2_begin_journaling(H5F_t * f, "H5C2_get_journal_config() failed.") } - result = H5C2_call_mdjsc_callbacks(cache_ptr, &config); + result = H5C2_call_mdjsc_callbacks(cache_ptr, dxpl_id, &config); if ( result < 0 ) { @@ -384,7 +397,7 @@ H5C2_end_journaling(H5F_t * f, "H5C2_get_journal_config() failed.") } - result = H5C2_call_mdjsc_callbacks(cache_ptr, &config); + result = H5C2_call_mdjsc_callbacks(cache_ptr, dxpl_id, &config); if ( result < 0 ) { @@ -1950,8 +1963,9 @@ done: *------------------------------------------------------------------------- */ -herr_t +static herr_t H5C2_call_mdjsc_callbacks(H5C2_t * cache_ptr, + hid_t dxpl_id, H5C2_mdj_config_t * config_ptr) { herr_t ret_value = SUCCEED; /* Return value */ @@ -1960,7 +1974,7 @@ H5C2_call_mdjsc_callbacks(H5C2_t * cache_ptr, H5C2_mdj_status_change_func_t func_ptr; void * data_ptr; - FUNC_ENTER_NOAPI(H5C2_call_mdjsc_callbacks, FAIL) + FUNC_ENTER_NOAPI_NOINIT(H5C2_call_mdjsc_callbacks) HDassert( cache_ptr != NULL ); HDassert( cache_ptr->magic == H5C2__H5C2_T_MAGIC ); @@ -2009,7 +2023,7 @@ H5C2_call_mdjsc_callbacks(H5C2_t * cache_ptr, func_ptr = ((cache_ptr->mdjsc_cb_tbl)[i]).fcn_ptr; data_ptr = ((cache_ptr->mdjsc_cb_tbl)[i]).data_ptr; - func_ptr(config_ptr, data_ptr); + func_ptr(config_ptr, dxpl_id, data_ptr); funcs_called++; } @@ -2236,7 +2250,7 @@ done: *------------------------------------------------------------------------- */ -herr_t +static herr_t H5C2_grow_mdjsc_callback_table(H5C2_t * cache_ptr) { herr_t ret_value = SUCCEED; /* Return value */ @@ -2246,7 +2260,7 @@ H5C2_grow_mdjsc_callback_table(H5C2_t * cache_ptr) H5C2_mdjsc_record_t * old_mdjsc_cb_tbl = NULL; H5C2_mdjsc_record_t * new_mdjsc_cb_tbl = NULL; - FUNC_ENTER_NOAPI(H5C2_grow_mdjsc_callback_table, FAIL) + FUNC_ENTER_NOAPI_NOINIT(H5C2_grow_mdjsc_callback_table) HDassert( cache_ptr != NULL ); HDassert( cache_ptr->magic == H5C2__H5C2_T_MAGIC ); @@ -2491,7 +2505,7 @@ done: *------------------------------------------------------------------------- */ -herr_t +static herr_t H5C2_shrink_mdjsc_callback_table(H5C2_t * cache_ptr) { herr_t ret_value = SUCCEED; /* Return value */ @@ -2504,7 +2518,7 @@ H5C2_shrink_mdjsc_callback_table(H5C2_t * cache_ptr) H5C2_mdjsc_record_t * old_mdjsc_cb_tbl = NULL; H5C2_mdjsc_record_t * new_mdjsc_cb_tbl = NULL; - FUNC_ENTER_NOAPI(H5C2_shrink_mdjsc_callback_table, FAIL) + FUNC_ENTER_NOAPI_NOINIT(H5C2_shrink_mdjsc_callback_table) HDassert( cache_ptr != NULL ); HDassert( cache_ptr->magic == H5C2__H5C2_T_MAGIC ); diff --git a/src/H5C2private.h b/src/H5C2private.h index ba6d751..e681054 100644 --- a/src/H5C2private.h +++ b/src/H5C2private.h @@ -1340,7 +1340,8 @@ typedef struct H5C2_mdj_config_t * configuration changes. */ -typedef void (*H5C2_mdj_status_change_func_t)(H5C2_mdj_config_t * config_ptr, +typedef void (*H5C2_mdj_status_change_func_t)(const H5C2_mdj_config_t * config_ptr, + hid_t dxpl_id, void * data_ptr); @@ -1675,20 +1676,13 @@ H5_DLL herr_t H5C2_unmark_journaling_in_progress(H5F_t * f, /****** metadata journaling status change callback management code ********/ /**************************************************************************/ -H5_DLL herr_t H5C2_call_mdjsc_callbacks(H5C2_t * cache_ptr, - H5C2_mdj_config_t * config_ptr); - H5_DLL herr_t H5C2_deregister_mdjsc_callback(H5C2_t * cache_ptr, int32_t idx); -H5_DLL herr_t H5C2_grow_mdjsc_callback_table(H5C2_t * cache_ptr); - H5_DLL herr_t H5C2_register_mdjsc_callback(H5C2_t * cache_ptr, H5C2_mdj_status_change_func_t fcn_ptr, void * data_ptr, int32_t * idx_ptr); -H5_DLL herr_t H5C2_shrink_mdjsc_callback_table(H5C2_t * cache_ptr); - #endif /* !_H5C2private_H */ diff --git a/src/H5Dint.c b/src/H5Dint.c index 2d7b16d..d4a0ab0 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -502,6 +502,47 @@ done: /*------------------------------------------------------------------------- + * Function: H5D_journal_status_cb + * + * Purpose: Update journal status for dataset + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Sunday, October 12, 2008 + * + *------------------------------------------------------------------------- + */ +static void +H5D_journal_status_cb(const H5C2_mdj_config_t *mdj_config, hid_t dxpl_id, + void *udata) +{ + H5D_t *dset = (H5D_t *)udata; /* User callback data */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5D_journal_status_cb) + + /* Sanity check */ + HDassert(mdj_config); + HDassert(dset); + + /* Check if journaling is now enabled */ + if(mdj_config->enable_journaling) { + /* Flush any cached dataset information */ + if(H5D_flush_real(dset, dxpl_id, (unsigned)H5F_FLUSH_NONE) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to flush cached dataset info") + } /* end if */ + + /* Keep current journaling state */ + dset->shared->journaling_enabled = mdj_config->enable_journaling; + +done: + FUNC_LEAVE_NOAPI_VOID +} /* end H5D_journal_status_cb() */ + + +/*------------------------------------------------------------------------- * Function: H5D_new * * Purpose: Creates a new, empty dataset structure @@ -536,7 +577,7 @@ H5D_new(const H5F_t *file, hid_t dcpl_id, hbool_t creating, hbool_t vl_type) /* Copy the default dataset information */ HDmemcpy(new_dset, &H5D_def_dset, sizeof(H5D_shared_t)); - /* Remember whether journaling is enabled, to help managed future behavior */ + /* Remember whether journaling is enabled, to help manage future behavior */ new_dset->journaling_enabled = journaling_enabled; /* If we are using the default dataset creation property list, during creation @@ -544,7 +585,7 @@ H5D_new(const H5F_t *file, hid_t dcpl_id, hbool_t creating, hbool_t vl_type) */ if(!vl_type && creating && dcpl_id == H5P_DATASET_CREATE_DEFAULT) { if(H5I_inc_ref(dcpl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINC, NULL, "Can't increment default DCPL ID") + HGOTO_ERROR(H5E_DATASET, H5E_CANTINC, NULL, "can't increment default DCPL ID") new_dset->dcpl_id = dcpl_id; } /* end if */ else { @@ -1055,6 +1096,7 @@ H5D_create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, /* Initialize the dataset object */ if(NULL == (new_dset = H5FL_CALLOC(H5D_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + new_dset->mdjsc_idx = (-1); /* Set up & reset dataset location */ dset_loc.oloc = &(new_dset->oloc); @@ -1162,6 +1204,10 @@ H5D_create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, new_dset->shared->fo_count = 1; + /* Register callback for this dataset with cache, when journaling status changes */ + if(H5AC2_register_mdjsc_callback(new_dset->oloc.file, H5D_journal_status_cb, new_dset, &new_dset->mdjsc_idx, NULL) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't register journal status callback") + /* Success */ ret_value = new_dset; @@ -1232,6 +1278,7 @@ H5D_open(const H5G_loc_t *loc, hid_t dxpl_id) /* Allocate the dataset structure */ if(NULL == (dataset = H5FL_CALLOC(H5D_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + dataset->mdjsc_idx = (-1); /* Shallow copy (take ownership) of the object location object */ if(H5O_loc_copy(&(dataset->oloc), loc->oloc, H5_COPY_SHALLOW) < 0) @@ -1250,6 +1297,10 @@ H5D_open(const H5G_loc_t *loc, hid_t dxpl_id) if(H5D_open_oid(dataset, dxpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, NULL, "not found") + /* Register callback for this dataset with cache, when journaling status changes */ + if(H5AC2_register_mdjsc_callback(dataset->oloc.file, H5D_journal_status_cb, dataset, &dataset->mdjsc_idx, NULL) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't register journal status callback") + /* Add the dataset to the list of opened objects in the file */ if(H5FO_insert(dataset->oloc.file, dataset->oloc.addr, dataset->shared, FALSE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, NULL, "can't insert dataset into list of open objects") @@ -1569,6 +1620,11 @@ H5D_close(H5D_t *dataset) H5D_chunk_stats(dataset, FALSE); #endif /* H5D_CHUNK_DEBUG */ + /* Deregister callback for this dataset with cache, when journaling status changes */ + if(dataset->mdjsc_idx >= 0) + if(H5AC2_deregister_mdjsc_callback(dataset->oloc.file, dataset->mdjsc_idx) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't deregister journal status callback") + dataset->shared->fo_count--; if(dataset->shared->fo_count == 0) { /* Flush the dataset's information */ diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index ebfb8bb..bb7d13c 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -415,6 +415,7 @@ struct H5D_t { H5O_loc_t oloc; /* Object header location */ H5G_name_t path; /* Group hierarchy path */ H5D_shared_t *shared; /* cached information from file */ + int32_t mdjsc_idx; /* Journaling status change index */ }; /* Enumerated type for allocating dataset's storage */ diff --git a/test/cache2_journal.c b/test/cache2_journal.c index 7fb60d6..a7a476b 100644 --- a/test/cache2_journal.c +++ b/test/cache2_journal.c @@ -179,6 +179,7 @@ static void check_superblock_extensions(void); static void check_mdjsc_callbacks(void); static void test_mdjsc_callback(H5C2_mdj_config_t * config_ptr, + hid_t dxpl_id, void * data_ptr); static void deregister_mdjsc_callback(H5F_t * file_ptr, @@ -6546,6 +6547,7 @@ static int callback_test_null_data_ptr_count = 0; static void test_mdjsc_callback(H5C2_mdj_config_t * config_ptr, + hid_t dxpl_id, void * data_ptr) { if ( config_ptr == NULL ) |