commit d777c30de9ec340cf603530fcccf8cbeadf149c7
Author: Yiannis Pericleous <[EMAIL PROTECTED]>
Date:   Thu Mar 15 14:52:05 2007 -0400

    odf cleanup thread, removes everything from odf/reclaim
    
    whenever it wakes up

diff --git a/fs/unionfs/dirhelper.c b/fs/unionfs/dirhelper.c
index 6ce34ce..8901708 100644
--- a/fs/unionfs/dirhelper.c
+++ b/fs/unionfs/dirhelper.c
@@ -33,7 +33,6 @@ struct unionfs_rdutil_callback {
 };
 struct unionfs_rmdir_callback {
        int err;
-       int bindex;
        int filldir_called;
        struct dentry *dir;
        struct vfsmount *mnt;
@@ -60,7 +59,7 @@ static int rmdir_util_callback(void *dirent, const char 
*name, int namelen,
                BUG_ON(1); /*can this ever happen?*/
        
        if (d_type == DT_DIR)
-               err = unionfs_force_rmdir(buf->mnt, dentry, buf->bindex);
+               err = unionfs_force_rmdir(buf->mnt, dentry, 1);
        else
                err = vfs_unlink(buf->dir->d_inode, dentry);
        dput(dentry);
@@ -375,12 +374,12 @@ out:
 }
 
 /* This function recursively rermoves all the entries of a lower directory
- * at a specific branch and then the directory itself. It does not
- * cross branches, and does nothing visible to the union. It should
+ * at a specific branch and then the directory itself if rm_parent is set. It
+ * does not cross branches, and does nothing visible to the union. It should
  * only be used when both a whiteout and a dir at top branch exists
- * and we need to create a new dentry
+ * and we need to create a new dentry or in the odf
  */
-int unionfs_force_rmdir(struct vfsmount *mnt, struct dentry *hidden_dentry, 
int bindex)
+int unionfs_force_rmdir(struct vfsmount *mnt, struct dentry *hidden_dentry, 
int rm_parent)
 {
        int err = 0;
        struct file *hidden_file;
@@ -392,7 +391,6 @@ int unionfs_force_rmdir(struct vfsmount *mnt, struct dentry 
*hidden_dentry, int
                goto out;
        }
        buf->err = 0;
-       buf->bindex = bindex;
        buf->dir = hidden_dentry;
        buf->mnt = mnt;
 
@@ -422,8 +420,9 @@ int unionfs_force_rmdir(struct vfsmount *mnt, struct dentry 
*hidden_dentry, int
 
        if (err < 0)
                goto out;
-
-       err = vfs_rmdir(hidden_dentry->d_parent->d_inode, hidden_dentry);
+       
+       if (rm_parent)
+               err = vfs_rmdir(hidden_dentry->d_parent->d_inode, 
hidden_dentry);
 
 out:
        kfree(buf);
diff --git a/fs/unionfs/odf.c b/fs/unionfs/odf.c
index bd8285a..63cdc95 100644
--- a/fs/unionfs/odf.c
+++ b/fs/unionfs/odf.c
@@ -68,7 +68,7 @@ struct odf_sb_info* odf_read_super(char *options)
        }
        sioa->reclaim.odf = osi;
        osi->sioa = sioa;
-       run_sioa(sioa, __unionfs_reclaim_w, __unionfs_reclaim_d, 
ODF_RC_TIMEOUT);
+       run_sioa(sioa, __odf_reclaim_w, __odf_reclaim_d, ODF_RC_TIMEOUT);
 
        osi->mnt = nd.mnt;
        mntget(osi->mnt);
@@ -204,7 +204,7 @@ int odf_reclaim(struct dentry *dentry)
        int err = 0;
 
        odf_dentry = UNIONFS_D(dentry)->odf_info->dentry;
-       odi = UNIONFS_SB(dentry->d_sb)->odf->odi_sb;
+       odi = UNIONFS_SB(dentry->d_sb)->odf->odi_rc;
        
        new_name = kzalloc(ODF_INAME_LEN, GFP_KERNEL);
        if (!new_name){
@@ -1156,4 +1156,29 @@ void odf_put_info(struct odf_dentry_info *odi)
        kfree(odi);
 }
 
+/* 
+ * Worker function for the cleanup thread. It recursively removes all entries 
+ * in the reclaim directory
+ */
+void __odf_reclaim_w(void *args)
+{
+        struct sioa_args *sioa_args = (struct sioa_args *)args;
+        struct reclaim_args *rc = &sioa_args->reclaim;
+       struct odf_dentry_info *odi_rc;
+
+       odi_rc = rc->odf->odi_rc;
+       odf_lock(odi_rc);
+       unionfs_force_rmdir(rc->odf->mnt, odi_rc->dentry, 0);
+       odf_unlock(odi_rc);
+}
+
+/*
+ * done function for the cleanup thread. It returns true if the odf is umounted
+ */
+int __odf_reclaim_d(void *args)
+{
+        struct sioa_args *sioa_args = (struct sioa_args *)args;
+        struct reclaim_args *rc = &sioa_args->reclaim;
+        return !(rc->odf && rc->odf->odi_rc);
+}
 
diff --git a/fs/unionfs/odf.h b/fs/unionfs/odf.h
index c0f3e74..30de795 100644
--- a/fs/unionfs/odf.h
+++ b/fs/unionfs/odf.h
@@ -40,7 +40,7 @@
 #define ODF_DIRENT_MAGIC 0x0DFD1300
 
 /* Reclaim thread timeout */
-#define ODF_RC_TIMEOUT 1000
+#define ODF_RC_TIMEOUT 10000
 
 /* super */
 struct odf_sb_info* odf_read_super(char *options);
@@ -89,6 +89,10 @@ int __odf_is_opaque(struct inode *i);
 int __odf_get_opaque(struct inode *i);
 int __odf_set_opaque(struct inode *i, int branch);
 
+/* cleanup thread functions */
+extern void __odf_reclaim_w(void *args);
+extern int __odf_reclaim_d(void *args);
+
 /* Macros for locking an odf dentry info. */
 static inline void odf_lock(struct odf_dentry_info *odi)
 {
diff --git a/fs/unionfs/sioq.c b/fs/unionfs/sioq.c
index 6b90bf3..8f23c1d 100644
--- a/fs/unionfs/sioq.c
+++ b/fs/unionfs/sioq.c
@@ -88,21 +88,6 @@ void run_sioa(struct sioa_args *args, void (*work) (void*),
        kernel_thread(__run_sioa, args, 0);
 }
 
-void __unionfs_reclaim_w(void *args)
-{
-       struct sioa_args *sioa_args = (struct sioa_args *)args;
-       struct reclaim_args *rc = &sioa_args->reclaim;
-       
-       /* do work */
-}
-
-int __unionfs_reclaim_d(void *args)
-{
-       struct sioa_args *sioa_args = (struct sioa_args *)args;
-       struct reclaim_args *rc = &sioa_args->reclaim;
-       return !(rc->odf && rc->odf->odi_rc);
-}
-
 void __unionfs_create(struct work_struct *work)
 {
        struct sioq_args *args = container_of(work, struct sioq_args, work);
diff --git a/fs/unionfs/sioq.h b/fs/unionfs/sioq.h
index 1896dd0..545428c 100644
--- a/fs/unionfs/sioq.h
+++ b/fs/unionfs/sioq.h
@@ -75,8 +75,6 @@ extern void __unionfs_mkdir(struct work_struct *work);
 extern void __unionfs_mknod(struct work_struct *work);
 extern void __unionfs_symlink(struct work_struct *work);
 extern void __unionfs_unlink(struct work_struct *work);
-extern void __unionfs_reclaim_w(void *args);
-extern int __unionfs_reclaim_d(void *args);
 
 #endif /* _SIOQ_H */
 
diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h
index 0b7e078..395824d 100644
--- a/fs/unionfs/union.h
+++ b/fs/unionfs/union.h
@@ -312,7 +312,7 @@ int unionfs_unlink(struct inode *dir, struct dentry 
*dentry);
 int unionfs_rmdir(struct inode *dir, struct dentry *dentry);
 
 int __unionfs_d_revalidate_chain(struct dentry *dentry, struct nameidata *nd);
-int unionfs_force_rmdir(struct vfsmount *mnt, struct dentry *hidden_dentry, 
int bindex);
+int unionfs_force_rmdir(struct vfsmount *mnt, struct dentry *hidden_dentry, 
int rm_parent);
 int unionfs_force_rm(struct dentry *dentry, struct dentry **hidden_dentry, int 
bindex);
 int unionfs_silly_rename(struct dentry *dentry, struct dentry *hidden_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