1use crate::lsm_tree::{
6 PersistentLayerHeader, PersistentLayerHeaderV39, PersistentLayerInfo, PersistentLayerInfoV39,
7};
8use crate::object_store::allocator::{
9 AllocatorInfo, AllocatorInfoV32, AllocatorKey, AllocatorKeyV32, AllocatorValue,
10 AllocatorValueV32,
11};
12use crate::object_store::journal::super_block::{
13 SuperBlockHeader, SuperBlockHeaderV32, SuperBlockRecord, SuperBlockRecordV40,
14 SuperBlockRecordV41, SuperBlockRecordV43, SuperBlockRecordV46, SuperBlockRecordV47,
15 SuperBlockRecordV49, SuperBlockRecordV50,
16};
17use crate::object_store::journal::{
18 JournalRecord, JournalRecordV40, JournalRecordV41, JournalRecordV42, JournalRecordV43,
19 JournalRecordV46, JournalRecordV47, JournalRecordV49, JournalRecordV50,
20};
21use crate::object_store::object_record::{
22 FsverityMetadata, FsverityMetadataV33, FsverityMetadataV50, ObjectKey, ObjectKeyV40,
23 ObjectKeyV43, ObjectValue, ObjectValueV40, ObjectValueV41, ObjectValueV46, ObjectValueV47,
24 ObjectValueV49, ObjectValueV50,
25};
26use crate::object_store::transaction::{
27 Mutation, MutationV40, MutationV41, MutationV43, MutationV46, MutationV47, MutationV49,
28 MutationV50,
29};
30use crate::object_store::{
31 EncryptedMutations, EncryptedMutationsV40, EncryptedMutationsV49, StoreInfo, StoreInfoV40,
32 StoreInfoV49,
33};
34use crate::serialized_types::{Version, Versioned, VersionedLatest, versioned_type};
35use std::collections::BTreeMap;
36
37pub const LATEST_VERSION: Version = Version { major: 50, minor: 0 };
47
48pub const EARLIEST_SUPPORTED_VERSION: Version = Version { major: 40, minor: 0 };
57
58pub const SMALL_SUPERBLOCK_VERSION: Version = Version { major: 44, minor: 0 };
61
62pub const FIRST_EXTENT_IN_SUPERBLOCK_VERSION: Version = Version { major: 45, minor: 0 };
65
66macro_rules! versioned_types {
67 ( $( $name:ident { $latest:literal.. => $latest_type:ty $(, $major:literal.. => $type:ty )* $(,)? } )+ ) => {
68 $(
69 static_assertions::assert_type_eq_all!($name, $latest_type);
70
71 versioned_type! {
72 $latest.. => $latest_type,
73 $( $major.. => $type ),*
74 }
75 )+
76
77 pub fn get_type_fingerprints(version: Version) -> BTreeMap<String, String> {
78 let mut map = BTreeMap::new();
79 $(
80 let fingerprint = {
81 let mut fp = None;
82 const FINGERPRINTS: &[(u32, fn() -> String)] = &[
83 ($latest, <$latest_type as fprint::TypeFingerprint>::fingerprint),
84 $( ($major, <$type as fprint::TypeFingerprint>::fingerprint) ),*
85 ];
86 for (major, type_fp) in FINGERPRINTS {
87 if version.major >= *major {
88 fp = Some(type_fp());
89 break;
90 }
91 }
92 fp
93 };
94 if let Some(fp) = fingerprint {
95 map.insert(stringify!($name).to_string(), fp.to_string());
96 }
97 )+
98 map
99 }
100 };
101}
102
103versioned_types! {
104 AllocatorInfo {
105 32.. => AllocatorInfoV32,
106 }
107 AllocatorKey {
108 32.. => AllocatorKeyV32,
109 }
110 AllocatorValue {
111 32.. => AllocatorValueV32,
112 }
113 EncryptedMutations {
114 49.. => EncryptedMutationsV49,
115 40.. => EncryptedMutationsV40,
116 }
117 FsverityMetadata {
118 50.. => FsverityMetadataV50,
119 33.. => FsverityMetadataV33,
120 }
121 JournalRecord {
122 50.. => JournalRecordV50,
123 49.. => JournalRecordV49,
124 47.. => JournalRecordV47,
125 46.. => JournalRecordV46,
126 43.. => JournalRecordV43,
127 42.. => JournalRecordV42,
128 41.. => JournalRecordV41,
129 40.. => JournalRecordV40,
130 }
131 Mutation {
132 50.. => MutationV50,
133 49.. => MutationV49,
134 47.. => MutationV47,
135 46.. => MutationV46,
136 43.. => MutationV43,
137 41.. => MutationV41,
138 40.. => MutationV40,
139 }
140 ObjectKey {
141 43.. => ObjectKeyV43,
142 40.. => ObjectKeyV40,
143 }
144 ObjectValue {
145 50.. => ObjectValueV50,
146 49.. => ObjectValueV49,
147 47.. => ObjectValueV47,
148 46.. => ObjectValueV46,
149 41.. => ObjectValueV41,
150 40.. => ObjectValueV40,
151 }
152 PersistentLayerHeader {
153 39.. => PersistentLayerHeaderV39,
154 }
155 PersistentLayerInfo {
156 39.. => PersistentLayerInfoV39,
157 }
158 StoreInfo {
159 49.. => StoreInfoV49,
160 40.. => StoreInfoV40,
161 }
162 SuperBlockHeader {
163 32.. => SuperBlockHeaderV32,
164 }
165 SuperBlockRecord {
166 50.. => SuperBlockRecordV50,
167 49.. => SuperBlockRecordV49,
168 47.. => SuperBlockRecordV47,
169 46.. => SuperBlockRecordV46,
170 43.. => SuperBlockRecordV43,
171 41.. => SuperBlockRecordV41,
172 40.. => SuperBlockRecordV40,
173 }
174}