Whamcloud - gitweb
aa58c49678a859b0e4bfc4025d31b153052fb55e
[fs/lustre-release.git] / lustre / include / linux / lustre_lib.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. <braam@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  * Basic Lustre library routines. 
22  *
23  */
24
25 #ifndef _LUSTRE_LIB_H
26 #define _LUSTRE_LIB_H
27
28 #ifndef __KERNEL__
29 # include <string.h>
30 #else
31 # include <asm/semaphore.h>
32 #endif
33 #include <linux/types.h>
34 #include <linux/portals_lib.h>
35 #include <linux/kp30.h> /* XXX just for LASSERT! */
36 #include <linux/lustre_idl.h>
37
38 #ifndef LPU64
39 #if BITS_PER_LONG > 32
40 #define LPU64 "%lu"
41 #define LPD64 "%ld"
42 #define LPX64 "%#lx"
43 #else
44 #define LPU64 "%Lu"
45 #define LPD64 "%Ld"
46 #define LPX64 "%#Lx"
47 #endif
48 #endif
49
50 #ifdef __KERNEL__
51 /* l_net.c */
52 struct ptlrpc_request;
53 struct obd_device;
54 struct recovd_data;
55 struct recovd_obd;
56 #include <linux/lustre_ha.h>
57
58 int target_handle_connect(struct ptlrpc_request *req);
59 int target_handle_disconnect(struct ptlrpc_request *req);
60 int client_obd_connect(struct lustre_handle *conn, struct obd_device *obd,
61                        obd_uuid_t cluuid, struct recovd_obd *recovd,
62                        ptlrpc_recovery_cb_t recover);
63 int client_obd_disconnect(struct lustre_handle *conn);
64 int client_obd_setup(struct obd_device *obddev, obd_count len, void *buf);
65 int client_obd_cleanup(struct obd_device * obddev);
66 struct client_obd *client_conn2cli(struct lustre_handle *conn); 
67 struct obd_device *client_tgtuuid2obd(char *tgtuuid);
68
69 int target_revoke_connection(struct recovd_data *rd, int phase);
70
71 /* l_lock.c */
72 struct lustre_lock { 
73         int l_depth;
74         struct task_struct *l_owner;
75         struct semaphore l_sem;
76         spinlock_t l_spin;
77 };
78
79 void l_lock_init(struct lustre_lock *);
80 void l_lock(struct lustre_lock *);
81 void l_unlock(struct lustre_lock *);
82 int l_has_lock(struct lustre_lock *);
83
84 #define CB_PHASE_START   12
85 #define CB_PHASE_FINISH  13
86
87 /* This list head doesn't need to be locked, because it's only manipulated by
88  * one thread at a time. */
89 struct obd_brw_set {
90         struct list_head brw_desc_head; /* list of ptlrpc_bulk_desc */
91         wait_queue_head_t brw_waitq;
92         atomic_t brw_refcount;
93         int brw_flags;
94
95         int (*brw_callback)(struct obd_brw_set *, int phase);
96 };
97
98 /* simple.c */
99 struct obd_run_ctxt;
100 struct obd_ucred;
101 void push_ctxt(struct obd_run_ctxt *save, struct obd_run_ctxt *new_ctx,
102                struct obd_ucred *cred);
103 void pop_ctxt(struct obd_run_ctxt *saved, struct obd_run_ctxt *new_ctx,
104               struct obd_ucred *cred);
105 struct dentry *simple_mkdir(struct dentry *dir, char *name, int mode);
106 struct dentry *simple_mknod(struct dentry *dir, char *name, int mode);
107 int lustre_fread(struct file *file, char *str, int len, loff_t *off);
108 int lustre_fwrite(struct file *file, const char *str, int len, loff_t *off);
109 int lustre_fsync(struct file *file);
110
111 static inline void l_dput(struct dentry *de)
112 {
113         if (!de || IS_ERR(de))
114                 return;
115         shrink_dcache_parent(de);
116         LASSERT(atomic_read(&de->d_count) > 0);
117         dput(de);
118 }
119
120 static inline void ll_sleep(int t)
121 {
122         set_current_state(TASK_INTERRUPTIBLE);
123         schedule_timeout(t * HZ);
124         set_current_state(TASK_RUNNING);
125 }
126 #endif
127
128 /* FIXME: This needs to validate pointers and cookies */
129 static inline void *lustre_handle2object(struct lustre_handle *handle)
130 {
131         if (handle) 
132                 return (void *)(unsigned long)(handle->addr);
133         return NULL; 
134 }
135
136 static inline void ldlm_object2handle(void *object, struct lustre_handle *handle)
137 {
138         handle->addr = (__u64)(unsigned long)object;
139 }
140
141 struct obd_statfs;
142 struct statfs;
143 void statfs_pack(struct obd_statfs *osfs, struct statfs *sfs);
144 void statfs_unpack(struct statfs *sfs, struct obd_statfs *osfs);
145 void obd_statfs_pack(struct obd_statfs *tgt, struct obd_statfs *src);
146 static inline void
147 obd_statfs_unpack(struct obd_statfs *tgt, struct obd_statfs *src)
148 {
149         obd_statfs_pack(tgt, src);
150 }
151
152 #include <linux/portals_lib.h>
153
154 /*
155  *   OBD IOCTLS
156  */
157 #define OBD_IOCTL_VERSION 0x00010001
158
159 struct obd_ioctl_data {
160         uint32_t ioc_len;
161         uint32_t ioc_version;
162
163         uint64_t ioc_addr;
164         uint64_t ioc_cookie;
165         uint32_t ioc_conn1;
166         uint32_t ioc_conn2;
167
168         struct obdo ioc_obdo1;
169         struct obdo ioc_obdo2;
170
171         obd_size         ioc_count;
172         obd_off          ioc_offset;
173         uint32_t         ioc_dev;
174         uint32_t         ____padding;
175
176         /* buffers the kernel will treat as user pointers */
177         uint32_t ioc_plen1;
178         char    *ioc_pbuf1;
179         uint32_t ioc_plen2;
180         char    *ioc_pbuf2;
181
182         /* two inline buffers */
183         uint32_t ioc_inllen1;
184         char    *ioc_inlbuf1;
185         uint32_t ioc_inllen2;
186         char    *ioc_inlbuf2;
187         uint32_t ioc_inllen3;
188         char    *ioc_inlbuf3;
189
190         char    ioc_bulk[0];
191 };
192
193 struct obd_ioctl_hdr {
194         uint32_t ioc_len;
195         uint32_t ioc_version;
196 };
197
198 static inline int obd_ioctl_packlen(struct obd_ioctl_data *data)
199 {
200         int len = size_round(sizeof(struct obd_ioctl_data));
201         len += size_round(data->ioc_inllen1);
202         len += size_round(data->ioc_inllen2);
203         len += size_round(data->ioc_inllen3);
204         return len;
205 }
206
207
208 static inline int obd_ioctl_is_invalid(struct obd_ioctl_data *data)
209 {
210         if (data->ioc_len > (1<<30)) {
211                 printk("OBD ioctl: ioc_len larger than 1<<30\n");
212                 return 1;
213         }
214         if (data->ioc_inllen1 > (1<<30)) {
215                 printk("OBD ioctl: ioc_inllen1 larger than 1<<30\n");
216                 return 1;
217         }
218         if (data->ioc_inllen2 > (1<<30)) {
219                 printk("OBD ioctl: ioc_inllen2 larger than 1<<30\n");
220                 return 1;
221         }
222
223         if (data->ioc_inllen3 > (1<<30)) {
224                 printk("OBD ioctl: ioc_inllen3 larger than 1<<30\n");
225                 return 1;
226         }
227         if (data->ioc_inlbuf1 && !data->ioc_inllen1) {
228                 printk("OBD ioctl: inlbuf1 pointer but 0 length\n");
229                 return 1;
230         }
231         if (data->ioc_inlbuf2 && !data->ioc_inllen2) {
232                 printk("OBD ioctl: inlbuf2 pointer but 0 length\n");
233                 return 1;
234         }
235         if (data->ioc_inlbuf3 && !data->ioc_inllen3) {
236                 printk("OBD ioctl: inlbuf3 pointer but 0 length\n");
237                 return 1;
238         }
239         if (data->ioc_pbuf1 && !data->ioc_plen1) {
240                 printk("OBD ioctl: pbuf1 pointer but 0 length\n");
241                 return 1;
242         }
243         if (data->ioc_pbuf2 && !data->ioc_plen2) {
244                 printk("OBD ioctl: pbuf2 pointer but 0 length\n");
245                 return 1;
246         }
247         /*
248         if (data->ioc_inllen1 && !data->ioc_inlbuf1) {
249                 printk("OBD ioctl: inllen1 set but NULL pointer\n");
250                 return 1;
251         }
252         if (data->ioc_inllen2 && !data->ioc_inlbuf2) {
253                 printk("OBD ioctl: inllen2 set but NULL pointer\n");
254                 return 1;
255         }
256         if (data->ioc_inllen3 && !data->ioc_inlbuf3) {
257                 printk("OBD ioctl: inllen3 set but NULL pointer\n");
258                 return 1;
259         }
260         */
261         if (data->ioc_plen1 && !data->ioc_pbuf1) {
262                 printk("OBD ioctl: plen1 set but NULL pointer\n");
263                 return 1;
264         }
265         if (data->ioc_plen2 && !data->ioc_pbuf2) {
266                 printk("OBD ioctl: plen2 set but NULL pointer\n");
267                 return 1;
268         }
269         if (obd_ioctl_packlen(data) != data->ioc_len ) {
270                 printk("OBD ioctl: packlen exceeds ioc_len\n");
271                 return 1;
272         }
273 #if 0
274         if (data->ioc_inllen1 &&
275             data->ioc_bulk[data->ioc_inllen1 - 1] != '\0') {
276                 printk("OBD ioctl: inlbuf1 not 0 terminated\n");
277                 return 1;
278         }
279         if (data->ioc_inllen2 &&
280             data->ioc_bulk[size_round(data->ioc_inllen1) + data->ioc_inllen2 - 1] != '\0') {
281                 printk("OBD ioctl: inlbuf2 not 0 terminated\n");
282                 return 1;
283         }
284         if (data->ioc_inllen3 &&
285             data->ioc_bulk[size_round(data->ioc_inllen1) + size_round(data->ioc_inllen2)
286                            + data->ioc_inllen3 - 1] != '\0') {
287                 printk("OBD ioctl: inlbuf3 not 0 terminated\n");
288                 return 1;
289         }
290 #endif 
291         return 0;
292 }
293
294 #ifndef __KERNEL__
295 static inline int obd_ioctl_pack(struct obd_ioctl_data *data, char **pbuf,
296                                  int max)
297 {
298         char *ptr;
299         struct obd_ioctl_data *overlay;
300         data->ioc_len = obd_ioctl_packlen(data);
301         data->ioc_version = OBD_IOCTL_VERSION;
302
303         if (*pbuf && data->ioc_len > max)
304                 return 1;
305         if (*pbuf == NULL) {
306                 *pbuf = malloc(data->ioc_len);
307         }
308         if (!*pbuf)
309                 return 1;
310         overlay = (struct obd_ioctl_data *)*pbuf;
311         memcpy(*pbuf, data, sizeof(*data));
312
313         ptr = overlay->ioc_bulk;
314         if (data->ioc_inlbuf1)
315                 LOGL(data->ioc_inlbuf1, data->ioc_inllen1, ptr);
316         if (data->ioc_inlbuf2)
317                 LOGL(data->ioc_inlbuf2, data->ioc_inllen2, ptr);
318         if (data->ioc_inlbuf3)
319                 LOGL(data->ioc_inlbuf3, data->ioc_inllen3, ptr);
320         if (obd_ioctl_is_invalid(overlay))
321                 return 1;
322
323         return 0;
324 }
325
326 static inline int obd_ioctl_unpack(struct obd_ioctl_data *data, char *pbuf,
327                                    int max)
328 {
329         char *ptr;
330         struct obd_ioctl_data *overlay;
331
332         if (!pbuf)
333                 return 1;
334         overlay = (struct obd_ioctl_data *)pbuf;
335
336         /* Preserve the caller's buffer pointers */
337         overlay->ioc_inlbuf1 = data->ioc_inlbuf1;
338         overlay->ioc_inlbuf2 = data->ioc_inlbuf2;
339         overlay->ioc_inlbuf3 = data->ioc_inlbuf3;
340
341         memcpy(data, pbuf, sizeof(*data));
342
343         ptr = overlay->ioc_bulk;
344         if (data->ioc_inlbuf1)
345                 LOGU(data->ioc_inlbuf1, data->ioc_inllen1, ptr);
346         if (data->ioc_inlbuf2)
347                 LOGU(data->ioc_inlbuf2, data->ioc_inllen2, ptr);
348         if (data->ioc_inlbuf3)
349                 LOGU(data->ioc_inlbuf3, data->ioc_inllen3, ptr);
350
351         return 0;
352 }
353 #else
354
355 #include <linux/obd_support.h>
356
357 /* buffer MUST be at least the size of obd_ioctl_hdr */
358 static inline int obd_ioctl_getdata(char **buf, int *len, void *arg)
359 {
360         struct obd_ioctl_hdr hdr;
361         struct obd_ioctl_data *data;
362         int err;
363         ENTRY;
364
365         err = copy_from_user(&hdr, (void *)arg, sizeof(hdr));
366         if ( err ) {
367                 EXIT;
368                 return err;
369         }
370
371         if (hdr.ioc_version != OBD_IOCTL_VERSION) {
372                 printk("OBD: version mismatch kernel vs application\n");
373                 return -EINVAL;
374         }
375
376         if (hdr.ioc_len > 8192) {
377                 printk("OBD: user buffer exceeds 8192 max buffer\n");
378                 return -EINVAL;
379         }
380
381         if (hdr.ioc_len < sizeof(struct obd_ioctl_data)) {
382                 printk("OBD: user buffer too small for ioctl\n");
383                 return -EINVAL;
384         }
385
386         OBD_ALLOC(*buf, hdr.ioc_len);
387         if (!*buf) {
388                 CERROR("Cannot allocate control buffer of len %d\n",
389                        hdr.ioc_len);
390                 RETURN(-EINVAL);
391         }
392         *len = hdr.ioc_len;
393         data = (struct obd_ioctl_data *)*buf;
394
395         err = copy_from_user(*buf, (void *)arg, hdr.ioc_len);
396         if ( err ) {
397                 EXIT;
398                 return err;
399         }
400
401         if (obd_ioctl_is_invalid(data)) {
402                 printk("OBD: ioctl not correctly formatted\n");
403                 return -EINVAL;
404         }
405
406         if (data->ioc_inllen1) {
407                 data->ioc_inlbuf1 = &data->ioc_bulk[0];
408         }
409
410         if (data->ioc_inllen2) {
411                 data->ioc_inlbuf2 = &data->ioc_bulk[0] + size_round(data->ioc_inllen1);
412         }
413
414         if (data->ioc_inllen3) {
415                 data->ioc_inlbuf3 = &data->ioc_bulk[0] + size_round(data->ioc_inllen1) + 
416                         size_round(data->ioc_inllen2);
417         }
418
419         EXIT;
420         return 0;
421 }
422 #endif
423
424 #define OBD_IOC_CREATE                 _IOR ('f', 101, long)
425 #define OBD_IOC_SETUP                  _IOW ('f', 102, long)
426 #define OBD_IOC_CLEANUP                _IO  ('f', 103      )
427 #define OBD_IOC_DESTROY                _IOW ('f', 104, long)
428 #define OBD_IOC_PREALLOCATE            _IOWR('f', 105, long)
429 #define OBD_IOC_DEC_USE_COUNT          _IO  ('f', 106      )
430 #define OBD_IOC_SETATTR                _IOW ('f', 107, long)
431 #define OBD_IOC_GETATTR                _IOR ('f', 108, long)
432 #define OBD_IOC_READ                   _IOWR('f', 109, long)
433 #define OBD_IOC_WRITE                  _IOWR('f', 110, long)
434 #define OBD_IOC_CONNECT                _IOR ('f', 111, long)
435 #define OBD_IOC_DISCONNECT             _IOW ('f', 112, long)
436 #define OBD_IOC_STATFS                 _IOWR('f', 113, long)
437 #define OBD_IOC_SYNC                   _IOR ('f', 114, long)
438 #define OBD_IOC_READ2                  _IOWR('f', 115, long)
439 #define OBD_IOC_FORMAT                 _IOWR('f', 116, long)
440 #define OBD_IOC_PARTITION              _IOWR('f', 117, long)
441 #define OBD_IOC_ATTACH                 _IOWR('f', 118, long)
442 #define OBD_IOC_DETACH                 _IOWR('f', 119, long)
443 #define OBD_IOC_COPY                   _IOWR('f', 120, long)
444 #define OBD_IOC_MIGR                   _IOWR('f', 121, long)
445 #define OBD_IOC_PUNCH                  _IOWR('f', 122, long)
446 #define OBD_IOC_DEVICE                 _IOWR('f', 123, long)
447 #define OBD_IOC_MODULE_DEBUG           _IOWR('f', 124, long)
448 #define OBD_IOC_BRW_READ               _IOWR('f', 125, long)
449 #define OBD_IOC_BRW_WRITE              _IOWR('f', 126, long)
450 #define OBD_IOC_NAME2DEV               _IOWR('f', 127, long)
451 #define OBD_IOC_NEWDEV                 _IOWR('f', 128, long)
452 #define OBD_IOC_LIST                   _IOWR('f', 129, long)
453 #define OBD_IOC_UUID2DEV               _IOWR('f', 130, long)
454
455 #define OBD_IOC_RECOVD_NEWCONN         _IOWR('f', 131, long)
456 #define OBD_IOC_LOV_SET_CONFIG         _IOWR('f', 132, long)
457 #define OBD_IOC_LOV_GET_CONFIG         _IOWR('f', 133, long)
458 #define OBD_IOC_LOV_CONFIG             OBD_IOC_LOV_SET_CONFIG
459
460 #define OBD_IOC_OPEN                   _IOWR('f', 134, long)
461 #define OBD_IOC_CLOSE                  _IOWR('f', 135, long)
462
463 #define OBD_IOC_RECOVD_FAILCONN        _IOWR('f', 136, long)
464
465 #define OBD_IOC_DEC_FS_USE_COUNT       _IO  ('f', 139      )
466
467 #define OBD_GET_VERSION                _IOWR ('f', 144, long)
468
469 /*
470  * l_wait_event is a flexible sleeping function, permitting simple caller
471  * configuration of interrupt and timeout sensitivity along with actions to
472  * be performed in the event of either exception.
473  *
474  * Common usage looks like this:
475  * 
476  * struct l_wait_info lwi = LWI_TIMEOUT_INTR(timeout, timeout_handler,
477  *                                           intr_handler, callback_data);
478  * rc = l_wait_event(waitq, condition, &lwi);
479  *
480  * (LWI_TIMEOUT and LWI_INTR macros are available for timeout- and
481  * interrupt-only variants, respectively.)
482  *
483  * If a timeout is specified, the timeout_handler will be invoked in the event
484  * that the timeout expires before the process is awakened.  (Note that any
485  * waking of the process will restart the timeout, even if the condition is
486  * not satisfied and the process immediately returns to sleep.  This might be
487  * considered a bug.)  If the timeout_handler returns non-zero, l_wait_event
488  * will return -ETIMEDOUT and the caller will continue.  If the handler returns
489  * zero instead, the process will go back to sleep until it is awakened by the
490  * waitq or some similar mechanism, or an interrupt occurs (if the caller has
491  * asked for interrupts to be detected).  The timeout will only fire once, so
492  * callers should take care that a timeout_handler which returns zero will take
493  * future steps to awaken the process.  N.B. that these steps must include
494  * making the provided condition become true.
495  *
496  * If the interrupt flag (lwi_signals) is non-zero, then the process will be
497  * interruptible, and will be awakened by any "killable" signal (SIGTERM,
498  * SIGKILL or SIGINT).  If a timeout is also specified, then the process will
499  * only become interruptible _after_ the timeout has expired, though it can be
500  * awakened by a signal that was delivered before the timeout and is still
501  * pending when the timeout expires.  If a timeout is not specified, the process
502  * will be interruptible at all times during l_wait_event.
503  */
504
505 struct l_wait_info {
506         long   lwi_timeout;
507         int  (*lwi_on_timeout)(void *);
508         long   lwi_signals;
509         int  (*lwi_on_signal)(void *); /* XXX return is ignored for now */
510         void  *lwi_cb_data;
511 };
512
513 #define LWI_TIMEOUT(time, cb, data)                                            \
514 ((struct l_wait_info) {                                                        \
515         lwi_timeout:    time,                                                  \
516         lwi_on_timeout: cb,                                                    \
517         lwi_cb_data:    data                                                   \
518 })
519
520 #define LWI_INTR(cb, data)                                                     \
521 ((struct l_wait_info) {                                                        \
522         lwi_signals:   1,                                                      \
523         lwi_on_signal: cb,                                                     \
524         lwi_cb_data:   data                                                    \
525 })
526
527 #define LWI_TIMEOUT_INTR(time, time_cb, sig_cb, data)                          \
528 ((struct l_wait_info) {                                                        \
529         lwi_timeout:    time,                                                  \
530         lwi_on_timeout: time_cb,                                               \
531         lwi_signals:    1,                                                     \
532         lwi_on_signal:  sig_cb,                                                \
533         lwi_cb_data:    data                                                   \
534 })
535
536 /* XXX this should be one mask-check */
537 #define l_killable_pending(task)                                               \
538 (sigismember(&(task->pending.signal), SIGKILL) ||                              \
539  sigismember(&(task->pending.signal), SIGINT) ||                               \
540  sigismember(&(task->pending.signal), SIGTERM))
541
542 #define __l_wait_event(wq, condition, info, ret)                               \
543 do {                                                                           \
544         wait_queue_t __wait;                                                   \
545         long __state;                                                          \
546         int __timed_out = 0;                                                   \
547         init_waitqueue_entry(&__wait, current);                                \
548                                                                                \
549         add_wait_queue(&wq, &__wait);                                          \
550         if (info->lwi_signals && !info->lwi_timeout)                           \
551             __state = TASK_INTERRUPTIBLE;                                      \
552         else                                                                   \
553             __state = TASK_UNINTERRUPTIBLE;                                    \
554         for (;;) {                                                             \
555             set_current_state(__state);                                        \
556             if (condition)                                                     \
557                     break;                                                     \
558             if (__state == TASK_INTERRUPTIBLE && l_killable_pending(current)) {\
559                 if (info->lwi_on_signal)                                       \
560                         info->lwi_on_signal(info->lwi_cb_data);                \
561                 ret = -EINTR;                                                  \
562                 break;                                                         \
563             }                                                                  \
564             if (info->lwi_timeout && !__timed_out) {                           \
565                 if (schedule_timeout(info->lwi_timeout) == 0) {                \
566                     __timed_out = 1;                                           \
567                     if (!info->lwi_on_timeout ||                               \
568                         info->lwi_on_timeout(info->lwi_cb_data)) {             \
569                         ret = -ETIMEDOUT;                                      \
570                         break;                                                 \
571                     }                                                          \
572                     /* We'll take signals after a timeout. */                  \
573                     if (info->lwi_signals) {                                   \
574                         __state = TASK_INTERRUPTIBLE;                          \
575                         /* Check for a pending interrupt. */                   \
576                         if (info->lwi_signals && l_killable_pending(current)) {\
577                             if (info->lwi_on_signal)                           \
578                                 info->lwi_on_signal(info->lwi_cb_data);        \
579                             ret = -EINTR;                                      \
580                             break;                                             \
581                         }                                                      \
582                     }                                                          \
583                 }                                                              \
584             } else {                                                           \
585                 schedule();                                                    \
586             }                                                                  \
587         }                                                                      \
588         current->state = TASK_RUNNING;                                         \
589         remove_wait_queue(&wq, &__wait);                                       \
590 } while(0)
591
592 #define l_wait_event(wq, condition, info)                                      \
593 ({                                                                             \
594         int __ret = 0;                                                         \
595         struct l_wait_info *__info = (info);                                   \
596         if (!(condition))                                                      \
597                 __l_wait_event(wq, condition, __info, __ret);                  \
598         __ret;                                                                 \
599 })
600
601 #endif /* _LUSTRE_LIB_H */