commit 8432356104ad611236dbe74d82b1becee63683bb
Author: Yiannis Pericleous <[EMAIL PROTECTED]>
Date:   Mon Apr 30 13:53:17 2007 -0400

    more duplicate code

diff --git a/fs/unionfs/dirfops.c b/fs/unionfs/dirfops.c
index 1a8b279..15cc7f7 100644
--- a/fs/unionfs/dirfops.c
+++ b/fs/unionfs/dirfops.c
@@ -88,7 +88,6 @@ static int unionfs_readdir(struct file *file, void *dirent, 
filldir_t filldir)
        err = odf_read_dirent(odf_file, &name, &namelen, &ino, &d_type);
        if (err)
                goto out;
-       }
 
        /* filldir */
        err = filldir(dirent, name, namelen, odf_file->f_pos, ino, d_type);
diff --git a/fs/unionfs/dirhelper.c b/fs/unionfs/dirhelper.c
index 4c31571..0a83675 100644
--- a/fs/unionfs/dirhelper.c
+++ b/fs/unionfs/dirhelper.c
@@ -68,31 +68,6 @@ struct unionfs_cleanup_callback {
        u64 inodes;
 };
 
-static int rmdir_util_callback(void *dirent, const char *name, int namelen,
-                                loff_t offset, u64 ino, unsigned int d_type)
-{
-       int err = 0;
-       struct unionfs_rmdir_callback *buf = dirent;
-       struct dentry *dentry;
-
-       buf->filldir_called++;
-
-       if (name[0] == '.' &&
-               (namelen == 1 || (name[1] == '.' && namelen == 2)))
-                       goto out;
-
-/* callback structure for odf_cleanup*/
-struct unionfs_cleanup_callback {
-       int err;
-       int filldir_called;
-       int reclaim;
-       struct dentry *dir;
-       struct vfsmount *mnt;
-       struct dentry_stack *stack;
-       u64 blocks;
-       u64 inodes;
-};
-
 /* odf_cleanup callback */
 static int cleanup_util_callback(void *dirent, const char *name, int namelen,
                                 loff_t offset, u64 ino, unsigned int d_type)
@@ -709,396 +684,3 @@ out:
                err = success;
        return err;
 }
