summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-06-08 23:16:19 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-06-08 23:16:19 (GMT)
commit4fa1b3c1aa6ee23977c095ceaab7aca4ce2b9edf (patch)
tree9dc15e50454dbb7e6558fa579074d3f1fd589fc8 /src
parentc87c334876247c27b1ca3bb670641ccff48b51d9 (diff)
downloadhdf5-4fa1b3c1aa6ee23977c095ceaab7aca4ce2b9edf.zip
hdf5-4fa1b3c1aa6ee23977c095ceaab7aca4ce2b9edf.tar.gz
hdf5-4fa1b3c1aa6ee23977c095ceaab7aca4ce2b9edf.tar.bz2
[svn-r17017] Description:
Rework the "proxy address" code to be more general and implement a better "temporary address" feature, that will allow for metadata allocations to be deferred to when the metadata is actually flushed to the file. 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
Diffstat (limited to 'src')
-rw-r--r--src/H5F.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/H5MF.c69
-rw-r--r--src/H5MFprivate.h3
7 files changed, 80 insertions, 36 deletions
diff --git a/src/H5F.c b/src/H5F.c
index 3af83fa..d1890b0 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -894,7 +894,7 @@ 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->next_proxy_addr = HADDR_MAX;
+ f->shared->tmp_addr = HADDR_MAX;
/*
* Copy the file creation and file access property lists into the
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 0f14b46..59f5109 100644
--- a/src/H5Fpkg.h
+++ b/src/H5Fpkg.h
@@ -162,7 +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 next_proxy_addr; /* Next address to use for metadata cache proxy entries */
+ 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) */
diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h
index 59bdd10..cd6bcd0 100644
--- a/src/H5Fprivate.h
+++ b/src/H5Fprivate.h
@@ -265,7 +265,6 @@ 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_GET_NEXT_PROXY_ADDR(F) ((F)->shared->next_proxy_addr--)
#else /* H5F_PACKAGE */
#define H5F_INTENT(F) (H5F_get_intent(F))
#define H5F_FCPL(F) (H5F_get_fcpl(F))
@@ -288,7 +287,6 @@ 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_GET_NEXT_PROXY_ADDR(F) (H5F_get_next_proxy_addr(F))
#endif /* H5F_PACKAGE */
@@ -474,7 +472,6 @@ H5_DLL char *H5F_get_name(const H5F_t *f);
H5_DLL hid_t H5F_get_id(H5F_t *file, hbool_t app_ref);
H5_DLL size_t H5F_get_obj_count(const H5F_t *f, unsigned types, hbool_t app_ref);
H5_DLL size_t H5F_get_obj_ids(const H5F_t *f, unsigned types, size_t max_objs, hid_t *obj_id_list, hbool_t app_ref);
-H5_DLL haddr_t H5F_get_next_proxy_addr(const H5F_t *f);
/* Functions than retrieve values set/cached from the superblock/FCPL */
H5_DLL hid_t H5F_get_fcpl(const H5F_t *f);
diff --git a/src/H5Fquery.c b/src/H5Fquery.c
index d070b94..275061d 100644
--- a/src/H5Fquery.c
+++ b/src/H5Fquery.c
@@ -687,32 +687,3 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5F_get_fileno() */
-
-/*-------------------------------------------------------------------------
- * Function: H5F_get_next_proxy_addr
- *
- * Purpose: Quick and dirty routine to retrieve the next metadata proxy
- * address for a file.
- * (Mainly added to stop non-file routines from poking about in the
- * H5F_t data structure)
- *
- * Return: Success: Address to use for metadata cache proxy
- * Failure: abort (should not happen)
- *
- * Programmer: Quincey Koziol <koziol@hdfgroup.org>
- * May 19, 2009
- *
- *-------------------------------------------------------------------------
- */
-haddr_t
-H5F_get_next_proxy_addr(const H5F_t *f)
-{
- /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_get_next_proxy_addr)
-
- HDassert(f);
- HDassert(f->shared);
-
- FUNC_LEAVE_NOAPI(f->shared->next_proxy_addr--)
-} /* end H5F_get_next_proxy_addr() */
-
diff --git a/src/H5MF.c b/src/H5MF.c
index 3fc7af0..8beac3b 100644
--- a/src/H5MF.c
+++ b/src/H5MF.c
@@ -374,14 +374,18 @@ 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 */
+ /* Check for overlapping into file's temporary allocation space */
+ if(H5F_addr_gt((ret_value + size), f->shared->tmp_addr))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request overlaps into 'temporary' file space")
+
done:
#ifdef H5MF_ALLOC_DEBUG
HDfprintf(stderr, "%s: Leaving: ret_value = %a, size = %Hu\n", FUNC, ret_value, size);
@@ -394,6 +398,63 @@ 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)
+
+ /* 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 +488,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")
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);