mirror of
https://github.com/HDFGroup/hdf5.git
synced 2024-11-21 01:04:10 +08:00
[svn-r19292] Description:
Merge r19290 & r19291 from 1.8 branch to trunk: r19290: Correct another error in metadata accumulator dirty region calculations (this time with a corner case when freeing data in the file). r19291: Avoid getting object information for soft/external links if we aren't going to traverse across the link itself. 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/default API=1.8.x, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (amani) 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, w/threadsafe, in production mode Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode Mac OS X/32 10.6.4 (amazon) in debug mode Mac OS X/32 10.6.4 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode Mac OS X/32 10.6.4 (amazon) w/parallel, in debug mode
This commit is contained in:
parent
9fbdf8f07a
commit
0cd7123fb6
@ -766,50 +766,66 @@ H5F_accum_free(H5F_t *f, hid_t dxpl_id, H5FD_mem_t UNUSED type, haddr_t addr,
|
||||
/* Calculate the address of the tail to write */
|
||||
tail_addr = addr + size;
|
||||
|
||||
/* Check if there's dirty data after the block to free */
|
||||
if(H5F_addr_lt(tail_addr, dirty_end)) {
|
||||
/* Check if the dirty region falls entirely after block to free */
|
||||
if(tail_addr < dirty_start) {
|
||||
/* Write out the dirty region of the accumulator */
|
||||
/* Check if the block to free begins before dirty region */
|
||||
if(H5F_addr_lt(addr, dirty_start)) {
|
||||
/* Check if block to free is entirely before dirty region */
|
||||
if(H5F_addr_le(tail_addr, dirty_start)) {
|
||||
/* Write out the entire dirty region of the accumulator */
|
||||
if(H5FD_write(f->shared->lf, dxpl_id, H5FD_MEM_DEFAULT, dirty_start, f->shared->accum.dirty_len, f->shared->accum.buf + f->shared->accum.dirty_off) < 0)
|
||||
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed")
|
||||
} /* end if */
|
||||
/* Block to free overlaps with some/all of dirty region */
|
||||
else {
|
||||
size_t write_size;
|
||||
|
||||
write_size = (size_t)(dirty_end - tail_addr);
|
||||
|
||||
/* Check for unfreed dirty region to write */
|
||||
if(write_size > 0) {
|
||||
size_t dirty_delta;
|
||||
|
||||
dirty_delta = f->shared->accum.dirty_len - write_size;
|
||||
|
||||
/* Write out the unfreed dirty region of the accumulator */
|
||||
if(H5FD_write(f->shared->lf, dxpl_id, H5FD_MEM_DEFAULT, dirty_start + dirty_delta, write_size, f->shared->accum.buf + f->shared->accum.dirty_off + dirty_delta) < 0)
|
||||
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed")
|
||||
} /* end if */
|
||||
} /* end else */
|
||||
|
||||
/* Reset dirty flag */
|
||||
f->shared->accum.dirty = FALSE;
|
||||
} /* end if */
|
||||
/* Block to free begins at beginning of or in middle of dirty region */
|
||||
else {
|
||||
/* Check if block to free ends before end of dirty region */
|
||||
if(H5F_addr_lt(tail_addr, dirty_end)) {
|
||||
size_t write_size;
|
||||
|
||||
write_size = (size_t)(dirty_end - tail_addr);
|
||||
|
||||
/* Check for unfreed dirty region to write */
|
||||
if(write_size > 0) {
|
||||
size_t dirty_delta;
|
||||
|
||||
dirty_delta = f->shared->accum.dirty_len - write_size;
|
||||
|
||||
/* Write out the unfreed end of the dirty region of the accumulator */
|
||||
if(H5FD_write(f->shared->lf, dxpl_id, H5FD_MEM_DEFAULT, dirty_start + dirty_delta, write_size, f->shared->accum.buf + f->shared->accum.dirty_off + dirty_delta) < 0)
|
||||
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed")
|
||||
} /* end if */
|
||||
} /* end if */
|
||||
|
||||
/* Check for block to free beginning at same location as dirty region */
|
||||
if(H5F_addr_eq(addr, dirty_start)) {
|
||||
/* Reset dirty flag */
|
||||
f->shared->accum.dirty = FALSE;
|
||||
} /* end if */
|
||||
/* Dirty region overlaps block to free */
|
||||
/* Block to free eliminates end of dirty region */
|
||||
else {
|
||||
size_t tail_size;
|
||||
size_t write_size;
|
||||
|
||||
/* Calculate the size of the tail to write */
|
||||
H5_ASSIGN_OVERFLOW(tail_size, dirty_end - tail_addr, haddr_t, size_t);
|
||||
write_size = (size_t)(dirty_end - tail_addr);
|
||||
|
||||
/* Write out the dirty part of the accumulator after the block to free */
|
||||
if(H5FD_write(f->shared->lf, dxpl_id, H5FD_MEM_DEFAULT, tail_addr, write_size, f->shared->accum.buf + (tail_addr - f->shared->accum.loc)) < 0)
|
||||
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed")
|
||||
|
||||
/* Check if block to free falls within dirty region */
|
||||
if(addr == dirty_start)
|
||||
/* Reset dirty flag */
|
||||
f->shared->accum.dirty = FALSE;
|
||||
else
|
||||
/* Truncate dirty region */
|
||||
f->shared->accum.dirty_len = (size_t)(addr - dirty_start);
|
||||
} /* end else */
|
||||
} /* end if */
|
||||
else {
|
||||
/* Check if entire dirty region is in block to free */
|
||||
if(addr < dirty_start)
|
||||
/* Reset dirty flag */
|
||||
f->shared->accum.dirty = FALSE;
|
||||
/* Block to free truncates dirty region */
|
||||
else {
|
||||
/* Truncate dirty region */
|
||||
f->shared->accum.dirty_len = (size_t)(addr - dirty_start);
|
||||
f->shared->accum.dirty_len = (addr - dirty_start);
|
||||
} /* end else */
|
||||
} /* end else */
|
||||
|
||||
} /* end if */
|
||||
|
||||
/* Adjust the accumulator information */
|
||||
|
@ -416,7 +416,7 @@ main (int argc, const char *argv[])
|
||||
if(verbose)
|
||||
linkinfo.opt.msg_mode = 1;
|
||||
|
||||
li_ret = H5tools_get_link_info(fid_src, oname_src, &linkinfo);
|
||||
li_ret = H5tools_get_link_info(fid_src, oname_src, &linkinfo, 1);
|
||||
if (li_ret == 0) /* dangling link */
|
||||
{
|
||||
if(H5Lcopy(fid_src, oname_src,
|
||||
|
@ -1992,7 +1992,7 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter)
|
||||
|
||||
switch(linfo->type) {
|
||||
case H5L_TYPE_SOFT:
|
||||
ret = H5tools_get_link_info(iter->fid, name, &lnk_info);
|
||||
ret = H5tools_get_link_info(iter->fid, name, &lnk_info, follow_symlink_g);
|
||||
/* lnk_info.trg_path is malloced in H5tools_get_link_info()
|
||||
* so it will be freed via buf later */
|
||||
buf = lnk_info.trg_path;
|
||||
@ -2048,8 +2048,9 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter)
|
||||
{
|
||||
const char *filename;
|
||||
const char *path;
|
||||
hbool_t follow_link = follow_symlink_g || follow_elink_g;
|
||||
|
||||
ret = H5tools_get_link_info(iter->fid, name, &lnk_info);
|
||||
ret = H5tools_get_link_info(iter->fid, name, &lnk_info, follow_link);
|
||||
/* lnk_info.trg_path is malloced in H5tools_get_link_info()
|
||||
* so it will be freed via buf later */
|
||||
buf = lnk_info.trg_path;
|
||||
@ -2073,7 +2074,7 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter)
|
||||
|
||||
/* Recurse through the external link */
|
||||
/* keep the follow_elink_g for backward compatibility with -E */
|
||||
if(follow_symlink_g || follow_elink_g)
|
||||
if(follow_link)
|
||||
{
|
||||
hbool_t orig_grp_literal = grp_literal_g;
|
||||
HDfputc(' ', stdout);
|
||||
|
@ -951,7 +951,7 @@ hsize_t diff_compare(hid_t file1_id,
|
||||
if (obj1type == H5TRAV_TYPE_LINK)
|
||||
{
|
||||
/* get type of target object */
|
||||
l_ret = H5tools_get_link_info(file1_id, obj1_name, &linkinfo1);
|
||||
l_ret = H5tools_get_link_info(file1_id, obj1_name, &linkinfo1, TRUE);
|
||||
/* dangling link */
|
||||
if (l_ret == 0)
|
||||
{
|
||||
@ -984,7 +984,7 @@ hsize_t diff_compare(hid_t file1_id,
|
||||
if (obj2type == H5TRAV_TYPE_LINK)
|
||||
{
|
||||
/* get type target object */
|
||||
l_ret = H5tools_get_link_info(file2_id, obj2_name, &linkinfo2);
|
||||
l_ret = H5tools_get_link_info(file2_id, obj2_name, &linkinfo2, TRUE);
|
||||
/* dangling link */
|
||||
if (l_ret == 0)
|
||||
{
|
||||
@ -1021,7 +1021,7 @@ hsize_t diff_compare(hid_t file1_id,
|
||||
if (obj1type == H5TRAV_TYPE_UDLINK)
|
||||
{
|
||||
/* get type and name of target object */
|
||||
l_ret = H5tools_get_link_info(file1_id, obj1_name, &linkinfo1);
|
||||
l_ret = H5tools_get_link_info(file1_id, obj1_name, &linkinfo1, TRUE);
|
||||
/* dangling link */
|
||||
if (l_ret == 0)
|
||||
{
|
||||
@ -1055,7 +1055,7 @@ hsize_t diff_compare(hid_t file1_id,
|
||||
if (obj2type == H5TRAV_TYPE_UDLINK)
|
||||
{
|
||||
/* get type and name of target object */
|
||||
l_ret = H5tools_get_link_info(file2_id, obj2_name, &linkinfo2);
|
||||
l_ret = H5tools_get_link_info(file2_id, obj2_name, &linkinfo2, TRUE);
|
||||
/* dangling link */
|
||||
if (l_ret == 0)
|
||||
{
|
||||
@ -1310,7 +1310,7 @@ hsize_t diff(hid_t file1_id,
|
||||
case H5TRAV_TYPE_LINK:
|
||||
{
|
||||
/* get type and name of target object */
|
||||
ret = H5tools_get_link_info(file1_id, path1, &linkinfo1);
|
||||
ret = H5tools_get_link_info(file1_id, path1, &linkinfo1, TRUE);
|
||||
/* dangling link */
|
||||
if (ret == 0)
|
||||
{
|
||||
@ -1328,7 +1328,7 @@ hsize_t diff(hid_t file1_id,
|
||||
goto out;
|
||||
|
||||
/* get type and name of target object */
|
||||
ret = H5tools_get_link_info(file2_id, path2, &linkinfo2);
|
||||
ret = H5tools_get_link_info(file2_id, path2, &linkinfo2, TRUE);
|
||||
/* dangling link */
|
||||
if (ret == 0)
|
||||
{
|
||||
@ -1394,7 +1394,7 @@ hsize_t diff(hid_t file1_id,
|
||||
case H5TRAV_TYPE_UDLINK:
|
||||
{
|
||||
/* get type and name of target object */
|
||||
ret = H5tools_get_link_info(file1_id, path1, &linkinfo1);
|
||||
ret = H5tools_get_link_info(file1_id, path1, &linkinfo1, TRUE);
|
||||
/* dangling link */
|
||||
if (ret == 0)
|
||||
{
|
||||
@ -1412,7 +1412,7 @@ hsize_t diff(hid_t file1_id,
|
||||
goto out;
|
||||
|
||||
/* get type and name of target object */
|
||||
ret = H5tools_get_link_info(file2_id, path2, &linkinfo2);
|
||||
ret = H5tools_get_link_info(file2_id, path2, &linkinfo2, TRUE);
|
||||
/* dangling link */
|
||||
if (ret == 0)
|
||||
{
|
||||
|
@ -726,7 +726,8 @@ tmpfile(void)
|
||||
* Date: Feb 8, 2010
|
||||
*-------------------------------------------------------------------------*/
|
||||
int
|
||||
H5tools_get_link_info(hid_t file_id, const char * linkpath, h5tool_link_info_t *link_info)
|
||||
H5tools_get_link_info(hid_t file_id, const char * linkpath, h5tool_link_info_t *link_info,
|
||||
hbool_t get_obj_type)
|
||||
{
|
||||
htri_t l_ret;
|
||||
H5O_info_t trg_oinfo;
|
||||
@ -779,37 +780,42 @@ H5tools_get_link_info(hid_t file_id, const char * linkpath, h5tool_link_info_t *
|
||||
H5Pset_elink_fapl(lapl, fapl);
|
||||
} /* end if */
|
||||
|
||||
/*--------------------------------------------------------------
|
||||
* if link's target object exist, get type
|
||||
*/
|
||||
/* check if target object exist */
|
||||
l_ret = H5Oexists_by_name(file_id, linkpath, lapl);
|
||||
|
||||
/* detect dangling link */
|
||||
if(l_ret == FALSE) {
|
||||
ret = 0;
|
||||
goto out;
|
||||
/* Check for retrieving object info */
|
||||
if(get_obj_type) {
|
||||
/*--------------------------------------------------------------
|
||||
* if link's target object exist, get type
|
||||
*/
|
||||
/* check if target object exist */
|
||||
l_ret = H5Oexists_by_name(file_id, linkpath, lapl);
|
||||
|
||||
/* detect dangling link */
|
||||
if(l_ret == FALSE) {
|
||||
ret = 0;
|
||||
goto out;
|
||||
} /* end if */
|
||||
/* function failed */
|
||||
else if(l_ret < 0)
|
||||
goto out;
|
||||
|
||||
/* get target object info */
|
||||
if(H5Oget_info_by_name(file_id, linkpath, &trg_oinfo, lapl) < 0) {
|
||||
if(link_info->opt.msg_mode == 1)
|
||||
parallel_print("Warning: unable to get object information for <%s>\n", linkpath);
|
||||
goto out;
|
||||
} /* end if */
|
||||
|
||||
/* check unknown type */
|
||||
if(trg_oinfo.type < H5O_TYPE_GROUP || trg_oinfo.type >=H5O_TYPE_NTYPES) {
|
||||
if(link_info->opt.msg_mode == 1)
|
||||
parallel_print("Warning: target object of <%s> is unknown type\n", linkpath);
|
||||
goto out;
|
||||
} /* end if */
|
||||
|
||||
/* set target obj type to return */
|
||||
link_info->trg_type = trg_oinfo.type;
|
||||
} /* end if */
|
||||
/* function failed */
|
||||
else if(l_ret < 0)
|
||||
goto out;
|
||||
|
||||
/* get target object info */
|
||||
if(H5Oget_info_by_name(file_id, linkpath, &trg_oinfo, lapl) < 0) {
|
||||
if(link_info->opt.msg_mode == 1)
|
||||
parallel_print("Warning: unable to get object information for <%s>\n", linkpath);
|
||||
goto out;
|
||||
} /* end if */
|
||||
|
||||
/* check unknown type */
|
||||
if(trg_oinfo.type < H5O_TYPE_GROUP || trg_oinfo.type >=H5O_TYPE_NTYPES) {
|
||||
if(link_info->opt.msg_mode == 1)
|
||||
parallel_print("Warning: target object of <%s> is unknown type\n", linkpath);
|
||||
goto out;
|
||||
} /* end if */
|
||||
|
||||
/* set target obj type to return */
|
||||
link_info->trg_type = trg_oinfo.type;
|
||||
else
|
||||
link_info->trg_type = H5O_TYPE_UNKNOWN;
|
||||
|
||||
/* succeed */
|
||||
ret = 1;
|
||||
|
@ -156,7 +156,8 @@ typedef struct {
|
||||
|
||||
|
||||
/* Definitions of routines */
|
||||
H5TOOLS_DLL int H5tools_get_link_info(hid_t file_id, const char * linkpath, h5tool_link_info_t *link_info);
|
||||
H5TOOLS_DLL int H5tools_get_link_info(hid_t file_id, const char * linkpath,
|
||||
h5tool_link_info_t *link_info, hbool_t get_obj_type);
|
||||
H5TOOLS_DLL const char *h5tools_getprogname(void);
|
||||
H5TOOLS_DLL void h5tools_setprogname(const char*progname);
|
||||
H5TOOLS_DLL int h5tools_getstatus(void);
|
||||
|
Loading…
Reference in New Issue
Block a user