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 files COPYING and Copyright.html. COPYING can be found at the root *
9 * of the source code distribution tree; Copyright.html can be found at the *
10 * root level of an installed copy of the electronic HDF5 document set and *
11 * is linked from the top-level documents page. It can also be found at *
12 * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
13 * access to either file, you may request a copy from help@hdfgroup.org. *
14 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15
16 /* Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
17 * Monday, March 6, 2006
18 *
19 * Purpose: Fractal heap metadata statistics functions.
20 *
21 */
22
23 /****************/
24 /* Module Setup */
25 /****************/
26
27 #define H5HF_PACKAGE /*suppress error about including H5HFpkg */
28
29 /***********/
30 /* Headers */
31 /***********/
32 #include "H5private.h" /* Generic Functions */
33 #include "H5Eprivate.h" /* Error handling */
34 #include "H5HFpkg.h" /* Fractal heaps */
35
36 /****************/
37 /* Local Macros */
38 /****************/
39
40
41 /********************/
42 /* Package Typedefs */
43 /********************/
44
45
46 /******************/
47 /* Local Typedefs */
48 /******************/
49
50
51 /********************/
52 /* Local Prototypes */
53 /********************/
54
55
56 /*********************/
57 /* Package Variables */
58 /*********************/
59
60
61 /*****************************/
62 /* Library Private Variables */
63 /*****************************/
64
65
66 /*******************/
67 /* Local Variables */
68 /*******************/
69
70
71
72 /*-------------------------------------------------------------------------
73 * Function: H5HF_stat_info
74 *
75 * Purpose: Retrieve metadata statistics for the fractal heap
76 *
77 * Return: Success: non-negative
78 *
79 * Failure: negative
80 *
81 * Programmer: Quincey Koziol
82 * Monday, March 6, 2006
83 *
84 *-------------------------------------------------------------------------
85 */
86 herr_t
H5HF_stat_info(const H5HF_t * fh,H5HF_stat_t * stats)87 H5HF_stat_info(const H5HF_t *fh, H5HF_stat_t *stats)
88 {
89 FUNC_ENTER_NOAPI_NOINIT_NOERR
90
91 /* Check arguments. */
92 HDassert(fh);
93 HDassert(stats);
94
95 /* Report statistics for fractal heap */
96 stats->man_size = fh->hdr->man_size;
97 stats->man_alloc_size = fh->hdr->man_alloc_size;
98 stats->man_iter_off = fh->hdr->man_iter_off;
99 stats->man_nobjs = fh->hdr->man_nobjs;
100 stats->man_free_space = fh->hdr->total_man_free;
101 stats->huge_size = fh->hdr->huge_size;
102 stats->huge_nobjs = fh->hdr->huge_nobjs;
103 stats->tiny_size = fh->hdr->tiny_size;
104 stats->tiny_nobjs = fh->hdr->tiny_nobjs;
105 /* XXX: Add more metadata statistics for the heap */
106
107 FUNC_LEAVE_NOAPI(SUCCEED)
108 } /* H5HF_stat_info() */
109
110
111 /*-------------------------------------------------------------------------
112 * Function: H5HF_size
113 *
114 * Purpose: Retrieve storage info for:
115 * 1. fractal heap
116 * 2. btree storage used by huge objects in fractal heap
117 * 3. free space storage info
118 *
119 * Return: non-negative on success, negative on error
120 *
121 * Programmer: Vailin Choi
122 * July 12 2007
123 *
124 *-------------------------------------------------------------------------
125 */
126 herr_t
H5HF_size(const H5HF_t * fh,hid_t dxpl_id,hsize_t * heap_size)127 H5HF_size(const H5HF_t *fh, hid_t dxpl_id, hsize_t *heap_size)
128 {
129 H5HF_hdr_t *hdr; /* Fractal heap header */
130 H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */
131 hsize_t meta_size = 0; /* free space storage size */
132 herr_t ret_value = SUCCEED; /* Return value */
133
134 FUNC_ENTER_NOAPI(FAIL)
135
136 /*
137 * Check arguments.
138 */
139 HDassert(fh);
140 HDassert(heap_size);
141
142 /* Get "convenience" pointer to fractal heap header */
143 hdr = fh->hdr;
144
145 /* Add in values already known */
146 *heap_size += hdr->heap_size; /* Heap header */
147 *heap_size += hdr->man_alloc_size; /* Direct block storage for "managed" objects */
148 *heap_size += hdr->huge_size; /* "huge" object storage */
149
150 /* Check for indirect blocks for managed objects */
151 if(H5F_addr_defined(hdr->man_dtable.table_addr) && hdr->man_dtable.curr_root_rows != 0)
152 if(H5HF_man_iblock_size(hdr->f, dxpl_id, hdr, hdr->man_dtable.table_addr, hdr->man_dtable.curr_root_rows, NULL, 0, heap_size) < 0)
153 HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to get fractal heap storage info for indirect block")
154
155 /* Check for B-tree storage of huge objects in fractal heap */
156 if(H5F_addr_defined(hdr->huge_bt2_addr)) {
157 /* Open the huge object index v2 B-tree */
158 if(NULL == (bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f)))
159 HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' objects")
160
161 /* Get the B-tree storage */
162 if(H5B2_size(bt2, dxpl_id, heap_size) < 0)
163 HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info")
164 } /* end if */
165
166 /* Get storage for free-space tracking info */
167 if(H5F_addr_defined(hdr->fs_addr)) {
168 if(H5HF_space_size(hdr, dxpl_id, &meta_size) < 0)
169 HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't retrieve FS meta storage info")
170 *heap_size += meta_size;
171 } /* end if */
172
173 done:
174 /* Release resources */
175 if(bt2 && H5B2_close(bt2, dxpl_id) < 0)
176 HDONE_ERROR(H5E_HEAP, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for tracking 'huge' objects")
177
178 FUNC_LEAVE_NOAPI(ret_value)
179 } /* end H5HF_size() */
180
181