Whamcloud - gitweb
b=5881
[fs/lustre-release.git] / lustre / smfs / smfs_api.h
1 /* SMFS plugin stuff */
2 #define SMFS_PLG_DUMMY  0x0001L
3 #define SMFS_PLG_KML    0x0002L
4 #define SMFS_PLG_LRU    0x0004L
5 #define SMFS_PLG_COW    0x0008L
6
7 #define SMFS_SET_PLG(flags, mask) (flags |= mask)
8 #define SMFS_IS_PLG(flags, mask) (flags & mask)
9 #define SMFS_CLEAR_PLG(flags, mask) (flags &= ~mask)
10
11 typedef int (*smfs_plg_hook)(int hook_code, void *arg, int, void * priv);
12 typedef int (*smfs_plg_func)(int help_code, void *arg, void * priv);
13
14 struct smfs_plugin {
15         struct list_head plg_list;
16         int              plg_type;
17
18         smfs_plg_hook    plg_pre_op;
19         smfs_plg_hook    plg_post_op;
20         smfs_plg_func    plg_helper;
21         void *           plg_private;
22 };
23
24 #define HOOK_CREATE       1
25 #define HOOK_LOOKUP       2
26 #define HOOK_LINK         3
27 #define HOOK_UNLINK       4
28 #define HOOK_SYMLINK      5
29 #define HOOK_MKDIR        6
30 #define HOOK_RMDIR        7
31 #define HOOK_MKNOD        8
32 #define HOOK_RENAME       9
33 #define HOOK_SETATTR      10
34 #define HOOK_WRITE        11
35 #define HOOK_READDIR      12
36 #define HOOK_MAX          13
37
38 struct hook_msg {
39         struct inode * dir;
40         struct dentry * dentry;
41 };
42
43 struct hook_unlink_msg {
44         struct inode * dir;
45         struct dentry * dentry;
46         int mode;
47 };
48
49 struct hook_symlink_msg {
50         struct inode * dir;
51         struct dentry * dentry;
52         int tgt_len;
53         char * symname;
54 };
55
56 struct hook_rename_msg {
57         struct inode * dir;
58         struct dentry * dentry;
59         struct inode * new_dir;
60         struct dentry * new_dentry;
61 };
62
63 struct hook_readdir_msg {
64         struct inode * dir;
65         struct dentry * dentry;
66         struct file * filp;
67         void * dirent;
68         filldir_t filldir;
69 };
70
71 struct hook_write_msg {
72         struct inode * inode;
73         struct dentry * dentry;
74         size_t count;
75         loff_t pos;
76 };
77
78 struct hook_setattr_msg {
79         struct inode * inode;
80         struct dentry * dentry;
81         struct iattr *attr;
82 };
83 #define SMFS_HOOK(sb, op, msg, a,b,c,d,e,f)                  \
84 do {                                                         \
85 } while(0)
86
87 #define SMFS_PRE_HOOK(sb, op, msg)                           \
88 do {                                                         \
89         struct smfs_super_info *smb = S2SMI(sb);             \
90         struct list_head *hlist = &smb->smsi_plg_list;       \
91         struct smfs_plugin *plg;                             \
92                                                              \
93         list_for_each_entry(plg, hlist, plg_list) {          \
94                 if (plg->plg_pre_op)                         \
95                         plg->plg_pre_op(op, msg, 0,          \
96                                         plg->plg_private);   \
97         }                                                    \
98 } while(0)
99
100 #define SMFS_POST_HOOK(sb, op, msg, rc)                      \
101 do {                                                         \
102         struct smfs_super_info *smb = S2SMI(sb);             \
103         struct list_head *hlist = &smb->smsi_plg_list;       \
104         struct smfs_plugin *plg;                             \
105                                                              \
106         list_for_each_entry(plg, hlist, plg_list) {          \
107                 if (plg->plg_post_op)                        \
108                         plg->plg_post_op(op, msg, rc,        \
109                                          plg->plg_private);  \
110         }                                                    \
111 } while(0)
112
113 #define PLG_EXIT        0
114 #define PLG_TRANS_SIZE  1
115 #define PLG_TEST_INODE  2
116 #define PLG_SET_INODE   3
117 #define PLG_HELPER_MAX  4
118
119 #define SMFS_PLG_HELP(sb, op, data)                              \
120 do {                                                             \
121         struct list_head *hlist = &S2SMI(sb)->smsi_plg_list;     \
122         struct smfs_plugin *plugin, *tmp;                        \
123                                                                  \
124         list_for_each_entry_safe(plugin, tmp, hlist, plg_list) { \
125                 if (plugin->plg_helper)                          \
126                         plugin->plg_helper(op, data,             \
127                                            plugin->plg_private); \
128         }                                                        \
129 } while(0)
130
131 int smfs_register_plugin(struct super_block *, struct smfs_plugin *);
132 void * smfs_deregister_plugin(struct super_block *, int);
133
134 int smfs_init_dummy(struct super_block *);
135 int smfs_init_kml(struct super_block *);
136 int smfs_init_lru(struct super_block *);
137 int smfs_init_cow(struct super_block *);
138
139
140
141
142