Whamcloud - gitweb
minor fix for build error
[fs/lustre-release.git] / lustre / smfs / smfs_internal.h
index 541afbf..fa8dcd0 100644 (file)
@@ -59,16 +59,6 @@ struct smfs_control_device {
 
 #define MYPATHLEN(buffer, path) ((buffer) + PAGE_SIZE - (path))
 
-#define SMFS_KML_POST(dir, dentry, data1, data2, op, name, rc, label)   \
-do {                                                                    \
-        if (smfs_do_rec(dir) && !rc) {                                  \
-                CDEBUG(D_INODE, "Do %s kml post for dir %lu \n",        \
-                              name, dir->i_ino);                        \
-                rc = smfs_post_kml_rec(dir, dentry, data1, data2, op);  \
-                if (rc)                                                 \
-                        GOTO(label, rc);                                \
-        }                                                               \
-} while(0)
 
 #define PACK_KML_REC_INIT(buffer, op_code)          \
 do{                                                 \
@@ -77,6 +67,7 @@ do{                                                 \
         buffer += sizeof(opcode);                   \
 } while (0)
 
+
 extern int init_smfs_proc_sys(void);
 /*options.c*/
 extern int get_opt(struct option **option, char **pos);
@@ -126,12 +117,20 @@ static inline struct journal_operations *journal_ops(struct smfs_super_info *smb
 {
         return &smb->sm_ops->sm_journal_ops;
 }
-/*super.c*/
-extern int init_smfs(void);
-extern int cleanup_smfs(void);
-extern void smfs_put_super(struct super_block *sb);
-extern struct super_block *smfs_get_sb_by_path(char *path, int len);
-extern struct vfsmount* get_vfsmount(struct super_block *sb);
+
+struct smfs_hook_ops *smfs_alloc_hook_ops(char *name, 
+                                          smfs_hook_func pre_hook, 
+                                          smfs_hook_func post_hook);
+
+void smfs_free_hook_ops(struct smfs_hook_ops *hops);
+int smfs_register_hook_ops(struct smfs_super_info *smb, 
+                           struct smfs_hook_ops *smh_ops);
+
+struct smfs_hook_ops *smfs_unregister_hook_ops(struct smfs_super_info *smb, 
+                                               char *name);
+/*smfs_lib.c*/
+void smfs_put_super(struct super_block *sb);
+int smfs_fill_super(struct super_block *sb, void *data, int silent);
 /*sysctl.c*/
 extern int sm_debug_level;
 extern int sm_inodes;
@@ -156,7 +155,16 @@ extern int smfs_removexattr(struct dentry *dentry, const char *name);
 extern int smfs_open(struct inode * inode, struct file * filp);
 extern int smfs_release(struct inode * inode, struct file * filp);
 /*inode.c*/
+struct inode *smfs_get_inode(struct super_block *sb, ino_t hash, 
+                             struct inode *dir, int index);
+
 extern struct super_operations smfs_super_ops;
+
+struct smfs_iget_args {
+        struct inode *s_inode;
+        int           s_index;
+        int           s_ino;
+};
 /*symlink.c*/
 extern struct inode_operations smfs_sym_iops;
 extern struct file_operations smfs_sym_fops;
@@ -174,19 +182,21 @@ extern int smfs_post_rec_setattr(struct inode *dir, struct dentry *dentry,
 extern int smfs_post_rec_create(struct inode *dir, struct dentry *dentry,
                                 void   *data1, void   *data2);
 /*kml.c*/
-extern int smfs_kml_init(struct super_block *sb);
-extern int smfs_do_rec(struct inode *inode);
-extern int smfs_rec_cleanup(struct super_block *sb);
-extern int smfs_rec_init(struct super_block *sb);
+int smfs_do_rec(struct inode *inode);
+int smfs_rec_cleanup(struct smfs_super_info *sb);
+int smfs_rec_init(struct super_block *sb);
+
 extern int smfs_rec_unpack(struct smfs_proc_args *args, char *record,
                            char **pbuf, int *opcode);
 extern int smfs_process_rec(struct super_block *sb, int count,
                             char *dir, int flags);
 extern smfs_pack_rec_func smfs_get_rec_pack_type(struct super_block *sb);
 
-extern int ost_rec_pack_init(struct super_block *sb);
+
+/*mds_kml.c*/
+int mds_rec_pack_init(struct super_block *sb);
 /*ost_kml.c*/
-extern int mds_rec_pack_init(struct super_block *sb);
+int ost_rec_pack_init(struct super_block *sb);
 
 /*smfs_llog.c*/
 extern int smfs_llog_setup(struct super_block *sb, struct vfsmount *mnt);
@@ -198,7 +208,6 @@ extern int init_smfs_psdev(void);
 extern void smfs_cleanup_psdev(void);
 /*smfs_cow.c */
 
-extern int smfs_cow_init(struct super_block *sb);
 /* cache_space.c */
 extern int do_cache_manage;
 struct cache_purge_queue {
@@ -221,10 +230,10 @@ 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 *);
+int cache_space_hook_setup(struct super_block *);
+int cache_space_hook_cleanup(void);
+int cache_space_hook_init(struct super_block *sb);
+int cache_space_hook_exit(struct smfs_super_info *smfs_info);
 
 #define XATTR_SMFS_HOARD_MARK           "hoard"
 #define XATTR_SMFS_CACHE_LOGCOOKIE      "cache"
@@ -272,57 +281,63 @@ static inline int get_active_entry(struct inode *dir, __u64 *active_entry)
                 rc = 0;
         RETURN(rc);
 }
+#define HOOK_CREATE       1
+#define HOOK_LOOKUP       2
+#define HOOK_LINK         3
+#define HOOK_UNLINK       4
+#define HOOK_SYMLINK      5
+#define HOOK_MKDIR        6
+#define HOOK_RMDIR        7
+#define HOOK_MKNOD        8
+#define HOOK_RENAME       9
+#define HOOK_SETATTR      10
+#define HOOK_WRITE        11 
+#define HOOK_MAX          11 
 
-#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 PRE_HOOK 0
+#define POST_HOOK 1
+#define SMFS_HOOK(inode, dentry, data1, data2, op, handle, flag, rc, label)    \
+do {                                                                           \
+        LASSERT(inode->i_sb);                                                  \
+        if (!rc) {                                                             \
+                struct smfs_super_info *smb = S2SMI(inode->i_sb);              \
+                struct list_head *hlist = &smb->smsi_hook_list;                \
+                struct list_head *p;                                           \
+                                                                               \
+                list_for_each(p, hlist) {                                      \
+                       struct smfs_hook_ops *hops;                            \
+                                                                               \
+                        hops = list_entry(p, typeof(*hops), smh_list);         \
+                        if (flag == PRE_HOOK && hops->smh_pre_op)              \
+                                rc = hops->smh_pre_op(inode, dentry, data1,    \
+                                                      data2, op, handle);      \
+                        else if (flag == POST_HOOK && hops->smh_post_op)       \
+                                rc = hops->smh_post_op(inode, dentry, data1,   \
+                                                       data2, op, handle);     \
+                        if (rc)                                                \
+                                break;                                         \
+                }                                                              \
+        }                                                                      \
+        if (rc)                                                                \
+                GOTO(label, rc);                                               \
+} while(0)                                                                     \
 
-#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);                                \
-        }                                                               \
-}
-#if CONFIG_SNAP
-/*snap macros*/
-#define SMFS_PRE_COW(dir, dentry, op, name, rc, label)                  \
+#define SMFS_GET_INODE(sb, cache_inode, dir, inode, rc, label)          \
 do {                                                                    \
-        if (smfs_do_cow(dir) && !rc) {                                  \
-                CDEBUG(D_INODE, "Do %s snap post for dir %lu \n",       \
-                              name, dir->i_ino);                        \
-                rc = smfs_cow(dir, dentry, op);                         \
-                if (rc)                                                 \
-                        GOTO(label, rc);                                \
-        }                                                               \
-} while(0)
+        LASSERT(cache_inode);                                           \
+        inode = smfs_get_inode(sb, cache_inode->i_ino, dir, 0);         \
+        iput(cache_inode);                                              \
+        if (!inode)                                                     \
+                GOTO(label, rc = -ENOENT);                              \
+} while(0)        
+
+
+#if CONFIG_SNAPFS
+int smfs_cow_init(struct super_block *sb);
+int smfs_cow_cleanup(struct smfs_super_info *smb);
+int smfs_snap_test_inode(struct inode *inode, void *args);
 #else
-#define SMFS_PRE_COW(dir, dentry, op, name, rc, label)                 
+#define SMFS_PRE_COW(dir, dentry, new_dir, new_dentry, op, name, rc, label)                 
 #endif 
-
 #endif /*__KERNEL*/
 #endif /* __LINUX_SMFS_H */