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