From d143653f75da3b8532781a52b5d9dbe754bd245b Mon Sep 17 00:00:00 2001 From: Maxim Patlasov Date: Wed, 24 Mar 2010 15:05:25 +0300 Subject: [PATCH] b=21945 Adding WIRE_ATTR attribute to LNET types i=liang LST nodes on different platforms might not communicate well due to the lack of WIRE_ATTR attribute in some LNET structures traversing network. The patch fixes the problem by adding WIRE_ATTR where needed. --- lnet/include/lnet/lib-types.h | 8 +++++++- lnet/include/lnet/lnetst.h | 4 ++-- lnet/selftest/conrpc.c | 30 ++++++++++++++++-------------- lnet/selftest/framework.c | 9 +++++---- lnet/selftest/selftest.h | 2 +- 5 files changed, 31 insertions(+), 22 deletions(-) diff --git a/lnet/include/lnet/lib-types.h b/lnet/include/lnet/lib-types.h index 609cdb8..dd113d8 100644 --- a/lnet/include/lnet/lib-types.h +++ b/lnet/include/lnet/lib-types.h @@ -58,6 +58,12 @@ #define WIRE_ATTR __attribute__((packed)) +/* Packed version of lnet_process_id_t to transfer via network */ +typedef struct { + lnet_nid_t nid; + lnet_pid_t pid; /* node id / process id */ +} WIRE_ATTR lnet_process_id_packed_t; + /* The wire handle's interface cookie only matches one network interface in * one epoch (i.e. new cookie when the interface restarts or the node * reboots). The object cookie only matches one object on that interface @@ -494,7 +500,7 @@ typedef struct { __u64 recv_length; __u64 route_length; __u64 drop_length; -} lnet_counters_t; +} WIRE_ATTR lnet_counters_t; #define LNET_PEER_HASHSIZE 503 /* prime! */ diff --git a/lnet/include/lnet/lnetst.h b/lnet/include/lnet/lnetst.h index 5b72579..7b21ca9 100644 --- a/lnet/include/lnet/lnetst.h +++ b/lnet/include/lnet/lnetst.h @@ -467,7 +467,7 @@ typedef struct { __u32 rpcs_expired; __u64 bulk_get; __u64 bulk_put; -} srpc_counters_t; +} WIRE_ATTR srpc_counters_t; typedef struct { __u32 active_tests; @@ -475,6 +475,6 @@ typedef struct { __u32 zombie_sessions; __u32 brw_errors; __u32 ping_errors; -} sfw_counters_t; +} WIRE_ATTR sfw_counters_t; #endif diff --git a/lnet/selftest/conrpc.c b/lnet/selftest/conrpc.c index a2e3df2..3b2fb75 100644 --- a/lnet/selftest/conrpc.c +++ b/lnet/selftest/conrpc.c @@ -694,31 +694,31 @@ lstcon_statrpc_prep(lstcon_node_t *nd, lstcon_rpc_t **crpc) return 0; } -lnet_process_id_t * +lnet_process_id_packed_t * lstcon_next_id(int idx, int nkiov, lnet_kiov_t *kiov) { - lnet_process_id_t *pid; - int i; + lnet_process_id_packed_t *pid; + int i; - i = idx / (CFS_PAGE_SIZE / sizeof(lnet_process_id_t)); + i = idx / SFW_ID_PER_PAGE; LASSERT (i < nkiov); - pid = (lnet_process_id_t *)cfs_page_address(kiov[i].kiov_page); + pid = (lnet_process_id_packed_t *)cfs_page_address(kiov[i].kiov_page); - return &pid[idx % (CFS_PAGE_SIZE / sizeof(lnet_process_id_t))]; + return &pid[idx % SFW_ID_PER_PAGE]; } int lstcon_dstnodes_prep(lstcon_group_t *grp, int idx, int dist, int span, int nkiov, lnet_kiov_t *kiov) { - lnet_process_id_t *pid; - lstcon_ndlink_t *ndl; - lstcon_node_t *nd; - int start; - int end; - int i = 0; + lnet_process_id_packed_t *pid; + lstcon_ndlink_t *ndl; + lstcon_node_t *nd; + int start; + int end; + int i = 0; LASSERT (dist >= 1); LASSERT (span >= 1); @@ -741,7 +741,8 @@ lstcon_dstnodes_prep(lstcon_group_t *grp, int idx, break; pid = lstcon_next_id((i - start), nkiov, kiov); - *pid = nd->nd_id; + pid->nid = nd->nd_id.nid; + pid->pid = nd->nd_id.pid; i++; } @@ -754,7 +755,8 @@ lstcon_dstnodes_prep(lstcon_group_t *grp, int idx, nd = ndl->ndl_node; pid = lstcon_next_id((i - start), nkiov, kiov); - *pid = nd->nd_id; + pid->nid = nd->nd_id.nid; + pid->pid = nd->nd_id.pid; i++; } diff --git a/lnet/selftest/framework.c b/lnet/selftest/framework.c index 07de3ef..ae8216c 100644 --- a/lnet/selftest/framework.c +++ b/lnet/selftest/framework.c @@ -754,9 +754,9 @@ sfw_add_test_instance (sfw_batch_t *tsb, srpc_server_rpc_t *rpc) memcpy(&tsi->tsi_u, &req->tsr_u, sizeof(tsi->tsi_u)); for (i = 0; i < ndest; i++) { - lnet_process_id_t *dests; - lnet_process_id_t id; - int j; + lnet_process_id_packed_t *dests; + lnet_process_id_packed_t id; + int j; #ifdef __KERNEL__ dests = cfs_page_address(bk->bk_iovs[i / SFW_ID_PER_PAGE].kiov_page); @@ -777,7 +777,8 @@ sfw_add_test_instance (sfw_batch_t *tsb, srpc_server_rpc_t *rpc) goto error; } - tsu->tsu_dest = id; + tsu->tsu_dest.nid = id.nid; + tsu->tsu_dest.pid = id.pid; tsu->tsu_instance = tsi; tsu->tsu_private = NULL; list_add_tail(&tsu->tsu_list, &tsi->tsi_units); diff --git a/lnet/selftest/selftest.h b/lnet/selftest/selftest.h index 2f0c34a..10be23e 100644 --- a/lnet/selftest/selftest.h +++ b/lnet/selftest/selftest.h @@ -416,7 +416,7 @@ typedef struct sfw_test_instance { /* XXX: trailing (CFS_PAGE_SIZE % sizeof(lnet_process_id_t)) bytes at * the end of pages are not used */ #define SFW_MAX_CONCUR LST_MAX_CONCUR -#define SFW_ID_PER_PAGE (CFS_PAGE_SIZE / sizeof(lnet_process_id_t)) +#define SFW_ID_PER_PAGE (CFS_PAGE_SIZE / sizeof(lnet_process_id_packed_t)) #define SFW_MAX_NDESTS (LNET_MAX_IOV * SFW_ID_PER_PAGE) #define sfw_id_pages(n) (((n) + SFW_ID_PER_PAGE - 1) / SFW_ID_PER_PAGE) -- 1.8.3.1