diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2003-03-19 18:58:54 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2003-03-19 18:58:54 (GMT) |
commit | a52914987ebff61d0347172e11520af02a5a6b4f (patch) | |
tree | 2bfce5cf8f4a54dfb07b5e1a6a13c3404237722f /src | |
parent | d317b8b404bea67439bf9dbb8565f5532d69aa1a (diff) | |
download | hdf5-a52914987ebff61d0347172e11520af02a5a6b4f.zip hdf5-a52914987ebff61d0347172e11520af02a5a6b4f.tar.gz hdf5-a52914987ebff61d0347172e11520af02a5a6b4f.tar.bz2 |
[svn-r6497] Purpose:
Finish code cleanup
Description:
Wrap up the conversion of H5F_flush's multiple boolean flags into a single
bitfield of flags by pushing the flags down into the H5AC_flush and
H5F_istore_flush routines.
Also, changed the flags from H5_FLUSH_<foo> to H5F_FLUSH_<foo> to be more
consistent with rest of library.
And reverted the changes to H5FDflush and H5FD_flush routines.
Platforms tested:
FreeBSD 4.7 (sleipnir)
Solaris 5.8 (sol)
IRIX64 6.5 (modi4) w/parallel
Misc. update:
Diffstat (limited to 'src')
-rw-r--r-- | src/H5AC.c | 48 | ||||
-rw-r--r-- | src/H5ACprivate.h | 2 | ||||
-rw-r--r-- | src/H5B.c | 2 | ||||
-rw-r--r-- | src/H5Distore.c | 10 | ||||
-rw-r--r-- | src/H5F.c | 24 | ||||
-rw-r--r-- | src/H5FD.c | 15 | ||||
-rw-r--r-- | src/H5FDprivate.h | 2 | ||||
-rw-r--r-- | src/H5Fistore.c | 10 | ||||
-rw-r--r-- | src/H5Fpkg.h | 2 | ||||
-rw-r--r-- | src/H5Fprivate.h | 10 | ||||
-rw-r--r-- | src/H5Gnode.c | 2 | ||||
-rw-r--r-- | src/H5HG.c | 2 |
12 files changed, 73 insertions, 56 deletions
@@ -385,7 +385,7 @@ H5AC_dest(H5F_t *f, hid_t dxpl_id) assert(f->shared->cache); cache = f->shared->cache; - if (H5AC_flush(f, dxpl_id, NULL, HADDR_UNDEF, TRUE) < 0) + if (H5AC_flush(f, dxpl_id, NULL, HADDR_UNDEF, H5F_FLUSH_INVALIDATE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache"); #ifdef H5AC_DEBUG @@ -713,13 +713,15 @@ H5AC_compare(const void *_a, const void *_b) *------------------------------------------------------------------------- */ herr_t -H5AC_flush(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, hbool_t destroy) +H5AC_flush(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, unsigned flags) { unsigned i; herr_t status; H5AC_flush_func_t flush=NULL; H5AC_info_t **info; int *map = NULL; + hbool_t destroy=(flags&H5F_FLUSH_INVALIDATE)>0; + hbool_t clear_only=(flags&H5F_FLUSH_CLEAR_ONLY)>0; unsigned nslots; H5AC_t *cache; herr_t ret_value=SUCCEED; /* Return value */ @@ -828,19 +830,25 @@ H5AC_flush(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, hboo flush = (*info)->type->flush; - /* Only block for all the processes on the first piece of metadata */ - if(first_flush && (*info)->dirty) { - status = (flush)(f, dxpl_id, destroy, (*info)->addr, (*info)); - first_flush=0; - } /* end if */ - else - status = (flush)(f, H5AC_noblock_dxpl_id, destroy, (*info)->addr, (*info)); - if (status < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache"); - + /* Clear the dirty flag only, if requested */ + if(clear_only) + (*info)->dirty=0; + else { + /* Only block for all the processes on the first piece of metadata */ + if(first_flush && (*info)->dirty) { + status = (flush)(f, dxpl_id, destroy, (*info)->addr, (*info)); + first_flush=0; + } /* end if */ + else + status = (flush)(f, H5AC_noblock_dxpl_id, destroy, (*info)->addr, (*info)); + if (status < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache"); #ifdef H5AC_DEBUG cache->diagnostics[type_id].nflushes++; #endif /* H5AC_DEBUG */ + } /* end else */ + + /* Destroy entry also, if asked */ if (destroy) (*info)= NULL; } @@ -915,12 +923,20 @@ H5AC_flush(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, hboo /* * Flush just this entry. */ - flush = (*info)->type->flush; - if((flush)(f, dxpl_id, destroy, (*info)->addr, (*info)) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush object"); + + /* Clear the dirty flag only, if requested */ + if(clear_only) + (*info)->dirty=0; + else { + flush = (*info)->type->flush; + if((flush)(f, dxpl_id, destroy, (*info)->addr, (*info)) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush object"); #ifdef H5AC_DEBUG - cache->diagnostics[type_id].nflushes++; + cache->diagnostics[type_id].nflushes++; #endif /* H5AC_DEBUG */ + } /* end else */ + + /* Destroy entry also, if asked */ if (destroy) (*info)= NULL; } /* end if */ diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h index be37ae1..d1edf7c 100644 --- a/src/H5ACprivate.h +++ b/src/H5ACprivate.h @@ -165,7 +165,7 @@ H5_DLL herr_t H5AC_unprotect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, H5_DLL void *H5AC_find(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, const void *udata1, void *udata2); H5_DLL herr_t H5AC_flush(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, - hbool_t destroy); + unsigned flags); H5_DLL herr_t H5AC_rename(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t old_addr, haddr_t new_addr); H5_DLL herr_t H5AC_dest(H5F_t *f, hid_t dxpl_id); @@ -1709,7 +1709,7 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type sizeof_rkey = (type->get_sizeof_rkey)(f, udata); sizeof_node = H5B_nodesize(f, type, NULL, sizeof_rkey); if (H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt)<0 || - H5AC_flush(f, dxpl_id, H5AC_BT, addr, TRUE)<0 || + H5AC_flush(f, dxpl_id, H5AC_BT, addr, H5F_FLUSH_INVALIDATE)<0 || H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, addr, sizeof_node)<0) { bt = NULL; HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to free B-tree node"); diff --git a/src/H5Distore.c b/src/H5Distore.c index cbdd504..6ac8ee3 100644 --- a/src/H5Distore.c +++ b/src/H5Distore.c @@ -1060,7 +1060,7 @@ H5F_istore_preempt(H5F_t *f, hid_t dxpl_id, H5F_rdcc_ent_t * ent, hbool_t flush) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "cannot flush indexed storage buffer"); } else { - /* Reset, but do not free or remove from list */ + /* Don't flush, just free chunk */ ent->layout = H5O_free(H5O_LAYOUT_ID, ent->layout); ent->pline = H5O_free(H5O_PLINE_ID, ent->pline); if(ent->chunk != NULL) @@ -1110,7 +1110,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F_istore_flush (H5F_t *f, hid_t dxpl_id, hbool_t preempt) +H5F_istore_flush (H5F_t *f, hid_t dxpl_id, unsigned flags) { H5F_rdcc_t *rdcc = &(f->shared->rdcc); int nerrors=0; @@ -1121,7 +1121,11 @@ H5F_istore_flush (H5F_t *f, hid_t dxpl_id, hbool_t preempt) for (ent=rdcc->head; ent; ent=next) { next = ent->next; - if (preempt) { + if ((flags&H5F_FLUSH_CLEAR_ONLY)) { + /* Just mark cache entry as clean */ + ent->dirty = FALSE; + } /* end if */ + else if ((flags&H5F_FLUSH_INVALIDATE)) { if (H5F_istore_preempt(f, dxpl_id, ent, TRUE )<0) nerrors++; } else { @@ -674,7 +674,7 @@ H5F_flush_all_cb(H5F_t *f, hid_t UNUSED fid, const void *_invalidate) FUNC_ENTER_NOINIT(H5F_flush_all_cb); - H5F_flush(f, H5F_SCOPE_LOCAL, (invalidate ? H5_FLUSH_INVALIDATE : H5_FLUSH_NONE)); + H5F_flush(f, H5F_SCOPE_LOCAL, (invalidate ? H5F_FLUSH_INVALIDATE : H5F_FLUSH_NONE)); FUNC_LEAVE_NOAPI(0); } @@ -1894,7 +1894,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d shared->base_addr = shared->boot_addr; shared->consist_flags = 0x03; - if (H5F_flush(file, dxpl_id, H5F_SCOPE_LOCAL, H5_FLUSH_ALLOC_ONLY) < 0) + if (H5F_flush(file, dxpl_id, H5F_SCOPE_LOCAL, H5F_FLUSH_ALLOC_ONLY) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to write file superblock"); /* Create and open the root group */ @@ -2379,7 +2379,7 @@ H5Fflush(hid_t object_id, H5F_scope_t scope) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "object is not associated with a file"); /* Flush the file */ - if (H5F_flush(f, H5AC_dxpl_id, scope, H5_FLUSH_NONE) < 0) + if (H5F_flush(f, H5AC_dxpl_id, scope, H5F_FLUSH_NONE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "flush failed"); done: @@ -2483,11 +2483,11 @@ H5F_flush(H5F_t *f, hid_t dxpl_id, H5F_scope_t scope, unsigned flags) for (i = 0; i < f->mtab.nmounts; i++) /* Flush but don't pass down the ALLOC_ONLY flag if there */ if (H5F_flush(f->mtab.child[i].file, dxpl_id, scope, - flags & ~H5_FLUSH_ALLOC_ONLY) < 0) + flags & ~H5F_FLUSH_ALLOC_ONLY) < 0) nerrors++; /* Avoid flushing buffers & caches when alloc_only set */ - if ((flags & H5_FLUSH_ALLOC_ONLY) == 0) { + if ((flags & H5F_FLUSH_ALLOC_ONLY) == 0) { /* flush any cached compact storage raw data */ if (H5D_flush(f, dxpl_id) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush dataset cache"); @@ -2498,7 +2498,7 @@ H5F_flush(H5F_t *f, hid_t dxpl_id, H5F_scope_t scope, unsigned flags) * metadata and "small data" blocks back to the free lists in the * file. */ - if (flags & H5_FLUSH_INVALIDATE) { + if (flags & H5F_FLUSH_INVALIDATE) { if (f->shared->lf->feature_flags & H5FD_FEAT_AGGREGATE_METADATA) { /* Return the unused portion of the metadata block to a free list */ if (f->shared->lf->eoma != 0) @@ -2541,11 +2541,11 @@ H5F_flush(H5F_t *f, hid_t dxpl_id, H5F_scope_t scope, unsigned flags) } /* end if */ /* flush the entire raw data cache */ - if (H5F_istore_flush(f, dxpl_id, flags & H5_FLUSH_INVALIDATE) < 0) + if (H5F_istore_flush(f, dxpl_id, flags & (H5F_FLUSH_INVALIDATE|H5F_FLUSH_CLEAR_ONLY)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush raw data cache"); /* flush (and invalidate) the entire meta data cache */ - if (H5AC_flush(f, dxpl_id, NULL, HADDR_UNDEF, flags & H5_FLUSH_INVALIDATE) < 0) + if (H5AC_flush(f, dxpl_id, NULL, HADDR_UNDEF, flags & (H5F_FLUSH_INVALIDATE|H5F_FLUSH_CLEAR_ONLY)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush meta data cache"); } /* end if */ @@ -2619,7 +2619,7 @@ H5F_flush(H5F_t *f, hid_t dxpl_id, H5F_scope_t scope, unsigned flags) assert(driver_size<=sizeof(dbuf)); } /* end if */ - if (flags & H5_FLUSH_ALLOC_ONLY) { + if (flags & H5F_FLUSH_ALLOC_ONLY) { haddr_t addr; /* @@ -2689,9 +2689,9 @@ H5F_flush(H5F_t *f, hid_t dxpl_id, H5F_scope_t scope, unsigned flags) } /* end else */ /* If we're not just allocating... */ - if ((flags & H5_FLUSH_ALLOC_ONLY) == 0) + if ((flags & H5F_FLUSH_ALLOC_ONLY) == 0) /* ...flush file buffers to disk. */ - if (H5FD_flush(f->shared->lf, dxpl_id, flags) < 0) + if (H5FD_flush(f->shared->lf, dxpl_id, (flags&H5F_FLUSH_CLOSING)>0) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "low level flush failed"); /* Check flush errors for children - errors are already on the stack */ @@ -2894,7 +2894,7 @@ H5F_close(H5F_t *f) /* Flush and destroy all caches */ if (H5F_flush(f, H5AC_dxpl_id, H5F_SCOPE_LOCAL, - H5_FLUSH_INVALIDATE | H5_FLUSH_CLOSING) < 0) + H5F_FLUSH_INVALIDATE | H5F_FLUSH_CLOSING) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache"); } /* end if */ @@ -3202,7 +3202,7 @@ H5FDflush(H5FD_t *file, hid_t dxpl_id, unsigned closing) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list"); /* Do the real work */ - if (H5FD_flush(file, dxpl_id, closing ? H5_FLUSH_CLOSING : H5_FLUSH_NONE) < 0) + if (H5FD_flush(file,dxpl_id,closing)<0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "file flush request failed"); done: @@ -3226,14 +3226,10 @@ done: * Quincey Koziol, May 20, 2002 * Added 'closing' parameter * - * Bill Wendling, March 18, 2003 - * Changed closing flag to FLAGS so that more than just one - * can be supported. - * *------------------------------------------------------------------------- */ herr_t -H5FD_flush(H5FD_t *file, hid_t dxpl_id, unsigned flags) +H5FD_flush(H5FD_t *file, hid_t dxpl_id, unsigned closing) { herr_t ret_value=SUCCEED; /* Return value */ @@ -3252,11 +3248,8 @@ H5FD_flush(H5FD_t *file, hid_t dxpl_id, unsigned flags) file->accum_dirty=FALSE; } /* end if */ - if ((flags & H5_FLUSH_CLEAR_ONLY) == 0) - /* Flush only if we're not clearing the dirty bits in the caches */ - if (file->cls->flush && - (file->cls->flush)(file, dxpl_id, flags & H5_FLUSH_CLOSING)<0) - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver flush request failed"); + if (file->cls->flush && (file->cls->flush)(file,dxpl_id,closing)<0) + HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver flush request failed"); done: FUNC_LEAVE_NOAPI(ret_value); diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h index b0f0b1d..7993e91 100644 --- a/src/H5FDprivate.h +++ b/src/H5FDprivate.h @@ -50,7 +50,7 @@ H5_DLL herr_t H5FD_read(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t ad void *buf/*out*/); H5_DLL herr_t H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *buf); -H5_DLL herr_t H5FD_flush(H5FD_t *file, hid_t dxpl_id, unsigned flags); +H5_DLL herr_t H5FD_flush(H5FD_t *file, hid_t dxpl_id, unsigned closing); H5_DLL herr_t H5FD_get_fileno(const H5FD_t *file, unsigned long *filenum); H5_DLL herr_t H5FD_get_vfd_handle(H5FD_t *file, hid_t fapl, void** file_handle); diff --git a/src/H5Fistore.c b/src/H5Fistore.c index cbdd504..6ac8ee3 100644 --- a/src/H5Fistore.c +++ b/src/H5Fistore.c @@ -1060,7 +1060,7 @@ H5F_istore_preempt(H5F_t *f, hid_t dxpl_id, H5F_rdcc_ent_t * ent, hbool_t flush) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "cannot flush indexed storage buffer"); } else { - /* Reset, but do not free or remove from list */ + /* Don't flush, just free chunk */ ent->layout = H5O_free(H5O_LAYOUT_ID, ent->layout); ent->pline = H5O_free(H5O_PLINE_ID, ent->pline); if(ent->chunk != NULL) @@ -1110,7 +1110,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F_istore_flush (H5F_t *f, hid_t dxpl_id, hbool_t preempt) +H5F_istore_flush (H5F_t *f, hid_t dxpl_id, unsigned flags) { H5F_rdcc_t *rdcc = &(f->shared->rdcc); int nerrors=0; @@ -1121,7 +1121,11 @@ H5F_istore_flush (H5F_t *f, hid_t dxpl_id, hbool_t preempt) for (ent=rdcc->head; ent; ent=next) { next = ent->next; - if (preempt) { + if ((flags&H5F_FLUSH_CLEAR_ONLY)) { + /* Just mark cache entry as clean */ + ent->dirty = FALSE; + } /* end if */ + else if ((flags&H5F_FLUSH_INVALIDATE)) { if (H5F_istore_preempt(f, dxpl_id, ent, TRUE )<0) nerrors++; } else { diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index aab992a..d3af30c 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -185,7 +185,7 @@ H5_DLL herr_t H5F_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, /* Functions that operate on indexed storage */ H5_DLL herr_t H5F_istore_init (H5F_t *f); -H5_DLL herr_t H5F_istore_flush (H5F_t *f, hid_t dxpl_id, hbool_t preempt); +H5_DLL herr_t H5F_istore_flush (H5F_t *f, hid_t dxpl_id, unsigned flags); H5_DLL herr_t H5F_istore_dest (H5F_t *f, hid_t dxpl_id); H5_DLL herr_t H5F_istore_read(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout, diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 522b3bd..8fd4109 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -35,11 +35,11 @@ typedef struct H5F_t H5F_t; * Flags passed into the flush routines which indicate what type of * flush we want to do. They can be ORed together. */ -#define H5_FLUSH_NONE (0U) /* No flags specified */ -#define H5_FLUSH_INVALIDATE (1U << 0) /* Invalidate cached data */ -#define H5_FLUSH_ALLOC_ONLY (1U << 1) /* Allocate space for user and super blocks */ -#define H5_FLUSH_CLOSING (1U << 2) /* Closing the file */ -#define H5_FLUSH_CLEAR_ONLY (1U << 3) /* Don't write, just clear dirty flags */ +#define H5F_FLUSH_NONE (0U) /* No flags specified */ +#define H5F_FLUSH_INVALIDATE (1U << 0) /* Invalidate cached data */ +#define H5F_FLUSH_ALLOC_ONLY (1U << 1) /* Allocate space for user and super blocks */ +#define H5F_FLUSH_CLOSING (1U << 2) /* Closing the file */ +#define H5F_FLUSH_CLEAR_ONLY (1U << 3) /* Don't write, just clear dirty flags */ /* * Encode and decode macros for file meta-data. diff --git a/src/H5Gnode.c b/src/H5Gnode.c index f77b4c5..1a153d5 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -1059,7 +1059,7 @@ H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key/*in,out*/, sn->nsyms = 0; sn->cache_info.dirty = TRUE; if (H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn)<0 || - H5AC_flush(f, dxpl_id, H5AC_SNODE, addr, TRUE)<0 || + H5AC_flush(f, dxpl_id, H5AC_SNODE, addr, H5F_FLUSH_INVALIDATE)<0 || H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, addr, (hsize_t)H5G_node_size(f))<0) { sn = NULL; HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to free symbol table node"); @@ -892,7 +892,7 @@ H5HG_remove (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj) heap->dirty = FALSE; H5_CHECK_OVERFLOW(heap->size,size_t,hsize_t); H5MF_xfree(f, H5FD_MEM_GHEAP, dxpl_id, heap->addr, (hsize_t)heap->size); - H5AC_flush (f, dxpl_id, H5AC_GHEAP, heap->addr, TRUE); + H5AC_flush (f, dxpl_id, H5AC_GHEAP, heap->addr, H5F_FLUSH_INVALIDATE); heap = NULL; } else { /* |