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