]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/checksum.h
Merge https://github.com/YellowOnion/bcachefs-tools
[bcachefs-tools-debian] / libbcachefs / checksum.h
index ca9e45906dc8813f707076670caabfdabcab4bd9..f5c1a609c5c42fe408a5896498c1aeed748679ff 100644 (file)
@@ -13,9 +13,9 @@ static inline bool bch2_checksum_mergeable(unsigned type)
 {
 
        switch (type) {
-       case BCH_CSUM_NONE:
-       case BCH_CSUM_CRC32C:
-       case BCH_CSUM_CRC64:
+       case BCH_CSUM_none:
+       case BCH_CSUM_crc32c:
+       case BCH_CSUM_crc64:
                return true;
        default:
                return false;
@@ -77,12 +77,14 @@ static inline enum bch_csum_type bch2_csum_opt_to_type(enum bch_csum_opts type,
                                                       bool data)
 {
        switch (type) {
-       case BCH_CSUM_OPT_NONE:
-            return BCH_CSUM_NONE;
-       case BCH_CSUM_OPT_CRC32C:
-            return data ? BCH_CSUM_CRC32C : BCH_CSUM_CRC32C_NONZERO;
-       case BCH_CSUM_OPT_CRC64:
-            return data ? BCH_CSUM_CRC64 : BCH_CSUM_CRC64_NONZERO;
+       case BCH_CSUM_OPT_none:
+            return BCH_CSUM_none;
+       case BCH_CSUM_OPT_crc32c:
+            return data ? BCH_CSUM_crc32c : BCH_CSUM_crc32c_nonzero;
+       case BCH_CSUM_OPT_crc64:
+            return data ? BCH_CSUM_crc64 : BCH_CSUM_crc64_nonzero;
+       case BCH_CSUM_OPT_xxhash:
+            return BCH_CSUM_xxhash;
        default:
             BUG();
        }
@@ -93,8 +95,8 @@ static inline enum bch_csum_type bch2_data_checksum_type(struct bch_fs *c,
 {
        if (c->sb.encryption_type)
                return c->opts.wide_macs
-                       ? BCH_CSUM_CHACHA20_POLY1305_128
-                       : BCH_CSUM_CHACHA20_POLY1305_80;
+                       ? BCH_CSUM_chacha20_poly1305_128
+                       : BCH_CSUM_chacha20_poly1305_80;
 
        return bch2_csum_opt_to_type(opt, true);
 }
@@ -102,7 +104,7 @@ static inline enum bch_csum_type bch2_data_checksum_type(struct bch_fs *c,
 static inline enum bch_csum_type bch2_meta_checksum_type(struct bch_fs *c)
 {
        if (c->sb.encryption_type)
-               return BCH_CSUM_CHACHA20_POLY1305_128;
+               return BCH_CSUM_chacha20_poly1305_128;
 
        return bch2_csum_opt_to_type(c->opts.metadata_checksum, false);
 }
@@ -155,13 +157,16 @@ static inline struct nonce null_nonce(void)
 static inline struct nonce extent_nonce(struct bversion version,
                                        struct bch_extent_crc_unpacked crc)
 {
-       unsigned size = crc.compression_type ? crc.uncompressed_size : 0;
+       unsigned compression_type = crc_is_compressed(crc)
+               ? crc.compression_type
+               : 0;
+       unsigned size = compression_type ? crc.uncompressed_size : 0;
        struct nonce nonce = (struct nonce) {{
                [0] = cpu_to_le32(size << 22),
                [1] = cpu_to_le32(version.lo),
                [2] = cpu_to_le32(version.lo >> 32),
                [3] = cpu_to_le32(version.hi|
-                                 (crc.compression_type << 24))^BCH_NONCE_EXTENT,
+                                 (compression_type << 24))^BCH_NONCE_EXTENT,
        }};
 
        return nonce_add(nonce, crc.nonce << 9);