-
-/* Cache contents of dir to an odf/ic file */
-int odf_cache_dir(struct dentry *d_upper, struct dentry *d_odf, struct 
timespec *mtime)
-{
-       int err = 0;
-       struct dentry *hidden_dentry = NULL;
-       struct inode *i_odf;
-       struct super_block *sb;
-       struct file *hidden_file, *odf_file = NULL;
-       struct unionfs_rdutil_callback *buf = NULL;
-       int bindex, bstart, bend, bopaque;
-       struct iattr attr;
-
-       sb = d_upper->d_sb;
-retry:
-       unionfs_read_lock(sb);
-
-       if ((err = unionfs_partial_lookup(d_upper)))
-               goto out_sb;
-
-retry:
-       odf_lock(UNIONFS_SB(sb)->odf->odi_ic);
-       BUG_ON(!S_ISDIR(d_upper->d_inode->i_mode));
-
-       i_odf = d_odf->d_inode;
-
-       /* compare mtimes, do not proceed if equal, do not check if retrying 
after -ENOSPC */
-       if (i_odf && i_odf->i_size && !cleaned) {
-               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;
-               attr.ia_valid = ATTR_SIZE | ATTR_FORCE;
-               err = notify_change(d_odf, &attr);
-               if (err)
-                       goto out;
-       }
-       odf_file = dentry_open(d_odf,
-                       UNIONFS_SB(sb)->odf->mnt,
-                       O_TRUNC|O_CREAT|O_WRONLY);
-       if (IS_ERR(odf_file)){
-               err = PTR_ERR(odf_file);
-               dput(d_odf);
-               mntput(UNIONFS_SB(sb)->odf->mnt);
-               odf_file = NULL;
-               goto out;
-       }
-
-       bstart = dbstart(d_upper);
-       bend = dbend(d_upper);
-       bopaque = odf_get_opaque(sb, d_upper);
-       if (0 <= bopaque && bopaque < bend)
-               bend = bopaque;
-
-       buf = kmalloc(sizeof(struct unionfs_rdutil_callback), GFP_KERNEL);
-       if (!buf) {
-               err = -ENOMEM;
-               goto out;
-       }
-       buf->err = 0;
-       buf->mode = RD_CACHE_ODF;
-       buf->rdstate = alloc_rdstate(d_upper->d_inode, bstart);
-       if (!buf->rdstate) {
-               err = -ENOMEM;
-               goto out;
-       }
-
-       /* lock to prevent concurrent writes */
-       odf_lock(UNIONFS_D(d_upper)->odf_info);
-       /* Process the hidden directories with rdutil_callback as a filldir. */
-       for (bindex = bstart; bindex <= bend; bindex++) {
-               hidden_dentry = unionfs_lower_dentry_idx(d_upper, bindex);
-               if (!hidden_dentry)
-                       continue;
-               if (!hidden_dentry->d_inode)
-                       continue;
-               if (!S_ISDIR(hidden_dentry->d_inode->i_mode))
-                       continue;
-               dget(hidden_dentry);
-               mntget(unionfs_lower_mnt_idx(d_upper, bindex));
-               branchget(sb, bindex);
-               hidden_file =
-                   dentry_open(hidden_dentry, unionfs_lower_mnt_idx(d_upper, 
bindex),
-                               O_RDONLY);
-               if (IS_ERR(hidden_file)) {
-                       err = PTR_ERR(hidden_file);
-                       dput(hidden_dentry);
-                       branchput(sb, bindex);
-                       goto out_unlock;
-               }
-
-               do {
-                       buf->filldir_called = 0;
-                       buf->dir = d_upper;
-                       buf->filp = odf_file;
-                       buf->rdstate->bindex = bindex;
-                       err = vfs_readdir(hidden_file,
-                                         readdir_util_callback, buf);
-                       if (buf->err)
-                               err = buf->err;
-               } while ((err >= 0) && buf->filldir_called);
-
-               /* fput calls dput for hidden_dentry */
-               fput(hidden_file);
-               branchput(sb, bindex);
-
-               if (err < 0)
-                       goto out_unlock;
-       }
-       odf_unlock(UNIONFS_D(d_upper)->odf_info);
-
-       /* set mtime of odf file to that of higher file */
-       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);
-       goto out;
-
-out_unlock:
-       odf_unlock(UNIONFS_D(d_upper)->odf_info);
-
-out:
-       if (buf && buf->rdstate)
-               free_rdstate(buf->rdstate);
-       kfree(buf);
-       buf = NULL;
-
-       if (odf_file)
-               filp_close(odf_file, NULL);
-       odf_file = NULL;
-
-       odf_unlock(UNIONFS_SB(sb)->odf->odi_ic);
-
-       if (err == -ENOSPC && !cleaned) {
-               cleaned = 1;
-               wake_up_and_wait_sioa(UNIONFS_SB(sb)->odf->cleanup);
-               goto retry;
-       }
-
-out_sb:
-       unionfs_read_unlock(sb);
-       return err;
-}
-
-/* Remove the hidden dentry by:
- *     a) rmdir if its a physically empty dir
- *     b) silly rename if its not physically empty
- *     c) unlink if not a dir
- */
-int check_empty_lower(struct dentry *lower_dentry, struct vfsmount *mnt)
-{
-       struct file *lower_file;
-       struct unionfs_rdutil_callback *buf = NULL;
-       int err;
-
-       BUG_ON(!S_ISDIR(lower_dentry->d_inode->i_mode));
-
-       /* check if dir is empty */
-       buf = kmalloc(sizeof(struct unionfs_rdutil_callback), GFP_KERNEL);
-       if (!buf) {
-               err = -ENOMEM;
-               goto out;
-       }
-       buf->err = 0;
-       buf->mode = RD_CHECK_HD_EMPTY;
-       buf->rdstate = NULL;
-       buf->dir = NULL;
-       buf->filp = NULL;
-
-       dget(lower_dentry);
-       mntget(mnt);
-       lower_file = dentry_open(lower_dentry, mnt, O_RDONLY);
-       if (IS_ERR(lower_file)) {
-               err = PTR_ERR(lower_file);
-               dput(lower_dentry);
-               mntput(mnt);
-               goto out;
-       }
-
-       do {
-               buf->filldir_called = 0;
-               err = vfs_readdir(lower_file, readdir_util_callback, buf);
-               if (buf->err)
-                       err = buf->err;
-       } while ((err >= 0) && buf->filldir_called);
-
-       fput(lower_file);
-out:
-       kfree(buf);
-       return err;
-}
-
-/* Remove the hidden dentry by:
- *     a) rmdir if its a physically empty dir
- *     b) silly rename if its not physically empty
- *     c) unlink if not a dir
- */
-int unionfs_force_rm(struct dentry *dentry, struct dentry **hidden_dentry, int 
bindex)
-{
-       struct super_block *sb;
-       int err;
-
-       sb = dentry->d_sb;
-       if (!S_ISDIR((*hidden_dentry)->d_inode->i_mode)) {
-               err = vfs_unlink((*hidden_dentry)->d_parent->d_inode,
-                                               (*hidden_dentry));
-               if (err)
-                       goto out;
-               goto refresh;
-       }
-
-       /* check if dir is empty */
-       branchget(sb, bindex);
-       err = check_empty_lower(*hidden_dentry, unionfs_lower_mnt_idx(dentry, 
bindex));
-       branchput(sb, bindex);
-
-       if (err == 0)
-               err = vfs_rmdir((*hidden_dentry)->d_parent->d_inode, 
*hidden_dentry);
-
-       else if (err == -ENOTEMPTY)
-               err = unionfs_silly_rename(dentry, *hidden_dentry);
-
-       if (err)
-               goto out;
-
-refresh:
-       *hidden_dentry = lookup_one_len(dentry->d_name.name,
-                               (*hidden_dentry)->d_parent,
-                               dentry->d_name.len);
-       if (IS_ERR(*hidden_dentry)) {
-               err = PTR_ERR(*hidden_dentry);
-               goto out;
-       }
-       BUG_ON((*hidden_dentry)->d_inode);
-       dput(unionfs_lower_dentry_idx(dentry, bindex));
-       if (dentry->d_inode) {
-               iput(unionfs_lower_inode_idx(dentry->d_inode, bindex));
-               unionfs_set_lower_inode_idx(dentry->d_inode, bindex, NULL);
-       }
-       unionfs_set_lower_dentry_idx(dentry, bindex, *hidden_dentry);
-out:
-       return err;
-}
-
-/*
- * Cleanup function for the odf cleanup thread.
- * First cleans up the dir caches in odf/ic and then everything
- * in odf/reclaim. It stops once the requested blocks/inodes
- * were freed.
- * size contains the requested amount of inodes/blocks to be freed
- * MULTIPLIED BY 100
- * Modes :
- *     ODF_CLEAN_ALL: cleans all the dir caches and odf/reclaim
- *     ODF_CLEAN_CACHE: cleans all the dir caches
- *     ODF_CLEAN_BLOCKS: clean until size blocks are freed
- *     ODF_CLEAN_INODES: clean until size inodes are freed
- * Returns 1 if it manages to bring inodes/block below requested,
- * threshold and 0 if not.
- */
-int odf_cleanup(struct odf_sb_info *odf, int mode, u64 size)
-{
-       int err = 0;
-       struct file *file;
-       struct unionfs_cleanup_callback *buf = NULL;
-       struct dentry *dentry;
-       struct dentry_stack stack;
-       int success = 0, reclaim = 0;
-       loff_t bytes, isize;
-       int blocks;
-
-       stack.size = STACK_SIZE;
-       stack.n = 0;
-       stack.item = kmalloc(stack.size * sizeof(struct dentry *), GFP_KERNEL);
-       if (!stack.item) {
-               err = -ENOMEM;
-               goto out;
-       }
-
-       buf = kmalloc(sizeof(struct unionfs_cleanup_callback), GFP_KERNEL);
-       if (!buf) {
-               err = -ENOMEM;
-               goto out;
-       }
-       buf->err = 0;
-       buf->mnt = odf->mnt;
-       buf->reclaim = reclaim;
-       buf->blocks = 0;
-       buf->inodes = 0;
-       buf->stack = &stack;
-
-       /* first cleanup odf/ic */
-       dget(odf->odi_ic->dentry);
-       stack.item[stack.n++] = odf->odi_ic->dentry;
-
-
-cleanup_loop:
-       /* The cleanup loop pops a dentry off the stack, reads all
-        * its entries, unlinking dir cache files and files in
-        * odf/reclaim and pushing to the stack all directories
-        */
-       while (err >= 0 && stack.n > 0 && !success) {
-               dentry = stack.item[--stack.n]; /* pop */
-
-               /* we need to dget /reclaim dirs again since we need
-                * them after we close the file
-                */
-               if (reclaim)
-                       dget(dentry);
-               mntget(odf->mnt);
-
-               file = dentry_open(dentry, odf->mnt, O_RDONLY);
-               if (IS_ERR(file)) {
-                       err = PTR_ERR(file);
-                       dput(dentry);
-                       goto out;
-               }
-
-               buf->dir = dentry;
-               do {
-                       buf->filldir_called = 0;
-                       err = vfs_readdir(file, cleanup_util_callback, buf);
-                       if (buf->err)
-                               err = buf->err;
-               } while ((err >= 0) && buf->filldir_called);
-               fput(file);
-
-               if (!err && reclaim) {
-                       /* remove all directories in odf/reclaim
-                        * This assumes that the odf/reclaim dir structure
-                        * is entirely flat, ie only odf/reclaim contains
-                        * subdirectories
-                        */
-                       if (dentry != odf->odi_rc->dentry) {
-                               blocks = dentry->d_inode->i_blocks;
-                               bytes = blocks * dentry->d_sb->s_blocksize;
-                               isize = i_size_read(dentry->d_inode);
-                               while (bytes > isize) {
-                                       bytes -= dentry->d_sb->s_blocksize;
-                                       blocks--;
-                               }
-                               buf->blocks += blocks + 1;
-                               buf->inodes++;
-                               err = vfs_rmdir(dentry->d_parent->d_inode, 
dentry);
-                               BUG_ON(err == -ENOTEMPTY);
-                       }
-                       dput(dentry);
-               }
-
-               /* check if we have reached the threshold */
-               if (mode == ODF_CLEAN_BLOCKS && buf->blocks * 100 >= size)
-                       success = 1;
-               else if (mode == ODF_CLEAN_INODES && buf->inodes * 100 >= size)
-                       success = 1;
-       }
-
-       if (err < 0)
-               goto out;
-
-       if (mode == ODF_CLEAN_CACHE)
-               success = 1;
-
-       if (!success) {
-               BUG_ON(stack.n);
-
-               /* if we did not succeed, clean up odf/reclaim as well */
-               if (!reclaim) {
-                       reclaim = 1;
-                       buf->reclaim = 1;
-                       dget(odf->odi_rc->dentry);
-                       stack.item[stack.n++] = odf->odi_rc->dentry;
-                       goto cleanup_loop;
-               }
-       }
-
-       if (mode == ODF_CLEAN_ALL)
-               success = 1;
-
-out:
-       BUG_ON(stack.n < 0);
-       while(stack.n)
-               dput(stack.item[--stack.n]);
-
-       kfree(buf);
-       kfree(stack.item);
-       if (!err)
-               err = success;
-       return err;
-}
-
diff --git a/fs/unionfs/odf.c b/fs/unionfs/odf.c
index 174e3dc..d77495e 100644
--- a/fs/unionfs/odf.c
+++ b/fs/unionfs/odf.c
@@ -292,86 +292,6 @@ int odf_parse_options(char *options, char **odf_path)
 out:
        return err;
 }
