]> git.sesse.net Git - bcachefs-tools-debian/blob - bcache.h
set btree_node_size for the cache_sb based on bucket_size
[bcachefs-tools-debian] / bcache.h
1 /*
2  * Author: Kent Overstreet <kmo@daterainc.com>
3  *
4  * GPLv2
5  */
6
7 #ifndef _BCACHE_H
8 #define _BCACHE_H
9
10 #include <linux/bcache.h>
11
12 typedef __u8    u8;
13 typedef __u16   u16;
14 typedef __u32   u32;
15 typedef __u64   u64;
16
17 typedef __s8    s8;
18 typedef __s16   s16;
19 typedef __s32   s32;
20 typedef __s64   s64;
21
22 #define SB_START                (SB_SECTOR * 512)
23
24
25 #define max(x, y) ({                            \
26         typeof(x) _max1 = (x);                  \
27         typeof(y) _max2 = (y);                  \
28         (void) (&_max1 == &_max2);              \
29         _max1 > _max2 ? _max1 : _max2; })
30
31
32 extern const char * const cache_state[];
33 extern const char * const replacement_policies[];
34 extern const char * const csum_types[];
35 extern const char * const bdev_cache_mode[];
36 extern const char * const bdev_state[];
37
38 ssize_t read_string_list(const char *, const char * const[]);
39 ssize_t read_string_list_or_die(const char *, const char * const[],
40                                 const char *);
41 void print_string_list(const char * const[], size_t);
42
43 uint64_t bch_checksum(unsigned, const void *, size_t);
44
45 uint64_t getblocks(int);
46 uint64_t hatoi(const char *);
47 unsigned hatoi_validate(const char *, const char *);
48 void write_backingdev_sb(int, unsigned, unsigned *,     bool, uint64_t,
49                                 const char *, uuid_le);
50 int dev_open(const char *, bool);
51 void write_cache_sbs(int *, struct cache_sb *, unsigned, unsigned *, int);
52 void next_cache_device(struct cache_sb *, unsigned, unsigned, unsigned, bool);
53 unsigned get_blocksize(const char *);
54 long strtoul_or_die(const char *, size_t, const char *);
55
56 void show_super_backingdev(struct cache_sb *, bool);
57 void show_cache_member(struct cache_sb *, unsigned);
58 void show_super_cache(struct cache_sb *, bool);
59
60 #define csum_set(i, type)                                               \
61 ({                                                                      \
62         void *start = ((void *) (i)) + sizeof(uint64_t);                \
63         void *end = bset_bkey_last(i);                                  \
64                                                                         \
65         bch_checksum(type, start, end - start);                         \
66 })
67
68 #endif