Whamcloud - gitweb
6c6ac1db559ff7edc78b1e355f743148e0cc91d0
[fs/lustre-release.git] / lustre / include / liblustre.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2001 Cluster File Systems, Inc. <info@clusterfs.com>
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
8  *   Lustre is free software; you can redistribute it and/or
9  *   modify it under the terms of version 2 of the GNU General Public
10  *   License as published by the Free Software Foundation.
11  *
12  *   Lustre is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with Lustre; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  *
21  * User-space Lustre headers.
22  *
23  */
24 #ifndef LIBLUSTRE_H__
25 #define LIBLUSTRE_H__
26
27 #include <sys/mman.h>
28 #ifndef  __CYGWIN__
29 #include <stdint.h>
30 #include <asm/page.h>
31 #else
32 #include <sys/types.h>
33 #include "ioctl.h"
34 #endif
35 #include <stdio.h>
36 #include <sys/ioctl.h>
37 #include <stdlib.h>
38 #include <string.h>
39 #include <errno.h>
40 #include <sys/stat.h>
41 #include <sys/vfs.h>
42
43 #include <portals/list.h>
44 #include <portals/p30.h>
45 #include <linux/kp30.h>
46
47 /* definitions for liblustre */
48
49 #ifdef __CYGWIN__
50
51 #define PAGE_SHIFT 12
52 #define PAGE_SIZE (1UL << PAGE_SHIFT)
53 #define PAGE_MASK (~(PAGE_SIZE-1))
54 #define loff_t __u64
55 #define ERESTART 2001
56 typedef unsigned short umode_t;
57
58 #endif
59
60 /* This is because lprocfs_status.h gets included here indirectly.  It would
61  * be much better to just avoid lprocfs being included into liblustre entirely
62  * but that requires more header surgery than I can handle right now.
63  */
64 #ifndef smp_processor_id
65 #define smp_processor_id() 0
66 #endif
67
68 /* always adopt 2.5 definitions */
69 #define KERNEL_VERSION(a,b,c) ((a)*100+(b)*10+c)
70 #define LINUX_VERSION_CODE (2*200+5*10+0)
71
72 static inline void inter_module_put(void *a)
73 {
74         return;
75 }
76
77 extern ptl_handle_ni_t         tcpnal_ni;
78
79 void *inter_module_get(char *arg);
80
81 /* cheats for now */
82
83 struct work_struct {
84         void (*ws_task)(void *arg);
85         void *ws_arg;
86 };
87
88 static inline void prepare_work(struct work_struct *q, void (*t)(void *),
89                                 void *arg)
90 {
91         q->ws_task = t;
92         q->ws_arg = arg;
93         return;
94 }
95
96 static inline void schedule_work(struct work_struct *q)
97 {
98         q->ws_task(q->ws_arg);
99 }
100
101
102 #define strnlen(a,b) strlen(a)
103 static inline void *kmalloc(int size, int prot)
104 {
105         return malloc(size);
106 }
107 #define vmalloc malloc
108 #define vfree free
109 #define kfree(a) free(a)
110 #define GFP_KERNEL 1
111 #define GFP_HIGHUSER 1
112 #define GFP_ATOMIC 1
113 #define GFP_NOFS 1
114 #define IS_ERR(a) (((a) && abs((int)(a)) < 500) ? 1 : 0)
115 #define PTR_ERR(a) ((int)(a))
116 #define ERR_PTR(a) ((void*)(a))
117
118 #define capable(foo) 1
119 #define CAP_SYS_ADMIN 1
120
121 typedef struct {
122         void *cwd;
123
124 }mm_segment_t;
125
126 typedef int (read_proc_t)(char *page, char **start, off_t off,
127                           int count, int *eof, void *data);
128
129 struct file; /* forward ref */
130 typedef int (write_proc_t)(struct file *file, const char *buffer,
131                            unsigned long count, void *data);
132
133 /* byteorder */
134 #define __swab16(x) \
135 ({ \
136         __u16 __x = (x); \
137         ((__u16)( \
138                 (((__u16)(__x) & (__u16)0x00ffU) << 8) | \
139                 (((__u16)(__x) & (__u16)0xff00U) >> 8) )); \
140 })
141
142 #define __swab32(x) \
143 ({ \
144         __u32 __x = (x); \
145         ((__u32)( \
146                 (((__u32)(__x) & (__u32)0x000000ffUL) << 24) | \
147                 (((__u32)(__x) & (__u32)0x0000ff00UL) <<  8) | \
148                 (((__u32)(__x) & (__u32)0x00ff0000UL) >>  8) | \
149                 (((__u32)(__x) & (__u32)0xff000000UL) >> 24) )); \
150 })
151
152 #define __swab64(x) \
153 ({ \
154         __u64 __x = (x); \
155         ((__u64)( \
156                 (__u64)(((__u64)(__x) & (__u64)0x00000000000000ffULL) << 56) | \
157                 (__u64)(((__u64)(__x) & (__u64)0x000000000000ff00ULL) << 40) | \
158                 (__u64)(((__u64)(__x) & (__u64)0x0000000000ff0000ULL) << 24) | \
159                 (__u64)(((__u64)(__x) & (__u64)0x00000000ff000000ULL) <<  8) | \
160                 (__u64)(((__u64)(__x) & (__u64)0x000000ff00000000ULL) >>  8) | \
161                 (__u64)(((__u64)(__x) & (__u64)0x0000ff0000000000ULL) >> 24) | \
162                 (__u64)(((__u64)(__x) & (__u64)0x00ff000000000000ULL) >> 40) | \
163                 (__u64)(((__u64)(__x) & (__u64)0xff00000000000000ULL) >> 56) )); \
164 })
165
166 #define __swab16s(x)    __swab16(*(x))
167 #define __swab32s(x)    __swab32(*(x))
168 #define __swab64s(x)    __swab64(*(x))
169
170 #define __LITTLE_ENDIAN__
171 #ifdef  __LITTLE_ENDIAN__
172 # define le16_to_cpu(x) ((__u16)(x))
173 # define cpu_to_le16(x) ((__u16)(x))
174 # define le32_to_cpu(x) ((__u32)(x))
175 # define cpu_to_le32(x) ((__u32)(x))
176 # define le64_to_cpu(x) ((__u64)(x))
177 # define cpu_to_le64(x) ((__u64)(x))
178 #else
179 # define le16_to_cpu(x) __swab16(x)
180 # define cpu_to_le16(x) __swab16(x)
181 # define le32_to_cpu(x) __swab32(x)
182 # define cpu_to_le32(x) __swab32(x)
183 # define le64_to_cpu(x) __swab64(x)
184 # define cpu_to_le64(x) __swab64(x)
185 # error "do more check here!!!"
186 #endif
187
188 #define NIPQUAD(addr) \
189         ((unsigned char *)&addr)[0], \
190         ((unsigned char *)&addr)[1], \
191         ((unsigned char *)&addr)[2], \
192         ((unsigned char *)&addr)[3]
193                                                                                                                         
194 #if defined(__LITTLE_ENDIAN__)
195 #define HIPQUAD(addr) \
196         ((unsigned char *)&addr)[3], \
197         ((unsigned char *)&addr)[2], \
198         ((unsigned char *)&addr)[1], \
199         ((unsigned char *)&addr)[0]
200 #elif defined(__BIG_ENDIAN__)
201 #define HIPQUAD NIPQUAD
202 #else
203 #error "Please fix asm/byteorder.h"
204 #endif /* __LITTLE_ENDIAN__ */
205
206 /* bits ops */
207 static __inline__ int set_bit(int nr,long * addr)
208 {
209         int     mask, retval;
210
211         addr += nr >> 5;
212         mask = 1 << (nr & 0x1f);
213         retval = (mask & *addr) != 0;
214         *addr |= mask;
215         return retval;
216 }
217
218 static __inline__ int clear_bit(int nr, long * addr)
219 {
220         int     mask, retval;
221
222         addr += nr >> 5;
223         mask = 1 << (nr & 0x1f);
224         retval = (mask & *addr) != 0;
225         *addr &= ~mask;
226         return retval;
227 }
228
229 static __inline__ int test_bit(int nr, long * addr)
230 {
231         int     mask;
232
233         addr += nr >> 5;
234         mask = 1 << (nr & 0x1f);
235         return ((mask & *addr) != 0);
236 }
237
238 static __inline__ int ext2_set_bit(int nr, void *addr)
239 {
240         return set_bit(nr, (long*)addr);
241 }
242
243 static __inline__ int ext2_clear_bit(int nr, void *addr)
244 {
245         return clear_bit(nr, (long*)addr);
246 }
247
248 static __inline__ int ext2_test_bit(int nr, void *addr)
249 {
250         return test_bit(nr, (long*)addr);
251 }
252
253 /* modules */
254
255 struct module {
256         int count;
257 };
258
259 static inline void MODULE_AUTHOR(char *name)
260 {
261         printf("%s\n", name);
262 }
263 #define MODULE_DESCRIPTION(name) MODULE_AUTHOR(name)
264 #define MODULE_LICENSE(name) MODULE_AUTHOR(name)
265
266 #define THIS_MODULE NULL
267 #define __init
268 #define __exit
269
270 /* devices */
271
272 static inline int misc_register(void *foo)
273 {
274         return 0;
275 }
276
277 static inline int misc_deregister(void *foo)
278 {
279         return 0;
280 }
281
282 static inline int request_module(char *name)
283 {
284         return (-EINVAL);
285 }
286
287 #define __MOD_INC_USE_COUNT(m)  do {int a = 1; a++; } while (0)
288 #define __MOD_DEC_USE_COUNT(m)  do {int a = 1; a++; } while (0)
289 #define MOD_INC_USE_COUNT  do {int a = 1; a++; } while (0)
290 #define MOD_DEC_USE_COUNT  do {int a = 1; a++; } while (0)
291 #define try_module_get                  __MOD_INC_USE_COUNT
292 #define module_put                      __MOD_DEC_USE_COUNT
293
294 /* module initialization */
295 extern int init_obdclass(void);
296 extern int ptlrpc_init(void);
297 extern int ldlm_init(void);
298 extern int osc_init(void);
299 extern int lov_init(void);
300 extern int mdc_init(void);
301 extern int echo_client_init(void);
302
303
304
305 /* general stuff */
306 #define jiffies 0
307
308 #define EXPORT_SYMBOL(S)
309
310 typedef int spinlock_t;
311 typedef __u64 kdev_t;
312
313 #define SPIN_LOCK_UNLOCKED 0
314 static inline void spin_lock(spinlock_t *l) {return;}
315 static inline void spin_unlock(spinlock_t *l) {return;}
316 static inline void spin_lock_init(spinlock_t *l) {return;}
317 static inline void local_irq_save(unsigned long flag) {return;}
318 static inline void local_irq_restore(unsigned long flag) {return;}
319 static inline int spin_is_locked(spinlock_t *l) {return 1;}
320
321 static inline void spin_lock_bh(spinlock_t *l)
322 {
323         return;
324 }
325 static inline void spin_unlock_bh(spinlock_t *l)
326 {
327         return;
328 }
329 static inline void spin_unlock_irqrestore(spinlock_t *a, unsigned long b)
330 {
331         return;
332 }
333 static inline void spin_lock_irqsave(spinlock_t *a, unsigned long b)
334 {
335         return;
336 }
337
338 #define min(x,y) ((x)<(y) ? (x) : (y))
339 #define max(x,y) ((x)>(y) ? (x) : (y))
340
341 #ifndef min_t
342 #define min_t(type,x,y) \
343         ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
344 #endif
345 #ifndef max_t
346 #define max_t(type,x,y) \
347         ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
348 #endif
349
350 /* registering symbols */
351
352 #define ERESTARTSYS ERESTART
353 #define HZ 1
354
355 /* random */
356
357 static inline void get_random_bytes(void *ptr, int size)
358 {
359         int *p = (int *)ptr;
360         int i, count = size/sizeof(int);
361
362         for (i = 0; i< count; i++)
363                 *p++ = rand();
364 }
365
366 /* memory */
367
368 /* FIXME */
369 #define num_physpages (16 * 1024)
370
371 static inline int copy_from_user(void *a,void *b, int c)
372 {
373         memcpy(a,b,c);
374         return 0;
375 }
376
377 static inline int copy_to_user(void *a,void *b, int c)
378 {
379         memcpy(a,b,c);
380         return 0;
381 }
382
383
384 /* slabs */
385 typedef struct {
386          int size;
387 } kmem_cache_t;
388 #define SLAB_HWCACHE_ALIGN 0
389 static inline kmem_cache_t *
390 kmem_cache_create(const char *name, size_t objsize, size_t cdum,
391                   unsigned long d,
392                   void (*e)(void *, kmem_cache_t *, unsigned long),
393                   void (*f)(void *, kmem_cache_t *, unsigned long))
394 {
395         kmem_cache_t *c;
396         c = malloc(sizeof(*c));
397         if (!c)
398                 return NULL;
399         c->size = objsize;
400         CDEBUG(D_MALLOC, "alloc slab cache %s at %p, objsize %d\n",
401                name, c, (int)objsize);
402         return c;
403 };
404
405 static inline int kmem_cache_destroy(kmem_cache_t *a)
406 {
407         CDEBUG(D_MALLOC, "destroy slab cache %p, objsize %u\n", a, a->size);
408         free(a);
409         return 0;
410 }
411 #define kmem_cache_alloc(cache, prio) malloc(cache->size)
412 #define kmem_cache_free(cache, obj) free(obj)
413
414 #define PAGE_CACHE_SIZE PAGE_SIZE
415 #define PAGE_CACHE_SHIFT 12
416 #define PAGE_CACHE_MASK PAGE_MASK
417
418 struct page {
419         void   *addr;
420         unsigned long index;
421         struct list_head list;
422         unsigned long private;
423
424         /* internally used by liblustre file i/o */
425         int     _offset;
426         int     _count;
427 };
428
429 #define kmap(page) (page)->addr
430 #define kunmap(a) do { int foo = 1; foo++; } while (0)
431
432 static inline struct page *alloc_pages(int mask, unsigned long order)
433 {
434         struct page *pg = malloc(sizeof(*pg));
435
436         if (!pg)
437                 return NULL;
438 #if 0 //#ifdef MAP_ANONYMOUS
439         pg->addr = mmap(0, PAGE_SIZE << order, PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
440 #else
441         pg->addr = malloc(PAGE_SIZE << order);
442 #endif
443
444         if (!pg->addr) {
445                 free(pg);
446                 return NULL;
447         }
448         return pg;
449 }
450
451 #define alloc_page(mask) alloc_pages((mask), 0)
452
453 static inline void __free_pages(struct page *pg, int what)
454 {
455 #if 0 //#ifdef MAP_ANONYMOUS
456         munmap(pg->addr, PAGE_SIZE);
457 #else
458         free(pg->addr);
459 #endif
460         free(pg);
461 }
462
463 #define __free_page(page) __free_pages((page), 0)
464
465 static inline struct page* __grab_cache_page(unsigned long index)
466 {
467         struct page *pg = alloc_pages(0, 0);
468
469         if (pg)
470                 pg->index = index;
471         return pg;
472 }
473
474 #define grab_cache_page(index) __grab_cache_page(index)
475 #define page_cache_release(page) __free_pages(page, 0)
476
477 /* arithmetic */
478 #define do_div(a,b)                     \
479         ({                              \
480                 unsigned long remainder;\
481                 remainder = (a) % (b);  \
482                 (a) = (a) / (b);        \
483                 (remainder);            \
484         })
485
486 /* VFS stuff */
487 #define ATTR_MODE       0x0001
488 #define ATTR_UID        0x0002
489 #define ATTR_GID        0x0004
490 #define ATTR_SIZE       0x0008
491 #define ATTR_ATIME      0x0010
492 #define ATTR_MTIME      0x0020
493 #define ATTR_CTIME      0x0040
494 #define ATTR_ATIME_SET  0x0080
495 #define ATTR_MTIME_SET  0x0100
496 #define ATTR_FORCE      0x0200  /* Not a change, but a change it */
497 #define ATTR_ATTR_FLAG  0x0400
498 #define ATTR_RAW        0x0800  /* file system, not vfs will massage attrs */
499 #define ATTR_FROM_OPEN  0x1000  /* called from open path, ie O_TRUNC */
500 #define ATTR_CTIME_SET  0x2000
501
502 struct iattr {
503         unsigned int    ia_valid;
504         umode_t         ia_mode;
505         uid_t           ia_uid;
506         gid_t           ia_gid;
507         loff_t          ia_size;
508         time_t          ia_atime;
509         time_t          ia_mtime;
510         time_t          ia_ctime;
511         unsigned int    ia_attr_flags;
512 };
513
514 #define IT_OPEN     0x0001
515 #define IT_CREAT    0x0002
516 #define IT_READDIR  0x0004
517 #define IT_GETATTR  0x0008
518 #define IT_LOOKUP   0x0010
519 #define IT_UNLINK   0x0020
520 #define IT_GETXATTR 0x0040
521 #define IT_EXEC     0x0080
522 #define IT_PIN      0x0100
523
524 #define IT_FL_LOCKED   0x0001
525 #define IT_FL_FOLLOWED 0x0002 /* set by vfs_follow_link */
526
527 #define INTENT_MAGIC 0x19620323
528
529 struct lustre_intent_data {
530         int       it_disposition;
531         int       it_status;
532         __u64     it_lock_handle;
533         void     *it_data;
534         int       it_lock_mode;
535         int it_int_flags;
536 };
537 struct lookup_intent {
538         int     it_magic;
539         void    (*it_op_release)(struct lookup_intent *);
540         int     it_op;
541         int     it_flags;
542         int     it_create_mode;
543         union {
544                 struct lustre_intent_data lustre;
545         } d;
546 };
547
548 static inline void intent_init(struct lookup_intent *it, int op, int flags)
549 {
550         memset(it, 0, sizeof(*it));
551         it->it_magic = INTENT_MAGIC;
552         it->it_op = op;
553         it->it_flags = flags;
554 }
555
556
557 struct dentry {
558         int d_count;
559 };
560
561 struct vfsmount {
562         void *pwd;
563 };
564
565 #define cpu_to_le32(x) ((__u32)(x))
566
567 /* semaphores */
568 struct rw_semaphore {
569         int count;
570 };
571
572 /* semaphores */
573 struct semaphore {
574         int count;
575 };
576
577 #define down(a) do {(a)->count++;} while (0)
578 #define up(a) do {(a)->count--;} while (0)
579 #define down_read(a) do {(a)->count++;} while (0)
580 #define up_read(a) do {(a)->count--;} while (0)
581 #define down_write(a) do {(a)->count++;} while (0)
582 #define up_write(a) do {(a)->count--;} while (0)
583 #define sema_init(a,b) do { (a)->count = b; } while (0)
584 #define init_rwsem(a) do {} while (0)
585 #define DECLARE_MUTEX(name)     \
586         struct semaphore name = { 1 }
587 static inline void init_MUTEX (struct semaphore *sem)
588 {
589         sema_init(sem, 1);
590 }
591
592
593 typedef struct  {
594         struct list_head sleepers;
595 } wait_queue_head_t;
596
597 typedef struct  {
598         struct list_head sleeping;
599         void *process;
600 } wait_queue_t;
601
602 struct signal {
603         int signal;
604 };
605
606 struct fs_struct {
607         int umask;
608 };
609
610 struct task_struct {
611         struct fs_struct *fs;
612         int state;
613         struct signal pending;
614         char comm[32];
615         int pid;
616         int fsuid;
617         int fsgid;
618         __u32 cap_effective;
619 };
620
621 extern struct task_struct *current;
622
623 #define in_group_p(a) 0 /* FIXME */
624
625 #define set_current_state(foo) do { current->state = foo; } while (0)
626
627 #define init_waitqueue_entry(q,p) do { (q)->process = p; } while (0)
628 #define add_wait_queue(q,p) do {  list_add(&(q)->sleepers, &(p)->sleeping); } while (0)
629 #define del_wait_queue(p) do { list_del(&(p)->sleeping); } while (0)
630 #define remove_wait_queue(q,p) do { list_del(&(p)->sleeping); } while (0)
631
632 #define init_waitqueue_head(l) INIT_LIST_HEAD(&(l)->sleepers)
633 #define wake_up(l) do { int a; a++; } while (0)
634 #define TASK_INTERRUPTIBLE 0
635 #define TASK_UNINTERRUPTIBLE 1
636 #define TASK_RUNNING 2
637
638 #define wait_event_interruptible(wq, condition)                         \
639 ({                                                                      \
640         struct l_wait_info lwi;                                         \
641         int timeout = 100000000;/* for ever */                          \
642         int ret;                                                        \
643                                                                         \
644         lwi = LWI_TIMEOUT(timeout, NULL, NULL);                         \
645         ret = l_wait_event(NULL, condition, &lwi);                      \
646                                                                         \
647         ret;                                                            \
648 })
649
650 #define in_interrupt() (0)
651
652 #define schedule() do { int a; a++; } while (0)
653 static inline int schedule_timeout(signed long t)
654 {
655         return 0;
656 }
657
658 #define lock_kernel() do { int a; a++; } while (0)
659 #define daemonize(l) do { int a; a++; } while (0)
660 #define sigfillset(l) do { int a; a++; } while (0)
661 #define recalc_sigpending(l) do { int a; a++; } while (0)
662 #define kernel_thread(l,m,n) LBUG()
663
664 #define USERMODEHELPER(path, argv, envp) (0)
665
666 static inline int call_usermodehelper(char *prog, char **argv, char **evnp, int unknown)
667 {
668         return 0;
669 }
670
671
672 #define SIGNAL_MASK_ASSERT()
673
674 #define KERN_INFO
675
676
677
678 struct timer_list {
679         struct list_head tl_list;
680         void (*function)(unsigned long unused);
681         unsigned long data;
682         long expires;
683 };
684
685 static inline int timer_pending(struct timer_list *l)
686 {
687         if (l->expires > jiffies)
688                 return 1;
689         else
690                 return 0;
691 }
692
693 static inline int init_timer(struct timer_list *l)
694 {
695         INIT_LIST_HEAD(&l->tl_list);
696         return 0;
697 }
698
699 static inline void mod_timer(struct timer_list *l, int thetime)
700 {
701         l->expires = thetime;
702 }
703
704 static inline void del_timer(struct timer_list *l)
705 {
706         free(l);
707 }
708
709 typedef struct { volatile int counter; } atomic_t;
710
711 #define atomic_read(a) ((a)->counter)
712 #define atomic_set(a,b) do {(a)->counter = b; } while (0)
713 #define atomic_dec_and_test(a) ((--((a)->counter)) == 0)
714 #define atomic_inc(a)  (((a)->counter)++)
715 #define atomic_dec(a)  do { (a)->counter--; } while (0)
716 #define atomic_add(b,a)  do {(a)->counter += b;} while (0)
717 #define atomic_sub(b,a)  do {(a)->counter -= b;} while (0)
718
719 #ifndef likely
720 #define likely(exp) (exp)
721 #endif
722 #ifndef unlikely
723 #define unlikely(exp) (exp)
724 #endif
725
726 /* log related */
727 static inline int llog_init_commit_master(void) { return 0; }
728 static inline int llog_cleanup_commit_master(int force) { return 0; }
729 static inline void portals_run_lbug_upcall(char *file, const char *fn,
730                                            const int l){}
731
732 #define LBUG()                                                          \
733         do {                                                            \
734                 printf("!!!LBUG at %s:%d\n", __FILE__, __LINE__);       \
735                 sleep(1000000);                                         \
736         } while (0)
737
738
739
740 /* completion */
741 struct completion {
742         unsigned int done;
743         wait_queue_head_t wait;
744 };
745
746 #define COMPLETION_INITIALIZER(work) \
747         { 0, __WAIT_QUEUE_HEAD_INITIALIZER((work).wait) }
748
749 #define DECLARE_COMPLETION(work) \
750         struct completion work = COMPLETION_INITIALIZER(work)
751
752 #define INIT_COMPLETION(x)      ((x).done = 0)
753
754 static inline void init_completion(struct completion *x)
755 {
756         x->done = 0;
757         init_waitqueue_head(&x->wait);
758 }
759
760 struct liblustre_wait_callback {
761         struct list_head    llwc_list;
762         int               (*llwc_fn)(void *arg);
763         void               *llwc_arg;
764 };
765
766 void *liblustre_register_wait_callback(int (*fn)(void *arg), void *arg);
767 void liblustre_deregister_wait_callback(void *notifier);
768 int liblustre_wait_event(int timeout);
769
770 #include <linux/obd_support.h>
771 #include <linux/lustre_idl.h>
772 #include <linux/lustre_lib.h>
773 #include <linux/lustre_import.h>
774 #include <linux/lustre_export.h>
775 #include <linux/lustre_net.h>
776
777
778 #endif
779