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