Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../usr/include/linux
File: bcache.h
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
[0] Fix | Delete
#ifndef _LINUX_BCACHE_H
[1] Fix | Delete
#define _LINUX_BCACHE_H
[2] Fix | Delete
[3] Fix | Delete
/*
[4] Fix | Delete
* Bcache on disk data structures
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
#include <linux/types.h>
[8] Fix | Delete
[9] Fix | Delete
#define BITMASK(name, type, field, offset, size) \
[10] Fix | Delete
static __inline__ __u64 name(const type *k) \
[11] Fix | Delete
{ return (k->field >> offset) & ~(~0ULL << size); } \
[12] Fix | Delete
\
[13] Fix | Delete
static __inline__ void SET_##name(type *k, __u64 v) \
[14] Fix | Delete
{ \
[15] Fix | Delete
k->field &= ~(~(~0ULL << size) << offset); \
[16] Fix | Delete
k->field |= (v & ~(~0ULL << size)) << offset; \
[17] Fix | Delete
}
[18] Fix | Delete
[19] Fix | Delete
/* Btree keys - all units are in sectors */
[20] Fix | Delete
[21] Fix | Delete
struct bkey {
[22] Fix | Delete
__u64 high;
[23] Fix | Delete
__u64 low;
[24] Fix | Delete
__u64 ptr[];
[25] Fix | Delete
};
[26] Fix | Delete
[27] Fix | Delete
#define KEY_FIELD(name, field, offset, size) \
[28] Fix | Delete
BITMASK(name, struct bkey, field, offset, size)
[29] Fix | Delete
[30] Fix | Delete
#define PTR_FIELD(name, offset, size) \
[31] Fix | Delete
static __inline__ __u64 name(const struct bkey *k, unsigned i) \
[32] Fix | Delete
{ return (k->ptr[i] >> offset) & ~(~0ULL << size); } \
[33] Fix | Delete
\
[34] Fix | Delete
static __inline__ void SET_##name(struct bkey *k, unsigned i, __u64 v) \
[35] Fix | Delete
{ \
[36] Fix | Delete
k->ptr[i] &= ~(~(~0ULL << size) << offset); \
[37] Fix | Delete
k->ptr[i] |= (v & ~(~0ULL << size)) << offset; \
[38] Fix | Delete
}
[39] Fix | Delete
[40] Fix | Delete
#define KEY_SIZE_BITS 16
[41] Fix | Delete
#define KEY_MAX_U64S 8
[42] Fix | Delete
[43] Fix | Delete
KEY_FIELD(KEY_PTRS, high, 60, 3)
[44] Fix | Delete
KEY_FIELD(HEADER_SIZE, high, 58, 2)
[45] Fix | Delete
KEY_FIELD(KEY_CSUM, high, 56, 2)
[46] Fix | Delete
KEY_FIELD(KEY_PINNED, high, 55, 1)
[47] Fix | Delete
KEY_FIELD(KEY_DIRTY, high, 36, 1)
[48] Fix | Delete
[49] Fix | Delete
KEY_FIELD(KEY_SIZE, high, 20, KEY_SIZE_BITS)
[50] Fix | Delete
KEY_FIELD(KEY_INODE, high, 0, 20)
[51] Fix | Delete
[52] Fix | Delete
/* Next time I change the on disk format, KEY_OFFSET() won't be 64 bits */
[53] Fix | Delete
[54] Fix | Delete
static __inline__ __u64 KEY_OFFSET(const struct bkey *k)
[55] Fix | Delete
{
[56] Fix | Delete
return k->low;
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
static __inline__ void SET_KEY_OFFSET(struct bkey *k, __u64 v)
[60] Fix | Delete
{
[61] Fix | Delete
k->low = v;
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
/*
[65] Fix | Delete
* The high bit being set is a relic from when we used it to do binary
[66] Fix | Delete
* searches - it told you where a key started. It's not used anymore,
[67] Fix | Delete
* and can probably be safely dropped.
[68] Fix | Delete
*/
[69] Fix | Delete
#define KEY(inode, offset, size) \
[70] Fix | Delete
((struct bkey) { \
[71] Fix | Delete
.high = (1ULL << 63) | ((__u64) (size) << 20) | (inode), \
[72] Fix | Delete
.low = (offset) \
[73] Fix | Delete
})
[74] Fix | Delete
[75] Fix | Delete
#define ZERO_KEY KEY(0, 0, 0)
[76] Fix | Delete
[77] Fix | Delete
#define MAX_KEY_INODE (~(~0 << 20))
[78] Fix | Delete
#define MAX_KEY_OFFSET (~0ULL >> 1)
[79] Fix | Delete
#define MAX_KEY KEY(MAX_KEY_INODE, MAX_KEY_OFFSET, 0)
[80] Fix | Delete
[81] Fix | Delete
#define KEY_START(k) (KEY_OFFSET(k) - KEY_SIZE(k))
[82] Fix | Delete
#define START_KEY(k) KEY(KEY_INODE(k), KEY_START(k), 0)
[83] Fix | Delete
[84] Fix | Delete
#define PTR_DEV_BITS 12
[85] Fix | Delete
[86] Fix | Delete
PTR_FIELD(PTR_DEV, 51, PTR_DEV_BITS)
[87] Fix | Delete
PTR_FIELD(PTR_OFFSET, 8, 43)
[88] Fix | Delete
PTR_FIELD(PTR_GEN, 0, 8)
[89] Fix | Delete
[90] Fix | Delete
#define PTR_CHECK_DEV ((1 << PTR_DEV_BITS) - 1)
[91] Fix | Delete
[92] Fix | Delete
#define MAKE_PTR(gen, offset, dev) \
[93] Fix | Delete
((((__u64) dev) << 51) | ((__u64) offset) << 8 | gen)
[94] Fix | Delete
[95] Fix | Delete
/* Bkey utility code */
[96] Fix | Delete
[97] Fix | Delete
static __inline__ unsigned long bkey_u64s(const struct bkey *k)
[98] Fix | Delete
{
[99] Fix | Delete
return (sizeof(struct bkey) / sizeof(__u64)) + KEY_PTRS(k);
[100] Fix | Delete
}
[101] Fix | Delete
[102] Fix | Delete
static __inline__ unsigned long bkey_bytes(const struct bkey *k)
[103] Fix | Delete
{
[104] Fix | Delete
return bkey_u64s(k) * sizeof(__u64);
[105] Fix | Delete
}
[106] Fix | Delete
[107] Fix | Delete
#define bkey_copy(_dest, _src) memcpy(_dest, _src, bkey_bytes(_src))
[108] Fix | Delete
[109] Fix | Delete
static __inline__ void bkey_copy_key(struct bkey *dest, const struct bkey *src)
[110] Fix | Delete
{
[111] Fix | Delete
SET_KEY_INODE(dest, KEY_INODE(src));
[112] Fix | Delete
SET_KEY_OFFSET(dest, KEY_OFFSET(src));
[113] Fix | Delete
}
[114] Fix | Delete
[115] Fix | Delete
static __inline__ struct bkey *bkey_next(const struct bkey *k)
[116] Fix | Delete
{
[117] Fix | Delete
__u64 *d = (void *) k;
[118] Fix | Delete
return (struct bkey *) (d + bkey_u64s(k));
[119] Fix | Delete
}
[120] Fix | Delete
[121] Fix | Delete
static __inline__ struct bkey *bkey_idx(const struct bkey *k, unsigned nr_keys)
[122] Fix | Delete
{
[123] Fix | Delete
__u64 *d = (void *) k;
[124] Fix | Delete
return (struct bkey *) (d + nr_keys);
[125] Fix | Delete
}
[126] Fix | Delete
/* Enough for a key with 6 pointers */
[127] Fix | Delete
#define BKEY_PAD 8
[128] Fix | Delete
[129] Fix | Delete
#define BKEY_PADDED(key) \
[130] Fix | Delete
union { struct bkey key; __u64 key ## _pad[BKEY_PAD]; }
[131] Fix | Delete
[132] Fix | Delete
/* Superblock */
[133] Fix | Delete
[134] Fix | Delete
/* Version 0: Cache device
[135] Fix | Delete
* Version 1: Backing device
[136] Fix | Delete
* Version 2: Seed pointer into btree node checksum
[137] Fix | Delete
* Version 3: Cache device with new UUID format
[138] Fix | Delete
* Version 4: Backing device with data offset
[139] Fix | Delete
*/
[140] Fix | Delete
#define BCACHE_SB_VERSION_CDEV 0
[141] Fix | Delete
#define BCACHE_SB_VERSION_BDEV 1
[142] Fix | Delete
#define BCACHE_SB_VERSION_CDEV_WITH_UUID 3
[143] Fix | Delete
#define BCACHE_SB_VERSION_BDEV_WITH_OFFSET 4
[144] Fix | Delete
#define BCACHE_SB_MAX_VERSION 4
[145] Fix | Delete
[146] Fix | Delete
#define SB_SECTOR 8
[147] Fix | Delete
#define SB_SIZE 4096
[148] Fix | Delete
#define SB_LABEL_SIZE 32
[149] Fix | Delete
#define SB_JOURNAL_BUCKETS 256U
[150] Fix | Delete
/* SB_JOURNAL_BUCKETS must be divisible by BITS_PER_LONG */
[151] Fix | Delete
#define MAX_CACHES_PER_SET 8
[152] Fix | Delete
[153] Fix | Delete
#define BDEV_DATA_START_DEFAULT 16 /* sectors */
[154] Fix | Delete
[155] Fix | Delete
struct cache_sb {
[156] Fix | Delete
__u64 csum;
[157] Fix | Delete
__u64 offset; /* sector where this sb was written */
[158] Fix | Delete
__u64 version;
[159] Fix | Delete
[160] Fix | Delete
__u8 magic[16];
[161] Fix | Delete
[162] Fix | Delete
__u8 uuid[16];
[163] Fix | Delete
union {
[164] Fix | Delete
__u8 set_uuid[16];
[165] Fix | Delete
__u64 set_magic;
[166] Fix | Delete
};
[167] Fix | Delete
__u8 label[SB_LABEL_SIZE];
[168] Fix | Delete
[169] Fix | Delete
__u64 flags;
[170] Fix | Delete
__u64 seq;
[171] Fix | Delete
__u64 pad[8];
[172] Fix | Delete
[173] Fix | Delete
union {
[174] Fix | Delete
struct {
[175] Fix | Delete
/* Cache devices */
[176] Fix | Delete
__u64 nbuckets; /* device size */
[177] Fix | Delete
[178] Fix | Delete
__u16 block_size; /* sectors */
[179] Fix | Delete
__u16 bucket_size; /* sectors */
[180] Fix | Delete
[181] Fix | Delete
__u16 nr_in_set;
[182] Fix | Delete
__u16 nr_this_dev;
[183] Fix | Delete
};
[184] Fix | Delete
struct {
[185] Fix | Delete
/* Backing devices */
[186] Fix | Delete
__u64 data_offset;
[187] Fix | Delete
[188] Fix | Delete
/*
[189] Fix | Delete
* block_size from the cache device section is still used by
[190] Fix | Delete
* backing devices, so don't add anything here until we fix
[191] Fix | Delete
* things to not need it for backing devices anymore
[192] Fix | Delete
*/
[193] Fix | Delete
};
[194] Fix | Delete
};
[195] Fix | Delete
[196] Fix | Delete
__u32 last_mount; /* time_t */
[197] Fix | Delete
[198] Fix | Delete
__u16 first_bucket;
[199] Fix | Delete
union {
[200] Fix | Delete
__u16 njournal_buckets;
[201] Fix | Delete
__u16 keys;
[202] Fix | Delete
};
[203] Fix | Delete
__u64 d[SB_JOURNAL_BUCKETS]; /* journal buckets */
[204] Fix | Delete
};
[205] Fix | Delete
[206] Fix | Delete
static __inline__ _Bool SB_IS_BDEV(const struct cache_sb *sb)
[207] Fix | Delete
{
[208] Fix | Delete
return sb->version == BCACHE_SB_VERSION_BDEV
[209] Fix | Delete
|| sb->version == BCACHE_SB_VERSION_BDEV_WITH_OFFSET;
[210] Fix | Delete
}
[211] Fix | Delete
[212] Fix | Delete
BITMASK(CACHE_SYNC, struct cache_sb, flags, 0, 1);
[213] Fix | Delete
BITMASK(CACHE_DISCARD, struct cache_sb, flags, 1, 1);
[214] Fix | Delete
BITMASK(CACHE_REPLACEMENT, struct cache_sb, flags, 2, 3);
[215] Fix | Delete
#define CACHE_REPLACEMENT_LRU 0U
[216] Fix | Delete
#define CACHE_REPLACEMENT_FIFO 1U
[217] Fix | Delete
#define CACHE_REPLACEMENT_RANDOM 2U
[218] Fix | Delete
[219] Fix | Delete
BITMASK(BDEV_CACHE_MODE, struct cache_sb, flags, 0, 4);
[220] Fix | Delete
#define CACHE_MODE_WRITETHROUGH 0U
[221] Fix | Delete
#define CACHE_MODE_WRITEBACK 1U
[222] Fix | Delete
#define CACHE_MODE_WRITEAROUND 2U
[223] Fix | Delete
#define CACHE_MODE_NONE 3U
[224] Fix | Delete
BITMASK(BDEV_STATE, struct cache_sb, flags, 61, 2);
[225] Fix | Delete
#define BDEV_STATE_NONE 0U
[226] Fix | Delete
#define BDEV_STATE_CLEAN 1U
[227] Fix | Delete
#define BDEV_STATE_DIRTY 2U
[228] Fix | Delete
#define BDEV_STATE_STALE 3U
[229] Fix | Delete
[230] Fix | Delete
/*
[231] Fix | Delete
* Magic numbers
[232] Fix | Delete
*
[233] Fix | Delete
* The various other data structures have their own magic numbers, which are
[234] Fix | Delete
* xored with the first part of the cache set's UUID
[235] Fix | Delete
*/
[236] Fix | Delete
[237] Fix | Delete
#define JSET_MAGIC 0x245235c1a3625032ULL
[238] Fix | Delete
#define PSET_MAGIC 0x6750e15f87337f91ULL
[239] Fix | Delete
#define BSET_MAGIC 0x90135c78b99e07f5ULL
[240] Fix | Delete
[241] Fix | Delete
static __inline__ __u64 jset_magic(struct cache_sb *sb)
[242] Fix | Delete
{
[243] Fix | Delete
return sb->set_magic ^ JSET_MAGIC;
[244] Fix | Delete
}
[245] Fix | Delete
[246] Fix | Delete
static __inline__ __u64 pset_magic(struct cache_sb *sb)
[247] Fix | Delete
{
[248] Fix | Delete
return sb->set_magic ^ PSET_MAGIC;
[249] Fix | Delete
}
[250] Fix | Delete
[251] Fix | Delete
static __inline__ __u64 bset_magic(struct cache_sb *sb)
[252] Fix | Delete
{
[253] Fix | Delete
return sb->set_magic ^ BSET_MAGIC;
[254] Fix | Delete
}
[255] Fix | Delete
[256] Fix | Delete
/*
[257] Fix | Delete
* Journal
[258] Fix | Delete
*
[259] Fix | Delete
* On disk format for a journal entry:
[260] Fix | Delete
* seq is monotonically increasing; every journal entry has its own unique
[261] Fix | Delete
* sequence number.
[262] Fix | Delete
*
[263] Fix | Delete
* last_seq is the oldest journal entry that still has keys the btree hasn't
[264] Fix | Delete
* flushed to disk yet.
[265] Fix | Delete
*
[266] Fix | Delete
* version is for on disk format changes.
[267] Fix | Delete
*/
[268] Fix | Delete
[269] Fix | Delete
#define BCACHE_JSET_VERSION_UUIDv1 1
[270] Fix | Delete
#define BCACHE_JSET_VERSION_UUID 1 /* Always latest UUID format */
[271] Fix | Delete
#define BCACHE_JSET_VERSION 1
[272] Fix | Delete
[273] Fix | Delete
struct jset {
[274] Fix | Delete
__u64 csum;
[275] Fix | Delete
__u64 magic;
[276] Fix | Delete
__u64 seq;
[277] Fix | Delete
__u32 version;
[278] Fix | Delete
__u32 keys;
[279] Fix | Delete
[280] Fix | Delete
__u64 last_seq;
[281] Fix | Delete
[282] Fix | Delete
BKEY_PADDED(uuid_bucket);
[283] Fix | Delete
BKEY_PADDED(btree_root);
[284] Fix | Delete
__u16 btree_level;
[285] Fix | Delete
__u16 pad[3];
[286] Fix | Delete
[287] Fix | Delete
__u64 prio_bucket[MAX_CACHES_PER_SET];
[288] Fix | Delete
[289] Fix | Delete
union {
[290] Fix | Delete
struct bkey start[0];
[291] Fix | Delete
__u64 d[0];
[292] Fix | Delete
};
[293] Fix | Delete
};
[294] Fix | Delete
[295] Fix | Delete
/* Bucket prios/gens */
[296] Fix | Delete
[297] Fix | Delete
struct prio_set {
[298] Fix | Delete
__u64 csum;
[299] Fix | Delete
__u64 magic;
[300] Fix | Delete
__u64 seq;
[301] Fix | Delete
__u32 version;
[302] Fix | Delete
__u32 pad;
[303] Fix | Delete
[304] Fix | Delete
__u64 next_bucket;
[305] Fix | Delete
[306] Fix | Delete
struct bucket_disk {
[307] Fix | Delete
__u16 prio;
[308] Fix | Delete
__u8 gen;
[309] Fix | Delete
} __attribute((packed)) data[];
[310] Fix | Delete
};
[311] Fix | Delete
[312] Fix | Delete
/* UUIDS - per backing device/flash only volume metadata */
[313] Fix | Delete
[314] Fix | Delete
struct uuid_entry {
[315] Fix | Delete
union {
[316] Fix | Delete
struct {
[317] Fix | Delete
__u8 uuid[16];
[318] Fix | Delete
__u8 label[32];
[319] Fix | Delete
__u32 first_reg;
[320] Fix | Delete
__u32 last_reg;
[321] Fix | Delete
__u32 invalidated;
[322] Fix | Delete
[323] Fix | Delete
__u32 flags;
[324] Fix | Delete
/* Size of flash only volumes */
[325] Fix | Delete
__u64 sectors;
[326] Fix | Delete
};
[327] Fix | Delete
[328] Fix | Delete
__u8 pad[128];
[329] Fix | Delete
};
[330] Fix | Delete
};
[331] Fix | Delete
[332] Fix | Delete
BITMASK(UUID_FLASH_ONLY, struct uuid_entry, flags, 0, 1);
[333] Fix | Delete
[334] Fix | Delete
/* Btree nodes */
[335] Fix | Delete
[336] Fix | Delete
/* Version 1: Seed pointer into btree node checksum
[337] Fix | Delete
*/
[338] Fix | Delete
#define BCACHE_BSET_CSUM 1
[339] Fix | Delete
#define BCACHE_BSET_VERSION 1
[340] Fix | Delete
[341] Fix | Delete
/*
[342] Fix | Delete
* Btree nodes
[343] Fix | Delete
*
[344] Fix | Delete
* On disk a btree node is a list/log of these; within each set the keys are
[345] Fix | Delete
* sorted
[346] Fix | Delete
*/
[347] Fix | Delete
struct bset {
[348] Fix | Delete
__u64 csum;
[349] Fix | Delete
__u64 magic;
[350] Fix | Delete
__u64 seq;
[351] Fix | Delete
__u32 version;
[352] Fix | Delete
__u32 keys;
[353] Fix | Delete
[354] Fix | Delete
union {
[355] Fix | Delete
struct bkey start[0];
[356] Fix | Delete
__u64 d[0];
[357] Fix | Delete
};
[358] Fix | Delete
};
[359] Fix | Delete
[360] Fix | Delete
/* OBSOLETE */
[361] Fix | Delete
[362] Fix | Delete
/* UUIDS - per backing device/flash only volume metadata */
[363] Fix | Delete
[364] Fix | Delete
struct uuid_entry_v0 {
[365] Fix | Delete
__u8 uuid[16];
[366] Fix | Delete
__u8 label[32];
[367] Fix | Delete
__u32 first_reg;
[368] Fix | Delete
__u32 last_reg;
[369] Fix | Delete
__u32 invalidated;
[370] Fix | Delete
__u32 pad;
[371] Fix | Delete
};
[372] Fix | Delete
[373] Fix | Delete
#endif /* _LINUX_BCACHE_H */
[374] Fix | Delete
[375] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function