commit 16ea9c328802c7ae0de95fb1cbd986944407c70b
Author: Yiannis Pericleous <[EMAIL PROTECTED]>
Date:   Tue May 22 16:32:40 2007 -0400

    silly rename (move to /odf/sr) files to be removed that have i_count > 1

diff --git a/fs/unionfs/odf.c b/fs/unionfs/odf.c
index 04c4172..dd33968 100644
--- a/fs/unionfs/odf.c
+++ b/fs/unionfs/odf.c
@@ -195,6 +195,7 @@ out_free:
        odf_put_info(osi->odi_ns);
        odf_put_info(osi->odi_rc);
        odf_put_info(osi->odi_ic);
+       odf_put_info(osi->odi_sr);
        dput(osi->sb);
        dput(osi->whiteout);
        kfree(osi->branch_uuids);
@@ -310,16 +311,22 @@ out:
 
 /*
  * Moves the dentry to /odf/reclaim with the name of its inode no
+ * If sr is set silly rename it instead (move it to /odf/sr)
  */
-int odf_reclaim(struct dentry *dentry)
+int odf_reclaim(struct dentry *dentry, int sr)
 {
        struct inode *old_dir, *new_dir;
        struct dentry *odf_dentry, *old_dentry, *new_dentry;
        struct odf_dentry_info *odi;
        char *new_name = NULL;
        int err = 0;
+
        odf_dentry = UNIONFS_D(dentry)->odf_info->dentry;
-       odi = UNIONFS_SB(dentry->d_sb)->odf->odi_rc;
+       
+       if (sr)
+               odi = UNIONFS_SB(dentry->d_sb)->odf->odi_sr;
+       else
+               odi = UNIONFS_SB(dentry->d_sb)->odf->odi_rc;
        new_name = kzalloc(ODF_INAME_LEN, GFP_KERNEL);
        if (!new_name){
                err = -ENOMEM;
@@ -338,9 +345,6 @@ int odf_reclaim(struct dentry *dentry)
                goto out_unlock;
        }
 
-       /* this should never happen */
-       BUG_ON(new_dentry->d_inode);
-
        lock_rename(old_dentry->d_parent, new_dentry->d_parent);
        err = vfs_rename(old_dir, old_dentry, new_dir, new_dentry);
        unlock_rename(old_dentry->d_parent, new_dentry->d_parent);
@@ -1378,9 +1382,16 @@ int odf_remove(struct dentry *dentry, int flags)
        current->fsuid = 0;
        current->fsgid = 0;
        if (S_ISDIR(odi->dentry->d_inode->i_mode))
-               err = odf_reclaim(dentry);
-       else
-               err = vfs_unlink(odi->dentry->d_parent->d_inode, odi->dentry);
+               err = odf_reclaim(dentry, 0);
+       else {
+               if (atomic_read(&dentry->d_inode->i_count) <= 1)
+                       err = vfs_unlink(odi->dentry->d_parent->d_inode, 
odi->dentry);
+               else
+                       /* silly rename open files, so their ino does 
+                        * not get recycled while still open 
+                        */
+                       err = odf_reclaim(dentry, 1);
+       }
        current->fsuid = olduid;
        current->fsgid = oldgid;
        if (err)
diff --git a/fs/unionfs/odf.h b/fs/unionfs/odf.h
index 8f408c3..54b25b0 100644
--- a/fs/unionfs/odf.h
+++ b/fs/unionfs/odf.h
@@ -98,7 +98,7 @@ int odf_copyup_link(struct super_block *sb, struct dentry 
*old_dentry, struct de
 
 /* unlink */
 int odf_remove(struct dentry *dentry, int flags);
-int odf_reclaim(struct dentry *dentry);
+int odf_reclaim(struct dentry *dentry, int sr);
 
 /* whiteouts */
 int odf_create_wh(struct dentry *dentry);
_______________________________________________
unionfs-cvs mailing list: http://unionfs.filesystems.org/
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs-cvs

Reply via email to