H5HFpkg.h

00001 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00002  * Copyright by The HDF Group.                                               *
00003  * Copyright by the Board of Trustees of the University of Illinois.         *
00004  * All rights reserved.                                                      *
00005  *                                                                           *
00006  * This file is part of HDF5.  The full HDF5 copyright notice, including     *
00007  * terms governing use, modification, and redistribution, is contained in    *
00008  * the files COPYING and Copyright.html.  COPYING can be found at the root   *
00009  * of the source code distribution tree; Copyright.html can be found at the  *
00010  * root level of an installed copy of the electronic HDF5 document set and   *
00011  * is linked from the top-level documents page.  It can also be found at     *
00012  * http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have          *
00013  * access to either file, you may request a copy from help@hdfgroup.org.     *
00014  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00015 
00016 /*
00017  * Programmer:  Quincey Koziol <koziol@ncsa.uiuc.edu>
00018  *              Friday, February 24, 2006
00019  *
00020  * Purpose:     This file contains declarations which are visible only within
00021  *              the H5HF package.  Source files outside the H5HF package should
00022  *              include H5HFprivate.h instead.
00023  */
00024 #ifndef H5HF_PACKAGE
00025 #error "Do not include this file outside the H5HF package!"
00026 #endif
00027 
00028 #ifndef _H5HFpkg_H
00029 #define _H5HFpkg_H
00030 
00031 /* Get package's private header */
00032 #include "H5HFprivate.h"
00033 
00034 /* Other private headers needed by this file */
00035 #include "H5ACprivate.h"        /* Metadata cache                       */
00036 #include "H5B2private.h"        /* v2 B-trees                           */
00037 #include "H5FLprivate.h"        /* Free Lists                           */
00038 #include "H5FSprivate.h"        /* Free space manager                   */
00039 #include "H5SLprivate.h"        /* Skip lists                           */
00040 
00041 /**************************/
00042 /* Package Private Macros */
00043 /**************************/
00044 
00045 /* Size of checksum information (on disk) */
00046 #define H5HF_SIZEOF_CHKSUM      4
00047 
00048 /* "Standard" size of prefix information for fractal heap metadata */
00049 #define H5HF_METADATA_PREFIX_SIZE(c) (                                        \
00050     H5_SIZEOF_MAGIC   /* Signature */                                         \
00051     + 1 /* Version */                                                         \
00052     + ((c) ? H5HF_SIZEOF_CHKSUM : 0) /* Metadata checksum */                  \
00053     )
00054 
00055 /* Size of doubling-table information */
00056 #define H5HF_DTABLE_INFO_SIZE(h) (                                            \
00057     2   /* Width of table (i.e. # of columns) */                              \
00058     + (h)->sizeof_size /* Starting block size */                              \
00059     + (h)->sizeof_size /* Maximum direct block size */                        \
00060     + 2 /* Max. size of heap (log2 of actual value - i.e. the # of bits) */   \
00061     + 2 /* Starting # of rows in root indirect block */                       \
00062     + (h)->sizeof_addr /* File address of table managed */                    \
00063     + 2 /* Current # of rows in root indirect block */                        \
00064     )
00065 
00066 /* Flags for status byte */
00067 #define H5HF_HDR_FLAGS_HUGE_ID_WRAPPED 0x01     /* "huge" object IDs have wrapped */
00068 #define H5HF_HDR_FLAGS_CHECKSUM_DBLOCKS 0x02    /* checksum direct blocks */
00069 
00070 /* Size of the fractal heap header on disk */
00071 /* (this is the fixed-len portion, the variable-len I/O filter information
00072  *      follows this information, if there are I/O filters for the heap)
00073  */
00074 #define H5HF_HEADER_SIZE(h)     (                                             \
00075     /* General metadata fields */                                             \
00076     H5HF_METADATA_PREFIX_SIZE(TRUE)                                           \
00077                                                                               \
00078     /* Fractal Heap Header specific fields */                                 \
00079                                                                               \
00080     /* General heap information */                                            \
00081     + 2 /* Heap ID len */                                                     \
00082     + 2 /* I/O filters' encoded len */                                        \
00083     + 1 /* Status flags */                                                    \
00084                                                                               \
00085     /* "Huge" object fields */                                                \
00086     + 4 /* Max. size of "managed" object */                                   \
00087     + (h)->sizeof_size /* Next ID for "huge" object */                        \
00088     + (h)->sizeof_addr /* File address of "huge" object tracker B-tree  */    \
00089                                                                               \
00090     /* "Managed" object free space fields */                                  \
00091     + (h)->sizeof_size /* Total man. free space */                            \
00092     + (h)->sizeof_addr /* File address of free section header */              \
00093                                                                               \
00094     /* Statistics fields */                                                   \
00095     + (h)->sizeof_size /* Size of man. space in heap */                       \
00096     + (h)->sizeof_size /* Size of man. space iterator offset in heap */       \
00097     + (h)->sizeof_size /* Size of alloacted man. space in heap */             \
00098     + (h)->sizeof_size /* Number of man. objects in heap */                   \
00099     + (h)->sizeof_size /* Size of huge space in heap */                       \
00100     + (h)->sizeof_size /* Number of huge objects in heap */                   \
00101     + (h)->sizeof_size /* Size of tiny space in heap */                       \
00102     + (h)->sizeof_size /* Number of tiny objects in heap */                   \
00103                                                                               \
00104     /* "Managed" object doubling table info */                                \
00105     + H5HF_DTABLE_INFO_SIZE(h) /* Size of managed obj. doubling-table info */ \
00106     )
00107 
00108 /* Size of overhead for a direct block */
00109 #define H5HF_MAN_ABS_DIRECT_OVERHEAD(h) (                                     \
00110     /* General metadata fields */                                             \
00111     H5HF_METADATA_PREFIX_SIZE(h->checksum_dblocks)                            \
00112                                                                               \
00113     /* Fractal heap managed, absolutely mapped direct block specific fields */ \
00114     + (h)->sizeof_addr          /* File address of heap owning the block */   \
00115     + (h)->heap_off_size        /* Offset of the block in the heap */         \
00116     )
00117 
00118 /* Size of managed indirect block entry for a child direct block */
00119 #define H5HF_MAN_INDIRECT_CHILD_DIR_ENTRY_SIZE(h) (                           \
00120     ((h)->filter_len > 0 ?                                                    \
00121         ((h)->sizeof_addr + (h)->sizeof_size + 4) : /* Size of entries for filtered direct blocks */ \
00122         (h)->sizeof_addr)             /* Size of entries for un-filtered direct blocks */ \
00123     )
00124 
00125 /* Size of managed indirect block */
00126 #define H5HF_MAN_INDIRECT_SIZE(h, i) (                                        \
00127     /* General metadata fields */                                             \
00128     H5HF_METADATA_PREFIX_SIZE(TRUE)                                           \
00129                                                                               \
00130     /* Fractal heap managed, absolutely mapped indirect block specific fields */ \
00131     + (h)->sizeof_addr          /* File address of heap owning the block */   \
00132     + (h)->heap_off_size        /* Offset of the block in the heap */         \
00133     + (MIN((i)->nrows, (h)->man_dtable.max_direct_rows) * (h)->man_dtable.cparam.width * H5HF_MAN_INDIRECT_CHILD_DIR_ENTRY_SIZE(h)) /* Size of entries for direct blocks */ \
00134     + ((((i)->nrows > (h)->man_dtable.max_direct_rows) ? ((i)->nrows - (h)->man_dtable.max_direct_rows) : 0)  * (h)->man_dtable.cparam.width * (h)->sizeof_addr) /* Size of entries for indirect blocks */ \
00135     )
00136 
00137 
00138 /* Compute the # of bytes required to store an offset into a given buffer size */
00139 #define H5HF_SIZEOF_OFFSET_BITS(b)   (((b) + 7) / 8)
00140 #define H5HF_SIZEOF_OFFSET_LEN(l)   H5HF_SIZEOF_OFFSET_BITS(H5V_log2_of2((unsigned)(l)))
00141 
00142 /* Heap ID bit flags */
00143 /* Heap ID version (2 bits: 6-7) */
00144 #define H5HF_ID_VERS_CURR       0x00    /* Current version of ID format */
00145 #define H5HF_ID_VERS_MASK       0xC0    /* Mask for getting the ID version from flags */
00146 /* Heap ID type (2 bits: 4-5) */
00147 #define H5HF_ID_TYPE_MAN        0x00    /* "Managed" object - stored in fractal heap blocks */
00148 #define H5HF_ID_TYPE_HUGE       0x10    /* "Huge" object - stored in file directly */
00149 #define H5HF_ID_TYPE_TINY       0x20    /* "Tiny" object - stored in heap ID directly */
00150 #define H5HF_ID_TYPE_RESERVED   0x30    /* "?" object - reserved for future use */
00151 #define H5HF_ID_TYPE_MASK       0x30    /* Mask for getting the ID type from flags */
00152 /* Heap ID bits 0-3 reserved for future use */
00153 
00154 /* Encode a "managed" heap ID */
00155 #define H5HF_MAN_ID_ENCODE(i, h, o, l)                                        \
00156     *(i) = H5HF_ID_VERS_CURR | H5HF_ID_TYPE_MAN;                              \
00157     (i)++;                                                                    \
00158     UINT64ENCODE_VAR((i), (o), (h)->heap_off_size);                           \
00159     UINT64ENCODE_VAR((i), (l), (h)->heap_len_size)
00160 
00161 /* Decode a "managed" heap ID */
00162 #define H5HF_MAN_ID_DECODE(i, h, f, o, l)                                     \
00163     f = *(uint8_t *)i++;                                                      \
00164     UINT64DECODE_VAR((i), (o), (h)->heap_off_size);                           \
00165     UINT64DECODE_VAR((i), (l), (h)->heap_len_size)
00166 
00167 /* Free space section types for fractal heap */
00168 /* (values stored in free space data structures in file) */
00169 #define H5HF_FSPACE_SECT_SINGLE         0       /* Section is a range of actual bytes in a direct block */
00170 #define H5HF_FSPACE_SECT_FIRST_ROW      1       /* Section is first range of blocks in an indirect block row */
00171 #define H5HF_FSPACE_SECT_NORMAL_ROW     2       /* Section is a range of blocks in an indirect block row */
00172 #define H5HF_FSPACE_SECT_INDIRECT      3       /* Section is a span of blocks in an indirect block */
00173 
00174 /* Flags for 'op' operations */
00175 #define H5HF_OP_MODIFY          0x0001          /* Operation will modify object */
00176 #define H5HF_OP_FLAGS           (H5HF_OP_MODIFY)        /* Bit-wise OR of all op flags */
00177 
00178 /****************************/
00179 /* Package Private Typedefs */
00180 /****************************/
00181 
00182 /* Doubling-table info */
00183 typedef struct H5HF_dtable_t {
00184     /* Immutable, pre-set information for table */
00185     H5HF_dtable_cparam_t    cparam;     /* Creation parameters for table */
00186 
00187     /* Derived information (stored, varies during lifetime of table) */
00188     haddr_t     table_addr;     /* Address of first block for table */
00189                                 /* Undefined if no space allocated for table */
00190     unsigned    curr_root_rows; /* Current number of rows in the root indirect block */
00191                                 /* 0 indicates that the TABLE_ADDR field points
00192                                  * to direct block (of START_BLOCK_SIZE) instead
00193                                  * of indirect root block.
00194                                  */
00195 
00196     /* Computed information (not stored) */
00197     unsigned    max_root_rows;      /* Maximum # of rows in root indirect block */
00198     unsigned    max_direct_rows;    /* Maximum # of direct rows in any indirect block */
00199     unsigned    start_bits;         /* # of bits for starting block size (i.e. log2(start_block_size)) */
00200     unsigned    max_direct_bits;    /* # of bits for max. direct block size (i.e. log2(max_direct_size)) */
00201     unsigned    max_dir_blk_off_size;   /* Max. size of offsets in direct blocks */
00202     unsigned    first_row_bits;     /* # of bits in address of first row */
00203     hsize_t     num_id_first_row;   /* Number of IDs in first row of table */
00204     hsize_t     *row_block_size;    /* Block size per row of indirect block */
00205     hsize_t     *row_block_off;     /* Cumulative offset per row of indirect block */
00206     hsize_t     *row_tot_dblock_free;   /* Total free space in dblocks for this row */
00207                                     /* (For indirect block rows, it's the total
00208                                      * free space in all direct blocks referenced
00209                                      * from the indirect block)
00210                                      */
00211     size_t      *row_max_dblock_free;   /* Max. free space in dblocks for this row */
00212                                     /* (For indirect block rows, it's the maximum
00213                                      * free space in a direct block referenced
00214                                      * from the indirect block)
00215                                      */
00216 } H5HF_dtable_t;
00217 
00218 /* Fractal heap free list info (forward decl - defined in H5HFflist.c) */
00219 typedef struct H5HF_freelist_t H5HF_freelist_t;
00220 
00221 /* Forward decl indirect block info */
00222 typedef struct H5HF_indirect_t H5HF_indirect_t;
00223 
00224 /* Fractal heap block location */
00225 typedef struct H5HF_block_loc_t {
00226     /* Necessary table fields */
00227     unsigned    row;            /* Row of block in doubling table             */
00228     unsigned    col;            /* Column of block in doubling table          */
00229 
00230     /* Derived/computed/cached table fields */
00231     unsigned    entry;          /* Entry of block in doubling table           */
00232 
00233     /* Infrastructure */
00234     H5HF_indirect_t *context;   /* Pointer to the indirect block containing the block */
00235     struct H5HF_block_loc_t *up;  /* Pointer to next level up in the stack of levels */
00236 } H5HF_block_loc_t;
00237 
00238 /* Fractal heap block iterator info */
00239 typedef struct H5HF_block_iter_t {
00240     hbool_t ready;              /* Set if iterator is finished initializing   */
00241     H5HF_block_loc_t *curr;     /* Pointer to the current level information for iterator */
00242 } H5HF_block_iter_t;
00243 
00244 /* Fractal heap free space section info */
00245 typedef struct H5HF_free_section_t {
00246     H5FS_section_info_t sect_info;              /* Free space section information (must be first in struct) */
00247     union {
00248         struct {
00249             H5HF_indirect_t *parent;            /* Indirect block parent for free section's direct block */
00250             unsigned par_entry;                 /* Entry of free section's direct block in parent indirect block */
00251         } single;
00252         struct {
00253             struct H5HF_free_section_t *under;  /* Pointer to indirect block underlying row section */
00254             unsigned    row;                    /* Row for range of blocks */
00255             unsigned    col;                    /* Column for range of blocks */
00256             unsigned    num_entries;            /* Number of entries covered */
00257 
00258             /* Fields that aren't stored */
00259             hbool_t     checked_out;            /* Flag to indicate that a row section is temporarily out of the free space manager */
00260         } row;
00261         struct {
00262             /* Holds either a pointer to an indirect block (if its "live") or
00263              *  the block offset of it's indirect block (if its "serialized")
00264              *  (This allows the indirect block that the section is within to
00265              *          be compared with other sections, whether it's serialized
00266              *          or not)
00267              */
00268             union {
00269                 H5HF_indirect_t *iblock;        /* Indirect block for free section */
00270                 hsize_t iblock_off;             /* Indirect block offset in "heap space" */
00271             } u;
00272             unsigned    row;                    /* Row for range of blocks */
00273             unsigned    col;                    /* Column for range of blocks */
00274             unsigned    num_entries;            /* Number of entries covered */
00275 
00276             /* Fields that aren't stored */
00277             struct H5HF_free_section_t *parent; /* Pointer to "parent" indirect section */
00278             unsigned    par_entry;              /* Entry within parent indirect section */
00279             hsize_t     span_size;              /* Size of space tracked, in "heap space" */
00280             unsigned    iblock_entries;         /* Number of entries in indirect block where section is located */
00281             unsigned    rc;                     /* Reference count of outstanding row & child indirect sections */
00282             unsigned    dir_nrows;              /* Number of direct rows in section */
00283             struct H5HF_free_section_t **dir_rows;  /* Array of pointers to outstanding row sections */
00284             unsigned    indir_nents;            /* Number of indirect entries in section */
00285             struct H5HF_free_section_t **indir_ents; /* Array of pointers to outstanding child indirect sections */
00286         } indirect;
00287     } u;
00288 } H5HF_free_section_t;
00289 
00290 /* The fractal heap header information */
00291 /* (Each fractal heap header has certain information that is shared across all
00292  * the instances of blocks in that fractal heap)
00293  */
00294 typedef struct H5HF_hdr_t {
00295     /* Information for H5AC cache functions, _must_ be first field in structure */
00296     H5AC_info_t cache_info;
00297 
00298     /* General header information (stored in header) */
00299     unsigned    id_len;         /* Size of heap IDs (in bytes) */
00300     unsigned    filter_len;     /* Size of I/O filter information (in bytes) */
00301 
00302     /* Flags for heap settings (stored in status byte in header) */
00303     hbool_t     debug_objs;     /* Is the heap storing objects in 'debug' format */
00304     hbool_t     write_once;     /* Is heap being written in "write once" mode? */
00305     hbool_t     huge_ids_wrapped; /* Have "huge" object IDs wrapped around? */
00306     hbool_t     checksum_dblocks; /* Should the direct blocks in the heap be checksummed? */
00307 
00308     /* Doubling table information (partially stored in header) */
00309     /* (Partially set by user, partially derived/updated internally) */
00310     H5HF_dtable_t man_dtable;   /* Doubling-table info for managed objects */
00311 
00312     /* Free space information for managed objects (stored in header) */
00313     hsize_t     total_man_free; /* Total amount of free space in managed blocks */
00314     haddr_t     fs_addr;        /* Address of free space header on disk */
00315 
00316     /* "Huge" object support (stored in header) */
00317     uint32_t    max_man_size;   /* Max. size of object to manage in doubling table */
00318     hsize_t     huge_next_id;   /* Next ID to use for indirectly tracked 'huge' object */
00319     haddr_t     huge_bt2_addr;  /* Address of v2 B-tree for tracking "huge" object info */
00320 
00321     /* I/O filter support (stored in header, if any are used) */
00322     H5O_pline_t pline;          /* I/O filter pipeline for heap objects */
00323     size_t      pline_root_direct_size;    /* Size of filtered root direct block */
00324     unsigned    pline_root_direct_filter_mask; /* I/O filter mask for filtered root direct block */
00325 
00326     /* Statistics for heap (stored in header) */
00327     hsize_t     man_size;       /* Total amount of 'managed' space in heap */
00328     hsize_t     man_alloc_size; /* Total amount of allocated 'managed' space in heap */
00329     hsize_t     man_iter_off;   /* Offset of iterator in 'managed' heap space */
00330     hsize_t     man_nobjs;      /* Number of 'managed' objects in heap */
00331     hsize_t     huge_size;      /* Total size of 'huge' objects in heap */
00332     hsize_t     huge_nobjs;     /* Number of 'huge' objects in heap */
00333     hsize_t     tiny_size;      /* Total size of 'tiny' objects in heap */
00334     hsize_t     tiny_nobjs;     /* Number of 'tiny' objects in heap */
00335 
00336     /* Cached/computed values (not stored in header) */
00337     size_t      rc;             /* Reference count of heap's components using heap header */
00338     hbool_t     dirty;          /* Shared info is modified */
00339     haddr_t     heap_addr;      /* Address of heap header in the file */
00340     size_t      heap_size;      /* Size of heap header in the file */
00341     H5AC_protect_t mode;        /* Access mode for heap */
00342     H5F_t      *f;              /* Pointer to file for heap */
00343     size_t      file_rc;        /* Reference count of files using heap header */
00344     hbool_t     pending_delete; /* Heap is pending deletion */
00345     size_t      sizeof_size;    /* Size of file sizes */
00346     size_t      sizeof_addr;    /* Size of file addresses */
00347     struct H5HF_indirect_t *root_iblock;    /* Pointer to pinned root indirect block */
00348     H5FS_t      *fspace;        /* Free space list for objects in heap */
00349     H5HF_block_iter_t next_block;   /* Block iterator for searching for next block with space */
00350     hsize_t     huge_max_id;    /* Max. 'huge' heap ID before rolling 'huge' heap IDs over */
00351     hbool_t     huge_ids_direct; /* Flag to indicate that 'huge' object's offset & length are stored directly in heap ID */
00352     size_t      tiny_max_len;   /* Max. size of tiny objects for this heap */
00353     hbool_t     tiny_len_extended; /* Flag to indicate that 'tiny' object's length is stored in extended form (i.e. w/extra byte) */
00354     unsigned char huge_id_size; /* Size of 'huge' heap IDs (in bytes) */
00355     unsigned char heap_off_size; /* Size of heap offsets (in bytes) */
00356     unsigned char heap_len_size; /* Size of heap ID lengths (in bytes) */
00357 } H5HF_hdr_t;
00358 
00359 /* Common indirect block doubling table entry */
00360 /* (common between entries pointing to direct & indirect child blocks) */
00361 typedef struct H5HF_indirect_ent_t {
00362     haddr_t     addr;           /* Direct block's address                     */
00363 } H5HF_indirect_ent_t;
00364 
00365 /* Extern indirect block doubling table entry for compressed direct blocks */
00366 /* (only exists for indirect blocks in heaps that have I/O filters) */
00367 typedef struct H5HF_indirect_filt_ent_t {
00368     size_t     size;            /* Size of child direct block, after passing though I/O filters */
00369     unsigned    filter_mask;    /* Excluded filters for child direct block */
00370 } H5HF_indirect_filt_ent_t;
00371 
00372 /* Fractal heap indirect block */
00373 struct H5HF_indirect_t {
00374     /* Information for H5AC cache functions, _must_ be first field in structure */
00375     H5AC_info_t cache_info;
00376 
00377     /* Internal heap information (not stored) */
00378     size_t      rc;             /* Reference count of objects using this block */
00379     H5HF_hdr_t  *hdr;           /* Shared heap header info                    */
00380     struct H5HF_indirect_t *parent;     /* Shared parent indirect block info  */
00381     unsigned    par_entry;      /* Entry in parent's table                    */
00382     haddr_t     addr;           /* Address of this indirect block on disk     */
00383     size_t      size;           /* Size of indirect block on disk             */
00384     unsigned    nrows;          /* Total # of rows in indirect block          */
00385     unsigned    max_rows;       /* Max. # of rows in indirect block           */
00386     unsigned    nchildren;      /* Number of child blocks                     */
00387     unsigned    max_child;      /* Max. offset used in child entries          */
00388     struct H5HF_indirect_t **child_iblocks; /* Array of pointers to pinned child indirect blocks */
00389 
00390     /* Stored values */
00391     hsize_t     block_off;      /* Offset of the block within the heap's address space */
00392     H5HF_indirect_ent_t *ents;  /* Pointer to block entry table               */
00393     H5HF_indirect_filt_ent_t *filt_ents;    /* Pointer to filtered information for direct blocks */
00394 };
00395 
00396 /* A fractal heap direct block */
00397 typedef struct H5HF_direct_t {
00398     /* Information for H5AC cache functions, _must_ be first field in structure */
00399     H5AC_info_t cache_info;
00400 
00401     /* Internal heap information */
00402     H5HF_hdr_t  *hdr;           /* Shared heap header info                    */
00403     H5HF_indirect_t *parent;    /* Shared parent indirect block info          */
00404     unsigned    par_entry;      /* Entry in parent's table                    */
00405     size_t      size;           /* Size of direct block                       */
00406     hsize_t     file_size;      /* Size of direct block in file (only valid when block's space is being freed) */
00407     unsigned    blk_off_size;   /* Size of offsets in the block               */
00408     uint8_t     *blk;           /* Pointer to buffer containing block data    */
00409 
00410     /* Stored values */
00411     hsize_t     block_off;      /* Offset of the block within the heap's address space */
00412 } H5HF_direct_t;
00413 
00414 /* Fractal heap */
00415 struct H5HF_t {
00416     H5HF_hdr_t  *hdr;           /* Pointer to internal fractal heap header info */
00417     H5F_t      *f;              /* Pointer to file for heap */
00418 };
00419 
00420 /* Fractal heap "parent info" (for loading a block) */
00421 typedef struct H5HF_parent_t {
00422     H5HF_hdr_t *hdr;                /* Pointer to heap header info */
00423     H5HF_indirect_t *iblock;    /* Pointer to parent indirect block */
00424     unsigned entry;             /* Location of block in parent's entry table */
00425 } H5HF_parent_t;
00426 
00427 /* Typedef for indirectly accessed 'huge' object's records in the v2 B-tree */
00428 typedef struct H5HF_huge_bt2_indir_rec_t {
00429     haddr_t addr;       /* Address of the object in the file */
00430     hsize_t len;        /* Length of the object in the file */
00431     hsize_t id;         /* ID used for object (not used for 'huge' objects directly accessed) */
00432 } H5HF_huge_bt2_indir_rec_t;
00433 
00434 /* Typedef for indirectly accessed, filtered 'huge' object's records in the v2 B-tree */
00435 typedef struct H5HF_huge_bt2_filt_indir_rec_t {
00436     haddr_t addr;       /* Address of the filtered object in the file */
00437     hsize_t len;        /* Length of the filtered object in the file */
00438     unsigned filter_mask;   /* I/O pipeline filter mask for filtered object in the file */
00439     hsize_t obj_size;   /* Size of the de-filtered object in memory */
00440     hsize_t id;         /* ID used for object (not used for 'huge' objects directly accessed) */
00441 } H5HF_huge_bt2_filt_indir_rec_t;
00442 
00443 /* Typedef for directly accessed 'huge' object's records in the v2 B-tree */
00444 typedef struct H5HF_huge_bt2_dir_rec_t {
00445     haddr_t addr;       /* Address of the object in the file */
00446     hsize_t len;        /* Length of the object in the file */
00447 } H5HF_huge_bt2_dir_rec_t;
00448 
00449 /* Typedef for directly accessed, filtered 'huge' object's records in the v2 B-tree */
00450 typedef struct H5HF_huge_bt2_filt_dir_rec_t {
00451     haddr_t addr;       /* Address of the filtered object in the file */
00452     hsize_t len;        /* Length of the filtered object in the file */
00453     unsigned filter_mask;   /* I/O pipeline filter mask for filtered object in the file */
00454     hsize_t obj_size;   /* Size of the de-filtered object in memory */
00455 } H5HF_huge_bt2_filt_dir_rec_t;
00456 
00457 /* User data for free space section 'add' callback */
00458 typedef struct {
00459     H5HF_hdr_t *hdr;            /* Fractal heap header */
00460     hid_t dxpl_id;              /* DXPL ID for operation */
00461 } H5HF_sect_add_ud1_t;
00462 
00463 /* User data for v2 B-tree 'remove' callback on 'huge' objects */
00464 typedef struct {
00465     H5HF_hdr_t *hdr;            /* Fractal heap header (in) */
00466     hid_t dxpl_id;              /* DXPL ID for operation (in) */
00467     hsize_t obj_len;            /* Length of object removed (out) */
00468 } H5HF_huge_remove_ud1_t;
00469 
00470 /*****************************/
00471 /* Package Private Variables */
00472 /*****************************/
00473 
00474 /* H5HF header inherits cache-like properties from H5AC */
00475 H5_DLLVAR const H5AC_class_t H5AC_FHEAP_HDR[1];
00476 
00477 /* H5HF indirect block inherits cache-like properties from H5AC */
00478 H5_DLLVAR const H5AC_class_t H5AC_FHEAP_IBLOCK[1];
00479 
00480 /* H5HF direct block inherits cache-like properties from H5AC */
00481 H5_DLLVAR const H5AC_class_t H5AC_FHEAP_DBLOCK[1];
00482 
00483 /* The v2 B-tree class for tracking indirectly accessed 'huge' objects */
00484 H5_DLLVAR const H5B2_class_t H5HF_BT2_INDIR[1];
00485 
00486 /* The v2 B-tree class for tracking indirectly accessed filtered 'huge' objects */
00487 H5_DLLVAR const H5B2_class_t H5HF_BT2_FILT_INDIR[1];
00488 
00489 /* The v2 B-tree class for tracking directly accessed 'huge' objects */
00490 H5_DLLVAR const H5B2_class_t H5HF_BT2_DIR[1];
00491 
00492 /* The v2 B-tree class for tracking directly accessed filtered 'huge' objects */
00493 H5_DLLVAR const H5B2_class_t H5HF_BT2_FILT_DIR[1];
00494 
00495 /* H5HF single section inherits serializable properties from H5FS_section_class_t */
00496 H5_DLLVAR H5FS_section_class_t H5HF_FSPACE_SECT_CLS_SINGLE[1];
00497 
00498 /* H5HF 'first' row section inherits serializable properties from H5FS_section_class_t */
00499 H5_DLLVAR H5FS_section_class_t H5HF_FSPACE_SECT_CLS_FIRST_ROW[1];
00500 
00501 /* H5HF 'normal' row section inherits serializable properties from H5FS_section_class_t */
00502 H5_DLLVAR H5FS_section_class_t H5HF_FSPACE_SECT_CLS_NORMAL_ROW[1];
00503 
00504 /* H5HF indirect section inherits serializable properties from H5FS_section_class_t */
00505 H5_DLLVAR H5FS_section_class_t H5HF_FSPACE_SECT_CLS_INDIRECT[1];
00506 
00507 /* Declare a free list to manage the H5HF_hdr_t struct */
00508 H5FL_EXTERN(H5HF_hdr_t);
00509 
00510 /* Declare a free list to manage the H5HF_indirect_t struct */
00511 H5FL_EXTERN(H5HF_indirect_t);
00512 
00513 /* Declare a free list to manage the H5HF_indirect_ent_t sequence information */
00514 H5FL_SEQ_EXTERN(H5HF_indirect_ent_t);
00515 
00516 /* Declare a free list to manage the H5HF_indirect_filt_ent_t sequence information */
00517 H5FL_SEQ_EXTERN(H5HF_indirect_filt_ent_t);
00518 
00519 /* Declare a free list to manage the H5HF_indirect_t * sequence information */
00520 typedef H5HF_indirect_t *H5HF_indirect_ptr_t;
00521 H5FL_SEQ_EXTERN(H5HF_indirect_ptr_t);
00522 
00523 /* Declare a free list to manage the H5HF_direct_t struct */
00524 H5FL_EXTERN(H5HF_direct_t);
00525 
00526 /* Declare a free list to manage heap direct block data to/from disk */
00527 H5FL_BLK_EXTERN(direct_block);
00528 
00529 
00530 /******************************/
00531 /* Package Private Prototypes */
00532 /******************************/
00533 
00534 /* Doubling table routines */
00535 H5_DLL herr_t H5HF_dtable_init(H5HF_dtable_t *dtable);
00536 H5_DLL herr_t H5HF_dtable_dest(H5HF_dtable_t *dtable);
00537 H5_DLL herr_t H5HF_dtable_lookup(const H5HF_dtable_t *dtable, hsize_t off,
00538     unsigned *row, unsigned *col);
00539 H5_DLL unsigned H5HF_dtable_size_to_row(const H5HF_dtable_t *dtable, size_t block_size);
00540 H5_DLL unsigned H5HF_dtable_size_to_rows(const H5HF_dtable_t *dtable, hsize_t size);
00541 H5_DLL hsize_t H5HF_dtable_span_size(const H5HF_dtable_t *dtable, unsigned start_row,
00542     unsigned start_col, unsigned num_entries);
00543 
00544 /* Heap header routines */
00545 H5_DLL H5HF_hdr_t * H5HF_hdr_alloc(H5F_t *f);
00546 H5_DLL haddr_t H5HF_hdr_create(H5F_t *f, hid_t dxpl_id, const H5HF_create_t *cparam);
00547 H5_DLL herr_t H5HF_hdr_finish_init_phase1(H5HF_hdr_t *hdr);
00548 H5_DLL herr_t H5HF_hdr_finish_init_phase2(H5HF_hdr_t *hdr);
00549 H5_DLL herr_t H5HF_hdr_finish_init(H5HF_hdr_t *hdr);
00550 H5_DLL herr_t H5HF_hdr_incr(H5HF_hdr_t *hdr);
00551 H5_DLL herr_t H5HF_hdr_decr(H5HF_hdr_t *hdr);
00552 H5_DLL herr_t H5HF_hdr_fuse_incr(H5HF_hdr_t *hdr);
00553 H5_DLL size_t H5HF_hdr_fuse_decr(H5HF_hdr_t *hdr);
00554 H5_DLL herr_t H5HF_hdr_dirty(H5HF_hdr_t *hdr);
00555 H5_DLL herr_t H5HF_hdr_adj_free(H5HF_hdr_t *hdr, ssize_t amt);
00556 H5_DLL herr_t H5HF_hdr_adjust_heap(H5HF_hdr_t *hdr, hsize_t new_size, hssize_t extra_free);
00557 H5_DLL herr_t H5HF_hdr_inc_alloc(H5HF_hdr_t *hdr, size_t alloc_size);
00558 H5_DLL herr_t H5HF_hdr_start_iter(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, hsize_t curr_off, unsigned curr_entry);
00559 H5_DLL herr_t H5HF_hdr_skip_blocks(H5HF_hdr_t *hdr, hid_t dxpl_id,
00560     H5HF_indirect_t *iblock, unsigned start_entry, unsigned nentries);
00561 H5_DLL herr_t H5HF_hdr_update_iter(H5HF_hdr_t *hdr, hid_t dxpl_id, size_t min_dblock_size);
00562 H5_DLL herr_t H5HF_hdr_inc_iter(H5HF_hdr_t *hdr, hsize_t adv_size, unsigned nentries);
00563 H5_DLL herr_t H5HF_hdr_reverse_iter(H5HF_hdr_t *hdr, hid_t dxpl_id,
00564     haddr_t dblock_addr);
00565 H5_DLL herr_t H5HF_hdr_reset_iter(H5HF_hdr_t *hdr, hsize_t curr_off);
00566 H5_DLL herr_t H5HF_hdr_empty(H5HF_hdr_t *hdr);
00567 H5_DLL herr_t H5HF_hdr_delete(H5HF_hdr_t *hdr, hid_t dxpl_id);
00568 
00569 /* Indirect block routines */
00570 H5_DLL herr_t H5HF_iblock_incr(H5HF_indirect_t *iblock);
00571 H5_DLL herr_t H5HF_iblock_decr(H5HF_indirect_t *iblock);
00572 H5_DLL herr_t H5HF_iblock_dirty(H5HF_indirect_t *iblock);
00573 H5_DLL herr_t H5HF_man_iblock_root_create(H5HF_hdr_t *hdr, hid_t dxpl_id,
00574     size_t min_dblock_size);
00575 H5_DLL herr_t H5HF_man_iblock_root_double(H5HF_hdr_t *hdr, hid_t dxpl_id,
00576     size_t min_dblock_size);
00577 H5_DLL herr_t H5HF_man_iblock_alloc_row(H5HF_hdr_t *hdr, hid_t dxpl_id,
00578     H5HF_free_section_t **sec_node);
00579 H5_DLL herr_t H5HF_man_iblock_create(H5HF_hdr_t *hdr, hid_t dxpl_id,
00580     H5HF_indirect_t *par_iblock, unsigned par_entry, unsigned nrows,
00581     unsigned max_rows, haddr_t *addr_p);
00582 H5_DLL H5HF_indirect_t *H5HF_man_iblock_protect(H5HF_hdr_t *hdr, hid_t dxpl_id,
00583     haddr_t iblock_addr, unsigned iblock_nrows,
00584     H5HF_indirect_t *par_iblock, unsigned par_entry, hbool_t must_protect,
00585     H5AC_protect_t rw, hbool_t *did_protect);
00586 H5_DLL herr_t H5HF_man_iblock_unprotect(H5HF_indirect_t *iblock, hid_t dxpl_id,
00587     unsigned cache_flags, hbool_t did_protect);
00588 H5_DLL herr_t H5HF_man_iblock_attach(H5HF_indirect_t *iblock, unsigned entry,
00589     haddr_t dblock_addr);
00590 H5_DLL herr_t H5HF_man_iblock_detach(H5HF_indirect_t *iblock, hid_t dxpl_id, unsigned entry);
00591 H5_DLL herr_t H5HF_man_iblock_entry_addr(H5HF_indirect_t *iblock, unsigned entry,
00592     haddr_t *child_addr);
00593 H5_DLL herr_t H5HF_man_iblock_delete(H5HF_hdr_t *hdr, hid_t dxpl_id,
00594     haddr_t iblock_addr, unsigned iblock_nrows, H5HF_indirect_t *par_iblock,
00595     unsigned par_entry);
00596 H5_DLL herr_t H5HF_man_iblock_size(H5F_t *f, hid_t dxpl_id, H5HF_hdr_t *hdr,
00597     haddr_t iblock_addr, unsigned nrows, H5HF_indirect_t *par_iblock, unsigned par_entry, hsize_t *heap_size/*out*/);
00598 
00599 /* Direct block routines */
00600 H5_DLL herr_t H5HF_man_dblock_new(H5HF_hdr_t *fh, hid_t dxpl_id, size_t request,
00601     H5HF_free_section_t **ret_sec_node);
00602 H5_DLL herr_t H5HF_man_dblock_create(hid_t dxpl_id, H5HF_hdr_t *hdr,
00603     H5HF_indirect_t *par_iblock, unsigned par_entry, haddr_t *addr_p,
00604     H5HF_free_section_t **ret_sec_node);
00605 H5_DLL herr_t H5HF_man_dblock_destroy(H5HF_hdr_t *hdr, hid_t dxpl_id,
00606     H5HF_direct_t *dblock, haddr_t dblock_addr);
00607 H5_DLL H5HF_direct_t *H5HF_man_dblock_protect(H5HF_hdr_t *hdr, hid_t dxpl_id,
00608     haddr_t dblock_addr, size_t dblock_size,
00609     H5HF_indirect_t *par_iblock, unsigned par_entry,
00610     H5AC_protect_t rw);
00611 H5_DLL herr_t H5HF_man_dblock_locate(H5HF_hdr_t *hdr, hid_t dxpl_id,
00612     hsize_t obj_off, H5HF_indirect_t **par_iblock,
00613     unsigned *par_entry, hbool_t *par_did_protect, H5AC_protect_t rw);
00614 H5_DLL herr_t H5HF_man_dblock_delete(H5F_t *f, hid_t dxpl_id, haddr_t dblock_addr,
00615     hsize_t dblock_size);
00616 
00617 /* Managed object routines */
00618 H5_DLL herr_t H5HF_man_insert(H5HF_hdr_t *fh, hid_t dxpl_id, size_t obj_size,
00619     const void *obj, void *id);
00620 H5_DLL herr_t H5HF_man_read(H5HF_hdr_t *fh, hid_t dxpl_id, const uint8_t *id,
00621     void *obj);
00622 H5_DLL herr_t H5HF_man_write(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id,
00623     const void *obj);
00624 H5_DLL herr_t H5HF_man_op(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id,
00625     H5HF_operator_t op, void *op_data);
00626 H5_DLL herr_t H5HF_man_remove(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id);
00627 
00628 /* 'Huge' object routines */
00629 H5_DLL herr_t H5HF_huge_init(H5HF_hdr_t *hdr);
00630 H5_DLL herr_t H5HF_huge_insert(H5HF_hdr_t *hdr, hid_t dxpl_id, size_t obj_size,
00631     void *obj, void *id);
00632 H5_DLL herr_t H5HF_huge_get_obj_len(H5HF_hdr_t *hdr, hid_t dxpl_id,
00633     const uint8_t *id, size_t *obj_len_p);
00634 H5_DLL herr_t H5HF_huge_read(H5HF_hdr_t *fh, hid_t dxpl_id, const uint8_t *id,
00635     void *obj);
00636 H5_DLL herr_t H5HF_huge_write(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id,
00637     const void *obj);
00638 H5_DLL herr_t H5HF_huge_op(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id,
00639     H5HF_operator_t op, void *op_data);
00640 H5_DLL herr_t H5HF_huge_remove(H5HF_hdr_t *fh, hid_t dxpl_id, const uint8_t *id);
00641 H5_DLL herr_t H5HF_huge_term(H5HF_hdr_t *hdr, hid_t dxpl_id);
00642 H5_DLL herr_t H5HF_huge_delete(H5HF_hdr_t *hdr, hid_t dxpl_id);
00643 
00644 /* 'Tiny' object routines */
00645 H5_DLL herr_t H5HF_tiny_init(H5HF_hdr_t *hdr);
00646 H5_DLL herr_t H5HF_tiny_insert(H5HF_hdr_t *hdr, size_t obj_size, const void *obj,
00647     void *id);
00648 H5_DLL herr_t H5HF_tiny_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id,
00649     size_t *obj_len_p);
00650 H5_DLL herr_t H5HF_tiny_read(H5HF_hdr_t *fh, const uint8_t *id, void *obj);
00651 H5_DLL herr_t H5HF_tiny_op(H5HF_hdr_t *hdr, const uint8_t *id,
00652     H5HF_operator_t op, void *op_data);
00653 H5_DLL herr_t H5HF_tiny_remove(H5HF_hdr_t *fh, const uint8_t *id);
00654 
00655 /* Metadata cache callbacks */
00656 H5_DLL herr_t H5HF_cache_hdr_dest(H5F_t *f, H5HF_hdr_t *hdr);
00657 H5_DLL herr_t H5HF_cache_dblock_dest(H5F_t *f, H5HF_direct_t *dblock);
00658 H5_DLL herr_t H5HF_cache_iblock_dest(H5F_t *f, H5HF_indirect_t *iblock);
00659 
00660 /* Debugging routines for dumping file structures */
00661 H5_DLL herr_t H5HF_hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr,
00662     FILE *stream, int indent, int fwidth);
00663 H5_DLL herr_t H5HF_dblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr,
00664     FILE *stream, int indent, int fwidth, haddr_t hdr_addr, size_t nrec);
00665 H5_DLL herr_t H5HF_iblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr,
00666     FILE *stream, int indent, int fwidth, haddr_t hdr_addr, unsigned nrows);
00667 
00668 /* Block iteration routines */
00669 H5_DLL herr_t H5HF_man_iter_init(H5HF_block_iter_t *biter);
00670 H5_DLL herr_t H5HF_man_iter_start_offset(H5HF_hdr_t *hdr, hid_t dxpl_id,
00671     H5HF_block_iter_t *biter, hsize_t offset);
00672 H5_DLL herr_t H5HF_man_iter_start_entry(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter,
00673     H5HF_indirect_t *iblock, unsigned start_entry);
00674 H5_DLL herr_t H5HF_man_iter_set_entry(const H5HF_hdr_t *hdr,
00675     H5HF_block_iter_t *biter, unsigned entry);
00676 H5_DLL herr_t H5HF_man_iter_next(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter,
00677     unsigned nentries);
00678 H5_DLL herr_t H5HF_man_iter_up(H5HF_block_iter_t *biter);
00679 H5_DLL herr_t H5HF_man_iter_down(H5HF_block_iter_t *biter, H5HF_indirect_t *iblock);
00680 H5_DLL herr_t H5HF_man_iter_reset(H5HF_block_iter_t *biter);
00681 H5_DLL herr_t H5HF_man_iter_curr(H5HF_block_iter_t *biter, unsigned *row, unsigned *col,
00682     unsigned *entry, H5HF_indirect_t **block);
00683 H5_DLL herr_t H5HF_man_iter_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter,
00684     hsize_t *offset);
00685 H5_DLL hbool_t H5HF_man_iter_ready(H5HF_block_iter_t *biter);
00686 
00687 /* Free space manipulation routines */
00688 H5_DLL herr_t H5HF_space_start(H5HF_hdr_t *hdr, hid_t dxpl_id, hbool_t may_create);
00689 H5_DLL herr_t H5HF_space_add(H5HF_hdr_t *hdr, hid_t dxpl_id,
00690     H5HF_free_section_t *node, unsigned flags);
00691 H5_DLL htri_t H5HF_space_find(H5HF_hdr_t *hdr, hid_t dxpl_id, hsize_t request,
00692     H5HF_free_section_t **node);
00693 H5_DLL herr_t H5HF_space_size(H5HF_hdr_t *hdr, hid_t dxpl_id, hsize_t *fs_size);
00694 H5_DLL herr_t H5HF_space_remove(H5HF_hdr_t *hdr, hid_t dxpl_id,
00695     H5HF_free_section_t *node);
00696 H5_DLL herr_t H5HF_space_close(H5HF_hdr_t *hdr, hid_t dxpl_id);
00697 H5_DLL herr_t H5HF_space_delete(H5HF_hdr_t *hdr, hid_t dxpl_id);
00698 H5_DLL herr_t H5HF_space_sect_change_class(H5HF_hdr_t *hdr, hid_t dxpl_id,
00699     H5HF_free_section_t *sect, unsigned new_class);
00700 
00701 /* Free space section routines */
00702 H5_DLL H5HF_free_section_t *H5HF_sect_single_new(hsize_t sect_off,
00703     size_t sect_size, H5HF_indirect_t *parent, unsigned par_entry);
00704 H5_DLL herr_t H5HF_sect_single_revive(H5HF_hdr_t *hdr, hid_t dxpl_id,
00705     H5HF_free_section_t *sect);
00706 H5_DLL herr_t H5HF_sect_single_dblock_info(H5HF_hdr_t *hdr, hid_t dxpl_id,
00707     H5HF_free_section_t *sect, haddr_t *dblock_addr, size_t *dblock_size);
00708 H5_DLL herr_t H5HF_sect_single_reduce(H5HF_hdr_t *hdr, hid_t dxpl_id,
00709     H5HF_free_section_t *sect, size_t amt);
00710 H5_DLL herr_t H5HF_sect_row_revive(H5HF_hdr_t *hdr, hid_t dxpl_id,
00711     H5HF_free_section_t *sect);
00712 H5_DLL herr_t H5HF_sect_row_reduce(H5HF_hdr_t *hdr, hid_t dxpl_id,
00713     H5HF_free_section_t *sect, unsigned *entry_p);
00714 H5_DLL H5HF_indirect_t *H5HF_sect_row_get_iblock(H5HF_free_section_t *sect);
00715 H5_DLL herr_t H5HF_sect_indirect_add(H5HF_hdr_t *hdr, hid_t dxpl_id,
00716     H5HF_indirect_t *iblock, unsigned start_entry, unsigned nentries);
00717 
00718 /* Internal operator callbacks */
00719 H5_DLL herr_t H5HF_op_read(const void *obj, size_t obj_len, void *op_data);
00720 H5_DLL herr_t H5HF_op_write(const void *obj, size_t obj_len, void *op_data);
00721 
00722 /* Testing routines */
00723 #ifdef H5HF_TESTING
00724 H5_DLL herr_t H5HF_get_cparam_test(const H5HF_t *fh, H5HF_create_t *cparam);
00725 H5_DLL int H5HF_cmp_cparam_test(const H5HF_create_t *cparam1, const H5HF_create_t *cparam2);
00726 H5_DLL unsigned H5HF_get_max_root_rows(const H5HF_t *fh);
00727 H5_DLL unsigned H5HF_get_dtable_width_test(const H5HF_t *fh);
00728 H5_DLL unsigned H5HF_get_dtable_max_drows_test(const H5HF_t *fh);
00729 H5_DLL unsigned H5HF_get_iblock_max_drows_test(const H5HF_t *fh, unsigned pos);
00730 H5_DLL hsize_t H5HF_get_dblock_size_test(const H5HF_t *fh, unsigned row);
00731 H5_DLL hsize_t H5HF_get_dblock_free_test(const H5HF_t *fh, unsigned row);
00732 H5_DLL herr_t H5HF_get_id_off_test(const H5HF_t *fh, const void *id, hsize_t *obj_off);
00733 H5_DLL herr_t H5HF_get_id_type_test(const void *id, unsigned char *obj_type);
00734 H5_DLL herr_t H5HF_get_tiny_info_test(const H5HF_t *fh, size_t *max_len,
00735     hbool_t *len_extended);
00736 H5_DLL herr_t H5HF_get_huge_info_test(const H5HF_t *fh, hsize_t *next_id,
00737     hbool_t *ids_direct);
00738 #endif /* H5HF_TESTING */
00739 
00740 #endif /* _H5HFpkg_H */
00741