Whamcloud - gitweb
land b1_5 onto HEAD
[fs/lustre-release.git] / lustre / include / lustre_handles.h
1 #ifndef __LUSTRE_HANDLES_H_
2 #define __LUSTRE_HANDLES_H_
3
4 #if defined(__linux__)
5 #include <linux/lustre_handles.h>
6 #elif defined(__APPLE__)
7 #include <darwin/lustre_handles.h>
8 #elif defined(__WINNT__)
9 #include <winnt/lustre_handles.h>
10 #else
11 #error Unsupported operating system.
12 #endif
13
14 typedef void (*portals_handle_addref_cb)(void *object);
15
16 /* These handles are most easily used by having them appear at the very top of
17  * whatever object that you want to make handles for.  ie:
18  *
19  * struct ldlm_lock {
20  *         struct portals_handle handle;
21  *         ...
22  * };
23  *
24  * Now you're able to assign the results of cookie2handle directly to an
25  * ldlm_lock.  If it's not at the top, you'll want to hack up a macro that
26  * uses some offsetof() magic. */
27
28 struct portals_handle {
29         struct list_head h_link;
30         __u64 h_cookie;
31         portals_handle_addref_cb h_addref;
32 };
33
34 /* handles.c */
35
36 /* Add a handle to the hash table */
37 void class_handle_hash(struct portals_handle *, portals_handle_addref_cb);
38 void class_handle_unhash(struct portals_handle *);
39 void *class_handle2object(__u64 cookie);
40 int class_handle_init(void);
41 void class_handle_cleanup(void);
42
43 #endif