Whamcloud - gitweb
- another day of good progress with liblustre. We now have all the
authorbraam <braam>
Fri, 21 Feb 2003 11:05:45 +0000 (11:05 +0000)
committerbraam <braam>
Fri, 21 Feb 2003 11:05:45 +0000 (11:05 +0000)
  modules initialized, ready to start playing with lctl dumpfiles.

lustre/include/liblustre.h
lustre/liblustre/Makefile.am [new file with mode: 0644]
lustre/liblustre/libtest.c [new file with mode: 0644]
lustre/obdclass/lustre_handles.c

index 7804610..668d0d5 100644 (file)
 #define LINUX_VERSION_CODE 1
 #define KERNEL_VERSION(a,b,c) 0 
 
+static inline void inter_module_put(void *a)
+{
+        return;
+}
+
+extern ptl_handle_ni_t         tcpnal_ni;
+
+static inline void *inter_module_get(char *arg)
+{
+
+        if (strcmp(arg, "tcpnal_ni") == 0 )
+                return &tcpnal_ni;
+        else 
+                return NULL;
+
+}
+
+
 /* cheats for now */
 
 struct work_struct { 
@@ -43,7 +61,10 @@ static inline void schedule_work(struct work_struct *q)
 
 
 #define strnlen(a,b) strlen(a)
-#define kmalloc(a,b) malloc(a)
+static inline void *kmalloc(int size, int prot)
+{
+        return malloc(size);
+}
 #define vmalloc malloc
 #define vfree free
 #define kfree(a) free(a)
@@ -94,7 +115,16 @@ static inline int misc_register(void *foo)
 #define MOD_INC_USE_COUNT  do {int a = 1; a++; } while (0)
 #define MOD_DEC_USE_COUNT  do {int a = 1; a++; } while (0)
 
+/* module initialization */
+extern int init_obdclass(void);
+extern int ptlrpc_init(void);
+extern int ldlm_init(void);
+extern int osc_init(void);
+extern int echo_client_init(void);
+
+
 /* general stuff */
+#define jiffies 0
 
 #define EXPORT_SYMBOL(S)  
 
@@ -105,6 +135,14 @@ typedef __u64 kdev_t;
 #define spin_lock(l) do {int a = 1; a++; } while (0)
 #define spin_unlock(l) do {int a= 1; a++; } while (0)
 #define spin_lock_init(l) do {int a= 1; a++; } while (0)
+static inline void spin_lock_bh(spinlock_t *l)
+{
+        return;
+}
+static inline void spin_unlock_bh(spinlock_t *l)
+{
+        return;
+}
 static inline void spin_lock_irqrestore(a,b)
 {
         return;
@@ -121,8 +159,6 @@ static inline void spin_lock_irqsave(a,b)
 #define barrier() do {int a= 1; a++; } while (0)
 
 /* registering symbols */
-extern void *inter_module_get(char *name);
-extern void inter_module_put(char *name);
 
 #define ERESTARTSYS ERESTART
 #define HZ 1
@@ -160,7 +196,7 @@ static inline int copy_to_user(void *a,void *b, int c)
 typedef struct { 
          int size;
 } kmem_cache_t;
-
+#define SLAB_HWCACHE_ALIGN 0
 static inline kmem_cache_t *kmem_cache_create(name,objsize,c,d,e,f)
 {
         return malloc(objsize);
@@ -312,8 +348,35 @@ static inline int call_usermodehelper(char *prog, char **argv, char **evnp)
 
 struct timer_list { 
         struct list_head tl_list;
+        void (*function)(unsigned long unused);
+        void *data;
+        int expires;
 };
 
+static inline int timer_pending(struct timer_list *l)
+{
+        if (l->expires > jiffies)
+                return 1;
+        else 
+                return 0;
+}
+
+static inline int init_timer(struct timer_list *l)
+{
+        INIT_LIST_HEAD(&l->tl_list);
+}
+
+static inline void mod_timer(struct timer_list *l, int thetime)
+{
+        l->expires = thetime;
+
+}
+
+static inline void del_timer(struct timer_list *l)
+{
+        free(l);
+}
+
 typedef struct { volatile int counter; } atomic_t;
 
 #define atomic_read(a) ((a)->counter)
diff --git a/lustre/liblustre/Makefile.am b/lustre/liblustre/Makefile.am
new file mode 100644 (file)
index 0000000..b192a49
--- /dev/null
@@ -0,0 +1,14 @@
+# Administration utilities Makefile
+DEFS=
+
+CFLAGS:=-g -O2 -I$(top_srcdir)/utils -I$(PORTALS)/include  -I$(srcdir)/../include -Wall -L$(PORTALSLIB)
+
+KFLAGS:=
+CPPFLAGS = $(HAVE_LIBREADLINE)
+LIBS= 
+
+libtest_LDADD := $(LIBREADLINE) ../obdecho/libobdecho.a ../osc/libosc.a ../ldlm/libldlm.a ../ptlrpc/libptlrpc.a ../obdclass/liblustreclass.a  $(PORTALS)/user/procbridge/libprocbridge.a  $(PORTALS)/user/tcpnal/libtcpnal.a $(PORTALS)/user/util/libtcpnalutil.a $(PORTALS)/user/$(PORTALS)/api/libptlapi.a $(PORTALS)/lib/libptllib.a -lpthread -lefence
+bin_PROGRAMS = libtest
+libtest_SOURCES = libtest.c
+
+include $(top_srcdir)/Rules
diff --git a/lustre/liblustre/libtest.c b/lustre/liblustre/libtest.c
new file mode 100644 (file)
index 0000000..aeb3b91
--- /dev/null
@@ -0,0 +1,84 @@
+#include <stdio.h>
+
+#include <liblustre.h>
+#include <../user/procbridge/procbridge.h>
+
+ptl_handle_ni_t         tcpnal_ni;
+
+struct pingcli_args {
+        ptl_nid_t mynid;
+        ptl_nid_t nid;
+       ptl_pid_t port;
+        int count;
+        int size;
+};
+
+struct task_struct *current;
+
+/* portals interfaces */
+inline const ptl_handle_ni_t *
+kportal_get_ni (int nal)
+{
+        return &tcpnal_ni;
+}
+
+inline void
+kportal_put_ni (int nal)
+{
+        return;
+}
+
+void init_current(int argc, char **argv)
+{ 
+        current = malloc(sizeof(*current));
+        strncpy(current->comm, argv[0], sizeof(current->comm));
+        current->pid = getpid();
+
+}
+
+int init_lib_portals(struct pingcli_args *args)
+{
+        int rc;
+
+        PtlInit();
+
+        rc = PtlNIInit(procbridge_interface, 0, 0, args->mynid, &tcpnal_ni);
+        if (rc != 0) {
+                CERROR("ksocknal: PtlNIInit failed: error %d\n", rc);
+                PtlFini();
+                RETURN (rc);
+        }
+        PtlNIDebug(tcpnal_ni, ~0);
+        return rc;
+}
+
+int main(int arc, char **argv) 
+{
+        struct pingcli_args *args;
+       args= malloc(sizeof(*args));
+        if (!args) { 
+                printf("Malloc error\n");
+                exit(1);
+        }
+
+        args->mynid = atoi(argv[1]);
+        args->nid = atoi(argv[2]);
+       args->port = 9999;
+       args->count = atoi(argv[3]);
+       args->size = atoi(argv[4]);
+
+        init_obdclass();
+        init_lib_portals(args);
+        ptlrpc_init();
+        ldlm_init();
+        osc_init();
+        echo_client_init();
+        /* XXX  lov and mdc are next */
+
+        /* XXX RR parse an lctl dump file here */
+        /* XXX RR parse dumpfile here with obdclass/class_obd.c ioct command */
+
+        printf("Hello\n");
+        return 0;
+}
+
index f0987c4..01dd75b 100644 (file)
  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#define DEBUG_SUBSYSTEM S_PORTALS
+#ifdef __KERNEL__
 #include <linux/types.h>
 #include <linux/random.h>
+#else 
+#include <liblustre.h>
+#endif 
 
-#define DEBUG_SUBSYSTEM S_PORTALS
 
 #include <linux/kp30.h>
 #include <linux/lustre_handles.h>