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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 files COPYING and Copyright.html. COPYING can be found at the root *
* of the source code distribution tree; Copyright.html can be found at the *
* root level of an installed copy of the electronic HDF5 document set and *
* is linked from the top-level documents page. It can also be found at *
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "H5VLiod_server.h"
#include "H5RCpublic.h"
#include "H5TRpublic.h"
#ifdef H5_HAVE_EFF
#if H5_HAVE_IOD_CORRUPT_TOOL
static void check_ion_corruptions(iod_trans_id_t trans_num);
static void check_daos_corruptions(iod_hint_list_t *chint, iod_trans_id_t trans_num);
#endif
/*
* Programmer: Mohamad Chaarawi <chaarawi@hdfgroup.gov>
* July, 2013
*
* Purpose: The IOD plugin server side transaction and read context routines.
*/
/*-------------------------------------------------------------------------
* Function: H5VL_iod_server_rcxt_acquire_cb
*
* Purpose: Acquire a read context of a container using a version number.
*
* Return: Success: SUCCEED
* Failure: Negative
*
* Programmer: Mohamad Chaarawi
* September, 2013
*
*-------------------------------------------------------------------------
*/
void
H5VL_iod_server_rcxt_acquire_cb(AXE_engine_t UNUSED axe_engine,
size_t UNUSED num_n_parents, AXE_task_t UNUSED n_parents[],
size_t UNUSED num_s_parents, AXE_task_t UNUSED s_parents[],
void *_op_data)
{
op_data_t *op_data = (op_data_t *)_op_data;
rc_acquire_in_t *input = (rc_acquire_in_t *)op_data->input;
rc_acquire_out_t output;
iod_handle_t coh = input->coh; /* the container handle */
iod_trans_id_t c_version = input->c_version;
iod_trans_id_t acquired_version;
hid_t rcapl_id;
iod_ret_t ret;
H5RC_request_t acquire_req;
herr_t ret_value = SUCCEED;
if(H5P_DEFAULT == input->rcapl_id)
input->rcapl_id = H5Pcopy(H5P_RC_ACQUIRE_DEFAULT);
rcapl_id = input->rcapl_id;
if(H5Pget_rcapl_version_request(rcapl_id, &acquire_req) < 0) {
HGOTO_ERROR_FF(FAIL, "can't get acquire request property");
}
switch(acquire_req) {
case H5RC_EXACT:
#if H5_EFF_DEBUG
fprintf(stderr, "Exact Acquire Read Context %"PRIu64"\n", input->c_version);
#endif
if((ret = iod_trans_start(coh, &c_version, NULL, 0, IOD_TRANS_R, NULL)) < 0) {
fprintf(stderr, "can't acquire read context. %d (%s).\n", ret, strerror(-ret));
HGOTO_ERROR_FF(FAIL, "can't acquire read context");
}
acquired_version = c_version;
break;
case H5RC_LAST:
#if H5_EFF_DEBUG
fprintf(stderr, "Acquire LAST Read Context\n");
#endif
c_version = IOD_TID_UNKNOWN;
if(iod_trans_start(coh, &c_version, NULL, 0, IOD_TRANS_R, NULL) < 0)
HGOTO_ERROR_FF(FAIL, "can't acquire read context");
acquired_version = c_version;
break;
case H5RC_NEXT:
{
iod_cont_trans_stat_t *tids;
uint64_t u;
#if H5_EFF_DEBUG
fprintf(stderr, "Next Acquire Read Context %"PRIu64"\n", input->c_version);
#endif
if(iod_query_cont_trans_stat(coh, &tids, NULL) < 0)
HGOTO_ERROR_FF(FAIL, "can't get container tids status");
acquired_version = IOD_TID_UNKNOWN;
for(u=c_version; u<tids->latest_rdable ; u++) {
if(iod_trans_start(coh, &u, NULL, 0, IOD_TRANS_R, NULL) < 0)
continue;
acquired_version = u;
break;
}
if(IOD_TID_UNKNOWN == acquired_version) {
HGOTO_ERROR_FF(FAIL,
"can't get a read version");
}
if(iod_free_cont_trans_stat(coh, tids) < 0)
HGOTO_ERROR_FF(FAIL, "can't free container transaction status object");
break;
}
case H5RC_PREV:
{
iod_cont_trans_stat_t *tids;
uint64_t u;
#if H5_EFF_DEBUG
fprintf(stderr, "Next Acquire Read Context %"PRIu64"\n", input->c_version);
#endif
if(iod_query_cont_trans_stat(coh, &tids, NULL) < 0)
HGOTO_ERROR_FF(FAIL, "can't get container tids status");
if(c_version >= tids->latest_rdable) {
acquired_version = tids->latest_rdable;
if(iod_trans_start(coh, &acquired_version, NULL, 0, IOD_TRANS_R, NULL) < 0)
HGOTO_ERROR_FF(FAIL, "can't acquire read context");
break;
}
acquired_version = IOD_TID_UNKNOWN;
u=c_version;
for(u=c_version; u>0; u--) {
if(iod_trans_start(coh, &u, NULL, 0, IOD_TRANS_R, NULL) < 0)
continue;
acquired_version = u;
break;
}
if(IOD_TID_UNKNOWN == acquired_version) {
HGOTO_ERROR_FF(FAIL,
"can't get a read version");
}
if(iod_free_cont_trans_stat(coh, tids) < 0)
HGOTO_ERROR_FF(FAIL, "can't free container transaction status object");
break;
}
default:
HGOTO_ERROR_FF(FAIL, "invalid acquire request");
}
output.c_version = acquired_version;
output.ret = ret_value;
#if H5_EFF_DEBUG
fprintf(stderr, "Done with Acquire Read Context. Acquired %"PRIu64"\n", output.c_version);
#endif
HG_Handler_start_output(op_data->hg_handle, &output);
done:
/* return an UNDEFINED oh to the client if the operation failed */
if(ret_value < 0) {
fprintf(stderr, "Failed to Acquire Read context\n");
output.ret = FAIL;
output.c_version = c_version;
HG_Handler_start_output(op_data->hg_handle, &output);
}
input = (rc_acquire_in_t *)H5MM_xfree(input);
op_data = (op_data_t *)H5MM_xfree(op_data);
} /* end H5VL_iod_server_rcxt_acquire_cb() */
/*-------------------------------------------------------------------------
* Function: H5VL_iod_server_rcxt_release_cb
*
* Purpose: Release a read context of a container using a version number.
*
* Return: Success: SUCCEED
* Failure: Negative
*
* Programmer: Mohamad Chaarawi
* September, 2013
*
*-------------------------------------------------------------------------
*/
void
H5VL_iod_server_rcxt_release_cb(AXE_engine_t UNUSED axe_engine,
size_t UNUSED num_n_parents, AXE_task_t UNUSED n_parents[],
size_t UNUSED num_s_parents, AXE_task_t UNUSED s_parents[],
void *_op_data)
{
op_data_t *op_data = (op_data_t *)_op_data;
rc_release_in_t *input = (rc_release_in_t *)op_data->input;
iod_handle_t coh = input->coh; /* the container handle */
herr_t ret_value = SUCCEED;
#if H5_EFF_DEBUG
fprintf(stderr, "Release Read Context %"PRIu64"\n", input->c_version);
#endif
if(iod_trans_finish(coh, input->c_version, NULL, 0, NULL) < 0)
HGOTO_ERROR_FF(FAIL, "can't release Read Context");
done:
if(HG_SUCCESS != HG_Handler_start_output(op_data->hg_handle, &ret_value))
fprintf(stderr, "Failed to Release Read context\n");
input = (rc_release_in_t *)H5MM_xfree(input);
op_data = (op_data_t *)H5MM_xfree(op_data);
} /* end H5VL_iod_server_rcxt_release_cb() */
/*-------------------------------------------------------------------------
* Function: H5VL_iod_server_rcxt_persist_cb
*
* Purpose: Persist a read context of a container using a version number.
*
* Return: Success: SUCCEED
* Failure: Negative
*
* Programmer: Mohamad Chaarawi
* September, 2013
*
*-------------------------------------------------------------------------
*/
void
H5VL_iod_server_rcxt_persist_cb(AXE_engine_t UNUSED axe_engine,
size_t UNUSED num_n_parents, AXE_task_t UNUSED n_parents[],
size_t UNUSED num_s_parents, AXE_task_t UNUSED s_parents[],
void *_op_data)
{
op_data_t *op_data = (op_data_t *)_op_data;
rc_persist_in_t *input = (rc_persist_in_t *)op_data->input;
iod_handle_t coh = input->coh; /* the container handle */
char *persist = NULL, *sleep_timer = NULL;
int num_persist_retry = 0, i;
iod_trans_id_t tid = input->c_version;
int sleep_t = 0;
iod_ret_t ret;
iod_hint_list_t *chint = NULL;
herr_t ret_value = SUCCEED;
#if H5_EFF_DEBUG
fprintf(stderr, "Persist Read Context %"PRIu64"\n", tid);
#endif
persist = getenv ("H5ENV_NUM_PERSIST_RETRY");
sleep_timer = getenv ("H5ENV_SLEEP_PERSIST_RETRY");
if(NULL != persist)
num_persist_retry = atoi(persist);
if(NULL != sleep_timer)
sleep_t = atoi(sleep_timer);
#if H5_HAVE_IOD_CORRUPT_TOOL
chint = (iod_hint_list_t *)malloc(sizeof(iod_hint_list_t) + 9*sizeof(iod_hint_t));
chint->num_hint = 0;
check_daos_corruptions(chint, tid);
if(chint != NULL && 0 == chint->num_hint) {
free (chint);
chint = NULL;
}
#endif
ret = iod_trans_persist(coh, tid, chint, NULL);
if(ret != 0) {
fprintf(stderr, "%d (%s).\n", ret, strerror(-ret));
}
if(ret != 0 && -ESHUTDOWN != ret) {
for(i=0 ; i<num_persist_retry; i++) {
fprintf(stderr, "Retry Persist # %d on %"PRIu64".\n", i+1, tid);
ret = iod_trans_persist(coh, tid, NULL, NULL);
if(0 == ret) {
break;
}
else if(-ESHUTDOWN == ret) {
fprintf(stderr, "%d (%s).\n", ret, strerror(-ret));
HGOTO_ERROR_FF(FAIL, "can't persist read context");
}
else {
fprintf(stderr, "Retry failed.. %d (%s).\n", ret, strerror(-ret));
if(sleep_timer)
sleep(sleep_t);
}
}
}
if(ret != 0) {
HGOTO_ERROR_FF(FAIL, "can't persist read context");
}
#if H5_HAVE_IOD_CORRUPT_TOOL
if(chint != NULL) {
for(i=0 ; i<chint->num_hint ; i++) {
if(chint->hint[i].key) {
free(chint->hint[i].key);
chint->hint[i].key = NULL;
}
if(chint->hint[i].value) {
free(chint->hint[i].value);
chint->hint[i].value = NULL;
}
}
free(chint);
}
#endif
done:
if(HG_SUCCESS != HG_Handler_start_output(op_data->hg_handle, &ret_value))
fprintf(stderr, "Failed to Persist Read context\n");
input = (rc_persist_in_t *)H5MM_xfree(input);
op_data = (op_data_t *)H5MM_xfree(op_data);
} /* end H5VL_iod_server_rcxt_persist_cb() */
/*-------------------------------------------------------------------------
* Function: H5VL_iod_server_rcxt_snapshot_cb
*
* Purpose: Snapshot a read context of a container using a version number.
*
* Return: Success: SUCCEED
* Failure: Negative
*
* Programmer: Mohamad Chaarawi
* September, 2013
*
*-------------------------------------------------------------------------
*/
void
H5VL_iod_server_rcxt_snapshot_cb(AXE_engine_t UNUSED axe_engine,
size_t UNUSED num_n_parents, AXE_task_t UNUSED n_parents[],
size_t UNUSED num_s_parents, AXE_task_t UNUSED s_parents[],
void *_op_data)
{
op_data_t *op_data = (op_data_t *)_op_data;
rc_snapshot_in_t *input = (rc_snapshot_in_t *)op_data->input;
iod_handle_t coh = input->coh; /* the container handle */
iod_trans_id_t tid = input->c_version;
herr_t ret_value = SUCCEED;
#if H5_EFF_DEBUG
fprintf(stderr, "Snapshot %s with Read Context %"PRIu64"\n", input->snapshot_name, input->c_version);
#endif
/* MSC - can only snapshot latest version */
if(iod_container_snapshot(coh, tid, input->snapshot_name, NULL, NULL) < 0)
HGOTO_ERROR_FF(FAIL, "can't snapshot Read Context");
done:
if(HG_SUCCESS != HG_Handler_start_output(op_data->hg_handle, &ret_value))
fprintf(stderr, "Failed to Snapshot Read context\n");
input = (rc_snapshot_in_t *)H5MM_xfree(input);
op_data = (op_data_t *)H5MM_xfree(op_data);
} /* end H5VL_iod_server_rcxt_snapshot_cb() */
/*-------------------------------------------------------------------------
* Function: H5VL_iod_server_trans_start_cb
*
* Purpose: Start a transaction on a container.
*
* Return: Success: SUCCEED
* Failure: Negative
*
* Programmer: Mohamad Chaarawi
* September, 2013
*
*-------------------------------------------------------------------------
*/
void
H5VL_iod_server_trans_start_cb(AXE_engine_t UNUSED axe_engine,
size_t UNUSED num_n_parents, AXE_task_t UNUSED n_parents[],
size_t UNUSED num_s_parents, AXE_task_t UNUSED s_parents[],
void *_op_data)
{
op_data_t *op_data = (op_data_t *)_op_data;
tr_start_in_t *input = (tr_start_in_t *)op_data->input;
iod_handle_t coh = input->coh; /* the container handle */
hid_t trspl_id;
iod_trans_id_t trans_num = input->trans_num;
unsigned num_peers; /* the number of peers starting this transaction */
herr_t ret_value = SUCCEED;
#if H5_EFF_DEBUG
fprintf(stderr, "Transaction Start %"PRIu64"\n", input->trans_num);
#endif
if(H5P_DEFAULT == input->trspl_id)
input->trspl_id = H5Pcopy(H5P_TR_START_DEFAULT);
trspl_id = input->trspl_id;
if(H5Pget_trspl_num_peers(trspl_id, &num_peers) < 0)
HGOTO_ERROR_FF(FAIL, "can't get acquire request property");
if(iod_trans_start(coh, &trans_num, NULL, num_peers, IOD_TRANS_W, NULL) < 0)
HGOTO_ERROR_FF(FAIL, "can't start transaction");
#if H5_EFF_DEBUG
fprintf(stderr, "Done with Transaction Start\n");
#endif
done:
if(HG_SUCCESS != HG_Handler_start_output(op_data->hg_handle, &ret_value))
fprintf(stderr, "Failed to Start Transaction\n");
input = (tr_start_in_t *)H5MM_xfree(input);
op_data = (op_data_t *)H5MM_xfree(op_data);
} /* end H5VL_iod_server_trans_start_cb() */
/*-------------------------------------------------------------------------
* Function: H5VL_iod_server_trans_finish_cb
*
* Purpose: Finish a transaction on a container.
*
* Return: Success: SUCCEED
* Failure: Negative
*
* Programmer: Mohamad Chaarawi
* September, 2013
*
*-------------------------------------------------------------------------
*/
void
H5VL_iod_server_trans_finish_cb(AXE_engine_t UNUSED axe_engine,
size_t UNUSED num_n_parents, AXE_task_t UNUSED n_parents[],
size_t UNUSED num_s_parents, AXE_task_t UNUSED s_parents[],
void *_op_data)
{
op_data_t *op_data = (op_data_t *)_op_data;
tr_finish_in_t *input = (tr_finish_in_t *)op_data->input;
iod_handle_t coh = input->coh; /* the container handle */
uint32_t cs_scope = input->cs_scope;
//hid_t trfpl_id;
iod_trans_id_t trans_num = input->trans_num;
hbool_t acquire = input->acquire;
uint32_t client_rank = input->client_rank;
iod_obj_id_t oidkv_id = input->oidkv_id;
iod_handle_t oidkv_oh;
uint64_t oid_index[3];
iod_kv_t kv;
iod_ret_t ret;
int step = 0;
herr_t ret_value = SUCCEED;
#if H5_EFF_DEBUG
fprintf(stderr, "Transaction Finish %"PRIu64"\n", trans_num);
#endif
oid_index[0] = input->kv_oid_index;
oid_index[1] = input->array_oid_index;
oid_index[2] = input->blob_oid_index;
ret = iod_obj_open_write(coh, oidkv_id, trans_num, NULL, &oidkv_oh, NULL);
if(ret != 0)
HGOTO_ERROR_FF(FAIL, "can't open oid KV");
step ++;
kv.value = &oid_index;
kv.value_len = sizeof(iod_obj_id_t) * 3;
kv.key = &client_rank;
kv.key_len = sizeof(uint32_t);
if(cs_scope & H5_CHECKSUM_IOD) {
iod_checksum_t cs[2];
cs[0] = H5_checksum_crc64(kv.key, kv.key_len);
cs[1] = H5_checksum_crc64(kv.value, kv.value_len);
if (iod_kv_set(oidkv_oh, trans_num, NULL, &kv, cs, NULL) < 0)
HGOTO_ERROR_FF(FAIL, "can't set KV pair in parent");
}
else {
if (iod_kv_set(oidkv_oh, trans_num, NULL, &kv, NULL, NULL) < 0)
HGOTO_ERROR_FF(FAIL, "can't set KV pair in oid KV");
}
if(iod_obj_close(oidkv_oh, NULL, NULL) < 0)
HGOTO_ERROR_FF(FAIL, "can't close object handle");
step --;
/* Finish the transaction */
if((ret = iod_trans_finish(coh, trans_num, NULL, 0, NULL)) < 0) {
fprintf(stderr, "can't finish transaction %d (%s).\n", ret, strerror(-ret));
HGOTO_ERROR_FF(FAIL, "can't finish transaction");
}
#if H5_HAVE_IOD_CORRUPT_TOOL
if(0 == client_rank)
check_ion_corruptions(trans_num);
#endif
/* if the flag is true, acquire a read context on the finished transaction */
if(TRUE == acquire) {
#if H5_EFF_DEBUG
fprintf(stderr, "Transaction Acquire after Finish %"PRIu64"\n", trans_num);
#endif
if(iod_trans_start(coh, &trans_num, NULL, 0, IOD_TRANS_R, NULL) < 0)
HGOTO_ERROR_FF(FAIL, "can't acquire read context");
}
#if H5_EFF_DEBUG
fprintf(stderr, "Done with Transaction Finish\n");
#endif
done:
if(HG_SUCCESS != HG_Handler_start_output(op_data->hg_handle, &ret_value))
fprintf(stderr, "Failed to Finish Transaction\n");
if(step == 1) {
iod_obj_close(oidkv_oh, NULL, NULL);
}
input = (tr_finish_in_t *)H5MM_xfree(input);
op_data = (op_data_t *)H5MM_xfree(op_data);
} /* end H5VL_iod_server_trans_finish_cb() */
/*-------------------------------------------------------------------------
* Function: H5VL_iod_server_trans_set_dependency_cb
*
* Purpose: Set Dependency between 2 transactions on a container.
*
* Return: Success: SUCCEED
* Failure: Negative
*
* Programmer: Mohamad Chaarawi
* September, 2013
*
*-------------------------------------------------------------------------
*/
void
H5VL_iod_server_trans_set_dependency_cb(AXE_engine_t UNUSED axe_engine,
size_t UNUSED num_n_parents, AXE_task_t UNUSED n_parents[],
size_t UNUSED num_s_parents, AXE_task_t UNUSED s_parents[],
void *_op_data)
{
op_data_t *op_data = (op_data_t *)_op_data;
tr_set_depend_in_t *input = (tr_set_depend_in_t *)op_data->input;
iod_handle_t coh = input->coh; /* the container handle */
iod_trans_depend_desc_t depends;
herr_t ret_value = SUCCEED;
#if H5_EFF_DEBUG
fprintf(stderr, "Transaction Set_Dependency %"PRIu64" on %"PRIu64"\n",
input->child_trans_num, input->parent_trans_num);
#endif
/* MSC - set depends */
//if(iod_trans_depend(coh, depends, NULL) < 0)
//HGOTO_ERROR_FF(FAIL, "can't set dependency between transactions");
#if H5_EFF_DEBUG
fprintf(stderr, "Done with Transaction Set_Dependency\n");
#endif
done:
if(HG_SUCCESS != HG_Handler_start_output(op_data->hg_handle, &ret_value))
fprintf(stderr, "Failed to Set_Dependency between Transactions\n");
input = (tr_set_depend_in_t *)H5MM_xfree(input);
op_data = (op_data_t *)H5MM_xfree(op_data);
} /* end H5VL_iod_server_trans_set_dependency_cb() */
/*-------------------------------------------------------------------------
* Function: H5VL_iod_server_trans_skip_cb
*
* Purpose: Skip a number of transactions on a container.
*
* Return: Success: SUCCEED
* Failure: Negative
*
* Programmer: Mohamad Chaarawi
* September, 2013
*
*-------------------------------------------------------------------------
*/
void
H5VL_iod_server_trans_skip_cb(AXE_engine_t UNUSED axe_engine,
size_t UNUSED num_n_parents, AXE_task_t UNUSED n_parents[],
size_t UNUSED num_s_parents, AXE_task_t UNUSED s_parents[],
void *_op_data)
{
op_data_t *op_data = (op_data_t *)_op_data;
tr_skip_in_t *input = (tr_skip_in_t *)op_data->input;
iod_handle_t coh = input->coh; /* the container handle */
iod_trans_id_t start_trans_num = input->start_trans_num;
uint64_t count = input->count;
iod_trans_range_desc_t skip_ranges;
herr_t ret_value = SUCCEED;
#if H5_EFF_DEBUG
fprintf(stderr, "Transaction Skip %"PRIu64" starting at %"PRIu64"\n", count, start_trans_num);
#endif
/* MSC - set skip ranges */
skip_ranges.n_range = 1;
//if(iod_trans_skip(coh, skip_ranges, NULL) < 0)
//HGOTO_ERROR_FF(FAIL, "can't skip transactions");
#if H5_EFF_DEBUG
fprintf(stderr, "Done with Transaction Skip\n");
#endif
done:
if(HG_SUCCESS != HG_Handler_start_output(op_data->hg_handle, &ret_value))
fprintf(stderr, "Failed to Skip Transaction\n");
input = (tr_skip_in_t *)H5MM_xfree(input);
op_data = (op_data_t *)H5MM_xfree(op_data);
} /* end H5VL_iod_server_trans_skip_cb() */
/*-------------------------------------------------------------------------
* Function: H5VL_iod_server_trans_abort_cb
*
* Purpose: Abort a transaction on a container.
*
* Return: Success: SUCCEED
* Failure: Negative
*
* Programmer: Mohamad Chaarawi
* September, 2013
*
*-------------------------------------------------------------------------
*/
void
H5VL_iod_server_trans_abort_cb(AXE_engine_t UNUSED axe_engine,
size_t UNUSED num_n_parents, AXE_task_t UNUSED n_parents[],
size_t UNUSED num_s_parents, AXE_task_t UNUSED s_parents[],
void *_op_data)
{
op_data_t *op_data = (op_data_t *)_op_data;
tr_abort_in_t *input = (tr_abort_in_t *)op_data->input;
iod_handle_t coh = input->coh; /* the container handle */
iod_trans_id_t trans_num = input->trans_num;
iod_ret_t ret;
herr_t ret_value = SUCCEED;
#if H5_EFF_DEBUG
fprintf(stderr, "Aborting Transaction %"PRIu64"\n", input->trans_num);
#endif
ret = iod_trans_finish(coh, trans_num, NULL, IOD_TRANS_ABORT_DEPENDENT, NULL);
if(ret == -IOD_EC_TRANS_DISCARDED)
fprintf(stderr, "Transaction %"PRIu64" already discarded\n", input->trans_num);
else if(ret < 0) {
fprintf(stderr, "%d (%s).\n", ret, strerror(-ret));
HGOTO_ERROR_FF(FAIL, "can't abort transaction");
}
#if H5_EFF_DEBUG
fprintf(stderr, "Done with Transaction Abort\n");
#endif
done:
if(HG_SUCCESS != HG_Handler_start_output(op_data->hg_handle, &ret_value))
fprintf(stderr, "Failed to Abort Transaction\n");
input = (tr_abort_in_t *)H5MM_xfree(input);
op_data = (op_data_t *)H5MM_xfree(op_data);
} /* end H5VL_iod_server_trans_abort_cb() */
/*-------------------------------------------------------------------------
* Function: H5VL_iod_server_prefetch_cb
*
* Purpose: prefetch an object from central storage to BB.
*
* Return: Success: SUCCEED
* Failure: Negative
*
* Programmer: Mohamad Chaarawi
* February 2014
*
*-------------------------------------------------------------------------
*/
void
H5VL_iod_server_prefetch_cb(AXE_engine_t UNUSED axe_engine,
size_t UNUSED num_n_parents, AXE_task_t UNUSED n_parents[],
size_t UNUSED num_s_parents, AXE_task_t UNUSED s_parents[],
void *_op_data)
{
op_data_t *op_data = (op_data_t *)_op_data;
prefetch_in_t *input = (prefetch_in_t *)op_data->input;
//iod_handle_t coh = input->coh; /* the container handle */
iod_trans_id_t tid = input->rcxt_num;
iod_handles_t iod_oh = input->iod_oh; /* object handle */
iod_obj_id_t iod_id = input->iod_id; /* OID */
//H5I_type_t obj_type = input->obj_type;
//hid_t apl_id = input->apl_id;
iod_trans_id_t replica_id;
iod_ret_t ret;
herr_t ret_value = SUCCEED;
#if H5_EFF_DEBUG
fprintf(stderr, "Prefetch Object (OID %"PRIx64" OH %"PRIu64") at Version %"PRIu64"\n",
iod_id, iod_oh.rd_oh.cookie, tid);
#endif
ret = iod_obj_fetch(iod_oh.rd_oh, tid, NULL, NULL, NULL, &replica_id, NULL);
if(ret != 0) {
fprintf(stderr, "%d (%s).\n", ret, strerror(-ret));
HGOTO_ERROR_FF(FAIL, "can't prefetch object");
}
#if H5_EFF_DEBUG
fprintf(stderr, "Done with Prefetch\n");
#endif
done:
if(SUCCEED != ret_value)
replica_id = 0;
if(HG_SUCCESS != HG_Handler_start_output(op_data->hg_handle, &replica_id))
fprintf(stderr, "Failed to Prefetch Object\n");
input = (prefetch_in_t *)H5MM_xfree(input);
op_data = (op_data_t *)H5MM_xfree(op_data);
} /* end H5VL_iod_server_prefetch_cb() */
/*-------------------------------------------------------------------------
* Function: H5VL_iod_server_evict_cb
*
* Purpose: evicts an object from BB.
*
* Return: Success: SUCCEED
* Failure: Negative
*
* Programmer: Mohamad Chaarawi
* February 2014
*
*-------------------------------------------------------------------------
*/
void
H5VL_iod_server_evict_cb(AXE_engine_t UNUSED axe_engine,
size_t UNUSED num_n_parents, AXE_task_t UNUSED n_parents[],
size_t UNUSED num_s_parents, AXE_task_t UNUSED s_parents[],
void *_op_data)
{
op_data_t *op_data = (op_data_t *)_op_data;
evict_in_t *input = (evict_in_t *)op_data->input;
//iod_handle_t coh = input->coh; /* the container handle */
iod_trans_id_t tid = input->rcxt_num;
iod_handles_t iod_oh = input->iod_oh; /* object handle */
iod_obj_id_t iod_id = input->iod_id; /* OID */
//H5I_type_t obj_type = input->obj_type;
//hid_t apl_id = input->apl_id;
iod_trans_id_t replica_id = input->replica_id;
iod_ret_t ret;
herr_t ret_value = SUCCEED;
if(replica_id) {
fprintf(stderr, "Evict Object (OID %"PRIx64" OH %"PRIu64") replica tag %"PRIx64"\n",
iod_id, iod_oh.rd_oh.cookie, replica_id);
ret = iod_obj_purge(iod_oh.rd_oh, replica_id, NULL, NULL);
}
else {
fprintf(stderr, "Evict Object (OID %"PRIx64" OH %"PRIu64") at Version %"PRIu64"\n",
iod_id, iod_oh.rd_oh.cookie, tid);
ret = iod_obj_purge(iod_oh.rd_oh, tid, NULL, NULL);
}
if(ret < 0) {
fprintf(stderr, "%d (%s).\n", ret, strerror(-ret));
HGOTO_ERROR_FF(FAIL, "can't evict object");
}
#if H5_EFF_DEBUG
fprintf(stderr, "Done with Evict\n");
#endif
done:
if(HG_SUCCESS != HG_Handler_start_output(op_data->hg_handle, &ret_value))
fprintf(stderr, "Failed to Evict Object\n");
input = (evict_in_t *)H5MM_xfree(input);
op_data = (op_data_t *)H5MM_xfree(op_data);
} /* end H5VL_iod_server_evict_cb() */
#if H5_HAVE_IOD_CORRUPT_TOOL
static void check_ion_corruptions(iod_trans_id_t trans_num)
{
int step;
char *cor_step = NULL;
char *num_procs_s = NULL;
int num_procs = -1;
char *cor_data_s = NULL;
int cor_data = -1;
int ret;
num_procs_s = getenv ("H5ENV_NUM_CLIENTS");
if(NULL != num_procs_s)
num_procs = atoi(num_procs_s);
else
return;
cor_data_s = getenv ("H5ENV_CORRUPT_DATA");
if(NULL != cor_data_s)
cor_data = atoi(cor_data_s);
else
return;
cor_step = getenv ("H5ENV_STEP_CORRUPT_BB_DSET");
if(NULL != cor_step) {
step = atoi(cor_step);
if((int)trans_num == step+3) {
uint64_t oid;
oid = step*8*num_procs + num_procs;
IOD_OBJID_SETOWNER_APP(oid)
IOD_OBJID_SETTYPE(oid, IOD_OBJ_ARRAY)
if(cor_data)
printf("CORRUPTING DATA at step %d, ARRAY ID %"PRIx64"\n",
step, oid);
else
printf("CORRUPTING CS at step %d, ARRAY ID %"PRIx64"\n",
step, oid);
ret = corrupt_data("eff_vpic", oid, trans_num, 20, cor_data);
if(ret < 0) {
fprintf(stderr, "cant't corrupt data. %d (%s).\n", ret, strerror(-ret));
}
}
}
cor_step = NULL;
step = -1;
cor_step = getenv ("H5ENV_STEP_CORRUPT_BB_DTYPE");
if(NULL != cor_step) {
step = atoi(cor_step);
if((int)trans_num == step+3) {
uint64_t oid;
oid = step*num_procs;
IOD_OBJID_SETOWNER_APP(oid)
IOD_OBJID_SETTYPE(oid, IOD_OBJ_BLOB)
if(cor_data)
printf("CORRUPTING DATA at step %d, BLOB ID %"PRIx64"\n",
step, oid);
else
printf("CORRUPTING CS at step %d, BLOB ID %"PRIx64"\n",
step, oid);
ret = corrupt_data("eff_vpic", oid, trans_num, 5, cor_data);
if(ret < 0) {
fprintf(stderr, "cant't corrupt data. %d (%s).\n", ret, strerror(-ret));
}
}
}
cor_step = NULL;
step = -1;
cor_step = getenv ("H5ENV_STEP_CORRUPT_BB_GROUP");
if(NULL != cor_step) {
step = atoi(cor_step);
if((int)trans_num == step+3) {
uint64_t oid;
oid = 0;//5*num_procs + step*21*num_procs;
IOD_OBJID_SETOWNER_APP(oid)
IOD_OBJID_SETTYPE(oid, IOD_OBJ_KV)
if(cor_data)
printf("CORRUPTING DATA at step %d, KV ID %"PRIx64"\n",
step, oid);
else
printf("CORRUPTING CS at step %d, KV ID %"PRIx64"\n",
step, oid);
ret = corrupt_kv("eff_vpic", oid, trans_num, step*2+1, cor_data);
if(ret < 0) {
fprintf(stderr, "cant't corrupt data. %d (%s).\n", ret, strerror(-ret));
}
}
}
}
static void check_daos_corruptions(iod_hint_list_t *chint, iod_trans_id_t trans_num)
{
int step;
char *cor_step = NULL;
char *num_procs_s = NULL;
int num_procs = -1;
char *cor_data_s = NULL;
int cor_data = -1;
int ret, i;
num_procs_s = getenv ("H5ENV_NUM_CLIENTS");
if(NULL != num_procs_s)
num_procs = atoi(num_procs_s);
else
return;
cor_data_s = getenv ("H5ENV_CORRUPT_DATA");
if(NULL != cor_data_s)
cor_data = atoi(cor_data_s);
else
return;
chint->num_hint = 0;
i = 0;
cor_step = getenv ("H5ENV_STEP_CORRUPT_DAOS_DSET");
if(NULL != cor_step) {
uint64_t oid;
step = atoi(cor_step);
if((int)trans_num == step+3) {
oid = step*8*num_procs + num_procs;
IOD_OBJID_SETOWNER_APP(oid)
IOD_OBJID_SETTYPE(oid, IOD_OBJ_ARRAY)
chint->num_hint += 2;
chint->hint[i].key = strdup("iod_hint_obj_corrupt_offset");
chint->hint[i].value = strdup("20");
i++;
chint->hint[i].key = strdup("iod_hint_obj_corrupt_whichone");
chint->hint[i].value = (char *)malloc(50);
sprintf(chint->hint[i].value, "0x%llx", (unsigned long long)oid);
i++;
if(!cor_data) {
chint->num_hint ++;
chint->hint[i].key = strdup("iod_hint_obj_corrupt_checksum");
chint->hint[i].value = NULL;
i++;
printf("CORRUPTING CS at VPIC step %d, array ID %"PRIx64"\n",
step, oid);
}
else {
printf("CORRUPTING Data at VPIC step %d, array ID %"PRIx64"\n",
step, oid);
}
}
}
cor_step = NULL;
step = -1;
cor_step = getenv ("H5ENV_STEP_CORRUPT_DAOS_DTYPE");
if(NULL != cor_step) {
uint64_t oid;
step = atoi(cor_step);
if((int)trans_num == step+3) {
oid = step*num_procs;
IOD_OBJID_SETOWNER_APP(oid)
IOD_OBJID_SETTYPE(oid, IOD_OBJ_BLOB)
chint->num_hint += 2;
chint->hint[i].key = strdup("iod_hint_obj_corrupt_offset");
chint->hint[i].value = strdup("5");
i++;
chint->hint[i].key = strdup("iod_hint_obj_corrupt_whichone");
chint->hint[i].value = (char *)malloc(50);
sprintf(chint->hint[i].value, "0x%llx", (unsigned long long)oid);
//sprintf(chint->hint[i].value, "0x%"PRIx64"", oid);
i++;
if(!cor_data) {
chint->num_hint ++;
chint->hint[i].key = strdup("iod_hint_obj_corrupt_checksum");
chint->hint[i].value = NULL;
i++;
printf("CORRUPTING CS at VPIC step %d, blob ID %"PRIx64"\n",
step, oid);
}
else {
printf("CORRUPTING Data at VPIC step %d, blob ID %"PRIx64"\n",
step, oid);
}
}
}
cor_step = NULL;
step = -1;
cor_step = getenv ("H5ENV_STEP_CORRUPT_DAOS_GROUP");
if(NULL != cor_step) {
uint64_t oid;
step = atoi(cor_step);
if((int)trans_num == step+3) {
oid = 0;
IOD_OBJID_SETOWNER_APP(oid)
IOD_OBJID_SETTYPE(oid, IOD_OBJ_KV)
chint->num_hint += 2;
chint->hint[i].key = strdup("iod_hint_obj_corrupt_offset");
chint->hint[i].value = (char *)malloc(10);
sprintf(chint->hint[i].value, "%d", step*2+1);
i++;
chint->hint[i].key = strdup("iod_hint_obj_corrupt_whichone");
chint->hint[i].value = (char *)malloc(50);
sprintf(chint->hint[i].value, "0x%llx", (unsigned long long)oid);
//sprintf(chint->hint[i].value, "0x%"PRIx64"", oid);
i++;
if(!cor_data) {
chint->num_hint ++;
chint->hint[i].key = strdup("iod_hint_obj_corrupt_checksum");
chint->hint[i].value = NULL;
i++;
printf("CORRUPTING CS at VPIC step %d, KV ID %"PRIx64"\n",
step, oid);
}
else {
printf("CORRUPTING Data at VPIC step %d, KV ID %"PRIx64"\n",
step, oid);
}
ret = corrupt_kv("eff_vpic", oid, trans_num, step*2+1, cor_data);
if(ret < 0) {
fprintf(stderr, "cant't corrupt data. %d (%s).\n", ret, strerror(-ret));
}
}
}
}
#endif
#endif /* H5_HAVE_EFF */
|