*/
/*
* This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
*/
#ifndef __OBD_CKSUM
* 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;
+
+ /*
+ * Server reporting a single T10 checksum type
+ * means the target actually supports T10-PI.
+ */
+ if (hweight32(cksum_types & OBD_CKSUM_T10_ALL) == 1)
+ return cksum_types & OBD_CKSUM_T10_ALL;
+
+ 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);