-/*
- * Returns 0 if the given path is a valid odf file
- */
-int odf_is_odf(struct dentry *d_odf)
-{
-       struct dentry *magic;
-       int err = 0;
-
-       if (!d_odf->d_inode) {
-               err = -EINVAL;
-               goto out;
-       }
-
-       if (!S_ISDIR(d_odf->d_inode->i_mode)) {
-               err = -EINVAL;
-               goto out;
-       }
-
-       magic = lookup_one_len(ODF_MAGIC_FILE, d_odf, strlen(ODF_MAGIC_FILE));
-       if (IS_ERR(magic) || !magic) {
-               err = -EINVAL;
-               goto out;
-       }
-       else if (!magic->d_inode)
-               err = -EINVAL;
-
-       dput(magic);
-out:
-       if (err)
-               printk("unionfs: Invalid odf\n");
-       return err;
-}
-
-/* returns 1 if odfforce found, 0 if not */
-int odf_parse_options(char *options, char **odf_path)
-{
-       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;
-       char *ptr, *ptrend;
-
-       odf_dentry = UNIONFS_D(dentry)->odf_info->dentry;
-       odi = UNIONFS_SB(dentry->d_sb)->odf->odi_rc;
-
-       new_name = kzalloc(ODF_INAME_LEN, GFP_KERNEL);
-       if (!new_name){
-               err = -ENOMEM;
-               goto out;
-       }
-       sprintf(new_name, "%lu", odf_dentry->d_inode->i_ino);
-
-       /* lock new dir, the old dir should already be locked */
-       odf_lock(odi);
-
-       old_dentry = odf_dentry;
-       old_dir = odf_dentry->d_parent->d_inode;
-       new_dir = odi->dentry->d_inode;
-       new_dentry = lookup_one_len(new_name, odi->dentry, strlen(new_name));
-       if (IS_ERR(new_dentry)) {
-               err = PTR_ERR(new_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);
-       dput(new_dentry);
-
-out_unlock:
-       odf_unlock(odi); /* unlock new dir */
-
-out:
-       kfree(new_name);
-       return err;
-}
 
 /*
  * Rename in odf, expects UnionFS dentries.
@@ -845,54 +765,6 @@ out:
 }
 
 /*
- * Rename in odf, expects UnionFS dentries.
- * If the new_dentry exists (either as a file or wh)
- * it is removed using odf_remove (ie dirs are reclaimed)
- */
-int odf_rename(struct dentry *old_dentry, struct dentry *new_dentry)
-{
-       struct dentry *old_dir, *new_dir;
-       struct dentry *old_odfdentry, *new_odfdentry;
-       int err = 0;
-
-       err = odf_lookup(old_dentry->d_parent, old_dentry, 0);
-       if (err)
-               goto out;
-
-       err = odf_lookup(new_dentry->d_parent, new_dentry, 0);
-       if (err)
-               goto out;
-
-       /* if new exists, remove it */
-       if (UNIONFS_D(new_dentry)->odf_info)
-               err = odf_remove(new_dentry, ODF_RMV_ANY);
-
-       old_odfdentry = UNIONFS_D(old_dentry)->odf_info->dentry;
-       old_dir = old_odfdentry->d_parent;
-       new_dir = (UNIONFS_D(new_dentry->d_parent))->odf_info->dentry;
-       new_odfdentry = lookup_one_len(
-                               new_dentry->d_name.name,
-                               new_dir,
-                               new_dentry->d_name.len);
-       if (IS_ERR(new_odfdentry)) {
-               err = PTR_ERR(new_odfdentry);
-               goto out;
-       }
-
-       /* this should never happen */
-       BUG_ON(new_odfdentry->d_inode);
-
-       lock_rename(old_dir, new_dir);
-       err = vfs_rename(old_dir->d_inode,
-                       old_odfdentry, new_dir->d_inode,
-                       new_odfdentry);
-       unlock_rename(old_dir, new_dir);
-       dput(new_odfdentry);
-
-out:
-       return err;
-}
-/*
  * Lookup an entry in the odf, and create it if necessary
  * Returns a an odf_dentry_info containing whiteout and
  * opaqueness information. Also handles hard links.
@@ -1342,224 +1214,6 @@ out:
 }
 
 /*
- * Returns odf_dentry_info pointing to the location in the odf
- * for the given directory's cached contents
- */
-struct odf_dentry_info *odf_ic_cache_dentry(struct dentry *dir)
-{
-       struct odf_dentry_info *odi_dir;
-
-       odi_dir = UNIONFS_D(dir)->odf_info;
-       if (!odi_dir)
-               return ERR_PTR(-ENOENT);
-
-       if (!S_ISDIR(dir->d_inode->i_mode))
-               return ERR_PTR(-ENOTDIR);
-
-       return odf_ic_dentry(UNIONFS_SB(dir->d_sb)->odf,
-               dir->d_inode->i_ino, ODF_CONTENT, ODF_CONTENT_LEN);
-}
-
-/*
- * Returns odf_dentry_info pointing to the location in odf/ic
- * for the requested file name
- */
-struct odf_dentry_info *odf_ic_dentry(struct odf_sb_info *osi, u64 ino, char 
*name, int namelen)
-{
-       struct odf_dentry_info *odis[4], *odi_ic, *odi_ret = NULL;
-       int breakdown[4];
-       char tmp_name[6];
-       int i, err = 0;
-
-       odi_ic = osi->odi_ic;
-
-       for (i = 3; i >= 0; i--) {
-               breakdown[i] = ino & 0xFFFF;
-               ino >>= 16;
-               odis[i] = NULL;
-       }
-
-       memset(tmp_name,0,6);
-       sprintf(tmp_name, "%x", breakdown[0]);
-       odis[0] = odf_lookup_name(osi, odi_ic, tmp_name, strlen(tmp_name), 
ODF_LOOKUP_DIR, NULL);
-       if (IS_ERR(odis[0])) {
-               err = PTR_ERR(odis[0]);
-               odis[0] = NULL;
-               goto out;
-       }
-       for (i = 1; i < 4; i++) {
-               memset(tmp_name,0,6);
-               sprintf(tmp_name, "%x", breakdown[i]);
-               odis[i] = odf_lookup_name(osi, odis[i-1], tmp_name, 
strlen(tmp_name), ODF_LOOKUP_DIR, NULL);
-               if (IS_ERR(odis[i])) {
-                       err = PTR_ERR(odis[i]);
-                       odis[i] = NULL;
-                       goto out;
-               }
-       }
-
-       odi_ret = odf_lookup_name(osi, odis[3], name, namelen, ODF_LOOKUP_FILE, 
NULL);
-       if (IS_ERR(odi_ret)) {
-               err = PTR_ERR(odi_ret);
-               odi_ret = NULL;
-               goto out;
-       }
-out:
-       for (i = 0; i < 4; i++)
-               odf_put_info(odis[i]);
-
-       if (err)
-               return ERR_PTR(err);
-
-       return odi_ret;
-}
-/*
- * Write a dirent to the given file
- * FIXME: Instead of a file we should give the position
- * in the odf
- */
-int odf_write_dirent(struct file *filp, const char *name, int namelen,
-                               u64 ino, unsigned int d_type)
-{
-       int err = 0;
-       __le32 le32;
-       __le64 le64;
-       mm_segment_t oldfs;
-
-       oldfs = get_fs();
-       set_fs(KERNEL_DS);
-
-       le32 = cpu_to_le32(ODF_DIRENT_MAGIC);
-       err = filp->f_op->write(filp, (char*)&le32,
-                       sizeof(__le32), &filp->f_pos);
-       if (err != sizeof(__le32))
-               goto out;
-
-       le32 = cpu_to_le32(namelen);
-       err = filp->f_op->write(filp, (char*)&le32,
-                       sizeof(__le32), &filp->f_pos);
-       if (err != sizeof(__le32))
-               goto out;
-
-       err = filp->f_op->write(filp, (char*)name,
-                       namelen, &filp->f_pos);
-       if (err != namelen)
-               goto out;
-
-       le64 = cpu_to_le64(ino);
-       err = filp->f_op->write(filp, (char*)&le64,
-                       sizeof(__le64), &filp->f_pos);
-       if (err != sizeof(__le64))
-               goto out;
-
-       le32 = cpu_to_le32(d_type);
-       err =filp->f_op->write(filp, (char*)&le32,
-                       sizeof(__le32), &filp->f_pos);
-       if (err != sizeof(__le32))
-               goto out;
-
-       err = 0;
-out:
-       set_fs(oldfs);
-       if (err > 0)
-               err = -EIO;
-
-       return err;
-}
-/*
- * Reads the next dirent from the given file
- */
-int odf_read_dirent(struct file *filp, char **name, int *namelen,
-                               u64 *ino, unsigned int *d_type)
-{
-       int err = 0;
-       mm_segment_t oldfs;
-       __le32 le32;
-       __le64 le64;
-
-       oldfs = get_fs();
-       set_fs(KERNEL_DS);
-
-       err = filp->f_op->read(filp, (char*)&le32,
-                       sizeof(__le32), &filp->f_pos);
-       if (err != sizeof(__le32)) {
-               err = -EIO;
-               goto out;
-       }
-
-       /* check if we're reading at the correct offset */
-       if (le32_to_cpu(le32) != ODF_DIRENT_MAGIC) {
-               err = -EFAULT;
-               goto out;
-       }
-
-       err = filp->f_op->read(filp, (char*)&le32,
-                       sizeof(__le32), &filp->f_pos);
-       if (err != sizeof(__le32)) {
-               err = -EIO;
-               goto out;
-       }
-       *namelen = le32_to_cpu(le32);
-       if (*namelen <= 0) {
-               err = -EFAULT;
-               goto out;
-       }
-
-       *name = kmalloc(*namelen, GFP_KERNEL);
-       if (!(*name)) {
-               err = -ENOMEM;
-               goto out;
-       }
-       err = filp->f_op->read(filp, (char*)(*name),
-                       *namelen, &filp->f_pos);
-       if (err != *namelen) {
-               err = -EIO;
-               goto out;
-       }
-
-       err = filp->f_op->read(filp, (char*)&le64,
-                       sizeof(__le64), &filp->f_pos);
-       if (err != sizeof(__le64)) {
-               err = -EIO;
-               goto out;
-       }
-       *ino = le64_to_cpu(le64);
-       err = filp->f_op->read(filp, (char*)&le32,
-                       sizeof(__le32), &filp->f_pos);
-       if (err != sizeof(__le32)) {
-               err = -EIO;
-               goto out;
-       }
-       *d_type = le32_to_cpu(le32);
-
-       err = 0;
-out:
-       set_fs(oldfs);
-       return err;
-}
-
-/*
- * For now this just truncate the dir's content file
- */
-int odf_purge_dir_cache(struct dentry *dentry)
-{
-       int err = 0;
-       struct odf_dentry_info *odi = NULL;
-
-       odi = odf_ic_cache_dentry(dentry);
-       if (IS_ERR(odi)){
-               err = PTR_ERR(odi);
-               odi = NULL;
-               goto out;
-       }
-
-       err = vfs_unlink(odi->dentry->d_parent->d_inode, odi->dentry);
-out:
-       odf_put_info(odi);
-       return err;
-}
-
-/*
  * Unlinks the file from odf if exist, creates a new file with
  * the same name and sets its whiteout flag
  */
@@ -1699,53 +1353,6 @@ int odf_is_opaque(struct dentry *dentry)
        return __odf_is_opaque(UNIONFS_D(dentry)->odf_info->dentry->d_inode);
 }
 
