blob: 0933d518125cbefa2984579abda825754843997a [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)
32#define PTR_FIELD(name,offset,size) static inline __u64 name(const struct bkey * k, unsigned i) \
33{ return(k->ptr[i] >> offset) & ~(~0ULL << size); } static inline void SET_ ##name(struct bkey * k, unsigned i, __u64 v) \
34{ 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)
Tao Baod7db5942015-01-28 10:07:51 -080049#define PTR(gen,offset,dev) ((((__u64) dev) << 51) | ((__u64) offset) << 8 | gen)
50#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 Ferris38062f92014-07-09 15:33:25 -070059#define SB_SIZE 4096
60#define SB_LABEL_SIZE 32
61#define SB_JOURNAL_BUCKETS 256U
62#define MAX_CACHES_PER_SET 8
Christopher Ferris38062f92014-07-09 15:33:25 -070063#define BDEV_DATA_START_DEFAULT 16
64struct cache_sb {
Tao Baod7db5942015-01-28 10:07:51 -080065 __u64 csum;
66 __u64 offset;
Tao Baod7db5942015-01-28 10:07:51 -080067 __u64 version;
68 __u8 magic[16];
69 __u8 uuid[16];
70 union {
Tao Baod7db5942015-01-28 10:07:51 -080071 __u8 set_uuid[16];
72 __u64 set_magic;
73 };
74 __u8 label[SB_LABEL_SIZE];
Tao Baod7db5942015-01-28 10:07:51 -080075 __u64 flags;
76 __u64 seq;
77 __u64 pad[8];
78 union {
Tao Baod7db5942015-01-28 10:07:51 -080079 struct {
80 __u64 nbuckets;
81 __u16 block_size;
82 __u16 bucket_size;
Tao Baod7db5942015-01-28 10:07:51 -080083 __u16 nr_in_set;
84 __u16 nr_this_dev;
85 };
86 struct {
Tao Baod7db5942015-01-28 10:07:51 -080087 __u64 data_offset;
88 };
89 };
90 __u32 last_mount;
Tao Baod7db5942015-01-28 10:07:51 -080091 __u16 first_bucket;
92 union {
93 __u16 njournal_buckets;
94 __u16 keys;
Tao Baod7db5942015-01-28 10:07:51 -080095 };
96 __u64 d[SB_JOURNAL_BUCKETS];
Christopher Ferris38062f92014-07-09 15:33:25 -070097};
98#define CACHE_REPLACEMENT_LRU 0U
Christopher Ferris38062f92014-07-09 15:33:25 -070099#define CACHE_REPLACEMENT_FIFO 1U
100#define CACHE_REPLACEMENT_RANDOM 2U
101#define CACHE_MODE_WRITETHROUGH 0U
102#define CACHE_MODE_WRITEBACK 1U
Christopher Ferris38062f92014-07-09 15:33:25 -0700103#define CACHE_MODE_WRITEAROUND 2U
104#define CACHE_MODE_NONE 3U
105#define BDEV_STATE_NONE 0U
106#define BDEV_STATE_CLEAN 1U
Christopher Ferris38062f92014-07-09 15:33:25 -0700107#define BDEV_STATE_DIRTY 2U
108#define BDEV_STATE_STALE 3U
109#define JSET_MAGIC 0x245235c1a3625032ULL
110#define PSET_MAGIC 0x6750e15f87337f91ULL
Christopher Ferris38062f92014-07-09 15:33:25 -0700111#define BSET_MAGIC 0x90135c78b99e07f5ULL
112#define BCACHE_JSET_VERSION_UUIDv1 1
113#define BCACHE_JSET_VERSION_UUID 1
114#define BCACHE_JSET_VERSION 1
Christopher Ferris38062f92014-07-09 15:33:25 -0700115struct jset {
Tao Baod7db5942015-01-28 10:07:51 -0800116 __u64 csum;
117 __u64 magic;
118 __u64 seq;
Tao Baod7db5942015-01-28 10:07:51 -0800119 __u32 version;
120 __u32 keys;
121 __u64 last_seq;
122 BKEY_PADDED(uuid_bucket);
Tao Baod7db5942015-01-28 10:07:51 -0800123 BKEY_PADDED(btree_root);
124 __u16 btree_level;
125 __u16 pad[3];
126 __u64 prio_bucket[MAX_CACHES_PER_SET];
Tao Baod7db5942015-01-28 10:07:51 -0800127 union {
128 struct bkey start[0];
129 __u64 d[0];
130 };
Christopher Ferris38062f92014-07-09 15:33:25 -0700131};
132struct prio_set {
Tao Baod7db5942015-01-28 10:07:51 -0800133 __u64 csum;
134 __u64 magic;
Tao Baod7db5942015-01-28 10:07:51 -0800135 __u64 seq;
136 __u32 version;
137 __u32 pad;
138 __u64 next_bucket;
Tao Baod7db5942015-01-28 10:07:51 -0800139 struct bucket_disk {
140 __u16 prio;
141 __u8 gen;
142 } __attribute((packed)) data[];
Christopher Ferris38062f92014-07-09 15:33:25 -0700143};
144struct uuid_entry {
Tao Baod7db5942015-01-28 10:07:51 -0800145 union {
146 struct {
Tao Baod7db5942015-01-28 10:07:51 -0800147 __u8 uuid[16];
148 __u8 label[32];
149 __u32 first_reg;
150 __u32 last_reg;
Tao Baod7db5942015-01-28 10:07:51 -0800151 __u32 invalidated;
152 __u32 flags;
153 __u64 sectors;
154 };
Tao Baod7db5942015-01-28 10:07:51 -0800155 __u8 pad[128];
156 };
Christopher Ferris38062f92014-07-09 15:33:25 -0700157};
158#define BCACHE_BSET_CSUM 1
Christopher Ferris38062f92014-07-09 15:33:25 -0700159#define BCACHE_BSET_VERSION 1
160struct bset {
Tao Baod7db5942015-01-28 10:07:51 -0800161 __u64 csum;
162 __u64 magic;
Tao Baod7db5942015-01-28 10:07:51 -0800163 __u64 seq;
164 __u32 version;
165 __u32 keys;
166 union {
Tao Baod7db5942015-01-28 10:07:51 -0800167 struct bkey start[0];
168 __u64 d[0];
169 };
Christopher Ferris38062f92014-07-09 15:33:25 -0700170};
Christopher Ferris38062f92014-07-09 15:33:25 -0700171struct uuid_entry_v0 {
Tao Baod7db5942015-01-28 10:07:51 -0800172 __u8 uuid[16];
173 __u8 label[32];
174 __u32 first_reg;
Tao Baod7db5942015-01-28 10:07:51 -0800175 __u32 last_reg;
176 __u32 invalidated;
177 __u32 pad;
Christopher Ferris38062f92014-07-09 15:33:25 -0700178};
Christopher Ferris38062f92014-07-09 15:33:25 -0700179#endif