mirror of
https://github.com/HDFGroup/hdf5.git
synced 2024-11-27 02:10:55 +08:00
[svn-r25929] Description:
Clean up EOF code within library and add 'mem_type' parameter to 'get_eof' VFD callback, to avoid various ambiguous situations, particularly with the multi VFD. (Supports changes for 'avoid_truncate' feature also) Tested on: MacOSX/64 10.10.1 (amazon) w/serial & parallel h5committest forthcoming
This commit is contained in:
parent
662892e8b1
commit
b65eae7aee
@ -306,7 +306,7 @@ SUBROUTINE multi_file_test(cleanup, total_error)
|
||||
!
|
||||
CALL h5pcreate_f(H5P_FILE_ACCESS_F, fapl, error)
|
||||
CALL check("h5pcreate_f", error, total_error)
|
||||
CALL h5pset_fapl_multi_f(fapl, relax, error)
|
||||
CALL h5pset_fapl_multi_f(fapl, memb_map, memb_fapl, memb_name, memb_addr, relax, error)
|
||||
CALL check("h5pset_fapl_multi_f", error, total_error)
|
||||
CALL h5fopen_f (fix_filename, H5F_ACC_RDWR_F, file_id, error, access_prp = fapl)
|
||||
CALL check("h5fopen_f", error, total_error)
|
||||
|
11
src/H5F.c
11
src/H5F.c
@ -964,6 +964,8 @@ H5Fget_filesize(hid_t file_id, hsize_t *size)
|
||||
{
|
||||
H5F_t *file; /* File object for file ID */
|
||||
haddr_t eof; /* End of file address */
|
||||
haddr_t eoa; /* End of allocation address */
|
||||
haddr_t max_eof_eoa; /* Maximum of the EOA & EOF */
|
||||
haddr_t base_addr; /* Base address for the file */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
@ -975,12 +977,15 @@ H5Fget_filesize(hid_t file_id, hsize_t *size)
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID")
|
||||
|
||||
/* Go get the actual file size */
|
||||
if(HADDR_UNDEF == (eof = H5FD_get_eof(file->shared->lf)))
|
||||
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file size")
|
||||
eof = H5FD_get_eof(file->shared->lf, H5FD_MEM_DEFAULT);
|
||||
eoa = H5FD_get_eoa(file->shared->lf, H5FD_MEM_DEFAULT);
|
||||
max_eof_eoa = MAX(eof, eoa);
|
||||
if(HADDR_UNDEF == max_eof_eoa)
|
||||
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file get eof/eoa requests failed")
|
||||
base_addr = H5FD_get_base_addr(file->shared->lf);
|
||||
|
||||
if(size)
|
||||
*size = (hsize_t)(eof + base_addr); /* Convert relative base address for file to absolute address */
|
||||
*size = (hsize_t)(max_eof_eoa + base_addr); /* Convert relative base address for file to absolute address */
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_API(ret_value)
|
||||
|
@ -1521,19 +1521,19 @@ done:
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
haddr_t
|
||||
H5FDget_eof(H5FD_t *file)
|
||||
H5FDget_eof(H5FD_t *file, H5FD_mem_t type)
|
||||
{
|
||||
haddr_t ret_value;
|
||||
|
||||
FUNC_ENTER_API(HADDR_UNDEF)
|
||||
H5TRACE1("a", "*x", file);
|
||||
H5TRACE2("a", "*xMt", file, type);
|
||||
|
||||
/* Check arguments */
|
||||
if(!file || !file->cls)
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "invalid file pointer")
|
||||
|
||||
/* The real work */
|
||||
if(HADDR_UNDEF == (ret_value = H5FD_get_eof(file)))
|
||||
if(HADDR_UNDEF == (ret_value = H5FD_get_eof(file, type)))
|
||||
HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "file get eof request failed")
|
||||
|
||||
/* (Note compensating for base address subtraction in internal routine) */
|
||||
|
@ -138,7 +138,7 @@ static int H5FD_core_cmp(const H5FD_t *_f1, const H5FD_t *_f2);
|
||||
static herr_t H5FD_core_query(const H5FD_t *_f1, unsigned long *flags);
|
||||
static haddr_t H5FD_core_get_eoa(const H5FD_t *_file, H5FD_mem_t type);
|
||||
static herr_t H5FD_core_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr);
|
||||
static haddr_t H5FD_core_get_eof(const H5FD_t *_file);
|
||||
static haddr_t H5FD_core_get_eof(const H5FD_t *_file, H5FD_mem_t type);
|
||||
static herr_t H5FD_core_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle);
|
||||
static herr_t H5FD_core_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr,
|
||||
size_t size, void *buf);
|
||||
@ -1126,13 +1126,13 @@ done:
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static haddr_t
|
||||
H5FD_core_get_eof(const H5FD_t *_file)
|
||||
H5FD_core_get_eof(const H5FD_t *_file, H5FD_mem_t UNUSED type)
|
||||
{
|
||||
const H5FD_core_t *file = (const H5FD_core_t*)_file;
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT_NOERR
|
||||
|
||||
FUNC_LEAVE_NOAPI(MAX(file->eof, file->eoa))
|
||||
FUNC_LEAVE_NOAPI(file->eof)
|
||||
}
|
||||
|
||||
|
||||
|
@ -137,7 +137,7 @@ static int H5FD_direct_cmp(const H5FD_t *_f1, const H5FD_t *_f2);
|
||||
static herr_t H5FD_direct_query(const H5FD_t *_f1, unsigned long *flags);
|
||||
static haddr_t H5FD_direct_get_eoa(const H5FD_t *_file, H5FD_mem_t type);
|
||||
static herr_t H5FD_direct_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr);
|
||||
static haddr_t H5FD_direct_get_eof(const H5FD_t *_file);
|
||||
static haddr_t H5FD_direct_get_eof(const H5FD_t *_file, H5FD_mem_t type);
|
||||
static herr_t H5FD_direct_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle);
|
||||
static herr_t H5FD_direct_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr,
|
||||
size_t size, void *buf);
|
||||
@ -810,13 +810,13 @@ H5FD_direct_set_eoa(H5FD_t *_file, H5FD_mem_t UNUSED type, haddr_t addr)
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static haddr_t
|
||||
H5FD_direct_get_eof(const H5FD_t *_file)
|
||||
H5FD_direct_get_eof(const H5FD_t *_file, H5FD_mem_t UNUSED type)
|
||||
{
|
||||
const H5FD_direct_t *file = (const H5FD_direct_t*)_file;
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT
|
||||
|
||||
FUNC_LEAVE_NOAPI(MAX(file->eof, file->eoa))
|
||||
FUNC_LEAVE_NOAPI(file->eof)
|
||||
}
|
||||
|
||||
|
||||
|
@ -99,7 +99,7 @@ static int H5FD_family_cmp(const H5FD_t *_f1, const H5FD_t *_f2);
|
||||
static herr_t H5FD_family_query(const H5FD_t *_f1, unsigned long *flags);
|
||||
static haddr_t H5FD_family_get_eoa(const H5FD_t *_file, H5FD_mem_t type);
|
||||
static herr_t H5FD_family_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t eoa);
|
||||
static haddr_t H5FD_family_get_eof(const H5FD_t *_file);
|
||||
static haddr_t H5FD_family_get_eof(const H5FD_t *_file, H5FD_mem_t type);
|
||||
static herr_t H5FD_family_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle);
|
||||
static herr_t H5FD_family_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr,
|
||||
size_t size, void *_buf/*out*/);
|
||||
@ -757,7 +757,7 @@ H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id,
|
||||
* smaller than the size specified through H5Pset_fapl_family(). Update the actual
|
||||
* member size.
|
||||
*/
|
||||
if ((eof=H5FDget_eof(file->memb[0]))) file->memb_size = eof;
|
||||
if ((eof=H5FDget_eof(file->memb[0], H5FD_MEM_DEFAULT))) file->memb_size = eof;
|
||||
|
||||
ret_value=(H5FD_t *)file;
|
||||
|
||||
@ -1047,7 +1047,7 @@ done:
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static haddr_t
|
||||
H5FD_family_get_eof(const H5FD_t *_file)
|
||||
H5FD_family_get_eof(const H5FD_t *_file, H5FD_mem_t type)
|
||||
{
|
||||
const H5FD_family_t *file = (const H5FD_family_t*)_file;
|
||||
haddr_t eof=0;
|
||||
@ -1063,7 +1063,7 @@ H5FD_family_get_eof(const H5FD_t *_file)
|
||||
*/
|
||||
HDassert(file->nmembs > 0);
|
||||
for(i = (int)file->nmembs - 1; i >= 0; --i) {
|
||||
if((eof = H5FD_get_eof(file->memb[i])) != 0)
|
||||
if((eof = H5FD_get_eof(file->memb[i], type)) != 0)
|
||||
break;
|
||||
if(0 == i)
|
||||
break;
|
||||
@ -1079,7 +1079,7 @@ H5FD_family_get_eof(const H5FD_t *_file)
|
||||
eof += ((unsigned)i)*file->memb_size;
|
||||
|
||||
/* Set return value */
|
||||
ret_value = MAX(eof, file->eoa);
|
||||
ret_value = eof;
|
||||
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ H5FD_int_init_interface(void)
|
||||
herr_t
|
||||
H5FD_locate_signature(H5FD_t *file, const H5P_genplist_t *dxpl, haddr_t *sig_addr)
|
||||
{
|
||||
haddr_t addr, eoa;
|
||||
haddr_t addr, eoa, eof;
|
||||
uint8_t buf[H5F_SIGNATURE_LEN];
|
||||
unsigned n, maxpow;
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
@ -128,7 +128,10 @@ H5FD_locate_signature(H5FD_t *file, const H5P_genplist_t *dxpl, haddr_t *sig_add
|
||||
FUNC_ENTER_NOAPI_NOINIT
|
||||
|
||||
/* Find the least N such that 2^N is larger than the file size */
|
||||
if(HADDR_UNDEF == (addr = H5FD_get_eof(file)) || HADDR_UNDEF == (eoa = H5FD_get_eoa(file, H5FD_MEM_SUPER)))
|
||||
eof = H5FD_get_eof(file, H5FD_MEM_SUPER);
|
||||
eoa = H5FD_get_eoa(file, H5FD_MEM_SUPER);
|
||||
addr = MAX(eof, eoa);
|
||||
if(HADDR_UNDEF == addr)
|
||||
HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to obtain EOF/EOA value")
|
||||
for(maxpow = 0; addr; maxpow++)
|
||||
addr >>= 1;
|
||||
@ -348,7 +351,7 @@ done:
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
haddr_t
|
||||
H5FD_get_eof(const H5FD_t *file)
|
||||
H5FD_get_eof(const H5FD_t *file, H5FD_mem_t type)
|
||||
{
|
||||
haddr_t ret_value;
|
||||
|
||||
@ -358,7 +361,7 @@ H5FD_get_eof(const H5FD_t *file)
|
||||
|
||||
/* Dispatch to driver */
|
||||
if(file->cls->get_eof) {
|
||||
if(HADDR_UNDEF == (ret_value = (file->cls->get_eof)(file)))
|
||||
if(HADDR_UNDEF == (ret_value = (file->cls->get_eof)(file, type)))
|
||||
HGOTO_ERROR(H5E_VFL, H5E_CANTGET, HADDR_UNDEF, "driver get_eof request failed")
|
||||
} /* end if */
|
||||
else
|
||||
|
@ -177,7 +177,7 @@ static herr_t H5FD_log_query(const H5FD_t *_f1, unsigned long *flags);
|
||||
static haddr_t H5FD_log_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size);
|
||||
static haddr_t H5FD_log_get_eoa(const H5FD_t *_file, H5FD_mem_t type);
|
||||
static herr_t H5FD_log_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr);
|
||||
static haddr_t H5FD_log_get_eof(const H5FD_t *_file);
|
||||
static haddr_t H5FD_log_get_eof(const H5FD_t *_file, H5FD_mem_t type);
|
||||
static herr_t H5FD_log_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle);
|
||||
static herr_t H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr,
|
||||
size_t size, void *buf);
|
||||
@ -1061,13 +1061,13 @@ H5FD_log_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr)
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static haddr_t
|
||||
H5FD_log_get_eof(const H5FD_t *_file)
|
||||
H5FD_log_get_eof(const H5FD_t *_file, H5FD_mem_t UNUSED type)
|
||||
{
|
||||
const H5FD_log_t *file = (const H5FD_log_t *)_file;
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT_NOERR
|
||||
|
||||
FUNC_LEAVE_NOAPI(MAX(file->eof, file->eoa))
|
||||
FUNC_LEAVE_NOAPI(file->eof)
|
||||
} /* end H5FD_log_get_eof() */
|
||||
|
||||
|
||||
|
@ -69,6 +69,7 @@ typedef struct H5FD_mpio_t {
|
||||
haddr_t eof; /*end-of-file marker */
|
||||
haddr_t eoa; /*end-of-address marker */
|
||||
haddr_t last_eoa; /* Last known end-of-address marker */
|
||||
haddr_t local_eof; /* Local end-of-file address for each process */
|
||||
} H5FD_mpio_t;
|
||||
|
||||
/* Private Prototypes */
|
||||
@ -84,7 +85,7 @@ static herr_t H5FD_mpio_close(H5FD_t *_file);
|
||||
static herr_t H5FD_mpio_query(const H5FD_t *_f1, unsigned long *flags);
|
||||
static haddr_t H5FD_mpio_get_eoa(const H5FD_t *_file, H5FD_mem_t type);
|
||||
static herr_t H5FD_mpio_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr);
|
||||
static haddr_t H5FD_mpio_get_eof(const H5FD_t *_file);
|
||||
static haddr_t H5FD_mpio_get_eof(const H5FD_t *_file, H5FD_mem_t type);
|
||||
static herr_t H5FD_mpio_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle);
|
||||
static herr_t H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr,
|
||||
size_t size, void *buf);
|
||||
@ -1107,6 +1108,7 @@ H5FD_mpio_open(const char *name, unsigned flags, hid_t fapl_id,
|
||||
|
||||
/* Set the size of the file (from library's perspective) */
|
||||
file->eof = H5FD_mpi_MPIOff_to_haddr(size);
|
||||
file->local_eof = file->eof;
|
||||
|
||||
/* Set return value */
|
||||
ret_value=(H5FD_t*)file;
|
||||
@ -1331,7 +1333,7 @@ H5FD_mpio_set_eoa(H5FD_t *_file, H5FD_mem_t UNUSED type, haddr_t addr)
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static haddr_t
|
||||
H5FD_mpio_get_eof(const H5FD_t *_file)
|
||||
H5FD_mpio_get_eof(const H5FD_t *_file, H5FD_mem_t UNUSED type)
|
||||
{
|
||||
const H5FD_mpio_t *file = (const H5FD_mpio_t*)_file;
|
||||
|
||||
@ -1906,9 +1908,17 @@ H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr,
|
||||
if(bytes_written != io_size)
|
||||
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed")
|
||||
|
||||
/* Forget the EOF value (see H5FD_mpio_get_eof()) --rpm 1999-08-06 */
|
||||
/* Each process will keep track of its perceived EOF value locally, and
|
||||
* ultimately we will reduce this value to the maximum amongst all
|
||||
* processes, but until then keep the actual eof at HADDR_UNDEF just in
|
||||
* case something bad happens before that point. (rather have a value
|
||||
* we know is wrong sitting around rather than one that could only
|
||||
* potentially be wrong.) */
|
||||
file->eof = HADDR_UNDEF;
|
||||
|
||||
if(bytes_written && ((bytes_written + addr) > file->local_eof))
|
||||
file->local_eof = addr + bytes_written;
|
||||
|
||||
done:
|
||||
#ifdef H5FDmpio_DEBUG
|
||||
if(H5FD_mpio_Debug[(int)'t'])
|
||||
|
@ -43,10 +43,6 @@
|
||||
*/
|
||||
#define H5FD_MULTI_DEBUG
|
||||
|
||||
/* Our version of MAX */
|
||||
#undef MAX
|
||||
#define MAX(X,Y) ((X)>(Y)?(X):(Y))
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
@ -135,7 +131,7 @@ static herr_t H5FD_multi_query(const H5FD_t *_f1, unsigned long *flags);
|
||||
static herr_t H5FD_multi_get_type_map(const H5FD_t *file, H5FD_mem_t *type_map);
|
||||
static haddr_t H5FD_multi_get_eoa(const H5FD_t *_file, H5FD_mem_t type);
|
||||
static herr_t H5FD_multi_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t eoa);
|
||||
static haddr_t H5FD_multi_get_eof(const H5FD_t *_file);
|
||||
static haddr_t H5FD_multi_get_eof(const H5FD_t *_file, H5FD_mem_t type);
|
||||
static herr_t H5FD_multi_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle);
|
||||
static haddr_t H5FD_multi_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size);
|
||||
static herr_t H5FD_multi_free(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr,
|
||||
@ -1430,54 +1426,70 @@ H5FD_multi_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t eoa)
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static haddr_t
|
||||
H5FD_multi_get_eof(const H5FD_t *_file)
|
||||
H5FD_multi_get_eof(const H5FD_t *_file, H5FD_mem_t type)
|
||||
{
|
||||
const H5FD_multi_t *file = (const H5FD_multi_t*)_file;
|
||||
haddr_t eof=0, tmp_eof;
|
||||
haddr_t eoa=0, tmp_eoa;
|
||||
haddr_t eof = 0;
|
||||
static const char *func="H5FD_multi_get_eof"; /* Function Name for error reporting */
|
||||
|
||||
/* Clear the error stack */
|
||||
H5Eclear2(H5E_DEFAULT);
|
||||
|
||||
UNIQUE_MEMBERS(file->fa.memb_map, mt) {
|
||||
if (file->memb[mt]) {
|
||||
if(H5FD_MEM_DEFAULT == type) {
|
||||
UNIQUE_MEMBERS(file->fa.memb_map, mt) {
|
||||
haddr_t tmp_eof;
|
||||
|
||||
if(file->memb[mt]) {
|
||||
/* Retrieve EOF */
|
||||
H5E_BEGIN_TRY {
|
||||
tmp_eof = H5FDget_eof(file->memb[mt], type);
|
||||
} H5E_END_TRY;
|
||||
|
||||
if(HADDR_UNDEF == tmp_eof)
|
||||
H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file has unknown eof", HADDR_UNDEF)
|
||||
if(tmp_eof > 0)
|
||||
tmp_eof += file->fa.memb_addr[mt];
|
||||
} else if(file->fa.relax) {
|
||||
/*
|
||||
* The member is not open yet (maybe it doesn't exist). Make the
|
||||
* best guess about the end-of-file.
|
||||
*/
|
||||
tmp_eof = file->memb_next[mt];
|
||||
assert(HADDR_UNDEF != tmp_eof);
|
||||
} else {
|
||||
H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "bad eof", HADDR_UNDEF)
|
||||
}
|
||||
if(tmp_eof > eof)
|
||||
eof = tmp_eof;
|
||||
} END_MEMBERS;
|
||||
} else {
|
||||
H5FD_mem_t mmt = file->fa.memb_map[type];
|
||||
|
||||
if(H5FD_MEM_DEFAULT == mmt)
|
||||
mmt = type;
|
||||
|
||||
if(file->memb[mmt]) {
|
||||
/* Retrieve EOF */
|
||||
H5E_BEGIN_TRY {
|
||||
tmp_eof = H5FDget_eof(file->memb[mt]);
|
||||
} H5E_END_TRY;
|
||||
H5E_BEGIN_TRY {
|
||||
eof = H5FDget_eof(file->memb[mmt], mmt);
|
||||
} H5E_END_TRY;
|
||||
|
||||
if (HADDR_UNDEF==tmp_eof)
|
||||
if(HADDR_UNDEF == eof)
|
||||
H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file has unknown eof", HADDR_UNDEF)
|
||||
if (tmp_eof>0) tmp_eof += file->fa.memb_addr[mt];
|
||||
|
||||
/* Retrieve EOA */
|
||||
H5E_BEGIN_TRY {
|
||||
tmp_eoa = H5FDget_eoa(file->memb[mt], mt);
|
||||
} H5E_END_TRY;
|
||||
|
||||
if (HADDR_UNDEF==tmp_eoa)
|
||||
H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file has unknown eoa", HADDR_UNDEF)
|
||||
if (tmp_eoa>0) tmp_eoa += file->fa.memb_addr[mt];
|
||||
} else if (file->fa.relax) {
|
||||
if(eof > 0)
|
||||
eof += file->fa.memb_addr[mmt];
|
||||
} else if(file->fa.relax) {
|
||||
/*
|
||||
* The member is not open yet (maybe it doesn't exist). Make the
|
||||
* best guess about the end-of-file.
|
||||
*/
|
||||
tmp_eof = file->memb_next[mt];
|
||||
assert(HADDR_UNDEF!=tmp_eof);
|
||||
|
||||
tmp_eoa = file->memb_next[mt];
|
||||
assert(HADDR_UNDEF!=tmp_eoa);
|
||||
} else {
|
||||
eof = file->memb_next[mmt];
|
||||
assert(HADDR_UNDEF != eof);
|
||||
} else {
|
||||
H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "bad eof", HADDR_UNDEF)
|
||||
}
|
||||
|
||||
if (tmp_eof>eof) eof = tmp_eof;
|
||||
if (tmp_eoa>eoa) eoa = tmp_eoa;
|
||||
} END_MEMBERS;
|
||||
|
||||
return MAX(eoa, eof);
|
||||
}
|
||||
}
|
||||
return eof;
|
||||
}
|
||||
|
||||
|
||||
|
@ -130,7 +130,7 @@ H5_DLL htri_t H5FD_try_extend(H5FD_t *file, H5FD_mem_t type, struct H5F_t *f,
|
||||
haddr_t blk_end, hsize_t extra_requested);
|
||||
H5_DLL haddr_t H5FD_get_eoa(const H5FD_t *file, H5FD_mem_t type);
|
||||
H5_DLL herr_t H5FD_set_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t addr);
|
||||
H5_DLL haddr_t H5FD_get_eof(const H5FD_t *file);
|
||||
H5_DLL haddr_t H5FD_get_eof(const H5FD_t *file, H5FD_mem_t type);
|
||||
H5_DLL haddr_t H5FD_get_maxaddr(const H5FD_t *file);
|
||||
H5_DLL herr_t H5FD_get_feature_flags(const H5FD_t *file, unsigned long *feature_flags);
|
||||
H5_DLL herr_t H5FD_get_fs_type_map(const H5FD_t *file, H5FD_mem_t *type_map);
|
||||
|
@ -267,7 +267,7 @@ typedef struct H5FD_class_t {
|
||||
haddr_t addr, hsize_t size);
|
||||
haddr_t (*get_eoa)(const H5FD_t *file, H5FD_mem_t type);
|
||||
herr_t (*set_eoa)(H5FD_t *file, H5FD_mem_t type, haddr_t addr);
|
||||
haddr_t (*get_eof)(const H5FD_t *file);
|
||||
haddr_t (*get_eof)(const H5FD_t *file, H5FD_mem_t type);
|
||||
herr_t (*get_handle)(H5FD_t *file, hid_t fapl, void**file_handle);
|
||||
herr_t (*read)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl,
|
||||
haddr_t addr, size_t size, void *buffer);
|
||||
@ -348,7 +348,7 @@ H5_DLL herr_t H5FDfree(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id,
|
||||
haddr_t addr, hsize_t size);
|
||||
H5_DLL haddr_t H5FDget_eoa(H5FD_t *file, H5FD_mem_t type);
|
||||
H5_DLL herr_t H5FDset_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t eoa);
|
||||
H5_DLL haddr_t H5FDget_eof(H5FD_t *file);
|
||||
H5_DLL haddr_t H5FDget_eof(H5FD_t *file, H5FD_mem_t type);
|
||||
H5_DLL herr_t H5FDget_vfd_handle(H5FD_t *file, hid_t fapl, void**file_handle);
|
||||
H5_DLL herr_t H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id,
|
||||
haddr_t addr, size_t size, void *buf/*out*/);
|
||||
|
@ -135,7 +135,7 @@ static int H5FD_sec2_cmp(const H5FD_t *_f1, const H5FD_t *_f2);
|
||||
static herr_t H5FD_sec2_query(const H5FD_t *_f1, unsigned long *flags);
|
||||
static haddr_t H5FD_sec2_get_eoa(const H5FD_t *_file, H5FD_mem_t type);
|
||||
static herr_t H5FD_sec2_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr);
|
||||
static haddr_t H5FD_sec2_get_eof(const H5FD_t *_file);
|
||||
static haddr_t H5FD_sec2_get_eof(const H5FD_t *_file, H5FD_mem_t type);
|
||||
static herr_t H5FD_sec2_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle);
|
||||
static herr_t H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr,
|
||||
size_t size, void *buf);
|
||||
@ -621,13 +621,13 @@ H5FD_sec2_set_eoa(H5FD_t *_file, H5FD_mem_t UNUSED type, haddr_t addr)
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static haddr_t
|
||||
H5FD_sec2_get_eof(const H5FD_t *_file)
|
||||
H5FD_sec2_get_eof(const H5FD_t *_file, H5FD_mem_t UNUSED type)
|
||||
{
|
||||
const H5FD_sec2_t *file = (const H5FD_sec2_t *)_file;
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT_NOERR
|
||||
|
||||
FUNC_LEAVE_NOAPI(MAX(file->eof, file->eoa))
|
||||
FUNC_LEAVE_NOAPI(file->eof)
|
||||
} /* end H5FD_sec2_get_eof() */
|
||||
|
||||
|
||||
|
@ -185,7 +185,7 @@ static herr_t H5FD_stdio_query(const H5FD_t *_f1, unsigned long *flags);
|
||||
static haddr_t H5FD_stdio_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size);
|
||||
static haddr_t H5FD_stdio_get_eoa(const H5FD_t *_file, H5FD_mem_t type);
|
||||
static herr_t H5FD_stdio_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr);
|
||||
static haddr_t H5FD_stdio_get_eof(const H5FD_t *_file);
|
||||
static haddr_t H5FD_stdio_get_eof(const H5FD_t *_file, H5FD_mem_t type);
|
||||
static herr_t H5FD_stdio_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle);
|
||||
static herr_t H5FD_stdio_read(H5FD_t *lf, H5FD_mem_t type, hid_t fapl_id, haddr_t addr,
|
||||
size_t size, void *buf);
|
||||
@ -719,14 +719,14 @@ H5FD_stdio_set_eoa(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, haddr_t addr)
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static haddr_t
|
||||
H5FD_stdio_get_eof(const H5FD_t *_file)
|
||||
H5FD_stdio_get_eof(const H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type)
|
||||
{
|
||||
const H5FD_stdio_t *file = (const H5FD_stdio_t *)_file;
|
||||
|
||||
/* Clear the error stack */
|
||||
H5Eclear2(H5E_DEFAULT);
|
||||
|
||||
return MAX(file->eof, file->eoa);
|
||||
return(file->eof);
|
||||
} /* end H5FD_stdio_get_eof() */
|
||||
|
||||
|
||||
|
@ -1066,7 +1066,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id,
|
||||
* Read or write the file superblock, depending on whether the file is
|
||||
* empty or not.
|
||||
*/
|
||||
if(0 == H5FD_get_eof(lf) && (flags & H5F_ACC_RDWR)) {
|
||||
if(0 == (MAX(H5FD_get_eof(lf, H5FD_MEM_SUPER), H5FD_get_eoa(lf, H5FD_MEM_SUPER))) && (flags & H5F_ACC_RDWR)) {
|
||||
/*
|
||||
* We've just opened a fresh new file (or truncated one). We need
|
||||
* to create & write the superblock.
|
||||
|
@ -120,7 +120,7 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata)
|
||||
H5P_genplist_t *c_plist; /* File creation property list */
|
||||
H5F_file_t *shared; /* shared part of `file' */
|
||||
H5FD_t *lf; /* file driver part of `shared' */
|
||||
haddr_t stored_eoa; /*relative end-of-addr in file */
|
||||
haddr_t stored_eof; /* stored end-of-file address in file */
|
||||
haddr_t eof; /* end of file address */
|
||||
uint8_t sizeof_addr; /* Size of offsets in the file (in bytes) */
|
||||
uint8_t sizeof_size; /* Size of lengths in the file (in bytes) */
|
||||
@ -288,7 +288,7 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata)
|
||||
/* Remainder of "variable-sized" portion of superblock */
|
||||
H5F_addr_decode(f, (const uint8_t **)&p, &sblock->base_addr/*out*/);
|
||||
H5F_addr_decode(f, (const uint8_t **)&p, &sblock->ext_addr/*out*/);
|
||||
H5F_addr_decode(f, (const uint8_t **)&p, &stored_eoa/*out*/);
|
||||
H5F_addr_decode(f, (const uint8_t **)&p, &stored_eof/*out*/);
|
||||
H5F_addr_decode(f, (const uint8_t **)&p, &sblock->driver_addr/*out*/);
|
||||
|
||||
/* Allocate space for the root group symbol table entry */
|
||||
@ -310,10 +310,10 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata)
|
||||
if(!H5F_addr_eq(base_addr, sblock->base_addr)) {
|
||||
/* Check if the superblock moved earlier in the file */
|
||||
if(H5F_addr_lt(base_addr, sblock->base_addr))
|
||||
stored_eoa -= (sblock->base_addr - base_addr);
|
||||
stored_eof -= (sblock->base_addr - base_addr);
|
||||
else
|
||||
/* The superblock moved later in the file */
|
||||
stored_eoa += (base_addr - sblock->base_addr);
|
||||
stored_eof += (base_addr - sblock->base_addr);
|
||||
|
||||
/* Adjust base address for offsets of the HDF5 data in the file */
|
||||
sblock->base_addr = base_addr;
|
||||
@ -420,7 +420,7 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata)
|
||||
/* Base, superblock extension, end of file & root group object header addresses */
|
||||
H5F_addr_decode(f, (const uint8_t **)&p, &sblock->base_addr/*out*/);
|
||||
H5F_addr_decode(f, (const uint8_t **)&p, &sblock->ext_addr/*out*/);
|
||||
H5F_addr_decode(f, (const uint8_t **)&p, &stored_eoa/*out*/);
|
||||
H5F_addr_decode(f, (const uint8_t **)&p, &stored_eof/*out*/);
|
||||
H5F_addr_decode(f, (const uint8_t **)&p, &sblock->root_addr/*out*/);
|
||||
|
||||
/* Compute checksum for superblock */
|
||||
@ -440,10 +440,10 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata)
|
||||
if(!H5F_addr_eq(base_addr, sblock->base_addr)) {
|
||||
/* Check if the superblock moved earlier in the file */
|
||||
if(H5F_addr_lt(base_addr, sblock->base_addr))
|
||||
stored_eoa -= (sblock->base_addr - base_addr);
|
||||
stored_eof -= (sblock->base_addr - base_addr);
|
||||
else
|
||||
/* The superblock moved later in the file */
|
||||
stored_eoa += (base_addr - sblock->base_addr);
|
||||
stored_eof += (base_addr - sblock->base_addr);
|
||||
|
||||
/* Adjust base address for offsets of the HDF5 data in the file */
|
||||
sblock->base_addr = base_addr;
|
||||
@ -475,21 +475,21 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata)
|
||||
* possible is if the first file of a family of files was opened
|
||||
* individually.
|
||||
*/
|
||||
if(HADDR_UNDEF == (eof = H5FD_get_eof(lf)))
|
||||
if(HADDR_UNDEF == (eof = H5FD_get_eof(lf, H5FD_MEM_DEFAULT)))
|
||||
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "unable to determine file size")
|
||||
|
||||
/* (Account for the stored EOA being absolute offset -QAK) */
|
||||
if((eof + sblock->base_addr) < stored_eoa)
|
||||
/* (Account for the stored EOF being absolute offset -QAK) */
|
||||
if((eof + sblock->base_addr) < stored_eof)
|
||||
HGOTO_ERROR(H5E_FILE, H5E_TRUNCATED, NULL,
|
||||
"truncated file: eof = %llu, sblock->base_addr = %llu, stored_eoa = %llu",
|
||||
(unsigned long long)eof, (unsigned long long)sblock->base_addr, (unsigned long long)stored_eoa)
|
||||
"truncated file: eof = %llu, sblock->base_addr = %llu, stored_eof = %llu",
|
||||
(unsigned long long)eof, (unsigned long long)sblock->base_addr, (unsigned long long)stored_eof)
|
||||
|
||||
/*
|
||||
* Tell the file driver how much address space has already been
|
||||
* allocated so that it knows how to allocate additional memory.
|
||||
*/
|
||||
/* (Account for the stored EOA being absolute offset -NAF) */
|
||||
if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, stored_eoa - sblock->base_addr) < 0)
|
||||
if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, stored_eof - sblock->base_addr) < 0)
|
||||
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to set end-of-address marker for file")
|
||||
|
||||
/* Read the file's superblock extension, if there is one. */
|
||||
@ -508,7 +508,7 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata)
|
||||
/* Check for superblock extension being located "outside" the stored
|
||||
* 'eoa' value, which can occur with the split/multi VFD.
|
||||
*/
|
||||
if(H5F_addr_gt(sblock->ext_addr, stored_eoa)) {
|
||||
if(H5F_addr_gt(sblock->ext_addr, stored_eof)) {
|
||||
/* Set the 'eoa' for the object header memory type large enough
|
||||
* to give some room for a reasonably sized superblock extension.
|
||||
* (This is _rather_ a kludge -QAK)
|
||||
@ -665,7 +665,7 @@ H5F_sblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t UNUSED addr,
|
||||
H5P_genplist_t *dxpl; /* DXPL object */
|
||||
uint8_t buf[H5F_MAX_SUPERBLOCK_SIZE + H5F_MAX_DRVINFOBLOCK_SIZE]; /* Superblock & driver info blockencoding buffer */
|
||||
uint8_t *p; /* Ptr into encoding buffer */
|
||||
haddr_t rel_eoa; /* Relative EOA for file */
|
||||
haddr_t rel_eof; /* Relative EOF for file */
|
||||
size_t superblock_size; /* Size of superblock, in bytes */
|
||||
size_t driver_size; /* Size of driver info block (bytes)*/
|
||||
|
||||
@ -705,8 +705,15 @@ H5F_sblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t UNUSED addr,
|
||||
|
||||
/* Encode the address of global free-space index */
|
||||
H5F_addr_encode(f, &p, sblock->ext_addr);
|
||||
rel_eoa = H5FD_get_eoa(f->shared->lf, H5FD_MEM_SUPER);
|
||||
H5F_addr_encode(f, &p, (rel_eoa + sblock->base_addr));
|
||||
|
||||
/* Encode the end-of-file address. Note that at this point in time,
|
||||
* the EOF value itself may not be reflective of the file's size, as
|
||||
* we will eventually truncate the file to match the EOA value. As
|
||||
* such, use the EOA value in its place, knowing that the current EOF
|
||||
* value will ultimately match it. */
|
||||
if ((rel_eof = H5FD_get_eoa(f->shared->lf, H5FD_MEM_SUPER)) == HADDR_UNDEF)
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "driver get_eoa request failed")
|
||||
H5F_addr_encode(f, &p, (rel_eof + sblock->base_addr));
|
||||
|
||||
/* Encode the driver informaton block address */
|
||||
H5F_addr_encode(f, &p, sblock->driver_addr);
|
||||
@ -765,8 +772,14 @@ H5F_sblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t UNUSED addr,
|
||||
/* Encode the address of the superblock extension */
|
||||
H5F_addr_encode(f, &p, sblock->ext_addr);
|
||||
|
||||
rel_eoa = H5FD_get_eoa(f->shared->lf, H5FD_MEM_SUPER);
|
||||
H5F_addr_encode(f, &p, (rel_eoa + sblock->base_addr));
|
||||
/* At this point in time, the EOF value itself may
|
||||
* not be reflective of the file's size, since we'll eventually
|
||||
* truncate it to match the EOA value. As such, use the EOA value
|
||||
* in its place, knowing that the current EOF value will
|
||||
* ultimately match it. */
|
||||
if ((rel_eof = H5FD_get_eoa(f->shared->lf, H5FD_MEM_SUPER)) == HADDR_UNDEF)
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "driver get_eoa request failed")
|
||||
H5F_addr_encode(f, &p, rel_eof + sblock->base_addr);
|
||||
|
||||
/* Retrieve information for root group */
|
||||
if(NULL == (root_oloc = H5G_oloc(f->shared->root_grp)))
|
||||
|
Loading…
Reference in New Issue
Block a user