-/* The opaque number stored with the odf inode is that of the branch id
- * which is not necessarily the same as the branch position, so we need to
- * convert the branch id to the branch position
- */
-int odf_get_opaque(struct super_block *sb, struct dentry *dentry)
-{
-       int i, opaque;
-
-       BUG_ON(!UNIONFS_D(dentry)->odf_info);
-
-       opaque = UNIONFS_D(dentry)->odf_info->opaque;
-
-       if (opaque == -1)
-               return -1;
-
-       i = branch_id_to_idx(sb, opaque);
-
-       /* if this is reached then the opaque branch was deleted, so dentry
-        * can no longer be considered opaque
-        */
-       if (i == -1)
-               odf_set_opaque(dentry, -1);
-       return i;
-}
-
-/*
- * Sets a dentry as opaque. The branch must be the branch_id as stored in 
unionfs sb.
- * If the dentry is not to be opaque, then branch must be -1
- * The dentry version takes a UnionFS dentry, the inode one an ODF inode
- */
-int odf_set_opaque(struct dentry *dentry, int branch)
-{
-       struct odf_dentry_info *odi = UNIONFS_D(dentry)->odf_info;
-       int err = __odf_set_opaque(odi->dentry->d_inode, branch);
-       if (!err)
-               odi->opaque = branch;
-       return err;
-}
-
-int __odf_set_opaque(struct dentry *d, int branch)
-{
-       struct iattr ia;
-       ia.ia_valid = ATTR_GID;
-       ia.ia_gid = branch + 1;  /* since gid is unsigned */
-       return notify_change(d, &ia);
-}
-
 /*
  * checks if the /odf/sb file exists
  */
