From df935e999b3a0e3db0f7373d2c4b952353858aca Mon Sep 17 00:00:00 2001 From: braam Date: Fri, 21 Feb 2003 11:05:45 +0000 Subject: [PATCH] - another day of good progress with liblustre. We now have all the modules initialized, ready to start playing with lctl dumpfiles. --- lustre/include/liblustre.h | 71 +++++++++++++++++++++++++++++++-- lustre/liblustre/Makefile.am | 14 +++++++ lustre/liblustre/libtest.c | 84 ++++++++++++++++++++++++++++++++++++++++ lustre/obdclass/lustre_handles.c | 6 ++- 4 files changed, 170 insertions(+), 5 deletions(-) create mode 100644 lustre/liblustre/Makefile.am create mode 100644 lustre/liblustre/libtest.c diff --git a/lustre/include/liblustre.h b/lustre/include/liblustre.h index 7804610..668d0d5 100644 --- a/lustre/include/liblustre.h +++ b/lustre/include/liblustre.h @@ -21,6 +21,24 @@ #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 index 0000000..b192a49 --- /dev/null +++ b/lustre/liblustre/Makefile.am @@ -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 index 0000000..aeb3b91 --- /dev/null +++ b/lustre/liblustre/libtest.c @@ -0,0 +1,84 @@ +#include + +#include +#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; +} + diff --git a/lustre/obdclass/lustre_handles.c b/lustre/obdclass/lustre_handles.c index f0987c4..01dd75b 100644 --- a/lustre/obdclass/lustre_handles.c +++ b/lustre/obdclass/lustre_handles.c @@ -20,10 +20,14 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#define DEBUG_SUBSYSTEM S_PORTALS +#ifdef __KERNEL__ #include #include +#else +#include +#endif -#define DEBUG_SUBSYSTEM S_PORTALS #include #include -- 1.8.3.1