forked from daos-stack/daos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
daos_api.h
1278 lines (1211 loc) · 44.4 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.
*/
/**
* \file
*
* DAOS API methods
*/
#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[in] uuid UUID to identify a pool.
* \param[in] grp Process set name of the DAOS servers managing the pool
* \param[in] svc Pool service replica ranks, as reported by
* daos_pool_create().
* \param[in] flags Connect mode represented by the DAOS_PC_ bits.
* \param[out] poh Returned open handle.
* \param[out] info Returned pool info.
* \param[in] ev 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[in] poh Pool connection handle
* \param[in] ev 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[in] poh Valid local pool connection handle to be shared
* \param[out] glob 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[in] glob Global (shared) representation of a collective handle
* to be extracted
* \param[out] poh 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[in] coh valid local container handle to be shared
* \param[out] glob 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[in] poh Pool connection handle the container belong to
* \param[in] glob Global (shared) representation of a collective handle
* to be extracted
* \param[out] coh 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[in] poh Pool connection handle.
* \param[out] tgts Optional, returned storage targets in this pool.
* \param[out] info Optional, returned pool information.
* \param[in] ev 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[in] poh Pool connection handle.
* \param[in] tgts A list of targets to query.
* \param[out] failed Optional, buffer to store faulty targets on failure.
* \param[out] info_list
* Returned storage information of \a tgts, it is an array
* and array size must equal to tgts::rl_llen.
* \param[in] ev 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_query_target(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[in] poh Pool handle.
* \param[out] buffer 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[in,out]
* size [in]: Buffer size. [out]: Aggregate size of all
* attribute names (excluding terminating null
* characters), regardless of the actual buffer
* size.
* \param[in] ev Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*/
int
daos_pool_list_attr(daos_handle_t poh, char *buffer, size_t *size,
daos_event_t *ev);
/**
* Retrieve a list of user-defined pool attribute values.
*
* \param[in] poh Pool handle
* \param[in] n Number of attributes
* \param[in] names Array of \a n null-terminated attribute names.
* \param[out] buffers 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[in,out]
* sizes [in]: Array of \a n buffer sizes. [out]: Array of actual
* sizes of \a n attribute values, regardless of given
* buffer sizes.
* \param[in] ev Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*/
int
daos_pool_get_attr(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[in] poh Pool handle
* \param[in] n Number of attributes
* \param[in] names Array of \a n null-terminated attribute names.
* \param[in] values Array of \a n attribute values
* \param[in] sizes Array of \a n elements containing the sizes of
* respective attribute values.
* \param[in] ev Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*/
int
daos_pool_set_attr(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[in] poh Pool connection handle.
* \param[in] uuid UUID of the new Container.
* \param[in] ev 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[in] poh Pool connection handle.
* \param[in] uuid UUID to identify container.
* \param[in] flags Open mode, represented by the DAOS_COO_ bits.
* \param[out] coh Returned open handle.
* \param[out] info Optional, return container information
* \param[in] ev 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[in] coh Container open handle.
* \param[in] ev 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[in] poh Pool connection handle.
* \param[in] uuid Container UUID.
* \param[in] force 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[in] ev 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[in] coh Container open handle.
* \param[out] info 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[in] ev 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[in] coh Container handle.
* \param[out] buffer 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[in,out]
* size [in]: Buffer size. [out]: Aggregate size of all
* attribute names (excluding terminating null characters),
* regardless of the actual buffer size.
* \param[in] ev Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*/
int
daos_cont_list_attr(daos_handle_t coh, char *buffer, size_t *size,
daos_event_t *ev);
/**
* Retrieve a list of user-defined container attribute values.
*
* \param[in] coh Container handle
* \param[in] n Number of attributes
* \param[in] names Array of \a n null-terminated attribute names.
* \param[out] buffers 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[in,out]
* sizes [in]: Array of \a n buffer sizes. [out]: Array of actual
* sizes of \a n attribute values, regardless of given
* buffer sizes.
* \param[in] ev Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*/
int
daos_cont_get_attr(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[in] coh Container handle
* \param[in] n Number of attributes
* \param[in] names Array of \a n null-terminated attribute names.
* \param[in] values Array of \a n attribute values
* \param[in] sizes Array of \a n elements containing the sizes of
* respective attribute values.
* \param[in] ev Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*/
int
daos_cont_set_attr(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[in] coh Container open handle.
* \param[in] num_oids
* Number of unique IDs requested.
* \param[out] oid starting oid that was allocated up to oid + num_oids.
* \param[in] ev 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_alloc_oids(daos_handle_t coh, daos_size_t num_oids, uint64_t *oid,
daos_event_t *ev);
/**
* Rollback to a specific persistent snapshot.
*
* \param[in] coh Container handle
* \param[in] epoch Epoch if persistent snapshot to rollback to.
* \param[in] ev Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*/
int
daos_cont_rollback(daos_handle_t coh, daos_epoch_t epoch, daos_event_t *ev);
/**
* Subscribe to the container snapshot state. If user specifies a valid epoch,
* the call will return once a persistent snapshot has been taken at that epoch
* or a greater one. The epoch value will be updated with that epoch. If
* multiple snapshots exist at an epoch greater than the one specified, the
* lowest one will be returned in the epoch value. If the epoch value passed in
* is 0, this call will return the lowest persistent snapshot on the container,
* if any exist, otherwise will just wait till a persistent snapshot is created.
*
* \param[in] coh Container handle
* \param[in,out]
* epoch [in]: Epoch of snapshot to wait for. [out]: epoch of
* persistent snapshot that was taken.
* \param[in] ev Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*/
int
daos_cont_subscribe(daos_handle_t coh, daos_epoch_t *epoch, daos_event_t *ev);
#define DAOS_SNAPSHOT_MAX_LEN 128
/**
* Create a persistent snapshot at the current epoch and return it. The epoch
* that is returned can be used to create a read only transaction to read data
* from that persistent snapshot. Optionally the snapshot can be given a name as
* an attribute which can be retrieved with daos_cont_list_snap(). Name length
* can't exceed DAOS_SNAPSHOT_MAX_LEN.
*
* \param[in] coh Container handle
* \param[out] epoch returned epoch of persistent snapshot taken.
* \param[in] name Optional null terminated name for snapshot.
* \param[in] ev Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*/
int
daos_cont_create_snap(daos_handle_t coh, daos_epoch_t *epoch, char *name,
daos_event_t *ev);
/**
* List all the snapshots of a container and optionally retrieve the snapshot
* name of each one if it was given at create time.
*
* \param[in] coh Container handle
* \param[in,out]
* nr [in]: Number of snapshots in epochs and names.
* [out]: Actual number of snapshots returned.
* \param[out] epochs preallocated array of epochs to store snapshots.
* \param[out] names preallocated array of names of the snapshots.
* DAOS_SNAPSHOT_MAX_LEN can be used for each name
* size if not known.
* \param[in,out]
* anchor Hash anchor for the next call, it should be set to
* zeroes for the first call, it should not be changed
* by caller between calls.
* \param[in] ev Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*/
int
daos_cont_list_snap(daos_handle_t coh, int *nr, daos_epoch_t *epochs,
char **names, daos_anchor_t *anchor, daos_event_t *ev);
/**
* Destroy a snapshot. The epoch corresponding to the snapshot is not
* discarded, but may be aggregated.
*
* \param[in] coh Container handle
* \param[in] epr Epoch range of snapshots to destroy.
* If epr_lo == epr_hi delete 1 snapshot at epr_lo/hi.
* If epr_lo == 0, delete all snapshots <= epr_hi.
* If epr_hi == DAOS_EPOCH_MAX, delete all snapshots
* >= epr_lo.
* \param[in] ev Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*/
int
daos_cont_destroy_snap(daos_handle_t coh, daos_epoch_range_t epr,
daos_event_t *ev);
/*
* Transaction API
*/
/**
* Open a transaction on a container handle. This returns a transaction handle
* that is tagged with the current epoch. The transaction handle can be used
* for IOs that need to be committed transactionally.
*
* \param[in] coh Container handle.
* \param[out] th Returned transaction handle.
* \param[in] ev Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*
* \return 0 if Success, negative if failed.
*/
int
daos_tx_open(daos_handle_t coh, daos_handle_t *th, daos_event_t *ev);
/**
* Commit the transaction on the container it was created with. The transaction
* can't be used for future updates anymore. If -DER_RESTART was returned, the
* operations that have been done on this transaction need to be redone with a
* newer transaction since a conflict was detected with another transaction.
*
* \param[in] th Transaction handle to commit.
* \param[in] ev Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*
* \return 0 if Success, negative if failed.
* Possible error values include:
* -DER_NO_HDL invalid transaction handle.
* -DER_INVAL Invalid parameter
* -DER_RESTART transaction conflict detected.
*/
int
daos_tx_commit(daos_handle_t th, daos_event_t *ev);
/**
* Create a read-only transaction from a snapshot. This does not create the
* snapshot, but only a read transaction to be able to read from a persistent
* snapshot in the container. If the user passes an epoch that is not
* snapshoted, or the snapshot was deleted, reads using that transaction might
* fail if the epoch was aggregated.
*
* \param[in] coh Container handle.
* \param[in] epoch Epoch of snapshot to read from.
* \param[out] th Returned read only transaction handle.
* \param[in] ev Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*
* \return 0 if Success, negative if failed.
*/
int
daos_tx_open_snap(daos_handle_t coh, daos_epoch_t epoch, daos_handle_t *th,
daos_event_t *ev);
/**
* Abort all updates on the transaction. The transaction can't be used for
* future updates anymore.
*
* \param[in] th Transaction handle to abort.
* \param[in] ev Completion event, it is optional and can be NULL.
* The function will run in blocking mode if \a ev is NULL.
*
* \return 0 if Success, negative if failed.
*/
int
daos_tx_abort(daos_handle_t th, daos_event_t *ev);
/**
* Close and free the transaction handle. This is a local operation, no RPC
* involved.
*
* \param[in] th Transaction handle to free.
*
* \return 0 if Success, negative if failed.
*/
int
daos_tx_close(daos_handle_t th, daos_event_t *ev);
/**
* Return epoch associated with the transaction handle.
*
* \param[in] th Transaction handle.
* \param[out] th Returned epoch value.
*
* \return 0 if Success, negative if failed.
*/
int
daos_tx_hdl2epoch(daos_handle_t th, daos_epoch_t *epoch);
/*
* 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[in] coh Container open handle.
* \param[in] cid ID for the new object class.
* \param[in] cattr Attributes for the new object class.
* \param[in] ev 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_register_class(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[in] coh Container open handle.
* \param[in] cid Class ID to query.
* \param[out] cattr Returned attributes of the object class.
* \param[in] ev 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_query_class(daos_handle_t coh, daos_oclass_id_t cid,
daos_oclass_attr_t *cattr, daos_event_t *ev);
/**
* List existing object classes.
*
* \param[in] coh Container open handle.
* \param[out] clist Sink buffer for returned class list.
* \param[in,out]
* anchor 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[in] ev 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_list_class(daos_handle_t coh, daos_oclass_list_t *clist,
daos_anchor_t *anchor, daos_event_t *ev);
/**
* Generate a DAOS object ID by encoding the private DAOS bits of the object
* address space.
*
* \param[in,out]
* 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[in] ofeat Feature bits specific to object
* \param[in] cid Class Identifier
*/
static inline void
daos_obj_generate_id(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;
}
/**
* Generate a rank list from a string with a seprator argument. This is a
* convenience function to generate the rank list required by
* daos_pool_connect().
*
* \param[in] str string with the rank list
* \param[in] sep separator of the ranks in \a str.
* dmg uses ":" as the separator.
*
* \return allocated rank list that user is responsible to free
* with daos_rank_list_free().
*/
d_rank_list_t *
daos_rank_list_parse(const char *str, const char *sep);
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 bool
daos_oc_echo_type(daos_oclass_id_t oc)
{
return oc == DAOS_OC_ECHO_TINY_RW ||
oc == DAOS_OC_ECHO_R2S_RW ||
oc == DAOS_OC_ECHO_R3S_RW ||
oc == DAOS_OC_ECHO_R4S_RW;
}
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;
}
/**
* Open an DAOS object.
*
* \param[in] coh Container open handle.
* \param[in] oid Object ID.
* \param[in] mode Open mode: DAOS_OO_RO/RW/EXCL/IO_RAND/IO_SEQ
* \param[out] oh Returned object open handle.
* \param[in] ev 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, unsigned int mode,
daos_handle_t *oh, daos_event_t *ev);
/**
* Close an opened object.
*
* \param[in] oh Object open handle.
* \param[in] ev 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[in] oh Object open handle.
* \param[in] th Optional transaction handle to punch object in.
* Use DAOS_TX_NONE for an independent transaction.
* \param[in] ev 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_handle_t th, daos_event_t *ev);
/**
* Punch dkeys (with all akeys) from an object.
*
* \param[in] oh Object open handle.
* \param[in] th Optional transaction handle to punch dkeys in.
* Use DAOS_TX_NONE for an independent transaction.
* \param[in] nr number of dkeys to punch.
* \param[in] dkeys Array of dkeys to punch.
* \param[in] ev 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_handle_t th, unsigned int nr,
daos_key_t *dkeys, daos_event_t *ev);
/**
* Punch akeys (with all records) from an object.
*
* \param[in] oh Object open handle.
* \param[in] th Optional transaction handle to punch akeys in.
* Use DAOS_TX_NONE for an independent transaction.
* \param[in] dkey dkey to punch akeys from.
* \param[in] nr number of akeys to punch.
* \param[in] akeys Array of akeys to punch.
* \param[in] ev 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_handle_t th, 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[in] oh Object open handle.
* \param[in] th Optional transaction handle to query with.
* Use DAOS_TX_NONE for an independent transaction.
* \param[out] oa Returned object attributes.
* \param[out] ranks Ordered list of ranks where the object is stored.
* \param[in] ev 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_handle_t th, 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[in] oh Object open handle.
*
* \param[in] th Optional transaction handle to fetch with.
* Use DAOS_TX_NONE for an independent transaction.
*
* \param[in] dkey Distribution key associated with the fetch operation.
*
* \param[in] nr Number of I/O descriptor and scatter/gather lists in
* respectively \a iods and \a sgls.
*
* \param[in,out]
* 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[in] sgls 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[out] map Optional, 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.
*