From f8f8bed0c2d9d8c9dd39ce09018e629c6e886037 Mon Sep 17 00:00:00 2001 From: Raymond Lu Date: Wed, 22 Jun 2011 10:47:57 -0500 Subject: [svn-r21015] Bug fix for Issue 2598 - In v1.6 library, there was EOA for the whole MULTI file saved in the super block. We took it out in v1.8 library because it's meaningless for the MULTI file. v1.8 library saves the EOA for the metadata file, instead. But this caused some backward compatibility problem. v1.8 library couldn't open the file created with v1.6 library. I fixed the problem by checking the EOA value to detect the file created with v1.6 library. Tested on jam, koala, and heiwa. --- MANIFEST | 2 + release_docs/RELEASE.txt | 10 ++- src/H5FDmulti.c | 22 ++++++ src/H5FDsec2.c | 3 +- test/multi_file_v16-r.h5 | Bin 0 -> 65536 bytes test/multi_file_v16-s.h5 | Bin 0 -> 2048 bytes test/vfd.c | 173 ++++++++++++++++++++++++++++++++++++++++++++++- 7 files changed, 207 insertions(+), 3 deletions(-) create mode 100644 test/multi_file_v16-r.h5 create mode 100644 test/multi_file_v16-s.h5 diff --git a/MANIFEST b/MANIFEST index f7893eb..50fb2f9 100644 --- a/MANIFEST +++ b/MANIFEST @@ -891,6 +891,8 @@ ./test/mf.c ./test/mount.c ./test/mtime.c +./test/multi_file_v16-r.h5 +./test/multi_file_v16-s.h5 ./test/noencoder.h5 ./test/ntypes.c ./test/ohdr.c diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 86882fd..264908b 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -286,6 +286,14 @@ Bug Fixes since HDF5-1.8.0 release Library ------- + + - In v1.6 library, there was EOA for the whole MULTI file saved in the + super block. We took it out in v1.8 library because it's meaningless + for the MULTI file. v1.8 library saves the EOA for the metadata file, + instead. But this caused some backward compatibility problem. + v1.8 library couldn't open the file created with v1.6 library. We + fixed the problem by checking the EOA value to detect the file + created with v1.6 library. (SLU - 2011/6/22) - When a dataset had filters and reading data failed, the error message didn't say which filter isn't registered. It's fixed now. (SLU - 2011/6/3) @@ -519,7 +527,7 @@ Bug Fixes since HDF5-1.8.0 release prior to configuration. MAM - 2009/03/09 - BZ #1401. - Fixed error with 'make check install' failing due to h5dump needing other tools built first. MAM - 2008/10/24. - - When using shared szip, it is no longer necessary to specify + - Wpen using shared szip, it is no longer necessary to specify the path to the shared szip libraries in LD_LIBRARY_PATH. MAM - 2008/10/24. - The file libhdf5_fortran.settings is not installed since its content diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c index 9c30104..9f05126 100644 --- a/src/H5FDmulti.c +++ b/src/H5FDmulti.c @@ -83,6 +83,7 @@ typedef struct H5FD_multi_fapl_t { hid_t memb_fapl[H5FD_MEM_NTYPES];/*member access properties */ char *memb_name[H5FD_MEM_NTYPES];/*name generators */ haddr_t memb_addr[H5FD_MEM_NTYPES];/*starting addr per member */ + haddr_t memb_eoa[H5FD_MEM_NTYPES]; /*EOA for individual files */ hbool_t relax; /*less stringent error checking */ } H5FD_multi_fapl_t; @@ -506,6 +507,9 @@ H5Pset_fapl_multi(hid_t fapl_id, const H5FD_mem_t *memb_map, memcpy(fa.memb_addr, memb_addr, H5FD_MEM_NTYPES*sizeof(haddr_t)); fa.relax = relax; + /* Initialize all EOAs to zero */ + memset(fa.memb_eoa, 0, H5FD_MEM_NTYPES*sizeof(haddr_t)); + /* Patch up H5P_DEFAULT property lists for members */ for (mt=H5FD_MEM_DEFAULT; mtmemb[mt]) if(H5FDset_eoa(file->memb[mt], mt, memb_eoa[mt])<0) H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_CANTSET, "set_eoa() failed", -1) + + /* Save the individual EOAs in one place for later comparison (in H5FD_multi_set_eoa) */ + file->fa.memb_eoa[mt] = memb_eoa[mt]; } END_MEMBERS; return 0; @@ -1564,6 +1571,10 @@ H5FD_multi_get_eoa(const H5FD_t *_file, H5FD_mem_t type) * for MULTI file. This function only sets eoa for individual * file. * + * Raymond Lu + * 21 June 2011 + * Backward compatibility of EOA. Please the comment in the + * code. *------------------------------------------------------------------------- */ static herr_t @@ -1581,6 +1592,17 @@ H5FD_multi_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t eoa) if(H5FD_MEM_DEFAULT == mmt) mmt = type; + /* Handle backward compatibility in a quick and simple way. v1.6 library had EOA for the entire virtual + * file. But it wasn't meaningful. So v1.8 library doesn't have it anymore. It saves the EOA for the + * metadata file, instead. Here we try to figure out whether the EOA is from a v1.6 file by comparing its + * value. If it is a big value, we assume it's from v1.6 and simply discard it. This is the normal case + * when the metadata file has the smallest starting address. If the metadata file has the biggest address, + * the EOAs of v1.6 and v1.8 files are the same. It won't cause any trouble. (Please see Issue 2598 + * in Jira) SLU - 2011/6/21 + */ + if(H5FD_MEM_SUPER == type && file->fa.memb_eoa[H5FD_MEM_SUPER] > 0 && eoa > file->fa.memb_eoa[H5FD_MEM_SUPER]) + return 0; + assert(eoa >= file->fa.memb_addr[mmt]); assert(eoa < file->memb_next[mmt]); diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index bb5dc15..7908fd9 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -697,7 +697,8 @@ H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, if(REGION_OVERFLOW(addr, size)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu", (unsigned long long)addr) if((addr + size) > file->eoa) - HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu", (unsigned long long)addr) + HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size=%lu, eoa=%llu", + (unsigned long long)addr, size, (unsigned long long)file->eoa) /* Seek to the correct location */ if(addr != file->pos || OP_READ != file->op) { diff --git a/test/multi_file_v16-r.h5 b/test/multi_file_v16-r.h5 new file mode 100644 index 0000000..36a4c88 Binary files /dev/null and b/test/multi_file_v16-r.h5 differ diff --git a/test/multi_file_v16-s.h5 b/test/multi_file_v16-s.h5 new file mode 100644 index 0000000..e990e95 Binary files /dev/null and b/test/multi_file_v16-s.h5 differ diff --git a/test/vfd.c b/test/vfd.c index 9fe0e9e..8f88681 100644 --- a/test/vfd.c +++ b/test/vfd.c @@ -50,13 +50,14 @@ const char *FILENAME[] = { "log_file", /*6*/ "stdio_file", /*7*/ "windows_file", /*8*/ + "new_multi_file_v16",/*9*/ NULL }; #define LOG_FILENAME "log_vfd_out.log" #define COMPAT_BASENAME "family_v16_" - +#define MULTI_COMPAT_BASENAME "multi_file_v16" /*------------------------------------------------------------------------- @@ -1123,6 +1124,175 @@ error: /*------------------------------------------------------------------------- + * Function: test_multi_compat + * + * Purpose: Tests the backward compatibility for MULTI driver. + * See if we can open files created with v1.6 library. + * The source file was created by the test/file_handle.c + * of the v1.6 library. This test verifies the fix for + * Issue 2598. In v1.6 library, there was EOA for the whole + * MULTI file saved in the super block. We took it out in + * v1.8 library because it's meaningless for the MULTI file. + * v1.8 library saves the EOA for the metadata file, instead. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Raymond Lu + * 21 June 2011 + * + *------------------------------------------------------------------------- + */ +static herr_t +test_multi_compat(void) +{ + hid_t file=(-1), fapl, fapl2=(-1), dset=(-1), space=(-1); + hid_t access_fapl = -1; + char filename[1024], newname[1024], tmp[1024]; + char filename_s[1024], newname_s[1024]; + char filename_r[1024], newname_r[1024]; + int *fhandle2=NULL, *fhandle=NULL; + hsize_t file_size; + H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES]; + hid_t memb_fapl[H5FD_MEM_NTYPES]; + haddr_t memb_addr[H5FD_MEM_NTYPES]; + const char *memb_name[H5FD_MEM_NTYPES]; + char sv[H5FD_MEM_NTYPES][32]; + hsize_t dims[2]={MULTI_SIZE, MULTI_SIZE}; + char dname[]="dataset2"; + int i, j; + int buf[MULTI_SIZE][MULTI_SIZE]; + + TESTING("MULTI file driver backward compatibility"); + + /* Set file access property list for MULTI driver */ + fapl = h5_fileaccess(); + + HDmemset(memb_map, 0, sizeof memb_map); + HDmemset(memb_fapl, 0, sizeof memb_fapl); + HDmemset(memb_name, 0, sizeof memb_name); + HDmemset(memb_addr, 0, sizeof memb_addr); + HDmemset(sv, 0, sizeof sv); + + for(mt=H5FD_MEM_DEFAULT; mt