summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-06-18 17:20:50 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-06-18 17:20:50 (GMT)
commitb6cfe32b73a7fd3e4c9ace7bcec1e27156db67d3 (patch)
tree16da916bf11f5972e4383b079fb9788082646c65
parent79a41596f50a0c7dee47203af389b8647dfdb963 (diff)
downloadhdf5-b6cfe32b73a7fd3e4c9ace7bcec1e27156db67d3.zip
hdf5-b6cfe32b73a7fd3e4c9ace7bcec1e27156db67d3.tar.gz
hdf5-b6cfe32b73a7fd3e4c9ace7bcec1e27156db67d3.tar.bz2
[svn-r17083] Description:
Bring r17010,17017,17021-17022,17029-17031,17035 back from trunk: "temporary" file allocation space changes. Tested on: 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 debug mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode Mac OS X/32 10.5.7 (amazon) in debug mode Mac OS X/32 10.5.7 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
-rw-r--r--src/H5F.c1
-rw-r--r--src/H5FDstdio.c2
-rw-r--r--src/H5Fio.c8
-rw-r--r--src/H5Fpkg.h2
-rw-r--r--src/H5Fprivate.h3
-rw-r--r--src/H5Fquery.c29
-rw-r--r--src/H5Ftest.c33
-rw-r--r--src/H5MF.c75
-rw-r--r--src/H5MFaggr.c30
-rw-r--r--src/H5MFprivate.h3
-rw-r--r--test/mf.c208
11 files changed, 376 insertions, 18 deletions
diff --git a/src/H5F.c b/src/H5F.c
index eebbc4f..2ae2886 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -949,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/H5FDstdio.c b/src/H5FDstdio.c
index 0ae09a6..193c576 100644
--- a/src/H5FDstdio.c
+++ b/src/H5FDstdio.c
@@ -147,8 +147,10 @@ typedef struct H5FD_stdio_t {
#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \
HADDR_UNDEF==(A)+(Z) || (file_offset_t)((A)+(Z))<(file_offset_t)(A))
+#ifndef H5_HAVE_FSEEKO
/* Define big file as 2GB */
#define BIG_FILE 0x80000000UL
+#endif
/* Prototypes */
static H5FD_t *H5FD_stdio_open(const char *name, unsigned flags,
diff --git a/src/H5Fio.c b/src/H5Fio.c
index 1081a27..407f950 100644
--- a/src/H5Fio.c
+++ b/src/H5Fio.c
@@ -104,6 +104,10 @@ H5F_block_read(const H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size,
HDassert(f->shared);
HDassert(buf);
+ /* Check for attempting I/O on 'temporary' file address */
+ if(H5F_addr_le(f->shared->tmp_addr, (addr + size)))
+ HGOTO_ERROR(H5E_IO, H5E_BADRANGE, FAIL, "attempting I/O in temporary file space")
+
/* Check if this I/O can be satisfied by the metadata accumulator */
if((accumulated = H5F_accum_read(f, dxpl_id, type, addr, size, buf)) < 0)
HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "read from metadata accumulator failed")
@@ -150,6 +154,10 @@ HDfprintf(stderr, "%s: write to addr = %a, size = %Zu\n", FUNC, addr, size);
HDassert(f->intent & H5F_ACC_RDWR);
HDassert(buf);
+ /* Check for attempting I/O on 'temporary' file address */
+ if(H5F_addr_le(f->shared->tmp_addr, (addr + size)))
+ HGOTO_ERROR(H5E_IO, H5E_BADRANGE, FAIL, "attempting I/O in temporary file space")
+
/* Check for accumulating metadata */
if((accumulated = H5F_accum_write(f, dxpl_id, type, addr, size, buf)) < 0)
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "write to metadata accumulator failed")
diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h
index 49af73e..acc8aaf 100644
--- a/src/H5Fpkg.h
+++ b/src/H5Fpkg.h
@@ -162,6 +162,7 @@ typedef struct H5F_file_t {
haddr_t root_addr; /* Root group address */
H5FO_t *open_objs; /* Open objects in file */
H5RC_t *grp_btree_shared; /* Ref-counted group B-tree node info */
+ haddr_t tmp_addr; /* Next address to use for temp. space in the file */
/* File space allocation information */
unsigned fs_aggr_merge[H5FD_MEM_NTYPES]; /* Flags for whether free space can merge with aggregator(s) */
@@ -249,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/H5Fprivate.h b/src/H5Fprivate.h
index 4062505..58997ee 100644
--- a/src/H5Fprivate.h
+++ b/src/H5Fprivate.h
@@ -265,6 +265,7 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t;
#define H5F_HAS_FEATURE(F,FL) ((F)->shared->lf->feature_flags & (FL))
#define H5F_DRIVER_ID(F) ((F)->shared->lf->driver_id)
#define H5F_GET_FILENO(F,FILENUM) ((FILENUM) = (F)->shared->lf->fileno)
+#define H5F_IS_TMP_ADDR(F, ADDR) (H5F_addr_le((F)->shared->tmp_addr, (ADDR)))
#else /* H5F_PACKAGE */
#define H5F_INTENT(F) (H5F_get_intent(F))
#define H5F_FCPL(F) (H5F_get_fcpl(F))
@@ -287,6 +288,7 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t;
#define H5F_HAS_FEATURE(F,FL) (H5F_has_feature(F,FL))
#define H5F_DRIVER_ID(F) (H5F_get_driver_id(F))
#define H5F_GET_FILENO(F,FILENUM) (H5F_get_fileno((F), &(FILENUM)))
+#define H5F_IS_TMP_ADDR(F, ADDR) (H5F_is_tmp_addr((F), (ADDR)))
#endif /* H5F_PACKAGE */
@@ -488,6 +490,7 @@ H5_DLL unsigned H5F_gc_ref(const H5F_t *f);
H5_DLL hbool_t H5F_use_latest_format(const H5F_t *f);
H5_DLL H5F_close_degree_t H5F_get_fc_degree(const H5F_t *f);
H5_DLL hbool_t H5F_store_msg_crt_idx(const H5F_t *f);
+H5_DLL hbool_t H5F_is_tmp_addr(const H5F_t *f, haddr_t addr);
/* Functions that retrieve values from VFD layer */
H5_DLL hbool_t H5F_has_feature(const H5F_t *f, unsigned feature);
diff --git a/src/H5Fquery.c b/src/H5Fquery.c
index 275061d..5538d60 100644
--- a/src/H5Fquery.c
+++ b/src/H5Fquery.c
@@ -687,3 +687,32 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5F_get_fileno() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5F_is_tmp_addr
+ *
+ * Purpose: Quick and dirty routine to determine if an address is in
+ * the 'temporary' file space.
+ * (Mainly added to stop non-file routines from poking about in the
+ * H5F_t data structure)
+ *
+ * Return: TRUE/FALSE on success/abort on failure (shouldn't fail)
+ *
+ * Programmer: Quincey Koziol <koziol@hdfgroup.org>
+ * June 11, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+hbool_t
+H5F_is_tmp_addr(const H5F_t *f, haddr_t addr)
+{
+ /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_is_tmp_addr)
+
+ HDassert(f);
+ HDassert(f->shared);
+ HDassert(f->shared->lf);
+
+ FUNC_LEAVE_NOAPI(H5F_addr_le(f->shared->tmp_addr, addr))
+} /* end H5F_is_tmp_addr() */
+
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/src/H5MF.c b/src/H5MF.c
index 3fc7af0..2cf52b0 100644
--- a/src/H5MF.c
+++ b/src/H5MF.c
@@ -302,6 +302,8 @@ HDfprintf(stderr, "%s: alloc_type = %u, size = %Hu\n", FUNC, (unsigned)alloc_typ
/* check arguments */
HDassert(f);
+ HDassert(f->shared);
+ HDassert(f->shared->lf);
HDassert(size > 0);
/* Get free space type from allocation type */
@@ -374,14 +376,17 @@ HDfprintf(stderr, "%s: Check 2.0\n", FUNC);
if(alloc_type != H5FD_MEM_DRAW) {
/* Handle metadata differently from "raw" data */
if(HADDR_UNDEF == (ret_value = H5MF_aggr_alloc(f, dxpl_id, &(f->shared->meta_aggr), &(f->shared->sdata_aggr), alloc_type, size)))
- HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate metadata")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate metadata")
} /* end if */
else {
/* Allocate "raw" data */
if(HADDR_UNDEF == (ret_value = H5MF_aggr_alloc(f, dxpl_id, &(f->shared->sdata_aggr), &(f->shared->meta_aggr), alloc_type, size)))
- HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate raw data")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate raw data")
} /* end else */
+ /* Sanity check for overlapping into file's temporary allocation space */
+ HDassert(H5F_addr_le((ret_value + size), f->shared->tmp_addr));
+
done:
#ifdef H5MF_ALLOC_DEBUG
HDfprintf(stderr, "%s: Leaving: ret_value = %a, size = %Hu\n", FUNC, ret_value, size);
@@ -394,6 +399,66 @@ H5MF_sects_dump(f, dxpl_id, stderr);
/*-------------------------------------------------------------------------
+ * Function: H5MF_alloc_tmp
+ *
+ * Purpose: Allocate temporary space in the file
+ *
+ * Note: The address returned is non-overlapping with any other address
+ * in the file and suitable for insertion into the metadata
+ * cache.
+ *
+ * The address is _not_ suitable for actual file I/O and will
+ * cause an error if it is so used.
+ *
+ * The space allocated with this routine should _not_ be freed,
+ * it should just be abandoned. Calling H5MF_xfree() with space
+ * from this routine will cause an error.
+ *
+ * Return: Success: Temporary file address
+ * Failure: HADDR_UNDEF
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, June 4, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+haddr_t
+H5MF_alloc_tmp(H5F_t *f, hsize_t size)
+{
+ haddr_t eoa; /* End of allocated space in the file */
+ haddr_t ret_value; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5MF_alloc_tmp, HADDR_UNDEF)
+#ifdef H5MF_ALLOC_DEBUG
+HDfprintf(stderr, "%s: size = %Hu\n", FUNC, size);
+#endif /* H5MF_ALLOC_DEBUG */
+
+ /* check args */
+ HDassert(f);
+ HDassert(f->shared);
+ HDassert(f->shared->lf);
+ HDassert(size > 0);
+
+ /* Retrieve the 'eoa' for the file */
+ if(HADDR_UNDEF == (eoa = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, HADDR_UNDEF, "driver get_eoa request failed")
+
+ /* Compute value to return */
+ ret_value = f->shared->tmp_addr - size;
+
+ /* Check for overlap into the actual allocated space in the file */
+ if(H5F_addr_le(ret_value, eoa))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, HADDR_UNDEF, "driver get_eoa request failed")
+
+ /* Adjust temporary address allocator in the file */
+ f->shared->tmp_addr = ret_value;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5MF_alloc_tmp() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5MF_xfree
*
* Purpose: Frees part of a file, making that part of the file
@@ -427,6 +492,10 @@ HDfprintf(stderr, "%s: Entering - alloc_type = %u, addr = %a, size = %Hu\n", FUN
HGOTO_DONE(SUCCEED);
HDassert(addr != 0); /* Can't deallocate the superblock :-) */
+ /* Check for attempting to free space that's a 'temporary' file address */
+ if(H5F_addr_le(f->shared->tmp_addr, addr))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, FAIL, "attempting to free temporary file space")
+
/* Check if the space to free intersects with the file's metadata accumulator */
if(H5F_accum_free(f, dxpl_id, alloc_type, addr, size) < 0)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't check free space intersection w/metadata accumulator")
@@ -701,6 +770,8 @@ HDfprintf(stderr, "%s: Entering - alloc_type = %u, addr = %a, size = %Hu\n", FUN
/* check arguments */
HDassert(f);
+ HDassert(f->shared);
+ HDassert(f->shared->lf);
HDassert(H5F_addr_defined(addr));
HDassert(size > 0);
diff --git a/src/H5MFaggr.c b/src/H5MFaggr.c
index f383e23..0f8a374 100644
--- a/src/H5MFaggr.c
+++ b/src/H5MFaggr.c
@@ -119,6 +119,9 @@ HDfprintf(stderr, "%s: type = %u, size = %Hu\n", FUNC, (unsigned)type, size);
HDassert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES);
HDassert(size > 0);
+ if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, type)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, HADDR_UNDEF, "Unable to get eoa")
+
/*
* If the aggregation feature is enabled for this file, allocate "generic"
* space and sub-allocate out of that, if possible. Otherwise just allocate
@@ -138,9 +141,6 @@ HDfprintf(stderr, "%s: aggr = {%a, %Hu, %Hu}\n", FUNC, aggr->addr, aggr->tot_siz
frag_size = alignment - mis_align;
}
- if (HADDR_UNDEF == (eoa = H5F_get_eoa(f, type)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "Unable to get eoa")
-
alloc_type = aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA ? H5FD_MEM_DEFAULT : H5FD_MEM_DRAW;
other_alloc_type = other_aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA ? H5FD_MEM_DEFAULT : H5FD_MEM_DRAW;
@@ -149,9 +149,12 @@ HDfprintf(stderr, "%s: aggr = {%a, %Hu, %Hu}\n", FUNC, aggr->addr, aggr->tot_siz
/* Check if the block asked for is too large for 'normal' aggregator block */
if(size >= aggr->alloc_size) {
-
hsize_t ext_size = size + frag_size;
+ /* Check for overlapping into file's temporary allocation space */
+ if(H5F_addr_gt((aggr->addr + aggr->size + ext_size), f->shared->tmp_addr))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space")
+
if ((aggr->addr > 0) && (extended=H5FD_try_extend(f->shared->lf, alloc_type, aggr->addr + aggr->size, ext_size)) < 0)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't extending space")
else if (extended) {
@@ -160,6 +163,10 @@ HDfprintf(stderr, "%s: aggr = {%a, %Hu, %Hu}\n", FUNC, aggr->addr, aggr->tot_siz
aggr->addr += ext_size;
aggr->tot_size += ext_size;
} else {
+ /* Check for overlapping into file's temporary allocation space */
+ if(H5F_addr_gt((eoa + size), f->shared->tmp_addr))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space")
+
if ((other_aggr->size > 0) && (H5F_addr_eq((other_aggr->addr + other_aggr->size), eoa)) &&
((other_aggr->tot_size - other_aggr->size) >= other_aggr->alloc_size)) {
@@ -189,6 +196,10 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC);
if (frag_size > (ext_size - size))
ext_size += (frag_size - (ext_size - size));
+ /* Check for overlapping into file's temporary allocation space */
+ if(H5F_addr_gt((aggr->addr + aggr->size + ext_size), f->shared->tmp_addr))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space")
+
if ((aggr->addr > 0) && (extended = H5FD_try_extend(f->shared->lf, alloc_type, aggr->addr + aggr->size, ext_size)) < 0)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't extending space")
else if (extended) {
@@ -196,6 +207,10 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC);
aggr->size += (ext_size - frag_size);
aggr->tot_size += ext_size;
} else {
+ /* Check for overlapping into file's temporary allocation space */
+ if(H5F_addr_gt((eoa + aggr->alloc_size), f->shared->tmp_addr))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space")
+
if ((other_aggr->size > 0) && (H5F_addr_eq((other_aggr->addr + other_aggr->size), eoa)) &&
((other_aggr->tot_size - other_aggr->size) >= other_aggr->alloc_size)) {
@@ -250,6 +265,10 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC);
}
} /* end if */
else {
+ /* Check for overlapping into file's temporary allocation space */
+ if(H5F_addr_gt((eoa + size), f->shared->tmp_addr))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space")
+
/* Allocate data from the file */
if(HADDR_UNDEF == (ret_value = H5FD_alloc(f->shared->lf, dxpl_id, type, size, &eoa_frag_addr, &eoa_frag_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space")
@@ -258,6 +277,9 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC);
HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, HADDR_UNDEF, "can't free eoa fragment")
} /* end else */
+ /* Sanity check for overlapping into file's temporary allocation space */
+ HDassert(H5F_addr_le((ret_value + size), f->shared->tmp_addr));
+
done:
#ifdef H5MF_AGGR_DEBUG
HDfprintf(stderr, "%s: ret_value = %a\n", FUNC, ret_value);
diff --git a/src/H5MFprivate.h b/src/H5MFprivate.h
index 0d1da8a..4508199 100644
--- a/src/H5MFprivate.h
+++ b/src/H5MFprivate.h
@@ -72,6 +72,9 @@ H5_DLL herr_t H5MF_try_extend(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type,
H5_DLL htri_t H5MF_try_shrink(H5F_t *f, H5FD_mem_t alloc_type, hid_t dxpl_id,
haddr_t addr, hsize_t size);
+/* File 'temporary' space allocation routines */
+H5_DLL haddr_t H5MF_alloc_tmp(H5F_t *f, hsize_t size);
+
/* 'block aggregator' routines */
H5_DLL herr_t H5MF_aggr_reset(H5F_t *file, hid_t dxpl_id, H5F_blk_aggr_t *aggr);
diff --git a/test/mf.c b/test/mf.c
index ff54751..5c05848 100644
--- a/test/mf.c
+++ b/test/mf.c
@@ -30,6 +30,7 @@
#include "H5FSpkg.h"
#define H5F_PACKAGE
+#define H5F_TESTING
#include "H5Fpkg.h"
#include "H5FLprivate.h"
@@ -718,6 +719,182 @@ error:
} /* test_mf_eoa_extend() */
/*
+ * To verify that temporary blocks are allocated correctly
+ *
+ * Set up:
+ * There is nothing in free-space manager
+ *
+ * Tests:
+ * Allocate a reasonable-sized temporary block
+ * Check that the temporary address is high enough
+ * Check that file I/O with the temporary address fails
+ * Check that freeing a temporary address fails
+ * Check that closing the file doesn't change the file's size
+ * Check that overlapping normal & temporary address space fails:
+ * - Reopen the file
+ * - Allocate enough temporary space to use ~1/3 of the file
+ * - Allocate enough 'normal' space to use ~1/3 of the file
+ * - Check that allocating another 1/2 of the file as temporary address
+ * space fails
+ * - Check that allocating another 1/2 of the file as normal address
+ * space fails
+ */
+static unsigned
+test_mf_tmp(const char *env_h5_drvr, hid_t fapl)
+{
+ hid_t file = -1; /* File ID */
+
+ 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")) {
+ 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 */
+ unsigned char buf = 0; /* Buffer to read/write with */
+ herr_t status; /* Generic status value */
+
+ /* Set the filename to use for this test */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
+
+ /* Create the file to work on */
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ 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(!H5F_IS_TMP_ADDR(f, tmp_addr))
+ TEST_ERROR
+ if(tmp_addr < (haddr_t)(maxaddr - TEST_BLOCK_SIZE30))
+ TEST_ERROR
+
+ /* Reading & writing with a temporary address value should fail */
+ H5E_BEGIN_TRY {
+ status = H5F_block_read(f, H5FD_MEM_SUPER, tmp_addr, sizeof(buf), H5P_DATASET_XFER_DEFAULT, &buf);
+ } H5E_END_TRY;
+ if(status >= 0)
+ TEST_ERROR
+ H5E_BEGIN_TRY {
+ status = H5F_block_write(f, H5FD_MEM_SUPER, tmp_addr, sizeof(buf), H5P_DATASET_XFER_DEFAULT, &buf);
+ } H5E_END_TRY;
+ if(status >= 0)
+ TEST_ERROR
+
+ /* Freeing a temporary address value should fail */
+ H5E_BEGIN_TRY {
+ status = H5MF_xfree(f, H5FD_MEM_SUPER, H5P_DATASET_XFER_DEFAULT, tmp_addr, (hsize_t)TEST_BLOCK_SIZE30);
+ } H5E_END_TRY;
+ if(status >= 0)
+ TEST_ERROR
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((new_file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if(new_file_size != file_size)
+ TEST_ERROR
+
+
+ /* Re-open the file */
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
+ /* Allocate 1/3 of the file as temporary address space */
+ if(HADDR_UNDEF == (tmp_addr = H5MF_alloc_tmp(f, (hsize_t)(maxaddr / 3))))
+ FAIL_STACK_ERROR
+ if(!H5F_IS_TMP_ADDR(f, tmp_addr))
+ TEST_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)(maxaddr / 3))))
+ FAIL_STACK_ERROR
+ if(H5F_IS_TMP_ADDR(f, norm_addr))
+ TEST_ERROR
+
+ /* Test that pushing temporary space allocation into normal space fails */
+ H5E_BEGIN_TRY {
+ 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)(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)(maxaddr / 3)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the size of the file */
+ if((new_file_size = h5_get_file_size(filename, fapl)) < 0)
+ TEST_ERROR
+
+ /* Verify the file is the correct size */
+ if(new_file_size != file_size)
+ TEST_ERROR
+
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support continuous address space");
+ } /* end else */
+
+ return(0);
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ } H5E_END_TRY;
+ return(1);
+} /* test_mf_tmp() */
+
+/*
* To verify that the free-space manager is started up via H5MF_alloc_start()
*
* Set up:
@@ -3583,6 +3760,10 @@ test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl)
if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl1)) < 0)
FAIL_STACK_ERROR
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
/* shrink the block */
if(H5MF_try_shrink(f, type, H5P_DATASET_XFER_DEFAULT, addr1, (hsize_t)TEST_BLOCK_SIZE50) <= 0)
TEST_ERROR
@@ -3634,6 +3815,10 @@ test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl)
if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl1)) < 0)
FAIL_STACK_ERROR
+ /* Get a pointer to the internal file object */
+ if(NULL == (f = (H5F_t *)H5I_object(file)))
+ FAIL_STACK_ERROR
+
/* try to extend the block */
extended = H5MF_try_extend(f, H5P_DATASET_XFER_DEFAULT, type, (haddr_t)addr1, (hsize_t)TEST_BLOCK_SIZE50, (hsize_t)TEST_BLOCK_SIZE30);
@@ -5625,11 +5810,6 @@ main(void)
env_h5_drvr = "nomatch";
fapl = h5_fileaccess();
- if((new_fapl = H5Pcopy(fapl)) < 0) TEST_ERROR
-
- /* alignment is not set for the following tests */
- if(H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)1) < 0)
- TEST_ERROR
/* meta/small data is set to 2048 for the following tests */
if(H5Pset_meta_block_size(fapl, (hsize_t)TEST_BLOCK_SIZE2048) < 0)
@@ -5637,11 +5817,21 @@ main(void)
if(H5Pset_small_data_block_size(fapl, (hsize_t)TEST_BLOCK_SIZE2048) < 0)
TEST_ERROR
+ /* Make a copy of the FAPL before adjusting the alignment */
+ if((new_fapl = H5Pcopy(fapl)) < 0) TEST_ERROR
+
+ /* alignment is not set for the following tests */
+ if(H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)1) < 0)
+ TEST_ERROR
+
/* interaction with file allocation */
nerrors += test_mf_eoa(env_h5_drvr, fapl);
nerrors += test_mf_eoa_shrink(env_h5_drvr, fapl);
nerrors += test_mf_eoa_extend(env_h5_drvr, fapl);
+ /* interaction with temporary file space allocation */
+ nerrors += test_mf_tmp(env_h5_drvr, fapl);
+
/* interaction with free-space manager */
nerrors += test_mf_fs_start(fapl);
nerrors += test_mf_fs_alloc_free(fapl);
@@ -5663,12 +5853,6 @@ main(void)
* tests for alignment
*/
- /* set meta/sdata block size = 2048 */
- if(H5Pset_meta_block_size(new_fapl, (hsize_t)TEST_BLOCK_SIZE2048) < 0)
- TEST_ERROR
- if(H5Pset_small_data_block_size(new_fapl, (hsize_t)TEST_BLOCK_SIZE2048) < 0)
- TEST_ERROR
-
for(curr_test = TEST_NORMAL; curr_test < TEST_NTESTS; curr_test++) {
switch(curr_test) {
@@ -5695,7 +5879,7 @@ main(void)
nerrors += test_mf_align_alloc4(env_h5_drvr, fapl, new_fapl);
nerrors += test_mf_align_alloc5(env_h5_drvr, fapl, new_fapl);
nerrors += test_mf_align_alloc6(env_h5_drvr, fapl, new_fapl);
- }
+ } /* end if */
if(nerrors)
goto error;