Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 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 |
Christopher Ferris | 525ce91 | 2017-07-26 13:12:53 -0700 | [diff] [blame] | 21 | #include <linux/types.h> |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 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 | } |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 26 | struct bkey { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 27 | __u64 high; |
| 28 | __u64 low; |
| 29 | __u64 ptr[]; |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 30 | }; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 31 | #define KEY_FIELD(name,field,offset,size) BITMASK(name, struct bkey, field, offset, size) |
Christopher Ferris | 9ce2884 | 2018-10-25 12:11:39 -0700 | [diff] [blame] | 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) \ |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 34 | { k->ptr[i] &= ~(~(~0ULL << size) << offset); k->ptr[i] |= (v & ~(~0ULL << size)) << offset; \ |
| 35 | } |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 36 | #define KEY_SIZE_BITS 16 |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 37 | #define KEY_MAX_U64S 8 |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 38 | #define KEY(inode,offset,size) \ |
| 39 | ((struct bkey) {.high = (1ULL << 63) | ((__u64) (size) << 20) | (inode),.low = (offset) \ |
| 40 | }) |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 41 | #define ZERO_KEY KEY(0, 0, 0) |
| 42 | #define MAX_KEY_INODE (~(~0 << 20)) |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 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) |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 47 | #define PTR_DEV_BITS 12 |
| 48 | #define PTR_CHECK_DEV ((1 << PTR_DEV_BITS) - 1) |
Christopher Ferris | 934ec94 | 2018-01-31 15:29:16 -0800 | [diff] [blame] | 49 | #define MAKE_PTR(gen,offset,dev) ((((__u64) dev) << 51) | ((__u64) offset) << 8 | gen) |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 50 | #define bkey_copy(_dest,_src) memcpy(_dest, _src, bkey_bytes(_src)) |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 51 | #define BKEY_PAD 8 |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 52 | #define BKEY_PADDED(key) union { struct bkey key; __u64 key ##_pad[BKEY_PAD]; } |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 53 | #define BCACHE_SB_VERSION_CDEV 0 |
| 54 | #define BCACHE_SB_VERSION_BDEV 1 |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 55 | #define BCACHE_SB_VERSION_CDEV_WITH_UUID 3 |
| 56 | #define BCACHE_SB_VERSION_BDEV_WITH_OFFSET 4 |
Christopher Ferris | 25c18d4 | 2020-10-14 17:42:58 -0700 | [diff] [blame^] | 57 | #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 Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 60 | #define SB_SECTOR 8 |
Christopher Ferris | bb9fcb4 | 2020-04-06 11:38:04 -0700 | [diff] [blame] | 61 | #define SB_OFFSET (SB_SECTOR << SECTOR_SHIFT) |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 62 | #define SB_SIZE 4096 |
| 63 | #define SB_LABEL_SIZE 32 |
| 64 | #define SB_JOURNAL_BUCKETS 256U |
| 65 | #define MAX_CACHES_PER_SET 8 |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 66 | #define BDEV_DATA_START_DEFAULT 16 |
Christopher Ferris | bb9fcb4 | 2020-04-06 11:38:04 -0700 | [diff] [blame] | 67 | struct 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 Ferris | 25c18d4 | 2020-10-14 17:42:58 -0700 | [diff] [blame^] | 80 | __le64 feature_compat; |
| 81 | __le64 feature_incompat; |
| 82 | __le64 feature_ro_compat; |
| 83 | __le64 pad[5]; |
Christopher Ferris | bb9fcb4 | 2020-04-06 11:38:04 -0700 | [diff] [blame] | 84 | 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 Ferris | 25c18d4 | 2020-10-14 17:42:58 -0700 | [diff] [blame^] | 103 | __le16 bucket_size_hi; |
Christopher Ferris | bb9fcb4 | 2020-04-06 11:38:04 -0700 | [diff] [blame] | 104 | }; |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 105 | struct cache_sb { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 106 | __u64 offset; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 107 | __u64 version; |
| 108 | __u8 magic[16]; |
| 109 | __u8 uuid[16]; |
| 110 | union { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 111 | __u8 set_uuid[16]; |
| 112 | __u64 set_magic; |
| 113 | }; |
| 114 | __u8 label[SB_LABEL_SIZE]; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 115 | __u64 flags; |
| 116 | __u64 seq; |
Christopher Ferris | 25c18d4 | 2020-10-14 17:42:58 -0700 | [diff] [blame^] | 117 | __u64 feature_compat; |
| 118 | __u64 feature_incompat; |
| 119 | __u64 feature_ro_compat; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 120 | union { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 121 | struct { |
| 122 | __u64 nbuckets; |
| 123 | __u16 block_size; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 124 | __u16 nr_in_set; |
| 125 | __u16 nr_this_dev; |
Christopher Ferris | 25c18d4 | 2020-10-14 17:42:58 -0700 | [diff] [blame^] | 126 | __u32 bucket_size; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 127 | }; |
| 128 | struct { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 129 | __u64 data_offset; |
| 130 | }; |
| 131 | }; |
| 132 | __u32 last_mount; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 133 | __u16 first_bucket; |
| 134 | union { |
| 135 | __u16 njournal_buckets; |
| 136 | __u16 keys; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 137 | }; |
| 138 | __u64 d[SB_JOURNAL_BUCKETS]; |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 139 | }; |
| 140 | #define CACHE_REPLACEMENT_LRU 0U |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 141 | #define CACHE_REPLACEMENT_FIFO 1U |
| 142 | #define CACHE_REPLACEMENT_RANDOM 2U |
| 143 | #define CACHE_MODE_WRITETHROUGH 0U |
| 144 | #define CACHE_MODE_WRITEBACK 1U |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 145 | #define CACHE_MODE_WRITEAROUND 2U |
| 146 | #define CACHE_MODE_NONE 3U |
| 147 | #define BDEV_STATE_NONE 0U |
| 148 | #define BDEV_STATE_CLEAN 1U |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 149 | #define BDEV_STATE_DIRTY 2U |
| 150 | #define BDEV_STATE_STALE 3U |
| 151 | #define JSET_MAGIC 0x245235c1a3625032ULL |
| 152 | #define PSET_MAGIC 0x6750e15f87337f91ULL |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 153 | #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 Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 157 | struct jset { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 158 | __u64 csum; |
| 159 | __u64 magic; |
| 160 | __u64 seq; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 161 | __u32 version; |
| 162 | __u32 keys; |
| 163 | __u64 last_seq; |
| 164 | BKEY_PADDED(uuid_bucket); |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 165 | BKEY_PADDED(btree_root); |
| 166 | __u16 btree_level; |
| 167 | __u16 pad[3]; |
| 168 | __u64 prio_bucket[MAX_CACHES_PER_SET]; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 169 | union { |
| 170 | struct bkey start[0]; |
| 171 | __u64 d[0]; |
| 172 | }; |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 173 | }; |
| 174 | struct prio_set { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 175 | __u64 csum; |
| 176 | __u64 magic; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 177 | __u64 seq; |
| 178 | __u32 version; |
| 179 | __u32 pad; |
| 180 | __u64 next_bucket; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 181 | struct bucket_disk { |
| 182 | __u16 prio; |
| 183 | __u8 gen; |
| 184 | } __attribute((packed)) data[]; |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 185 | }; |
| 186 | struct uuid_entry { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 187 | union { |
| 188 | struct { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 189 | __u8 uuid[16]; |
| 190 | __u8 label[32]; |
| 191 | __u32 first_reg; |
| 192 | __u32 last_reg; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 193 | __u32 invalidated; |
| 194 | __u32 flags; |
| 195 | __u64 sectors; |
| 196 | }; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 197 | __u8 pad[128]; |
| 198 | }; |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 199 | }; |
| 200 | #define BCACHE_BSET_CSUM 1 |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 201 | #define BCACHE_BSET_VERSION 1 |
| 202 | struct bset { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 203 | __u64 csum; |
| 204 | __u64 magic; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 205 | __u64 seq; |
| 206 | __u32 version; |
| 207 | __u32 keys; |
| 208 | union { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 209 | struct bkey start[0]; |
| 210 | __u64 d[0]; |
| 211 | }; |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 212 | }; |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 213 | struct uuid_entry_v0 { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 214 | __u8 uuid[16]; |
| 215 | __u8 label[32]; |
| 216 | __u32 first_reg; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 217 | __u32 last_reg; |
| 218 | __u32 invalidated; |
| 219 | __u32 pad; |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 220 | }; |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 221 | #endif |