aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/bcache/bcache.h
diff options
context:
space:
mode:
authorKent Overstreet <koverstreet@google.com>2013-04-11 18:14:35 -0400
committerKent Overstreet <koverstreet@google.com>2013-04-20 20:56:12 -0400
commit2903381fce71004a7ce24d40fad53ba8236a3921 (patch)
treef493d51bdf17b2376e3f79fe0aecc8a7a9e37263 /drivers/md/bcache/bcache.h
parentcef5279735d3f6f0243e626963e6d5c84efade0a (diff)
bcache: Take data offset from the bdev superblock.
Add a new superblock version, and consolidate related defines. Signed-off-by: Gabriel de Perthuis <g2p.code+bcache@gmail.com> Signed-off-by: Kent Overstreet <koverstreet@google.com>
Diffstat (limited to 'drivers/md/bcache/bcache.h')
-rw-r--r--drivers/md/bcache/bcache.h47
1 files changed, 37 insertions, 10 deletions
diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h
index f05723565f17..340146d7c17f 100644
--- a/drivers/md/bcache/bcache.h
+++ b/drivers/md/bcache/bcache.h
@@ -223,11 +223,17 @@ struct bkey {
223#define BKEY_PADDED(key) \ 223#define BKEY_PADDED(key) \
224 union { struct bkey key; uint64_t key ## _pad[BKEY_PAD]; } 224 union { struct bkey key; uint64_t key ## _pad[BKEY_PAD]; }
225 225
226/* Version 1: Backing device 226/* Version 0: Cache device
227 * Version 1: Backing device
227 * Version 2: Seed pointer into btree node checksum 228 * Version 2: Seed pointer into btree node checksum
228 * Version 3: New UUID format 229 * Version 3: Cache device with new UUID format
230 * Version 4: Backing device with data offset
229 */ 231 */
230#define BCACHE_SB_VERSION 3 232#define BCACHE_SB_VERSION_CDEV 0
233#define BCACHE_SB_VERSION_BDEV 1
234#define BCACHE_SB_VERSION_CDEV_WITH_UUID 3
235#define BCACHE_SB_VERSION_BDEV_WITH_OFFSET 4
236#define BCACHE_SB_MAX_VERSION 4
231 237
232#define SB_SECTOR 8 238#define SB_SECTOR 8
233#define SB_SIZE 4096 239#define SB_SIZE 4096
@@ -236,13 +242,12 @@ struct bkey {
236/* SB_JOURNAL_BUCKETS must be divisible by BITS_PER_LONG */ 242/* SB_JOURNAL_BUCKETS must be divisible by BITS_PER_LONG */
237#define MAX_CACHES_PER_SET 8 243#define MAX_CACHES_PER_SET 8
238 244
239#define BDEV_DATA_START 16 /* sectors */ 245#define BDEV_DATA_START_DEFAULT 16 /* sectors */
240 246
241struct cache_sb { 247struct cache_sb {
242 uint64_t csum; 248 uint64_t csum;
243 uint64_t offset; /* sector where this sb was written */ 249 uint64_t offset; /* sector where this sb was written */
244 uint64_t version; 250 uint64_t version;
245#define CACHE_BACKING_DEV 1
246 251
247 uint8_t magic[16]; 252 uint8_t magic[16];
248 253
@@ -257,12 +262,28 @@ struct cache_sb {
257 uint64_t seq; 262 uint64_t seq;
258 uint64_t pad[8]; 263 uint64_t pad[8];
259 264
260 uint64_t nbuckets; /* device size */ 265 union {
261 uint16_t block_size; /* sectors */ 266 struct {
262 uint16_t bucket_size; /* sectors */ 267 /* Cache devices */
268 uint64_t nbuckets; /* device size */
269
270 uint16_t block_size; /* sectors */
271 uint16_t bucket_size; /* sectors */
263 272
264 uint16_t nr_in_set; 273 uint16_t nr_in_set;
265 uint16_t nr_this_dev; 274 uint16_t nr_this_dev;
275 };
276 struct {
277 /* Backing devices */
278 uint64_t data_offset;
279
280 /*
281 * block_size from the cache device section is still used by
282 * backing devices, so don't add anything here until we fix
283 * things to not need it for backing devices anymore
284 */
285 };
286 };
266 287
267 uint32_t last_mount; /* time_t */ 288 uint32_t last_mount; /* time_t */
268 289
@@ -861,6 +882,12 @@ static inline bool key_merging_disabled(struct cache_set *c)
861#endif 882#endif
862} 883}
863 884
885static inline bool SB_IS_BDEV(const struct cache_sb *sb)
886{
887 return sb->version == BCACHE_SB_VERSION_BDEV
888 || sb->version == BCACHE_SB_VERSION_BDEV_WITH_OFFSET;
889}
890
864struct bbio { 891struct bbio {
865 unsigned submit_time_us; 892 unsigned submit_time_us;
866 union { 893 union {