Whamcloud - gitweb
LU-13124 scrub: check for multiple linked file
[fs/lustre-release.git] / lustre / include / obd_cksum.h
index a2ce2ec..8234d0b 100644 (file)
@@ -27,7 +27,6 @@
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
  */
 
 #ifndef __OBD_CKSUM
@@ -112,17 +111,24 @@ enum cksum_types obd_cksum_types_supported_server(const char *obd_name);
  * checksum type due to its benchmarking at libcfs module load.
  * Caution is advised, however, since what is fastest on a single client may
  * not be the fastest or most efficient algorithm on the server.  */
-static inline enum cksum_types
-obd_cksum_type_select(const char *obd_name, enum cksum_types cksum_types)
+static inline
+enum cksum_types obd_cksum_type_select(const char *obd_name,
+                                      enum cksum_types cksum_types,
+                                      enum cksum_types preferred)
 {
-       u32 flag = obd_cksum_type_pack(obd_name, cksum_types);
+       u32 flag;
+
+       if (preferred & cksum_types)
+               return preferred;
+
+       flag = obd_cksum_type_pack(obd_name, cksum_types);
 
        return obd_cksum_type_unpack(flag);
 }
 
 /* Checksum algorithm names. Must be defined in the same order as the
  * OBD_CKSUM_* flags. */
-#define DECLARE_CKSUM_NAME const char *cksum_name[] = {"crc32", "adler", \
+#define DECLARE_CKSUM_NAME const char *const cksum_name[] = {"crc32", "adler", \
        "crc32c", "reserved", "t10ip512", "t10ip4K", "t10crc512", "t10crc4K"}
 
 typedef __u16 (obd_dif_csum_fn) (void *, unsigned int);
@@ -144,6 +150,7 @@ static inline void obd_t10_cksum2dif(enum cksum_types cksum_type,
        *fn = NULL;
        *sector_size = 0;
 
+#if IS_ENABLED(CONFIG_CRC_T10DIF)
        switch (cksum_type) {
        case OBD_CKSUM_T10IP512:
                *fn = obd_dif_ip_fn;
@@ -164,6 +171,7 @@ static inline void obd_t10_cksum2dif(enum cksum_types cksum_type,
        default:
                break;
        }
+#endif /* CONFIG_CRC_T10DIF */
 }
 
 enum obd_t10_cksum_type {