Source
95
95
H5AC_OHDR_ID,
96
96
(H5AC_load_func_t)H5O_load,
97
97
(H5AC_flush_func_t)H5O_flush,
98
98
(H5AC_dest_func_t)H5O_dest,
99
99
(H5AC_clear_func_t)H5O_clear,
100
100
(H5AC_size_func_t)H5O_size,
101
101
}};
102
102
103
103
•
104
104
/*-------------------------------------------------------------------------
105
-
* Function: H5O_flush_msgs
106
-
*
107
-
* Purpose: Flushes messages for object header.
108
-
*
109
-
* Return: Non-negative on success/Negative on failure
110
-
*
111
-
* Programmer: Quincey Koziol
112
-
* koziol@ncsa.uiuc.edu
113
-
* Nov 21 2005
114
-
*
115
-
*-------------------------------------------------------------------------
116
-
*/
117
-
herr_t
118
-
H5O_flush_msgs(H5F_t *f, H5O_t *oh)
119
-
{
120
-
H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */
121
-
unsigned u; /* Local index variable */
122
-
herr_t ret_value = SUCCEED; /* Return value */
123
-
124
-
FUNC_ENTER_NOAPI(H5O_flush_msgs, FAIL)
125
-
126
-
/* check args */
127
-
HDassert(f);
128
-
HDassert(oh);
129
-
130
-
/* Encode any dirty messages */
131
-
for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) {
132
-
if(curr_msg->dirty) {
133
-
uint8_t *p; /* Temporary pointer to encode with */
134
-
unsigned msg_id; /* ID for message */
135
-
136
-
/* Point into message's chunk's image */
137
-
p = curr_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh);
138
-
139
-
/* Retrieve actual message ID, for unknown messages */
140
-
if(curr_msg->type == H5O_MSG_UNKNOWN)
141
-
msg_id = *(H5O_unknown_t *)(curr_msg->native);
142
-
else
143
-
msg_id = (uint8_t)curr_msg->type->id;
144
-
145
-
/* Encode the message prefix */
146
-
if(oh->version == H5O_VERSION_1)
147
-
UINT16ENCODE(p, msg_id)
148
-
else
149
-
*p++ = (uint8_t)msg_id;
150
-
HDassert(curr_msg->raw_size < H5O_MESG_MAX_SIZE);
151
-
UINT16ENCODE(p, curr_msg->raw_size);
152
-
*p++ = curr_msg->flags;
153
-
154
-
/* Only encode reserved bytes for version 1 of format */
155
-
if(oh->version == H5O_VERSION_1) {
156
-
*p++ = 0; /*reserved*/
157
-
*p++ = 0; /*reserved*/
158
-
*p++ = 0; /*reserved*/
159
-
} /* end for */
160
-
/* Only encode creation index for version 2+ of format */
161
-
else {
162
-
/* Only encode creation index if they are being tracked */
163
-
if(oh->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED)
164
-
UINT16ENCODE(p, curr_msg->crt_idx);
165
-
} /* end else */
166
-
HDassert(p == curr_msg->raw);
167
-
168
-
#ifndef NDEBUG
169
-
/* Make certain that null messages aren't in chunks w/gaps */
170
-
if(H5O_NULL_ID == msg_id)
171
-
HDassert(oh->chunk[curr_msg->chunkno].gap == 0);
172
-
173
-
/* Unknown messages should always have a native pointer */
174
-
if(curr_msg->type == H5O_MSG_UNKNOWN)
175
-
HDassert(curr_msg->native);
176
-
#endif /* NDEBUG */
177
-
178
-
/* Encode the message itself, if it's not an "unknown" message */
179
-
if(curr_msg->native && curr_msg->type != H5O_MSG_UNKNOWN) {
180
-
/*
181
-
* Encode the message. If the message is shared then we
182
-
* encode a Shared Object message instead of the object
183
-
* which is being shared.
184
-
*/
185
-
HDassert(curr_msg->raw >= oh->chunk[curr_msg->chunkno].image);
186
-
HDassert(curr_msg->raw_size == H5O_ALIGN_OH(oh, curr_msg->raw_size));
187
-
HDassert(curr_msg->raw + curr_msg->raw_size <=
188
-
oh->chunk[curr_msg->chunkno].image + (oh->chunk[curr_msg->chunkno].size - H5O_SIZEOF_CHKSUM_OH(oh)));
189
-
#ifndef NDEBUG
190
-
/* Sanity check that the message won't overwrite past it's allocated space */
191
-
{
192
-
size_t msg_size;
193
-
194
-
msg_size = curr_msg->type->raw_size(f, FALSE, curr_msg->native);
195
-
msg_size = H5O_ALIGN_OH(oh, msg_size);
196
-
HDassert(msg_size <= curr_msg->raw_size);
197
-
}
198
-
#endif /* NDEBUG */
199
-
HDassert(curr_msg->type->encode);
200
-
if((curr_msg->type->encode)(f, FALSE, curr_msg->raw, curr_msg->native) < 0)
201
-
HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode object header message")
202
-
} /* end if */
203
-
204
-
/* Pass "modifiedness" from message to chunk */
205
-
curr_msg->dirty = FALSE;
206
-
oh->chunk[curr_msg->chunkno].dirty = TRUE;
207
-
} /* end if */
208
-
} /* end for */
209
-
210
-
/* Sanity check for the correct # of messages in object header */
211
-
if(oh->nmesgs != u)
212
-
HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "corrupt object header - too few messages")
213
-
214
-
done:
215
-
FUNC_LEAVE_NOAPI(ret_value)
216
-
} /* end H5O_flush_msgs() */
217
-
218
-
•
219
-
/*-------------------------------------------------------------------------
220
105
* Function: H5O_load
221
106
*
222
107
* Purpose: Loads an object header from disk.
223
108
*
224
109
* Return: Success: Pointer to the new object header.
225
110
*
226
111
* Failure: NULL
227
112
*
228
113
* Programmer: Robb Matzke
229
114
* matzke@llnl.gov