@@ -1813,78 +1420,6 @@ out:
 }
 
 /*
- * Unsets the newbit
- */
-void odf_unset_newbit(struct odf_sb_info *osi)
-{
-       struct dentry *newbit;
-
-       /* check the new bit, for now check if file newbit exists */
-       newbit = lookup_one_len(ODF_NEWBIT, osi->odi_sb->dentry, 
strlen(ODF_NEWBIT));
-       if (IS_ERR(newbit) || !newbit)
-               return;
-       else if (unlikely(!newbit->d_inode)) {
-               dput(newbit);
-               return;
-       }
-       vfs_unlink(newbit->d_parent->d_inode, newbit);
-       dput(newbit);
-}
-
-/*
- * Generates uuids for branches and makes sure branches belonging to the same
- * filesystem get the same uuid.
- */
-int odf_update_uuids(struct odf_sb_info *odf, struct path *old_paths, int 
old_branches,
-                       struct path *new_paths, int new_branches)
-{
-       struct vfsmount *m;
-       char *old_uuids = odf->branch_uuids;
-       char *new_uuids;
-       int err = 0, bindex, i;
-
-       new_uuids = kmalloc(new_branches * UUID_LEN, GFP_KERNEL);
-       if (!new_uuids) {
-               err = -ENOMEM;
-               goto out;
-       }
-
-       for (bindex = 0; bindex < new_branches; bindex++) {
-
-               m = new_paths[bindex].mnt;
-
-               /* check if this fs was in the old uuids */
-               for (i = 0; i < old_branches; i++) {
-                       if (m == old_paths[i].mnt)
-                               break;
-               }
-
-               /* if yes, then give it the old uuid */
-               if (i != old_branches) {
-                       memcpy(new_uuids + bindex * UUID_LEN, old_uuids + i * 
UUID_LEN, UUID_LEN);
-                       continue;
-               }
-
-               /* now check the processed new branches */
-               for (i = 0; i < bindex; i++) {
-                       if (m == new_paths[i].mnt)
-                               break;
-               }
-
-               if (i != bindex)
-                       memcpy(new_uuids + bindex * UUID_LEN, new_uuids + i * 
UUID_LEN, UUID_LEN);
-
-               else    /* if this is a new fs in the union give it a new uuid 
*/
-                       generate_random_uuid(new_uuids + bindex * UUID_LEN);
-       }
-
-       kfree(odf->branch_uuids);
-       odf->branch_uuids = new_uuids;
-
-out:
-       return err;
-}
-/*
  * Writes the superblock data for new odf's, generates branch UUID's
  * Superblock contains:
  *     odf version number, numbers of branches
diff --git a/fs/unionfs/odf.h b/fs/unionfs/odf.h
index c4b989c..8ad17b6 100644
--- a/fs/unionfs/odf.h
+++ b/fs/unionfs/odf.h
@@ -137,21 +137,4 @@ static inline void odf_unlock(struct odf_dentry_info *odi)
 
 extern void generate_random_uuid(unsigned char uuid_out[16]);
 
-/* cleanup thread functions */
-extern void __odf_cleanup(void *args);
-int odf_cleanup(struct odf_sb_info *odf, int mode, u64 size);
-
-/* Macros for locking an odf dentry info. */
-static inline void odf_lock(struct odf_dentry_info *odi)
-{
-       mutex_lock(&odi->lock);
-}
-
-static inline void odf_unlock(struct odf_dentry_info *odi)
-{
-       mutex_unlock(&odi->lock);
-}
-
-extern void generate_random_uuid(unsigned char uuid_out[16]);
-
 #endif /* _ODF_H_ */
