-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
+// SPDX-License-Identifier: GPL-2.0
+
/*
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
* Copyright (c) 2012, 2017, Intel Corporation.
*/
+
/*
* This file is part of Lustre, http://www.lustre.org/
*
- * lnet/selftest/brw_test.c
- *
* Author: Isaac Huang <isaac@clusterfs.com>
*/
struct sfw_session *sn = tsi->tsi_batch->bat_session;
int flags;
int off;
- int npg;
- int len;
+ unsigned int len;
int opc;
struct srpc_bulk *bulk;
struct sfw_test_unit *tsu;
opc = breq->blk_opc;
flags = breq->blk_flags;
- npg = breq->blk_npg;
/* NB: this is not going to work for variable page size,
* but we have to keep it for compatibility */
- len = npg * PAGE_SIZE;
+ len = breq->blk_npg * PAGE_SIZE;
off = 0;
} else {
flags = breq->blk_flags;
len = breq->blk_len;
off = breq->blk_offset & ~PAGE_MASK;
- npg = (off + len + PAGE_SIZE - 1) >> PAGE_SHIFT;
}
if (off % BRW_MSIZE != 0)
return -EINVAL;
- if (npg > LNET_MAX_IOV || npg <= 0)
+ if (len > LNET_MTU)
return -EINVAL;
if (opc != LST_BRW_READ && opc != LST_BRW_WRITE)
list_for_each_entry(tsu, &tsi->tsi_units, tsu_list) {
bulk = srpc_alloc_bulk(lnet_cpt_of_nid(tsu->tsu_dest.nid, NULL),
- npg);
+ len);
if (bulk == NULL) {
brw_client_fini(tsi);
return -ENOMEM;
}
- srpc_init_bulk(bulk, off, npg, len, opc == LST_BRW_READ);
+ srpc_init_bulk(bulk, off, len, opc == LST_BRW_READ);
tsu->tsu_private = bulk;
}
int flags;
int npg;
int len;
+ int off;
int opc;
int rc;
opc = breq->blk_opc;
flags = breq->blk_flags;
- npg = breq->blk_npg;
- len = npg * PAGE_SIZE;
+ len = breq->blk_npg * PAGE_SIZE;
+ off = 0;
} else {
struct test_bulk_req_v1 *breq = &tsi->tsi_u.bulk_v1;
flags = breq->blk_flags;
len = breq->blk_len;
off = breq->blk_offset;
- npg = (off + len + PAGE_SIZE - 1) >> PAGE_SHIFT;
}
+ npg = (off + len + PAGE_SIZE - 1) >> PAGE_SHIFT;
rc = sfw_create_test_rpc(tsu, dest, sn->sn_features, npg, len, &rpc);
if (rc != 0)
return rc;
- memcpy(&rpc->crpc_bulk, bulk, offsetof(struct srpc_bulk, bk_iovs[npg]));
+ unsafe_memcpy(&rpc->crpc_bulk, bulk,
+ offsetof(struct srpc_bulk, bk_iovs[npg]),
+ FLEXIBLE_OBJECT);
if (opc == LST_BRW_WRITE)
brw_fill_bulk(&rpc->crpc_bulk, flags, BRW_MAGIC);
else
struct srpc_msg *reqstmsg = &rpc->srpc_reqstbuf->buf_msg;
struct srpc_brw_reply *reply = &replymsg->msg_body.brw_reply;
struct srpc_brw_reqst *reqst = &reqstmsg->msg_body.brw_reqst;
- int npg;
LASSERT (sv->sv_id == SRPC_SERVICE_BRW);
reply->brw_status = EINVAL;
return 0;
}
- npg = reqst->brw_len >> PAGE_SHIFT;
-
- } else {
- npg = (reqst->brw_len + PAGE_SIZE - 1) >> PAGE_SHIFT;
}
replymsg->msg_ses_feats = reqstmsg->msg_ses_feats;
- if (reqst->brw_len == 0 || npg > LNET_MAX_IOV) {
+ if (reqst->brw_len == 0 || reqst->brw_len > LNET_MTU) {
reply->brw_status = EINVAL;
return 0;
}
- srpc_init_bulk(rpc->srpc_bulk, 0, npg, reqst->brw_len,
+ srpc_init_bulk(rpc->srpc_bulk, 0, reqst->brw_len,
reqst->brw_rw == LST_BRW_WRITE);
if (reqst->brw_rw == LST_BRW_READ)
brw_srpc_init(struct srpc_server_rpc *rpc, int cpt)
{
/* just alloc a maximal size - actual values will be adjusted later */
- rpc->srpc_bulk = srpc_alloc_bulk(cpt, LNET_MAX_IOV);
+ rpc->srpc_bulk = srpc_alloc_bulk(cpt, LNET_MTU);
if (rpc->srpc_bulk == NULL)
return -ENOMEM;
- srpc_init_bulk(rpc->srpc_bulk, 0, LNET_MAX_IOV, 0, 0);
+ srpc_init_bulk(rpc->srpc_bulk, 0, 0, 0);
return 0;
}
static void
brw_srpc_fini(struct srpc_server_rpc *rpc)
{
- /* server RPC have just MAX_IOV size */
- srpc_init_bulk(rpc->srpc_bulk, 0, LNET_MAX_IOV, 0, 0);
-
srpc_free_bulk(rpc->srpc_bulk);
rpc->srpc_bulk = NULL;
}
void brw_init_test_service(void)
{
- unsigned long cache_size = cfs_totalram_pages() >> 1;
+ unsigned long cache_size = cfs_totalram_pages() >> 4;
/* brw prealloc cache should don't eat more than half memory */
- cache_size /= LNET_MAX_IOV;
+ cache_size /= ((LNET_MTU >> PAGE_SHIFT) + 1) ;
brw_test_service.sv_wi_total = brw_srv_workitems;