Whamcloud - gitweb
* Change mds_client_info to mds_export_data and embed it in obd_export.
[fs/lustre-release.git] / lustre / include / linux / lustre_lib.h
index 535861d..c309fc2 100644 (file)
 #ifndef _LUSTRE_LIB_H
 #define _LUSTRE_LIB_H
 
-#include <asm/types.h>
-
 #ifndef __KERNEL__
 # include <string.h>
+#else
+# include <asm/semaphore.h>
 #endif
-
 #include <linux/portals_lib.h>
-#include <asm/semaphore.h>
 #include <linux/lustre_idl.h>
 
 #ifdef __KERNEL__
 /* l_net.c */
 struct ptlrpc_request;
+struct obd_device;
 int target_handle_connect(struct ptlrpc_request *req);
 int target_handle_disconnect(struct ptlrpc_request *req);
+int client_obd_connect(struct lustre_handle *conn, struct obd_device *obd);
+int client_obd_disconnect(struct lustre_handle *conn);
+int client_obd_setup(struct obd_device *obddev, obd_count len, void *buf);
+int client_obd_cleanup(struct obd_device * obddev);
+struct client_obd *client_conn2cli(struct lustre_handle *conn); 
 
 /* l_lock.c */
 struct lustre_lock { 
@@ -286,6 +290,8 @@ static inline int obd_ioctl_pack(struct obd_ioctl_data *data, char **pbuf,
 
 #else
 
+#include <linux/obd_support.h>
+
 /* buffer MUST be at least the size of obd_ioctl_hdr */
 static inline int obd_ioctl_getdata(char **buf, int *len, void *arg)
 {
@@ -390,6 +396,10 @@ static inline int obd_ioctl_getdata(char **buf, int *len, void *arg)
 
 #define OBD_IOC_DEC_FS_USE_COUNT       _IO  ('f', 133      )
 
+
+
+
+
 /* XXX this should be one mask-check */
 #define l_killable_pending(task)                                               \
 (sigismember(&(task->pending.signal), SIGKILL) ||                              \
@@ -399,6 +409,8 @@ static inline int obd_ioctl_getdata(char **buf, int *len, void *arg)
 /*
  * Like wait_event_interruptible, but we're only interruptible by KILL, INT, or
  * TERM.
+ *
+ * XXXshaver These are going away soon, I hope.
  */
 #define __l_wait_event_killable(wq, condition, ret)                          \
 do {                                                                         \
@@ -430,4 +442,31 @@ do {                                                                         \
         __ret;                                                          \
 })
 
+#define __l_wait_event_timeout(wq, condition, timeout, ret)                   \
+do {                                                                          \
+        wait_queue_t __wait;                                                  \
+        init_waitqueue_entry(&__wait, current);                               \
+                                                                              \
+        add_wait_queue(&wq, &__wait);                                         \
+        for (;;) {                                                            \
+                set_current_state(TASK_INTERRUPTIBLE);                        \
+                if (condition)                                                \
+                        break;                                                \
+                if (timeout)                                                  \
+                        schedule_timeout(timeout);                            \
+                else                                                          \
+                        schedule();                                           \
+        }                                                                     \
+        current->state = TASK_RUNNING;                                        \
+        remove_wait_queue(&wq, &__wait);                                      \
+} while(0)
+
+#define l_wait_event_timeout(wq, condition, timeout)                          \
+({                                                                            \
+        int __ret = 0;                                                        \
+        if (!(condition))                                                     \
+                __l_wait_event_timeout(wq, condition, timeout, __ret);        \
+        __ret;                                                                \
+})
+
 #endif /* _LUSTRE_LIB_H */