forked from daos-stack/daos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
daos_api.h
1175 lines (1111 loc) · 40.2 KB
/
daos_api.h
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
/**
* (C) Copyright 2015-2018 Intel Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* GOVERNMENT LICENSE RIGHTS-OPEN SOURCE SOFTWARE
* The Government's rights to use, modify, reproduce, release, perform, display,
* or disclose this software are subject to the terms of the Apache License as
* provided in Contract No. B609815.
* Any reproduction of computer software, computer software documentation, or
* portions thereof marked with this legend must also reproduce the markings.
*/
/**
* DAOS APIs
*/
#ifndef __DAOS_API_H__
#define __DAOS_API_H__
#if defined(__cplusplus)
extern "C" {
#endif
/**
* Initialize the DAOS library.
*/
int
daos_init(void);
/**
* Finalize the DAOS library.
*/
int
daos_fini(void);
/**
* Connect to the DAOS pool identified by UUID \a uuid. Upon a successful
* completion, \a poh returns the pool handle, and \a info returns the latest
* pool information.
*
* \param uuid [IN] UUID to identify a pool.
* \param grp [IN] Process set name of the DAOS servers managing the pool
* \param svc [IN] Pool service replica ranks, as reported by
* daos_pool_create().
* \param flags [IN] Connect mode represented by the DAOS_PC_ bits.
* \param poh [OUT] Returned open handle.
* \param info [OUT] Returned pool info.
* \param ev [IN] Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*
* \return These values will be returned by \a ev::ev_error in
* non-blocking mode:
* 0 Success
* -DER_INVAL Invalid parameter
* -DER_UNREACH Network is unreachable
* -DER_NO_PERM Permission denied
* -DER_NONEXIST Pool is nonexistent
*/
int
daos_pool_connect(const uuid_t uuid, const char *grp,
const d_rank_list_t *svc, unsigned int flags,
daos_handle_t *poh, daos_pool_info_t *info, daos_event_t *ev);
/**
* Disconnect from the DAOS pool. It should revoke all the container open
* handles of this pool.
*
* \param poh [IN] Pool connection handle
* \param ev [IN] Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*
* \return These values will be returned by \a ev::ev_error in
* non-blocking mode:
* 0 Success
* -DER_UNREACH Network is unreachable
* -DER_NO_HDL Invalid pool handle
*/
int
daos_pool_disconnect(daos_handle_t poh, daos_event_t *ev);
/**
* Handle API
*/
/**
* Convert a local pool connection to global representation data which can be
* shared with peer processes.
* If glob->iov_buf is set to NULL, the actual size of the global handle is
* returned through glob->iov_buf_len.
* This function does not involve any communication and does not block.
*
* \param poh [IN] Valid local pool connection handle to be shared
* \param glob [OUT] Pointer to iov of the buffer to store handle information
*
* \return These values will be returned:
* non-blocking mode:
* 0 Success
* -DER_INVAL Invalid parameter
* -DER_NO_HDL Pool handle is nonexistent
* -DER_TRUNC Buffer in \a glob is too short, a larger
* buffer is required. In this case the
* required buffer size is returned through
* glob->iov_buf_len.
*/
int
daos_pool_local2global(daos_handle_t poh, daos_iov_t *glob);
/**
* Create a local pool connection for global representation data.
*
* \param glob [IN] Global (shared) representation of a collective handle
* to be extracted
* \param poh [OUT] Returned local pool connection handle
*
* \return These values will be returned:
* non-blocking mode:
* 0 Success
* -DER_INVAL Invalid parameter
*/
int
daos_pool_global2local(daos_iov_t glob, daos_handle_t *poh);
/**
* Convert a local container handle to global representation data which can be
* shared with peer processes.
* If glob->iov_buf is set to NULL, the actual size of the global handle is
* returned through glob->iov_buf_len.
* This function does not involve any communication and does not block.
*
* \param coh [IN] valid local container handle to be shared
* \param glob [OUT] pointer to iov of the buffer to store handle information
*
* \return These values will be returned:
* non-blocking mode:
* 0 Success
* -DER_INVAL Invalid parameter
* -DER_NO_HDL Container handle is nonexistent
* -DER_TRUNC Buffer in \a glob is too short, larger
* buffer required. In this case the
* required buffer size is returned through
* glob->iov_buf_len.
*/
int
daos_cont_local2global(daos_handle_t coh, daos_iov_t *glob);
/**
* Create a local container handle for global representation data.
*
* \param poh [IN] Pool connection handle the container belong to
* \param glob [IN] Global (shared) representation of a collective handle
* to be extracted
* \param coh [OUT] Returned local container handle
*
* \return These values will be returned:
* non-blocking mode:
* 0 Success
* -DER_INVAL Invalid parameter
* -DER_NO_HDL Pool handle is nonexistent
*/
int
daos_cont_global2local(daos_handle_t poh, daos_iov_t glob, daos_handle_t *coh);
/**
* Query pool information. User should provide at least one of \a info and
* \a tgts as output buffer.
*
* \param poh [IN] Pool connection handle.
* \param tgts [OUT] Optional, returned storage targets in this pool.
* \param info [OUT] Optional, returned pool information.
* \param ev [IN] Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*
* \return These values will be returned by \a ev::ev_error in
* non-blocking mode:
* 0 Success
* -DER_INVAL Invalid parameter
* -DER_UNREACH Network is unreachable
* -DER_NO_HDL Invalid pool handle
*/
int
daos_pool_query(daos_handle_t poh, d_rank_list_t *tgts,
daos_pool_info_t *info, daos_event_t *ev);
/**
* Query information of storage targets within a DAOS pool.
*
* \param poh [IN] Pool connection handle.
* \param tgts [IN] A list of targets to query.
* \param failed
* [OUT] Optional, buffer to store faulty targets on failure.
* \param info_list
* [OUT] Returned storage information of \a tgts, it is an array
* and array size must equal to tgts::rl_llen.
* \param ev [IN] Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*
* \return These values will be returned by \a ev::ev_error in
* non-blocking mode:
* 0 Success
* -DER_INVAL Invalid parameter
* -DER_NO_HDL Invalid pool handle
* -DER_UNREACH Network is unreachable
* -DER_NONEXIST No pool on specified targets
*/
int
daos_pool_target_query(daos_handle_t poh, d_rank_list_t *tgts,
d_rank_list_t *failed, daos_target_info_t *info_list,
daos_event_t *ev);
/**
* List the names of all user-defined pool attributes.
*
* \param poh [IN] Pool handle.
* \param buffer [OUT] Buffer containing concatenation of all attribute
* names, each being null-terminated. No truncation is
* performed and only full names will be returned.
* NULL is permitted in which case only the aggregate
* size will be retrieved.
* \param size [IN] Buffer size.
* [OUT] Aggregate size of all attribute names (excluding
* terminating null characters), regardless of the
* actual buffer size.
* \param ev [IN] Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*/
int
daos_pool_attr_list(daos_handle_t poh, char *buffer, size_t *size,
daos_event_t *ev);
/**
* Retrieve a list of user-defined pool attribute values.
*
* \param poh [IN] Pool handle
* \param n [IN] Number of attributes
* \param names [IN] Array of \a n null-terminated attribute names.
* \param buffers [OUT] Array of \a n buffers to store attribute values.
* Attribute values larger than corresponding
* buffer sizes will be truncated. NULL values are
* permitted and will be treated identical to
* zero-length buffers, in which case only the
* sizes of attribute values will be retrieved.
* \param sizes [IN] Array of \a n buffer sizes.
* [OUT] Array of actual sizes of \a n attribute values,
* regardless of given buffer sizes.
* \param ev [IN] Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*/
int
daos_pool_attr_get(daos_handle_t poh, int n, char const *const names[],
void *const buffers[], size_t sizes[], daos_event_t *ev);
/**
* Create or update a list of user-defined pool attributes.
*
* \param poh [IN] Pool handle
* \param n [IN] Number of attributes
* \param names [IN] Array of \a n null-terminated attribute names.
* \param values [IN] Array of \a n attribute values
* \param sizes [IN] Array of \a n elements containing the
* sizes of respective attribute values.
* \param ev [IN] Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*/
int
daos_pool_attr_set(daos_handle_t poh, int n, char const *const names[],
void const *const values[], size_t const sizes[],
daos_event_t *ev);
/**
* Container API
*/
/**
* Create a new container with uuid \a uuid on the storage pool connected
* by \a poh.
*
* \param poh [IN] Pool connection handle.
* \param uuid [IN] UUID of the new Container.
* \param ev [IN] Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*
* \return These values will be returned by \a ev::ev_error in
* non-blocking mode:
* 0 Success
* -DER_INVAL Invalid parameter
* -DER_NO_HDL Invalid pool handle
* -DER_NO_PERM Permission denied
* -DER_UNREACH network is unreachable
*/
int
daos_cont_create(daos_handle_t poh, const uuid_t uuid, daos_event_t *ev);
/**
* Open an existing container identified by UUID \a uuid. Upon successful
* completion, \a coh and \a info, both of which shall be allocated by the
* caller, return the container handle and the latest container information
* respectively. The resulting container handle has an HCE equal to GHCE, an
* LHE equal to DAOS_EPOCH_MAX, and an LRE equal to GHCE.
*
* \param poh [IN] Pool connection handle.
* \param uuid [IN] UUID to identify container.
* \param flags [IN] Open mode, represented by the DAOS_COO_ bits.
* \param coh [OUT] Returned open handle.
* \param info [OUT] Optional, return container information
* \param ev [IN] Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*
* \return These values will be returned by \a ev::ev_error in
* non-blocking mode:
* 0 Success
* -DER_INVAL Invalid parameter
* -DER_UNREACH Network is unreachable
* -DER_NO_PERM Permission denied
* -DER_NONEXIST Container is nonexistent
*/
int
daos_cont_open(daos_handle_t poh, const uuid_t uuid, unsigned int flags,
daos_handle_t *coh, daos_cont_info_t *info, daos_event_t *ev);
/**
* Close a container handle. Upon successful completion, the container handle's
* epoch hold (i.e., if LHE < DAOS_EPOCH_MAX) is released, and any uncommitted
* updates from the container handle are discarded.
*
* \param coh [IN] Container open handle.
* \param ev [IN] Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*
* \return These values will be returned by \a ev::ev_error in
* non-blocking mode:
* 0 Success
* -DER_UNREACH Network is unreachable
* -DER_NO_HDL Invalid container handle
*/
int
daos_cont_close(daos_handle_t coh, daos_event_t *ev);
/**
* Destroy a container identified by \a uuid, all objects within this
* container will be destroyed as well.
* If there is at least one container opener, and \a force is set to zero, then
* the operation completes with DER_BUSY. Otherwise, the container is destroyed
* when the operation completes.
*
* \param poh [IN] Pool connection handle.
* \param uuid [IN] Container UUID.
* \param force [IN] Container destroy will return failure if the container
* is still busy (outstanding open handles). This parameter
* will force the destroy to proceed even if there is an
* outstanding open handle.
* \param ev [IN] Completion event, it is optional and can be NULL.
* Function will run in blocking mode if \a ev is NULL.
*
* \return These values will be returned by \a ev::ev_error in
* non-blocking mode:
* 0 Success
* -DER_NO_PERM Permission denied
* -DER_UNREACH Network is unreachable
* -DER_NONEXIST Container is nonexistent
* -DER_BUSY Pool is busy
*/
int
daos_cont_destroy(daos_handle_t poh, const uuid_t uuid, int force,
daos_event_t *ev);
/**
* Query container information.
*
* \param coh [IN] Container open handle.
* \param info [OUT] Returned container information.
* If \a info::ci_snapshots is not NULL, epochs of
* snapshots will be stored in it.
* If \a info::ci_snapshots is NULL, number of snapshots
* will be returned by \a info::ci_nsnapshots.
* \param ev [IN] Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*
* \return These values will be returned by \a ev::ev_error in
* non-blocking mode:
* 0 Success
* -DER_INVAL Invalid parameter
* -DER_UNREACH Network is unreachable
* -DER_NO_HDL Invalid container handle
*/
int
daos_cont_query(daos_handle_t container, daos_cont_info_t *info,
daos_event_t *ev);
/**
* List the names of all user-defined container attributes.
*
* \param coh [IN] Container handle.
* \param buffer [OUT] Buffer containing concatenation of all attribute
* names, each being null-terminated. No truncation is
* performed and only full names will be returned.
* NULL is permitted in which case only the aggregate
* size will be retrieved.
* \param size [IN] Buffer size.
* [OUT] Aggregate size of all attribute names (excluding
* terminating null characters), regardless of the
* actual buffer size.
* \param ev [IN] Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*/
int
daos_cont_attr_list(daos_handle_t coh, char *buffer, size_t *size,
daos_event_t *ev);
/**
* Retrieve a list of user-defined container attribute values.
*
* \param coh [IN] Container handle
* \param n [IN] Number of attributes
* \param names [IN] Array of \a n null-terminated attribute names.
* \param buffers [OUT] Array of \a n buffers to store attribute values.
* Attribute values larger than corresponding
* buffer sizes will be truncated. NULL values are
* permitted and will be treated identical to
* zero-length buffers, in which case only the
* sizes of attribute values will be retrieved.
* \param sizes [IN] Array of \a n buffer sizes.
* [OUT] Array of actual sizes of \a n attribute values,
* regardless of given buffer sizes.
* \param ev [IN] Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*/
int
daos_cont_attr_get(daos_handle_t coh, int n, char const *const names[],
void *const buffers[], size_t sizes[], daos_event_t *ev);
/**
* Create or update a list of user-defined container attributes.
*
* \param coh [IN] Container handle
* \param n [IN] Number of attributes
* \param names [IN] Array of \a n null-terminated attribute names.
* \param values [IN] Array of \a n attribute values
* \param sizes [IN] Array of \a n elements containing the
* sizes of respective attribute values.
* \param ev [IN] Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*/
int
daos_cont_attr_set(daos_handle_t coh, int n, char const *const names[],
void const *const values[], size_t const sizes[],
daos_event_t *ev);
/**
* Allocate a unique set of 64 bit unsigned integers to be used for object ID
* generation for that container. This is an optional helper function for
* applications to use to guarantee unique object IDs on the container when more
* than 1 client are accessing objects on the container. The highest used ID is
* tracked in the container metadata for future access to that container. This
* doesn't guarantee that the IDs allocated are sequential; and several ID
* ranges could be discarded at container close.
*
* \param coh [IN] Container open handle.
* \param num_oids [IN] Number of unique IDs requested.
* \param oid [OUT] starting oid that was allocated up to oid + num_oids.
* \param ev [IN] Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*
* \return These values will be returned by \a ev::ev_error in
* non-blocking mode:
* 0 Success
* -DER_NO_HDL Invalid container open handle
* -DER_UNREACH Network is unreachable
*/
int
daos_cont_oid_alloc(daos_handle_t coh, daos_size_t num_oids, uint64_t *oid,
daos_event_t *ev);
/**
* Epoch API
*/
/**
* Flush an epoch of a container handle.
*
* \param coh [IN] Container handle
* \param epoch [IN] Epoch to flush
* \param state [OUT] Latest epoch state
* \param ev [IN] Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*/
int
daos_epoch_flush(daos_handle_t coh, daos_epoch_t epoch,
daos_epoch_state_t *state, daos_event_t *ev);
/**
* Discard an epoch of a container handle.
*
* \param coh [IN] Container handle
* \param epoch [IN] Epoch to discard
* \param state [OUT] Optional, latest epoch state
* \param ev [IN] Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*/
int
daos_epoch_discard(daos_handle_t coh, daos_epoch_t epoch,
daos_epoch_state_t *state, daos_event_t *ev);
/**
* Query latest epoch state.
*
* \param coh [IN] Container handle
* \param state [OUT] Optional, latest epoch state
* \param ev [IN] Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*/
int
daos_epoch_query(daos_handle_t coh, daos_epoch_state_t *state,
daos_event_t *ev);
/**
* Propose a new lowest held epoch (LHE) on a container handle. The resulting
* LHE may be higher than the one proposed. The owner of the container handle
* is responsible for releasing its held epochs by either committing them or
* setting LHE to DAOS_EPOCH_MAX.
*
* \param coh [IN] Container handle
* \param epoch [IN] Minimum requested LHE, set to 0 if no requirement
* [OUT] returned LHE of the container handle
* \param state [OUT] Optional, latest epoch state
* \param ev [IN] Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*/
int
daos_epoch_hold(daos_handle_t coh, daos_epoch_t *epoch,
daos_epoch_state_t *state, daos_event_t *ev);
/**
* Increase the lowest referenced epoch (LRE) of a container handle. If
* \a epoch is lower than current LRE, then the epoch state of the container
* handle is unchanged.
*
* \param coh [IN] Container handle
* \param epoch [IN] Epoch to increase LRE to
* \param state [OUT] Optional, latest epoch state
* \param ev [IN] Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*/
int
daos_epoch_slip(daos_handle_t coh, daos_epoch_t epoch,
daos_epoch_state_t *state, daos_event_t *ev);
/**
* Commit to an epoch for a container handle. Unless already committed, in
* which case the epoch state of the container handle is unchanged, epoch must
* be equal to or higher than the LHE. Otherwise, an error is returned. Once
* the commit succeeds, the HCE, LHE, and LRE (unless DAOS_COO_NOSLIP was
* specified when opening this container handle) of the container handle
* becomes epoch, epoch + 1, and epoch, respectively.
*
* \param coh [IN] Container handle
* \param epoch [IN] Epoch to commit
* \param state [OUT] Optional, latest epoch state
* \param ev [IN] Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*/
int
daos_epoch_commit(daos_handle_t coh, daos_epoch_t epoch,
daos_epoch_state_t *state, daos_event_t *ev);
/**
* Wait for an epoch to be committed. This function is typically used by a
* consumer application waiting for the producer to commit a specific epoch.
*
* \param coh [IN] Container handle
* \param epoch [IN] Epoch to wait on
* \param state [OUT] Optional, latest epoch state
* \param ev [IN] Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*/
int
daos_epoch_wait(daos_handle_t coh, daos_epoch_t epoch,
daos_epoch_state_t *state, daos_event_t *ev);
/**
* Snapshot API
*/
/**
* List epochs of all the snapshots of a container.
*
* \param coh [IN] Container handle
* \param buf [IN] Buffer to hold the epochs
* [OUT] Array of epochs of snapshots
* \param n [IN] Number of epochs the buffer can hold
* [OUT] Number of all snapshots (regardless of buffer size)
* \param ev [IN] Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*/
int
daos_snap_list(daos_handle_t coh, daos_epoch_t *buf, int *n, daos_event_t *ev);
/**
* Take a snapshot of a container at an epoch.
*
* \param coh [IN] Container handle
* \param epoch [IN] Epoch to snapshot
* \param ev [IN] Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*/
int
daos_snap_create(daos_handle_t coh, daos_epoch_t epoch, daos_event_t *ev);
/**
* Destroy a snapshot. The epoch corresponding to the snapshot is not
* discarded, but may be aggregated.
*
* \param coh [IN] Container handle
* \param epoch [IN] Epoch of snapshot to destroy
* \param ev [IN] Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*/
int
daos_snap_destroy(daos_handle_t coh, daos_epoch_t epoch, daos_event_t *ev);
/**
* Object API
*/
/**
* Register a new object class in addition to the default ones (see DAOS_OC_*).
* An object class cannot be unregistered for the time being.
*
* \param coh [IN] Container open handle.
* \param cid [IN] ID for the new object class.
* \param cattr [IN] Attributes for the new object class.
* \param ev [IN] Completion event, it is optional and can be NULL.
* Function will run in blocking mode if \a ev is NULL.
*
* \return These values will be returned by \a ev::ev_error in
* non-blocking mode:
* 0 success
* -DER_NO_HDL Invalid container handle
* -DER_INVAL Invalid parameter
* -DER_NO_PERM Permission denied
* -DER_UNREACH Network is unreachable
* -DER_EXIST Object class ID already existed
*/
int
daos_obj_class_register(daos_handle_t coh, daos_oclass_id_t cid,
daos_oclass_attr_t *cattr, daos_event_t *ev);
/**
* Query attributes of an object class by its ID.
*
* \param coh [IN] Container open handle.
* \param cid [IN] Class ID to query.
* \param cattr [OUT] Returned attributes of the object class.
* \param ev [IN] Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*
* \return These values will be returned by \a ev::ev_error in
* non-blocking mode:
* 0 success
* -DER_NO_HDL Invalid container handle
* -DER_INVAL Invalid parameter
* -DER_UNREACH Network is unreachable
* -DER_NONEXIST Nonexistent class ID
*/
int
daos_obj_class_query(daos_handle_t coh, daos_oclass_id_t cid,
daos_oclass_attr_t *cattr, daos_event_t *ev);
/**
* List existing object classes.
*
* \param coh [IN] Container open handle.
* \param clist [OUT] Sink buffer for returned class list.
* \param anchor [IN/OUT]
* Hash anchor for the next call. It should be set to
* zeroes for the first call. It should not be altered
* by caller between calls.
* \param ev [IN] Completion event, it is optional and can be NULL.
* Function will run in blocking mode if \a ev is NULL.
*
* \return These values will be returned by \a ev::ev_error in
* non-blocking mode:
* 0 success
* -DER_NO_HDL Invalid container handle
* -DER_INVAL Invalid parameter
* -DER_UNREACH Network is unreachable
*/
int
daos_obj_class_list(daos_handle_t coh, daos_oclass_list_t *clist,
daos_hash_out_t *anchor, daos_event_t *ev);
/**
* Generate a DAOS object ID by encoding the private DAOS bits of the object
* address space.
*
* \param oid [IN] Object ID with low 160 bits set and unique inside the
* container.
* [OUT] Fully populated DAOS object identifier with the the low
* 96 bits untouched and the DAOS private bits (the high
* 32 bits) encoded.
* \param ofeat [IN] Feature bits specific to object
* \param cid [IN] Class Identifier
*/
static inline void
daos_obj_id_generate(daos_obj_id_t *oid, daos_ofeat_t ofeats,
daos_oclass_id_t cid)
{
uint64_t hdr = cid;
oid->hi &= 0x00000000ffffffff;
/**
* | Upper bits contain
* | DAOS_OVERSION_BITS version |
* | DAOS_OFEAT_BITS object features |
* | DAOS_OCLASS_BITS object class |
* | 96-bit for upper layer ... |
*/
hdr <<= DAOS_OCLASS_SHIFT;
hdr |= 0x1ULL << DAOS_OVERSION_SHIFT;
hdr |= ((uint64_t)ofeats << DAOS_OFEAT_SHIFT);
oid->hi |= hdr;
}
static inline daos_oclass_id_t
daos_obj_id2class(daos_obj_id_t oid)
{
daos_oclass_id_t ocid;
ocid = (oid.hi & DAOS_OCLASS_MASK) >> DAOS_OCLASS_SHIFT;
return ocid;
}
static inline daos_ofeat_t
daos_obj_id2feat(daos_obj_id_t oid)
{
daos_ofeat_t ofeat;
ofeat = (oid.hi & DAOS_OFEAT_MASK) >> DAOS_OFEAT_SHIFT;
return ofeat;
}
static inline uint8_t
daos_obj_id2version(daos_obj_id_t oid)
{
uint8_t version;
version = (oid.hi & DAOS_OVERSION_MASK) >> DAOS_OVERSION_SHIFT;
return version;
}
/**
* Declare a new object based on attributes \a oa.
*
* \param coh [IN] Container open handle.
* \param oid [IN] Object ID generated by daos_objid_generate().
* \param epoch [IN] Epoch to create object.
* \param oa [IN] Optional, object creation parameters.
* \param ev [IN] Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*
* \return These values will be returned by \a ev::ev_error in
* non-blocking mode:
* 0 success
* -DER_NO_HDL Invalid container handle
* -DER_INVAL Invalid parameter
* -DER_UNREACH Network is unreachable
* -DER_NO_PERM Permission denied
* -DER_EXIST Object ID has been used for another
* object.
* -DER_NONEXIST Cannot find container on specified
* storage target
* -DER_NOTYPE Unknown object type
* -DER_NOSCHEMA Unknown object schema
* -DER_EP_RO Epoch is read-only
*/
int
daos_obj_declare(daos_handle_t coh, daos_obj_id_t oid, daos_epoch_t epoch,
daos_obj_attr_t *oa, daos_event_t *ev);
/**
* Open an declared DAOS-SR object.
*
* \param coh [IN] Container open handle.
* \param oid [IN] Object ID.
* \param epoch [IN] Epoch to open object.
* \param mode [IN] Open mode: DAOS_OO_RO/RW/EXCL/IO_RAND/IO_SEQ
* \param oh [OUT] Returned object open handle.
* \param ev [IN] Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*
* \return These values will be returned by \a ev::ev_error in
* non-blocking mode:
* 0 Success
* -DER_NO_HDL Invalid container handle
* -DER_INVAL Invalid parameter
* -DER_UNREACH Network is unreachable
* -DER_NO_PERM Permission denied
* -DER_NONEXIST Cannot find object
* -DER_EP_OLD Epoch is too old and has no data for
* this object
*/
int
daos_obj_open(daos_handle_t coh, daos_obj_id_t oid, daos_epoch_t epoch,
unsigned int mode, daos_handle_t *oh, daos_event_t *ev);
/**
* Close an opened object.
*
* \param oh [IN] Object open handle.
* \param ev [IN] Completion event, it is optional and can be NULL.
* Function will run in blocking mode if \a ev is NULL.
*
* \return These values will be returned by \a ev::ev_error in
* non-blocking mode:
* 0 Success
* -DER_NO_HDL Invalid object open handle
*/
int
daos_obj_close(daos_handle_t oh, daos_event_t *ev);
/**
* Punch an entire object with all keys associated with it.
*
* \param oh [IN] Object open handle.
* \param epoch [IN] Epoch to punch the object in.
* \param ev [IN] Completion event, it is optional and can be NULL.
* Function will run in blocking mode if \a ev is NULL.
*
* \return These values will be returned by \a ev::ev_error in
* non-blocking mode:
* 0 Success
* -DER_NO_HDL Invalid object open handle
* -DER_UNREACH Network is unreachable
* -DER_EP_RO Permission denied
* -DER_NOEXIST Nonexistent object ID
*/
int
daos_obj_punch(daos_handle_t oh, daos_epoch_t epoch, daos_event_t *ev);
/**
* Punch dkeys (with all akeys) from an object.
*
* \param oh [IN] Object open handle.
* \param epoch [IN] Epoch to punch records.
* \param nr [IN] number of dkeys to punch.
* \param dkeys [IN] Array of dkeys to punch.
* \param ev [IN] Completion event, it is optional and can be NULL.
* Function will run in blocking mode if \a ev is NULL.
*
* \return These values will be returned by \a ev::ev_error in
* non-blocking mode:
* 0 Success
* -DER_NO_HDL Invalid object open handle
* -DER_UNREACH Network is unreachable
* -DER_EP_RO Permission denied
* -DER_NOEXIST Nonexistent object ID
*/
int
daos_obj_punch_dkeys(daos_handle_t oh, daos_epoch_t epoch, unsigned int nr,
daos_key_t *dkeys, daos_event_t *ev);
/**
* Punch akeys (with all records) from an object.
*
* \param oh [IN] Object open handle.
* \param epoch [IN] Epoch to punch records.
* \param dkey [IN] dkey to punch akeys from.
* \param nr [IN] number of akeys to punch.
* \param akeys [IN] Array of akeys to punch.
* \param ev [IN] Completion event, it is optional and can be NULL.
* Function will run in blocking mode if \a ev is NULL.
*
* \return These values will be returned by \a ev::ev_error in
* non-blocking mode:
* 0 Success
* -DER_NO_HDL Invalid object open handle
* -DER_UNREACH Network is unreachable
* -DER_EP_RO Permission denied
* -DER_NOEXIST Nonexistent object ID
*/
int
daos_obj_punch_akeys(daos_handle_t oh, daos_epoch_t epoch, daos_key_t *dkey,
unsigned int nr, daos_key_t *akeys, daos_event_t *ev);
/**
* Query attributes of an object.
* Caller should provide at least one of the output parameters.
*
* \param oh [IN] Object open handle.
* \param epoch [IN] Epoch to query.
* \param oa [OUT] Returned object attributes.
* \param ranks [OUT] Ordered list of ranks where the object is stored.
* \param ev [IN] Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*
* \return These values will be returned by \a ev::ev_error in
* non-blocking mode:
* 0 Success
* -DER_NO_HDL Invalid object open handle
* -DER_INVAL Invalid parameter
* -DER_UNREACH Network is unreachable
*/
int
daos_obj_query(daos_handle_t oh, daos_epoch_t epoch, daos_obj_attr_t *oa,
d_rank_list_t *ranks, daos_event_t *ev);
/**
* Object I/O API
*/
/**
* Fetch object records from co-located arrays.
*
* \param oh [IN] Object open handle.
*
* \param epoch [IN] Epoch for the fetch. It is ignored if epoch range is
* provided for each extent through the I/O descriptor
* \a iods[]::iod_eprs[]).
*
* \param dkey [IN] Distribution key associated with the fetch operation.
*
* \param nr [IN] Number of I/O descriptor and scatter/gather lists in
* respectively \a iods and \a sgls.
*
* \param iods [IN] Array of I/O descriptors. Each descriptor is associated
* with a given akey and describes the list of record
* extents to fetch from the array.
* A different epoch can be passed for each extent via
* \a iods[]::iod_eprs[] and in this case, \a epoch will be
* ignored.
* [OUT] Checksum of each extent is returned via
* \a iods[]::iod_csums[]. If the record size of an
* extent is unknown (i.e. set to DAOS_REC_ANY as input),
* then the actual record size will be returned in
* \a iods[]::iod_size.
*
* \param sgls [IN] Scatter/gather lists (sgl) to store records. Each array
* is associated with a separate sgl in \a sgls.
* I/O descs in each sgl can be arbitrary as long as their
* total size is sufficient to fill in all returned data.
* For example, extents with records of different sizes can
* be adjacently stored in the same iod of the sgl of the
* I/O descriptor start offset of an extent is the end
* offset of the previous extent.
* For an unfound record, the output length of the
* corresponding sgl is set to zero.
*
* \param map [OUT] Optional, this parameter is mostly for the cache and
* tiering layer, other upper layers can simply pass in
* NULL.
* It is the sink buffer to store the returned actual
* index layouts and their epoch validities. The returned
* layout covers the record extents as \a iods.
* However, the returned extents could be fragmented if
* these extents were partially updated in different
* epochs. Additionally, the returned extents should also
* allow to discriminate punched extents from punched
* holes.
*
* \param ev [IN] Completion event, it is optional and can be NULL.
* Function will run in blocking mode if \a ev is NULL.
*
* \return These values will be returned by \a ev::ev_error in
* non-blocking mode:
* 0 Success
* -DER_NO_HDL Invalid object open handle
* -DER_INVAL Invalid parameter
* -DER_UNREACH Network is unreachable
* -DER_KEY2BIG Key is too large and can't be
* fit into output buffer
* -DER_REC2BIG Record is too large and can't be
* fit into output buffer
* -DER_EP_OLD Epoch is too old and has no data
*/
int
daos_obj_fetch(daos_handle_t oh, daos_epoch_t epoch, daos_key_t *dkey,
unsigned int nr, daos_iod_t *iods, daos_sg_list_t *sgls,
daos_iom_t *maps, daos_event_t *ev);
/**
* Insert or update object records stored in co-located arrays.
*
* \param oh [IN] Object open handle.
*
* \param epoch [IN] Epoch for the update. It is ignored if epoch range is
* provided for each extent through the I/O descriptor
* \a iods[]::iod_eprs[]).
*
* \param dkey [IN] Distribution key associated with the update operation.
*
* \param nr [IN] Number of descriptors and scatter/gather lists in