commit 2b8dfe8cdff6926373b82e278cfc3fee75622755
Author: Yiannis Pericleous <[EMAIL PROTECTED]>
Date:   Fri May 25 23:50:10 2007 -0400

    changed unionfs_dentry_info to contain an odf_dentry_info instead of a 
pointer to one

diff --git a/fs/unionfs/dirhelper.c b/fs/unionfs/dirhelper.c
index a811945..d4a89fa 100644
--- a/fs/unionfs/dirhelper.c
+++ b/fs/unionfs/dirhelper.c
@@ -187,7 +187,7 @@ find:
                ino = odf_dentry->d_inode->i_ino;
        err = odf_write_dirent(buf->filp, name, namelen, ino, d_type);
 out:
-       odf_put_info(odi);
+       dput(odf_dentry);
        buf->err = err;
        return err;
 }
diff --git a/fs/unionfs/export.c b/fs/unionfs/export.c
index 828622e..1c27ba6 100644
--- a/fs/unionfs/export.c
+++ b/fs/unionfs/export.c
@@ -6,7 +6,7 @@ extern struct export_operations export_op_default;
 
 static struct dentry *__get_parent(struct super_block *sb, struct dentry 
*odf_dentry)
 {
-       struct dentry *odf_root = UNIONFS_D(sb->s_root)->odf_info->dentry;
+       struct dentry *odf_root = UNIONFS_D(sb->s_root)->odf.dentry;
        struct dentry *d, *d_parent, *parent, *child = NULL;
        struct dentry_stack stack;
        char *name = NULL;
@@ -77,11 +77,11 @@ static struct dentry *__get_parent(struct super_block *sb, 
struct dentry *odf_de
                        BUG_ON(d == odf_root);
                        if (odf_root->d_sb->s_export_op->get_name)
                                res = odf_root->d_sb->s_export_op->get_name(
-                                       UNIONFS_D(parent)->odf_info->dentry,
+                                       UNIONFS_D(parent)->odf.dentry,
                                        name, d);
                        else
                                res = export_op_default.get_name(
-                                       UNIONFS_D(parent)->odf_info->dentry,
+                                       UNIONFS_D(parent)->odf.dentry,
                                        name, d);
                }
                else
@@ -181,7 +181,7 @@ static int unionfs_get_name(struct dentry *dentry, char 
*name, struct dentry *ch
        if (!dir->i_fop)
                goto out;
 
-       if (!UNIONFS_D(dentry) || !UNIONFS_D(dentry)->odf_info)
+       if (!UNIONFS_D(dentry) || !UNIONFS_D(dentry)->odf.dentry)
                goto out;
 
        odf_cache = odf_ic_cache_dentry(dentry);
diff --git a/fs/unionfs/inode.c b/fs/unionfs/inode.c
index b279cc0..4ddf9b8 100644
--- a/fs/unionfs/inode.c
+++ b/fs/unionfs/inode.c
@@ -74,7 +74,7 @@ static int unionfs_create(struct inode *parent, struct dentry 
*dentry,
                }
        }
 
-       if (hidden_dentry->d_inode && UNIONFS_D(dentry)->odf_info->whiteout) {
+       if (hidden_dentry->d_inode && UNIONFS_D(dentry)->odf.whiteout) {
                err = unionfs_force_rm(dentry, &hidden_dentry, bstart);
                if (err)
                        goto out;
@@ -207,7 +207,7 @@ static int unionfs_link(struct dentry *old_dentry, struct 
inode *dir,
        hidden_new_dentry = unionfs_lower_dentry(new_dentry);
        hidden_old_dentry = unionfs_lower_dentry(old_dentry);
 
-       if (hidden_new_dentry->d_inode && 
UNIONFS_D(new_dentry)->odf_info->whiteout) {
+       if (hidden_new_dentry->d_inode && UNIONFS_D(new_dentry)->odf.whiteout) {
                err = unionfs_force_rm(new_dentry, &hidden_new_dentry, 
dbstart(old_dentry));
                if (err)
                        goto out;
@@ -236,7 +236,7 @@ docopyup:
                                        new_dentry->d_name.name, bindex);
                        hidden_old_dentry = unionfs_lower_dentry(old_dentry);
                        if (hidden_new_dentry->d_inode &&
-                                       
UNIONFS_D(new_dentry)->odf_info->whiteout) {
+                                       UNIONFS_D(new_dentry)->odf.whiteout) {
                                err = unionfs_force_rm(new_dentry,
                                                &hidden_new_dentry,
                                                dbstart(old_dentry));
@@ -327,7 +327,7 @@ static int unionfs_symlink(struct inode *dir, struct dentry 
*dentry,
                }
        }
 
-       if (hidden_dentry->d_inode && UNIONFS_D(dentry)->odf_info->whiteout) {
+       if (hidden_dentry->d_inode && UNIONFS_D(dentry)->odf.whiteout) {
                err = unionfs_force_rm(dentry, &hidden_dentry, bstart);
                if (err)
                        goto out;
@@ -406,7 +406,7 @@ static int unionfs_mkdir(struct inode *parent, struct 
dentry *dentry, int mode)
                }
        }
 
-       if (hidden_dentry->d_inode && UNIONFS_D(dentry)->odf_info->whiteout) {
+       if (hidden_dentry->d_inode && UNIONFS_D(dentry)->odf.whiteout) {
                err = unionfs_force_rm(dentry, &hidden_dentry, bindex);
                if (err)
                        goto out;
@@ -501,7 +501,7 @@ static int unionfs_mknod(struct inode *dir, struct dentry 
*dentry, int mode,
                }
        }
 
-       if (hidden_dentry->d_inode && UNIONFS_D(dentry)->odf_info->whiteout) {
+       if (hidden_dentry->d_inode && UNIONFS_D(dentry)->odf.whiteout) {
                err = unionfs_force_rm(dentry, &hidden_dentry, bstart);
                if (err)
                        goto out;
diff --git a/fs/unionfs/lookup.c b/fs/unionfs/lookup.c
index cf92d64..f8e4eb0 100644
--- a/fs/unionfs/lookup.c
+++ b/fs/unionfs/lookup.c
@@ -85,8 +85,8 @@ struct dentry *unionfs_lookup_backend(struct dentry *dentry, 
struct nameidata *n
                        goto out;
 
                /* return negative dentry if a whiteout */
-               if (UNIONFS_D(dentry)->odf_info &&
-                       UNIONFS_D(dentry)->odf_info->whiteout){
+               if (UNIONFS_D(dentry)->odf.dentry &&
+                       UNIONFS_D(dentry)->odf.whiteout){
                        bindex = 0;
                        goto out_negative;
                }
@@ -248,7 +248,7 @@ out_negative:
 /* This part of the code is for positive dentries. */
 out_positive:
        BUG_ON(dentry_count <= 0);
-       BUG_ON(UNIONFS_D(dentry)->odf_info && 
UNIONFS_D(dentry)->odf_info->whiteout);
+       BUG_ON(UNIONFS_D(dentry)->odf.dentry && 
UNIONFS_D(dentry)->odf.whiteout);
 
        /*
         * If we're holding onto the first negative dentry & corresponding
@@ -260,8 +260,8 @@ out_positive:
        /* Partial lookups need to re-interpose, or throw away older negs. */
        if (lookupmode == INTERPOSE_PARTIAL) {
                err = odf_lookup(parent_dentry, dentry, 0);
-               if (UNIONFS_D(dentry)->odf_info &&
-                               UNIONFS_D(dentry)->odf_info->whiteout){
+               if (UNIONFS_D(dentry)->odf.dentry &&
+                               UNIONFS_D(dentry)->odf.whiteout){
                        err = -ENOENT;
                        goto out_drop;
                }
@@ -292,8 +292,8 @@ out_positive:
                goto out_drop;
 
        /* check for whiteout && opaqueness */
-       if (UNIONFS_D(dentry)->odf_info) {
-               if (UNIONFS_D(dentry)->odf_info->whiteout){
+       if (UNIONFS_D(dentry)->odf.dentry) {
+               if (UNIONFS_D(dentry)->odf.whiteout){
                        err = -ENOENT;
                        goto out_drop;
                }
@@ -361,13 +361,13 @@ int unionfs_partial_lookup(struct dentry *dentry)
        tmp = unionfs_lookup_backend(dentry, &nd, INTERPOSE_PARTIAL);
        if (!tmp) {
                int err = 0;
-               if (UNIONFS_D(dentry) && !UNIONFS_D(dentry)->odf_info) {
+               if (UNIONFS_D(dentry) && !UNIONFS_D(dentry)->odf.dentry) {
                        tmp = unionfs_lower_dentry_idx(dentry, 0);
                        if (dentry->d_inode || (tmp && tmp->d_inode)) {
                                err = odf_lookup(dentry->d_parent, dentry, 0);
                                if (err)
                                        return  err;
-                               BUG_ON(!UNIONFS_D(dentry)->odf_info);
+                               BUG_ON(!UNIONFS_D(dentry)->odf.dentry);
                        }
 
                }
@@ -402,7 +402,8 @@ void free_dentry_private_data(struct unionfs_dentry_info 
*udi)
 {
        if (!udi)
                return;
-       odf_put_info(udi->odf_info);
+       dput(udi->odf.dentry);
+       udi->odf.dentry = NULL;
        kmem_cache_free(unionfs_dentry_cachep, udi);
 }
 
@@ -429,7 +430,7 @@ int new_dentry_private_data(struct dentry *dentry)
 
        info->bstart = info->bend = -1;
        info->bcount = sbmax(dentry->d_sb);
-       info->odf_info = NULL;
+       info->odf.dentry = NULL;
        atomic_set(&info->generation,
                   atomic_read(&UNIONFS_SB(dentry->d_sb)->generation));
 
diff --git a/fs/unionfs/main.c b/fs/unionfs/main.c
index fbb5ab5..9741e94 100644
--- a/fs/unionfs/main.c
+++ b/fs/unionfs/main.c
@@ -80,7 +80,7 @@ struct dentry *unionfs_interpose(struct dentry *dentry, 
struct super_block *sb,
        } else {
                ino_t ino;
                /* get unique inode number for unionfs */
-               if (!UNIONFS_D(dentry)->odf_info)
+               if (!UNIONFS_D(dentry)->odf.dentry)
                        err = odf_lookup(dentry->d_parent, dentry, odf_flag);
                if (err){
                        printk("unionfs_interpose: odf failed to create dentry: 
%s, %d\n",
@@ -88,7 +88,7 @@ struct dentry *unionfs_interpose(struct dentry *dentry, 
struct super_block *sb,
                        goto out;
                }
                /* check whiteouts and opaqueness */
-               if (UNIONFS_D(dentry)->odf_info->whiteout){
+               if (UNIONFS_D(dentry)->odf.whiteout){
                        err = -ENOENT;
                        goto out;
                }
@@ -96,7 +96,7 @@ struct dentry *unionfs_interpose(struct dentry *dentry, 
struct super_block *sb,
                if (opaque >= 0)
                        set_dbend(dentry, opaque);
 
-               ino = UNIONFS_D(dentry)->odf_info->dentry->d_inode->i_ino;
+               ino = UNIONFS_D(dentry)->odf.dentry->d_inode->i_ino;
 
                inode = iget(sb, ino);
                if (!inode) {
@@ -734,9 +734,11 @@ static int unionfs_read_super(struct super_block *sb, void 
*raw_data,
        set_dbstart(sb->s_root, bstart);
        set_dbend(sb->s_root, bend);
 
-       /* save odf root dentry */
-       UNIONFS_D(sb->s_root)->odf_info =
-               odf_fill_info(NULL, &UNIONFS_SB(sb)->odf, 
UNIONFS_SB(sb)->odf.ns);
+       /* save /odf/ns as odf dentry for root */
+       dget(UNIONFS_SB(sb)->odf.ns);
+       UNIONFS_D(sb->s_root)->odf.dentry = UNIONFS_SB(sb)->odf.ns;
+       UNIONFS_D(sb->s_root)->odf.opaque = -1; /* root can never be opq */
+       UNIONFS_D(sb->s_root)->odf.whiteout = 0; /* nor a whiteout */
 
        /* Set the generation number to one, since this is for the mount. */
        atomic_set(&UNIONFS_D(sb->s_root)->generation, 1);
diff --git a/fs/unionfs/odf.c b/fs/unionfs/odf.c
index fdbf681..9bbd9cf 100644
--- a/fs/unionfs/odf.c
+++ b/fs/unionfs/odf.c
@@ -324,7 +324,7 @@ int odf_reclaim(struct dentry *dentry, int sr)
        char *new_name = NULL;
        int err = 0;
 
-       odf_dentry = UNIONFS_D(dentry)->odf_info->dentry;
+       odf_dentry = UNIONFS_D(dentry)->odf.dentry;
 
        if (sr)
                new_dir = UNIONFS_SB(dentry->d_sb)->odf.sr;
@@ -430,7 +430,7 @@ int odf_rename(struct dentry *old_dentry, struct dentry 
*new_dentry)
        if (err)
                goto out;
 
-       if (UNIONFS_D(old_dentry)->odf_info == NULL) {
+       if (UNIONFS_D(old_dentry)->odf.dentry == NULL) {
                printk("rename attempt %s to %s not in odf\n",
                        old_dentry->d_name.name,
                        new_dentry->d_name.name);
@@ -441,12 +441,12 @@ int odf_rename(struct dentry *old_dentry, struct dentry 
*new_dentry)
                goto out;
 
        /* if new exists, remove it */
-       if (UNIONFS_D(new_dentry)->odf_info)
+       if (UNIONFS_D(new_dentry)->odf.dentry)
                err = odf_remove(new_dentry, ODF_RMV_ANY);
 
-       old_odfdentry = UNIONFS_D(old_dentry)->odf_info->dentry;
+       old_odfdentry = UNIONFS_D(old_dentry)->odf.dentry;
        old_dir = old_odfdentry->d_parent;
-       new_dir = (UNIONFS_D(new_dentry->d_parent))->odf_info->dentry;
+       new_dir = (UNIONFS_D(new_dentry->d_parent))->odf.dentry;
        new_odfdentry = lookup_one_len(
                                new_dentry->d_name.name,
                                new_dir,
@@ -494,12 +494,12 @@ int odf_link(struct dentry *old_dentry, struct dentry 
*new_dentry)
                goto out;
 
        /* if new exists, remove it */
-       if (UNIONFS_D(new_dentry)->odf_info)
+       if (UNIONFS_D(new_dentry)->odf.dentry)
                err = odf_remove(new_dentry, ODF_RMV_ANY);
 
-       old_odfdentry = UNIONFS_D(old_dentry)->odf_info->dentry;
+       old_odfdentry = UNIONFS_D(old_dentry)->odf.dentry;
        old_dir = old_odfdentry->d_parent;
-       new_dir = (UNIONFS_D(new_dentry->d_parent))->odf_info->dentry;
+       new_dir = (UNIONFS_D(new_dentry->d_parent))->odf.dentry;
        new_odfdentry = lookup_one_len(
                                new_dentry->d_name.name,
                                new_dir,
@@ -962,9 +962,13 @@ int odf_lookup(struct dentry *parent, struct dentry 
*dentry, int flags)
 
        ret = __odf_lookup(parent, dentry, dentry->d_name.name,
                           dentry->d_name.len, flags, NULL);
-       if (IS_ERR(ret))
+       if (IS_ERR(ret)) {
+               BUG_ON(UNIONFS_D(dentry)->odf.dentry);
                err = PTR_ERR(ret);
+       }
 
+       if (err == -ENOENT)
+               err = 0;
 out:
        dput(links);
        if (link_file)
@@ -1109,17 +1113,15 @@ out:
  */
 struct dentry *odf_ic_cache_dentry(struct dentry *dir)
 {
-       struct odf_dentry_info *odi_dir;
-
-       odi_dir = UNIONFS_D(dir)->odf_info;
-       if (!odi_dir)
+       if (!UNIONFS_D(dir)->odf.dentry)
                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);
+                            dir->d_inode->i_ino,
+                            ODF_CONTENT, ODF_CONTENT_LEN);
 }
 
 /*
@@ -1371,8 +1373,8 @@ int odf_create_wh(struct dentry *dentry)
 {
        int err = 0;
        struct dentry *odf_dentry;
-       if (UNIONFS_D(dentry)->odf_info) {
-               odf_dentry = UNIONFS_D(dentry)->odf_info->dentry;
+       if (UNIONFS_D(dentry)->odf.dentry) {
+               odf_dentry = UNIONFS_D(dentry)->odf.dentry;
                if (__odf_is_wh(&UNIONFS_SB(dentry->d_sb)->odf, odf_dentry))
                        goto out;       /* nothing to be done */
                /* remove entry if existed */
@@ -1385,8 +1387,8 @@ int odf_create_wh(struct dentry *dentry)
 
        if (err)
                goto out;
-       odf_put_info(UNIONFS_D(dentry)->odf_info);
-       UNIONFS_D(dentry)->odf_info = NULL;
+       dput(UNIONFS_D(dentry)->odf.dentry);
+       UNIONFS_D(dentry)->odf.dentry = NULL;
 out:
        return err;
 }
@@ -1404,8 +1406,7 @@ out:
  */
 int odf_remove(struct dentry *dentry, int flags)
 {
-       struct odf_dentry_info *odf_dir;
-       struct odf_dentry_info *odi = NULL;
+       struct dentry *odf_dentry = NULL;
        int err = 0, rmv = 0;
        uid_t olduid = current->fsuid;
        gid_t oldgid = current->fsgid;
@@ -1415,37 +1416,32 @@ int odf_remove(struct dentry *dentry, int flags)
 
        /* refresh odi */
        err = odf_lookup(dentry->d_parent, dentry, 0);
-       if (err) {
-               odi = NULL;
-               goto out;
-       }
-       BUG_ON(!UNIONFS_D(dentry)->odf_info);
-       odi = UNIONFS_D(dentry)->odf_info;
-       if (!odi)
+       if (err)
                goto out;
+
+       BUG_ON(!UNIONFS_D(dentry)->odf.dentry);
+       odf_dentry = UNIONFS_D(dentry)->odf.dentry;
+       
        /* should we remove? */
-       if (__odf_is_wh(&UNIONFS_SB(dentry->d_sb)->odf, odi->dentry)) {
+       if (__odf_is_wh(&UNIONFS_SB(dentry->d_sb)->odf, odf_dentry)) {
                if (flags & ODF_RMV_WH)
                        rmv = 1;
        }
-       else {
-               if (flags & ODF_RMV_NOTWH)
+       else if (flags & ODF_RMV_NOTWH)
                        rmv = 1;
-       }
+
        if (!rmv)
                goto out;
 
-       odf_dir = UNIONFS_D(dentry->d_parent)->odf_info;
-
        /* remove */
        current->fsuid = 0;
        current->fsgid = 0;
-       if (S_ISDIR(odi->dentry->d_inode->i_mode)) {
+       if (S_ISDIR(odf_dentry->d_inode->i_mode)) {
                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);
+                       err = vfs_unlink(odf_dentry->d_parent->d_inode, 
odf_dentry);
                else
                        /* silly rename open files, so their ino does
                         * not get recycled while still open
@@ -1458,8 +1454,8 @@ int odf_remove(struct dentry *dentry, int flags)
                goto out;
 
        /* clean up */
-       odf_put_info(odi);
-       UNIONFS_D(dentry)->odf_info = NULL;
+       dput(odf_dentry);
+       UNIONFS_D(dentry)->odf.dentry = NULL;
 out:
        return err;
 }
@@ -1472,9 +1468,9 @@ int odf_get_opaque(struct super_block *sb, struct dentry 
*dentry)
 {
        int i, opaque;
 
-       BUG_ON(!UNIONFS_D(dentry)->odf_info);
+       BUG_ON(!UNIONFS_D(dentry)->odf.dentry);
 
-       opaque = UNIONFS_D(dentry)->odf_info->opaque;
+       opaque = UNIONFS_D(dentry)->odf.opaque;
 
        if (opaque == -1)
                return -1;
@@ -1496,10 +1492,10 @@ int odf_get_opaque(struct super_block *sb, struct 
dentry *dentry)
  */
 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, branch);
+       struct dentry *odf_dentry = UNIONFS_D(dentry)->odf.dentry;
+       int err = __odf_set_opaque(odf_dentry, branch);
        if (!err)
-               odi->opaque = branch;
+               UNIONFS_D(dentry)->odf.opaque = branch;
        return err;
 }
 
diff --git a/fs/unionfs/rename.c b/fs/unionfs/rename.c
index f0896bc..cce4d51 100644
--- a/fs/unionfs/rename.c
+++ b/fs/unionfs/rename.c
@@ -365,7 +365,7 @@ int unionfs_rename(struct inode *old_dir, struct dentry 
*old_dentry,
         * since it will cause us problems when we copyup */
        hidden = unionfs_lower_dentry_idx(new_dentry, 0);
        if (hidden && hidden->d_inode ) {
-               if (UNIONFS_D(new_dentry)->odf_info->whiteout) {
+               if (UNIONFS_D(new_dentry)->odf.whiteout) {
                        err = unionfs_force_rm(new_dentry, &hidden, 0);
                        if (err)
                                goto out;
diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h
index 2822fed..614d233 100644
--- a/fs/unionfs/union.h
+++ b/fs/unionfs/union.h
@@ -146,7 +146,7 @@ struct unionfs_dentry_info {
        int bend;
        int bcount;
        atomic_t generation;
-       struct odf_dentry_info *odf_info;
+       struct odf_dentry_info odf;
        struct path *lower_paths;
 };
 
_______________________________________________
unionfs-cvs mailing list: http://unionfs.filesystems.org/
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs-cvs

Reply via email to