Whamcloud - gitweb
- landed b_hd_cray_merge3
[fs/lustre-release.git] / lustre / include / linux / lustre_smfs.h
index 710569c..792cbe9 100644 (file)
@@ -26,6 +26,9 @@
 #ifndef __LUSTRE_SMFS_H
 #define __LUSTRE_SMFS_H
 
+#include <linux/lustre_fsfilt.h>
+#include <linux/namei.h>
+
 struct snap_inode_info {
        int sn_flags;           /*the flags indicated inode type */
        int sn_gen;             /*the inode generation*/
@@ -33,6 +36,10 @@ struct snap_inode_info {
         ino_t sn_root_ino;        /*the root ino of this snap*/
 };
 struct smfs_inode_info {
+        /* this first part of struct should be the same as in mds_info_info */
+        struct lustre_id smi_id;
+        
+        /* smfs part. */
         struct inode *smi_inode;
         __u32  smi_flags;
        struct snap_inode_info sm_sninfo;
@@ -72,7 +79,7 @@ struct mds_kml_pack_info {
         int mpi_size[4];
         int mpi_total_size;
 };
-typedef int (*smfs_hook_func)(struct inode *inode, struct dentry *dentry,
+typedef int (*smfs_hook_func)(struct inode *inode, void *dentry,
                              void *data1, void *data2, int op, void *handle);
 struct smfs_hook_ops {
         struct list_head smh_list;
@@ -98,6 +105,7 @@ struct smfs_super_info {
         smfs_pack_rec_func      smsi_pack_rec[PACK_MAX]; /* sm_pack_rec type ops */
         __u32                    smsi_flags;        /* flags */
         __u32                    smsi_ops_check;
+        struct list_head         smsi_plg_list;
         struct list_head         smsi_hook_list;
         kmem_cache_t *           smsi_inode_cachep;  /*inode_cachep*/
 };
@@ -124,11 +132,14 @@ struct fs_extent{
 };
 
 #define I2SMI(inode)  ((struct smfs_inode_info *) ((inode->u.generic_ip)))
+#define I2FSI(inode)  (((inode->u.generic_ip)))
 
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
+#define S2FSI(sb)   (((sb->u.generic_sbp)))
 #define S2SMI(sb)   ((struct smfs_super_info *) ((sb->u.generic_sbp)))
 #define S2CSB(sb)   (((struct smfs_super_info *)((sb->u.generic_sbp)))->smsi_sb)
 #else
+#define S2FSI(sb)   ((sb->s_fs_info))
 #define S2SMI(sb)   ((struct smfs_super_info *) (sb->s_fs_info))
 #define S2CSB(sb)   (((struct smfs_super_info *) (sb->s_fs_info))->smsi_sb)
 #endif
@@ -300,8 +311,9 @@ static inline void duplicate_inode(struct inode *dst_inode,
         dst_inode->i_mtime = src_inode->i_mtime;
         dst_inode->i_blksize = src_inode->i_blksize;
         dst_inode->i_version = src_inode->i_version;
-        dst_inode->i_state = src_inode->i_state;
+        //dst_inode->i_state = src_inode->i_state;
         dst_inode->i_generation = src_inode->i_generation;
+        dst_inode->i_flags = src_inode->i_flags;
 
         /* This is to make creating special files working. */
         dst_inode->i_rdev = src_inode->i_rdev;
@@ -312,11 +324,12 @@ static inline void post_smfs_inode(struct inode *inode,
 {
         if (inode && cache_inode) {
                 duplicate_inode(inode, cache_inode);
-                /*Here we must release the cache_inode,
-                 *Otherwise we will have no chance to
-                 *do it
+                
+                /*
+                 * here we must release the cache_inode, otherwise we will have
+                 * no chance to do it later.
                  */
-                cache_inode->i_state &=~I_LOCK;
+                //cache_inode->i_state &=~I_LOCK;
                 inode->i_blocks = cache_inode->i_blocks;
         }
 }
@@ -324,8 +337,9 @@ static inline void post_smfs_inode(struct inode *inode,
 static inline void pre_smfs_inode(struct inode *inode,
                                   struct inode *cache_inode)
 {
-        if (inode && cache_inode)
-                duplicate_inode(cache_inode, inode);
+        //if (inode && cache_inode) {
+                //cache_inode->i_state = inode->i_state;
+        //}
 }
 
 /* instantiate a file handle to the cache file */
@@ -360,18 +374,6 @@ static inline void duplicate_sb(struct super_block *dst_sb,
         dst_sb->s_flags = src_sb->s_flags;
 }
 
-static inline void d_unalloc(struct dentry *dentry)
-{
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
-        list_del(&dentry->d_hash);
-        INIT_LIST_HEAD(&dentry->d_hash);
-#else
-        hlist_del_init(&dentry->d_hash);
-        dentry->d_flags |= DCACHE_UNHASHED;
-#endif
-        dput(dentry); /* this will free the dentry memory */
-}
-
 static inline int smfs_get_dentry_name_index(struct dentry *dentry,
                                              struct qstr  *str,
                                              int *index)
@@ -410,59 +412,54 @@ static inline void smfs_free_dentry_name(struct qstr *str)
         OBD_FREE(name, str->len + 1);
 }
 
+static int smfs_d_delete(struct dentry * dentry) 
+{
+        return 1;
+}
+
+static inline void d_unalloc(struct dentry *dentry)
+{
+        struct dentry_operations dop = {
+                .d_delete = smfs_d_delete,
+        };
+        //this will invoke unhash and kill for dentry
+        dentry->d_op = &dop;
+        dput(dentry); /* this will free the dentry memory */
+}
+
 static inline struct dentry *pre_smfs_dentry(struct dentry *parent_dentry,
                                              struct inode *cache_inode,
-                                             struct dentry *dentry,
-                                             int           *index)
+                                             struct dentry *dentry)
 {
         struct dentry *cache_dentry = NULL;
-        struct qstr   name; 
         
-        smfs_get_dentry_name_index(dentry, &name, index);       
-        cache_dentry = d_alloc(parent_dentry, &name);
-        smfs_free_dentry_name(&name);
+        
+        if (!parent_dentry) {
+                cache_dentry = d_find_alias(cache_inode);
+                if (cache_dentry) 
+                        RETURN(cache_dentry);
+        }
+        
+        cache_dentry = d_alloc(parent_dentry, &dentry->d_name);
         if (!cache_dentry)
                 RETURN(NULL);
+        
         if (!parent_dentry)
                 cache_dentry->d_parent = cache_dentry;
-        if (cache_inode)
+        
+        if (cache_inode) {
+                atomic_inc(&cache_inode->i_count); //d_instantiate suppose that
                 d_add(cache_dentry, cache_inode);
+        }
+        
         RETURN(cache_dentry);
 }
 
 static inline void post_smfs_dentry(struct dentry *cache_dentry)
 {
-        if (!cache_dentry)
-                return;
-        if (cache_dentry->d_inode)
-                igrab(cache_dentry->d_inode);
-        d_unalloc(cache_dentry);
-}
-
-static inline int lookup_by_path(char *path, int flags, struct nameidata *nd)
-{
-        struct dentry *dentry = NULL;
-        int rc = 0;
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
-        if (path_init(path, flags, nd)) {
-#else
-        if (path_lookup(path, flags, nd)) {
-#endif
-                rc = path_walk(path, nd);
-                if (rc)
-                        RETURN(rc);
-        } else {
-                RETURN(-EINVAL);
-        }
-
-        dentry = nd->dentry;
-
-        if (!dentry->d_inode || is_bad_inode(dentry->d_inode)) {
-                path_release(nd);
-                RETURN(-ENODEV);
-        }
-        RETURN(rc);
+        if (cache_dentry)
+                d_unalloc(cache_dentry);
+        
 }
 
 /*FIXME there should be more conditions in this check*/
@@ -514,8 +511,10 @@ extern int smfs_write_extents(struct inode *dir, struct dentry *dentry,
                               unsigned long from, unsigned long num);
 extern int smfs_rec_setattr(struct inode *dir, struct dentry *dentry,
                             struct iattr *attr);
-extern int smfs_rec_precreate(struct dentry *dentry, int *num, struct obdo *oa);
-extern int smfs_rec_md(struct inode *inode, void * lmm, int lmm_size);
+extern int smfs_rec_precreate(struct dentry *dentry, int *num,
+                              struct obdo *oa);
+extern int smfs_rec_md(struct inode *inode, void * lmm, int lmm_size, 
+                      enum ea_type type);
 extern int smfs_rec_unpack(struct smfs_proc_args *args, char *record,
                            char **pbuf, int *opcode);