#define DEBUG_SUBSYSTEM S_RPC
+#include <linux/crc32.h>
+
#include <libcfs/libcfs.h>
#include <llog_swab.h>
}
}
-__u32 lustre_msg_calc_cksum(struct lustre_msg *msg)
+__u32 lustre_msg_calc_cksum(struct lustre_msg *msg, __u32 buf)
{
switch (msg->lm_magic) {
case LUSTRE_MSG_MAGIC_V2: {
- struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
- __u32 len = lustre_msg_buflen(msg, MSG_PTLRPC_BODY_OFF);
-
- unsigned int hsize = 4;
+ struct ptlrpc_body *pb = lustre_msg_buf_v2(msg, buf, 0);
+ __u32 len = lustre_msg_buflen(msg, buf);
__u32 crc;
LASSERTF(pb != NULL, "invalid msg %p: no ptlrpc body!\n", msg);
+#if IS_ENABLED(CONFIG_CRC32)
+ /* about 10x faster than crypto_hash for small buffers */
+ crc = crc32_le(~(__u32)0, (unsigned char *)pb, len);
+#elif IS_ENABLED(CONFIG_CRYPTO_CRC32)
+ unsigned int hsize = 4;
cfs_crypto_hash_digest(CFS_HASH_ALG_CRC32, (unsigned char *)pb,
len, NULL, 0, (unsigned char *)&crc,
&hsize);
+#else
+#error "need either CONFIG_CRC32 or CONFIG_CRYPTO_CRC32 enabled in the kernel"
+#endif
return crc;
}
default:
__swab32s(&b->mbo_projid);
__swab64s(&b->mbo_dom_size);
__swab64s(&b->mbo_dom_blocks);
- BUILD_BUG_ON(offsetof(typeof(*b), mbo_padding_8) == 0);
+ __swab64s(&b->mbo_btime);
BUILD_BUG_ON(offsetof(typeof(*b), mbo_padding_9) == 0);
BUILD_BUG_ON(offsetof(typeof(*b), mbo_padding_10) == 0);
}
BUILD_BUG_ON(offsetof(typeof(*b), dqb_padding) == 0);
}
-void lustre_swab_obd_quotactl(struct obd_quotactl *q)
+int lustre_swab_obd_quotactl(struct obd_quotactl *q, __u32 len)
{
+ if (unlikely(len <= sizeof(struct obd_quotactl)))
+ return -EOVERFLOW;
+
__swab32s(&q->qc_cmd);
__swab32s(&q->qc_type);
__swab32s(&q->qc_id);
__swab32s(&q->qc_stat);
lustre_swab_obd_dqinfo(&q->qc_dqinfo);
lustre_swab_obd_dqblk(&q->qc_dqblk);
+
+ return len;
}
void lustre_swab_fid2path(struct getinfo_fid2path *gf)