diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2017-01-08 00:13:18 -0900 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2017-01-20 09:07:08 -0900 |
commit | b33fc8298f7e13226b9895abc57c9bfce5e3fa2d (patch) | |
tree | a3d2a5a909b6372f7777c1c5c18cef5f81d123a9 /libbcache/checksum.h | |
parent | 7f4191a202ea4558ca2d5eb8a47daea33c9999c7 (diff) |
bcache in userspace; userspace fsck
Diffstat (limited to 'libbcache/checksum.h')
-rw-r--r-- | libbcache/checksum.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libbcache/checksum.h b/libbcache/checksum.h new file mode 100644 index 0000000..196b7e8 --- /dev/null +++ b/libbcache/checksum.h @@ -0,0 +1,24 @@ +#ifndef _BCACHE_CHECKSUM_H +#define _BCACHE_CHECKSUM_H + +#include "btree_types.h" + +u64 bch_crc64_update(u64, const void *, size_t); + +u64 bch_checksum_update(unsigned, u64, const void *, size_t); +u64 bch_checksum(unsigned, const void *, size_t); +u32 bch_checksum_bio(struct bio *, unsigned); + +/* + * This is used for various on disk data structures - cache_sb, prio_set, bset, + * jset: The checksum is _always_ the first 8 bytes of these structs + */ +#define __csum_set(i, u64s, type) \ +({ \ + const void *start = ((const void *) (i)) + sizeof(u64); \ + const void *end = __bkey_idx(i, u64s); \ + \ + bch_checksum(type, start, end - start); \ +}) + +#endif /* _BCACHE_CHECKSUM_H */ |