-
Notifications
You must be signed in to change notification settings - Fork 4
/
castle_public.h
1118 lines (978 loc) · 48.8 KB
/
castle_public.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
#ifndef __CASTLE_PUBLIC_H__
#define __CASTLE_PUBLIC_H__
#include <linux/types.h>
#include <asm/ioctl.h>
#ifndef __KERNEL__
#include <sys/time.h>
#include <sys/types.h>
#else
#include <linux/time.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define CASTLE_PROTOCOL_VERSION 39 /* last updated by BM */
#ifdef SWIG
#define PACKED //override gcc intrinsics for SWIG
#else
#define PACKED __attribute__((packed))
#endif
#ifndef __KERNEL__
#define PAGE_SIZE 4096
#define PAGE_SHIFT 12
#endif
/* Streaming format */
#define CASTLE_STREAMING_ENTRY_HEADER_TYPE_NULL (0)
#define CASTLE_STREAMING_ENTRY_HEADER_TYPE_VALUE (1)
#define CASTLE_STREAMING_ENTRY_HEADER_TYPE_COUNTER_SET (2)
#define CASTLE_STREAMING_ENTRY_HEADER_TYPE_COUNTER_ADD (3)
#define CASTLE_STREAMING_ENTRY_HEADER_TYPE_TOMBSTONE (4)
#define MAX_INLINE_VAL_SIZE 512 /* In bytes */
typedef uint64_t castle_user_timestamp_t;
struct castle_streaming_entry_header
{
unsigned char type;
castle_user_timestamp_t timestamp;
uint32_t key_length;
uint64_t val_length;
} PACKED;
typedef struct castle_streaming_entry_header c_stream_entry_hdr;
typedef enum {
NO_FAULT, /* 0 */
MERGE_FAULT, /* 1 */
EXTENT_FAULT, /* 2 */
FREESPACE_FAULT, /* 3 */
REPLACE_FAULT, /* 4 */
GET_FAULT, /* 5 */
BIG_PUT_FAULT, /* 6 */
BIG_GET_FAULT, /* 7 */
CHECKPOINT_FAULT, /* 8 */
CLAIM_FAULT, /* 9 */
FS_INIT_FAULT, /*10 */
FS_RESTORE_FAULT, /*11 */
FINI_FAULT, /*12 */
SLAVE_OOS_ERR, /*13 */
REBUILD_FAULT1, /*14 Fault between extent remaps*/
REBUILD_FAULT2, /*15 Fault in mid extent remap*/
} c_fault_t;
typedef enum {
BUILD_ID = 0,
LAST_ENV_VAR_ID,
} c_env_var_t;
/**
* Trace providers.
*/
typedef enum {
TRACE_CACHE, /**< Cache events */
TRACE_DA, /**< DA events */
TRACE_DA_MERGE, /**< Merge events */
TRACE_DA_MERGE_UNIT, /**< Merge unit events */
TRACE_IO_SCHED, /**< IO scheduler events */
} c_trc_prov_t;
/**
* Event types.
*/
typedef enum {
TRACE_PERCENTAGE, /**< Percentage value */
TRACE_VALUE, /**< Value being reported */
TRACE_MARK, /**< Event has occurred */
TRACE_START, /**< Event has started */
TRACE_END, /**< Event has ended */
} c_trc_type_t;
/**
* Cache trace variables.
*/
typedef enum {
TRACE_CACHE_CHECKPOINT_ID, /**< Checkpoint running. */
TRACE_CACHE_DIRTY_PGS_ID, /**< Number of c2ps on the dirtylist. */
TRACE_CACHE_CLEAN_PGS_ID, /**< Number of c2ps on the cleanlist. */
TRACE_CACHE_FREE_PGS_ID, /**< Number of c2ps on the freelist. */
TRACE_CACHE_RESERVE_PGS_ID, /**< Number of c2ps on the reserve freelist. */
TRACE_CACHE_CLEAN_BLKS_ID, /**< Number of c2bs on the cleanlist. */
TRACE_CACHE_FREE_BLKS_ID, /**< Number of c2bs on the freelist. */
TRACE_CACHE_RESERVE_BLKS_ID, /**< Number of c2bs on the reserve freelist. */
TRACE_CACHE_BLOCK_VICTIMS_ID, /**< Number of c2bs evicted from the cache. */
TRACE_CACHE_READS_ID, /**< Number of reads this tick. */
TRACE_CACHE_WRITES_ID, /**< Number of writes this tick. */
TRACE_CACHE_RESERVE_PGS_USED_ID, /**< Number of c2ps from reserve freelist in use. */
TRACE_CACHE_RESERVE_BLKS_USED_ID, /**< Number of c2bs from reserve freelist in use. */
TRACE_CACHE_META_DATA_IOS_ID, /**< IOs to meta extent */
TRACE_CACHE_GLOBAL_BTREE_IOS_ID, /**< IOs to global btree extent */
TRACE_CACHE_BLOCK_DEV_IOS_ID, /**< IOs to device mapper blocks */
TRACE_CACHE_INTERNAL_NODES_IOS_ID, /**< IOs to non T0 internal btree nodes */
TRACE_CACHE_LEAF_NODES_IOS_ID, /**< IOs to non T0 leaf btree nodes */
TRACE_CACHE_MEDIUM_OBJECTS_IOS_ID, /**< IOs to non T0 medium objects */
TRACE_CACHE_T0_INTERNAL_NODES_IOS_ID, /**< IOs to T0 internal btree nodes */
TRACE_CACHE_T0_LEAF_NODES_IOS_ID, /**< IOs to T0 leaf btree nodes */
TRACE_CACHE_T0_MEDIUM_OBJECTS_IOS_ID, /**< IOs to T0 medium objects */
TRACE_CACHE_LARGE_OBJECT_IOS_ID, /**< IOs to large objects */
TRACE_CACHE_BLOOM_FILTER_IOS_ID, /**< IOs to bloom filters */
TRACE_CACHE_BLK_T0_INT_HIT_MISS_ID, /**< Hits, misses T0 internal nodes */
TRACE_CACHE_BLK_T0_INT_HITS_ID, /**< Hits T0 internal nodes */
TRACE_CACHE_BLK_T0_INT_MISSES_ID, /**< Misses T0 internal nodes */
TRACE_CACHE_BLK_T0_INT_HITS_PCT_ID, /**< %Hits T0 internal nodes */
TRACE_CACHE_BLK_T0_INT_MISSES_PCT_ID, /**< %Misses T0 internal nodes */
TRACE_CACHE_BLK_T0_LEAF_HIT_MISS_ID, /**< Hits, misses T0 leaf nodes */
TRACE_CACHE_BLK_T0_LEAF_HITS_ID, /**< Hits T0 leaf nodes */
TRACE_CACHE_BLK_T0_LEAF_MISSES_ID, /**< Misses T0 leaf nodes */
TRACE_CACHE_BLK_T0_LEAF_HITS_PCT_ID, /**< %Hits T0 leaf nodes */
TRACE_CACHE_BLK_T0_LEAF_MISSES_PCT_ID,/**< %Misses T0 leaf nodes */
TRACE_CACHE_BLK_INT_HIT_MISS_ID, /**< Hits, misses ROCT internal nodes */
TRACE_CACHE_BLK_INT_HITS_ID, /**< Hits ROCT internal nodes */
TRACE_CACHE_BLK_INT_MISSES_ID, /**< Misses ROCT internal nodes */
TRACE_CACHE_BLK_INT_HITS_PCT_ID, /**< %Hits ROCT internal nodes */
TRACE_CACHE_BLK_INT_MISSES_PCT_ID, /**< %Misses ROCT internal nodes */
TRACE_CACHE_BLK_LEAF_HIT_MISS_ID, /**< Hits, misses ROCT leaf nodes */
TRACE_CACHE_BLK_LEAF_HITS_ID, /**< Hits ROCT leaf nodes */
TRACE_CACHE_BLK_LEAF_MISSES_ID, /**< Misses ROCT leaf nodes */
TRACE_CACHE_BLK_LEAF_HITS_PCT_ID, /**< %Hits ROCT leaf nodes */
TRACE_CACHE_BLK_LEAF_MISSES_PCT_ID, /**< %Misses ROCT leaf nodes */
TRACE_CACHE_BLK_GET_HIT_MISS_ID, /**< Hits, misses within the cache */
TRACE_CACHE_BLK_GET_HITS_ID, /**< Block hits within the cache */
TRACE_CACHE_BLK_GET_MISSES_ID, /**< Block misses within the cache */
TRACE_CACHE_BLK_GET_HITS_PCT_ID, /**< % of block hits within the cache */
TRACE_CACHE_BLK_GET_MISSES_PCT_ID, /**< % of block misses within the cache */
TRACE_CACHE_BLK_MERGE_HIT_MISS_ID, /**< Hits, misses of merges within the cache */
TRACE_CACHE_BLK_MERGE_HITS_ID, /**< Merge hits within the cache */
TRACE_CACHE_BLK_MERGE_MISSES_ID, /**< Merge misses within the cache */
TRACE_CACHE_BLK_MERGE_HITS_PCT_ID, /**< % of merge hits within the cache */
TRACE_CACHE_BLK_MERGE_MISSES_PCT_ID, /**< % of merge misses within the cache */
TRACE_CACHE_BLK_NON_MERGE_HIT_MISS_ID,/**< Hits, misses of merges within the cache */
TRACE_CACHE_BLK_NON_MERGE_HITS_ID, /**< Merge hits within the cache */
TRACE_CACHE_BLK_NON_MERGE_MISSES_ID, /**< Merge misses within the cache */
TRACE_CACHE_BLK_NON_MERGE_HITS_PCT_ID,/**< % of merge hits within the cache */
TRACE_CACHE_BLK_NON_MERGE_MISSES_PCT_ID,/**< % of merge misses within the cache */
} c_trc_cache_var_t;
/**
* DA trace variables.
*/
typedef enum {
TRACE_DA_INSERTS_DISABLED_ID, /**< Whether inserts are enabled or not. */
TRACE_DA_MERGE_ID, /**< Merge */
TRACE_DA_MERGE_MODLIST_ITER_INIT_ID, /**< Modlist iter init */
TRACE_DA_MERGE_UNIT_ID, /**< Merge unit */
TRACE_DA_MERGE_UNIT_CACHE_BTREE_EFFICIENCY_ID, /**< % of up2date btree chunk-c2bs. */
TRACE_DA_MERGE_UNIT_CACHE_DATA_EFFICIENCY_ID, /**< % of up2date data chunk-c2bs. */
} c_trc_da_var_t;
#define MERGE_START_FLAG (1U<<0)
#define MERGE_END_FLAG (1U<<1)
/**
* IO scheduler trace variables.
*/
typedef enum {
TRACE_IO_SCHED_NUM_READ_IOS_ID, /**< Number of IOs done due to reads */
TRACE_IO_SCHED_NUM_MERGE_RD_IOS_ID, /**< Number of RD IOs done due to merges (and writes) */
TRACE_IO_SCHED_NUM_MERGE_WR_IOS_ID, /**< Number of WR IOs done due to merges (and writes) */
TRACE_IO_SCHED_NUM_CHECKPOINT_IOS_ID, /**< Number of IOs done due to checkpoints */
TRACE_IO_SCHED_BYTES_READ_IOS_ID, /**< Amount of IO data due to reads */
TRACE_IO_SCHED_BYTES_MERGE_RD_IOS_ID, /**< Amount of RD IO data due to merges (and writes) */
TRACE_IO_SCHED_BYTES_MERGE_WR_IOS_ID, /**< Amount of WR data due to merges (and writes) */
TRACE_IO_SCHED_BYTES_CHECKPOINT_IOS_ID, /**< Amount of IO data due to checkpoints */
} c_trc_io_sched_var_t;
/* Bump the magic version byte (LSB) when c_trc_evt_t changes. */
#define CASTLE_TRACE_MAGIC 0xCAE5E112
typedef struct castle_trace_event {
uint32_t magic;
struct timeval timestamp;
int cpu; /**< CPU ID that allocated structure. */
c_trc_prov_t provider; /**< Event provider */
c_trc_type_t type; /**< Event type */
int var; /**< Event variable */
uint64_t v1;
uint64_t v2;
uint64_t v3;
uint64_t v4;
uint64_t v5;
} c_trc_evt_t;
typedef uint32_t c_transfer_id_t;
typedef uint32_t c_slave_uuid_t;
typedef uint32_t c_collection_id_t;
typedef uint32_t c_ver_t; /**< Version ID type, unique across all Doubling Arrays. */
typedef uint32_t c_da_t;
typedef uint8_t castle_resp_flags_t;
#define INVAL_VERSION ((c_ver_t)-1)
#define VERSION_INVAL(_v) ((_v) == INVAL_VERSION)
typedef uint64_t c_da_opts_t; /**< Options bitmask for DA options that must be set at
creation time. */
enum {
CASTLE_DA_OPTS_NONE = (0), /**< No options (all defaults). */
CASTLE_DA_OPTS_NO_USER_TIMESTAMPING = (1 << 0), /**< Disable user timestamping. */
};
/* Golden Nugget - Types */
typedef uint64_t c_array_id_t;
typedef uint32_t c_merge_id_t;
typedef uint32_t c_thread_id_t;
typedef uint32_t c_work_id_t;
typedef uint64_t c_work_size_t;
typedef uint64_t c_data_ext_id_t;
#define INVAL_ARRAY_ID ((c_array_id_t)-1)
#define ARRAY_ID_INVAL(_a) ((_a) == INVAL_ARRAY_ID)
#define INVAL_MERGE_ID ((c_merge_id_t)-1)
#define MERGE_ID_INVAL(_m) ((_m) == INVAL_MERGE_ID)
#define INVAL_THREAD_ID ((c_thread_id_t)-1)
#define THREAD_ID_INVAL(_t) ((_t) == INVAL_THREAD_ID)
#define INVAL_WORK_ID ((c_work_id_t)-1)
#define WORK_ID_INVAL(_t) ((_t) == INVAL_WORK_ID)
#define MERGE_ALL_DATA_EXTS ((uint32_t)(~0U))
typedef enum {
RDA_1,
RDA_2,
SSD_RDA_2,
SSD_RDA_3,
META_EXT,
MICRO_EXT,
SUPER_EXT,
SSD_ONLY_EXT,
NR_RDA_SPECS
} c_rda_type_t;
typedef struct castle_merge_config {
c_da_t vertree; /**< DA to perform the merge on. */
uint32_t nr_arrays; /**< # of arrays to be merged. */
c_array_id_t *arrays; /**< List of arrays. */
uint32_t nr_data_exts; /**< Number of medium extents in this array. */
c_data_ext_id_t *data_exts; /**< List of medium extents. */
c_rda_type_t metadata_ext_type; /**< Type of the extent that the output metadata *
*< to go. (SSD_RDA/DEFAULT_RDA/SSD_ONLY_EXT) */
c_rda_type_t data_ext_type; /**< Type of the extent that medium objects *
*< to go. (SSD_RDA/DEFAULT_RDA/SSD_ONLY_EXT) */
uint32_t bandwidth;
} c_merge_cfg_t;
/* And our IOCTL code is: */
#define CASTLE_CTRL_IOCTL_TYPE (0xCA)
/* Subtypes for CASTLE_CTRL_ used for IOCTLs */
#define CASTLE_CTRL_CLAIM 1
#define CASTLE_CTRL_ATTACH 3
#define CASTLE_CTRL_DETACH 4
#define CASTLE_CTRL_CREATE 5
#define CASTLE_CTRL_CLONE 6
#define CASTLE_CTRL_SNAPSHOT 7
#define CASTLE_CTRL_INIT 8
#define CASTLE_CTRL_COLLECTION_ATTACH 13
#define CASTLE_CTRL_COLLECTION_DETACH 14
#define CASTLE_CTRL_COLLECTION_SNAPSHOT 15
#define CASTLE_CTRL_VALID_STATS 17
#define CASTLE_CTRL_INVALID_STATS 18
#define CASTLE_CTRL_DESTROY_VERTREE 20
#define CASTLE_CTRL_PROTOCOL_VERSION 21
#define CASTLE_CTRL_FAULT 22
#define CASTLE_CTRL_ENVIRONMENT_SET 23
#define CASTLE_CTRL_TRACE_SETUP 24
#define CASTLE_CTRL_TRACE_START 25
#define CASTLE_CTRL_TRACE_STOP 26
#define CASTLE_CTRL_TRACE_TEARDOWN 27
#define CASTLE_CTRL_SLAVE_EVACUATE 28
#define CASTLE_CTRL_THREAD_PRIORITY 29
#define CASTLE_CTRL_SLAVE_SCAN 30
#define CASTLE_CTRL_DELETE_VERSION 31
#define CASTLE_CTRL_COLLECTION_REATTACH 32
#define CASTLE_CTRL_MERGE_THREAD_CREATE 33
#define CASTLE_CTRL_MERGE_THREAD_DESTROY 34
#define CASTLE_CTRL_MERGE_START 35
#define CASTLE_CTRL_MERGE_DO_WORK 36
#define CASTLE_CTRL_MERGE_STOP 37
#define CASTLE_CTRL_MERGE_THREAD_ATTACH 38
#define CASTLE_CTRL_INSERT_RATE_SET 39
#define CASTLE_CTRL_READ_RATE_SET 40
#define CASTLE_CTRL_PROG_REGISTER 41 /* This is hardcoded in castle-fs.rules */
#define CASTLE_CTRL_PROG_DEREGISTER 42
#define CASTLE_CTRL_PROG_HEARTBEAT 43
#define CASTLE_CTRL_CREATE_WITH_OPTS 44
#define CASTLE_CTRL_VERTREE_TDP_SET 45
#define CASTLE_CTRL_STATE_QUERY 46
typedef struct castle_control_cmd_claim {
uint32_t dev; /* IN */
int ret; /* OUT */
c_slave_uuid_t id; /* OUT */
} cctrl_cmd_claim_t;
typedef struct castle_control_cmd_release {
c_slave_uuid_t id; /* IN */
int ret; /* OUT */
} cctrl_cmd_release_t;
typedef struct castle_control_cmd_attach {
c_ver_t version; /* IN */
int ret; /* OUT */
uint32_t dev; /* OUT */
} cctrl_cmd_attach_t;
typedef struct castle_control_cmd_detach {
uint32_t dev; /* IN */
int ret; /* OUT */
} cctrl_cmd_detach_t;
typedef struct castle_control_cmd_snapshot {
uint32_t dev; /* IN */
int ret; /* OUT */
c_ver_t version; /* OUT */
} cctrl_cmd_snapshot_t;
typedef struct castle_control_cmd_collection_attach {
c_ver_t version; /* IN */
const char *name; /* IN */
size_t name_length; /* IN */
int ret; /* OUT */
c_collection_id_t collection; /* OUT */
} cctrl_cmd_collection_attach_t;
typedef struct castle_control_cmd_collection_reattach {
c_collection_id_t collection; /* IN */
c_ver_t new_version; /* IN */
int ret; /* OUT */
} cctrl_cmd_collection_reattach_t;
typedef struct castle_control_cmd_collection_detach {
c_collection_id_t collection; /* IN */
int ret; /* OUT */
} cctrl_cmd_collection_detach_t;
typedef struct castle_control_cmd_collection_snapshot {
c_collection_id_t collection; /* IN */
int ret; /* OUT */
c_ver_t version; /* OUT */
} cctrl_cmd_collection_snapshot_t;
typedef struct castle_control_cmd_create {
uint64_t size; /* IN */
int ret; /* OUT */
c_ver_t id; /* OUT */
} cctrl_cmd_create_t;
typedef struct castle_control_cmd_create_with_opts {
uint64_t size; /* IN */
c_da_opts_t opts; /* IN */
int ret; /* OUT */
c_ver_t id; /* OUT */
} cctrl_cmd_create_with_opts_t;
typedef struct castle_control_cmd_destroy_vertree {
c_da_t vertree_id; /* IN */
int ret; /* OUT */
} cctrl_cmd_destroy_vertree_t;
typedef struct castle_control_cmd_delete_version {
c_ver_t version; /* IN */
int ret; /* OUT */
} cctrl_cmd_delete_version_t;
typedef struct castle_control_cmd_clone {
c_ver_t version; /* IN */
int ret; /* OUT */
c_ver_t clone; /* OUT */
} cctrl_cmd_clone_t;
typedef struct castle_control_cmd_init {
int ret; /* OUT */
} cctrl_cmd_init_t;
typedef struct castle_control_cmd_transfer_create {
c_ver_t version; /* IN */
uint32_t direction; /* IN */
int ret; /* OUT */
c_transfer_id_t id; /* OUT */
} cctrl_cmd_transfer_create_t;
typedef struct castle_control_cmd_transfer_destroy {
c_transfer_id_t id; /* IN */
int ret; /* OUT */
} cctrl_cmd_transfer_destroy_t;
typedef struct castle_control_cmd_protocol_version {
int ret; /* OUT */
uint32_t version; /* OUT */
} cctrl_cmd_protocol_version_t;
typedef struct castle_control_cmd_environment_set {
c_env_var_t var_id; /* IN */
const char *var_str; /* IN */
size_t var_len; /* IN */
int ret; /* OUT */
} cctrl_cmd_environment_set_t;
typedef struct castle_control_cmd_fault {
c_fault_t fault_id; /* IN */
uint32_t fault_arg; /* IN */
int ret; /* OUT */
} cctrl_cmd_fault_t;
typedef struct castle_control_cmd_trace_setup {
const char *dir_str; /* IN */
size_t dir_len; /* IN */
int ret; /* OUT */
} cctrl_cmd_trace_setup_t;
typedef struct castle_control_cmd_trace_start {
int ret; /* OUT */
} cctrl_cmd_trace_start_t;
typedef struct castle_control_cmd_trace_stop {
int ret; /* OUT */
} cctrl_cmd_trace_stop_t;
typedef struct castle_control_cmd_trace_teardown {
int ret; /* OUT */
} cctrl_cmd_trace_teardown_t;
typedef struct castle_control_slave_evacuate {
c_slave_uuid_t id; /* IN */
uint32_t force; /* IN */
int ret; /* OUT */
} PACKED cctrl_cmd_slave_evacuate_t;
typedef struct castle_control_slave_scan {
c_slave_uuid_t id; /* IN */
int ret; /* OUT */
} PACKED cctrl_cmd_slave_scan_t;
typedef struct castle_control_cmd_thread_priority {
int nice_value; /* IN */
int ret; /* OUT */
} cctrl_cmd_thread_priority_t;
/* Golden Nugget - Interface structures. */
typedef struct castle_control_cmd_merge_thread_create {
c_thread_id_t thread_id; /* OUT */
int ret; /* OUT */
} cctrl_cmd_merge_thread_create_t;
typedef struct castle_control_cmd_merge_thread_destroy {
c_thread_id_t thread_id; /* IN */
int ret; /* OUT */
} cctrl_cmd_merge_thread_destroy_t;
typedef struct castle_control_cmd_merge_start {
c_merge_cfg_t merge_cfg; /* IN */
c_merge_id_t merge_id; /* OUT */
int ret; /* OUT */
} cctrl_cmd_merge_start_t;
typedef struct castle_control_cmd_merge_do_work {
c_merge_id_t merge_id; /* IN */
c_work_size_t work_size; /* IN */
c_work_id_t work_id; /* OUT */
int ret; /* OUT */
} cctrl_cmd_merge_do_work_t;
typedef struct castle_control_cmd_merge_stop {
c_merge_id_t merge_id; /* IN */
int ret; /* OUT */
} cctrl_cmd_merge_stop_t;
typedef struct castle_control_cmd_merge_thread_attach {
c_merge_id_t merge_id; /* IN */
c_thread_id_t thread_id; /* IN */
int ret; /* OUT */
} cctrl_cmd_merge_thread_attach_t;
typedef struct castle_control_cmd_insert_rate_set {
c_da_t vertree_id; /* IN */
uint32_t insert_rate; /* IN */
int ret; /* OUT */
} cctrl_cmd_insert_rate_set_t;
typedef struct castle_control_cmd_read_rate_set {
c_da_t vertree_id; /* IN */
uint32_t read_rate; /* IN */
int ret; /* OUT */
} cctrl_cmd_read_rate_set_t;
typedef struct castle_control_cmd_prog_register {
int ret; /* OUT */
} cctrl_cmd_prog_register_t;
typedef struct castle_control_cmd_prog_deregister {
uint8_t shutdown; /* IN */
pid_t pid; /* OUT */
int ret; /* OUT */
} cctrl_cmd_prog_deregister_t;
typedef struct castle_control_cmd_prog_heartbeat {
int ret; /* OUT */
} cctrl_cmd_prog_heartbeat_t;
typedef struct castle_control_cmd_vertree_tdp_set {
c_da_t vertree_id; /* IN */
uint64_t seconds; /* IN */
int ret; /* OUT */
} cctrl_cmd_vertree_tdp_set_t;
typedef enum {
CASTLE_STATE_LOADING = 0,
CASTLE_STATE_UNINITED,
CASTLE_STATE_INITED,
} c_state_t;
typedef struct castle_control_cmd_state_query {
c_state_t state; /* OUT */
int ret; /* OUT */
} cctrl_cmd_state_query_t;
typedef struct castle_control_ioctl {
uint16_t cmd;
union {
cctrl_cmd_claim_t claim;
cctrl_cmd_release_t release;
cctrl_cmd_init_t init;
cctrl_cmd_attach_t attach;
cctrl_cmd_detach_t detach;
cctrl_cmd_snapshot_t snapshot;
cctrl_cmd_collection_attach_t collection_attach;
cctrl_cmd_collection_reattach_t collection_reattach;
cctrl_cmd_collection_detach_t collection_detach;
cctrl_cmd_collection_snapshot_t collection_snapshot;
cctrl_cmd_create_t create;
cctrl_cmd_create_with_opts_t create_with_opts;
cctrl_cmd_destroy_vertree_t destroy_vertree;
cctrl_cmd_delete_version_t delete_version;
cctrl_cmd_clone_t clone;
cctrl_cmd_transfer_create_t transfer_create;
cctrl_cmd_transfer_destroy_t transfer_destroy;
cctrl_cmd_protocol_version_t protocol_version;
cctrl_cmd_environment_set_t environment_set;
cctrl_cmd_fault_t fault;
cctrl_cmd_trace_setup_t trace_setup;
cctrl_cmd_trace_start_t trace_start;
cctrl_cmd_trace_stop_t trace_stop;
cctrl_cmd_trace_teardown_t trace_teardown;
cctrl_cmd_slave_evacuate_t slave_evacuate;
cctrl_cmd_slave_scan_t slave_scan;
cctrl_cmd_thread_priority_t thread_priority;
cctrl_cmd_merge_thread_create_t merge_thread_create;
cctrl_cmd_merge_thread_destroy_t merge_thread_destroy;
cctrl_cmd_merge_start_t merge_start;
cctrl_cmd_merge_do_work_t merge_do_work;
cctrl_cmd_merge_stop_t merge_stop;
cctrl_cmd_merge_thread_attach_t merge_thread_attach;
cctrl_cmd_insert_rate_set_t insert_rate_set;
cctrl_cmd_read_rate_set_t read_rate_set;
cctrl_cmd_prog_register_t ctrl_prog_register;
cctrl_cmd_prog_deregister_t ctrl_prog_deregister;
cctrl_cmd_prog_heartbeat_t ctrl_prog_heartbeat;
cctrl_cmd_vertree_tdp_set_t vertree_tdp_set;
cctrl_cmd_state_query_t state_query;
};
} cctrl_ioctl_t;
/* IOCTL definitions. */
enum {
CASTLE_CTRL_CLAIM_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_CLAIM, cctrl_ioctl_t),
CASTLE_CTRL_ATTACH_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_ATTACH, cctrl_ioctl_t),
CASTLE_CTRL_DETACH_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_DETACH, cctrl_ioctl_t),
CASTLE_CTRL_CREATE_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_CREATE, cctrl_ioctl_t),
CASTLE_CTRL_CREATE_WITH_OPTS_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_CREATE_WITH_OPTS, cctrl_ioctl_t),
CASTLE_CTRL_CLONE_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_CLONE, cctrl_ioctl_t),
CASTLE_CTRL_SNAPSHOT_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_SNAPSHOT, cctrl_ioctl_t),
CASTLE_CTRL_INIT_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_INIT, cctrl_ioctl_t),
CASTLE_CTRL_COLLECTION_ATTACH_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_COLLECTION_ATTACH, cctrl_ioctl_t),
CASTLE_CTRL_COLLECTION_REATTACH_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_COLLECTION_REATTACH, cctrl_ioctl_t),
CASTLE_CTRL_COLLECTION_DETACH_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_COLLECTION_DETACH, cctrl_ioctl_t),
CASTLE_CTRL_COLLECTION_SNAPSHOT_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_COLLECTION_SNAPSHOT, cctrl_ioctl_t),
CASTLE_CTRL_VALID_STATS_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_VALID_STATS, cctrl_ioctl_t),
CASTLE_CTRL_INVALID_STATS_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_INVALID_STATS, cctrl_ioctl_t),
CASTLE_CTRL_DESTROY_VERTREE_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_DESTROY_VERTREE, cctrl_ioctl_t),
CASTLE_CTRL_DELETE_VERSION_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_DELETE_VERSION, cctrl_ioctl_t),
CASTLE_CTRL_PROTOCOL_VERSION_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_PROTOCOL_VERSION, cctrl_ioctl_t),
CASTLE_CTRL_ENVIRONMENT_SET_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_ENVIRONMENT_SET, cctrl_ioctl_t),
CASTLE_CTRL_FAULT_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_FAULT, cctrl_ioctl_t),
CASTLE_CTRL_TRACE_SETUP_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_TRACE_SETUP, cctrl_ioctl_t),
CASTLE_CTRL_TRACE_START_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_TRACE_START, cctrl_ioctl_t),
CASTLE_CTRL_TRACE_STOP_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_TRACE_STOP, cctrl_ioctl_t),
CASTLE_CTRL_TRACE_TEARDOWN_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_TRACE_TEARDOWN, cctrl_ioctl_t),
CASTLE_CTRL_SLAVE_EVACUATE_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_SLAVE_EVACUATE, cctrl_ioctl_t),
CASTLE_CTRL_THREAD_PRIORITY_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_THREAD_PRIORITY, cctrl_ioctl_t),
CASTLE_CTRL_SLAVE_SCAN_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_SLAVE_SCAN, cctrl_ioctl_t),
CASTLE_CTRL_MERGE_THREAD_CREATE_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_MERGE_THREAD_CREATE, cctrl_ioctl_t),
CASTLE_CTRL_MERGE_THREAD_DESTROY_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_MERGE_THREAD_DESTROY, cctrl_ioctl_t),
CASTLE_CTRL_MERGE_START_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_MERGE_START, cctrl_ioctl_t),
CASTLE_CTRL_MERGE_DO_WORK_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_MERGE_DO_WORK, cctrl_ioctl_t),
CASTLE_CTRL_MERGE_STOP_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_MERGE_STOP, cctrl_ioctl_t),
CASTLE_CTRL_MERGE_THREAD_ATTACH_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_MERGE_THREAD_ATTACH, cctrl_ioctl_t),
CASTLE_CTRL_INSERT_RATE_SET_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_INSERT_RATE_SET, cctrl_ioctl_t),
CASTLE_CTRL_READ_RATE_SET_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_READ_RATE_SET, cctrl_ioctl_t),
CASTLE_CTRL_PROG_REGISTER_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_PROG_REGISTER, cctrl_ioctl_t),
CASTLE_CTRL_PROG_DEREGISTER_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_PROG_DEREGISTER, cctrl_ioctl_t),
CASTLE_CTRL_PROG_HEARTBEAT_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_PROG_HEARTBEAT, cctrl_ioctl_t),
CASTLE_CTRL_VERTREE_TDP_SET_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_VERTREE_TDP_SET, cctrl_ioctl_t),
CASTLE_CTRL_STATE_QUERY_IOCTL =
_IOWR(CASTLE_CTRL_IOCTL_TYPE, CASTLE_CTRL_STATE_QUERY, cctrl_ioctl_t),
};
/*
* Castle B-tree key definitions. The key structure defined here is also, in fact, the key
* structure which is exported to userspace.
*/
/**
* Castle B-Tree key. No pointers.
*
* Each dim_head(one per dimension) contains 8-bits for flags(lower bits) and remaining
* 24 bits for offset of the payload. Payloads continue immediately after dim_head array.
*/
typedef struct castle_var_length_btree_key {
/* align: 4 */
/* offset: 0 */ uint32_t length;
/* 4 */ uint32_t nr_dims;
/* 8 */ uint8_t _unused[8];
/* 16 */ uint32_t dim_head[0];
/* 16 */
/* Dimension header is followed by individual dimensions. */
} PACKED c_vl_bkey_t;
#define KEY_DIMENSION_NEXT_FLAG (1 << 0)
#define KEY_DIMENSION_MINUS_INFINITY_FLAG (1 << 1)
#define KEY_DIMENSION_PLUS_INFINITY_FLAG (1 << 2)
#define KEY_DIMENSION_UNUSED3_FLAG (1 << 3)
#define KEY_DIMENSION_UNUSED4_FLAG (1 << 4)
#define KEY_DIMENSION_UNUSED5_FLAG (1 << 5)
#define KEY_DIMENSION_UNUSED6_FLAG (1 << 6)
#define KEY_DIMENSION_UNUSED7_FLAG (1 << 7)
#define KEY_DIMENSION_FLAGS_SHIFT (8)
#define KEY_DIMENSION_FLAGS_MASK ((1 << KEY_DIMENSION_FLAGS_SHIFT) - 1)
#define KEY_DIMENSION_INFINITY_FLAGS_MASK (KEY_DIMENSION_MINUS_INFINITY_FLAG | \
KEY_DIMENSION_PLUS_INFINITY_FLAG)
#define KEY_DIMENSION_FLAGS(_dim_head) ((_dim_head) & KEY_DIMENSION_FLAGS_MASK)
#define KEY_DIMENSION_OFFSET(_dim_head) ((_dim_head) >> KEY_DIMENSION_FLAGS_SHIFT)
#define KEY_DIMENSION_HEADER(_off, _flags) (((_off) << KEY_DIMENSION_FLAGS_SHIFT) | \
((_flags) & KEY_DIMENSION_FLAGS_MASK))
#define castle_object_btree_key_header_size(_nr_dims) \
( sizeof(c_vl_bkey_t) + ((_nr_dims) * 4) )
#define castle_object_btree_key_length(_key) \
( (_key) ? ((_key)->length + 4) : 0 )
#define castle_object_btree_key_dim_length(key, dim) \
({ \
uint32_t end_offset; \
\
end_offset = (dim+1 < key->nr_dims) ? KEY_DIMENSION_OFFSET(key->dim_head[dim+1]) : \
key->length + 4; \
(end_offset - KEY_DIMENSION_OFFSET(key->dim_head[dim])); \
})
#define castle_object_btree_key_dim_get(key, dim) \
({ \
((char *)key + KEY_DIMENSION_OFFSET(key->dim_head[dim])); \
})
#define castle_object_btree_key_dim_flags_get(key, dim) \
({ \
(KEY_DIMENSION_FLAGS(key->dim_head[dim])); \
})
/*
* Castle request interface definitions.
*
* CASTLE_RING_SIZE (and hence CASTLE_RING_PAGES) must be a power of two or code
* will silently break.
*
* The __RING_SIZE macro determines how many requests can be present on the ring
* at a time. This macro allocates some space for the ring structures before
* rounding down the remaining space to the next power of two. Hence the Bytes
* available for requests tends to be CASTLE_RING_SIZE/2 (which should be a
* power of two).
*
* Requests on the ring are represented as castle_back_op structures. As such
* there are (CASTLE_RING_SIZE/2)/sizeof(castle_back_op) slots on the ring.
*
* CASTLE_STATEFUL_OPS determines the maximum number of stateful_ops. In the
* frontend code (libcastle) CASTLE_STATEFUL_OPS slots are reserved on the ring.
* These slots cannot be used except by ongoing stateful_ops. Therefore there
* can be at most
* (CASTLE_RING_SIZE/2)/sizeof(castle_back_request)-CASTLE_STATEFUL_OPS requests
* on the ring that are not ongoing stateful ops. Furthermore, the total ring
* capacity must not exactly match CASTLE_STATEFUL_OPS or no requests may be
* queued.
*/
#define CASTLE_RING_PAGES (32) /**< Must be a power of 2. */
#define CASTLE_RING_SIZE (CASTLE_RING_PAGES << PAGE_SHIFT)
#define CASTLE_STATEFUL_OPS 512 /**< Must be < total slots. */
#define CASTLE_IOCTL_POKE_RING 2
#define CASTLE_IOCTL_WAIT 3
#define CASTLE_RING_REPLACE 1
#define CASTLE_RING_BIG_PUT 2
#define CASTLE_RING_PUT_CHUNK 3
#define CASTLE_RING_GET 4
#define CASTLE_RING_BIG_GET 5
#define CASTLE_RING_GET_CHUNK 6
#define CASTLE_RING_ITER_START 7
#define CASTLE_RING_ITER_NEXT 8
#define CASTLE_RING_ITER_SKIP 9
#define CASTLE_RING_ITER_FINISH 10
#define CASTLE_RING_REMOVE 11
#define CASTLE_RING_COUNTER_REPLACE 12
#define CASTLE_RING_TIMESTAMPED_REPLACE 13
#define CASTLE_RING_TIMESTAMPED_REMOVE 14
#define CASTLE_RING_TIMESTAMPED_BIG_PUT 15
/* Sequential stream insertion interface */
#define CASTLE_RING_STREAM_IN_START 16
#define CASTLE_RING_STREAM_IN_NEXT 17
#define CASTLE_RING_STREAM_IN_FINISH 18
typedef uint32_t castle_interface_token_t;
typedef struct castle_request_replace {
c_collection_id_t collection_id;
uint32_t key_len;
c_vl_bkey_t *key_ptr;
void *value_ptr;
uint32_t value_len;
} castle_request_replace_t;
typedef struct castle_request_timestamped_replace {
c_collection_id_t collection_id;
uint32_t key_len;
c_vl_bkey_t *key_ptr;
void *value_ptr;
uint32_t value_len;
castle_user_timestamp_t user_timestamp;
} castle_request_timestamped_replace_t;
enum{
CASTLE_COUNTER_TYPE_SET=0,
CASTLE_COUNTER_TYPE_ADD,
};
typedef struct castle_request_counter_replace {
c_collection_id_t collection_id;
uint32_t key_len;
c_vl_bkey_t *key_ptr;
void *value_ptr;
uint32_t value_len;
uint8_t add; /**< Op type: CASTLE_COUNTER_TYPE_{SET|ADD}. */
} castle_request_counter_replace_t;
typedef struct castle_request_remove {
c_collection_id_t collection_id;
uint32_t key_len;
c_vl_bkey_t *key_ptr;
} castle_request_remove_t;
typedef struct castle_request_timestamped_remove {
c_collection_id_t collection_id;
uint32_t key_len;
c_vl_bkey_t *key_ptr;
castle_user_timestamp_t user_timestamp;
} castle_request_timestamped_remove_t;
typedef struct castle_request_get {
c_collection_id_t collection_id;
uint32_t key_len;
c_vl_bkey_t *key_ptr;
void *value_ptr; /**< Output buffer for result. */
uint32_t value_len;
} castle_request_get_t;
typedef struct castle_request_iter_start {
c_collection_id_t collection_id;
uint32_t start_key_len;
c_vl_bkey_t *start_key_ptr;
c_vl_bkey_t *end_key_ptr;
uint32_t end_key_len;
void *buffer_ptr; /**< Resulting kvps from iterator. */
uint32_t buffer_len; /**< Size of buffer_ptr buffer. */
} castle_request_iter_start_t;
typedef struct castle_request_stream_in_start {
c_collection_id_t collection_id;
uint64_t entries_count;
uint32_t medium_object_chunks;
} castle_request_stream_in_start_t;
typedef struct castle_request_iter_next {
castle_interface_token_t token;
uint32_t buffer_len;
void *buffer_ptr;
} castle_request_iter_next_t;
typedef struct castle_request_stream_in_next {
castle_interface_token_t token;
uint32_t buffer_len;
void *buffer_ptr;
} castle_request_stream_in_next_t;
typedef struct castle_request_iter_finish {
castle_interface_token_t token;
} castle_request_iter_finish_t;
typedef struct castle_request_stream_in_finish {
castle_interface_token_t token;
int8_t abort;
} castle_request_stream_in_finish_t;
typedef struct castle_request_big_get {
c_collection_id_t collection_id;
uint32_t key_len;
c_vl_bkey_t *key_ptr;
} castle_request_big_get_t;
typedef struct castle_request_get_chunk {
castle_interface_token_t token;
uint32_t buffer_len;
void *buffer_ptr;
} castle_request_get_chunk_t;
typedef struct castle_request_big_put {
c_collection_id_t collection_id;
uint32_t key_len;
c_vl_bkey_t *key_ptr;
uint64_t value_len;
} castle_request_big_put_t;
typedef struct castle_request_timestamped_big_put {
c_collection_id_t collection_id;
uint32_t key_len;
c_vl_bkey_t *key_ptr;
uint64_t value_len;
castle_user_timestamp_t user_timestamp;
} castle_request_timestamped_big_put_t;
typedef struct castle_request_put_chunk {
castle_interface_token_t token;
uint32_t buffer_len;
void *buffer_ptr;
} castle_request_put_chunk_t;
typedef struct castle_request {
uint32_t call_id;
uint32_t tag;
union {
castle_request_timestamped_replace_t timestamped_replace;
castle_request_timestamped_remove_t timestamped_remove;
castle_request_timestamped_big_put_t timestamped_big_put;
castle_request_replace_t replace;
castle_request_remove_t remove;
castle_request_get_t get;
castle_request_counter_replace_t counter_replace;
castle_request_big_get_t big_get;
castle_request_get_chunk_t get_chunk;
castle_request_big_put_t big_put;
castle_request_put_chunk_t put_chunk;
castle_request_iter_start_t iter_start;
castle_request_iter_next_t iter_next;
castle_request_iter_finish_t iter_finish;
castle_request_stream_in_start_t stream_in_start;
castle_request_stream_in_next_t stream_in_next;
castle_request_stream_in_finish_t stream_in_finish;
};
uint8_t flags; /**< Flags affecting op, see CASTLE_RING_FLAGs. */
} castle_request_t;
/**
* Value types used in struct castle_request.flags field, which is a uint8_t.
*/
enum {
CASTLE_RING_FLAG_NONE = (1 << 0), /**< No flags specified. */
CASTLE_RING_FLAG_NO_PREFETCH = (1 << 1), /**< Don't prefetch as part of this request. */
CASTLE_RING_FLAG_NO_CACHE = (1 << 2), /**< Don't evict other data to cache this request. */
CASTLE_RING_FLAG_ITER_NO_VALUES = (1 << 3), /**< Iterator to return only keys, not values. */
CASTLE_RING_FLAG_ITER_GET_OOL = (1 << 4), /**< Return out-of-line values inline. */
CASTLE_RING_FLAG_RET_TIMESTAMP = (1 << 5), /**< Return value timestamps. */
CASTLE_RING_FLAG_RET_TOMBSTONE = (1 << 6), /**< Return tombstones (instead of ENOENT). */
CASTLE_RING_FLAG_INC_BACKUP = (1 << 7), /**< Iterator for Incremental Backup. */
/* Note: Flags are stored in 8-bit fields. Don't overflow. */
};
typedef struct castle_response {
uint32_t call_id;
uint32_t err;
uint64_t length;
castle_interface_token_t token;
castle_user_timestamp_t user_timestamp; /**< For non-timestamped collections, this will be
undefined. If the request flag did not specify
CASTLE_RING_FLAG_RET_TIMESTAMP, this is
undefined. Undefined on non-get ops. */
castle_resp_flags_t flags; /**< See e.g. CASTLE_RESPONSE_FLAG_TOMBSTONE. */
} castle_response_t;
enum {
CASTLE_RESPONSE_FLAG_NONE = (0 ), /**< No flags specified. */
CASTLE_RESPONSE_FLAG_TOMBSTONE = (1 << 0), /**< Value is a tombstone. */
};
/* Value types used in struct castle_iter_val. */
enum {
CASTLE_VALUE_TYPE_INVALID = 0,
CASTLE_VALUE_TYPE_INLINE = 1,
CASTLE_VALUE_TYPE_OUT_OF_LINE = 2,
CASTLE_VALUE_TYPE_INLINE_COUNTER = 3,
CASTLE_VALUE_TYPE_TOMBSTONE = 4
};
struct castle_iter_val {
uint64_t length;
uint8_t type;
union {
uint8_t *val;
c_collection_id_t collection_id;
};
};
struct castle_key_value_list {
struct castle_key_value_list *next;