[svn-r13217] Description:

Move fill value messages into new shared message method calling scheme.

    Only update an opened dataset's fill value property if it's different from
the default fill value settings.

Tested on:
    Linux/32 2.6 (chicago)
    Linux/64 2.6 (chicago2)
This commit is contained in:
Quincey Koziol 2007-01-29 13:19:05 -05:00
parent 55d4ec6ebf
commit 108114495f
12 changed files with 122 additions and 53 deletions

View File

@ -1879,7 +1879,7 @@ H5D_open_oid(H5D_t *dataset, hid_t dxpl_id)
} /* end switch */ /*lint !e788 All appropriate cases are covered */
} /* end if */
/* If size is 0, make it -1 for undefined. */
/* If "old" fill value size is 0 (undefined), map it to -1 */
if(fill_prop->size == 0)
fill_prop->size = (size_t)-1;
} /* end if */
@ -1889,11 +1889,13 @@ H5D_open_oid(H5D_t *dataset, hid_t dxpl_id)
|| (dataset->shared->layout.type == H5D_CHUNKED && fill_prop->alloc_time == H5D_ALLOC_TIME_INCR))
alloc_time_state = 1;
/* Set revised fill value properties */
/* Set revised fill value properties, if they are different from the defaults */
if(H5P_fill_value_cmp(&H5D_def_dset.dcpl_cache.fill, fill_prop, sizeof(H5O_fill_t))) {
if(H5P_set(plist, H5D_CRT_FILL_VALUE_NAME, fill_prop) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set fill value")
if(H5P_set(plist, H5D_CRT_ALLOC_TIME_STATE_NAME, &alloc_time_state) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set allocation time state")
} /* end if */
/* Get the external file list message, which might not exist. Space is
* also undefined when space allocate time is H5D_ALLOC_TIME_LATE. */

View File

@ -524,7 +524,10 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
/* Recompute shared message size (mesg_dst->native is really
* an H5O_shared_t)
*/
if(!H5O_NEW_SHARED(mesg_dst->type))
if(H5O_NEW_SHARED(mesg_dst->type))
mesg_dst->raw_size = H5O_ALIGN_OH(oh_dst,
H5O_msg_raw_size(oloc_dst->file, mesg_dst->type->id, mesg_dst->native));
else
mesg_dst->raw_size = H5O_ALIGN_OH(oh_dst,
H5O_msg_raw_size(oloc_dst->file, H5O_SHARED_ID, mesg_dst->native));
} /* end if */
@ -535,7 +538,6 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
/* Recompute native message size (msg_dest->native is no longer
* an H5O_shared_t)
*/
if(!H5O_NEW_SHARED(mesg_dst->type))
mesg_dst->raw_size = H5O_ALIGN_OH(oh_dst,
H5O_msg_raw_size(oloc_dst->file, mesg_dst->type->id, mesg_dst->native));
} /* end else */
@ -591,7 +593,6 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
*/
if(oh_dst->version > H5O_VERSION_1)
HDmemcpy(current_pos, H5O_HDR_MAGIC, H5O_SIZEOF_MAGIC);
current_pos += H5O_SIZEOF_HDR(oh_dst) - H5O_SIZEOF_CHKSUM_OH(oh_dst);
/* Copy each message that wasn't dirtied above */
@ -604,8 +605,8 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
while(deleted[mesgno + null_msgs]) {
++null_msgs;
HDassert(mesgno + null_msgs < oh_src->nmesgs);
}
}
} /* end while */
} /* end if */
/* Set up convenience variables */
mesg_src = &(oh_src->mesg[mesgno + null_msgs]);
@ -615,10 +616,10 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
/* Copy the message header plus the message's raw data. */
HDmemcpy(current_pos, mesg_src->raw - msghdr_size,
msghdr_size + mesg_src->raw_size);
}
} /* end if */
mesg_dst->raw = current_pos + msghdr_size;
current_pos += mesg_dst->raw_size + msghdr_size;
}
} /* end for */
/* Make sure we filled the chunk, except for room at the end for a checksum */
HDassert(current_pos + H5O_SIZEOF_CHKSUM_OH(oh_dst) == dst_oh_size + oh_dst->chunk[0].image);
@ -653,8 +654,8 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
while(deleted[mesgno + null_msgs]) {
++null_msgs;
HDassert(mesgno + null_msgs < oh_src->nmesgs);
}
}
} /* end while */
} /* end if */
/* Set up convenience variables */
mesg_src = &(oh_src->mesg[mesgno + null_msgs]);

View File

