diff options
-rw-r--r-- | release_docs/RELEASE.txt | 5 | ||||
-rw-r--r-- | src/H5Bpublic.h | 3 | ||||
-rw-r--r-- | src/H5F.c | 164 | ||||
-rw-r--r-- | src/H5Fpkg.h | 11 | ||||
-rw-r--r-- | src/H5Fprivate.h | 12 | ||||
-rw-r--r-- | src/H5Pfcpl.c | 12 | ||||
-rw-r--r-- | src/H5private.h | 12 | ||||
-rw-r--r-- | test/set_extent.c | 13 | ||||
-rw-r--r-- | test/tmisc.c | 188 |
9 files changed, 322 insertions, 98 deletions
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 8ec9402..1d7f877 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -55,8 +55,11 @@ Bug Fixes since HDF5-1.6.0 release Library ------- + - Modified library and file format to support storing indexed storage + (chunked dataset) B-tree's with non-default internal 'K' values. + QAK - 2003/07/15 - Returned H5T_BKG_TEMP support to library after it was accidentally - removed. (2003/07/14 - QAK) + removed. QAK - 2003/07/14 Configuration ------------- diff --git a/src/H5Bpublic.h b/src/H5Bpublic.h index 8d2ec6c..26bac99 100644 --- a/src/H5Bpublic.h +++ b/src/H5Bpublic.h @@ -32,6 +32,9 @@ /* B-tree IDs for various internal things. */ /* Not really a "public" symbol, but that should be OK -QAK */ +/* Note - if more of these are added, any 'K' values (for internal or leaf + * nodes) they use will need to be stored in the file somewhere. -QAK + */ typedef enum H5B_subid_t { H5B_SNODE_ID = 0, /*B-tree is for symbol table nodes */ H5B_ISTORE_ID = 1, /*B-tree is for indexed object storage */ @@ -177,7 +177,7 @@ H5F_init_interface(void) * - Default value for 1/2 rank for btree internal nodes * - Default value for byte number in an address * - Default value for byte number for object size - * - Default value for version number of bootblock + * - Default value for version number of superblock * - Default value for free-space version number * - Default value for object directory version number * - Default value for share-header format version @@ -188,7 +188,7 @@ H5F_init_interface(void) int btree_k[H5B_NUM_BTREE_ID] = H5F_CRT_BTREE_RANK_DEF; size_t sizeof_addr = H5F_CRT_ADDR_BYTE_NUM_DEF; size_t sizeof_size = H5F_CRT_OBJ_BYTE_NUM_DEF; - int bootblock_ver = H5F_CRT_BOOT_VERS_DEF; + int superblock_ver = H5F_CRT_SUPER_VERS_DEF; int freespace_ver = H5F_CRT_FREESPACE_VERS_DEF; int objectdir_ver = H5F_CRT_OBJ_DIR_VERS_DEF; int sharedheader_ver = H5F_CRT_SHARE_HEAD_VERS_DEF; @@ -287,8 +287,8 @@ H5F_init_interface(void) if(H5P_register(crt_pclass,H5F_CRT_OBJ_BYTE_NUM_NAME, H5F_CRT_OBJ_BYTE_NUM_SIZE,&sizeof_size,NULL,NULL,NULL,NULL,NULL, NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); - /* Register the bootblock version number */ - if(H5P_register(crt_pclass,H5F_CRT_BOOT_VERS_NAME,H5F_CRT_BOOT_VERS_SIZE, &bootblock_ver,NULL,NULL,NULL,NULL,NULL,NULL)<0) + /* Register the superblock version number */ + if(H5P_register(crt_pclass,H5F_CRT_SUPER_VERS_NAME,H5F_CRT_SUPER_VERS_SIZE, &superblock_ver,NULL,NULL,NULL,NULL,NULL,NULL)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); /* Register the free-space version number */ @@ -1348,7 +1348,7 @@ H5F_equal(void *_haystack, hid_t UNUSED id, void *_needle) /*------------------------------------------------------------------------- * Function: H5F_locate_signature * - * Purpose: Finds the HDF5 boot block signature in a file. The signature + * Purpose: Finds the HDF5 super block signature in a file. The signature * can appear at address 0, or any power of two beginning with * 512. * @@ -1507,7 +1507,7 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id) f->shared = shared; } else { f->shared = H5FL_CALLOC(H5F_file_t); - f->shared->boot_addr = HADDR_UNDEF; + f->shared->super_addr = HADDR_UNDEF; f->shared->base_addr = HADDR_UNDEF; f->shared->freespace_addr = HADDR_UNDEF; f->shared->driver_addr = HADDR_UNDEF; @@ -1528,6 +1528,22 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get byte number for object size"); if(H5P_get(plist, H5F_CRT_SYM_LEAF_NAME, &f->shared->sym_leaf_k)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get byte number for object size"); + if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, &f->shared->btree_k[0])<0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "unable to get rank for btree internal nodes"); + + /* Check for non-default indexed storage B-tree internal 'K' value + * and increment the version # of the superblock if it is a non-default + * value. + */ + if(f->shared->btree_k[H5B_ISTORE_ID]!=HDF5_BTREE_ISTORE_IK_DEF) { + int super_vers=HDF5_SUPERBLOCK_VERSION_MAX; /* Super block version */ + H5P_genplist_t *c_plist; /* Property list */ + + if(NULL == (c_plist = H5I_object(f->shared->fcpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not property list"); + if(H5P_set(c_plist, H5F_CRT_SUPER_VERS_NAME, &super_vers) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set superblock version"); + } /* end if */ if(NULL == (plist = H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not file access property list"); @@ -1798,17 +1814,17 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d char driver_name[9]; /*file driver name/version */ hbool_t driver_has_cmp; /*`cmp' callback defined? */ hsize_t userblock_size = 0; - int boot_vers; - int freespace_vers; + int super_vers; /* Superblock version # */ + int freespace_vers; /* File freespace version # */ int obj_dir_vers; int share_head_vers; size_t sizeof_addr = 0; size_t sizeof_size = 0; unsigned sym_leaf_k = 0; - int btree_k[H5B_NUM_BTREE_ID]; - H5P_genplist_t *c_plist; - H5P_genplist_t *a_plist; /* Property list */ - H5F_close_degree_t fc_degree; + unsigned btree_k[H5B_NUM_BTREE_ID]; /* B-tree internal node 'K' values */ + H5P_genplist_t *c_plist; /* File creation property list */ + H5P_genplist_t *a_plist; /* File access property list */ + H5F_close_degree_t fc_degree; /* File close degree */ unsigned chksum; /* Checksum temporary variable */ unsigned i; /* Index variable */ @@ -1954,16 +1970,6 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d } #endif /* H5_HAVE_FPHDF5 */ - /* Get values to cache from the FCPL */ - if(H5P_get(c_plist, H5F_CRT_ADDR_BYTE_NUM_NAME,&shared->sizeof_addr)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set byte number in an address"); - if(H5P_get(c_plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &shared->sizeof_size)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set byte number for object size"); - if(H5P_get(c_plist, H5F_CRT_SYM_LEAF_NAME, &shared->sym_leaf_k)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set rank for symbol table leaf nodes"); - if(H5P_get(c_plist, H5F_CRT_BTREE_RANK_NAME, &shared->btree_k[0])<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "unable to get rank for btree internal nodes"); - /* * The superblock starts immediately after the user-defined header, * which we have already insured is a proper size. The base address @@ -1971,8 +1977,8 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d */ if(H5P_get(c_plist, H5F_CRT_USER_BLOCK_NAME, &userblock_size) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "unable to get user block size"); - shared->boot_addr = userblock_size; - shared->base_addr = shared->boot_addr; + shared->super_addr = userblock_size; + shared->base_addr = shared->super_addr; shared->consist_flags = 0x03; if (H5F_flush(file, dxpl_id, H5F_SCOPE_LOCAL, H5F_FLUSH_ALLOC_ONLY) < 0) @@ -2001,21 +2007,21 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d #endif /* H5_HAVE_FPHDF5 */ } else if (1==shared->nrefs) { /* Read the superblock if it hasn't been read before. */ - if (HADDR_UNDEF==(shared->boot_addr=H5F_locate_signature(lf,dxpl_id))) + if (HADDR_UNDEF==(shared->super_addr=H5F_locate_signature(lf,dxpl_id))) HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, NULL, "unable to find file signature"); - if (H5FD_set_eoa(lf, shared->boot_addr+fixed_size)<0 || - H5FD_read(lf, H5FD_MEM_SUPER, dxpl_id, shared->boot_addr, fixed_size, buf)<0) + if (H5FD_set_eoa(lf, shared->super_addr+fixed_size)<0 || + H5FD_read(lf, H5FD_MEM_SUPER, dxpl_id, shared->super_addr, fixed_size, buf)<0) HGOTO_ERROR(H5E_FILE, H5E_READERROR, NULL, "unable to read superblock"); /* Signature, already checked */ p = buf + H5F_SIGNATURE_LEN; /* Superblock version */ - boot_vers = *p++; - if(HDF5_BOOTBLOCK_VERSION != boot_vers) + super_vers = *p++; + if(super_vers>HDF5_SUPERBLOCK_VERSION_MAX) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad superblock version number"); - if(H5P_set(c_plist, H5F_CRT_BOOT_VERS_NAME, &boot_vers) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set boot version"); + if(H5P_set(c_plist, H5F_CRT_SUPER_VERS_NAME, &super_vers) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set superblock version"); /* Freespace version */ freespace_vers = *p++; @@ -2031,7 +2037,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d if(H5P_set(c_plist, H5F_CRT_OBJ_DIR_VERS_NAME, &obj_dir_vers) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set object directory version"); - /* reserved */ + /* Skip over reserved byte */ p++; /* Shared header version number */ @@ -2059,7 +2065,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set byte number for object size"); shared->sizeof_size=sizeof_size; /* Keep a local copy also */ - /* Reserved byte */ + /* Skip over reserved byte */ p++; /* Various B-tree sizes */ @@ -2076,24 +2082,41 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d UINT16DECODE(p, btree_k[H5B_SNODE_ID]); if(btree_k[H5B_SNODE_ID] < 1) HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, NULL, "bad 1/2 rank for btree internal nodes"); - if(H5P_set(c_plist, H5F_CRT_BTREE_RANK_NAME, btree_k)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set rank for btree internal nodes"); - HDmemcpy(shared->btree_k,btree_k,sizeof(int)*H5B_NUM_BTREE_ID); /* Keep a local copy also */ + /* Delay setting the value in the property list until we've checked for + * the indexed storage B-tree internal 'K' value later. + */ /* File consistency flags. Not really used yet */ UINT32DECODE(p, shared->consist_flags); assert((hsize_t)(p-buf) == fixed_size); /* Decode the variable-length part of the superblock... */ - variable_size = H5F_SIZEOF_ADDR(file) + /*base addr*/ + variable_size = (super_vers>0 ? 4 : 0) + /* Potential indexed storage B-tree internal 'K' value */ + H5F_SIZEOF_ADDR(file) + /*base addr*/ H5F_SIZEOF_ADDR(file) + /*global free list*/ H5F_SIZEOF_ADDR(file) + /*end-of-address*/ H5F_SIZEOF_ADDR(file) + /*reserved address*/ H5G_SIZEOF_ENTRY(file); /*root group ptr*/ - assert(variable_size<=sizeof(buf)); - if (H5FD_set_eoa(lf, shared->boot_addr+fixed_size+variable_size)<0 || - H5FD_read(lf, H5FD_MEM_SUPER, dxpl_id, shared->boot_addr+fixed_size, variable_size, &buf[fixed_size])<0) + assert((fixed_size+variable_size)<=sizeof(buf)); + if (H5FD_set_eoa(lf, shared->super_addr+fixed_size+variable_size)<0 || + H5FD_read(lf, H5FD_MEM_SUPER, dxpl_id, shared->super_addr+fixed_size, variable_size, &buf[fixed_size])<0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to read superblock"); + + /* If the superblock version # is greater than 0, read in the indexed storage B-tree internal 'K' value */ + if(super_vers>0) { + UINT16DECODE(p, btree_k[H5B_ISTORE_ID]); + + /* Skip over reserved bytes */ + p+=2; + } /* end if */ + else + btree_k[H5B_ISTORE_ID]=HDF5_BTREE_ISTORE_IK_DEF; + + /* Set the B-tree internal node values, etc */ + if(H5P_set(c_plist, H5F_CRT_BTREE_RANK_NAME, btree_k)<0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set rank for btree internal nodes"); + HDmemcpy(shared->btree_k,btree_k,sizeof(unsigned)*H5B_NUM_BTREE_ID); /* Keep a local copy also */ + H5F_addr_decode(file, &p, &(shared->base_addr)/*out*/); H5F_addr_decode(file, &p, &(shared->freespace_addr)/*out*/); H5F_addr_decode(file, &p, &stored_eoa/*out*/); @@ -2101,17 +2124,18 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d if (H5G_ent_decode(file, &p, &root_ent/*out*/)<0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to read root symbol entry"); - /* Compute boot block checksum */ - assert(sizeof(chksum)==sizeof(shared->boot_chksum)); + /* Compute super block checksum */ + assert(sizeof(chksum)==sizeof(shared->super_chksum)); for(q=(uint8_t *)&chksum, chksum=0, i=0; i<(fixed_size+variable_size); i++) - q[i%sizeof(shared->boot_chksum)] ^= buf[i]; + q[i%sizeof(shared->super_chksum)] ^= buf[i]; - /* Set the boot block checksum */ - shared->boot_chksum=chksum; + /* Set the super block checksum */ + shared->super_chksum=chksum; /* Decode the optional driver information block */ if (H5F_addr_defined(shared->driver_addr)) { haddr_t drv_addr = shared->base_addr + shared->driver_addr; + if (H5FD_set_eoa(lf, drv_addr+16)<0 || H5FD_read(lf, H5FD_MEM_SUPER, dxpl_id, drv_addr, 16, buf)<0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to read driver information block"); @@ -2132,6 +2156,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d driver_name[8] = '\0'; /* Read driver information and decode */ + assert((driver_size+16)<=sizeof(buf)); if (H5FD_set_eoa(lf, drv_addr+16+driver_size)<0 || H5FD_read(lf, H5FD_MEM_SUPER, dxpl_id, drv_addr+16, driver_size, &buf[16])<0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to read file driver information"); @@ -2489,8 +2514,8 @@ done: * Function: H5F_flush * * Purpose: Flushes (and optionally invalidates) cached data plus the - * file boot block. If the logical file size field is zero - * then it is updated to be the length of the boot block. + * file super block. If the logical file size field is zero + * then it is updated to be the length of the super block. * * Return: Non-negative on success/Negative on failure * @@ -2542,8 +2567,8 @@ done: static herr_t H5F_flush(H5F_t *f, hid_t dxpl_id, H5F_scope_t scope, unsigned flags) { - uint8_t sbuf[1024]; /* Superblock encoding buffer */ - uint8_t dbuf[1024]; /* Driver info block encoding buffer */ + uint8_t sbuf[H5F_SUPERBLOCK_SIZE]; /* Superblock encoding buffer */ + uint8_t dbuf[H5F_DRVINFOBLOCK_SIZE]; /* Driver info block encoding buffer */ uint8_t *p=NULL; /* Temporary pointer into encoding buffers */ unsigned nerrors=0; /* Errors from nested flushes */ unsigned i; /* Index variable */ @@ -2551,7 +2576,7 @@ H5F_flush(H5F_t *f, hid_t dxpl_id, H5F_scope_t scope, unsigned flags) size_t superblock_size;/* Size of superblock, in bytes */ size_t driver_size; /* Size of driver info block, in bytes */ char driver_name[9]; /* Name of driver, for driver info block */ - int boot_vers; /* Boot block version */ + int super_vers; /* Super block version */ int freespace_vers; /* Freespace info version */ int obj_dir_vers; /* Object header info version */ int share_head_vers;/* Shared header info version */ @@ -2678,8 +2703,8 @@ H5F_flush(H5F_t *f, hid_t dxpl_id, H5F_scope_t scope, unsigned flags) if(NULL == (plist = H5I_object(f->shared->fcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); - if(H5P_get(plist, H5F_CRT_BOOT_VERS_NAME, &boot_vers) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get boot block version"); + if(H5P_get(plist, H5F_CRT_SUPER_VERS_NAME, &super_vers) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get super block version"); if(H5P_get(plist, H5F_CRT_FREESPACE_VERS_NAME, &freespace_vers) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get free space version"); if(H5P_get(plist, H5F_CRT_OBJ_DIR_VERS_NAME, &obj_dir_vers) < 0) @@ -2687,11 +2712,11 @@ H5F_flush(H5F_t *f, hid_t dxpl_id, H5F_scope_t scope, unsigned flags) if(H5P_get(plist, H5F_CRT_SHARE_HEAD_VERS_NAME, &share_head_vers) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get shared-header format version"); - /* encode the file boot block */ + /* encode the file super block */ p = sbuf; HDmemcpy(p, H5F_SIGNATURE, H5F_SIGNATURE_LEN); p += H5F_SIGNATURE_LEN; - *p++ = boot_vers; + *p++ = super_vers; *p++ = freespace_vers; *p++ = obj_dir_vers; *p++ = 0; /*reserved*/ @@ -2704,6 +2729,14 @@ H5F_flush(H5F_t *f, hid_t dxpl_id, H5F_scope_t scope, unsigned flags) UINT16ENCODE(p, f->shared->sym_leaf_k); UINT16ENCODE(p, f->shared->btree_k[H5B_SNODE_ID]); UINT32ENCODE(p, f->shared->consist_flags); + + /* Versions of the superblock >0 have the indexed storage B-tree internal 'K' value stored */ + if(super_vers>0) { + UINT16ENCODE(p, f->shared->btree_k[H5B_ISTORE_ID]); + *p++ = 0; /*reserved */ + *p++ = 0; /*reserved */ + } /* end if */ + H5F_addr_encode(f, &p, f->shared->base_addr); H5F_addr_encode(f, &p, f->shared->freespace_addr); H5F_addr_encode(f, &p, H5FD_get_eoa(f->shared->lf)); @@ -2721,7 +2754,11 @@ H5F_flush(H5F_t *f, hid_t dxpl_id, H5F_scope_t scope, unsigned flags) if (driver_size > 0) { driver_size += 16; /*driver block header */ + + /* Double check we didn't overrun the block (unlikely) */ assert(driver_size<=sizeof(dbuf)); + + /* Encode the driver information block */ p = dbuf; /* Version */ @@ -2739,9 +2776,6 @@ H5F_flush(H5F_t *f, hid_t dxpl_id, H5F_scope_t scope, unsigned flags) /* Driver name */ HDmemcpy(dbuf+8, driver_name, 8); - - /* Double check we didn't overrun the block (unlikely) */ - assert(driver_size<=sizeof(dbuf)); } /* end if */ if (flags & H5F_FLUSH_ALLOC_ONLY) { @@ -2779,21 +2813,21 @@ H5F_flush(H5F_t *f, hid_t dxpl_id, H5F_scope_t scope, unsigned flags) if (driver_size > 0) f->shared->driver_addr = superblock_size; } else { - /* Compute boot block checksum */ - assert(sizeof(chksum)==sizeof(f->shared->boot_chksum)); + /* Compute super block checksum */ + assert(sizeof(chksum)==sizeof(f->shared->super_chksum)); for (p=(uint8_t *)&chksum, chksum=0, i=0; i<superblock_size; i++) - p[i%sizeof(f->shared->boot_chksum)] ^= sbuf[i]; + p[i%sizeof(f->shared->super_chksum)] ^= sbuf[i]; /* Compare with current checksums */ - if (chksum!=f->shared->boot_chksum) { + if (chksum!=f->shared->super_chksum) { /* Write superblock */ if (H5FD_write(f->shared->lf, H5FD_MEM_SUPER, dxpl_id, - f->shared->boot_addr, superblock_size, sbuf) < 0) + f->shared->super_addr, superblock_size, sbuf) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write superblock"); /* Update checksum information if different */ - f->shared->boot_chksum=chksum; + f->shared->super_chksum=chksum; } /* end if */ /* Check for driver info block */ @@ -4247,7 +4281,7 @@ H5F_debug(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, FILE * stream, int inden if(H5P_get(plist, H5F_CRT_USER_BLOCK_NAME, &userblock_size)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get user block size"); - if(H5P_get(plist, H5F_CRT_BOOT_VERS_NAME, &super_vers)<0) + if(H5P_get(plist, H5F_CRT_SUPER_VERS_NAME, &super_vers)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get super block version"); if(H5P_get(plist, H5F_CRT_FREESPACE_VERS_NAME, &freespace_vers)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get super block version"); @@ -4269,7 +4303,7 @@ H5F_debug(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, FILE * stream, int inden "File open reference count:", (unsigned) (f->shared->nrefs)); HDfprintf(stream, "%*s%-*s %a (abs)\n", indent, "", fwidth, - "Address of super block:", f->shared->boot_addr); + "Address of super block:", f->shared->super_addr); HDfprintf(stream, "%*s%-*s %lu bytes\n", indent, "", fwidth, "Size of user block:", (unsigned long) userblock_size); diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 2d92ad3..1ae333d 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -56,8 +56,9 @@ # undef H5F_DEBUG #endif -/* Maximum size of boot-block buffer */ -#define H5F_BOOTBLOCK_SIZE 1024 +/* Maximum size of super-block buffer */ +#define H5F_SUPERBLOCK_SIZE 256 +#define H5F_DRVINFOBLOCK_SIZE 1024 /* Define the HDF5 file signature */ #define H5F_SIGNATURE "\211HDF\r\n\032\n" @@ -118,11 +119,11 @@ typedef struct H5F_file_t { unsigned sym_leaf_k; /* Size of leaves in symbol tables */ int btree_k[H5B_NUM_BTREE_ID]; /* B-tree key values for each type */ - haddr_t boot_addr; /* Absolute address of boot block */ + haddr_t super_addr; /* Absolute address of super block */ haddr_t base_addr; /* Absolute base address for rel.addrs. */ haddr_t freespace_addr; /* Relative address of free-space info */ haddr_t driver_addr; /* File driver information block address*/ - unsigned boot_chksum; /* Boot block checksum */ + unsigned super_chksum; /* Superblock checksum */ unsigned drvr_chksum; /* Driver info block checksum */ struct H5AC_t *cache; /* The object cache */ hid_t fcpl_id; /* File creation property list ID */ @@ -217,7 +218,7 @@ H5_DLL herr_t H5F_istore_stats (H5F_t *f, hbool_t headers); H5_DLL herr_t H5F_istore_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int fwidth, int ndims); -/* Functions that operate on contiguous storage wrt boot block */ +/* Functions that operate on contiguous storage wrt superblock */ H5_DLL ssize_t H5F_contig_readvv(H5F_t *f, hsize_t _max_data, haddr_t _addr, size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[], diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 6c81e21..e6b5bf7 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -257,7 +257,7 @@ typedef struct H5F_t H5F_t; /* Definitions for the 1/2 rank for btree internal nodes */ #define H5F_CRT_BTREE_RANK_NAME "btree_rank" #define H5F_CRT_BTREE_RANK_SIZE sizeof(int[H5B_NUM_BTREE_ID]) -#define H5F_CRT_BTREE_RANK_DEF {16,32} +#define H5F_CRT_BTREE_RANK_DEF {HDF5_BTREE_SNODE_IK_DEF,HDF5_BTREE_ISTORE_IK_DEF} /* Definitions for byte number in an address */ #define H5F_CRT_ADDR_BYTE_NUM_NAME "addr_byte_num" #define H5F_CRT_ADDR_BYTE_NUM_SIZE sizeof(size_t) @@ -266,10 +266,10 @@ typedef struct H5F_t H5F_t; #define H5F_CRT_OBJ_BYTE_NUM_NAME "obj_byte_num" #define H5F_CRT_OBJ_BYTE_NUM_SIZE sizeof(size_t) #define H5F_CRT_OBJ_BYTE_NUM_DEF sizeof(hsize_t) -/* Definitions for version number of the bootblock */ -#define H5F_CRT_BOOT_VERS_NAME "boot_version" -#define H5F_CRT_BOOT_VERS_SIZE sizeof(int) -#define H5F_CRT_BOOT_VERS_DEF HDF5_BOOTBLOCK_VERSION +/* Definitions for version number of the superblock */ +#define H5F_CRT_SUPER_VERS_NAME "super_version" +#define H5F_CRT_SUPER_VERS_SIZE sizeof(int) +#define H5F_CRT_SUPER_VERS_DEF HDF5_SUPERBLOCK_VERSION_DEF /* Definitions for free-space version number */ #define H5F_CRT_FREESPACE_VERS_NAME "free_space_version" #define H5F_CRT_FREESPACE_VERS_SIZE sizeof(int) @@ -400,7 +400,7 @@ H5_DLL size_t H5F_sizeof_size(const H5F_t *f); H5_DLL unsigned H5F_sym_leaf_k(const H5F_t *f); H5_DLL int H5F_Kvalue(const H5F_t *f, const struct H5B_class_t *type); -/* Functions that operate on blocks of bytes wrt boot block */ +/* Functions that operate on blocks of bytes wrt super block */ H5_DLL herr_t H5F_block_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, hid_t dxpl_id, void *buf/*out*/); H5_DLL herr_t H5F_block_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, diff --git a/src/H5Pfcpl.c b/src/H5Pfcpl.c index d709859..1567e53 100644 --- a/src/H5Pfcpl.c +++ b/src/H5Pfcpl.c @@ -40,7 +40,7 @@ static int interface_initialize_g = 0; * * Purpose: Retrieves version information for various parts of a file. * - * BOOT: The file boot block. + * SUPER: The file super block. * HEAP: The global heap. * FREELIST: The global free list. * STAB: The root symbol table entry. @@ -65,23 +65,23 @@ static int interface_initialize_g = 0; *------------------------------------------------------------------------- */ herr_t -H5Pget_version(hid_t plist_id, int *boot/*out*/, int *freelist/*out*/, +H5Pget_version(hid_t plist_id, int *super/*out*/, int *freelist/*out*/, int *stab/*out*/, int *shhdr/*out*/) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Pget_version, FAIL); - H5TRACE5("e","ixxxx",plist_id,boot,freelist,stab,shhdr); + H5TRACE5("e","ixxxx",plist_id,super,freelist,stab,shhdr); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get values */ - if (boot) - if(H5P_get(plist, H5F_CRT_BOOT_VERS_NAME, boot) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get boot version"); + if (super) + if(H5P_get(plist, H5F_CRT_SUPER_VERS_NAME, super) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get superblock version"); if (freelist) if(H5P_get(plist, H5F_CRT_FREESPACE_VERS_NAME, freelist) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get free-space version"); diff --git a/src/H5private.h b/src/H5private.h index dacefd8..b72df0a 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -219,12 +219,22 @@ #endif /* Version #'s of the major components of the file format */ -#define HDF5_BOOTBLOCK_VERSION 0 /* of the boot block format */ +#define HDF5_SUPERBLOCK_VERSION_DEF 0 /* The default super block format */ +#define HDF5_SUPERBLOCK_VERSION_MAX 1 /* The maximum super block format */ #define HDF5_FREESPACE_VERSION 0 /* of the Free-Space Info */ #define HDF5_OBJECTDIR_VERSION 0 /* of the Object Directory format */ #define HDF5_SHAREDHEADER_VERSION 0 /* of the Shared-Header Info */ #define HDF5_DRIVERINFO_VERSION 0 /* of the Driver Information Block*/ +/* B-tree internal 'K' values */ +#define HDF5_BTREE_SNODE_IK_DEF 16 +#define HDF5_BTREE_ISTORE_IK_DEF 32 /* Note! this value is assumed + to be 32 for older versions + of the superblock (<1) and + if it is changed, the code + must compensate. -QAK + */ + /* * Status return values for the `herr_t' type. * Since some unix/c routines use 0 and -1 (or more precisely, non-negative diff --git a/test/set_extent.c b/test/set_extent.c index 90d1654..067dabc 100644 --- a/test/set_extent.c +++ b/test/set_extent.c @@ -33,6 +33,7 @@ */ #define RANK 2 +#define ISTORE_IK 64 int main( void ) @@ -42,6 +43,7 @@ int main( void ) hid_t dataset_id=(-1); hid_t space_id=(-1); hid_t plist_id=(-1); + hid_t fcpl; /* File creation property list */ hsize_t dims[RANK] = { 90, 90 }; hsize_t dims_new[RANK] = { 70, 70 }; hsize_t dims_chunk[RANK] = { 20, 20 }; @@ -280,10 +282,17 @@ int main( void ) *------------------------------------------------------------------------- */ + /* Create a file creation property list */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE))<0) goto out; - /* Create a new file using default properties. */ - if ((file_id = H5Fcreate( "set_extent_read.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT ))<0) goto out; + /* Set non-default indexed storage B-tree internal 'K' value */ + if(H5Pset_istore_k(fcpl,ISTORE_IK)<0) goto out; + + /* Create a new file using properties. */ + if ((file_id = H5Fcreate( "set_extent_read.h5", H5F_ACC_TRUNC, fcpl, H5P_DEFAULT ))<0) goto out; + /* Close property list */ + if(H5Pclose(fcpl)<0) goto out; TESTING("extend dataset read with fill value"); diff --git a/test/tmisc.c b/test/tmisc.c index 7b82273..6e59393 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -147,6 +147,15 @@ typedef struct #define MISC10_FILE_NEW "tmisc10.h5" #define MISC10_DSETNAME "Dataset1" +/* Definitions for misc. test #11 */ +#define MISC11_FILE "tmisc11.h5" +#define MISC11_USERBLOCK 1024 +#define MISC11_SIZEOF_OFF 4 +#define MISC11_SIZEOF_LEN 4 +#define MISC11_SYM_LK 8 +#define MISC11_SYM_IK 32 +#define MISC11_ISTORE_IK 64 + /**************************************************************** ** ** test_misc1(): test unlinking a dataset from a group and immediately @@ -1659,6 +1668,159 @@ test_misc10(void) /**************************************************************** ** +** test_misc11(): Test that all properties in a file creation property +** list are stored correctly in the file and can be retrieved +** when the file is re-opened. +** +****************************************************************/ +static void +test_misc11(void) +{ + hid_t file; /* File IDs for old & new files */ + hid_t fcpl; /* File creation property list */ + hsize_t userblock; /* Userblock size retrieved from FCPL */ + size_t off_size; /* Size of offsets in the file */ + size_t len_size; /* Size of lengths in the file */ + int sym_ik; /* Symbol table B-tree initial 'K' value */ + int istore_ik; /* Indexed storage B-tree initial 'K' value */ +#ifdef H5_WANT_H5_V1_4_COMPAT + int sym_lk; /* Symbol table B-tree leaf 'K' value */ +#else /* H5_WANT_H5_V1_4_COMPAT */ + unsigned sym_lk; /* Symbol table B-tree leaf 'K' value */ +#endif /* H5_WANT_H5_V1_4_COMPAT */ + int super; /* Superblock version # */ + int freelist; /* Free list version # */ + int stab; /* Symbol table entry version # */ + int shhdr; /* Shared object header version # */ + herr_t ret; /* Generic return value */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing file creation properties retrieved correctly\n")); + + /* Creating a file with the default file creation property list should + * create a version 0 superblock + */ + + /* Create file with default file creation property list */ + file= H5Fcreate(MISC11_FILE, H5F_ACC_TRUNC , H5P_DEFAULT, H5P_DEFAULT); + CHECK(file, FAIL, "H5Fcreate"); + + /* Get the file's dataset creation property list */ + fcpl = H5Fget_create_plist(file); + CHECK(fcpl, FAIL, "H5Fget_create_plist"); + + /* Get the file's version information */ + ret=H5Pget_version(fcpl, &super, &freelist, &stab, &shhdr); + CHECK(ret, FAIL, "H5Pget_version"); + VERIFY(super,0,"H5Pget_version"); + VERIFY(freelist,0,"H5Pget_version"); + VERIFY(stab,0,"H5Pget_version"); + VERIFY(shhdr,0,"H5Pget_version"); + + /* Close FCPL */ + ret=H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); + + /* Close file */ + ret=H5Fclose(file); + CHECK(ret, FAIL, "H5Fclose"); + + + /* Create a file creation property list */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); + + /* Set all the properties in the FCPL */ + ret=H5Pset_userblock(fcpl,(hsize_t)MISC11_USERBLOCK); + CHECK(ret, FAIL, "H5Pset_userblock"); + + ret=H5Pset_sizes(fcpl,MISC11_SIZEOF_OFF,MISC11_SIZEOF_LEN); + CHECK(ret, FAIL, "H5Pset_sizes"); + + ret=H5Pset_sym_k(fcpl,MISC11_SYM_IK,MISC11_SYM_LK); + CHECK(ret, FAIL, "H5Pset_sym_k"); + + ret=H5Pset_istore_k(fcpl,MISC11_ISTORE_IK); + CHECK(ret, FAIL, "H5Pset_istore_k"); + + /* Creating a file with the non-default file creation property list should + * create a version 1 superblock + */ + + /* Create file with custom file creation property list */ + file= H5Fcreate(MISC11_FILE, H5F_ACC_TRUNC , fcpl, H5P_DEFAULT); + CHECK(file, FAIL, "H5Fcreate"); + + /* Close FCPL */ + ret=H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); + + /* Get the file's dataset creation property list */ + fcpl = H5Fget_create_plist(file); + CHECK(fcpl, FAIL, "H5Fget_create_plist"); + + /* Get the file's version information */ + ret=H5Pget_version(fcpl, &super, &freelist, &stab, &shhdr); + CHECK(ret, FAIL, "H5Pget_version"); + VERIFY(super,1,"H5Pget_version"); + VERIFY(freelist,0,"H5Pget_version"); + VERIFY(stab,0,"H5Pget_version"); + VERIFY(shhdr,0,"H5Pget_version"); + + /* Close FCPL */ + ret=H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); + + /* Close file */ + ret=H5Fclose(file); + CHECK(ret, FAIL, "H5Fclose"); + + /* Re-open the file */ + file = H5Fopen(MISC11_FILE, H5F_ACC_RDONLY, H5P_DEFAULT); + CHECK(file, FAIL, "H5Fcreate"); + + /* Get the file's dataset creation property list */ + fcpl = H5Fget_create_plist(file); + CHECK(fcpl, FAIL, "H5Fget_create_plist"); + + /* Get the file's version information */ + ret=H5Pget_version(fcpl, &super, &freelist, &stab, &shhdr); + CHECK(ret, FAIL, "H5Pget_version"); + VERIFY(super,1,"H5Pget_version"); + VERIFY(freelist,0,"H5Pget_version"); + VERIFY(stab,0,"H5Pget_version"); + VERIFY(shhdr,0,"H5Pget_version"); + + /* Retrieve all the property values & check them */ + ret=H5Pget_userblock(fcpl,&userblock); + CHECK(ret, FAIL, "H5Pget_userblock"); + VERIFY(userblock, MISC11_USERBLOCK, "H5Pget_userblock"); + + ret=H5Pget_sizes(fcpl,&off_size,&len_size); + CHECK(ret, FAIL, "H5Pget_sizes"); + VERIFY(off_size, MISC11_SIZEOF_OFF, "H5Pget_sizes"); + VERIFY(len_size, MISC11_SIZEOF_LEN, "H5Pget_sizes"); + + ret=H5Pget_sym_k(fcpl,&sym_ik,&sym_lk); + CHECK(ret, FAIL, "H5Pget_sym_k"); + VERIFY(sym_ik, MISC11_SYM_IK, "H5Pget_sym_k"); + VERIFY(sym_lk, MISC11_SYM_LK, "H5Pget_sym_k"); + + ret=H5Pget_istore_k(fcpl,&istore_ik); + CHECK(ret, FAIL, "H5Pget_istore_k"); + VERIFY(istore_ik, MISC11_ISTORE_IK, "H5Pget_istore_k"); + + /* Close file */ + ret=H5Fclose(file); + CHECK(ret, FAIL, "H5Fclose"); + + /* Close FCPL */ + ret=H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); +} /* end test_misc11() */ + +/**************************************************************** +** ** test_misc(): Main misc. test routine. ** ****************************************************************/ @@ -1678,6 +1840,7 @@ test_misc(void) test_misc8(); /* Test storage sizes of various types of dataset storage */ test_misc9(); /* Test for opening (not creating) core files */ test_misc10(); /* Test for using dataset creation property lists from old files */ + test_misc11(); /* Test for all properties of a file creation property list being stored */ } /* test_misc() */ @@ -1699,16 +1862,17 @@ test_misc(void) void cleanup_misc(void) { - remove(MISC1_FILE); - remove(MISC2_FILE_1); - remove(MISC2_FILE_2); - remove(MISC3_FILE); - remove(MISC4_FILE_1); - remove(MISC4_FILE_2); - remove(MISC5_FILE); - remove(MISC6_FILE); - remove(MISC7_FILE); - remove(MISC8_FILE); - remove(MISC9_FILE); - remove(MISC10_FILE_NEW); + HDremove(MISC1_FILE); + HDremove(MISC2_FILE_1); + HDremove(MISC2_FILE_2); + HDremove(MISC3_FILE); + HDremove(MISC4_FILE_1); + HDremove(MISC4_FILE_2); + HDremove(MISC5_FILE); + HDremove(MISC6_FILE); + HDremove(MISC7_FILE); + HDremove(MISC8_FILE); + HDremove(MISC9_FILE); + HDremove(MISC10_FILE_NEW); + HDremove(MISC11_FILE); } |