4 #include <linux/lustre_fsfilt.h>
5 #define SMFSDEV_NAME "/dev/smfsconf"
6 #define SMFS_PSDEV_MINOR 250
7 #define SMFS_PSDEV_MAJOR 10
12 struct list_head list;
15 struct smfs_control_device {
16 struct list_head smfs_dev_list;
19 #define SMFS_TYPE "smfs"
20 #define IOC_SMFS_START _IOWR('s', 41, long)
21 #define IOC_SMFS_STOP _IOWR('s', 42, long)
22 #define IOC_SMFS_REINT _IOWR('s', 43, long)
23 #define IOC_SMFS_UNDO _IOWR('s', 44, long)
27 struct smfs_proc_args {
28 struct super_block *sr_sb;
35 #define SB_OPS_CHECK 0x1
36 #define INODE_OPS_CHECK 0x2
37 #define FILE_OPS_CHECK 0x4
38 #define DENTRY_OPS_CHECK 0x8
39 #define DEV_OPS_CHECK 0x10
40 #define SYMLINK_OPS_CHECK 0x20
41 #define DIR_OPS_CHECK 0x40
43 #define KML_LOG_NAME "kml_rec"
45 #define MYPATHLEN(buffer, path) ((buffer) + PAGE_SIZE - (path))
47 #define SMFS_KML_POST(dir, dentry, data1, data2, op, name, rc, label) \
49 if(smfs_do_rec(dir) && !rc) { \
50 CDEBUG(D_INODE, "Do %s kml post for dir %lu \n", \
52 rc = smfs_post_kml_rec(dir, dentry, data1, data2, op); \
58 extern int init_smfs_proc_sys(void);
60 extern int get_opt(struct option **option, char **pos);
61 extern void cleanup_option(void);
62 extern int init_option(char *data);
64 extern void sm_set_inode_ops(struct inode *cache_inode, struct inode *inode);
65 extern void sm_set_sb_ops(struct super_block *cache_sb, struct super_block *sb);
66 extern void init_smfs_cache(void);
67 extern void cleanup_smfs_cache(void);
68 extern void sm_set_journal_ops(struct super_block *sb, char *cache_type);
69 extern int smfs_init_sm_ops(struct smfs_super_info *smb);
70 extern void smfs_cleanup_sm_ops(struct smfs_super_info *smb);
71 static inline struct super_operations *cache_sops(struct smfs_super_info *smb)
73 return &smb->sm_ops->sm_sb_ops;
75 static inline struct inode_operations *cache_diops(struct smfs_super_info *smb)
77 return &smb->sm_ops->sm_dir_iops;
79 static inline struct inode_operations *cache_fiops(struct smfs_super_info *smb)
81 return &smb->sm_ops->sm_file_iops;
83 static inline struct inode_operations *cache_siops(struct smfs_super_info *smb)
85 return &smb->sm_ops->sm_sym_iops;
87 static inline struct file_operations *cache_dfops(struct smfs_super_info *smb)
89 return &smb->sm_ops->sm_dir_fops;
91 static inline struct file_operations *cache_ffops(struct smfs_super_info *smb)
93 return &smb->sm_ops->sm_file_fops;
95 static inline struct file_operations *cache_sfops(struct smfs_super_info *smb)
97 return &smb->sm_ops->sm_sym_fops;
99 static inline struct dentry_operations *cache_dops(struct smfs_super_info *smb)
101 return &smb->sm_ops->sm_dentry_ops;
103 static inline struct journal_operations *journal_ops(struct smfs_super_info *smb)
105 return &smb->sm_ops->sm_journal_ops;
108 extern int init_smfs(void);
109 extern int cleanup_smfs(void);
110 extern void smfs_put_super(struct super_block *sb);
111 extern struct super_block *smfs_get_sb_by_path(char *path, int len);
112 extern struct vfsmount* get_vfsmount(struct super_block *sb);
114 extern int sm_debug_level;
115 extern int sm_inodes;
116 extern long sm_kmemory;
119 extern struct inode_operations smfs_dir_iops;
120 extern struct file_operations smfs_dir_fops;
122 extern struct inode_operations smfs_file_iops;
123 extern struct file_operations smfs_file_fops;
124 extern int smfs_ioctl(struct inode * inode, struct file * filp,
125 unsigned int cmd, unsigned long arg);
126 extern int smfs_fsync(struct file * file, struct dentry *dentry, int datasync);
127 extern int smfs_setattr(struct dentry *dentry, struct iattr *attr);
128 extern int smfs_setxattr(struct dentry *dentry, const char *name,
129 const void *value, size_t size, int flags);
130 extern int smfs_getxattr(struct dentry *dentry, const char *name, void *buffer,
132 extern ssize_t smfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
133 extern int smfs_removexattr(struct dentry *dentry, const char *name);
134 extern int smfs_open(struct inode * inode, struct file * filp);
135 extern int smfs_release(struct inode * inode, struct file * filp);
137 extern struct super_operations smfs_super_ops;
139 extern struct inode_operations smfs_sym_iops;
140 extern struct file_operations smfs_sym_fops;
142 extern void *smfs_trans_start(struct inode *inode, int op, void *desc_private);
143 extern void smfs_trans_commit(struct inode *inode, void *handle,
145 extern int smfs_post_kml_rec(struct inode *dir, struct dentry *dst_dentry,
146 void *data1, void *data2, int op);
148 extern int smfs_kml_init(struct super_block *sb);
149 extern int smfs_do_rec(struct inode *inode);
150 extern int smfs_rec_cleanup(struct super_block *sb);
151 extern int smfs_rec_init(struct super_block *sb);
152 extern int smfs_rec_unpack(struct smfs_proc_args *args,
153 struct reint_record *u_rec, char *rec_buf);
154 extern int smfs_start_rec(struct super_block *sb);
155 extern int smfs_stop_rec(struct super_block *sb);
156 extern int smfs_process_rec(struct super_block *sb, int count, char *dir,
158 void reint_rec_free(struct reint_record *reint_rec);
160 extern void smfs_rec_pack(struct update_record *rec, struct inode *dst,
163 extern int smfs_llog_setup(struct super_block *sb);
164 extern int smfs_llog_cleanup(struct super_block *sb);
165 extern int smfs_llog_add_rec(struct smfs_super_info * sinfo, void *data,
168 extern int init_smfs_psdev(void);
169 extern void smfs_cleanup_psdev(void);
172 extern int do_cache_manage;
173 struct cache_purge_queue {
174 wait_queue_head_t cpq_waitq;
175 struct super_block *cpq_sb;
176 struct llog_handle *cpq_loghandle;
178 struct completion cpq_comp;
182 #define CACHE_SPACE_INSERT 0x1
183 #define CACHE_SPACE_DELETE 0x2
184 #define CACHE_SPACE_COMMIT 0x4
186 #define CACHE_LRU_LOG "CACHE_LRU_LIST"
188 extern int smfs_cache_hook(struct inode *inode);
189 extern void cache_space_pre(struct inode *inode, int op);
190 extern int cache_space_post(int op, void *handle, struct inode *old_dir,
191 struct dentry *old_dentry, struct inode *new_dir,
192 struct dentry *new_dentry);
194 extern int cache_space_hook_setup(struct super_block *);
195 extern int cache_space_hook_cleanup(void);
196 extern int cache_space_hook_init(struct super_block *);
197 extern int cache_space_hook_exit(struct super_block *);
199 #define XATTR_SMFS_HOARD_MARK "hoard"
200 #define XATTR_SMFS_CACHE_LOGCOOKIE "cache"
201 #define XATTR_SMFS_ACTIVE_ENTRY "entry"
203 #define SMFS_TRANS_OP(inode, op) \
205 if (smfs_do_rec(inode)) \
207 if (smfs_cache_hook(inode)) \
211 static inline int set_hoard_priority(struct inode *inode, void *handle,
214 struct fsfilt_operations *fsops = I2CSB(inode)->sm_fsfilt;
217 rc = fsops->fs_set_xattr(inode, handle, XATTR_SMFS_HOARD_MARK,
218 hoard, sizeof(__u32));
222 static inline int get_hoard_priority(struct inode *inode, __u32 *hoard)
224 struct fsfilt_operations *fsops = I2CSB(inode)->sm_fsfilt;
227 rc = fsops->fs_get_xattr(inode, XATTR_SMFS_HOARD_MARK,
228 hoard, sizeof(__u32));
232 static inline int set_active_entry(struct inode *dir, __u64 *active_entry,
235 struct fsfilt_operations *fsops = I2CSB(dir)->sm_fsfilt;
237 *active_entry = cpu_to_le64(*active_entry);
238 rc = fsops->fs_set_xattr(dir, handle, XATTR_SMFS_ACTIVE_ENTRY,
239 active_entry, sizeof(__u64));
242 static inline int get_active_entry(struct inode *dir, __u64 *active_entry)
244 struct fsfilt_operations *fsops = I2CSB(dir)->sm_fsfilt;
245 int rc = fsops->fs_get_xattr(dir, XATTR_SMFS_ACTIVE_ENTRY,
246 active_entry, sizeof(__u64));
247 *active_entry = le64_to_cpu(*active_entry);
253 #define CACHE_HOOK_CREATE 1
254 #define CACHE_HOOK_LOOKUP 2
255 #define CACHE_HOOK_LINK 3
256 #define CACHE_HOOK_UNLINK 4
257 #define CACHE_HOOK_SYMLINK 5
258 #define CACHE_HOOK_MKDIR 6
259 #define CACHE_HOOK_RMDIR 7
260 #define CACHE_HOOK_MKNOD 8
261 #define CACHE_HOOK_RENAME 9
263 #define CACHE_HOOK_MAX 9
265 #define SMFS_CACHE_HOOK_PRE(op, handle, dir) \
267 if (smfs_cache_hook(dir)) { \
268 LASSERT(handle != NULL); \
269 CDEBUG(D_INODE, "cache hook pre: op %d, dir %lu\n", \
271 cache_space_pre(dir, op); \
275 #define SMFS_CACHE_HOOK_POST(op, handle, old_dir, old_dentry, \
276 new_dir, new_dentry, rc, label) \
278 if (!rc && smfs_cache_hook(old_dir)) { \
279 LASSERT(handle != NULL); \
280 CDEBUG(D_INODE, "cache hook post: op %d, dir %lu\n", \
281 op, old_dir->i_ino); \
282 rc = cache_space_post(op, handle, old_dir, old_dentry, \
283 new_dir, new_dentry); \
290 #endif /* __LINUX_SMFS_H */