+extern int smfs_llog_setup(struct super_block *sb, struct vfsmount *mnt);
+extern int smfs_llog_cleanup(struct super_block *sb);
+extern int smfs_llog_add_rec(struct smfs_super_info * sinfo, void *data,
+ int data_size);
+/*ioctl.c*/
+extern int init_smfs_psdev(void);
+extern void smfs_cleanup_psdev(void);
+
+/* cache_space.c */
+extern int do_cache_manage;
+struct cache_purge_queue {
+ wait_queue_head_t cpq_waitq;
+ struct super_block *cpq_sb;
+ struct llog_handle *cpq_loghandle;
+ __u32 cpq_flags;
+ struct completion cpq_comp;
+};
+/* opcodes */
+#define CACHE_SPACE_INSERT 0x1
+#define CACHE_SPACE_DELETE 0x2
+#define CACHE_SPACE_COMMIT 0x4
+
+#define CACHE_LRU_LOG "CACHE_LRU_LIST"
+
+extern int smfs_cache_hook(struct inode *inode);
+extern void cache_space_pre(struct inode *inode, int op);
+extern int cache_space_post(int op, void *handle, struct inode *old_dir,
+ struct dentry *old_dentry, struct inode *new_dir,
+ struct dentry *new_dentry);
+
+extern int cache_space_hook_setup(struct super_block *);
+extern int cache_space_hook_cleanup(void);
+extern int cache_space_hook_init(struct super_block *);
+extern int cache_space_hook_exit(struct super_block *);
+
+#define XATTR_SMFS_HOARD_MARK "hoard"
+#define XATTR_SMFS_CACHE_LOGCOOKIE "cache"
+#define XATTR_SMFS_ACTIVE_ENTRY "entry"
+
+
+static inline int set_hoard_priority(struct inode *inode, void *handle,
+ __u32 *hoard)
+{
+ struct fsfilt_operations *fsops = I2CSB(inode)->sm_fsfilt;
+ int rc;
+
+ rc = fsops->fs_set_xattr(inode, handle, XATTR_SMFS_HOARD_MARK,
+ hoard, sizeof(__u32));
+ RETURN(rc);
+}
+
+static inline int get_hoard_priority(struct inode *inode, __u32 *hoard)
+{
+ struct fsfilt_operations *fsops = I2CSB(inode)->sm_fsfilt;
+ int rc;
+
+ rc = fsops->fs_get_xattr(inode, XATTR_SMFS_HOARD_MARK,
+ hoard, sizeof(__u32));
+ RETURN(rc);
+}
+
+static inline int set_active_entry(struct inode *dir, __u64 *active_entry,
+ void *handle)
+{
+ struct fsfilt_operations *fsops = I2CSB(dir)->sm_fsfilt;
+ int rc;
+ *active_entry = cpu_to_le64(*active_entry);
+ rc = fsops->fs_set_xattr(dir, handle, XATTR_SMFS_ACTIVE_ENTRY,
+ active_entry, sizeof(__u64));
+ RETURN(rc);
+}
+static inline int get_active_entry(struct inode *dir, __u64 *active_entry)
+{
+ struct fsfilt_operations *fsops = I2CSB(dir)->sm_fsfilt;
+ int rc = fsops->fs_get_xattr(dir, XATTR_SMFS_ACTIVE_ENTRY,
+ active_entry, sizeof(__u64));
+ *active_entry = le64_to_cpu(*active_entry);
+ if (rc >= 0)
+ rc = 0;
+ RETURN(rc);
+}
+
+#define CACHE_HOOK_CREATE 1
+#define CACHE_HOOK_LOOKUP 2
+#define CACHE_HOOK_LINK 3
+#define CACHE_HOOK_UNLINK 4
+#define CACHE_HOOK_SYMLINK 5
+#define CACHE_HOOK_MKDIR 6
+#define CACHE_HOOK_RMDIR 7
+#define CACHE_HOOK_MKNOD 8
+#define CACHE_HOOK_RENAME 9
+
+#define CACHE_HOOK_MAX 9
+
+#define SMFS_CACHE_HOOK_PRE(op, handle, dir) \
+{ \
+ if (smfs_cache_hook(dir)) { \
+ LASSERT(handle != NULL); \
+ CDEBUG(D_INODE, "cache hook pre: op %d, dir %lu\n", \
+ op, dir->i_ino); \
+ cache_space_pre(dir, op); \
+ } \
+}
+
+#define SMFS_CACHE_HOOK_POST(op, handle, old_dir, old_dentry, \
+ new_dir, new_dentry, rc, label) \
+{ \
+ if (!rc && smfs_cache_hook(old_dir)) { \
+ LASSERT(handle != NULL); \
+ CDEBUG(D_INODE, "cache hook post: op %d, dir %lu\n", \
+ op, old_dir->i_ino); \
+ rc = cache_space_post(op, handle, old_dir, old_dentry, \
+ new_dir, new_dentry); \
+ if (rc) \
+ GOTO(label, rc); \
+ } \
+}
+
+#endif /*__KERNEL*/