Coverage Report

Created: 2026-11-22 17:17

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/hdf5/src/H5HFstat.c
Line
Count
Source
1
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2
 * Copyright by The HDF Group.                                               *
3
 * All rights reserved.                                                      *
4
 *                                                                           *
5
 * This file is part of HDF5.  The full HDF5 copyright notice, including     *
6
 * terms governing use, modification, and redistribution, is contained in    *
7
 * the LICENSE file, which can be found at the root of the source code       *
8
 * distribution tree, or in https://www.hdfgroup.org/licenses.               *
9
 * If you do not have access to either file, you may request a copy from     *
10
 * help@hdfgroup.org.                                                        *
11
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
12
13
/*
14
 * Purpose: Fractal heap metadata statistics functions.
15
 *
16
 */
17
18
/****************/
19
/* Module Setup */
20
/****************/
21
22
#include "H5HFmodule.h" /* This source code file is part of the H5HF module */
23
24
/***********/
25
/* Headers */
26
/***********/
27
#include "H5private.h"  /* Generic Functions      */
28
#include "H5Eprivate.h" /* Error handling       */
29
#include "H5HFpkg.h"    /* Fractal heaps      */
30
31
/****************/
32
/* Local Macros */
33
/****************/
34
35
/********************/
36
/* Package Typedefs */
37
/********************/
38
39
/******************/
40
/* Local Typedefs */
41
/******************/
42
43
/********************/
44
/* Local Prototypes */
45
/********************/
46
47
/*********************/
48
/* Package Variables */
49
/*********************/
50
51
/*****************************/
52
/* Library Private Variables */
53
/*****************************/
54
55
/*******************/
56
/* Local Variables */
57
/*******************/
58
59
/*-------------------------------------------------------------------------
60
 * Function:  H5HF_stat_info
61
 *
62
 * Purpose: Retrieve metadata statistics for the fractal heap
63
 *
64
 * Return:  Success:  non-negative
65
 *
66
 *    Failure:  negative
67
 *
68
 *-------------------------------------------------------------------------
69
 */
70
herr_t
71
H5HF_stat_info(const H5HF_t *fh, H5HF_stat_t *stats)
72
0
{
73
0
    FUNC_ENTER_NOAPI_NOINIT_NOERR
74
75
    /* Check arguments. */
76
0
    assert(fh);
77
0
    assert(stats);
78
79
    /* Report statistics for fractal heap */
80
0
    stats->man_size       = fh->hdr->man_size;
81
0
    stats->man_alloc_size = fh->hdr->man_alloc_size;
82
0
    stats->man_iter_off   = fh->hdr->man_iter_off;
83
0
    stats->man_nobjs      = fh->hdr->man_nobjs;
84
0
    stats->man_free_space = fh->hdr->total_man_free;
85
0
    stats->huge_size      = fh->hdr->huge_size;
86
0
    stats->huge_nobjs     = fh->hdr->huge_nobjs;
87
0
    stats->tiny_size      = fh->hdr->tiny_size;
88
0
    stats->tiny_nobjs     = fh->hdr->tiny_nobjs;
89
    /* XXX: Add more metadata statistics for the heap */
90
91
0
    FUNC_LEAVE_NOAPI(SUCCEED)
92
0
} /* H5HF_stat_info() */
93
94
/*-------------------------------------------------------------------------
95
 * Function:    H5HF_size
96
 *
97
 * Purpose:     Retrieve storage info for:
98
 *      1. fractal heap
99
 *      2. btree storage used by huge objects in fractal heap
100
 *      3. free space storage info
101
 *
102
 * Return:      non-negative on success, negative on error
103
 *
104
 *-------------------------------------------------------------------------
105
 */
106
herr_t
107
H5HF_size(const H5HF_t *fh, hsize_t *heap_size)
108
0
{
109
0
    H5HF_hdr_t *hdr;                 /* Fractal heap header */
110
0
    H5B2_t     *bt2       = NULL;    /* v2 B-tree handle for index */
111
0
    hsize_t     meta_size = 0;       /* free space storage size */
112
0
    herr_t      ret_value = SUCCEED; /* Return value */
113
114
0
    FUNC_ENTER_NOAPI(FAIL)
115
116
    /*
117
     * Check arguments.
118
     */
119
0
    assert(fh);
120
0
    assert(heap_size);
121
122
    /* Get "convenience" pointer to fractal heap header */
123
0
    hdr = fh->hdr;
124
125
    /* Add in values already known */
126
0
    *heap_size += hdr->heap_size;      /* Heap header */
127
0
    *heap_size += hdr->man_alloc_size; /* Direct block storage for "managed" objects */
128
0
    *heap_size += hdr->huge_size;      /* "huge" object storage */
129
130
    /* Check for indirect blocks for managed objects */
131
0
    if (H5_addr_defined(hdr->man_dtable.table_addr) && hdr->man_dtable.curr_root_rows != 0)
132
0
        if (H5HF__man_iblock_size(hdr->f, hdr, hdr->man_dtable.table_addr, hdr->man_dtable.curr_root_rows,
133
0
                                  NULL, 0, heap_size) < 0)
134
0
            HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL,
135
0
                        "unable to get fractal heap storage info for indirect block");
136
137
    /* Check for B-tree storage of huge objects in fractal heap */
138
0
    if (H5_addr_defined(hdr->huge_bt2_addr)) {
139
        /* Open the huge object index v2 B-tree */
140
0
        if (NULL == (bt2 = H5B2_open(hdr->f, hdr->huge_bt2_addr, hdr->f)))
141
0
            HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL,
142
0
                        "unable to open v2 B-tree for tracking 'huge' objects");
143
144
        /* Get the B-tree storage */
145
0
        if (H5B2_size(bt2, heap_size) < 0)
146
0
            HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info");
147
0
    } /* end if */
148
149
    /* Get storage for free-space tracking info */
150
0
    if (H5_addr_defined(hdr->fs_addr)) {
151
0
        if (H5HF__space_size(hdr, &meta_size) < 0)
152
0
            HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't retrieve FS meta storage info");
153
0
        *heap_size += meta_size;
154
0
    } /* end if */
155
156
0
done:
157
    /* Release resources */
158
0
    if (bt2 && H5B2_close(bt2) < 0)
159
0
        HDONE_ERROR(H5E_HEAP, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for tracking 'huge' objects");
160
161
0
    FUNC_LEAVE_NOAPI(ret_value)
162
0
} /* end H5HF_size() */