1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 * Copyright by The HDF Group. * 3 * Copyright by the Board of Trustees of the University of Illinois. * 4 * All rights reserved. * 5 * * 6 * This file is part of HDF5. The full HDF5 copyright notice, including * 7 * terms governing use, modification, and redistribution, is contained in * 8 * the COPYING file, which can be found at the root of the source code * 9 * distribution tree, or in https://www.hdfgroup.org/licenses. * 10 * If you do not have access to either file, you may request a copy from * 11 * help@hdfgroup.org. * 12 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 13 14 /*------------------------------------------------------------------------- 15 * 16 * Created: H5PBprivate.h 17 * June 2014 18 * Mohamad Chaarawi 19 * 20 *------------------------------------------------------------------------- 21 */ 22 23 #ifndef H5PBprivate_H 24 #define H5PBprivate_H 25 26 /* Include package's public header */ 27 #ifdef NOT_YET 28 #include "H5PBpublic.h" 29 #endif /* NOT_YET */ 30 31 /* Private headers needed by this header */ 32 #include "H5private.h" /* Generic Functions */ 33 #include "H5Fprivate.h" /* File access */ 34 #include "H5FLprivate.h" /* Free Lists */ 35 #include "H5SLprivate.h" /* Skip List */ 36 37 /**************************/ 38 /* Library Private Macros */ 39 /**************************/ 40 41 /****************************/ 42 /* Library Private Typedefs */ 43 /****************************/ 44 45 /* Forward declaration for a page buffer entry */ 46 struct H5PB_entry_t; 47 48 /* Typedef for the main structure for the page buffer */ 49 typedef struct H5PB_t { 50 size_t max_size; /* The total page buffer size */ 51 size_t page_size; /* Size of a single page */ 52 unsigned min_meta_perc; /* Minimum ratio of metadata entries required before evicting meta entries */ 53 unsigned min_raw_perc; /* Minimum ratio of raw data entries required before evicting raw entries */ 54 unsigned meta_count; /* Number of entries for metadata */ 55 unsigned raw_count; /* Number of entries for raw data */ 56 unsigned min_meta_count; /* Minimum # of entries for metadata */ 57 unsigned min_raw_count; /* Minimum # of entries for raw data */ 58 59 H5SL_t *slist_ptr; /* Skip list with all the active page entries */ 60 H5SL_t *mf_slist_ptr; /* Skip list containing newly allocated page entries inserted from the MF layer */ 61 62 size_t LRU_list_len; /* Number of entries in the LRU (identical to slist_ptr count) */ 63 struct H5PB_entry_t *LRU_head_ptr; /* Head pointer of the LRU */ 64 struct H5PB_entry_t *LRU_tail_ptr; /* Tail pointer of the LRU */ 65 66 H5FL_fac_head_t *page_fac; /* Factory for allocating pages */ 67 68 /* Statistics */ 69 unsigned accesses[2]; 70 unsigned hits[2]; 71 unsigned misses[2]; 72 unsigned evictions[2]; 73 unsigned bypasses[2]; 74 } H5PB_t; 75 76 /*****************************/ 77 /* Library-private Variables */ 78 /*****************************/ 79 80 /***************************************/ 81 /* Library-private Function Prototypes */ 82 /***************************************/ 83 84 /* General routines */ 85 H5_DLL herr_t H5PB_create(H5F_shared_t *f_sh, size_t page_buffer_size, unsigned page_buf_min_meta_perc, 86 unsigned page_buf_min_raw_perc); 87 H5_DLL herr_t H5PB_flush(H5F_shared_t *f_sh); 88 H5_DLL herr_t H5PB_dest(H5F_shared_t *f_sh); 89 H5_DLL herr_t H5PB_add_new_page(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t page_addr); 90 H5_DLL herr_t H5PB_update_entry(H5PB_t *page_buf, haddr_t addr, size_t size, const void *buf); 91 H5_DLL herr_t H5PB_remove_entry(const H5F_shared_t *f_sh, haddr_t addr); 92 H5_DLL herr_t H5PB_read(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, void *buf /*out*/); 93 H5_DLL herr_t H5PB_write(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf); 94 95 /* Statistics routines */ 96 H5_DLL herr_t H5PB_reset_stats(H5PB_t *page_buf); 97 H5_DLL herr_t H5PB_get_stats(const H5PB_t *page_buf, unsigned accesses[2], unsigned hits[2], 98 unsigned misses[2], unsigned evictions[2], unsigned bypasses[2]); 99 H5_DLL herr_t H5PB_print_stats(const H5PB_t *page_buf); 100 101 #endif /* H5PBprivate_H */ 102