]> git.sesse.net Git - bcachefs-tools-debian/blob - bcache.h
Don't write journal buckets
[bcachefs-tools-debian] / bcache.h
1 #ifndef _BCACHE_H
2 #define _BCACHE_H
3
4 static const char bcache_magic[] = {
5         0xc6, 0x85, 0x73, 0xf6, 0x4e, 0x1a, 0x45, 0xca,
6         0x82, 0x65, 0xf5, 0x7f, 0x48, 0xba, 0x6d, 0x81 };
7
8 #define SB_SECTOR               8
9 #define SB_LABEL_SIZE           32
10
11 struct cache_sb {
12         uint64_t                csum;
13         uint64_t                offset; /* sector where this sb was written */
14         uint64_t                version;
15 #define CACHE_BACKING_DEV       1
16
17         uint8_t                 magic[16];
18
19         uint8_t                 uuid[16];
20         union {
21                 uint8_t         set_uuid[16];
22                 uint64_t        set_magic;
23         };
24         uint8_t                 label[SB_LABEL_SIZE];
25
26         uint64_t                flags;
27         uint64_t                seq;
28         uint64_t                pad[8];
29
30         uint64_t                nbuckets;       /* device size */
31         uint16_t                block_size;     /* sectors */
32         uint16_t                bucket_size;    /* sectors */
33
34         uint16_t                nr_in_set;
35         uint16_t                nr_this_dev;
36
37         uint32_t                last_mount;     /* time_t */
38
39         uint16_t                first_bucket;
40         uint16_t                keys;           /* number of journal buckets */
41         uint64_t                d[];            /* journal buckets */
42 };
43
44 inline uint64_t crc64(const void *_data, size_t len);
45
46 #define node(i, j)              ((void *) ((i)->d + (j)))
47 #define end(i)                  node(i, (i)->keys)
48
49 #define csum_set(i)                                                     \
50         crc64(((void *) (i)) + 8, ((void *) end(i)) - (((void *) (i)) + 8))
51
52 #endif