Whamcloud - gitweb
add null_audit command to lctl which will make audit silent. For testing purposes.
[fs/lustre-release.git] / lustre / smfs / smfs_internal.h
index 1c72bf6..59d5720 100644 (file)
 #ifndef __LINUX_SMFS_H
 #define __LINUX_SMFS_H
 
-//#include <linux/lustre_fsfilt.h>
+#include "smfs_api.h"
 #define SMFSDEV_NAME "/dev/smfsconf"
 #define SMFS_PSDEV_MINOR 250
 #define SMFS_PSDEV_MAJOR 10
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10))
+#define FC3_KERNEL
+#endif
+
 struct option {
         char *opt;
         char *value;
@@ -51,25 +55,12 @@ struct smfs_control_device {
 #define INODE_OPS_CHECK          0x2
 #define FILE_OPS_CHECK           0x4
 #define DENTRY_OPS_CHECK         0x8
-#define DEV_OPS_CHECK            0x10
+#define SPECIAL_OPS_CHECK        0x10
 #define SYMLINK_OPS_CHECK        0x20
 #define DIR_OPS_CHECK            0x40
 
-#define KML_LOG_NAME "kml_rec"
-
 #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{                                                 \
         int opcode = op_code;                       \
@@ -77,60 +68,25 @@ do{                                                 \
         buffer += sizeof(opcode);                   \
 } while (0)
 
+#define SMFS_IOPEN_INO  1
+#define KEY_IS(str, key) (strcmp(str,key) == 0)
+
 extern int init_smfs_proc_sys(void);
-/*options.c*/
-extern int get_opt(struct option **option, char **pos);
-extern void cleanup_option(void);
-extern int init_option(char *data);
 /*cache.c*/
-extern void sm_set_inode_ops(struct inode *cache_inode, struct inode *inode);
+extern void sm_set_inode_ops(struct inode *);
 extern void sm_set_sb_ops(struct super_block *cache_sb, struct super_block *sb);
-extern void init_smfs_cache(void);
-extern void cleanup_smfs_cache(void);
-extern void sm_set_journal_ops(struct super_block *sb, char *cache_type);
+//extern void init_smfs_cache(void);
+//extern void cleanup_smfs_cache(void);
+//extern void sm_set_journal_ops(struct super_block *sb, char *cache_type);
 extern int smfs_init_sm_ops(struct smfs_super_info *smb);
 extern void smfs_cleanup_sm_ops(struct smfs_super_info *smb);
-static inline struct super_operations *cache_sops(struct smfs_super_info *smb)
-{
-        return &smb->sm_ops->sm_sb_ops;
-}
-static inline struct inode_operations *cache_diops(struct smfs_super_info *smb)
-{
-        return &smb->sm_ops->sm_dir_iops;
-}
-static inline struct inode_operations *cache_fiops(struct smfs_super_info *smb)
-{
-        return &smb->sm_ops->sm_file_iops;
-}
-static inline struct inode_operations *cache_siops(struct smfs_super_info *smb)
-{
-        return &smb->sm_ops->sm_sym_iops;
-}
-static inline struct file_operations *cache_dfops(struct smfs_super_info *smb)
-{
-        return &smb->sm_ops->sm_dir_fops;
-}
-static inline struct file_operations *cache_ffops(struct smfs_super_info *smb)
-{
-        return &smb->sm_ops->sm_file_fops;
-}
-static inline struct file_operations *cache_sfops(struct smfs_super_info *smb)
-{
-        return &smb->sm_ops->sm_sym_fops;
-}
-static inline struct dentry_operations *cache_dops(struct smfs_super_info *smb)
-{
-        return &smb->sm_ops->sm_dentry_ops;
-}
-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);
+
+/*smfs_lib.c*/
+void smfs_put_super(struct super_block *sb);
+int smfs_fill_super(struct super_block *sb, void *data, int silent);
+int smfs_post_setup(struct obd_device *, struct vfsmount *, struct dentry *);
+void smfs_post_cleanup(struct super_block *);
+void * smfs_get_plg_priv(struct smfs_super_info *, int);
 /*sysctl.c*/
 extern int sm_debug_level;
 extern int sm_inodes;
@@ -139,9 +95,13 @@ extern int sm_stack;
 /*dir.c*/
 extern struct inode_operations smfs_dir_iops;
 extern struct file_operations smfs_dir_fops;
+extern struct inode_operations smfs_iopen_iops;
+extern struct file_operations smfs_iopen_fops;
+
 /*file.c*/
 extern struct inode_operations smfs_file_iops;
 extern struct file_operations  smfs_file_fops;
+extern struct inode_operations smfs_special_iops;
 extern int smfs_ioctl(struct inode * inode, struct file * filp,
                       unsigned int cmd, unsigned long arg);
 extern int smfs_fsync(struct file * file, struct dentry *dentry, int datasync);
@@ -152,19 +112,27 @@ extern int smfs_getxattr(struct dentry *dentry, const char *name, void *buffer,
                          size_t size);
 extern ssize_t smfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
 extern int smfs_removexattr(struct dentry *dentry, const char *name);
+extern int smfs_permission(struct inode *inode, int mask, struct nameidata *nd);
 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 *, struct inode*,  
+                             struct smfs_inode_info *, int);
+
 extern struct super_operations smfs_super_ops;
