summaryrefslogtreecommitdiffstats
path: root/src/H5Ctest.c
blob: cb0c046071376bc51b785b55e226ac586e2d32ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Copyright by The HDF Group.                                               *
 * Copyright by the Board of Trustees of the University of Illinois.         *
 * All rights reserved.                                                      *
 *                                                                           *
 * This file is part of HDF5.  The full HDF5 copyright notice, including     *
 * terms governing use, modification, and redistribution, is contained in    *
 * the COPYING file, which can be found at the root of the source code       *
 * distribution tree, or in https://www.hdfgroup.org/licenses.               *
 * If you do not have access to either file, you may request a copy from     *
 * help@hdfgroup.org.                                                        *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/*-------------------------------------------------------------------------
 *
 * Created:     H5Ctest.c
 *              June 7 2016
 *              Quincey Koziol
 *
 * Purpose:     Functions in this file support the metadata cache regression
 *		tests>
 *
 *-------------------------------------------------------------------------
 */

/****************/
/* Module Setup */
/****************/

#include "H5Cmodule.h" /* This source code file is part of the H5C module */
#define H5C_TESTING    /*suppress warning about H5C testing funcs*/
#define H5F_FRIEND     /*suppress error about including H5Fpkg	  */

/***********/
/* Headers */
/***********/
#include "H5private.h"          /* Generic Functions			    */
#include "H5Cpkg.h"             /* Cache				    */
#include "H5Eprivate.h"         /* Error handling		  	    */
#include "H5Fpkg.h"             /* Files				    */
#include "H5Iprivate.h"         /* IDs			  		    */
#include "H5VLprivate.h"        /* Virtual Object Layer                     */
#include "H5VLnative_private.h" /* Native VOL connector                     */

/****************/
/* Local Macros */
/****************/

/******************/
/* Local Typedefs */
/******************/

/* Typedef for tagged entry iterator callback context - verify cork tag */
typedef struct {
    hbool_t status; /* Corked status */
} H5C_tag_iter_vct_ctx_t;

/********************/
/* Local Prototypes */
/********************/

/*********************/
/* Package Variables */
/*********************/

/*****************************/
/* Library Private Variables */
/*****************************/

/*******************/
/* Local Variables */
/*******************/

/*-------------------------------------------------------------------------
 * Function:    H5C__verify_cork_tag_test_cb
 *
 * Purpose:     Verify the cork status for an entry
 *
 * Return:      SUCCEED on success, FAIL on error
 *
 * Programmer:  Vailin Choi
 *		Feb 2014
 *
 *-------------------------------------------------------------------------
 */
static int
H5C__verify_cork_tag_test_cb(H5C_cache_entry_t *entry, void *_ctx)
{
    H5C_tag_iter_vct_ctx_t *ctx = (H5C_tag_iter_vct_ctx_t *)_ctx; /* Get pointer to iterator context */
    hbool_t                 is_corked;                            /* Corked status for entry */
    int                     ret_value = H5_ITER_CONT;             /* Return value */

    /* Function enter macro */
    FUNC_ENTER_STATIC

    /* Santify checks */
    HDassert(entry);
    HDassert(ctx);

    /* Retrieve corked status for entry */
    is_corked = entry->tag_info ? entry->tag_info->corked : FALSE;

    /* Verify corked status for entry */
    if (is_corked != ctx->status)
        HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, H5_ITER_ERROR, "bad cork status")

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5C__verify_cork_tag_test_cb() */

/*-------------------------------------------------------------------------
 * Function:    H5C__verify_cork_tag_test
 *
 * Purpose:     This routine verifies that all cache entries associated with
 *      the object tag are marked with the desired "cork" status.
 *
 * Return:      SUCCEED on success, FAIL on error
 *
 * Programmer:  Vailin Choi
 *		Feb 2014
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5C__verify_cork_tag_test(hid_t fid, H5O_token_t tag_token, hbool_t status)
{
    H5F_t *                f;                   /* File Pointer */
    H5C_t *                cache;               /* Cache Pointer */
    H5C_tag_iter_vct_ctx_t ctx;                 /* Context for iterator callback */
    haddr_t                tag;                 /* Tagged address */
    herr_t                 ret_value = SUCCEED; /* Return value */

    /* Function enter macro */
    FUNC_ENTER_PACKAGE

    /* Get file pointer */
    if (NULL == (f = (H5F_t *)H5VL_object_verify(fid, H5I_FILE)))
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file")

    /* Convert token to address */
    tag = HADDR_UNDEF;
    if (H5VL_native_token_to_addr(f, H5I_FILE, tag_token, &tag) < 0)
        HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "can't get address for token")

    /* Get cache pointer */
    cache = f->shared->cache;

    /* Construct context for iterator callbacks */
    ctx.status = status;

    /* Iterate through tagged entries in the cache */
    if (H5C__iter_tagged_entries(cache, tag, FALSE, H5C__verify_cork_tag_test_cb, &ctx) < 0)
        HGOTO_ERROR(H5E_CACHE, H5E_BADITER, FAIL, "iteration of tagged entries failed")

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5C__verify_cork_tag_test() */

/*-------------------------------------------------------------------------
 * Function:    H5C_set_curr_io_type_splitable()
 *
 * Purpose:     To test the meta data entry splitting capability in the page
 *              buffer (needed to deal with H5FA and H5EA's unfortunate
 *              design choice of sub-allocating multiple metadata entries
 *              out of a single file space allocation), we must be able
 *              to configure the metadata cache to report that the
 *              current I/O request is for such an entry.
 *
 *              To do this, we must set cache_ptr->curr_io_type to
 *              point to the instance of H5C_class_t with one such
 *              client.
 *
 *              This function does this by setting cache_ptr->curr_io_type
 *              to H5AC_EARRAY_DBLK_PAGE if set_splitable is TRUE, and to
 *              NULL otherwise.
 *
 *              Needless to say, this is purely a testing function, and
 *              should not be called otherwise.
 *
 * Return:      void
 *
 * Programmer:  John Mainzer
 *              4/10/20
 *
 * Changes:     None.
 *
 *-------------------------------------------------------------------------
 */

void
H5C_set_curr_io_type_splitable(H5C_t *cache_ptr, hbool_t set_splitable)
{
    FUNC_ENTER_NOAPI_NOINIT_NOERR

    HDassert(cache_ptr);
    HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC);

    if (set_splitable) {

        cache_ptr->curr_io_type = H5AC_EARRAY_DBLK_PAGE;
    }
    else {

        cache_ptr->curr_io_type = NULL;
    }

    FUNC_LEAVE_NOAPI_VOID

} /* H5C_set_curr_io_type_splitable() */