Whamcloud - gitweb
i=liang:
authorisaac <isaac>
Thu, 5 Jun 2008 03:37:22 +0000 (03:37 +0000)
committerisaac <isaac>
Thu, 5 Jun 2008 03:37:22 +0000 (03:37 +0000)
-   remove liblustre.h dependency from selftest.

lnet/lnet/lib-move.c
lnet/lnet/router.c
lnet/selftest/selftest.h
lnet/selftest/workitem.c
lnet/utils/lstclient.c

index c174762..a6288d8 100644 (file)
@@ -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)
 {
 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;
         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);
 
         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 &&
                 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) {
         }
 
         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));
 
                 if (rnet->lrn_net == dstnet) {
                         LASSERT (!list_empty(&rnet->lrn_routes));
index 01b635a..938a4d6 100644 (file)
@@ -271,11 +271,11 @@ int
 lnet_add_route (__u32 net, unsigned int hops, lnet_nid_t gateway)
 {
         struct list_head     zombies;
 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;
         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);
                 }
         }
                         LASSERT (route2->lr_gateway->lp_nid != gateway);
                 }
         }
-        
+
         if (add_route) {
                 ni = route->lr_gateway->lp_ni;
                 lnet_ni_addref_locked(ni);
         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++;
                 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);
         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_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)
 {
 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;
 
         lnet_remotenet_t    *rnet;
         lnet_route_t        *route;
 
index 485570b..5038350 100644 (file)
 #define LNET_ONLY
 
 #ifndef __KERNEL__
 #define LNET_ONLY
 
 #ifndef __KERNEL__
+
 /* XXX workaround XXX */
 /* XXX workaround XXX */
-#ifdef HAVE_SYS_TYPES_H
+#ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
 #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
 #endif
+
 #include <libcfs/kp30.h>
 #include <libcfs/libcfs.h>
 #include <lnet/lnet.h>
 #include <libcfs/kp30.h>
 #include <libcfs/libcfs.h>
 #include <lnet/lnet.h>
index 19b0a79..789da8d 100644 (file)
@@ -259,7 +259,7 @@ swi_check_events (void)
                         q = &swi_data.wi_runq;
                 else
                         break;
                         q = &swi_data.wi_runq;
                 else
                         break;
-                               
+
                 wi = list_entry(q->next, swi_workitem_t, wi_list);
                 list_del_init(&wi->wi_list);
 
                 wi = list_entry(q->next, swi_workitem_t, wi_list);
                 list_del_init(&wi->wi_list);
 
index ec52175..c9a70f8 100644 (file)
@@ -178,7 +178,7 @@ main(int argc, char **argv)
 
         if (server_mode_flag)
                 lnet_server_mode();
 
         if (server_mode_flag)
                 lnet_server_mode();
-        
+
         rc = lnet_selftest_init();
         if (rc != 0) {
                 fprintf(stderr, "Can't startup selftest\n");
         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;
         }
 
                 return -1;
         }
-       
+
         rc = lstjn_join_session(ses, grp);
         if (rc != 0)
                 goto out;
         rc = lstjn_join_session(ses, grp);
         if (rc != 0)
                 goto out;