+
+struct smfs_iget_args {
+        struct inode            *s_inode;
+        struct smfs_inode_info  *s_info;
+        int                      s_index;
+};
+
 /*symlink.c*/
 extern struct inode_operations smfs_sym_iops;
 extern struct file_operations smfs_sym_fops;
-/*journal.c */
-extern void *smfs_trans_start(struct inode *inode, int op, void *desc_private);
-extern void smfs_trans_commit(struct inode *inode, void *handle,
-                              int force_sync);
-extern int  smfs_post_kml_rec(struct inode *dir, struct dentry *dst_dentry,
-                              void   *data1, void *data2, int op);
+
+void *smfs_trans_start(struct inode *inode, int op, void *desc_private);
+void smfs_trans_commit(struct inode *inode, void *handle, int force_sync);
 
 extern int smfs_post_rec_write(struct inode *dir, struct dentry *dentry,
                                void   *data1, void *data2);
@@ -173,30 +141,34 @@ 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);
-/*ost_kml.c*/
-extern int mds_rec_pack_init(struct super_block *sb);
+extern int mds_rec_pack(int, char *, struct dentry *, struct inode *,
+                        void *, void *);
+extern int ost_rec_pack(int, char *, struct dentry *, struct inode *,
+                        void *, void *);
 
 /*smfs_llog.c*/
-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);
+extern int smfs_llog_setup(struct dentry **, struct dentry **);
+extern int smfs_llog_cleanup(struct smfs_super_info *);
+extern int smfs_llog_add_rec(struct smfs_super_info *, void *, int);
 /*ioctl.c*/
 extern int init_smfs_psdev(void);
 extern void smfs_cleanup_psdev(void);
 /*smfs_cow.c */
 
+/* audit_transfer.c */
+int audit_notify(struct llog_handle *llh, void*, int);
+int audit_start_transferd(void);
+int audit_stop_transferd(void);
+
 /* cache_space.c */
 extern int do_cache_manage;
 struct cache_purge_queue {
@@ -219,10 +191,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"
@@ -271,66 +243,46 @@ static inline int get_active_entry(struct inode *dir, __u64 *active_entry)
         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, rc)                                \
-{                                                                               \
-        while (smfs_cache_hook(dir)) {                                          \
-                if (!handle) {                                                  \
-                        handle = smfs_trans_start(dir, KML_CACHE_NOOP, NULL);   \
-                        if (IS_ERR(handle)) {                                   \
-                               rc = -ENOSPC;                                    \
-                               break;                                           \
-                        }                                                       \
-                }                                                               \
-                CDEBUG(D_INODE, "cache hook pre: op %d, dir %lu\n",             \
-                       op, dir->i_ino);                                         \
-                cache_space_pre(dir, op);                                       \
-                break;                                                          \
-        }                                                                       \
+struct kml_buffer {
+        char *buf;
+        int   buf_size;
+}; 
+
+#ifdef __KERNEL__
+static inline void
+smfs_inode2id(struct lustre_id *id, struct inode *inode)
+{
+        mdc_pack_id(id, inode->i_ino, inode->i_generation,
+                    (inode->i_mode & S_IFMT), 0, 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);                                \
-        }                                                               \
+static inline void 
+smfs_prepare_mdc_data(struct mdc_op_data *data, struct inode *i1,
+                      struct inode *i2, const char *name, int namelen,
+                      int mode)
+{
+        LASSERT(i1);
+
+        smfs_inode2id(&data->id1, i1);
+        if (i2)
+                smfs_inode2id(&data->id2, i2);
+        else
+                memset(&data->id2, 0, sizeof(data->id2));
+
+       data->valid = 0;
+        data->name = name;
+        data->namelen = namelen;
+        data->create_mode = mode;
+        data->mod_time = LTIME_S(CURRENT_TIME);
 }
+#endif
+
 #if CONFIG_SNAPFS
-/*snap macros*/
-#define SMFS_PRE_COW(dir, dentry, op, name, 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)
-extern int smfs_cow_init(struct super_block *sb);
-extern int smfs_cow_cleanup(struct super_block *sb);
-extern int smfs_init_snap_inode_info(struct inode *inode, int flags);
+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 */