• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /****************************************************************************
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
21 #include <linux/types.h>
22 #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 }
26 struct bkey {
27   __u64 high;
28   __u64 low;
29   __u64 ptr[];
30 };
31 #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 int i) \
33 { return(k->ptr[i] >> offset) & ~(~0ULL << size); } static inline void SET_ ##name(struct bkey * k, unsigned int i, __u64 v) \
34 { k->ptr[i] &= ~(~(~0ULL << size) << offset); k->ptr[i] |= (v & ~(~0ULL << size)) << offset; \
35 }
36 #define KEY_SIZE_BITS 16
37 #define KEY_MAX_U64S 8
38 #define KEY(inode,offset,size) \
39 ((struct bkey) {.high = (1ULL << 63) | ((__u64) (size) << 20) | (inode),.low = (offset) \
40 })
41 #define ZERO_KEY KEY(0, 0, 0)
42 #define MAX_KEY_INODE (~(~0 << 20))
43 #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)
47 #define PTR_DEV_BITS 12
48 #define PTR_CHECK_DEV ((1 << PTR_DEV_BITS) - 1)
49 #define MAKE_PTR(gen,offset,dev) ((((__u64) dev) << 51) | ((__u64) offset) << 8 | gen)
50 #define bkey_copy(_dest,_src) memcpy(_dest, _src, bkey_bytes(_src))
51 #define BKEY_PAD 8
52 #define BKEY_PADDED(key) union { struct bkey key; __u64 key ##_pad[BKEY_PAD]; }
53 #define BCACHE_SB_VERSION_CDEV 0
54 #define BCACHE_SB_VERSION_BDEV 1
55 #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
59 #define SB_SIZE 4096
60 #define SB_LABEL_SIZE 32
61 #define SB_JOURNAL_BUCKETS 256U
62 #define MAX_CACHES_PER_SET 8
63 #define BDEV_DATA_START_DEFAULT 16
64 struct cache_sb {
65   __u64 csum;
66   __u64 offset;
67   __u64 version;
68   __u8 magic[16];
69   __u8 uuid[16];
70   union {
71     __u8 set_uuid[16];
72     __u64 set_magic;
73   };
74   __u8 label[SB_LABEL_SIZE];
75   __u64 flags;
76   __u64 seq;
77   __u64 pad[8];
78   union {
79     struct {
80       __u64 nbuckets;
81       __u16 block_size;
82       __u16 bucket_size;
83       __u16 nr_in_set;
84       __u16 nr_this_dev;
85     };
86     struct {
87       __u64 data_offset;
88     };
89   };
90   __u32 last_mount;
91   __u16 first_bucket;
92   union {
93     __u16 njournal_buckets;
94     __u16 keys;
95   };
96   __u64 d[SB_JOURNAL_BUCKETS];
97 };
98 #define CACHE_REPLACEMENT_LRU 0U
99 #define CACHE_REPLACEMENT_FIFO 1U
100 #define CACHE_REPLACEMENT_RANDOM 2U
101 #define CACHE_MODE_WRITETHROUGH 0U
102 #define CACHE_MODE_WRITEBACK 1U
103 #define CACHE_MODE_WRITEAROUND 2U
104 #define CACHE_MODE_NONE 3U
105 #define BDEV_STATE_NONE 0U
106 #define BDEV_STATE_CLEAN 1U
107 #define BDEV_STATE_DIRTY 2U
108 #define BDEV_STATE_STALE 3U
109 #define JSET_MAGIC 0x245235c1a3625032ULL
110 #define PSET_MAGIC 0x6750e15f87337f91ULL
111 #define BSET_MAGIC 0x90135c78b99e07f5ULL
112 #define BCACHE_JSET_VERSION_UUIDv1 1
113 #define BCACHE_JSET_VERSION_UUID 1
114 #define BCACHE_JSET_VERSION 1
115 struct jset {
116   __u64 csum;
117   __u64 magic;
118   __u64 seq;
119   __u32 version;
120   __u32 keys;
121   __u64 last_seq;
122   BKEY_PADDED(uuid_bucket);
123   BKEY_PADDED(btree_root);
124   __u16 btree_level;
125   __u16 pad[3];
126   __u64 prio_bucket[MAX_CACHES_PER_SET];
127   union {
128     struct bkey start[0];
129     __u64 d[0];
130   };
131 };
132 struct prio_set {
133   __u64 csum;
134   __u64 magic;
135   __u64 seq;
136   __u32 version;
137   __u32 pad;
138   __u64 next_bucket;
139   struct bucket_disk {
140     __u16 prio;
141     __u8 gen;
142   } __attribute((packed)) data[];
143 };
144 struct uuid_entry {
145   union {
146     struct {
147       __u8 uuid[16];
148       __u8 label[32];
149       __u32 first_reg;
150       __u32 last_reg;
151       __u32 invalidated;
152       __u32 flags;
153       __u64 sectors;
154     };
155     __u8 pad[128];
156   };
157 };
158 #define BCACHE_BSET_CSUM 1
159 #define BCACHE_BSET_VERSION 1
160 struct bset {
161   __u64 csum;
162   __u64 magic;
163   __u64 seq;
164   __u32 version;
165   __u32 keys;
166   union {
167     struct bkey start[0];
168     __u64 d[0];
169   };
170 };
171 struct uuid_entry_v0 {
172   __u8 uuid[16];
173   __u8 label[32];
174   __u32 first_reg;
175   __u32 last_reg;
176   __u32 invalidated;
177   __u32 pad;
178 };
179 #endif
180