From d7b4e4a631d3aead75f8beea07f2c129ea5765b9 Mon Sep 17 00:00:00 2001 From: isaac Date: Thu, 5 Jun 2008 03:37:22 +0000 Subject: [PATCH 1/1] i=liang: - remove liblustre.h dependency from selftest. --- lnet/lnet/lib-move.c | 6 +++--- lnet/lnet/router.c | 20 ++++++++++---------- lnet/selftest/selftest.h | 23 +++++++++++++++++++++-- lnet/selftest/workitem.c | 2 +- lnet/utils/lstclient.c | 4 ++-- 5 files changed, 37 insertions(+), 18 deletions(-) diff --git a/lnet/lnet/lib-move.c b/lnet/lnet/lib-move.c index c174762..a6288d8 100644 --- a/lnet/lnet/lib-move.c +++ b/lnet/lnet/lib-move.c @@ -2426,7 +2426,7 @@ LNetGet(lnet_nid_t self, lnet_handle_md_t mdh, int LNetDist (lnet_nid_t dstnid, lnet_nid_t *srcnidp, __u32 *orderp) { - struct list_head *e; + struct list_head *e; lnet_ni_t *ni; lnet_route_t *route; lnet_remotenet_t *rnet; @@ -2446,7 +2446,7 @@ LNetDist (lnet_nid_t dstnid, lnet_nid_t *srcnidp, __u32 *orderp) list_for_each (e, &the_lnet.ln_nis) { ni = list_entry(e, lnet_ni_t, ni_list); - + if (ni->ni_nid == dstnid || (the_lnet.ln_ptlcompat > 0 && LNET_NIDNET(dstnid) == 0 && @@ -2481,7 +2481,7 @@ LNetDist (lnet_nid_t dstnid, lnet_nid_t *srcnidp, __u32 *orderp) } list_for_each (e, &the_lnet.ln_remote_nets) { - rnet = list_entry(e, lnet_remotenet_t, lrn_list); + rnet = list_entry(e, lnet_remotenet_t, lrn_list); if (rnet->lrn_net == dstnet) { LASSERT (!list_empty(&rnet->lrn_routes)); diff --git a/lnet/lnet/router.c b/lnet/lnet/router.c index 01b635a..938a4d6 100644 --- a/lnet/lnet/router.c +++ b/lnet/lnet/router.c @@ -271,11 +271,11 @@ int lnet_add_route (__u32 net, unsigned int hops, lnet_nid_t gateway) { struct list_head zombies; - struct list_head *e; - lnet_remotenet_t *rnet; - lnet_remotenet_t *rnet2; - lnet_route_t *route; - lnet_route_t *route2; + struct list_head *e; + lnet_remotenet_t *rnet; + lnet_remotenet_t *rnet2; + lnet_route_t *route; + lnet_route_t *route2; lnet_ni_t *ni; int add_route; int rc; @@ -363,11 +363,11 @@ lnet_add_route (__u32 net, unsigned int hops, lnet_nid_t gateway) LASSERT (route2->lr_gateway->lp_nid != gateway); } } - + if (add_route) { ni = route->lr_gateway->lp_ni; lnet_ni_addref_locked(ni); - + LASSERT (rc == 0); list_add_tail(&route->lr_list, &rnet2->lrn_routes); the_lnet.ln_remote_nets_version++; @@ -393,7 +393,7 @@ lnet_add_route (__u32 net, unsigned int hops, lnet_nid_t gateway) while (!list_empty(&zombies)) { route = list_entry(zombies.next, lnet_route_t, lr_list); list_del(&route->lr_list); - + LNET_LOCK(); lnet_rtr_decref_locked(route->lr_gateway); lnet_peer_decref_locked(route->lr_gateway); @@ -509,8 +509,8 @@ int lnet_get_route (int idx, __u32 *net, __u32 *hops, lnet_nid_t *gateway, __u32 *alive) { - struct list_head *e1; - struct list_head *e2; + struct list_head *e1; + struct list_head *e2; lnet_remotenet_t *rnet; lnet_route_t *route; diff --git a/lnet/selftest/selftest.h b/lnet/selftest/selftest.h index 485570b..5038350 100644 --- a/lnet/selftest/selftest.h +++ b/lnet/selftest/selftest.h @@ -11,12 +11,31 @@ #define LNET_ONLY #ifndef __KERNEL__ + /* XXX workaround XXX */ -#ifdef HAVE_SYS_TYPES_H +#ifdef HAVE_SYS_TYPES_H #include #endif -#include /* userland spinlock_t and atomic_t */ + +/* TODO: remove these when libcfs provides proper primitives for userspace + * + * Dummy implementations of spinlock_t and atomic_t work since userspace + * selftest is completely single-threaded, even using multi-threaded usocklnd. + */ +typedef struct { } spinlock_t; +static inline void spin_lock(spinlock_t *l) {return;} +static inline void spin_unlock(spinlock_t *l) {return;} +static inline void spin_lock_init(spinlock_t *l) {return;} + +typedef struct { volatile int counter; } atomic_t; +#define atomic_read(a) ((a)->counter) +#define atomic_set(a,b) do {(a)->counter = b; } while (0) +#define atomic_dec_and_test(a) ((--((a)->counter)) == 0) +#define atomic_inc(a) (((a)->counter)++) +#define atomic_dec(a) do { (a)->counter--; } while (0) + #endif + #include #include #include diff --git a/lnet/selftest/workitem.c b/lnet/selftest/workitem.c index 19b0a79..789da8d 100644 --- a/lnet/selftest/workitem.c +++ b/lnet/selftest/workitem.c @@ -259,7 +259,7 @@ swi_check_events (void) q = &swi_data.wi_runq; else break; - + wi = list_entry(q->next, swi_workitem_t, wi_list); list_del_init(&wi->wi_list); diff --git a/lnet/utils/lstclient.c b/lnet/utils/lstclient.c index ec52175..c9a70f8 100644 --- a/lnet/utils/lstclient.c +++ b/lnet/utils/lstclient.c @@ -178,7 +178,7 @@ main(int argc, char **argv) if (server_mode_flag) lnet_server_mode(); - + rc = lnet_selftest_init(); if (rc != 0) { fprintf(stderr, "Can't startup selftest\n"); @@ -187,7 +187,7 @@ main(int argc, char **argv) return -1; } - + rc = lstjn_join_session(ses, grp); if (rc != 0) goto out; -- 1.8.3.1