commit 0387f5f6fc6df41bfdfe4c92c5a060ff70f7d169
Author: Yiannis Pericleous <[EMAIL PROTECTED]>
Date:   Fri Feb 23 13:31:21 2007 -0500

    check mtime from all branches

diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index a2f7f10..3bb94fa 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -372,10 +372,13 @@ static int __open_dir(struct inode *inode, struct file 
*file)
        struct file *hidden_file;
        int bindex, bstart, bend;
        struct odf_dentry_info *odi;
+       struct timespec *newest;
        int err;
        bstart = fbstart(file) = dbstart(file->f_dentry);
        bend = fbend(file) = dbend(file->f_dentry);
 
+       newest = &file->f_dentry->d_inode->i_mtime;
+
        for (bindex = bstart; bindex <= bend; bindex++) {
                hidden_dentry = unionfs_lower_dentry_idx(file->f_dentry, 
bindex);
                if (!hidden_dentry)
@@ -391,6 +394,9 @@ static int __open_dir(struct inode *inode, struct file 
*file)
 
                unionfs_set_lower_file_idx(file, bindex, hidden_file);
 
+               if (timespec_compare(newest, &hidden_dentry->d_inode->i_mtime) 
< 0)
+                       newest = &hidden_dentry->d_inode->i_mtime;
+
                /* The branchget goes after the open, because otherwise
                 * we would miss the reference on release.
                 */
@@ -402,10 +408,10 @@ static int __open_dir(struct inode *inode, struct file 
*file)
        odi = odf_ic_dir(file->f_dentry);
        if (IS_ERR(odi))
                return PTR_ERR(odi);
-       err = odf_cache_dir(file->f_dentry, odi->dentry);
+       err = odf_cache_dir(file->f_dentry, odi->dentry, newest);
        /* FIXME: store the dentry somewhere */
        odf_put_info(odi);
-       return 0;
+       return err;
 }
 
 /* unionfs_open helper function: open a file */
diff --git a/fs/unionfs/dirfops.c b/fs/unionfs/dirfops.c
index e2ee58f..b533507 100644
--- a/fs/unionfs/dirfops.c
+++ b/fs/unionfs/dirfops.c
@@ -47,7 +47,7 @@ static int unionfs_readdir(struct file *file, void *dirent, 
filldir_t filldir)
 
        /* check if cached dir does not exist */        
        if (!odi->dentry->d_inode || !odi->dentry->d_inode->i_size) {
-               err = odf_cache_dir(file->f_dentry, odi->dentry);
+               err = odf_cache_dir(file->f_dentry, odi->dentry, 
&file->f_dentry->d_inode->i_mtime);
                if (err)
                        goto out;
 
diff --git a/fs/unionfs/dirhelper.c b/fs/unionfs/dirhelper.c
index a8e7ab5..3d81dfb 100644
--- a/fs/unionfs/dirhelper.c
+++ b/fs/unionfs/dirhelper.c
@@ -192,7 +192,7 @@ out:
 }
 
 /* Cache contents of dir to an odf/ic file */
-int odf_cache_dir(struct dentry *d_upper, struct dentry *d_odf)
+int odf_cache_dir(struct dentry *d_upper, struct dentry *d_odf, struct 
timespec *mtime)
 {
        int err = 0;
        struct dentry *hidden_dentry = NULL;
@@ -216,14 +216,13 @@ int odf_cache_dir(struct dentry *d_upper, struct dentry 
*d_odf)
        
        /* compare mtimes, do not proceed if equal */
        if (i_odf && i_odf->i_size) { 
-               if(timespec_equal(&i_odf->i_mtime,
-                               &d_upper->d_inode->i_mtime))
+               if(timespec_compare(&i_odf->i_mtime,mtime) >= 0)
                goto out;
                
        }
        dget(d_odf);
        mntget(UNIONFS_SB(sb)->odf->mnt);
-               
+
        /* force truncate if file exists */
        if (i_odf) {
                attr.ia_size = 0;
@@ -303,7 +302,7 @@ int odf_cache_dir(struct dentry *d_upper, struct dentry 
*d_odf)
        }
 
        /* set mtime of odf file to that of higher file */
-       attr.ia_mtime = d_upper->d_inode->i_mtime;
+       attr.ia_mtime = *mtime;//d_upper->d_inode->i_mtime;
        attr.ia_valid = ATTR_MTIME | ATTR_MTIME_SET | ATTR_FORCE;
        err = notify_change(d_odf, &attr);
 
diff --git a/fs/unionfs/odf.h b/fs/unionfs/odf.h
index 24e1f4b..f72d311 100644
--- a/fs/unionfs/odf.h
+++ b/fs/unionfs/odf.h
@@ -55,6 +55,7 @@ struct odf_dentry_info *odf_ic_dir(struct dentry *dir);
 int odf_write_dirent(struct file *filp, const char *name, int namelen, u64 
ino, unsigned int d_type);
 int odf_read_dirent(struct file *filp, char **name, int *namelen, u64 *ino, 
unsigned int *d_type);
 int odf_purge_dir_cache(struct dentry *dentry);
+int odf_cache_dir(struct dentry *d_upper, struct dentry *d_odf, struct 
timespec *mtime);
 
 int odf_rename(struct dentry *old_dentry, struct dentry *new_dentry);
 
@@ -77,8 +78,6 @@ int __odf_is_opaque(struct inode *i);
 int __odf_get_opaque(struct inode *i);
 int __odf_set_opaque(struct inode *i, int branch);
 
-int odf_cache_dir(struct dentry *d_upper, struct dentry *d_odf);
-
 /* Macros for locking an odf dentry info. */
 static inline void odf_lock(struct odf_dentry_info *odi)
 {
_______________________________________________
unionfs-cvs mailing list: http://unionfs.filesystems.org/
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs-cvs

Reply via email to