linux/drivers/md/bcache/bcache_ondisk.h

/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#ifndef _LINUX_BCACHE_H
#define _LINUX_BCACHE_H

/*
 * Bcache on disk data structures
 */

#include <linux/types.h>

#define BITMASK(name, type, field, offset, size)

/* Btree keys - all units are in sectors */

struct bkey {};

#define KEY_FIELD(name, field, offset, size)

#define PTR_FIELD(name, offset, size)

#define KEY_SIZE_BITS
#define KEY_MAX_U64S

KEY_FIELD()
KEY_FIELD()
KEY_FIELD()
KEY_FIELD()
KEY_FIELD()

KEY_FIELD()
KEY_FIELD()

/* Next time I change the on disk format, KEY_OFFSET() won't be 64 bits */

static inline __u64 KEY_OFFSET(const struct bkey *k)
{}

static inline void SET_KEY_OFFSET(struct bkey *k, __u64 v)
{}

/*
 * The high bit being set is a relic from when we used it to do binary
 * searches - it told you where a key started. It's not used anymore,
 * and can probably be safely dropped.
 */
#define KEY(inode, offset, size)

#define ZERO_KEY

#define MAX_KEY_INODE
#define MAX_KEY_OFFSET
#define MAX_KEY

#define KEY_START(k)
#define START_KEY(k)

#define PTR_DEV_BITS

PTR_FIELD(PTR_DEV,			51, PTR_DEV_BITS)
PTR_FIELD(PTR_OFFSET,			8,  43)
PTR_FIELD(PTR_GEN,			0,  8)

#define PTR_CHECK_DEV

#define MAKE_PTR(gen, offset, dev)

/* Bkey utility code */

static inline unsigned long bkey_u64s(const struct bkey *k)
{}

static inline unsigned long bkey_bytes(const struct bkey *k)
{}

#define bkey_copy(_dest, _src)

static inline void bkey_copy_key(struct bkey *dest, const struct bkey *src)
{}

static inline struct bkey *bkey_next(const struct bkey *k)
{}

static inline struct bkey *bkey_idx(const struct bkey *k, unsigned int nr_keys)
{}
/* Enough for a key with 6 pointers */
#define BKEY_PAD

#define BKEY_PADDED(key)

/* Superblock */

/* Version 0: Cache device
 * Version 1: Backing device
 * Version 2: Seed pointer into btree node checksum
 * Version 3: Cache device with new UUID format
 * Version 4: Backing device with data offset
 */
#define BCACHE_SB_VERSION_CDEV
#define BCACHE_SB_VERSION_BDEV
#define BCACHE_SB_VERSION_CDEV_WITH_UUID
#define BCACHE_SB_VERSION_BDEV_WITH_OFFSET
#define BCACHE_SB_VERSION_CDEV_WITH_FEATURES
#define BCACHE_SB_VERSION_BDEV_WITH_FEATURES
#define BCACHE_SB_MAX_VERSION

#define SB_SECTOR
#define SB_OFFSET
#define SB_SIZE
#define SB_LABEL_SIZE
#define SB_JOURNAL_BUCKETS
/* SB_JOURNAL_BUCKETS must be divisible by BITS_PER_LONG */
#define MAX_CACHES_PER_SET

#define BDEV_DATA_START_DEFAULT

struct cache_sb_disk {};

/*
 * This is for in-memory bcache super block.
 * NOTE: cache_sb is NOT exactly mapping to cache_sb_disk, the member
 *       size, ordering and even whole struct size may be different
 *       from cache_sb_disk.
 */
struct cache_sb {};

static inline _Bool SB_IS_BDEV(const struct cache_sb *sb)
{}

BITMASK(CACHE_SYNC,			struct cache_sb, flags, 0, 1);
BITMASK(CACHE_DISCARD,			struct cache_sb, flags, 1, 1);
BITMASK(CACHE_REPLACEMENT,		struct cache_sb, flags, 2, 3);
#define CACHE_REPLACEMENT_LRU
#define CACHE_REPLACEMENT_FIFO
#define CACHE_REPLACEMENT_RANDOM

BITMASK(BDEV_CACHE_MODE,		struct cache_sb, flags, 0, 4);
#define CACHE_MODE_WRITETHROUGH
#define CACHE_MODE_WRITEBACK
#define CACHE_MODE_WRITEAROUND
#define CACHE_MODE_NONE
BITMASK(BDEV_STATE,			struct cache_sb, flags, 61, 2);
#define BDEV_STATE_NONE
#define BDEV_STATE_CLEAN
#define BDEV_STATE_DIRTY
#define BDEV_STATE_STALE

/*
 * Magic numbers
 *
 * The various other data structures have their own magic numbers, which are
 * xored with the first part of the cache set's UUID
 */

#define JSET_MAGIC
#define PSET_MAGIC
#define BSET_MAGIC

static inline __u64 jset_magic(struct cache_sb *sb)
{}

static inline __u64 pset_magic(struct cache_sb *sb)
{}

static inline __u64 bset_magic(struct cache_sb *sb)
{}

/*
 * Journal
 *
 * On disk format for a journal entry:
 * seq is monotonically increasing; every journal entry has its own unique
 * sequence number.
 *
 * last_seq is the oldest journal entry that still has keys the btree hasn't
 * flushed to disk yet.
 *
 * version is for on disk format changes.
 */

#define BCACHE_JSET_VERSION_UUIDv1
#define BCACHE_JSET_VERSION_UUID
#define BCACHE_JSET_VERSION

struct jset {};

/* Bucket prios/gens */

struct prio_set {};

/* UUIDS - per backing device/flash only volume metadata */

struct uuid_entry {};

BITMASK(UUID_FLASH_ONLY,	struct uuid_entry, flags, 0, 1);

/* Btree nodes */

/* Version 1: Seed pointer into btree node checksum
 */
#define BCACHE_BSET_CSUM
#define BCACHE_BSET_VERSION

/*
 * Btree nodes
 *
 * On disk a btree node is a list/log of these; within each set the keys are
 * sorted
 */
struct bset {};

/* OBSOLETE */

/* UUIDS - per backing device/flash only volume metadata */

struct uuid_entry_v0 {};

#endif /* _LINUX_BCACHE_H */