H5Fpkg.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  *              Thursday, September 28, 2000
00019  *
00020  * Purpose:     This file contains declarations which are visible only within
00021  *              the H5F package.  Source files outside the H5F package should
00022  *              include H5Fprivate.h instead.
00023  */
00024 #ifndef H5F_PACKAGE
00025 #error "Do not include this file outside the H5F package!"
00026 #endif
00027 
00028 #ifndef _H5Fpkg_H
00029 #define _H5Fpkg_H
00030 
00031 /* Get package's private header */
00032 #include "H5Fprivate.h"
00033 
00034 /* Other public headers needed by this file */
00035 #include "H5Bpublic.h"          /* B-tree header, for H5B_NUM_BTREE_ID */
00036 
00037 /* Other private headers needed by this file */
00038 #include "H5private.h"          /* Generic Functions                    */
00039 #include "H5FLprivate.h"        /* Free Lists                           */
00040 #include "H5FOprivate.h"        /* File objects                         */
00041 #include "H5FSprivate.h"        /* File free space                      */
00042 #include "H5Gprivate.h"         /* Groups                               */
00043 #include "H5Oprivate.h"         /* Object header messages               */
00044 #include "H5RCprivate.h"        /* Reference counted object functions   */
00045 
00046 /*
00047  * Feature: Define this constant on the compiler command-line if you want to
00048  *          see some debugging messages on the debug stream.
00049  */
00050 #ifdef NDEBUG
00051 #  undef H5F_DEBUG
00052 #endif
00053 
00054 /* Define the HDF5 file signature */
00055 #define H5F_SIGNATURE     "\211HDF\r\n\032\n"
00056 #define H5F_SIGNATURE_LEN 8
00057 
00058 /* Superblock status flags */
00059 #define H5F_SUPER_WRITE_ACCESS          0x01
00060 #define H5F_SUPER_FILE_OK               0x02
00061 #define H5F_SUPER_ALL_FLAGS             (H5F_SUPER_WRITE_ACCESS | H5F_SUPER_FILE_OK)
00062 
00063 /* Mask for removing private file access flags */
00064 #define H5F_ACC_PUBLIC_FLAGS    0x00ffu
00065 
00066 /* Free space section+aggregator merge flags */
00067 #define H5F_FS_MERGE_METADATA           0x01    /* Section can merge with metadata aggregator */
00068 #define H5F_FS_MERGE_RAWDATA            0x02    /* Section can merge with small 'raw' data aggregator */
00069 
00070 /* Structure for metadata & "small [raw] data" block aggregation fields */
00071 struct H5F_blk_aggr_t {
00072     unsigned long       feature_flag;   /* Feature flag type */
00073     hsize_t             alloc_size;     /* Size for allocating new blocks */
00074     hsize_t             tot_size;       /* Total amount of bytes aggregated into block */
00075     hsize_t             size;           /* Current size of block left */
00076     haddr_t             addr;           /* Location of block left */
00077 };
00078 
00079 /* Structure for metadata accumulator fields */
00080 typedef struct H5F_meta_accum_t {
00081     unsigned char      *buf;            /* Buffer to hold the accumulated metadata */
00082     haddr_t             loc;            /* File location (offset) of the accumulated metadata */
00083     size_t              size;           /* Size of the accumulated metadata buffer used (in bytes) */
00084     size_t              alloc_size;     /* Size of the accumulated metadata buffer allocated (in bytes) */
00085     hbool_t             dirty;          /* Flag to indicate that the accumulated metadata is dirty */
00086 } H5F_meta_accum_t;
00087 
00088 /* Enum for free space manager state */
00089 typedef enum H5F_fs_state_t {
00090     H5F_FS_STATE_CLOSED,                /* Free space manager is closed */
00091     H5F_FS_STATE_OPEN,                  /* Free space manager has been opened */
00092     H5F_FS_STATE_DELETING               /* Free space manager is being deleted */
00093 } H5F_fs_state_t;
00094 
00095 /* A record of the mount table */
00096 typedef struct H5F_mount_t {
00097     struct H5G_t        *group; /* Mount point group held open          */
00098     struct H5F_t        *file;  /* File mounted at that point           */
00099 } H5F_mount_t;
00100 
00101 /*
00102  * The mount table describes what files are attached to (mounted on) the file
00103  * to which this table belongs.
00104  */
00105 typedef struct H5F_mtab_t {
00106     unsigned            nmounts;/* Number of children which are mounted */
00107     unsigned            nalloc; /* Number of mount slots allocated      */
00108     H5F_mount_t         *child; /* An array of mount records            */
00109 } H5F_mtab_t;
00110 
00111 /*
00112  * Define the structure to store the file information for HDF5 files. One of
00113  * these structures is allocated per file, not per H5Fopen(). That is, set of
00114  * H5F_t structs can all point to the same H5F_file_t struct. The `nrefs'
00115  * count in this struct indicates the number of H5F_t structs which are
00116  * pointing to this struct.
00117  */
00118 typedef struct H5F_file_t {
00119     H5FD_t      *lf;            /* Lower level file handle for I/O      */
00120     unsigned    nrefs;          /* Ref count for times file is opened   */
00121     uint8_t     status_flags;   /* File status flags                    */
00122     unsigned    flags;          /* Access Permissions for file          */
00123     H5F_mtab_t  mtab;           /* File mount table             */
00124 
00125     /* Cached values from FCPL/superblock */
00126     unsigned    sym_leaf_k;     /* Size of leaves in symbol tables      */
00127     unsigned    btree_k[H5B_NUM_BTREE_ID];  /* B-tree key values for each type  */
00128     size_t      sizeof_addr;    /* Size of addresses in file            */
00129     size_t      sizeof_size;    /* Size of offsets in file              */
00130     haddr_t     base_addr;      /* Absolute base address for rel.addrs. */
00131                                 /* (superblock for file is at this offset) */
00132     haddr_t     extension_addr; /* Relative address of superblock extension     */
00133     haddr_t     sohm_addr;      /* Relative address of shared object header message table */
00134     unsigned    sohm_vers;      /* Version of shared message table on disk */
00135     unsigned    sohm_nindexes;  /* Number of shared messages indexes in the table */
00136     haddr_t     driver_addr;    /* File driver information block address*/
00137     unsigned long feature_flags; /* VFL Driver feature Flags            */
00138     haddr_t     maxaddr;        /* Maximum address for file             */
00139 
00140     H5AC_t      *cache;         /* The object cache                     */
00141     H5AC_cache_config_t
00142                 mdc_initCacheCfg; /* initial configuration for the      */
00143                                 /* metadata cache.  This structure is   */
00144                                 /* fixed at creation time and should    */
00145                                 /* not change thereafter.               */
00146     hid_t       fcpl_id;        /* File creation property list ID       */
00147     H5F_close_degree_t fc_degree;   /* File close behavior degree       */
00148     size_t      rdcc_nslots;    /* Size of raw data chunk cache (slots) */
00149     size_t      rdcc_nbytes;    /* Size of raw data chunk cache (bytes) */
00150     double      rdcc_w0;        /* Preempt read chunks first? [0.0..1.0]*/
00151     size_t      sieve_buf_size; /* Size of the data sieve buffer allocated (in bytes) */
00152     hsize_t     threshold;      /* Threshold for alignment              */
00153     hsize_t     alignment;      /* Alignment                            */
00154     unsigned    gc_ref;         /* Garbage-collect references?          */
00155     hbool_t     latest_format;  /* Always use the latest format?        */
00156     hbool_t     store_msg_crt_idx;  /* Store creation index for object header messages? */
00157     hbool_t     fam_to_sec2;    /* Is h5repart changing driver from family to sec2? */
00158     int ncwfs;                  /* Num entries on cwfs list             */
00159     struct H5HG_heap_t **cwfs;  /* Global heap cache                    */
00160     struct H5G_t *root_grp;     /* Open root group                      */
00161     H5G_entry_t *root_ent;      /* Root group symbol table entry        */
00162     haddr_t     root_addr;      /* Root group address                   */
00163     H5FO_t *open_objs;          /* Open objects in file                 */
00164     H5RC_t *grp_btree_shared;   /* Ref-counted group B-tree node info   */
00165 
00166     /* File space allocation information */
00167     unsigned fs_aggr_merge[H5FD_MEM_NTYPES];    /* Flags for whether free space can merge with aggregator(s) */
00168     H5F_fs_state_t fs_state[H5FD_MEM_NTYPES];   /* State of free space manager for each type */
00169     haddr_t fs_addr[H5FD_MEM_NTYPES];   /* Address of free space manager info for each type */
00170     H5FS_t *fs_man[H5FD_MEM_NTYPES];    /* Free space manager for each file space type */
00171     H5FD_mem_t fs_type_map[H5FD_MEM_NTYPES]; /* Mapping of "real" file space type into tracked type */
00172     H5F_blk_aggr_t meta_aggr;   /* Metadata aggregation info */
00173                                 /* (if aggregating metadata allocations) */
00174     H5F_blk_aggr_t sdata_aggr;  /* "Small data" aggregation info */
00175                                 /* (if aggregating "small data" allocations) */
00176 
00177     /* Metadata accumulator information */
00178     H5F_meta_accum_t accum;     /* Metadata accumulator info           */
00179 } H5F_file_t;
00180 
00181 /*
00182  * This is the top-level file descriptor.  One of these structures is
00183  * allocated every time H5Fopen() is called although they may contain pointers
00184  * to shared H5F_file_t structs. The reference count (nrefs) indicates the
00185  * number of times the file has been opened (the application can only open a
00186  * file once explicitly, but the library can open the file a second time to
00187  * indicate that the file is mounted on some other file).
00188  */
00189 struct H5F_t {
00190     unsigned            intent;         /* The flags passed to H5F_open()*/
00191     char                *name;          /* Name used to open file       */
00192     char                *extpath;       /* Path for searching target external link file */
00193     H5F_file_t          *shared;        /* The shared file info         */
00194     unsigned            nopen_objs;     /* Number of open object headers*/
00195     H5FO_t              *obj_count;     /* # of time each object is opened through top file structure */
00196     hid_t               file_id;        /* ID of this file              */
00197     hbool_t             closing;        /* File is in the process of being closed */
00198     struct H5F_t        *parent;        /* Parent file that this file is mounted to */
00199     unsigned            nmounts;        /* Number of children mounted to this file */
00200 };
00201 
00202 /*****************************/
00203 /* Package Private Variables */
00204 /*****************************/
00205 
00206 /* Declare a free list to manage the H5F_t struct */
00207 H5FL_EXTERN(H5F_t);
00208 
00209 /* Declare a free list to manage the H5F_file_t struct */
00210 H5FL_EXTERN(H5F_file_t);
00211 
00212 
00213 /******************************/
00214 /* Package Private Prototypes */
00215 /******************************/
00216 
00217 /* General routines */
00218 H5_DLL herr_t H5F_init(void);
00219 H5_DLL haddr_t H5F_locate_signature(H5FD_t *file, hid_t dxpl_id);
00220 
00221 /* File mount related routines */
00222 H5_DLL herr_t H5F_close_mounts(H5F_t *f);
00223 H5_DLL int H5F_term_unmount_cb(void *obj_ptr, hid_t obj_id, void *key);
00224 H5_DLL herr_t H5F_mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs);
00225 
00226 /* Superblock related routines */
00227 H5_DLL herr_t H5F_super_init(H5F_t *f, hid_t dxpl_id);
00228 H5_DLL herr_t H5F_super_write(H5F_t *f, hid_t dxpl_id);
00229 H5_DLL herr_t H5F_super_read(H5F_t *f, hid_t dxpl_id);
00230 H5_DLL herr_t H5F_super_ext_size(H5F_t *f, hid_t dxpl_id, hsize_t *super_ext_info);
00231 
00232 /* Metadata accumulator routines */
00233 H5_DLL htri_t H5F_accum_read(const H5F_t *f, hid_t dxpl_id, H5FD_mem_t type,
00234     haddr_t addr, size_t size, void *buf);
00235 H5_DLL htri_t H5F_accum_write(const H5F_t *f, hid_t dxpl_id, H5FD_mem_t type,
00236     haddr_t addr, size_t size, const void *buf);
00237 H5_DLL herr_t H5F_accum_free(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type,
00238     haddr_t addr, hsize_t size);
00239 H5_DLL herr_t H5F_accum_flush(H5F_t *f, hid_t dxpl_id);
00240 H5_DLL herr_t H5F_accum_reset(H5F_t *f);
00241 
00242 /* Shared file list related routines */
00243 H5_DLL herr_t H5F_sfile_add(H5F_file_t *shared);
00244 H5_DLL H5F_file_t * H5F_sfile_search(H5FD_t *lf);
00245 H5_DLL herr_t H5F_sfile_remove(H5F_file_t *shared);
00246 
00247 /* Testing functions */
00248 #ifdef H5F_TESTING
00249 H5_DLL herr_t H5F_get_sohm_mesg_count_test(hid_t fid, unsigned type_id,
00250     size_t *mesg_count);
00251 H5_DLL herr_t H5F_check_cached_stab_test(hid_t file_id);
00252 #endif /* H5F_TESTING */
00253 
00254 #endif /* _H5Fpkg_H */
00255