Commit b73d803b authored by Liang Zhen's avatar Liang Zhen Committed by Greg Kroah-Hartman

staging: lustre: lnet: add offset for selftest brw

In current lnet selftest, both client and server side bulk have
no offset and we can only test page aligned IO, this patch changed
this:

- user can set brw offset by lst add_test ... brw off=OFFSET ...
- offset is only effective on client side so far
- to simply implementation, offset needs to be eight bytes aligned
Signed-off-by: default avatarLiang Zhen <liang.zhen@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5718
Reviewed-on: http://review.whamcloud.com/12496Reviewed-by: default avatarDoug Oucharek <doug.s.oucharek@intel.com>
Reviewed-by: default avatarJames Simmons <uja.ornl@yahoo.com>
Reviewed-by: default avatarOleg Drokin <oleg.drokin@intel.com>
Signed-off-by: default avatarJames Simmons <jsimmons@infradead.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 482b27d8
...@@ -490,6 +490,8 @@ typedef struct { ...@@ -490,6 +490,8 @@ typedef struct {
int blk_size; /* size (bytes) */ int blk_size; /* size (bytes) */
int blk_time; /* time of running the test*/ int blk_time; /* time of running the test*/
int blk_flags; /* reserved flags */ int blk_flags; /* reserved flags */
int blk_cli_off; /* bulk offset on client */
int blk_srv_off; /* reserved: bulk offset on server */
} lst_test_bulk_param_t; } lst_test_bulk_param_t;
typedef struct { typedef struct {
......
...@@ -44,6 +44,10 @@ static int brw_inject_errors; ...@@ -44,6 +44,10 @@ static int brw_inject_errors;
module_param(brw_inject_errors, int, 0644); module_param(brw_inject_errors, int, 0644);
MODULE_PARM_DESC(brw_inject_errors, "# data errors to inject randomly, zero by default"); MODULE_PARM_DESC(brw_inject_errors, "# data errors to inject randomly, zero by default");
#define BRW_POISON 0xbeefbeefbeefbeefULL
#define BRW_MAGIC 0xeeb0eeb1eeb2eeb3ULL
#define BRW_MSIZE sizeof(u64)
static void static void
brw_client_fini(struct sfw_test_instance *tsi) brw_client_fini(struct sfw_test_instance *tsi)
{ {
...@@ -67,6 +71,7 @@ brw_client_init(struct sfw_test_instance *tsi) ...@@ -67,6 +71,7 @@ brw_client_init(struct sfw_test_instance *tsi)
{ {
struct sfw_session *sn = tsi->tsi_batch->bat_session; struct sfw_session *sn = tsi->tsi_batch->bat_session;
int flags; int flags;
int off;
int npg; int npg;
int len; int len;
int opc; int opc;
...@@ -87,6 +92,7 @@ brw_client_init(struct sfw_test_instance *tsi) ...@@ -87,6 +92,7 @@ brw_client_init(struct sfw_test_instance *tsi)
* but we have to keep it for compatibility * but we have to keep it for compatibility
*/ */
len = npg * PAGE_SIZE; len = npg * PAGE_SIZE;
off = 0;
} else { } else {
struct test_bulk_req_v1 *breq = &tsi->tsi_u.bulk_v1; struct test_bulk_req_v1 *breq = &tsi->tsi_u.bulk_v1;
...@@ -99,9 +105,13 @@ brw_client_init(struct sfw_test_instance *tsi) ...@@ -99,9 +105,13 @@ brw_client_init(struct sfw_test_instance *tsi)
opc = breq->blk_opc; opc = breq->blk_opc;
flags = breq->blk_flags; flags = breq->blk_flags;
len = breq->blk_len; len = breq->blk_len;
npg = (len + PAGE_SIZE - 1) >> PAGE_SHIFT; off = breq->blk_offset & ~PAGE_MASK;
npg = (off + len + PAGE_SIZE - 1) >> PAGE_SHIFT;
} }
if (off % BRW_MSIZE)
return -EINVAL;
if (npg > LNET_MAX_IOV || npg <= 0) if (npg > LNET_MAX_IOV || npg <= 0)
return -EINVAL; return -EINVAL;
...@@ -114,7 +124,7 @@ brw_client_init(struct sfw_test_instance *tsi) ...@@ -114,7 +124,7 @@ brw_client_init(struct sfw_test_instance *tsi)
list_for_each_entry(tsu, &tsi->tsi_units, tsu_list) { list_for_each_entry(tsu, &tsi->tsi_units, tsu_list) {
bulk = srpc_alloc_bulk(lnet_cpt_of_nid(tsu->tsu_dest.nid), bulk = srpc_alloc_bulk(lnet_cpt_of_nid(tsu->tsu_dest.nid),
npg, len, opc == LST_BRW_READ); off, npg, len, opc == LST_BRW_READ);
if (!bulk) { if (!bulk) {
brw_client_fini(tsi); brw_client_fini(tsi);
return -ENOMEM; return -ENOMEM;
...@@ -126,12 +136,7 @@ brw_client_init(struct sfw_test_instance *tsi) ...@@ -126,12 +136,7 @@ brw_client_init(struct sfw_test_instance *tsi)
return 0; return 0;
} }
#define BRW_POISON 0xbeefbeefbeefbeefULL int brw_inject_one_error(void)
#define BRW_MAGIC 0xeeb0eeb1eeb2eeb3ULL
#define BRW_MSIZE sizeof(__u64)
static int
brw_inject_one_error(void)
{ {
struct timespec64 ts; struct timespec64 ts;
...@@ -147,12 +152,13 @@ brw_inject_one_error(void) ...@@ -147,12 +152,13 @@ brw_inject_one_error(void)
} }
static void static void
brw_fill_page(struct page *pg, int pattern, __u64 magic) brw_fill_page(struct page *pg, int off, int len, int pattern, __u64 magic)
{ {
char *addr = page_address(pg); char *addr = page_address(pg) + off;
int i; int i;
LASSERT(addr); LASSERT(addr);
LASSERT(!(off % BRW_MSIZE) && !(len % BRW_MSIZE));
if (pattern == LST_BRW_CHECK_NONE) if (pattern == LST_BRW_CHECK_NONE)
return; return;
...@@ -162,14 +168,16 @@ brw_fill_page(struct page *pg, int pattern, __u64 magic) ...@@ -162,14 +168,16 @@ brw_fill_page(struct page *pg, int pattern, __u64 magic)
if (pattern == LST_BRW_CHECK_SIMPLE) { if (pattern == LST_BRW_CHECK_SIMPLE) {
memcpy(addr, &magic, BRW_MSIZE); memcpy(addr, &magic, BRW_MSIZE);
addr += PAGE_SIZE - BRW_MSIZE; if (len > BRW_MSIZE) {
memcpy(addr, &magic, BRW_MSIZE); addr += PAGE_SIZE - BRW_MSIZE;
memcpy(addr, &magic, BRW_MSIZE);
}
return; return;
} }
if (pattern == LST_BRW_CHECK_FULL) { if (pattern == LST_BRW_CHECK_FULL) {
for (i = 0; i < PAGE_SIZE / BRW_MSIZE; i++) for (i = 0; i < len; i += BRW_MSIZE)
memcpy(addr + i * BRW_MSIZE, &magic, BRW_MSIZE); memcpy(addr + i, &magic, BRW_MSIZE);
return; return;
} }
...@@ -177,13 +185,14 @@ brw_fill_page(struct page *pg, int pattern, __u64 magic) ...@@ -177,13 +185,14 @@ brw_fill_page(struct page *pg, int pattern, __u64 magic)
} }
static int static int
brw_check_page(struct page *pg, int pattern, __u64 magic) brw_check_page(struct page *pg, int off, int len, int pattern, __u64 magic)
{ {
char *addr = page_address(pg); char *addr = page_address(pg) + off;
__u64 data = 0; /* make compiler happy */ __u64 data = 0; /* make compiler happy */
int i; int i;
LASSERT(addr); LASSERT(addr);
LASSERT(!(off % BRW_MSIZE) && !(len % BRW_MSIZE));
if (pattern == LST_BRW_CHECK_NONE) if (pattern == LST_BRW_CHECK_NONE)
return 0; return 0;
...@@ -193,21 +202,21 @@ brw_check_page(struct page *pg, int pattern, __u64 magic) ...@@ -193,21 +202,21 @@ brw_check_page(struct page *pg, int pattern, __u64 magic)
if (data != magic) if (data != magic)
goto bad_data; goto bad_data;
addr += PAGE_SIZE - BRW_MSIZE; if (len > BRW_MSIZE) {
data = *((__u64 *)addr); addr += PAGE_SIZE - BRW_MSIZE;
if (data != magic) data = *((__u64 *)addr);
goto bad_data; if (data != magic)
goto bad_data;
}
return 0; return 0;
} }
if (pattern == LST_BRW_CHECK_FULL) { if (pattern == LST_BRW_CHECK_FULL) {
for (i = 0; i < PAGE_SIZE / BRW_MSIZE; i++) { for (i = 0; i < len; i += BRW_MSIZE) {
data = *(((__u64 *)addr) + i); data = *(u64 *)(addr + i);
if (data != magic) if (data != magic)
goto bad_data; goto bad_data;
} }
return 0; return 0;
} }
...@@ -226,8 +235,12 @@ brw_fill_bulk(struct srpc_bulk *bk, int pattern, __u64 magic) ...@@ -226,8 +235,12 @@ brw_fill_bulk(struct srpc_bulk *bk, int pattern, __u64 magic)
struct page *pg; struct page *pg;
for (i = 0; i < bk->bk_niov; i++) { for (i = 0; i < bk->bk_niov; i++) {
int off, len;
pg = bk->bk_iovs[i].bv_page; pg = bk->bk_iovs[i].bv_page;
brw_fill_page(pg, pattern, magic); off = bk->bk_iovs[i].bv_offset;
len = bk->bk_iovs[i].bv_len;
brw_fill_page(pg, off, len, pattern, magic);
} }
} }
...@@ -238,8 +251,12 @@ brw_check_bulk(struct srpc_bulk *bk, int pattern, __u64 magic) ...@@ -238,8 +251,12 @@ brw_check_bulk(struct srpc_bulk *bk, int pattern, __u64 magic)
struct page *pg; struct page *pg;
for (i = 0; i < bk->bk_niov; i++) { for (i = 0; i < bk->bk_niov; i++) {
int off, len;
pg = bk->bk_iovs[i].bv_page; pg = bk->bk_iovs[i].bv_page;
if (brw_check_page(pg, pattern, magic)) { off = bk->bk_iovs[i].bv_offset;
len = bk->bk_iovs[i].bv_len;
if (brw_check_page(pg, off, len, pattern, magic)) {
CERROR("Bulk page %p (%d/%d) is corrupted!\n", CERROR("Bulk page %p (%d/%d) is corrupted!\n",
pg, i, bk->bk_niov); pg, i, bk->bk_niov);
return 1; return 1;
...@@ -276,6 +293,7 @@ brw_client_prep_rpc(struct sfw_test_unit *tsu, ...@@ -276,6 +293,7 @@ brw_client_prep_rpc(struct sfw_test_unit *tsu,
len = npg * PAGE_SIZE; len = npg * PAGE_SIZE;
} else { } else {
struct test_bulk_req_v1 *breq = &tsi->tsi_u.bulk_v1; struct test_bulk_req_v1 *breq = &tsi->tsi_u.bulk_v1;
int off;
/* /*
* I should never get this step if it's unknown feature * I should never get this step if it's unknown feature
...@@ -286,7 +304,8 @@ brw_client_prep_rpc(struct sfw_test_unit *tsu, ...@@ -286,7 +304,8 @@ brw_client_prep_rpc(struct sfw_test_unit *tsu,
opc = breq->blk_opc; opc = breq->blk_opc;
flags = breq->blk_flags; flags = breq->blk_flags;
len = breq->blk_len; len = breq->blk_len;
npg = (len + PAGE_SIZE - 1) >> PAGE_SHIFT; off = breq->blk_offset;
npg = (off + len + PAGE_SIZE - 1) >> PAGE_SHIFT;
} }
rc = sfw_create_test_rpc(tsu, dest, sn->sn_features, npg, len, &rpc); rc = sfw_create_test_rpc(tsu, dest, sn->sn_features, npg, len, &rpc);
......
...@@ -789,14 +789,15 @@ lstcon_bulkrpc_v0_prep(lst_test_bulk_param_t *param, struct srpc_test_reqst *req ...@@ -789,14 +789,15 @@ lstcon_bulkrpc_v0_prep(lst_test_bulk_param_t *param, struct srpc_test_reqst *req
} }
static int static int
lstcon_bulkrpc_v1_prep(lst_test_bulk_param_t *param, struct srpc_test_reqst *req) lstcon_bulkrpc_v1_prep(lst_test_bulk_param_t *param, bool is_client,
struct srpc_test_reqst *req)
{ {
struct test_bulk_req_v1 *brq = &req->tsr_u.bulk_v1; struct test_bulk_req_v1 *brq = &req->tsr_u.bulk_v1;
brq->blk_opc = param->blk_opc; brq->blk_opc = param->blk_opc;
brq->blk_flags = param->blk_flags; brq->blk_flags = param->blk_flags;
brq->blk_len = param->blk_size; brq->blk_len = param->blk_size;
brq->blk_offset = 0; /* reserved */ brq->blk_offset = is_client ? param->blk_cli_off : param->blk_srv_off;
return 0; return 0;
} }
...@@ -897,7 +898,8 @@ lstcon_testrpc_prep(struct lstcon_node *nd, int transop, unsigned feats, ...@@ -897,7 +898,8 @@ lstcon_testrpc_prep(struct lstcon_node *nd, int transop, unsigned feats,
&test->tes_param[0], trq); &test->tes_param[0], trq);
} else { } else {
rc = lstcon_bulkrpc_v1_prep((lst_test_bulk_param_t *) rc = lstcon_bulkrpc_v1_prep((lst_test_bulk_param_t *)
&test->tes_param[0], trq); &test->tes_param[0],
trq->tsr_is_client, trq);
} }
break; break;
......
...@@ -1101,7 +1101,7 @@ sfw_alloc_pages(struct srpc_server_rpc *rpc, int cpt, int npages, int len, ...@@ -1101,7 +1101,7 @@ sfw_alloc_pages(struct srpc_server_rpc *rpc, int cpt, int npages, int len,
LASSERT(!rpc->srpc_bulk); LASSERT(!rpc->srpc_bulk);
LASSERT(npages > 0 && npages <= LNET_MAX_IOV); LASSERT(npages > 0 && npages <= LNET_MAX_IOV);
rpc->srpc_bulk = srpc_alloc_bulk(cpt, npages, len, sink); rpc->srpc_bulk = srpc_alloc_bulk(cpt, 0, npages, len, sink);
if (!rpc->srpc_bulk) if (!rpc->srpc_bulk)
return -ENOMEM; return -ENOMEM;
......
...@@ -84,14 +84,13 @@ void srpc_set_counters(const srpc_counters_t *cnt) ...@@ -84,14 +84,13 @@ void srpc_set_counters(const srpc_counters_t *cnt)
} }
static int static int
srpc_add_bulk_page(struct srpc_bulk *bk, struct page *pg, int i, int nob) srpc_add_bulk_page(struct srpc_bulk *bk, struct page *pg, int i, int off,
int nob)
{ {
nob = min_t(int, nob, PAGE_SIZE); LASSERT(off < PAGE_SIZE);
LASSERT(nob > 0 && nob <= PAGE_SIZE);
LASSERT(nob > 0); bk->bk_iovs[i].bv_offset = off;
LASSERT(i >= 0 && i < bk->bk_niov);
bk->bk_iovs[i].bv_offset = 0;
bk->bk_iovs[i].bv_page = pg; bk->bk_iovs[i].bv_page = pg;
bk->bk_iovs[i].bv_len = nob; bk->bk_iovs[i].bv_len = nob;
return nob; return nob;
...@@ -117,7 +116,8 @@ srpc_free_bulk(struct srpc_bulk *bk) ...@@ -117,7 +116,8 @@ srpc_free_bulk(struct srpc_bulk *bk)
} }
struct srpc_bulk * struct srpc_bulk *
srpc_alloc_bulk(int cpt, unsigned bulk_npg, unsigned bulk_len, int sink) srpc_alloc_bulk(int cpt, unsigned int bulk_off, unsigned int bulk_npg,
unsigned int bulk_len, int sink)
{ {
struct srpc_bulk *bk; struct srpc_bulk *bk;
int i; int i;
...@@ -148,8 +148,11 @@ srpc_alloc_bulk(int cpt, unsigned bulk_npg, unsigned bulk_len, int sink) ...@@ -148,8 +148,11 @@ srpc_alloc_bulk(int cpt, unsigned bulk_npg, unsigned bulk_len, int sink)
return NULL; return NULL;
} }
nob = srpc_add_bulk_page(bk, pg, i, bulk_len); nob = min_t(unsigned int, bulk_off + bulk_len, PAGE_SIZE) -
bulk_off;
srpc_add_bulk_page(bk, pg, i, bulk_off, nob);
bulk_len -= nob; bulk_len -= nob;
bulk_off = 0;
} }
return bk; return bk;
......
...@@ -175,7 +175,7 @@ struct test_bulk_req_v1 { ...@@ -175,7 +175,7 @@ struct test_bulk_req_v1 {
__u16 blk_opc; /* bulk operation code */ __u16 blk_opc; /* bulk operation code */
__u16 blk_flags; /* data check flags */ __u16 blk_flags; /* data check flags */
__u32 blk_len; /* data length */ __u32 blk_len; /* data length */
__u32 blk_offset; /* reserved: offset */ __u32 blk_offset; /* offset */
} WIRE_ATTR; } WIRE_ATTR;
struct test_ping_req { struct test_ping_req {
......
...@@ -434,8 +434,9 @@ srpc_create_client_rpc(lnet_process_id_t peer, int service, ...@@ -434,8 +434,9 @@ srpc_create_client_rpc(lnet_process_id_t peer, int service,
void srpc_post_rpc(struct srpc_client_rpc *rpc); void srpc_post_rpc(struct srpc_client_rpc *rpc);
void srpc_abort_rpc(struct srpc_client_rpc *rpc, int why); void srpc_abort_rpc(struct srpc_client_rpc *rpc, int why);
void srpc_free_bulk(struct srpc_bulk *bk); void srpc_free_bulk(struct srpc_bulk *bk);
struct srpc_bulk *srpc_alloc_bulk(int cpt, unsigned bulk_npg, struct srpc_bulk *srpc_alloc_bulk(int cpt, unsigned int off,
unsigned bulk_len, int sink); unsigned int bulk_npg, unsigned int bulk_len,
int sink);
int srpc_send_rpc(struct swi_workitem *wi); int srpc_send_rpc(struct swi_workitem *wi);
int srpc_send_reply(struct srpc_server_rpc *rpc); int srpc_send_reply(struct srpc_server_rpc *rpc);
int srpc_add_service(struct srpc_service *sv); int srpc_add_service(struct srpc_service *sv);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment