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
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef H5FDvfd_swmr_private_H
#define H5FDvfd_swmr_private_H
#include "H5queue.h" /* for TAILQ_* */
/* Forward declaration */
struct H5F_t;
struct H5F_shared_t;
struct H5FD_vfd_swmr_idx_entry_t;
/*
* struct eot_queue_entry_t
*
* This is the structure for an entry on the end-of-tick queue (EOT queue) of files
* opened in either VFD SWMR write or VFD SWMR read mode. This queue is maintained
* in increasing end of tick time order.
* The structure contains all information required to determine whether the end
* of tick has arrived for the specified file, and to initiate end of tick processing
* if it has.
*
* The fields of eot_queue_entry_t are discussed below:
*
* vfd_swmr_file: Pointer to the instance of H5F_file_t containing the shared
* fields of the associated file that has been opened in VFD SWMR mode
* NOTE: for the time being use H5F_t instead of H5F_file_t
*
* vfd_swmr_writer: Boolean flag that is set to TRUE if the associated file
* has been opened in VFD SWMR writer mode, and FALSE if it has been
* opened in VFD SWMR reader mode.
*
* tick_num: Number of the current tick of the target file.
*
* end_of_tick: Expiration time of the current tick of the target file.
*
* link: Forward and backward linkage between the next element and the previous
* element (or the queue head). Note that if there is a following entry,
* `next`, then `next->end_of_tick` must be greater than or equal to
* `end_of_tick`.
*/
typedef struct eot_queue_entry {
hbool_t vfd_swmr_writer;
uint64_t tick_num;
struct timespec end_of_tick;
struct H5F_t * vfd_swmr_file; /* NOTE: for the time being use H5F_t instead H5F_shared_t */
TAILQ_ENTRY(eot_queue_entry) link;
} eot_queue_entry_t;
#define TOTAL_TIME_PASSED(X, Y) \
((double)((Y.tv_sec - X.tv_sec) * 1000000000 + (Y.tv_nsec - X.tv_nsec))) / 1000000.0
#define TIME_PASSED_MIN(X) (unsigned int)(X / 60000)
#define TIME_PASSED_SEC(X, Y) (unsigned int)((X - Y * 60000) / 1000)
#define TIME_PASSED_MSEC(X, Y, Z) (unsigned int)(X - Y * 60000 - Z * 1000)
// H5_DLLVAR extern hbool_t vfd_swmr_log_on;
// H5_DLLVAR extern FILE *vfd_swmr_log_file_ptr;
H5_DLLVAR unsigned int vfd_swmr_api_entries_g;
/* The head of the EOT queue */
typedef TAILQ_HEAD(eot_queue, eot_queue_entry) eot_queue_t;
H5_DLLVAR eot_queue_t eot_queue_g;
/***************************************/
/* Library-private Function Prototypes */
/***************************************/
H5_DLL herr_t H5F_vfd_swmr_init(struct H5F_t *f, hbool_t file_create);
H5_DLL herr_t H5F_vfd_swmr_close_or_flush(struct H5F_t *f, hbool_t closing);
H5_DLL herr_t H5F_update_vfd_swmr_metadata_file(struct H5F_t *f, uint32_t index_len,
struct H5FD_vfd_swmr_idx_entry_t *index);
H5_DLL herr_t H5F_vfd_swmr_writer__delay_write(struct H5F_shared_t *, uint64_t, uint64_t *);
H5_DLL herr_t H5F_vfd_swmr_writer__prep_for_flush_or_close(struct H5F_t *f);
herr_t H5F_vfd_swmr_process_eot_queue(hbool_t);
H5_DLL herr_t H5F_vfd_swmr_writer_end_of_tick(struct H5F_t *f, hbool_t);
H5_DLL herr_t H5F_vfd_swmr_writer__dump_index(struct H5F_shared_t *);
H5_DLL herr_t H5F_vfd_swmr_reader_end_of_tick(struct H5F_t *f, hbool_t);
H5_DLL herr_t H5F_vfd_swmr_remove_entry_eot(struct H5F_t *f);
H5_DLL herr_t H5F_vfd_swmr_insert_entry_eot(struct H5F_t *f);
H5_DLL void H5F_vfd_swmr_update_entry_eot(eot_queue_entry_t *);
H5_DLL herr_t H5F_dump_eot_queue(void);
#endif /* H5FDvfd_swmr_private_H */
|