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 COPYING file, which can be found at the root of the source code       *
9  * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.  *
10  * If you do not have access to either file, you may request a copy from     *
11  * help@hdfgroup.org.                                                        *
12  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13 
14 /*-------------------------------------------------------------------------
15  *
16  * Created:             H5AClog.c
17  *
18  * Purpose:             Functions for metadata cache logging in JSON format
19  *
20  *-------------------------------------------------------------------------
21  */
22 
23 /****************/
24 /* Module Setup */
25 /****************/
26 #include "H5ACmodule.h"         /* This source code file is part of the H5AC module */
27 
28 /***********/
29 /* Headers */
30 /***********/
31 #include "H5private.h"          /* Generic Functions                    */
32 #include "H5ACpkg.h"            /* Metadata cache                       */
33 #include "H5Cprivate.h"		/* Cache                                */
34 #include "H5Eprivate.h"         /* Error handling                       */
35 
36 
37 /****************/
38 /* Local Macros */
39 /****************/
40 
41 #define MSG_SIZE 128
42 
43 
44 /******************/
45 /* Local Typedefs */
46 /******************/
47 
48 
49 /********************/
50 /* Package Typedefs */
51 /********************/
52 
53 
54 /********************/
55 /* Local Prototypes */
56 /********************/
57 
58 
59 /*********************/
60 /* Package Variables */
61 /*********************/
62 
63 
64 /*****************************/
65 /* Library Private Variables */
66 /*****************************/
67 
68 
69 /*******************/
70 /* Local Variables */
71 /*******************/
72 
73 
74 
75 /*-------------------------------------------------------------------------
76  * Function:    H5AC__write_create_cache_log_msg
77  *
78  * Purpose:     Write a log message for cache creation.
79  *
80  * Return:      Success:        SUCCEED
81  *              Failure:        FAIL
82  *
83  * Programmer:	Dana Robinson
84  *              Sunday, March 16, 2014
85  *
86  *-------------------------------------------------------------------------
87  */
88 herr_t
H5AC__write_create_cache_log_msg(H5AC_t * cache)89 H5AC__write_create_cache_log_msg(H5AC_t *cache)
90 {
91     char msg[MSG_SIZE];
92     hbool_t log_enabled;                /* TRUE if logging was set up */
93     hbool_t curr_logging;               /* TRUE if currently logging */
94     herr_t ret_value = SUCCEED;         /* Return value */
95 
96     FUNC_ENTER_NOAPI(FAIL)
97 
98     /* Sanity checks */
99     HDassert(cache);
100 
101     /* Check if log messages are being emitted */
102     if(H5C_get_logging_status(cache, &log_enabled, &curr_logging) < 0)
103         HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status")
104 
105     /* Since we're about to override the current logging flag,
106      * check the "log enabled" flag to see if we didn't get here
107      * by mistake.
108      */
109     if(!log_enabled)
110         HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "attempt to write opening log message when logging is disabled")
111 
112     /* Create the log message string */
113     HDsnprintf(msg, MSG_SIZE,
114 "\
115 {\n\
116 \"create_time\":%lld,\n\
117 \"messages\":\n\
118 [\n\
119 "
120     , (long long)HDtime(NULL));
121 
122     /* Have to temporarily enable logging, if it isn't currently  */
123     if(!curr_logging)
124         if(H5C_start_logging(cache) < 0)
125             HGOTO_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to start mdc logging")
126 
127     /* Write the log message to the file */
128     if(H5C_write_log_message(cache, msg) < 0)
129         HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message")
130 
131     /* Stop logging, if it wasn't started originally */
132     if(!curr_logging)
133         if(H5C_stop_logging(cache) < 0)
134             HGOTO_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to stop mdc logging")
135 
136 done:
137     FUNC_LEAVE_NOAPI(ret_value)
138 } /* H5AC__write_create_cache_log_msg() */
139 
140 
141 /*-------------------------------------------------------------------------
142  * Function:    H5AC__write_destroy_cache_log_msg
143  *
144  * Purpose:     Write a log message for cache destruction.
145  *
146  * Return:      Success:        SUCCEED
147  *              Failure:        FAIL
148  *
149  * Programmer:	Dana Robinson
150  *              Sunday, March 16, 2014
151  *
152  *-------------------------------------------------------------------------
153  */
154 herr_t
H5AC__write_destroy_cache_log_msg(H5AC_t * cache)155 H5AC__write_destroy_cache_log_msg(H5AC_t *cache)
156 {
157     char msg[MSG_SIZE];
158     hbool_t log_enabled;                /* TRUE if logging was set up */
159     hbool_t curr_logging;               /* TRUE if currently logging */
160     herr_t ret_value = SUCCEED;         /* Return value */
161 
162     FUNC_ENTER_NOAPI(FAIL)
163 
164     /* Sanity checks */
165     HDassert(cache);
166 
167     /* Check if log messages are being emitted */
168     if(H5C_get_logging_status(cache, &log_enabled, &curr_logging) < 0)
169         HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status")
170 
171     /* Since we're about to override the current logging flag,
172      * check the "log enabled" flag to see if we didn't get here
173      * by mistake.
174      */
175     if(!log_enabled)
176         HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "attempt to write closing log message when logging is disabled")
177 
178     /* Create the log message string */
179     HDsnprintf(msg, MSG_SIZE,
180 "\
181 ],\n\
182 \"close_time\":%lld,\n\
183 }\n\
184 "
185     , (long long)HDtime(NULL));
186 
187     /* Have to temporarily enable logging, if it isn't currently  */
188     if(!curr_logging)
189         if(H5C_start_logging(cache) < 0)
190             HGOTO_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to start mdc logging")
191 
192     /* Write the log message to the file */
193     if(H5C_write_log_message(cache, msg) < 0)
194         HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message")
195 
196     /* Stop logging, if it wasn't started originally */
197     if(!curr_logging)
198         if(H5C_stop_logging(cache) < 0)
199             HGOTO_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to stop mdc logging")
200 
201 done:
202     FUNC_LEAVE_NOAPI(ret_value)
203 } /* H5AC__write_destroy_cache_log_msg() */
204 
205 
206 /*-------------------------------------------------------------------------
207  * Function:    H5AC__write_evict_cache_log_msg
208  *
209  * Purpose:     Write a log message for eviction of cache entries.
210  *
211  * Return:      Success:        SUCCEED
212  *              Failure:        FAIL
213  *
214  * Programmer:	Dana Robinson
215  *              Sunday, March 16, 2014
216  *
217  *-------------------------------------------------------------------------
218  */
219 herr_t
H5AC__write_evict_cache_log_msg(const H5AC_t * cache,herr_t fxn_ret_value)220 H5AC__write_evict_cache_log_msg(const H5AC_t *cache,
221                                 herr_t fxn_ret_value)
222 {
223     char msg[MSG_SIZE];
224     herr_t ret_value = SUCCEED;
225 
226     FUNC_ENTER_NOAPI(FAIL)
227 
228     /* Sanity checks */
229     HDassert(cache);
230 
231     /* Create the log message string */
232     HDsnprintf(msg, MSG_SIZE,
233 "\
234 {\
235 \"timestamp\":%lld,\
236 \"action\":\"evict\",\
237 \"returned\":%d\
238 },\n\
239 "
240     , (long long)HDtime(NULL), (int)fxn_ret_value);
241 
242     /* Write the log message to the file */
243     if(H5C_write_log_message(cache, msg) < 0)
244         HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message")
245 
246 done:
247     FUNC_LEAVE_NOAPI(ret_value)
248 } /* H5AC__write_evict_cache_log_msg() */
249 
250 
251 /*-------------------------------------------------------------------------
252  * Function:    H5AC__write_expunge_entry_log_msg
253  *
254  * Purpose:     Write a log message for expunge of cache entries.
255  *
256  * Return:      Success:        SUCCEED
257  *              Failure:        FAIL
258  *
259  * Programmer:	Dana Robinson
260  *              Sunday, March 16, 2014
261  *
262  *-------------------------------------------------------------------------
263  */
264 herr_t
H5AC__write_expunge_entry_log_msg(const H5AC_t * cache,haddr_t address,int type_id,herr_t fxn_ret_value)265 H5AC__write_expunge_entry_log_msg(const H5AC_t *cache,
266                                   haddr_t address,
267                                   int type_id,
268                                   herr_t fxn_ret_value)
269 {
270     char msg[MSG_SIZE];
271     herr_t ret_value = SUCCEED;
272 
273     FUNC_ENTER_NOAPI(FAIL)
274 
275     /* Sanity checks */
276     HDassert(cache);
277 
278     /* Create the log message string */
279     HDsnprintf(msg, MSG_SIZE,
280 "\
281 {\
282 \"timestamp\":%lld,\
283 \"action\":\"expunge\",\
284 \"address\":0x%lx,\
285 \"type_id\":%d,\
286 \"returned\":%d\
287 },\n\
288 "
289     , (long long)HDtime(NULL), (unsigned long)address, (int)type_id, (int)fxn_ret_value);
290 
291 
292     /* Write the log message to the file */
293     if(H5C_write_log_message(cache, msg) < 0)
294         HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message")
295 
296 done:
297     FUNC_LEAVE_NOAPI(ret_value)
298 } /* H5AC__write_expunge_entry_log_msg() */
299 
300 
301 /*-------------------------------------------------------------------------
302  * Function:    H5AC__write_flush_cache_log_msg
303  *
304  * Purpose:     Write a log message for cache flushes.
305  *
306  * Return:      Success:        SUCCEED
307  *              Failure:        FAIL
308  *
309  * Programmer:	Dana Robinson
310  *              Sunday, March 16, 2014
311  *
312  *-------------------------------------------------------------------------
313  */
314 herr_t
H5AC__write_flush_cache_log_msg(const H5AC_t * cache,herr_t fxn_ret_value)315 H5AC__write_flush_cache_log_msg(const H5AC_t *cache,
316                                 herr_t fxn_ret_value)
317 {
318     char msg[MSG_SIZE];
319     herr_t ret_value = SUCCEED;
320 
321     FUNC_ENTER_NOAPI(FAIL)
322 
323     /* Sanity checks */
324     HDassert(cache);
325 
326     /* Create the log message string */
327     HDsnprintf(msg, MSG_SIZE,
328 "\
329 {\
330 \"timestamp\":%lld,\
331 \"action\":\"flush\",\
332 \"returned\":%d\
333 },\n\
334 "
335     , (long long)HDtime(NULL), (int)fxn_ret_value);
336 
337     /* Write the log message to the file */
338     if(H5C_write_log_message(cache, msg) < 0)
339         HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message")
340 
341 done:
342     FUNC_LEAVE_NOAPI(ret_value)
343 } /* H5AC__write_flush_cache_log_msg() */
344 
345 
346 /*-------------------------------------------------------------------------
347  * Function:    H5AC__write_insert_entry_log_msg
348  *
349  * Purpose:     Write a log message for insertion of cache entries.
350  *
351  * Return:      Success:        SUCCEED
352  *              Failure:        FAIL
353  *
354  * Programmer:	Dana Robinson
355  *              Sunday, March 16, 2014
356  *
357  *-------------------------------------------------------------------------
358  */
359 herr_t
H5AC__write_insert_entry_log_msg(const H5AC_t * cache,haddr_t address,int type_id,unsigned flags,size_t size,herr_t fxn_ret_value)360 H5AC__write_insert_entry_log_msg(const H5AC_t *cache,
361                                  haddr_t address,
362                                  int type_id,
363                                  unsigned flags,
364                                  size_t size,
365                                  herr_t fxn_ret_value)
366 {
367     char msg[MSG_SIZE];
368     herr_t ret_value = SUCCEED;
369 
370     FUNC_ENTER_NOAPI(FAIL)
371 
372     /* Sanity checks */
373     HDassert(cache);
374 
375 
376     /* Create the log message string */
377     HDsnprintf(msg, MSG_SIZE,
378 "\
379 {\
380 \"timestamp\":%lld,\
381 \"action\":\"insert\",\
382 \"address\":0x%lx,\
383 \"flags\":0x%x,\
384 \"type_id\":%d,\
385 \"size\":%d,\
386 \"returned\":%d\
387 },\n\
388 "
389     , (long long)HDtime(NULL), (unsigned long)address, flags, type_id,
390       (int)size, (int)fxn_ret_value);
391 
392     /* Write the log message to the file */
393     if(H5C_write_log_message(cache, msg) < 0)
394         HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message")
395 
396 done:
397     FUNC_LEAVE_NOAPI(ret_value)
398 } /* H5AC__write_insert_entry_log_msg() */
399 
400 
401 /*-------------------------------------------------------------------------
402  * Function:    H5AC__write_mark_dirty_entry_log_msg
403  *
404  * Purpose:     Write a log message for marking cache entries as dirty.
405  *
406  * Return:      Success:        SUCCEED
407  *              Failure:        FAIL
408  *
409  * Programmer:	Dana Robinson
410  *              Sunday, March 16, 2014
411  *
412  *-------------------------------------------------------------------------
413  */
414 herr_t
H5AC__write_mark_dirty_entry_log_msg(const H5AC_t * cache,const H5AC_info_t * entry,herr_t fxn_ret_value)415 H5AC__write_mark_dirty_entry_log_msg(const H5AC_t *cache,
416                                      const H5AC_info_t *entry,
417                                      herr_t fxn_ret_value)
418 {
419     char msg[MSG_SIZE];
420     herr_t ret_value = SUCCEED;
421 
422     FUNC_ENTER_NOAPI(FAIL)
423 
424     /* Sanity checks */
425     HDassert(cache);
426     HDassert(entry);
427 
428     /* Create the log message string */
429     HDsnprintf(msg, MSG_SIZE,
430 "\
431 {\
432 \"timestamp\":%lld,\
433 \"action\":\"dirty\",\
434 \"address\":0x%lx,\
435 \"returned\":%d\
436 },\n\
437 "
438     , (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value);
439 
440     /* Write the log message to the file */
441     if(H5C_write_log_message(cache, msg) < 0)
442         HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message")
443 
444 done:
445     FUNC_LEAVE_NOAPI(ret_value)
446 } /* H5AC__write_mark_dirty_entry_log_msg() */
447 
448 
449 /*-------------------------------------------------------------------------
450  * Function:    H5AC__write_mark_clean_entry_log_msg
451  *
452  * Purpose:     Write a log message for marking cache entries as clean.
453  *
454  * Return:      Success:        SUCCEED
455  *              Failure:        FAIL
456  *
457  * Programmer:	Quincey Koziol
458  *              Saturday, July 23, 2016
459  *
460  *-------------------------------------------------------------------------
461  */
462 herr_t
H5AC__write_mark_clean_entry_log_msg(const H5AC_t * cache,const H5AC_info_t * entry,herr_t fxn_ret_value)463 H5AC__write_mark_clean_entry_log_msg(const H5AC_t *cache, const H5AC_info_t *entry,
464     herr_t fxn_ret_value)
465 {
466     char msg[MSG_SIZE];                 /* Log message buffer */
467     herr_t ret_value = SUCCEED;         /* Return value */
468 
469     FUNC_ENTER_NOAPI(FAIL)
470 
471     /* Sanity checks */
472     HDassert(cache);
473     HDassert(entry);
474 
475     /* Create the log message string */
476     HDsnprintf(msg, MSG_SIZE,
477 "\
478 {\
479 \"timestamp\":%lld,\
480 \"action\":\"clean\",\
481 \"address\":0x%lx,\
482 \"returned\":%d\
483 },\n\
484 "
485     , (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value);
486 
487     /* Write the log message to the file */
488     if(H5C_write_log_message(cache, msg) < 0)
489         HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message")
490 
491 done:
492     FUNC_LEAVE_NOAPI(ret_value)
493 } /* H5AC__write_mark_clean_entry_log_msg() */
494 
495 
496 /*-------------------------------------------------------------------------
497  * Function:    H5AC__write_mark_unserialized_entry_log_msg
498  *
499  * Purpose:     Write a log message for marking cache entries as unserialized.
500  *
501  * Return:      Success:        SUCCEED
502  *              Failure:        FAIL
503  *
504  * Programmer:	Quincey Koziol
505  *              Thursday, December 22, 2016
506  *
507  *-------------------------------------------------------------------------
508  */
509 herr_t
H5AC__write_mark_unserialized_entry_log_msg(const H5AC_t * cache,const H5AC_info_t * entry,herr_t fxn_ret_value)510 H5AC__write_mark_unserialized_entry_log_msg(const H5AC_t *cache,
511                                      const H5AC_info_t *entry,
512                                      herr_t fxn_ret_value)
513 {
514     char msg[MSG_SIZE];
515     herr_t ret_value = SUCCEED;
516 
517     FUNC_ENTER_NOAPI(FAIL)
518 
519     /* Sanity checks */
520     HDassert(cache);
521     HDassert(entry);
522 
523     /* Create the log message string */
524     HDsnprintf(msg, MSG_SIZE,
525 "\
526 {\
527 \"timestamp\":%lld,\
528 \"action\":\"unserialized\",\
529 \"address\":0x%lx,\
530 \"returned\":%d\
531 },\n\
532 "
533     , (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value);
534 
535     /* Write the log message to the file */
536     if(H5C_write_log_message(cache, msg) < 0)
537         HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message")
538 
539 done:
540     FUNC_LEAVE_NOAPI(ret_value)
541 } /* H5AC__write_mark_unserialized_entry_log_msg() */
542 
543 
544 /*-------------------------------------------------------------------------
545  * Function:    H5AC__write_mark_serialize_entry_log_msg
546  *
547  * Purpose:     Write a log message for marking cache entries as serialize.
548  *
549  * Return:      Success:        SUCCEED
550  *              Failure:        FAIL
551  *
552  * Programmer:	Quincey Koziol
553  *              Thursday, December 22, 2016
554  *
555  *-------------------------------------------------------------------------
556  */
557 herr_t
H5AC__write_mark_serialized_entry_log_msg(const H5AC_t * cache,const H5AC_info_t * entry,herr_t fxn_ret_value)558 H5AC__write_mark_serialized_entry_log_msg(const H5AC_t *cache, const H5AC_info_t *entry,
559     herr_t fxn_ret_value)
560 {
561     char msg[MSG_SIZE];                 /* Log message buffer */
562     herr_t ret_value = SUCCEED;         /* Return value */
563 
564     FUNC_ENTER_NOAPI(FAIL)
565 
566     /* Sanity checks */
567     HDassert(cache);
568     HDassert(entry);
569 
570     /* Create the log message string */
571     HDsnprintf(msg, MSG_SIZE,
572 "\
573 {\
574 \"timestamp\":%lld,\
575 \"action\":\"serialized\",\
576 \"address\":0x%lx,\
577 \"returned\":%d\
578 },\n\
579 "
580     , (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value);
581 
582     /* Write the log message to the file */
583     if(H5C_write_log_message(cache, msg) < 0)
584         HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message")
585 
586 done:
587     FUNC_LEAVE_NOAPI(ret_value)
588 } /* H5AC__write_mark_serialized_entry_log_msg() */
589 
590 
591 /*-------------------------------------------------------------------------
592  * Function:    H5AC__write_move_entry_log_msg
593  *
594  * Purpose:     Write a log message for moving a cache entry.
595  *
596  * Return:      Success:        SUCCEED
597  *              Failure:        FAIL
598  *
599  * Programmer:	Dana Robinson
600  *              Sunday, March 16, 2014
601  *
602  *-------------------------------------------------------------------------
603  */
604 herr_t
H5AC__write_move_entry_log_msg(const H5AC_t * cache,haddr_t old_addr,haddr_t new_addr,int type_id,herr_t fxn_ret_value)605 H5AC__write_move_entry_log_msg(const H5AC_t *cache,
606                                haddr_t old_addr,
607                                haddr_t new_addr,
608                                int type_id,
609                                herr_t fxn_ret_value)
610 {
611     char msg[MSG_SIZE];
612     herr_t ret_value = SUCCEED;
613 
614     FUNC_ENTER_NOAPI(FAIL)
615 
616     /* Sanity checks */
617     HDassert(cache);
618 
619     /* Create the log message string */
620     HDsnprintf(msg, MSG_SIZE,
621 "\
622 {\
623 \"timestamp\":%lld,\
624 \"action\":\"move\",\
625 \"old_address\":0x%lx,\
626 \"new_address\":0x%lx,\
627 \"type_id\":%d,\
628 \"returned\":%d\
629 },\n\
630 "
631     , (long long)HDtime(NULL), (unsigned long)old_addr,
632       (unsigned long)new_addr, type_id, (int)fxn_ret_value);
633 
634     /* Write the log message to the file */
635     if(H5C_write_log_message(cache, msg) < 0)
636         HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message")
637 
638 done:
639     FUNC_LEAVE_NOAPI(ret_value)
640 } /* H5AC__write_move_entry_log_msg() */
641 
642 
643 /*-------------------------------------------------------------------------
644  * Function:    H5AC__write_pin_entry_log_msg
645  *
646  * Purpose:     Write a log message for pinning a cache entry.
647  *
648  * Return:      Success:        SUCCEED
649  *              Failure:        FAIL
650  *
651  * Programmer:	Dana Robinson
652  *              Sunday, March 16, 2014
653  *
654  *-------------------------------------------------------------------------
655  */
656 herr_t
H5AC__write_pin_entry_log_msg(const H5AC_t * cache,const H5AC_info_t * entry,herr_t fxn_ret_value)657 H5AC__write_pin_entry_log_msg(const H5AC_t *cache,
658                               const H5AC_info_t *entry,
659                               herr_t fxn_ret_value)
660 {
661     char msg[MSG_SIZE];
662     herr_t ret_value = SUCCEED;
663 
664     FUNC_ENTER_NOAPI(FAIL)
665 
666     /* Sanity checks */
667     HDassert(cache);
668     HDassert(entry);
669 
670     /* Create the log message string */
671     HDsnprintf(msg, MSG_SIZE,
672 "\
673 {\
674 \"timestamp\":%lld,\
675 \"action\":\"pin\",\
676 \"address\":0x%lx,\
677 \"returned\":%d\
678 },\n\
679 "
680     , (long long)HDtime(NULL), (unsigned long)entry->addr,
681       (int)fxn_ret_value);
682 
683     /* Write the log message to the file */
684     if(H5C_write_log_message(cache, msg) < 0)
685         HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message")
686 
687 done:
688     FUNC_LEAVE_NOAPI(ret_value)
689 } /* H5AC__write_pin_entry_log_msg() */
690 
691 
692 /*-------------------------------------------------------------------------
693  * Function:    H5AC__write_create_fd_log_msg
694  *
695  * Purpose:     Write a log message for creating a flush dependency between
696  *              two cache entries.
697  *
698  * Return:      Success:        SUCCEED
699  *              Failure:        FAIL
700  *
701  * Programmer:	Dana Robinson
702  *              Sunday, March 16, 2014
703  *
704  *-------------------------------------------------------------------------
705  */
706 herr_t
H5AC__write_create_fd_log_msg(const H5AC_t * cache,const H5AC_info_t * parent,const H5AC_info_t * child,herr_t fxn_ret_value)707 H5AC__write_create_fd_log_msg(const H5AC_t *cache,
708                               const H5AC_info_t *parent,
709                               const H5AC_info_t *child,
710                               herr_t fxn_ret_value)
711 {
712     char msg[MSG_SIZE];
713     herr_t ret_value = SUCCEED;
714 
715     FUNC_ENTER_NOAPI(FAIL)
716 
717     /* Sanity checks */
718     HDassert(cache);
719     HDassert(parent);
720     HDassert(child);
721 
722     /* Create the log message string */
723     HDsnprintf(msg, MSG_SIZE,
724 "\
725 {\
726 \"timestamp\":%lld,\
727 \"action\":\"create_fd\",\
728 \"parent_addr\":0x%lx,\
729 \"child_addr\":0x%lx,\
730 \"returned\":%d\
731 },\n\
732 "
733     , (long long)HDtime(NULL), (unsigned long)parent->addr,
734       (unsigned long)child->addr, (int)fxn_ret_value);
735 
736     /* Write the log message to the file */
737     if(H5C_write_log_message(cache, msg) < 0)
738         HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message")
739 
740 done:
741     FUNC_LEAVE_NOAPI(ret_value)
742 } /* H5AC__write_create_fd_log_msg() */
743 
744 
745 /*-------------------------------------------------------------------------
746  * Function:    H5AC__write_protect_entry_log_msg
747  *
748  * Purpose:     Write a log message for protecting a cache entry.
749  *
750  * Return:      Success:        SUCCEED
751  *              Failure:        FAIL
752  *
753  * Programmer:	Dana Robinson
754  *              Sunday, March 16, 2014
755  *
756  *-------------------------------------------------------------------------
757  */
758 herr_t
H5AC__write_protect_entry_log_msg(const H5AC_t * cache,const H5AC_info_t * entry,unsigned flags,herr_t fxn_ret_value)759 H5AC__write_protect_entry_log_msg(const H5AC_t *cache,
760                                   const H5AC_info_t *entry,
761                                   unsigned flags,
762                                   herr_t fxn_ret_value)
763 {
764     char msg[MSG_SIZE];
765     char rw_s[16];
766     herr_t ret_value = SUCCEED;
767 
768     FUNC_ENTER_NOAPI(FAIL)
769 
770     /* Sanity checks */
771     HDassert(cache);
772     HDassert(entry);
773 
774     if(H5AC__READ_ONLY_FLAG == flags)
775         HDstrcpy(rw_s, "READ");
776     else
777         HDstrcpy(rw_s, "WRITE");
778 
779     /* Create the log message string */
780     HDsnprintf(msg, MSG_SIZE,
781 "\
782 {\
783 \"timestamp\":%lld,\
784 \"action\":\"protect\",\
785 \"address\":0x%lx,\
786 \"readwrite\":\"%s\",\
787 \"size\":%d,\
788 \"returned\":%d\
789 },\n\
790 "
791     , (long long)HDtime(NULL), (unsigned long)entry->addr,
792       rw_s, (int)entry->size, (int)fxn_ret_value);
793 
794     /* Write the log message to the file */
795     if(H5C_write_log_message(cache, msg) < 0)
796         HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message")
797 
798 done:
799     FUNC_LEAVE_NOAPI(ret_value)
800 } /* H5AC__write_protect_entry_log_msg() */
801 
802 
803 /*-------------------------------------------------------------------------
804  * Function:    H5AC__write_resize_entry_log_msg
805  *
806  * Purpose:     Write a log message for resizing a cache entry.
807  *
808  * Return:      Success:        SUCCEED
809  *              Failure:        FAIL
810  *
811  * Programmer:	Dana Robinson
812  *              Sunday, March 16, 2014
813  *
814  *-------------------------------------------------------------------------
815  */
816 herr_t
H5AC__write_resize_entry_log_msg(const H5AC_t * cache,const H5AC_info_t * entry,size_t new_size,herr_t fxn_ret_value)817 H5AC__write_resize_entry_log_msg(const H5AC_t *cache,
818                                  const H5AC_info_t *entry,
819                                  size_t new_size,
820                                  herr_t fxn_ret_value)
821 {
822     char msg[MSG_SIZE];
823     herr_t ret_value = SUCCEED;
824 
825     FUNC_ENTER_NOAPI(FAIL)
826 
827     /* Sanity checks */
828     HDassert(cache);
829     HDassert(entry);
830 
831     /* Create the log message string */
832     HDsnprintf(msg, MSG_SIZE,
833 "\
834 {\
835 \"timestamp\":%lld,\
836 \"action\":\"resize\",\
837 \"address\":0x%lx,\
838 \"new_size\":%d,\
839 \"returned\":%d\
840 },\n\
841 "
842     , (long long)HDtime(NULL), (unsigned long)entry->addr,
843       (int)new_size, (int)fxn_ret_value);
844 
845     /* Write the log message to the file */
846     if(H5C_write_log_message(cache, msg) < 0)
847         HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message")
848 
849 done:
850     FUNC_LEAVE_NOAPI(ret_value)
851 } /* H5AC__write_resize_entry_log_msg() */
852 
853 
854 /*-------------------------------------------------------------------------
855  * Function:    H5AC__write_unpin_entry_log_msg
856  *
857  * Purpose:     Write a log message for unpinning a cache entry.
858  *
859  * Return:      Success:        SUCCEED
860  *              Failure:        FAIL
861  *
862  * Programmer:	Dana Robinson
863  *              Sunday, March 16, 2014
864  *
865  *-------------------------------------------------------------------------
866  */
867 herr_t
H5AC__write_unpin_entry_log_msg(const H5AC_t * cache,const H5AC_info_t * entry,herr_t fxn_ret_value)868 H5AC__write_unpin_entry_log_msg(const H5AC_t *cache,
869                                 const H5AC_info_t *entry,
870                                 herr_t fxn_ret_value)
871 {
872     char msg[MSG_SIZE];
873     herr_t ret_value = SUCCEED;
874 
875     FUNC_ENTER_NOAPI(FAIL)
876 
877     /* Sanity checks */
878     HDassert(cache);
879     HDassert(entry);
880 
881     /* Create the log message string */
882     HDsnprintf(msg, MSG_SIZE,
883 "\
884 {\
885 \"timestamp\":%lld,\
886 \"action\":\"unpin\",\
887 \"address\":0x%lx,\
888 \"returned\":%d\
889 },\n\
890 "
891     , (long long)HDtime(NULL), (unsigned long)entry->addr,
892       (int)fxn_ret_value);
893 
894     /* Write the log message to the file */
895     if(H5C_write_log_message(cache, msg) < 0)
896         HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message")
897 
898 done:
899     FUNC_LEAVE_NOAPI(ret_value)
900 } /* H5AC__write_unpin_entry_log_msg() */
901 
902 
903 /*-------------------------------------------------------------------------
904  * Function:    H5AC__write_destroy_fd_log_msg
905  *
906  * Purpose:     Write a log message for destroying a flush dependency
907  *              between two cache entries.
908  *
909  * Return:      Success:        SUCCEED
910  *              Failure:        FAIL
911  *
912  * Programmer:	Dana Robinson
913  *              Sunday, March 16, 2014
914  *
915  *-------------------------------------------------------------------------
916  */
917 herr_t
H5AC__write_destroy_fd_log_msg(const H5AC_t * cache,const H5AC_info_t * parent,const H5AC_info_t * child,herr_t fxn_ret_value)918 H5AC__write_destroy_fd_log_msg(const H5AC_t *cache,
919                                const H5AC_info_t *parent,
920                                const H5AC_info_t *child,
921                                herr_t fxn_ret_value)
922 {
923     char msg[MSG_SIZE];
924     herr_t ret_value = SUCCEED;
925 
926     FUNC_ENTER_NOAPI(FAIL)
927 
928     /* Sanity checks */
929     HDassert(cache);
930     HDassert(parent);
931     HDassert(child);
932 
933     /* Create the log message string */
934     HDsnprintf(msg, MSG_SIZE,
935 "\
936 {\
937 \"timestamp\":%lld,\
938 \"action\":\"destroy_fd\",\
939 \"parent_addr\":0x%lx,\
940 \"child_addr\":0x%lx,\
941 \"returned\":%d\
942 },\n\
943 "
944     , (long long)HDtime(NULL), (unsigned long)parent->addr,
945       (unsigned long)child->addr, (int)fxn_ret_value);
946 
947     /* Write the log message to the file */
948     if(H5C_write_log_message(cache, msg) < 0)
949         HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message")
950 
951 done:
952     FUNC_LEAVE_NOAPI(ret_value)
953 } /* H5AC__write_destroy_fd_log_msg() */
954 
955 
956 /*-------------------------------------------------------------------------
957  * Function:    H5AC__write_unprotect_entry_log_msg
958  *
959  * Purpose:     Write a log message for unprotecting a cache entry.
960  *
961  * Return:      Success:        SUCCEED
962  *              Failure:        FAIL
963  *
964  * Programmer:	Dana Robinson
965  *              Sunday, March 16, 2014
966  *
967  *-------------------------------------------------------------------------
968  */
969 herr_t
H5AC__write_unprotect_entry_log_msg(const H5AC_t * cache,const H5AC_info_t * entry,int type_id,unsigned flags,herr_t fxn_ret_value)970 H5AC__write_unprotect_entry_log_msg(const H5AC_t *cache,
971                                     const H5AC_info_t *entry,
972                                     int type_id,
973                                     unsigned flags,
974                                     herr_t fxn_ret_value)
975 {
976     char msg[MSG_SIZE];
977     herr_t ret_value = SUCCEED;
978 
979     FUNC_ENTER_NOAPI(FAIL)
980 
981     /* Sanity checks */
982     HDassert(cache);
983     HDassert(entry);
984 
985     /* Create the log message string */
986     HDsnprintf(msg, MSG_SIZE,
987 "\
988 {\
989 \"timestamp\":%lld,\
990 \"action\":\"unprotect\",\
991 \"address\":0x%lx,\
992 \"id\":%d,\
993 \"flags\":%x,\
994 \"returned\":%d\
995 },\n\
996 "
997     , (long long)HDtime(NULL), (unsigned long)entry->addr,
998       type_id, flags, (int)fxn_ret_value);
999 
1000     HDsnprintf(msg, MSG_SIZE, " ");
1001 
1002     /* Write the log message to the file */
1003     if(H5C_write_log_message(cache, msg) < 0)
1004         HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message")
1005 
1006 done:
1007     FUNC_LEAVE_NOAPI(ret_value)
1008 } /* H5AC__write_unprotect_entry_log_msg() */
1009 
1010 
1011 /*-------------------------------------------------------------------------
1012  * Function:    H5AC__write_set_cache_config_log_msg
1013  *
1014  * Purpose:     Write a log message for setting the cache configuration.
1015  *
1016  * Return:      Success:        SUCCEED
1017  *              Failure:        FAIL
1018  *
1019  * Programmer:	Dana Robinson
1020  *              Sunday, March 16, 2014
1021  *
1022  *-------------------------------------------------------------------------
1023  */
1024 herr_t
H5AC__write_set_cache_config_log_msg(const H5AC_t * cache,const H5AC_cache_config_t * config,herr_t fxn_ret_value)1025 H5AC__write_set_cache_config_log_msg(const H5AC_t *cache,
1026                                      const H5AC_cache_config_t *config,
1027                                      herr_t fxn_ret_value)
1028 {
1029     char msg[MSG_SIZE];
1030     herr_t ret_value = SUCCEED;
1031 
1032     FUNC_ENTER_NOAPI(FAIL)
1033 
1034     /* Sanity checks */
1035     HDassert(cache);
1036     HDassert(config);
1037 
1038     /* Create the log message string */
1039     HDsnprintf(msg, MSG_SIZE,
1040 "\
1041 {\
1042 \"timestamp\":%lld,\
1043 \"action\":\"set_config\",\
1044 \"returned\":%d\
1045 },\n\
1046 "
1047     , (long long)HDtime(NULL), (int)fxn_ret_value);
1048 
1049 
1050     /* Write the log message to the file */
1051     if(H5C_write_log_message(cache, msg) < 0)
1052         HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message")
1053 
1054 done:
1055     FUNC_LEAVE_NOAPI(ret_value)
1056 } /* H5AC__write_set_cache_config_log_msg() */
1057 
1058 
1059 /*-------------------------------------------------------------------------
1060  * Function:    H5AC__write_remove_entry_log_msg
1061  *
1062  * Purpose:     Write a log message for removing a cache entry.
1063  *
1064  * Return:      Success:        SUCCEED
1065  *              Failure:        FAIL
1066  *
1067  * Programmer:  Quincey Koziol
1068  *              September 17, 2016
1069  *
1070  *-------------------------------------------------------------------------
1071  */
1072 herr_t
H5AC__write_remove_entry_log_msg(const H5AC_t * cache,const H5AC_info_t * entry,herr_t fxn_ret_value)1073 H5AC__write_remove_entry_log_msg(const H5AC_t *cache, const H5AC_info_t *entry,
1074     herr_t fxn_ret_value)
1075 {
1076     char msg[MSG_SIZE];
1077     herr_t ret_value = SUCCEED;
1078 
1079     FUNC_ENTER_NOAPI(FAIL)
1080 
1081     /* Sanity checks */
1082     HDassert(cache);
1083     HDassert(entry);
1084 
1085     /* Create the log message string */
1086     HDsnprintf(msg, MSG_SIZE,
1087 "\
1088 {\
1089 \"timestamp\":%lld,\
1090 \"action\":\"remove\",\
1091 \"address\":0x%lx,\
1092 \"returned\":%d\
1093 },\n\
1094 "
1095     , (long long)HDtime(NULL), (unsigned long)entry->addr,
1096       (int)fxn_ret_value);
1097 
1098     /* Write the log message to the file */
1099     if(H5C_write_log_message(cache, msg) < 0)
1100         HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message")
1101 
1102 done:
1103     FUNC_LEAVE_NOAPI(ret_value)
1104 } /* H5AC__write_remove_entry_log_msg() */
1105 
1106