diff --git a/fs/unionfs/sioq.h b/fs/unionfs/sioq.h
index 6d64733..bc80a8a 100644
--- a/fs/unionfs/sioq.h
+++ b/fs/unionfs/sioq.h
@@ -88,21 +88,6 @@ struct sioa_args {
        };
 };
 
-struct sioa_args {
-       struct completion comp_thread;
-       struct completion comp_work;
-       struct task_struct *process;
-       signed long timeout;
-       void (*work) (void*);
-       struct mutex lock;
-       int waiting;
-       int complete;
-
-       union {
-               struct cleanup_args cleanup;
-       };
-};
-
 extern int __init init_sioq(void);
 extern __exit void stop_sioq(void);
 extern void run_sioq(work_func_t func, struct sioq_args *args);
diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h
index ea1feeb..3b726c7 100644
--- a/fs/unionfs/union.h
+++ b/fs/unionfs/union.h
@@ -116,17 +116,6 @@ struct odf_sb_info {
        struct dentry *whiteout;
 };
 
-/* odf sb data */
-struct odf_sb_info {
-       struct vfsmount *mnt;
-       struct odf_dentry_info *odi_ns;
-       struct odf_dentry_info *odi_sb;
-       struct odf_dentry_info *odi_rc;
-       struct odf_dentry_info *odi_ic;
-       struct sioa_args *cleanup;
-       int opaque_branch_id; /* should always be the branch id of branch 0*/
-};
-
 /* unionfs inode data in memory */
 struct unionfs_inode_info {
        int bstart;
diff --git a/fs/unionfs/unlink.c b/fs/unionfs/unlink.c
index 852ee59..0284d91 100644
--- a/fs/unionfs/unlink.c
+++ b/fs/unionfs/unlink.c
@@ -86,70 +86,6 @@ out:
 
        return err;
 }
