blob: 09335c80a64579c4bd1ceb0bd77971cd98efdb16 [file] [log] [blame]
Christopher Ferris38062f92014-07-09 15:33:25 -07001/****************************************************************************
2 ****************************************************************************
3 ***
4 *** This header was automatically generated from a Linux kernel header
5 *** of the same name, to make information necessary for userspace to
6 *** call into the kernel available to libc. It contains only constants,
7 *** structures, and macros generated from the original header, and thus,
8 *** contains no copyrightable information.
9 ***
10 *** To edit the content of this header, modify the corresponding
11 *** source file (e.g. under external/kernel-headers/original/) then
12 *** run bionic/libc/kernel/tools/update_all.py
13 ***
14 *** Any manual change here will be lost the next time this script will
15 *** be run. You've been warned!
16 ***
17 ****************************************************************************
18 ****************************************************************************/
19#ifndef _LINUX_BCACHE_H
20#define _LINUX_BCACHE_H
Christopher Ferris525ce912017-07-26 13:12:53 -070021#include <linux/types.h>
Tao Baod7db5942015-01-28 10:07:51 -080022#define BITMASK(name,type,field,offset,size) static inline __u64 name(const type * k) \
23{ return(k->field >> offset) & ~(~0ULL << size); } static inline void SET_ ##name(type * k, __u64 v) \
24{ k->field &= ~(~(~0ULL << size) << offset); k->field |= (v & ~(~0ULL << size)) << offset; \
25}
Christopher Ferris38062f92014-07-09 15:33:25 -070026struct bkey {
Tao Baod7db5942015-01-28 10:07:51 -080027 __u64 high;
28 __u64 low;
29 __u64 ptr[];
Christopher Ferris38062f92014-07-09 15:33:25 -070030};
Tao Baod7db5942015-01-28 10:07:51 -080031#define KEY_FIELD(name,field,offset,size) BITMASK(name, struct bkey, field, offset, size)
Christopher Ferris9ce28842018-10-25 12:11:39 -070032#define PTR_FIELD(name,offset,size) static inline __u64 name(const struct bkey * k, unsigned int i) \
33{ return(k->ptr[i] >> offset) & ~(~0ULL << size); } static inline void SET_ ##name(struct bkey * k, unsigned int i, __u64 v) \
Tao Baod7db5942015-01-28 10:07:51 -080034{ k->ptr[i] &= ~(~(~0ULL << size) << offset); k->ptr[i] |= (v & ~(~0ULL << size)) << offset; \
35}
Christopher Ferris38062f92014-07-09 15:33:25 -070036#define KEY_SIZE_BITS 16
Christopher Ferris38062f92014-07-09 15:33:25 -070037#define KEY_MAX_U64S 8
Tao Baod7db5942015-01-28 10:07:51 -080038#define KEY(inode,offset,size) \
39((struct bkey) {.high = (1ULL << 63) | ((__u64) (size) << 20) | (inode),.low = (offset) \
40})
Christopher Ferris38062f92014-07-09 15:33:25 -070041#define ZERO_KEY KEY(0, 0, 0)
42#define MAX_KEY_INODE (~(~0 << 20))
Christopher Ferris38062f92014-07-09 15:33:25 -070043#define MAX_KEY_OFFSET (~0ULL >> 1)
44#define MAX_KEY KEY(MAX_KEY_INODE, MAX_KEY_OFFSET, 0)
45#define KEY_START(k) (KEY_OFFSET(k) - KEY_SIZE(k))
46#define START_KEY(k) KEY(KEY_INODE(k), KEY_START(k), 0)
Christopher Ferris38062f92014-07-09 15:33:25 -070047#define PTR_DEV_BITS 12
48#define PTR_CHECK_DEV ((1 << PTR_DEV_BITS) - 1)
Christopher Ferris934ec942018-01-31 15:29:16 -080049#define MAKE_PTR(gen,offset,dev) ((((__u64) dev) << 51) | ((__u64) offset) << 8 | gen)
Tao Baod7db5942015-01-28 10:07:51 -080050#define bkey_copy(_dest,_src) memcpy(_dest, _src, bkey_bytes(_src))
Christopher Ferris38062f92014-07-09 15:33:25 -070051#define BKEY_PAD 8
Tao Baod7db5942015-01-28 10:07:51 -080052#define BKEY_PADDED(key) union { struct bkey key; __u64 key ##_pad[BKEY_PAD]; }
Christopher Ferris38062f92014-07-09 15:33:25 -070053#define BCACHE_SB_VERSION_CDEV 0
54#define BCACHE_SB_VERSION_BDEV 1
Christopher Ferris38062f92014-07-09 15:33:25 -070055#define BCACHE_SB_VERSION_CDEV_WITH_UUID 3
56#define BCACHE_SB_VERSION_BDEV_WITH_OFFSET 4
Christopher Ferris25c18d42020-10-14 17:42:58 -070057#define BCACHE_SB_VERSION_CDEV_WITH_FEATURES 5
58#define BCACHE_SB_VERSION_BDEV_WITH_FEATURES 6
59#define BCACHE_SB_MAX_VERSION 6
Christopher Ferris38062f92014-07-09 15:33:25 -070060#define SB_SECTOR 8
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -070061#define SB_OFFSET (SB_SECTOR << SECTOR_SHIFT)
Christopher Ferris38062f92014-07-09 15:33:25 -070062#define SB_SIZE 4096
63#define SB_LABEL_SIZE 32
64#define SB_JOURNAL_BUCKETS 256U
65#define MAX_CACHES_PER_SET 8
Christopher Ferris38062f92014-07-09 15:33:25 -070066#define BDEV_DATA_START_DEFAULT 16
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -070067struct cache_sb_disk {
68 __le64 csum;
69 __le64 offset;
70 __le64 version;
71 __u8 magic[16];
72 __u8 uuid[16];
73 union {
74 __u8 set_uuid[16];
75 __le64 set_magic;
76 };
77 __u8 label[SB_LABEL_SIZE];
78 __le64 flags;
79 __le64 seq;
Christopher Ferris25c18d42020-10-14 17:42:58 -070080 __le64 feature_compat;
81 __le64 feature_incompat;
82 __le64 feature_ro_compat;
83 __le64 pad[5];
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -070084 union {
85 struct {
86 __le64 nbuckets;
87 __le16 block_size;
88 __le16 bucket_size;
89 __le16 nr_in_set;
90 __le16 nr_this_dev;
91 };
92 struct {
93 __le64 data_offset;
94 };
95 };
96 __le32 last_mount;
97 __le16 first_bucket;
98 union {
99 __le16 njournal_buckets;
100 __le16 keys;
101 };
102 __le64 d[SB_JOURNAL_BUCKETS];
Christopher Ferris25c18d42020-10-14 17:42:58 -0700103 __le16 bucket_size_hi;
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700104};
Christopher Ferris38062f92014-07-09 15:33:25 -0700105struct cache_sb {
Tao Baod7db5942015-01-28 10:07:51 -0800106 __u64 offset;
Tao Baod7db5942015-01-28 10:07:51 -0800107 __u64 version;
108 __u8 magic[16];
109 __u8 uuid[16];
110 union {
Tao Baod7db5942015-01-28 10:07:51 -0800111 __u8 set_uuid[16];
112 __u64 set_magic;
113 };
114 __u8 label[SB_LABEL_SIZE];
Tao Baod7db5942015-01-28 10:07:51 -0800115 __u64 flags;
116 __u64 seq;
Christopher Ferris25c18d42020-10-14 17:42:58 -0700117 __u64 feature_compat;
118 __u64 feature_incompat;
119 __u64 feature_ro_compat;
Tao Baod7db5942015-01-28 10:07:51 -0800120 union {
Tao Baod7db5942015-01-28 10:07:51 -0800121 struct {
122 __u64 nbuckets;
123 __u16 block_size;
Tao Baod7db5942015-01-28 10:07:51 -0800124 __u16 nr_in_set;
125 __u16 nr_this_dev;
Christopher Ferris25c18d42020-10-14 17:42:58 -0700126 __u32 bucket_size;
Tao Baod7db5942015-01-28 10:07:51 -0800127 };
128 struct {
Tao Baod7db5942015-01-28 10:07:51 -0800129 __u64 data_offset;
130 };
131 };
132 __u32 last_mount;
Tao Baod7db5942015-01-28 10:07:51 -0800133 __u16 first_bucket;
134 union {
135 __u16 njournal_buckets;
136 __u16 keys;
Tao Baod7db5942015-01-28 10:07:51 -0800137 };
138 __u64 d[SB_JOURNAL_BUCKETS];
Christopher Ferris38062f92014-07-09 15:33:25 -0700139};
140#define CACHE_REPLACEMENT_LRU 0U
Christopher Ferris38062f92014-07-09 15:33:25 -0700141#define CACHE_REPLACEMENT_FIFO 1U
142#define CACHE_REPLACEMENT_RANDOM 2U
143#define CACHE_MODE_WRITETHROUGH 0U
144#define CACHE_MODE_WRITEBACK 1U
Christopher Ferris38062f92014-07-09 15:33:25 -0700145#define CACHE_MODE_WRITEAROUND 2U
146#define CACHE_MODE_NONE 3U
147#define BDEV_STATE_NONE 0U
148#define BDEV_STATE_CLEAN 1U
Christopher Ferris38062f92014-07-09 15:33:25 -0700149#define BDEV_STATE_DIRTY 2U
150#define BDEV_STATE_STALE 3U
151#define JSET_MAGIC 0x245235c1a3625032ULL
152#define PSET_MAGIC 0x6750e15f87337f91ULL
Christopher Ferris38062f92014-07-09 15:33:25 -0700153#define BSET_MAGIC 0x90135c78b99e07f5ULL
154#define BCACHE_JSET_VERSION_UUIDv1 1
155#define BCACHE_JSET_VERSION_UUID 1
156#define BCACHE_JSET_VERSION 1
Christopher Ferris38062f92014-07-09 15:33:25 -0700157struct jset {
Tao Baod7db5942015-01-28 10:07:51 -0800158 __u64 csum;
159 __u64 magic;
160 __u64 seq;
Tao Baod7db5942015-01-28 10:07:51 -0800161 __u32 version;
162 __u32 keys;
163 __u64 last_seq;
164 BKEY_PADDED(uuid_bucket);
Tao Baod7db5942015-01-28 10:07:51 -0800165 BKEY_PADDED(btree_root);
166 __u16 btree_level;
167 __u16 pad[3];
168 __u64 prio_bucket[MAX_CACHES_PER_SET];
Tao Baod7db5942015-01-28 10:07:51 -0800169 union {
170 struct bkey start[0];
171 __u64 d[0];
172 };
Christopher Ferris38062f92014-07-09 15:33:25 -0700173};
174struct prio_set {
Tao Baod7db5942015-01-28 10:07:51 -0800175 __u64 csum;
176 __u64 magic;
Tao Baod7db5942015-01-28 10:07:51 -0800177 __u64 seq;
178 __u32 version;
179 __u32 pad;
180 __u64 next_bucket;
Tao Baod7db5942015-01-28 10:07:51 -0800181 struct bucket_disk {
182 __u16 prio;
183 __u8 gen;
184 } __attribute((packed)) data[];
Christopher Ferris38062f92014-07-09 15:33:25 -0700185};
186struct uuid_entry {
Tao Baod7db5942015-01-28 10:07:51 -0800187 union {
188 struct {
Tao Baod7db5942015-01-28 10:07:51 -0800189 __u8 uuid[16];
190 __u8 label[32];
191 __u32 first_reg;
192 __u32 last_reg;
Tao Baod7db5942015-01-28 10:07:51 -0800193 __u32 invalidated;
194 __u32 flags;
195 __u64 sectors;
196 };
Tao Baod7db5942015-01-28 10:07:51 -0800197 __u8 pad[128];
198 };
Christopher Ferris38062f92014-07-09 15:33:25 -0700199};
200#define BCACHE_BSET_CSUM 1
Christopher Ferris38062f92014-07-09 15:33:25 -0700201#define BCACHE_BSET_VERSION 1
202struct bset {
Tao Baod7db5942015-01-28 10:07:51 -0800203 __u64 csum;
204 __u64 magic;
Tao Baod7db5942015-01-28 10:07:51 -0800205 __u64 seq;
206 __u32 version;
207 __u32 keys;
208 union {
Tao Baod7db5942015-01-28 10:07:51 -0800209 struct bkey start[0];
210 __u64 d[0];
211 };
Christopher Ferris38062f92014-07-09 15:33:25 -0700212};
Christopher Ferris38062f92014-07-09 15:33:25 -0700213struct uuid_entry_v0 {
Tao Baod7db5942015-01-28 10:07:51 -0800214 __u8 uuid[16];
215 __u8 label[32];
216 __u32 first_reg;
Tao Baod7db5942015-01-28 10:07:51 -0800217 __u32 last_reg;
218 __u32 invalidated;
219 __u32 pad;
Christopher Ferris38062f92014-07-09 15:33:25 -0700220};
Christopher Ferris38062f92014-07-09 15:33:25 -0700221#endif