blob: 5e5377e73c1e6723b7e86ecf66444e91ee5374d3 [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
57#define BCACHE_SB_MAX_VERSION 4
58#define SB_SECTOR 8
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -070059#define SB_OFFSET (SB_SECTOR << SECTOR_SHIFT)
Christopher Ferris38062f92014-07-09 15:33:25 -070060#define SB_SIZE 4096
61#define SB_LABEL_SIZE 32
62#define SB_JOURNAL_BUCKETS 256U
63#define MAX_CACHES_PER_SET 8
Christopher Ferris38062f92014-07-09 15:33:25 -070064#define BDEV_DATA_START_DEFAULT 16
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -070065struct cache_sb_disk {
66 __le64 csum;
67 __le64 offset;
68 __le64 version;
69 __u8 magic[16];
70 __u8 uuid[16];
71 union {
72 __u8 set_uuid[16];
73 __le64 set_magic;
74 };
75 __u8 label[SB_LABEL_SIZE];
76 __le64 flags;
77 __le64 seq;
78 __le64 pad[8];
79 union {
80 struct {
81 __le64 nbuckets;
82 __le16 block_size;
83 __le16 bucket_size;
84 __le16 nr_in_set;
85 __le16 nr_this_dev;
86 };
87 struct {
88 __le64 data_offset;
89 };
90 };
91 __le32 last_mount;
92 __le16 first_bucket;
93 union {
94 __le16 njournal_buckets;
95 __le16 keys;
96 };
97 __le64 d[SB_JOURNAL_BUCKETS];
98};
Christopher Ferris38062f92014-07-09 15:33:25 -070099struct cache_sb {
Tao Baod7db5942015-01-28 10:07:51 -0800100 __u64 csum;
101 __u64 offset;
Tao Baod7db5942015-01-28 10:07:51 -0800102 __u64 version;
103 __u8 magic[16];
104 __u8 uuid[16];
105 union {
Tao Baod7db5942015-01-28 10:07:51 -0800106 __u8 set_uuid[16];
107 __u64 set_magic;
108 };
109 __u8 label[SB_LABEL_SIZE];
Tao Baod7db5942015-01-28 10:07:51 -0800110 __u64 flags;
111 __u64 seq;
112 __u64 pad[8];
113 union {
Tao Baod7db5942015-01-28 10:07:51 -0800114 struct {
115 __u64 nbuckets;
116 __u16 block_size;
117 __u16 bucket_size;
Tao Baod7db5942015-01-28 10:07:51 -0800118 __u16 nr_in_set;
119 __u16 nr_this_dev;
120 };
121 struct {
Tao Baod7db5942015-01-28 10:07:51 -0800122 __u64 data_offset;
123 };
124 };
125 __u32 last_mount;
Tao Baod7db5942015-01-28 10:07:51 -0800126 __u16 first_bucket;
127 union {
128 __u16 njournal_buckets;
129 __u16 keys;
Tao Baod7db5942015-01-28 10:07:51 -0800130 };
131 __u64 d[SB_JOURNAL_BUCKETS];
Christopher Ferris38062f92014-07-09 15:33:25 -0700132};
133#define CACHE_REPLACEMENT_LRU 0U
Christopher Ferris38062f92014-07-09 15:33:25 -0700134#define CACHE_REPLACEMENT_FIFO 1U
135#define CACHE_REPLACEMENT_RANDOM 2U
136#define CACHE_MODE_WRITETHROUGH 0U
137#define CACHE_MODE_WRITEBACK 1U
Christopher Ferris38062f92014-07-09 15:33:25 -0700138#define CACHE_MODE_WRITEAROUND 2U
139#define CACHE_MODE_NONE 3U
140#define BDEV_STATE_NONE 0U
141#define BDEV_STATE_CLEAN 1U
Christopher Ferris38062f92014-07-09 15:33:25 -0700142#define BDEV_STATE_DIRTY 2U
143#define BDEV_STATE_STALE 3U
144#define JSET_MAGIC 0x245235c1a3625032ULL
145#define PSET_MAGIC 0x6750e15f87337f91ULL
Christopher Ferris38062f92014-07-09 15:33:25 -0700146#define BSET_MAGIC 0x90135c78b99e07f5ULL
147#define BCACHE_JSET_VERSION_UUIDv1 1
148#define BCACHE_JSET_VERSION_UUID 1
149#define BCACHE_JSET_VERSION 1
Christopher Ferris38062f92014-07-09 15:33:25 -0700150struct jset {
Tao Baod7db5942015-01-28 10:07:51 -0800151 __u64 csum;
152 __u64 magic;
153 __u64 seq;
Tao Baod7db5942015-01-28 10:07:51 -0800154 __u32 version;
155 __u32 keys;
156 __u64 last_seq;
157 BKEY_PADDED(uuid_bucket);
Tao Baod7db5942015-01-28 10:07:51 -0800158 BKEY_PADDED(btree_root);
159 __u16 btree_level;
160 __u16 pad[3];
161 __u64 prio_bucket[MAX_CACHES_PER_SET];
Tao Baod7db5942015-01-28 10:07:51 -0800162 union {
163 struct bkey start[0];
164 __u64 d[0];
165 };
Christopher Ferris38062f92014-07-09 15:33:25 -0700166};
167struct prio_set {
Tao Baod7db5942015-01-28 10:07:51 -0800168 __u64 csum;
169 __u64 magic;
Tao Baod7db5942015-01-28 10:07:51 -0800170 __u64 seq;
171 __u32 version;
172 __u32 pad;
173 __u64 next_bucket;
Tao Baod7db5942015-01-28 10:07:51 -0800174 struct bucket_disk {
175 __u16 prio;
176 __u8 gen;
177 } __attribute((packed)) data[];
Christopher Ferris38062f92014-07-09 15:33:25 -0700178};
179struct uuid_entry {
Tao Baod7db5942015-01-28 10:07:51 -0800180 union {
181 struct {
Tao Baod7db5942015-01-28 10:07:51 -0800182 __u8 uuid[16];
183 __u8 label[32];
184 __u32 first_reg;
185 __u32 last_reg;
Tao Baod7db5942015-01-28 10:07:51 -0800186 __u32 invalidated;
187 __u32 flags;
188 __u64 sectors;
189 };
Tao Baod7db5942015-01-28 10:07:51 -0800190 __u8 pad[128];
191 };
Christopher Ferris38062f92014-07-09 15:33:25 -0700192};
193#define BCACHE_BSET_CSUM 1
Christopher Ferris38062f92014-07-09 15:33:25 -0700194#define BCACHE_BSET_VERSION 1
195struct bset {
Tao Baod7db5942015-01-28 10:07:51 -0800196 __u64 csum;
197 __u64 magic;
Tao Baod7db5942015-01-28 10:07:51 -0800198 __u64 seq;
199 __u32 version;
200 __u32 keys;
201 union {
Tao Baod7db5942015-01-28 10:07:51 -0800202 struct bkey start[0];
203 __u64 d[0];
204 };
Christopher Ferris38062f92014-07-09 15:33:25 -0700205};
Christopher Ferris38062f92014-07-09 15:33:25 -0700206struct uuid_entry_v0 {
Tao Baod7db5942015-01-28 10:07:51 -0800207 __u8 uuid[16];
208 __u8 label[32];
209 __u32 first_reg;
Tao Baod7db5942015-01-28 10:07:51 -0800210 __u32 last_reg;
211 __u32 invalidated;
212 __u32 pad;
Christopher Ferris38062f92014-07-09 15:33:25 -0700213};
Christopher Ferris38062f92014-07-09 15:33:25 -0700214#endif