Whamcloud - gitweb
b=5881
[fs/lustre-release.git] / lustre / smfs / smfs_api.h
1 /* SMFS plugin stuff */
2 #define SMFS_PLG_DUMMY  0
3 #define SMFS_PLG_KML    1
4 #define SMFS_PLG_LRU    2
5 #define SMFS_PLG_COW    3
6 #define SMFS_PLG_MAX    4
7
8 typedef int (*smfs_plg_hook)(int hook_code, void *arg, void * priv);
9 typedef int (*smfs_plg_func) (int help_code, void *arg, void * priv);
10
11 struct smfs_plugin {
12         struct list_head plg_list;
13         int              plg_type;
14
15         smfs_plg_hook    plg_pre_op;
16         smfs_plg_hook    plg_post_op;
17         smfs_plg_func    plg_helper;
18         void *           plg_private;
19 };
20
21 #define HOOK_CREATE       1
22 #define HOOK_LOOKUP       2
23 #define HOOK_LINK         3
24 #define HOOK_UNLINK       4
25 #define HOOK_SYMLINK      5
26 #define HOOK_MKDIR        6
27 #define HOOK_RMDIR        7
28 #define HOOK_MKNOD        8
29 #define HOOK_RENAME       9
30 #define HOOK_SETATTR      10
31 #define HOOK_WRITE        11
32 #define HOOK_READDIR      12
33 #define HOOK_MAX          13
34
35 struct hook_data {
36         struct inode * dir;
37         struct dentry * dentry;
38         int ret_code;
39 };
40
41 struct hook_data_rename {
42         struct hook_data data;
43         struct inode * new_dir;
44         struct inode * new_dentry;
45 };
46
47 struct hook_data_readdir {
48         struct hook_data data;
49         struct file * filp;
50         void * dirent;
51         filldir_t filldir;
52 };
53
54 struct hook_data_setattr {
55         struct hook_data data;
56         struct iattr *attr;
57 };
58
59
60 #define SMFS_PRE_HOOK (op, data)                               \
61 do {                                                           \
62         struct list_head *hlist = &smfs_plg_list;              \
63         struct smfs_plugin *plugin;                            \
64                                                                \
65         list_for_each_entry(plugin, hlist, plg_list) {         \
66                 if (plugin->plg_pre_op)                        \
67                         plugin->plg_pre_op(op, data,           \
68                                            plg->plg_private);  \
69         }                                                      \
70 } while(0)
71
72 #define SMFS_POST_HOOK (op, data, rc)                          \
73 do {                                                           \
74         struct list_head *hlist = &smfs_plg_list;              \
75         struct smfs_plugin *plugin;                            \
76                                                                \
77         list_for_each_entry(plugin, hlist, plg_list) {         \
78                 if (plugin->plg_post_op)                       \
79                         plugin->plg_post_op(op, data,          \
80                                             plg->plg_private); \
81         }                                                      \
82 } while(0)
83
84 #define PLG_EXIT        0
85 #define PLG_TRANS_SIZE  1
86 #define PLG_TEST_INODE  2
87 #define PLG_SET_INODE   3
88 #define PLG_HELPER_MAX  4
89
90 #define SMFS_PLG_HELP (op, data)                              \
91 do {                                                          \
92         struct list_head *hlist = &smfs_plg_list;             \
93         struct smfs_plugin *plugin;                           \
94                                                               \
95         list_for_each_entry(plugin, hlist, plg_list) {        \
96                 if (plugin->plg_helper)                       \
97                         plugin->plg_helper(op, data,          \
98                                            plg->plg_private); \
99         }                                                     \
100 } while(0)
101
102 int smfs_register_plugin(struct smfs_plugin *);
103 void * smfs_deregister_plugin(int);
104
105
106
107
108
109
110