-static int unionfs_do_unlink(struct inode *dir, struct dentry *dentry)
-{
-       struct dentry *hidden_dentry;
-       struct dentry *hidden_dir_dentry;
-       int bstart, bend, bindex;
-       int err = 0;
-
-       if ((err = unionfs_partial_lookup(dentry)))
-               goto out;
-
-       bstart = dbstart(dentry);
-       bend = dbend(dentry);
-
-       for (bindex = bstart; bindex <= bend; bindex++) {
-               hidden_dentry = unionfs_lower_dentry_idx(dentry, bindex);
-               if (!hidden_dentry)
-                       continue;
-
-               hidden_dir_dentry = lock_parent(hidden_dentry);
-
-               /* avoid destroying the hidden inode if the file is in use */
-               dget(hidden_dentry);
-               if (!(err = is_robranch_super(dentry->d_sb, bindex)))
-                       err = vfs_unlink(hidden_dir_dentry->d_inode, 
hidden_dentry);
-               else
-                       err = -EROFS;
-               dput(hidden_dentry);
-               fsstack_copy_attr_times(dir, hidden_dir_dentry->d_inode);
-               unlock_dir(hidden_dir_dentry);
-
-               if (err)
-                       break;
-       }
-
-       if (err) {
-               if (err == -EIO)
-                       printk(KERN_WARNING
-                               "unionfs_unlink: IO error unlinking from branch 
%d\n",
-                               bindex);
-               err = odf_create_wh(dentry);
-               if (err)
-                       goto out;
-       }
-
-       /* we want to update mtime here, since if the file to
-        * be removed was only on a rd only branch, then since
-        * the mtime of that branch has not changed, so the
-        * mtime of the upper file is not updated
-        */
-       odf_purge_dir_cache(dentry->d_parent);
-       attr.ia_mtime = current_kernel_time();
-       attr.ia_valid = ATTR_MTIME | ATTR_MTIME_SET | ATTR_FORCE;
-       err = notify_change(dentry->d_parent, &attr);
-
-out:
-       if (!err)
-               dentry->d_inode->i_nlink--;
-
-       /* We don't want to leave negative leftover dentries for revalidate. */
-       if (!err && opaque != -1)
-               update_bstart(dentry);
-
-       return err;
-}
 
 int unionfs_unlink(struct inode *dir, 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