Whamcloud - gitweb
LU-14291 ptlrpc: format UPDATE messages in server-only code
[fs/lustre-release.git] / lustre / ptlrpc / pack_generic.c
index 0e382c4..e4bacc2 100644 (file)
@@ -40,9 +40,7 @@
 
 #define DEBUG_SUBSYSTEM S_RPC
 
-#ifndef CONFIG_CRYPTO_CRC32
 #include <linux/crc32.h>
-#endif
 
 #include <libcfs/libcfs.h>
 
@@ -52,8 +50,6 @@
 #include <obd_cksum.h>
 #include <obd_class.h>
 #include <obd_support.h>
-#include <obj_update.h>
-
 #include "ptlrpc_internal.h"
 
 static inline __u32 lustre_msg_hdr_size_v2(__u32 count)
@@ -1386,14 +1382,17 @@ __u32 lustre_msg_calc_cksum(struct lustre_msg *msg, __u32 buf)
                __u32 len = lustre_msg_buflen(msg, buf);
                __u32 crc;
 
-               LASSERTF(pb != NULL, "invalid msg %p: no ptlrpc body!\n", msg);
-#ifdef CONFIG_CRYPTO_CRC32
+#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
-               crc = crc32_le(~(__u32)0, (unsigned char *)pb, len);
+#error "need either CONFIG_CRC32 or CONFIG_CRYPTO_CRC32 enabled in the kernel"
 #endif
                return crc;
        }
@@ -2893,110 +2892,6 @@ void lustre_swab_hsm_request(struct hsm_request *hr)
        __swab32s(&hr->hr_data_len);
 }
 
-void lustre_swab_object_update(struct object_update *ou)
-{
-       struct object_update_param *param;
-       size_t  i;
-
-       __swab16s(&ou->ou_type);
-       __swab16s(&ou->ou_params_count);
-       __swab32s(&ou->ou_result_size);
-       __swab32s(&ou->ou_flags);
-       __swab32s(&ou->ou_padding1);
-       __swab64s(&ou->ou_batchid);
-       lustre_swab_lu_fid(&ou->ou_fid);
-       param = &ou->ou_params[0];
-       for (i = 0; i < ou->ou_params_count; i++) {
-               __swab16s(&param->oup_len);
-               __swab16s(&param->oup_padding);
-               __swab32s(&param->oup_padding2);
-               param = (struct object_update_param *)((char *)param +
-                        object_update_param_size(param));
-       }
-}
-
-int lustre_swab_object_update_request(struct object_update_request *our,
-                                     __u32 len)
-{
-       __u32 i, size = 0;
-       struct object_update *ou;
-
-       __swab32s(&our->ourq_magic);
-       __swab16s(&our->ourq_count);
-       __swab16s(&our->ourq_padding);
-
-       /* Don't need to calculate request size if len is 0. */
-       if (len > 0) {
-               size = sizeof(struct object_update_request);
-               for (i = 0; i < our->ourq_count; i++) {
-                       ou = object_update_request_get(our, i, NULL);
-                       if (ou == NULL)
-                               return -EPROTO;
-                       size += sizeof(struct object_update) +
-                               ou->ou_params_count *
-                               sizeof(struct object_update_param);
-               }
-               if (unlikely(size > len))
-                       return -EOVERFLOW;
-       }
-
-       for (i = 0; i < our->ourq_count; i++) {
-               ou = object_update_request_get(our, i, NULL);
-               lustre_swab_object_update(ou);
-       }
-
-       return size;
-}
-
-void lustre_swab_object_update_result(struct object_update_result *our)
-{
-       __swab32s(&our->our_rc);
-       __swab16s(&our->our_datalen);
-       __swab16s(&our->our_padding);
-}
-
-int lustre_swab_object_update_reply(struct object_update_reply *our, __u32 len)
-{
-       __u32 i, size;
-
-       __swab32s(&our->ourp_magic);
-       __swab16s(&our->ourp_count);
-       __swab16s(&our->ourp_padding);
-
-       size = sizeof(struct object_update_reply) + our->ourp_count *
-              (sizeof(__u16) + sizeof(struct object_update_result));
-       if (unlikely(size > len))
-               return -EOVERFLOW;
-
-       for (i = 0; i < our->ourp_count; i++) {
-               struct object_update_result *ourp;
-
-               __swab16s(&our->ourp_lens[i]);
-               ourp = object_update_result_get(our, i, NULL);
-               if (ourp == NULL)
-                       return -EPROTO;
-               lustre_swab_object_update_result(ourp);
-       }
-
-       return size;
-}
-
-void lustre_swab_out_update_header(struct out_update_header *ouh)
-{
-       __swab32s(&ouh->ouh_magic);
-       __swab32s(&ouh->ouh_count);
-       __swab32s(&ouh->ouh_inline_length);
-       __swab32s(&ouh->ouh_reply_size);
-}
-EXPORT_SYMBOL(lustre_swab_out_update_header);
-
-void lustre_swab_out_update_buffer(struct out_update_buffer *oub)
-{
-       __swab32s(&oub->oub_size);
-       __swab32s(&oub->oub_padding);
-}
-EXPORT_SYMBOL(lustre_swab_out_update_buffer);
-
 void lustre_swab_swap_layouts(struct mdc_swap_layouts *msl)
 {
        __swab64s(&msl->msl_flags);