From 19e0ec17dd066748a739ecb9ac4cd584479ea92c Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 10 Jun 2009 22:28:57 -0500 Subject: [svn-r17029] Description: Adjust 'temporary' file space code to always be within the file's address space, even when the file uses 32-bit addresses. (It's not really necessary to be within the file's address space, since objects with temporary addresses can't be written to the file, but it can't really hurt and it makes the testing easier) Tested on: Linux/32 2.6 (jam) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe, in debug mode and with 'make check-vfd' --- src/H5F.c | 2 +- src/H5Fpkg.h | 1 + src/H5Ftest.c | 33 +++++++++++++++++++++++++++++++++ test/mf.c | 25 +++++++++++++++++-------- 4 files changed, 52 insertions(+), 9 deletions(-) diff --git a/src/H5F.c b/src/H5F.c index d1890b0..3c3f98e 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -894,7 +894,6 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf) f->shared->accum.loc = HADDR_UNDEF; f->shared->lf = lf; f->shared->root_addr = HADDR_UNDEF; - f->shared->tmp_addr = HADDR_MAX; /* * Copy the file creation and file access property lists into the @@ -950,6 +949,7 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf) f->shared->maxaddr = H5FD_get_maxaddr(lf); if(!H5F_addr_defined(f->shared->maxaddr)) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad maximum address from VFD") + f->shared->tmp_addr = f->shared->maxaddr; if(H5FD_get_feature_flags(lf, &f->shared->feature_flags) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get feature flags from VFD") if(H5FD_get_fs_type_map(lf, f->shared->fs_type_map) < 0) diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 59f5109..acc8aaf 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -250,6 +250,7 @@ H5_DLL herr_t H5F_sfile_remove(H5F_file_t *shared); H5_DLL herr_t H5F_get_sohm_mesg_count_test(hid_t fid, unsigned type_id, size_t *mesg_count); H5_DLL herr_t H5F_check_cached_stab_test(hid_t file_id); +H5_DLL herr_t H5F_get_maxaddr_test(hid_t file_id, haddr_t *maxaddr); #endif /* H5F_TESTING */ #endif /* _H5Fpkg_H */ diff --git a/src/H5Ftest.c b/src/H5Ftest.c index 8cbc133..72fee96 100644 --- a/src/H5Ftest.c +++ b/src/H5Ftest.c @@ -153,3 +153,36 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_check_cached_stab_test() */ + +/*------------------------------------------------------------------------- + * Function: H5F_get_maxaddr_test + * + * Purpose: Retrieve the maximum address for a file + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Jun 10, 2009 + * + *------------------------------------------------------------------------- + */ +herr_t +H5F_get_maxaddr_test(hid_t file_id, haddr_t *maxaddr) +{ + H5F_t *file; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5F_get_maxaddr_test) + + /* Check arguments */ + if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") + + /* Retrieve maxaddr for file */ + *maxaddr = file->shared->maxaddr; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F_get_maxaddr_test() */ + diff --git a/test/mf.c b/test/mf.c index 958db67..164427c 100644 --- a/test/mf.c +++ b/test/mf.c @@ -742,14 +742,19 @@ static unsigned test_mf_tmp(const char *env_h5_drvr, hid_t fapl) { hid_t file = -1; /* File ID */ + hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ TESTING("'temporary' file space allocation"); - /* Can't run this test with multi-file VFDs */ - if(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family")) { + /* Skip test when using VFDs that has different address spaces for each + * type of metadata allocation. + */ + contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi")); + if(contig_addr_vfd) { char filename[FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ h5_stat_size_t file_size, new_file_size; /* file size */ + haddr_t maxaddr; /* File's max. address */ haddr_t tmp_addr; /* Temporary space file address */ haddr_t norm_addr; /* Normal space file address */ haddr_t check_addr; /* File address for checking for errors */ @@ -780,12 +785,16 @@ test_mf_tmp(const char *env_h5_drvr, hid_t fapl) if(NULL == (f = (H5F_t *)H5I_object(file))) FAIL_STACK_ERROR + /* Retrieve the file's maxaddr */ + if(H5F_get_maxaddr_test(file, &maxaddr) < 0) + FAIL_STACK_ERROR + /* Allocate some temporary address space */ if(HADDR_UNDEF == (tmp_addr = H5MF_alloc_tmp(f, (hsize_t)TEST_BLOCK_SIZE30))) FAIL_STACK_ERROR /* Check if temporary file address is valid */ - if(tmp_addr < (haddr_t)(HADDR_MAX - TEST_BLOCK_SIZE30)) + if(tmp_addr < (haddr_t)(maxaddr - TEST_BLOCK_SIZE30)) TEST_ERROR /* Reading & writing with a temporary address value should fail */ @@ -829,29 +838,29 @@ test_mf_tmp(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR /* Allocate 1/3 of the file as temporary address space */ - if(HADDR_UNDEF == (tmp_addr = H5MF_alloc_tmp(f, (hsize_t)(HADDR_MAX / 3)))) + if(HADDR_UNDEF == (tmp_addr = H5MF_alloc_tmp(f, (hsize_t)(maxaddr / 3)))) FAIL_STACK_ERROR /* Allocate 1/3 of the file as normal address space */ - if(HADDR_UNDEF == (norm_addr = H5MF_alloc(f, H5FD_MEM_DRAW, H5P_DATASET_XFER_DEFAULT, (hsize_t)(HADDR_MAX / 3)))) + if(HADDR_UNDEF == (norm_addr = H5MF_alloc(f, H5FD_MEM_DRAW, H5P_DATASET_XFER_DEFAULT, (hsize_t)(maxaddr / 3)))) FAIL_STACK_ERROR /* Test that pushing temporary space allocation into normal space fails */ H5E_BEGIN_TRY { - check_addr = H5MF_alloc_tmp(f, (hsize_t)(HADDR_MAX / 3)); + check_addr = H5MF_alloc_tmp(f, (hsize_t)(maxaddr / 3)); } H5E_END_TRY; if(H5F_addr_defined(check_addr)) TEST_ERROR /* Test that pushing normal space allocation into temporary space fails */ H5E_BEGIN_TRY { - check_addr = H5MF_alloc(f, H5FD_MEM_DRAW, H5P_DATASET_XFER_DEFAULT, (hsize_t)(HADDR_MAX / 3)); + check_addr = H5MF_alloc(f, H5FD_MEM_DRAW, H5P_DATASET_XFER_DEFAULT, (hsize_t)(maxaddr / 3)); } H5E_END_TRY; if(H5F_addr_defined(check_addr)) TEST_ERROR /* Free the normal block (so the file doesn't blow up to a huge size) */ - if(H5MF_xfree(f, H5FD_MEM_DRAW, H5P_DATASET_XFER_DEFAULT, norm_addr, (hsize_t)(HADDR_MAX / 3)) < 0) + if(H5MF_xfree(f, H5FD_MEM_DRAW, H5P_DATASET_XFER_DEFAULT, norm_addr, (hsize_t)(maxaddr / 3)) < 0) FAIL_STACK_ERROR /* Close the file */ -- cgit v0.12