#ifndef _BCACHEFS_FORMAT_H
#define _BCACHEFS_FORMAT_H
#include <asm/types.h>
#include <asm/byteorder.h>
#include <linux/kernel.h>
#include <linux/uuid.h>
#include <uapi/linux/magic.h>
#include "vstructs.h"
#ifdef __KERNEL__
__uuid_t;
#endif
#define BITMASK(name, type, field, offset, end) …
#define LE_BITMASK(_bits, name, type, field, offset, end) …
#define LE16_BITMASK(n, t, f, o, e) …
#define LE32_BITMASK(n, t, f, o, e) …
#define LE64_BITMASK(n, t, f, o, e) …
struct bkey_format { … };
struct bpos { … } __packed
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
__aligned(…)
#endif
;
#define KEY_INODE_MAX …
#define KEY_OFFSET_MAX …
#define KEY_SNAPSHOT_MAX …
#define KEY_SIZE_MAX …
static inline struct bpos SPOS(__u64 inode, __u64 offset, __u32 snapshot)
{ … }
#define POS_MIN …
#define POS_MAX …
#define SPOS_MAX …
#define POS(_inode, _offset) …
struct bch_val { … };
struct bversion { … } __packed
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
__aligned(…)
#endif
;
struct bkey { … } __packed
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
__aligned(…)
#endif
;
struct bkey_packed { … } __packed __aligned(…);
bch_le128;
#define BKEY_U64s …
#define BKEY_U64s_MAX …
#define BKEY_VAL_U64s_MAX …
#define KEY_PACKED_BITS_START …
#define KEY_FORMAT_LOCAL_BTREE …
#define KEY_FORMAT_CURRENT …
enum bch_bkey_fields { … };
#define bkey_format_field(name, field) …
#define BKEY_FORMAT_CURRENT …
struct bkey_i { … };
#define POS_KEY(_pos) …
#define KEY(_inode, _offset, _size) …
static inline void bkey_init(struct bkey *k)
{ … }
#define bkey_bytes(_k) …
#define __BKEY_PADDED(key, pad) …
#define BCH_BKEY_TYPES() …
enum bch_bkey_type { … };
struct bch_deleted { … };
struct bch_whiteout { … };
struct bch_error { … };
struct bch_cookie { … };
struct bch_hash_whiteout { … };
struct bch_set { … };
struct bch_csum { … } __packed __aligned(…);
struct bch_backpointer { … } __packed __aligned(…);
struct bch_sb_field { … };
#define BCH_SB_FIELDS() …
#include "alloc_background_format.h"
#include "dirent_format.h"
#include "disk_accounting_format.h"
#include "disk_groups_format.h"
#include "extents_format.h"
#include "ec_format.h"
#include "dirent_format.h"
#include "disk_groups_format.h"
#include "inode_format.h"
#include "journal_seq_blacklist_format.h"
#include "logged_ops_format.h"
#include "lru_format.h"
#include "quota_format.h"
#include "reflink_format.h"
#include "replicas_format.h"
#include "snapshot_format.h"
#include "subvolume_format.h"
#include "sb-counters_format.h"
#include "sb-downgrade_format.h"
#include "sb-errors_format.h"
#include "sb-members_format.h"
#include "xattr_format.h"
enum bch_sb_field_type { … };
#define BCH_SINGLE_DEVICE_SB_FIELDS …
struct bch_sb_field_journal { … };
struct bch_sb_field_journal_v2 { … };
struct nonce { … };
struct bch_key { … };
#define BCH_KEY_MAGIC …
struct bch_encrypted_key { … };
struct bch_sb_field_crypt { … };
LE64_BITMASK(BCH_CRYPT_KDF_TYPE, struct bch_sb_field_crypt, flags, 0, 4);
enum bch_kdf_types { … };
LE64_BITMASK(BCH_KDF_SCRYPT_N, struct bch_sb_field_crypt, kdf_flags, 0, 16);
LE64_BITMASK(BCH_KDF_SCRYPT_R, struct bch_sb_field_crypt, kdf_flags, 16, 32);
LE64_BITMASK(BCH_KDF_SCRYPT_P, struct bch_sb_field_crypt, kdf_flags, 32, 48);
struct jset_entry { … };
struct bch_sb_field_clean { … };
struct bch_sb_field_ext { … };
#define BCH_VERSION_MAJOR(_v) …
#define BCH_VERSION_MINOR(_v) …
#define BCH_VERSION(_major, _minor) …
#define BCH_METADATA_VERSIONS() …
enum bcachefs_metadata_version { … };
static const __maybe_unused
unsigned bcachefs_metadata_required_upgrade_below = …;
#define bcachefs_metadata_version_current …
#define BCH_SB_SECTOR …
#define BCH_SB_LAYOUT_SIZE_BITS_MAX …
struct bch_sb_layout { … } __packed __aligned(…);
#define BCH_SB_LAYOUT_SECTOR …
struct bch_sb { … } __packed __aligned(…);
LE16_BITMASK(BCH_SB_BLOCK_SIZE, struct bch_sb, block_size, 0, 16);
LE64_BITMASK(BCH_SB_INITIALIZED, struct bch_sb, flags[0], 0, 1);
LE64_BITMASK(BCH_SB_CLEAN, struct bch_sb, flags[0], 1, 2);
LE64_BITMASK(BCH_SB_CSUM_TYPE, struct bch_sb, flags[0], 2, 8);
LE64_BITMASK(BCH_SB_ERROR_ACTION, struct bch_sb, flags[0], 8, 12);
LE64_BITMASK(BCH_SB_BTREE_NODE_SIZE, struct bch_sb, flags[0], 12, 28);
LE64_BITMASK(BCH_SB_GC_RESERVE, struct bch_sb, flags[0], 28, 33);
LE64_BITMASK(BCH_SB_ROOT_RESERVE, struct bch_sb, flags[0], 33, 40);
LE64_BITMASK(BCH_SB_META_CSUM_TYPE, struct bch_sb, flags[0], 40, 44);
LE64_BITMASK(BCH_SB_DATA_CSUM_TYPE, struct bch_sb, flags[0], 44, 48);
LE64_BITMASK(BCH_SB_META_REPLICAS_WANT, struct bch_sb, flags[0], 48, 52);
LE64_BITMASK(BCH_SB_DATA_REPLICAS_WANT, struct bch_sb, flags[0], 52, 56);
LE64_BITMASK(BCH_SB_POSIX_ACL, struct bch_sb, flags[0], 56, 57);
LE64_BITMASK(BCH_SB_USRQUOTA, struct bch_sb, flags[0], 57, 58);
LE64_BITMASK(BCH_SB_GRPQUOTA, struct bch_sb, flags[0], 58, 59);
LE64_BITMASK(BCH_SB_PRJQUOTA, struct bch_sb, flags[0], 59, 60);
LE64_BITMASK(BCH_SB_HAS_ERRORS, struct bch_sb, flags[0], 60, 61);
LE64_BITMASK(BCH_SB_HAS_TOPOLOGY_ERRORS,struct bch_sb, flags[0], 61, 62);
LE64_BITMASK(BCH_SB_BIG_ENDIAN, struct bch_sb, flags[0], 62, 63);
LE64_BITMASK(BCH_SB_STR_HASH_TYPE, struct bch_sb, flags[1], 0, 4);
LE64_BITMASK(BCH_SB_COMPRESSION_TYPE_LO,struct bch_sb, flags[1], 4, 8);
LE64_BITMASK(BCH_SB_INODE_32BIT, struct bch_sb, flags[1], 8, 9);
LE64_BITMASK(BCH_SB_128_BIT_MACS, struct bch_sb, flags[1], 9, 10);
LE64_BITMASK(BCH_SB_ENCRYPTION_TYPE, struct bch_sb, flags[1], 10, 14);
LE64_BITMASK(BCH_SB_ENCODED_EXTENT_MAX_BITS,
struct bch_sb, flags[1], 14, 20);
LE64_BITMASK(BCH_SB_META_REPLICAS_REQ, struct bch_sb, flags[1], 20, 24);
LE64_BITMASK(BCH_SB_DATA_REPLICAS_REQ, struct bch_sb, flags[1], 24, 28);
LE64_BITMASK(BCH_SB_PROMOTE_TARGET, struct bch_sb, flags[1], 28, 40);
LE64_BITMASK(BCH_SB_FOREGROUND_TARGET, struct bch_sb, flags[1], 40, 52);
LE64_BITMASK(BCH_SB_BACKGROUND_TARGET, struct bch_sb, flags[1], 52, 64);
LE64_BITMASK(BCH_SB_BACKGROUND_COMPRESSION_TYPE_LO,
struct bch_sb, flags[2], 0, 4);
LE64_BITMASK(BCH_SB_GC_RESERVE_BYTES, struct bch_sb, flags[2], 4, 64);
LE64_BITMASK(BCH_SB_ERASURE_CODE, struct bch_sb, flags[3], 0, 16);
LE64_BITMASK(BCH_SB_METADATA_TARGET, struct bch_sb, flags[3], 16, 28);
LE64_BITMASK(BCH_SB_SHARD_INUMS, struct bch_sb, flags[3], 28, 29);
LE64_BITMASK(BCH_SB_INODES_USE_KEY_CACHE,struct bch_sb, flags[3], 29, 30);
LE64_BITMASK(BCH_SB_JOURNAL_FLUSH_DELAY,struct bch_sb, flags[3], 30, 62);
LE64_BITMASK(BCH_SB_JOURNAL_FLUSH_DISABLED,struct bch_sb, flags[3], 62, 63);
LE64_BITMASK(BCH_SB_JOURNAL_RECLAIM_DELAY,struct bch_sb, flags[4], 0, 32);
LE64_BITMASK(BCH_SB_JOURNAL_TRANSACTION_NAMES,struct bch_sb, flags[4], 32, 33);
LE64_BITMASK(BCH_SB_NOCOW, struct bch_sb, flags[4], 33, 34);
LE64_BITMASK(BCH_SB_WRITE_BUFFER_SIZE, struct bch_sb, flags[4], 34, 54);
LE64_BITMASK(BCH_SB_VERSION_UPGRADE, struct bch_sb, flags[4], 54, 56);
LE64_BITMASK(BCH_SB_COMPRESSION_TYPE_HI,struct bch_sb, flags[4], 56, 60);
LE64_BITMASK(BCH_SB_BACKGROUND_COMPRESSION_TYPE_HI,
struct bch_sb, flags[4], 60, 64);
LE64_BITMASK(BCH_SB_VERSION_UPGRADE_COMPLETE,
struct bch_sb, flags[5], 0, 16);
LE64_BITMASK(BCH_SB_ALLOCATOR_STUCK_TIMEOUT,
struct bch_sb, flags[5], 16, 32);
static inline __u64 BCH_SB_COMPRESSION_TYPE(const struct bch_sb *sb)
{ … }
static inline void SET_BCH_SB_COMPRESSION_TYPE(struct bch_sb *sb, __u64 v)
{ … }
static inline __u64 BCH_SB_BACKGROUND_COMPRESSION_TYPE(const struct bch_sb *sb)
{ … }
static inline void SET_BCH_SB_BACKGROUND_COMPRESSION_TYPE(struct bch_sb *sb, __u64 v)
{ … }
#define BCH_SB_FEATURES() …
#define BCH_SB_FEATURES_ALWAYS …
#define BCH_SB_FEATURES_ALL …
enum bch_sb_feature { … };
#define BCH_SB_COMPAT() …
enum bch_sb_compat { … };
#define BCH_VERSION_UPGRADE_OPTS() …
enum bch_version_upgrade_opts { … };
#define BCH_REPLICAS_MAX …
#define BCH_BKEY_PTRS_MAX …
#define BCH_ERROR_ACTIONS() …
enum bch_error_actions { … };
#define BCH_STR_HASH_TYPES() …
enum bch_str_hash_type { … };
#define BCH_STR_HASH_OPTS() …
enum bch_str_hash_opts { … };
#define BCH_CSUM_TYPES() …
enum bch_csum_type { … };
static const __maybe_unused unsigned bch_crc_bytes[] = …;
static inline _Bool bch2_csum_type_is_encryption(enum bch_csum_type type)
{ … }
#define BCH_CSUM_OPTS() …
enum bch_csum_opts { … };
#define BCH_COMPRESSION_TYPES() …
enum bch_compression_type { … };
#define BCH_COMPRESSION_OPTS() …
enum bch_compression_opts { … };
#define BCACHE_MAGIC …
#define BCHFS_MAGIC …
#define BCACHEFS_STATFS_MAGIC …
#define JSET_MAGIC …
#define BSET_MAGIC …
static inline __le64 __bch2_sb_magic(struct bch_sb *sb)
{ … }
static inline __u64 __jset_magic(struct bch_sb *sb)
{ … }
static inline __u64 __bset_magic(struct bch_sb *sb)
{ … }
#define JSET_KEYS_U64s …
#define BCH_JSET_ENTRY_TYPES() …
enum bch_jset_entry_type { … };
static inline bool jset_entry_is_key(struct jset_entry *e)
{ … }
struct jset_entry_blacklist { … };
struct jset_entry_blacklist_v2 { … };
#define BCH_FS_USAGE_TYPES() …
enum bch_fs_usage_type { … };
struct jset_entry_usage { … } __packed;
struct jset_entry_data_usage { … } __packed;
struct jset_entry_clock { … } __packed;
struct jset_entry_dev_usage_type { … } __packed;
struct jset_entry_dev_usage { … };
static inline unsigned jset_entry_dev_usage_nr_types(struct jset_entry_dev_usage *u)
{ … }
struct jset_entry_log { … } __packed __aligned(…);
struct jset_entry_datetime { … } __packed __aligned(…);
struct jset { … } __packed __aligned(…);
LE32_BITMASK(JSET_CSUM_TYPE, struct jset, flags, 0, 4);
LE32_BITMASK(JSET_BIG_ENDIAN, struct jset, flags, 4, 5);
LE32_BITMASK(JSET_NO_FLUSH, struct jset, flags, 5, 6);
#define BCH_JOURNAL_BUCKETS_MIN …
enum btree_id_flags { … };
#define BCH_BTREE_IDS() … \
enum btree_id { … };
#define BTREE_ID_NR_MAX …
static inline bool btree_id_is_alloc(enum btree_id id)
{ … }
#define BTREE_MAX_DEPTH …
struct bset { … } __packed __aligned(…);
LE32_BITMASK(BSET_CSUM_TYPE, struct bset, flags, 0, 4);
LE32_BITMASK(BSET_BIG_ENDIAN, struct bset, flags, 4, 5);
LE32_BITMASK(BSET_SEPARATE_WHITEOUTS,
struct bset, flags, 5, 6);
LE32_BITMASK(BSET_OFFSET, struct bset, flags, 16, 32);
struct btree_node { … } __packed __aligned(…);
LE64_BITMASK(BTREE_NODE_ID_LO, struct btree_node, flags, 0, 4);
LE64_BITMASK(BTREE_NODE_LEVEL, struct btree_node, flags, 4, 8);
LE64_BITMASK(BTREE_NODE_NEW_EXTENT_OVERWRITE,
struct btree_node, flags, 8, 9);
LE64_BITMASK(BTREE_NODE_ID_HI, struct btree_node, flags, 9, 25);
LE64_BITMASK(BTREE_NODE_SEQ, struct btree_node, flags, 32, 64);
static inline __u64 BTREE_NODE_ID(struct btree_node *n)
{ … }
static inline void SET_BTREE_NODE_ID(struct btree_node *n, __u64 v)
{ … }
struct btree_node_entry { … } __packed __aligned(…);
#endif