hc
2024-01-04 1543e317f1da31b75942316931e8f491a8920811
kernel/include/uapi/linux/bcache.h
....@@ -141,13 +141,16 @@
141141 * Version 3: Cache device with new UUID format
142142 * Version 4: Backing device with data offset
143143 */
144
-#define BCACHE_SB_VERSION_CDEV 0
145
-#define BCACHE_SB_VERSION_BDEV 1
146
-#define BCACHE_SB_VERSION_CDEV_WITH_UUID 3
147
-#define BCACHE_SB_VERSION_BDEV_WITH_OFFSET 4
148
-#define BCACHE_SB_MAX_VERSION 4
144
+#define BCACHE_SB_VERSION_CDEV 0
145
+#define BCACHE_SB_VERSION_BDEV 1
146
+#define BCACHE_SB_VERSION_CDEV_WITH_UUID 3
147
+#define BCACHE_SB_VERSION_BDEV_WITH_OFFSET 4
148
+#define BCACHE_SB_VERSION_CDEV_WITH_FEATURES 5
149
+#define BCACHE_SB_VERSION_BDEV_WITH_FEATURES 6
150
+#define BCACHE_SB_MAX_VERSION 6
149151
150152 #define SB_SECTOR 8
153
+#define SB_OFFSET (SB_SECTOR << SECTOR_SHIFT)
151154 #define SB_SIZE 4096
152155 #define SB_LABEL_SIZE 32
153156 #define SB_JOURNAL_BUCKETS 256U
....@@ -156,8 +159,70 @@
156159
157160 #define BDEV_DATA_START_DEFAULT 16 /* sectors */
158161
162
+struct cache_sb_disk {
163
+ __le64 csum;
164
+ __le64 offset; /* sector where this sb was written */
165
+ __le64 version;
166
+
167
+ __u8 magic[16];
168
+
169
+ __u8 uuid[16];
170
+ union {
171
+ __u8 set_uuid[16];
172
+ __le64 set_magic;
173
+ };
174
+ __u8 label[SB_LABEL_SIZE];
175
+
176
+ __le64 flags;
177
+ __le64 seq;
178
+
179
+ __le64 feature_compat;
180
+ __le64 feature_incompat;
181
+ __le64 feature_ro_compat;
182
+
183
+ __le64 pad[5];
184
+
185
+ union {
186
+ struct {
187
+ /* Cache devices */
188
+ __le64 nbuckets; /* device size */
189
+
190
+ __le16 block_size; /* sectors */
191
+ __le16 bucket_size; /* sectors */
192
+
193
+ __le16 nr_in_set;
194
+ __le16 nr_this_dev;
195
+ };
196
+ struct {
197
+ /* Backing devices */
198
+ __le64 data_offset;
199
+
200
+ /*
201
+ * block_size from the cache device section is still used by
202
+ * backing devices, so don't add anything here until we fix
203
+ * things to not need it for backing devices anymore
204
+ */
205
+ };
206
+ };
207
+
208
+ __le32 last_mount; /* time overflow in y2106 */
209
+
210
+ __le16 first_bucket;
211
+ union {
212
+ __le16 njournal_buckets;
213
+ __le16 keys;
214
+ };
215
+ __le64 d[SB_JOURNAL_BUCKETS]; /* journal buckets */
216
+ __le16 obso_bucket_size_hi; /* obsoleted */
217
+};
218
+
219
+/*
220
+ * This is for in-memory bcache super block.
221
+ * NOTE: cache_sb is NOT exactly mapping to cache_sb_disk, the member
222
+ * size, ordering and even whole struct size may be different
223
+ * from cache_sb_disk.
224
+ */
159225 struct cache_sb {
160
- __u64 csum;
161226 __u64 offset; /* sector where this sb was written */
162227 __u64 version;
163228
....@@ -172,7 +237,10 @@
172237
173238 __u64 flags;
174239 __u64 seq;
175
- __u64 pad[8];
240
+
241
+ __u64 feature_compat;
242
+ __u64 feature_incompat;
243
+ __u64 feature_ro_compat;
176244
177245 union {
178246 struct {
....@@ -180,10 +248,9 @@
180248 __u64 nbuckets; /* device size */
181249
182250 __u16 block_size; /* sectors */
183
- __u16 bucket_size; /* sectors */
184
-
185251 __u16 nr_in_set;
186252 __u16 nr_this_dev;
253
+ __u32 bucket_size; /* sectors */
187254 };
188255 struct {
189256 /* Backing devices */
....@@ -210,7 +277,8 @@
210277 static inline _Bool SB_IS_BDEV(const struct cache_sb *sb)
211278 {
212279 return sb->version == BCACHE_SB_VERSION_BDEV
213
- || sb->version == BCACHE_SB_VERSION_BDEV_WITH_OFFSET;
280
+ || sb->version == BCACHE_SB_VERSION_BDEV_WITH_OFFSET
281
+ || sb->version == BCACHE_SB_VERSION_BDEV_WITH_FEATURES;
214282 }
215283
216284 BITMASK(CACHE_SYNC, struct cache_sb, flags, 0, 1);