Whamcloud - gitweb
LU-10810 clio: SEEK_HOLE/SEEK_DATA on client side
[fs/lustre-release.git] / lustre / ptlrpc / sec_plain.c
index 82310b6..3d75653 100644 (file)
@@ -156,13 +156,13 @@ static void corrupt_bulk_data(struct ptlrpc_bulk_desc *desc)
        unsigned int off, i;
 
        for (i = 0; i < desc->bd_iov_count; i++) {
-               if (BD_GET_KIOV(desc, i).kiov_len == 0)
+               if (desc->bd_vec[i].bv_len == 0)
                        continue;
 
-               ptr = kmap(BD_GET_KIOV(desc, i).kiov_page);
-               off = BD_GET_KIOV(desc, i).kiov_offset & ~PAGE_MASK;
+               ptr = kmap(desc->bd_vec[i].bv_page);
+               off = desc->bd_vec[i].bv_offset & ~PAGE_MASK;
                ptr[off] ^= 0x1;
-               kunmap(BD_GET_KIOV(desc, i).kiov_page);
+               kunmap(desc->bd_vec[i].bv_page);
                return;
        }
 }
@@ -216,7 +216,6 @@ int plain_ctx_verify(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req)
 {
        struct lustre_msg *msg = req->rq_repdata;
        struct plain_header *phdr;
-       __u32 cksum;
        bool swabbed;
 
        ENTRY;
@@ -251,12 +250,8 @@ int plain_ctx_verify(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req)
        }
 
        if (unlikely(req->rq_early)) {
-               unsigned int hsize = 4;
+               __u32 cksum = lustre_msg_calc_cksum(msg, PLAIN_PACK_MSG_OFF);
 
-               cfs_crypto_hash_digest(CFS_HASH_ALG_CRC32,
-                               lustre_msg_buf(msg, PLAIN_PACK_MSG_OFF, 0),
-                               lustre_msg_buflen(msg, PLAIN_PACK_MSG_OFF),
-                               NULL, 0, (unsigned char *)&cksum, &hsize);
                if (cksum != msg->lm_cksum) {
                        CDEBUG(D_SEC,
                               "early reply checksum mismatch: %08x != %08x\n",
@@ -355,12 +350,12 @@ int plain_cli_unwrap_bulk(struct ptlrpc_cli_ctx *ctx,
 
        /* fix the actual data size */
        for (i = 0, nob = 0; i < desc->bd_iov_count; i++) {
-               if (BD_GET_KIOV(desc, i).kiov_len +
+               if (desc->bd_vec[i].bv_len +
                    nob > desc->bd_nob_transferred) {
-                       BD_GET_KIOV(desc, i).kiov_len =
+                       desc->bd_vec[i].bv_len =
                                desc->bd_nob_transferred - nob;
                }
-               nob += BD_GET_KIOV(desc, i).kiov_len;
+               nob += desc->bd_vec[i].bv_len;
        }
 
        rc = plain_verify_bulk_csum(desc, req->rq_flvr.u_bulk.hash.hash_alg,
@@ -890,20 +885,13 @@ int plain_authorize(struct ptlrpc_request *req)
                phdr->ph_flags |= PLAIN_FL_BULK;
 
        rs->rs_repdata_len = len;
+       req->rq_reply_off = 0;
 
        if (likely(req->rq_packed_final)) {
                if (lustre_msghdr_get_flags(req->rq_reqmsg) & MSGHDR_AT_SUPPORT)
                        req->rq_reply_off = plain_at_offset;
-               else
-                       req->rq_reply_off = 0;
        } else {
-               unsigned int hsize = 4;
-
-               cfs_crypto_hash_digest(CFS_HASH_ALG_CRC32,
-                       lustre_msg_buf(msg, PLAIN_PACK_MSG_OFF, 0),
-                       lustre_msg_buflen(msg, PLAIN_PACK_MSG_OFF),
-                       NULL, 0, (unsigned char *)&msg->lm_cksum, &hsize);
-               req->rq_reply_off = 0;
+               msg->lm_cksum = lustre_msg_calc_cksum(msg, PLAIN_PACK_MSG_OFF);
        }
 
        RETURN(0);