diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-11-15 19:33:41 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-11-15 19:33:41 -0500 |
| commit | f412f2c60b480fa5140a4b4cb321cd48c64e1812 (patch) | |
| tree | aafd5a5922b43daca4abdfa9bb723fc1f334108d /include/uapi/linux | |
| parent | cd1177f25069cb494680eedd718e7c6d8fd85d10 (diff) | |
| parent | 1cf7e9c68fe84248174e998922b39e508375e7c1 (diff) | |
Merge branch 'for-linus' of git://git.kernel.dk/linux-block
Pull second round of block driver updates from Jens Axboe:
"As mentioned in the original pull request, the bcache bits were pulled
because of their dependency on the immutable bio vecs. Kent re-did
this part and resubmitted it, so here's the 2nd round of (mostly)
driver updates for 3.13. It contains:
- The bcache work from Kent.
- Conversion of virtio-blk to blk-mq. This removes the bio and request
path, and substitutes with the blk-mq path instead. The end result
almost 200 deleted lines. Patch is acked by Asias and Christoph, who
both did a bunch of testing.
- A removal of bootmem.h include from Grygorii Strashko, part of a
larger series of his killing the dependency on that header file.
- Removal of __cpuinit from blk-mq from Paul Gortmaker"
* 'for-linus' of git://git.kernel.dk/linux-block: (56 commits)
virtio_blk: blk-mq support
blk-mq: remove newly added instances of __cpuinit
bcache: defensively handle format strings
bcache: Bypass torture test
bcache: Delete some slower inline asm
bcache: Use ida for bcache block dev minor
bcache: Fix sysfs splat on shutdown with flash only devs
bcache: Better full stripe scanning
bcache: Have btree_split() insert into parent directly
bcache: Move spinlock into struct time_stats
bcache: Kill sequential_merge option
bcache: Kill bch_next_recurse_key()
bcache: Avoid deadlocking in garbage collection
bcache: Incremental gc
bcache: Add make_btree_freeing_key()
bcache: Add btree_node_write_sync()
bcache: PRECEDING_KEY()
bcache: bch_(btree|extent)_ptr_invalid()
bcache: Don't bother with bucket refcount for btree node allocations
bcache: Debug code improvements
...
Diffstat (limited to 'include/uapi/linux')
| -rw-r--r-- | include/uapi/linux/bcache.h | 373 |
1 files changed, 373 insertions, 0 deletions
diff --git a/include/uapi/linux/bcache.h b/include/uapi/linux/bcache.h new file mode 100644 index 000000000000..164a7e263988 --- /dev/null +++ b/include/uapi/linux/bcache.h | |||
| @@ -0,0 +1,373 @@ | |||
| 1 | #ifndef _LINUX_BCACHE_H | ||
| 2 | #define _LINUX_BCACHE_H | ||
| 3 | |||
| 4 | /* | ||
| 5 | * Bcache on disk data structures | ||
| 6 | */ | ||
| 7 | |||
| 8 | #include <asm/types.h> | ||
| 9 | |||
| 10 | #define BITMASK(name, type, field, offset, size) \ | ||
| 11 | static inline __u64 name(const type *k) \ | ||
| 12 | { return (k->field >> offset) & ~(~0ULL << size); } \ | ||
| 13 | \ | ||
| 14 | static inline void SET_##name(type *k, __u64 v) \ | ||
| 15 | { \ | ||
| 16 | k->field &= ~(~(~0ULL << size) << offset); \ | ||
| 17 | k->field |= (v & ~(~0ULL << size)) << offset; \ | ||
| 18 | } | ||
| 19 | |||
| 20 | /* Btree keys - all units are in sectors */ | ||
| 21 | |||
| 22 | struct bkey { | ||
| 23 | __u64 high; | ||
| 24 | __u64 low; | ||
| 25 | __u64 ptr[]; | ||
| 26 | }; | ||
| 27 | |||
| 28 | #define KEY_FIELD(name, field, offset, size) \ | ||
| 29 | BITMASK(name, struct bkey, field, offset, size) | ||
| 30 | |||
| 31 | #define PTR_FIELD(name, offset, size) \ | ||
| 32 | static inline __u64 name(const struct bkey *k, unsigned i) \ | ||
| 33 | { return (k->ptr[i] >> offset) & ~(~0ULL << size); } \ | ||
| 34 | \ | ||
| 35 | static inline void SET_##name(struct bkey *k, unsigned i, __u64 v) \ | ||
| 36 | { \ | ||
| 37 | k->ptr[i] &= ~(~(~0ULL << size) << offset); \ | ||
| 38 | k->ptr[i] |= (v & ~(~0ULL << size)) << offset; \ | ||
| 39 | } | ||
| 40 | |||
| 41 | #define KEY_SIZE_BITS 16 | ||
| 42 | |||
| 43 | KEY_FIELD(KEY_PTRS, high, 60, 3) | ||
| 44 | KEY_FIELD(HEADER_SIZE, high, 58, 2) | ||
| 45 | KEY_FIELD(KEY_CSUM, high, 56, 2) | ||
| 46 | KEY_FIELD(KEY_PINNED, high, 55, 1) | ||
| 47 | KEY_FIELD(KEY_DIRTY, high, 36, 1) | ||
| 48 | |||
| 49 | KEY_FIELD(KEY_SIZE, high, 20, KEY_SIZE_BITS) | ||
| 50 | KEY_FIELD(KEY_INODE, high, 0, 20) | ||
| 51 | |||
| 52 | /* Next time I change the on disk format, KEY_OFFSET() won't be 64 bits */ | ||
| 53 | |||
| 54 | static inline __u64 KEY_OFFSET(const struct bkey *k) | ||
| 55 | { | ||
| 56 | return k->low; | ||
| 57 | } | ||
| 58 | |||
| 59 | static inline void SET_KEY_OFFSET(struct bkey *k, __u64 v) | ||
| 60 | { | ||
| 61 | k->low = v; | ||
| 62 | } | ||
| 63 | |||
| 64 | /* | ||
| 65 | * The high bit being set is a relic from when we used it to do binary | ||
| 66 | * searches - it told you where a key started. It's not used anymore, | ||
| 67 | * and can probably be safely dropped. | ||
| 68 | */ | ||
| 69 | #define KEY(inode, offset, size) \ | ||
| 70 | ((struct bkey) { \ | ||
| 71 | .high = (1ULL << 63) | ((__u64) (size) << 20) | (inode), \ | ||
| 72 | .low = (offset) \ | ||
| 73 | }) | ||
| 74 | |||
| 75 | #define ZERO_KEY KEY(0, 0, 0) | ||
| 76 | |||
| 77 | #define MAX_KEY_INODE (~(~0 << 20)) | ||
| 78 | #define MAX_KEY_OFFSET (~0ULL >> 1) | ||
| 79 | #define MAX_KEY KEY(MAX_KEY_INODE, MAX_KEY_OFFSET, 0) | ||
| 80 | |||
| 81 | #define KEY_START(k) (KEY_OFFSET(k) - KEY_SIZE(k)) | ||
| 82 | #define START_KEY(k) KEY(KEY_INODE(k), KEY_START(k), 0) | ||
| 83 | |||
| 84 | #define PTR_DEV_BITS 12 | ||
| 85 | |||
| 86 | PTR_FIELD(PTR_DEV, 51, PTR_DEV_BITS) | ||
| 87 | PTR_FIELD(PTR_OFFSET, 8, 43) | ||
| 88 | PTR_FIELD(PTR_GEN, 0, 8) | ||
| 89 | |||
| 90 | #define PTR_CHECK_DEV ((1 << PTR_DEV_BITS) - 1) | ||
| 91 | |||
| 92 | #define PTR(gen, offset, dev) \ | ||
| 93 | ((((__u64) dev) << 51) | ((__u64) offset) << 8 | gen) | ||
| 94 | |||
| 95 | /* Bkey utility code */ | ||
| 96 | |||
| 97 | static inline unsigned long bkey_u64s(const struct bkey *k) | ||
| 98 | { | ||
| 99 | return (sizeof(struct bkey) / sizeof(__u64)) + KEY_PTRS(k); | ||
| 100 | } | ||
| 101 | |||
| 102 | static inline unsigned long bkey_bytes(const struct bkey *k) | ||
| 103 | { | ||
| 104 | return bkey_u64s(k) * sizeof(__u64); | ||
| 105 | } | ||
| 106 | |||
| 107 | #define bkey_copy(_dest, _src) memcpy(_dest, _src, bkey_bytes(_src)) | ||
| 108 | |||
| 109 | static inline void bkey_copy_key(struct bkey *dest, const struct bkey *src) | ||
| 110 | { | ||
| 111 | SET_KEY_INODE(dest, KEY_INODE(src)); | ||
| 112 | SET_KEY_OFFSET(dest, KEY_OFFSET(src)); | ||
| 113 | } | ||
| 114 | |||
| 115 | static inline struct bkey *bkey_next(const struct bkey *k) | ||
| 116 | { | ||
| 117 | __u64 *d = (void *) k; | ||
| 118 | return (struct bkey *) (d + bkey_u64s(k)); | ||
| 119 | } | ||
| 120 | |||
| 121 | static inline struct bkey *bkey_last(const struct bkey *k, unsigned nr_keys) | ||
| 122 | { | ||
| 123 | __u64 *d = (void *) k; | ||
| 124 | return (struct bkey *) (d + nr_keys); | ||
| 125 | } | ||
| 126 | /* Enough for a key with 6 pointers */ | ||
| 127 | #define BKEY_PAD 8 | ||
| 128 | |||
| 129 | #define BKEY_PADDED(key) \ | ||
| 130 | union { struct bkey key; __u64 key ## _pad[BKEY_PAD]; } | ||
| 131 | |||
| 132 | /* Superblock */ | ||
| 133 | |||
| 134 | /* Version 0: Cache device | ||
| 135 | * Version 1: Backing device | ||
| 136 | * Version 2: Seed pointer into btree node checksum | ||
| 137 | * Version 3: Cache device with new UUID format | ||
| 138 | * Version 4: Backing device with data offset | ||
| 139 | */ | ||
| 140 | #define BCACHE_SB_VERSION_CDEV 0 | ||
| 141 | #define BCACHE_SB_VERSION_BDEV 1 | ||
| 142 | #define BCACHE_SB_VERSION_CDEV_WITH_UUID 3 | ||
| 143 | #define BCACHE_SB_VERSION_BDEV_WITH_OFFSET 4 | ||
| 144 | #define BCACHE_SB_MAX_VERSION 4 | ||
| 145 | |||
| 146 | #define SB_SECTOR 8 | ||
| 147 | #define SB_SIZE 4096 | ||
| 148 | #define SB_LABEL_SIZE 32 | ||
| 149 | #define SB_JOURNAL_BUCKETS 256U | ||
| 150 | /* SB_JOURNAL_BUCKETS must be divisible by BITS_PER_LONG */ | ||
| 151 | #define MAX_CACHES_PER_SET 8 | ||
| 152 | |||
| 153 | #define BDEV_DATA_START_DEFAULT 16 /* sectors */ | ||
| 154 | |||
| 155 | struct cache_sb { | ||
| 156 | __u64 csum; | ||
| 157 | __u64 offset; /* sector where this sb was written */ | ||
| 158 | __u64 version; | ||
| 159 | |||
| 160 | __u8 magic[16]; | ||
| 161 | |||
| 162 | __u8 uuid[16]; | ||
| 163 | union { | ||
| 164 | __u8 set_uuid[16]; | ||
| 165 | __u64 set_magic; | ||
| 166 | }; | ||
| 167 | __u8 label[SB_LABEL_SIZE]; | ||
| 168 | |||
| 169 | __u64 flags; | ||
| 170 | __u64 seq; | ||
| 171 | __u64 pad[8]; | ||
| 172 | |||
| 173 | union { | ||
| 174 | struct { | ||
| 175 | /* Cache devices */ | ||
| 176 | __u64 nbuckets; /* device size */ | ||
| 177 | |||
| 178 | __u16 block_size; /* sectors */ | ||
| 179 | __u16 bucket_size; /* sectors */ | ||
| 180 | |||
| 181 | __u16 nr_in_set; | ||
| 182 | __u16 nr_this_dev; | ||
| 183 | }; | ||
| 184 | struct { | ||
| 185 | /* Backing devices */ | ||
| 186 | __u64 data_offset; | ||
| 187 | |||
| 188 | |||
