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_OFFSET (SB_SECTOR << SECTOR_SHIFT) 60 #define SB_SIZE 4096 61 #define SB_LABEL_SIZE 32 62 #define SB_JOURNAL_BUCKETS 256U 63 #define MAX_CACHES_PER_SET 8 64 #define BDEV_DATA_START_DEFAULT 16 65 struct 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 }; 99 struct cache_sb { 100 __u64 csum; 101 __u64 offset; 102 __u64 version; 103 __u8 magic[16]; 104 __u8 uuid[16]; 105 union { 106 __u8 set_uuid[16]; 107 __u64 set_magic; 108 }; 109 __u8 label[SB_LABEL_SIZE]; 110 __u64 flags; 111 __u64 seq; 112 __u64 pad[8]; 113 union { 114 struct { 115 __u64 nbuckets; 116 __u16 block_size; 117 __u16 bucket_size; 118 __u16 nr_in_set; 119 __u16 nr_this_dev; 120 }; 121 struct { 122 __u64 data_offset; 123 }; 124 }; 125 __u32 last_mount; 126 __u16 first_bucket; 127 union { 128 __u16 njournal_buckets; 129 __u16 keys; 130 }; 131 __u64 d[SB_JOURNAL_BUCKETS]; 132 }; 133 #define CACHE_REPLACEMENT_LRU 0U 134 #define CACHE_REPLACEMENT_FIFO 1U 135 #define CACHE_REPLACEMENT_RANDOM 2U 136 #define CACHE_MODE_WRITETHROUGH 0U 137 #define CACHE_MODE_WRITEBACK 1U 138 #define CACHE_MODE_WRITEAROUND 2U 139 #define CACHE_MODE_NONE 3U 140 #define BDEV_STATE_NONE 0U 141 #define BDEV_STATE_CLEAN 1U 142 #define BDEV_STATE_DIRTY 2U 143 #define BDEV_STATE_STALE 3U 144 #define JSET_MAGIC 0x245235c1a3625032ULL 145 #define PSET_MAGIC 0x6750e15f87337f91ULL 146 #define BSET_MAGIC 0x90135c78b99e07f5ULL 147 #define BCACHE_JSET_VERSION_UUIDv1 1 148 #define BCACHE_JSET_VERSION_UUID 1 149 #define BCACHE_JSET_VERSION 1 150 struct jset { 151 __u64 csum; 152 __u64 magic; 153 __u64 seq; 154 __u32 version; 155 __u32 keys; 156 __u64 last_seq; 157 BKEY_PADDED(uuid_bucket); 158 BKEY_PADDED(btree_root); 159 __u16 btree_level; 160 __u16 pad[3]; 161 __u64 prio_bucket[MAX_CACHES_PER_SET]; 162 union { 163 struct bkey start[0]; 164 __u64 d[0]; 165 }; 166 }; 167 struct prio_set { 168 __u64 csum; 169 __u64 magic; 170 __u64 seq; 171 __u32 version; 172 __u32 pad; 173 __u64 next_bucket; 174 struct bucket_disk { 175 __u16 prio; 176 __u8 gen; 177 } __attribute((packed)) data[]; 178 }; 179 struct uuid_entry { 180 union { 181 struct { 182 __u8 uuid[16]; 183 __u8 label[32]; 184 __u32 first_reg; 185 __u32 last_reg; 186 __u32 invalidated; 187 __u32 flags; 188 __u64 sectors; 189 }; 190 __u8 pad[128]; 191 }; 192 }; 193 #define BCACHE_BSET_CSUM 1 194 #define BCACHE_BSET_VERSION 1 195 struct bset { 196 __u64 csum; 197 __u64 magic; 198 __u64 seq; 199 __u32 version; 200 __u32 keys; 201 union { 202 struct bkey start[0]; 203 __u64 d[0]; 204 }; 205 }; 206 struct uuid_entry_v0 { 207 __u8 uuid[16]; 208 __u8 label[32]; 209 __u32 first_reg; 210 __u32 last_reg; 211 __u32 invalidated; 212 __u32 pad; 213 }; 214 #endif 215