]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcache/checksum.h
bcache in userspace; userspace fsck
[bcachefs-tools-debian] / libbcache / checksum.h
1 #ifndef _BCACHE_CHECKSUM_H
2 #define _BCACHE_CHECKSUM_H
3
4 #include "btree_types.h"
5
6 u64 bch_crc64_update(u64, const void *, size_t);
7
8 u64 bch_checksum_update(unsigned, u64, const void *, size_t);
9 u64 bch_checksum(unsigned, const void *, size_t);
10 u32 bch_checksum_bio(struct bio *, unsigned);
11
12 /*
13  * This is used for various on disk data structures - cache_sb, prio_set, bset,
14  * jset: The checksum is _always_ the first 8 bytes of these structs
15  */
16 #define __csum_set(i, u64s, type)                                       \
17 ({                                                                      \
18         const void *start = ((const void *) (i)) + sizeof(u64);         \
19         const void *end = __bkey_idx(i, u64s);                          \
20                                                                         \
21         bch_checksum(type, start, end - start);                         \
22 })
23
24 #endif /* _BCACHE_CHECKSUM_H */