@ -121,20 +121,20 @@ const H5O_msg_class_t H5O_MSG_FILL_NEW[1] = {{
H5O_FILL_NEW_ID, /*message id number */
"fill_new", /*message name for debugging */
sizeof(H5O_fill_t), /*native message size */
H5O_fill_new_decode, /*decode message */
H5O_fill_new_encode, /*encode message */
H5O_fill_new_shared_decode, /*decode message */
H5O_fill_new_shared_encode, /*encode message */
H5O_fill_new_copy, /*copy the native value */
H5O_fill_new_size, /*raw message size */
H5O_fill_new_shared_size, /*raw message size */
H5O_fill_new_reset, /*free internal memory */
H5O_fill_new_free, /* free method */
NULL, /* file delete method */
NULL, /* link method */
H5O_fill_new_shared_delete, /* file delete method */
H5O_fill_new_shared_link, /* link method */
H5O_fill_new_get_share, /* get share method */
H5O_fill_new_set_share, /* set share method */
NULL, /*can share method */
H5O_fill_new_is_shared, /* is shared method */
NULL, /* pre copy native value to file */
NULL, /* copy native value to file */
H5O_fill_new_shared_copy_file, /* copy native value to file */
NULL, /* post copy native value to file */
NULL, /* get creation index */
NULL, /* set creation index */

View File

@ -1977,7 +1977,6 @@ H5O_new_mesg(H5F_t *f, H5O_t *oh, unsigned *mesg_flags, const H5O_msg_class_t *o
const void **new_mesg, hid_t dxpl_id, unsigned *oh_flags_ptr)
{
size_t size; /* Size of space allocated for object header */
htri_t is_shared; /* Is this a shared message? */
unsigned ret_value = UFAIL; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5O_new_mesg)
@ -1995,6 +1994,8 @@ H5O_new_mesg(H5F_t *f, H5O_t *oh, unsigned *mesg_flags, const H5O_msg_class_t *o
/* Check for shared message */
if((*mesg_flags & H5O_MSG_FLAG_SHARED) && !H5O_NEW_SHARED(orig_type)) {
htri_t is_shared; /* Is this a shared message? */
if((NULL == orig_type->is_shared) || (NULL == orig_type->get_share))
HGOTO_ERROR(H5E_OHDR, H5E_UNSUPPORTED, UFAIL, "message class is not sharable")
if((is_shared = (orig_type->is_shared)(orig_mesg)) == FALSE) {

View File

@ -160,7 +160,7 @@
/* Temporary macro to define which message classes are using the "new"
* shared message "interface" for their methods.
*/
#define H5O_NEW_SHARED(T) (T == H5O_MSG_PLINE)
#define H5O_NEW_SHARED(T) ((T) == H5O_MSG_PLINE || (T) == H5O_MSG_FILL_NEW || (T) == H5O_MSG_FILL)
/* The "message class" type */
@ -439,8 +439,9 @@ H5_DLL void * H5O_shared_decode_new(H5F_t *f, hid_t dxpl_id, const uint8_t *buf,
H5_DLL herr_t H5O_shared_encode_new(const H5F_t *f, uint8_t *buf/*out*/, const H5O_shared_t *sh_mesg);
H5_DLL size_t H5O_shared_size_new(const H5F_t *f, const H5O_shared_t *sh_mesg);
H5_DLL herr_t H5O_shared_delete_new(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *sh_mesg,
hbool_t adj_link);
H5_DLL herr_t H5O_shared_link_new(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *sh_mesg);
const H5O_msg_class_t *mesg_type, hbool_t adj_link);
H5_DLL herr_t H5O_shared_link_new(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *sh_mesg,
const H5O_msg_class_t *mesg_type);
H5_DLL herr_t H5O_shared_copy_file_new(H5F_t *file_src, H5F_t *file_dst, hid_t dxpl_id,
const H5O_msg_class_t *mesg_type, const void *_native_src, void *_native_dst,
H5O_copy_t *cpy_info, void *udata);

View File

@ -205,6 +205,69 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_shared_read() */
/*-------------------------------------------------------------------------
* Function: H5O_shared_link_adj_new
*
* Purpose: Changes the link count for the object referenced by a shared
* message.
*
* This function changes the object header link count and is
* only relevant for committed messages. Messages shared in
* the heap are re-shared each time they're written, so their
* reference count is stored in the file-wide shared message
* index and is changed in a different place in the code.
*
* Return: Success: New link count, or 1 for messages in heap
* Failure: Negative
*
* Programmer: Quincey Koziol
* koziol@ncsa.uiuc.edu
* Sep 26 2003
*
*-------------------------------------------------------------------------
*/
static int
H5O_shared_link_adj_new(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *shared,
const H5O_msg_class_t *type, int adjust)
{
int ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5O_shared_link_adj_new)
/* check args */
HDassert(f);
HDassert(shared);
/*
* The shared message is stored in some other object header.
* The other object header must be in the same file as the
* new object header. Adjust the reference count on that
* object header.
*/
if(shared->flags & H5O_COMMITTED_FLAG) {
if(shared->u.oloc.file->shared != f->shared)
HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "interfile hard links are not allowed")
if((ret_value = H5O_link(&(shared->u.oloc), adjust, dxpl_id)) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust shared object link count")
} /* end if */
else {
if(adjust < 0) {
if(H5SM_try_delete(f, dxpl_id, type->id, shared) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to delete message from SOHM table")
} /* end if */
/* Messages in the heap don't have file object ref counts; they
* return 1 as a dummy value.
*/
HDassert(shared->flags & H5O_SHARED_IN_HEAP_FLAG);
ret_value = 1;
} /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_shared_link_adj_new() */
/*-------------------------------------------------------------------------
* Function: H5O_shared_link_adj
@ -246,21 +309,19 @@ H5O_shared_link_adj(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *shared, int adj
* new object header. Adjust the reference count on that
* object header.
*/
if(shared->flags & H5O_COMMITTED_FLAG)
{
if(shared->flags & H5O_COMMITTED_FLAG) {
if(shared->u.oloc.file->shared != f->shared)
HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "interfile hard links are not allowed")
if((ret_value = H5O_link(&(shared->u.oloc), adjust, dxpl_id)) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust shared object link count")
}
else
{
} /* end if */
else {
/* Messages in the heap don't have file object ref counts; they
* return 1 as a dummy value.
*/
HDassert(shared->flags & H5O_SHARED_IN_HEAP_FLAG);
ret_value = 1;
}
} /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value)
@ -672,7 +733,8 @@ H5O_shared_size(const H5F_t *f, const void *_mesg)
*-------------------------------------------------------------------------
*/
herr_t
H5O_shared_delete_new(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *sh_mesg, hbool_t adj_link)
H5O_shared_delete_new(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *sh_mesg,
const H5O_msg_class_t *type, hbool_t adj_link)
{
herr_t ret_value = SUCCEED; /* Return value */
@ -693,7 +755,7 @@ H5O_shared_delete_new(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *sh_mesg, hboo
/* Decrement the reference count on the shared object, if requested */
if(adj_link)
if(H5O_shared_link_adj(f, dxpl_id, sh_mesg, -1) < 0)
if(H5O_shared_link_adj_new(f, dxpl_id, sh_mesg, type, -1) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust shared object link count")
done:
@ -760,7 +822,8 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
H5O_shared_link_new(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *sh_mesg)
H5O_shared_link_new(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *sh_mesg,
const H5O_msg_class_t *type)
{
herr_t ret_value = SUCCEED; /* Return value */
@ -771,7 +834,7 @@ H5O_shared_link_new(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *sh_mesg)
HDassert(sh_mesg);
/* Increment the reference count on the shared object */
if(H5O_shared_link_adj(f, dxpl_id, sh_mesg, 1) < 0)
if(H5O_shared_link_adj_new(f, dxpl_id, sh_mesg, type, 1) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust shared object link count")
done:
@ -877,7 +940,7 @@ done:
herr_t
H5O_shared_copy_file_new(H5F_t *file_src, H5F_t *file_dst, hid_t dxpl_id,
const H5O_msg_class_t *mesg_type, const void *_native_src, void *_native_dst,
H5O_copy_t *cpy_info, void *udata)
H5O_copy_t *cpy_info, void UNUSED *udata)
{
const H5O_shared_t *shared_src = (const H5O_shared_t *)_native_src; /* Alias to shared info in native source */
H5O_shared_t *shared_dst = (H5O_shared_t *)_native_dst; /* Alias to shared info in native destination message */

View File

@ -220,7 +220,7 @@ H5O_SHARED_DELETE(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link)
/* Check for shared message */
if(H5O_IS_SHARED(sh_mesg->flags)) {
/* Decrement the reference count on the shared message/object */
if(H5O_shared_delete_new(f, dxpl_id, sh_mesg, adj_link) < 0)
if(H5O_shared_delete_new(f, dxpl_id, sh_mesg, H5O_SHARED_TYPE, adj_link) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement ref count for shared message")
} /* end if */
#ifdef H5O_SHARED_DELETE_REAL
@ -272,7 +272,7 @@ H5O_SHARED_LINK(H5F_t *f, hid_t dxpl_id, const void *_mesg)
/* Check for shared message */
if(H5O_IS_SHARED(sh_mesg->flags)) {
/* Increment the reference count on the shared message/object */
if(H5O_shared_link_new(f, dxpl_id, sh_mesg) < 0)
if(H5O_shared_link_new(f, dxpl_id, sh_mesg, H5O_SHARED_TYPE) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTINC, FAIL, "unable to increment ref count for shared message")
} /* end if */
#ifdef H5O_SHARED_LINK_REAL

View File

@ -60,7 +60,7 @@
* library default; size=-1 means fill value is undefined. */
#define H5D_CRT_FILL_VALUE_SIZE sizeof(H5O_fill_t)
#define H5D_CRT_FILL_VALUE_DEF {{0, {{NULL, HADDR_UNDEF, FALSE}}}, NULL, 0, NULL, H5D_ALLOC_TIME_LATE, H5D_FILL_TIME_IFSET, FALSE}
#define H5D_CRT_FILL_VALUE_CMP H5P_dcrt_fill_value_cmp
#define H5D_CRT_FILL_VALUE_CMP H5P_fill_value_cmp
/* Definitions for space allocation time state */
#define H5D_CRT_ALLOC_TIME_STATE_SIZE sizeof(unsigned)
#define H5D_CRT_ALLOC_TIME_STATE_DEF 1
@ -97,7 +97,6 @@ static herr_t H5P_dcrt_copy(hid_t new_plist_t, hid_t old_plist_t, void *copy_dat
static herr_t H5P_dcrt_close(hid_t dxpl_id, void *close_data);
/* Property callbacks */
static int H5P_dcrt_fill_value_cmp(const void *value1, const void *value2, size_t size);
static int H5P_dcrt_ext_file_list_cmp(const void *value1, const void *value2, size_t size);
static int H5P_dcrt_data_pipeline_cmp(const void *value1, const void *value2, size_t size);
@ -307,7 +306,7 @@ done:
/*-------------------------------------------------------------------------
* Function: H5P_dcrt_fill_value_cmp
* Function: H5P_fill_value_cmp
*
* Purpose: Callback routine which is called whenever the fill value
* property in the dataset creation property list is compared.
@ -321,15 +320,15 @@ done:
*
*-------------------------------------------------------------------------
*/
static int
H5P_dcrt_fill_value_cmp(const void *_fill1, const void *_fill2, size_t UNUSED size)
int
H5P_fill_value_cmp(const void *_fill1, const void *_fill2, size_t UNUSED size)
{
const H5O_fill_t *fill1 = (const H5O_fill_t *)_fill1, /* Create local aliases for values */
*fill2 = (const H5O_fill_t *)_fill2;
int cmp_value; /* Value from comparison */
herr_t ret_value = 0; /* Return value */
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5P_dcrt_fill_value_cmp)
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5P_fill_value_cmp)
/* Sanity check */
HDassert(fill1);
@ -364,7 +363,7 @@ H5P_dcrt_fill_value_cmp(const void *_fill1, const void *_fill2, size_t UNUSED si
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P_dcrt_fill_value_cmp() */
} /* end H5P_fill_value_cmp() */
/*-------------------------------------------------------------------------

View File

@ -82,6 +82,8 @@ H5_DLL herr_t H5P_set_vlen_mem_manager(H5P_genplist_t *plist,
void *free_info);
H5_DLL herr_t H5P_is_fill_value_defined(const H5O_fill_t *fill,
H5D_fill_value_t *status);
H5_DLL int H5P_fill_value_cmp(const void *value1, const void *value2,
size_t size);
/* *SPECIAL* Don't make more of these! -QAK */
H5_DLL htri_t H5P_isa_class(hid_t plist_id, hid_t pclass_id);

View File

@ -1740,7 +1740,7 @@ H5SM_list_debug(H5F_t *f, hid_t dxpl_id, haddr_t list_addr,
FUNC_ENTER_NOAPI(H5SM_list_debug, FAIL)
HDassert(f);
HDassert(num_messages != HADDR_UNDEF);
HDassert(list_addr != HADDR_UNDEF);
HDassert(stream);
HDassert(indent >= 0);
HDassert(fwidth >= 0);

View File

@ -2963,8 +2963,8 @@ test_sohm_delete_revert(void)
ret = H5Pclose(fcpl_id);
CHECK_I(ret, "H5Pclose");
}
/*-------------------------------------------------------------------------
* Function: test_sohm_extlink_helper
*