Whamcloud - gitweb
Update smfs:some minor fix in smfs
authorwangdi <wangdi>
Wed, 25 Feb 2004 09:18:29 +0000 (09:18 +0000)
committerwangdi <wangdi>
Wed, 25 Feb 2004 09:18:29 +0000 (09:18 +0000)
lustre/smfs/dir.c
lustre/smfs/file.c
lustre/smfs/inode.c

index d194bb8..a5c7765 100644 (file)
@@ -162,6 +162,7 @@ static int smfs_link(struct dentry * old_dentry,
        prepare_parent_dentry(&parent_old, cache_dir);
        cache_old_dentry = d_alloc(&parent_old, &dentry->d_name);
        d_add(cache_old_dentry, cache_old_inode); 
+       pre_smfs_inode(inode, cache_old_dentry->d_inode);
        
        if (cache_dir->i_op->link)
                rc = cache_dir->i_op->link(cache_old_dentry, cache_dir, cache_dentry);          
@@ -201,6 +202,9 @@ static int smfs_unlink(struct inode * dir,
        cache_dentry = d_alloc(&parent, &dentry->d_name);
        d_add(cache_dentry, cache_inode);
 
+       pre_smfs_inode(dentry->d_inode, cache_dentry->d_inode);
+       pre_smfs_inode(dir, cache_dir);
+       
        if (cache_dir->i_op->unlink)
                rc = cache_dir->i_op->unlink(cache_dir, cache_dentry);
 
@@ -272,6 +276,7 @@ static int smfs_mkdir(struct inode * dir,
        prepare_parent_dentry(&parent, cache_dir);
        cache_dentry = d_alloc(&parent, &dentry->d_name);
 
+       pre_smfs_inode(dir, cache_dir);
        lock_kernel();  
        if (cache_dir->i_op->mkdir)
                rc = cache_dir->i_op->mkdir(cache_dir, cache_dentry, mode);
@@ -312,9 +317,12 @@ static int  smfs_rmdir(struct inode * dir,
        prepare_parent_dentry(&parent, cache_dir);
        cache_dentry = d_alloc(&parent, &dentry->d_name);
        d_add(cache_dentry, cache_inode);
-       
        igrab(cache_inode);
        
+       pre_smfs_inode(dir, cache_dir);
+       pre_smfs_inode(dentry->d_inode, cache_dentry->d_inode);
+       
+       
        if (cache_dir->i_op->rmdir)
                rc = cache_dir->i_op->rmdir(cache_dir, cache_dentry);
 
@@ -340,6 +348,9 @@ static int smfs_mknod(struct inode * dir, struct dentry *dentry,
        prepare_parent_dentry(&parent, cache_dir);
        cache_dentry = d_alloc(&parent, &dentry->d_name);
        
+       pre_smfs_inode(dir, cache_dir);
+       pre_smfs_inode(dentry->d_inode, cache_dentry->d_inode);
+       
        if (cache_dir->i_op->mknod)
                rc = cache_dir->i_op->mknod(cache_dir, cache_dentry, mode, rdev);
        
@@ -379,6 +390,9 @@ static int smfs_rename(struct inode * old_dir, struct dentry *old_dentry,
        prepare_parent_dentry(&parent_new, cache_new_dir);
        cache_new_dentry = d_alloc(&parent_new, &new_dentry->d_name);
        
+       pre_smfs_inode(old_dir, cache_old_dir) ;
+       pre_smfs_inode(new_dir, cache_new_dir);
+       
        if (cache_old_dir->i_op->rename)
                rc = cache_old_dir->i_op->rename(cache_old_dir, cache_old_dentry,
                                                 cache_new_dir, cache_new_dentry);
index 15d57e6..eaf1901 100644 (file)
@@ -87,6 +87,8 @@ static ssize_t smfs_write (struct file *filp, const char *buf,
        
        smfs_prepare_cachefile(inode, filp, cache_inode, 
                               &open_file, &open_dentry);
+       pre_smfs_inode(inode, cache_inode);
+       
        if (cache_inode->i_fop->write)
                rc = cache_inode->i_fop->write(&open_file, buf, count, cache_ppos);
        
@@ -153,6 +155,7 @@ static ssize_t smfs_read (struct file *filp, char *buf,
                               &open_file, &open_dentry);
 
        
+       pre_smfs_inode(inode, cache_inode);
        if (cache_inode->i_fop->read)
                rc = cache_inode->i_fop->read(&open_file, buf, count, cache_ppos);
     
@@ -181,6 +184,7 @@ static loff_t smfs_llseek(struct file *file,
        smfs_prepare_cachefile(dentry->d_inode, file, cache_inode, 
                               &open_file, &open_dentry);
        
+       pre_smfs_inode(dentry->d_inode, cache_inode);
        if (cache_inode->i_fop->llseek)
                rc = cache_inode->i_fop->llseek(&open_file, offset, origin);
 
@@ -208,6 +212,7 @@ static int smfs_mmap(struct file * file, struct vm_area_struct * vma)
        if (cache_inode->i_mapping == &cache_inode->i_data)
                 inode->i_mapping = cache_inode->i_mapping;
 
+       pre_smfs_inode(inode, cache_inode);
        if (cache_inode->i_fop->mmap)
                rc = cache_inode->i_fop->mmap(&open_file, vma);
       
@@ -231,6 +236,7 @@ static int smfs_open(struct inode * inode, struct file * filp)
        smfs_prepare_cachefile(inode, filp, cache_inode, 
                               &open_file, &open_dentry);
        
+       pre_smfs_inode(inode, cache_inode);
        if (cache_inode->i_fop->open)
                rc = cache_inode->i_fop->open(cache_inode, &open_file);
         
@@ -254,6 +260,7 @@ static int smfs_release(struct inode * inode, struct file * filp)
        smfs_prepare_cachefile(inode, filp, cache_inode, 
                               &open_file, &open_dentry);
 
+       pre_smfs_inode(inode, cache_inode);
        if (cache_inode->i_fop->release)
                rc = cache_inode->i_fop->release(cache_inode, &open_file);
 
@@ -279,6 +286,7 @@ int smfs_fsync(struct file * file,
        smfs_prepare_cachefile(inode, file, cache_inode, 
                               &open_file, &open_dentry);
 
+       pre_smfs_inode(inode, cache_inode);
        if (cache_inode->i_fop->fsync)
                rc = cache_inode->i_fop->fsync(&open_file, &open_dentry, datasync);
        
index dbc42a2..117d503 100644 (file)
@@ -33,17 +33,21 @@ static void duplicate_inode(struct inode *dst_inode,
 void post_smfs_inode(struct inode *inode, 
                     struct inode *cache_inode)
 {
-       duplicate_inode(inode, cache_inode);
-       /*Here we must release the cache_inode,
-        *Otherwise we will have no chance to
-        *do it
-        */
-       cache_inode->i_state &=~I_LOCK; 
+       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
+                */
+               cache_inode->i_state &=~I_LOCK; 
+       }
 }
 void pre_smfs_inode(struct inode *inode,
                    struct inode *cache_inode)
 {
-       duplicate_inode(cache_inode, inode);
+       if (inode && cache_inode) {
+               duplicate_inode(cache_inode, inode);
+       }
 }
 
 static void smfs_read_inode(struct inode *inode)