- remove liblustre.h dependency from selftest.
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;
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 &&
}
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));
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;
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++;
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);
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;
#define LNET_ONLY
#ifndef __KERNEL__
+
/* XXX workaround XXX */
-#ifdef HAVE_SYS_TYPES_H
+#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
-#include <liblustre.h> /* 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 <libcfs/kp30.h>
#include <libcfs/libcfs.h>
#include <lnet/lnet.h>
q = &swi_data.wi_runq;
else
break;
-
+
wi = list_entry(q->next, swi_workitem_t, wi_list);
list_del_init(&wi->wi_list);
if (server_mode_flag)
lnet_server_mode();
-
+
rc = lnet_selftest_init();
if (rc != 0) {
fprintf(stderr, "Can't startup selftest\n");
return -1;
}
-
+
rc = lstjn_join_session(ses, grp);
if (rc != 0)
goto out;