commit 126ad4206e83330420aa2cacfc3e98a4d4e869b7
Author: Yiannis Pericleous <[EMAIL PROTECTED]>
Date: Fri May 25 13:38:39 2007 -0400
changed the odf_sb_info structure to hold dentry pointers to the odf
special dirs
instead of odf_dentry_info pointers
diff --git a/fs/unionfs/dirhelper.c b/fs/unionfs/dirhelper.c
index 040e4e4..309f0eb 100644
--- a/fs/unionfs/dirhelper.c
+++ b/fs/unionfs/dirhelper.c
@@ -571,8 +571,8 @@ int odf_cleanup(struct odf_sb_info *odf, int mode, u64 size)
buf->stack = &stack;
/* first cleanup odf/ic */
- dget(odf->odi_ic->dentry);
- stack.item[stack.n++] = odf->odi_ic->dentry;
+ dget(odf->ic);
+ stack.item[stack.n++] = odf->ic;
cleanup_loop:
@@ -612,8 +612,7 @@ cleanup_loop:
* is entirely flat, ie only odf/reclaim contains
* subdirectories
*/
- if (dentry != odf->odi_rc->dentry &&
- dentry != odf->odi_sr->dentry) {
+ if (dentry != odf->rc && dentry != odf->sr) {
blocks = dentry->d_inode->i_blocks;
bytes = blocks * dentry->d_sb->s_blocksize;
isize = i_size_read(dentry->d_inode);
@@ -643,8 +642,8 @@ cleanup_loop:
/* cleanup odf/sr as well */
reclaim = 1;
buf->reclaim = 1;
- dget(odf->odi_sr->dentry);
- stack.item[stack.n++] = odf->odi_sr->dentry;
+ dget(odf->sr);
+ stack.item[stack.n++] = odf->sr;
goto cleanup_loop;
}
else if (mode == ODF_CLEAN_CACHE && reclaim)
@@ -657,8 +656,8 @@ cleanup_loop:
if (!reclaim) {
reclaim = 1;
buf->reclaim = 1;
- dget(odf->odi_rc->dentry);
- stack.item[stack.n++] = odf->odi_rc->dentry;
+ dget(odf->rc);
+ stack.item[stack.n++] = odf->rc;
goto cleanup_loop;
}
}
diff --git a/fs/unionfs/export.c b/fs/unionfs/export.c
index 2f7d0b9..84ec97a 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_SB(sb)->odf->odi_ns->dentry;
+ struct dentry *odf_root = UNIONFS_D(sb->s_root)->odf_info->dentry;
struct dentry *d, *d_parent, *parent, *child = NULL;
struct dentry_stack stack;
char *name = NULL;
diff --git a/fs/unionfs/main.c b/fs/unionfs/main.c
index b2f0e7d..c4f8624 100644
--- a/fs/unionfs/main.c
+++ b/fs/unionfs/main.c
@@ -590,10 +590,6 @@ static int unionfs_read_super(struct super_block *sb, void
*raw_data,
int bindex, bstart, bend;
char *odf_options = NULL;
int *bid = NULL, high_bid;
- int put_ns = 0; /* we dget the ns dentry in odf_read_super but do not
- * put it in odf_put_super since it is also assigned to
s_root
- * and will be put by s_root. put_ns decides if we got
- * the ns dentry but not yet assigned it to s_root */
if (!raw_data) {
printk(KERN_WARNING
@@ -627,7 +623,6 @@ static int unionfs_read_super(struct super_block *sb, void
*raw_data,
goto out_free;
}
odf = UNIONFS_SB(sb)->odf;
- put_ns = 1;
/* if this is an old odf reconstruct the dirs part of the mount time
options
* from the odf data on disk and discard the old options
@@ -738,8 +733,8 @@ static int unionfs_read_super(struct super_block *sb, void
*raw_data,
set_dbend(sb->s_root, bend);
/* save odf root dentry */
- UNIONFS_D(sb->s_root)->odf_info = UNIONFS_SB(sb)->odf->odi_ns;
- put_ns = 0;
+ UNIONFS_D(sb->s_root)->odf_info =
+ odf_fill_info(NULL, UNIONFS_SB(sb)->odf,
UNIONFS_SB(sb)->odf->ns);
/* Set the generation number to one, since this is for the mount. */
atomic_set(&UNIONFS_D(sb->s_root)->generation, 1);
@@ -788,8 +783,6 @@ out_free:
* odf_put_super doesnt wait for it */
kfree(UNIONFS_SB(sb)->odf->cleanup);
UNIONFS_SB(sb)->odf->cleanup = NULL;
- if (put_ns)
- odf_put_info(UNIONFS_SB(sb)->odf->odi_ns);
odf_put_super(UNIONFS_SB(sb)->odf);
}
kfree(UNIONFS_SB(sb)->data);
diff --git a/fs/unionfs/odf.c b/fs/unionfs/odf.c
index 617e3dd..4ec070f 100644
--- a/fs/unionfs/odf.c
+++ b/fs/unionfs/odf.c
@@ -12,8 +12,8 @@ static inline struct dentry * __odf_create_dir(struct dentry
*parent, char *name
if (IS_ERR(dentry))
goto out;
if (unlikely(dentry->d_inode)) {
- dput(dentry);
- dentry = ERR_PTR(-EEXIST);
+ // dput(dentry);
+ // dentry = ERR_PTR(-EEXIST);
goto out;
}
err = vfs_mkdir(parent->d_inode, dentry, S_IRWXUGO);
@@ -68,7 +68,7 @@ int __odf_create_hierarchy(struct dentry *odf_root)
goto out;
}
if (unlikely(dentry->d_inode)){
- err = -EEXIST;
+ // err = -EEXIST;
goto out;
}
err = vfs_create(odf_root->d_inode, dentry, S_IRWXUGO, NULL);
@@ -135,31 +135,31 @@ struct odf_sb_info* odf_read_super(char *options)
goto out_free;
}
- osi->odi_ns = odf_getpath(nd.dentry, osi, ODF_NS);
- if (IS_ERR(osi->odi_ns)){
- err = PTR_ERR(osi->odi_ns);
- osi->odi_ns = NULL;
+ osi->ns = odf_getdir(nd.dentry, ODF_NS, sizeof(ODF_NS) - 1);
+ if (IS_ERR(osi->ns)){
+ err = PTR_ERR(osi->ns);
+ osi->ns = NULL;
goto out_free;
}
- osi->odi_rc = odf_getpath(nd.dentry, osi, ODF_RC);
- if (IS_ERR(osi->odi_rc)){
- err = PTR_ERR(osi->odi_rc);
- osi->odi_rc = NULL;
+ osi->rc = odf_getdir(nd.dentry, ODF_RC, sizeof(ODF_RC) - 1);
+ if (IS_ERR(osi->rc)){
+ err = PTR_ERR(osi->rc);
+ osi->rc = NULL;
goto out_free;
}
- osi->odi_ic = odf_getpath(nd.dentry, osi, ODF_IC);
- if (IS_ERR(osi->odi_ic)){
- err = PTR_ERR(osi->odi_ic);
- osi->odi_ic = NULL;
+ osi->ic = odf_getdir(nd.dentry, ODF_IC, sizeof(ODF_IC) - 1);
+ if (IS_ERR(osi->ic)){
+ err = PTR_ERR(osi->ic);
+ osi->ic = NULL;
goto out_free;
}
- osi->odi_sr = odf_getpath(nd.dentry, osi, ODF_SR);
- if (IS_ERR(osi->odi_sr)){
- err = PTR_ERR(osi->odi_sr);
- osi->odi_sr = NULL;
+ osi->sr = odf_getdir(nd.dentry, ODF_SR, sizeof(ODF_SR) - 1);
+ if (IS_ERR(osi->sr)){
+ err = PTR_ERR(osi->sr);
+ osi->sr = NULL;
goto out_free;
}
@@ -192,10 +192,10 @@ struct odf_sb_info* odf_read_super(char *options)
goto out;
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->ns);
+ dput(osi->rc);
+ dput(osi->ic);
+ dput(osi->sr);
dput(osi->sb);
dput(osi->whiteout);
kfree(osi->branch_uuids);
@@ -215,10 +215,10 @@ out:
*/
void odf_put_super(struct odf_sb_info *osi)
{
- /* do not put ns here, as it will be put by root of unionfs*/
- odf_put_info(osi->odi_rc);
- odf_put_info(osi->odi_ic);
- odf_put_info(osi->odi_sr);
+ dput(osi->rc);
+ dput(osi->ic);
+ dput(osi->sr);
+ dput(osi->ns);
dput(osi->mnt->mnt_sb->s_root);
dput(osi->sb);
dput(osi->whiteout);
@@ -233,25 +233,22 @@ void odf_put_super(struct odf_sb_info *osi)
* This is to be used for accessing whatever is in the root of the
* odf, ie /odf/ic, /odf/ns, etc
*/
-struct odf_dentry_info* odf_getpath(struct dentry *d_odf, struct odf_sb_info
*osi, const char *name)
+struct dentry* odf_getdir(struct dentry *d_odf, const char *name, int len)
{
struct dentry *dentry;
- struct odf_dentry_info* odi = NULL;
- dentry = lookup_one_len(name, d_odf, strlen(name));
- if (IS_ERR(dentry) || !dentry) {
- odi = ERR_PTR(-EINVAL);
- goto out;
- }
+ dentry = lookup_one_len(name, d_odf, len);
+ if (IS_ERR(dentry))
+ ;
else if (!dentry->d_inode) {
- odi = ERR_PTR(-EINVAL);
dput(dentry);
- goto out;
+ dentry = ERR_PTR(-EINVAL);
}
- odi = odf_fill_info(NULL, osi, dentry);
- dput(dentry);
-out:
- return odi;
+ else if (!S_ISDIR(dentry->d_inode->i_mode)) {
+ dput(dentry);
+ dentry = ERR_PTR(-EINVAL);
+ }
+ return dentry;
}
/* returns 1 if odfforce found, 0 if not */
@@ -315,18 +312,17 @@ out:
*/
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;
+ struct inode *old_dir;
+ struct dentry *odf_dentry, *old_dentry, *new_dentry, *new_dir;
char *new_name = NULL;
int err = 0;
odf_dentry = UNIONFS_D(dentry)->odf_info->dentry;
if (sr)
- odi = UNIONFS_SB(dentry->d_sb)->odf->odi_sr;
+ new_dir = UNIONFS_SB(dentry->d_sb)->odf->sr;
else
- odi = UNIONFS_SB(dentry->d_sb)->odf->odi_rc;
+ new_dir = UNIONFS_SB(dentry->d_sb)->odf->rc;
new_name = kzalloc(ODF_INAME_LEN, GFP_KERNEL);
if (!new_name){
err = -ENOMEM;
@@ -336,15 +332,14 @@ int odf_reclaim(struct dentry *dentry, int sr)
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));
+ new_dentry = lookup_one_len(new_name, new_dir, strlen(new_name));
if (IS_ERR(new_dentry)) {
err = PTR_ERR(new_dentry);
goto out;
}
lock_rename(old_dentry->d_parent, new_dentry->d_parent);
- err = vfs_rename(old_dir, old_dentry, new_dir, new_dentry);
+ err = vfs_rename(old_dir, old_dentry, new_dir->d_inode, new_dentry);
unlock_rename(old_dentry->d_parent, new_dentry->d_parent);
dput(new_dentry);
@@ -359,14 +354,15 @@ out:
int odf_release_sr(struct inode *inode)
{
struct dentry *old_dentry = NULL, *new_dentry = NULL;
- struct odf_dentry_info *odi_sr, *odi_rc;
+ struct dentry *sr, *rc;
char name[ODF_INAME_LEN];
int err = 0;
+
uid_t olduid = current->fsuid;
gid_t oldgid = current->fsgid;
- odi_sr = UNIONFS_SB(inode->i_sb)->odf->odi_sr;
- odi_rc = UNIONFS_SB(inode->i_sb)->odf->odi_rc;
+ sr = UNIONFS_SB(inode->i_sb)->odf->sr;
+ rc = UNIONFS_SB(inode->i_sb)->odf->rc;
memset(name, 0, ODF_INAME_LEN);
if (!name){
err = -ENOMEM;
@@ -377,7 +373,7 @@ int odf_release_sr(struct inode *inode)
/* LOCK: need to lock sr? */
/* check for an entry in /odf/sr */
- old_dentry = lookup_one_len(name, odi_sr->dentry, strlen(name));
+ old_dentry = lookup_one_len(name, sr, strlen(name));
if (IS_ERR(old_dentry)) {
err = PTR_ERR(old_dentry);
old_dentry = NULL;
@@ -387,7 +383,7 @@ int odf_release_sr(struct inode *inode)
goto out_unlock;
/* move it to /odf/rc with the same name */
- new_dentry = lookup_one_len(name, odi_rc->dentry, strlen(name));
+ new_dentry = lookup_one_len(name, rc, strlen(name));
if (IS_ERR(new_dentry)) {
err = PTR_ERR(new_dentry);
new_dentry = NULL;
@@ -1114,7 +1110,7 @@ struct odf_dentry_info *odf_ic_dentry(struct odf_sb_info
*osi, u64 ino, char *na
char tmp_name[6];
int i, err = 0;
- odi_ic = osi->odi_ic;
+ odi_ic = odf_fill_info(NULL, osi, osi->ic);
for (i = 3; i >= 0; i--) {
breakdown[i] = ino & 0xFFFF;
@@ -1150,6 +1146,7 @@ struct odf_dentry_info *odf_ic_dentry(struct odf_sb_info
*osi, u64 ino, char *na
out:
for (i = 0; i < 4; i++)
odf_put_info(odis[i]);
+ odf_put_info(odi_ic);
if (err)
return ERR_PTR(err);
@@ -1371,8 +1368,7 @@ int odf_remove(struct dentry *dentry, int flags)
/* refresh odi */
err = odf_lookup(dentry->d_parent, dentry, 0);
- if (IS_ERR(odi)) {
- err = PTR_ERR(odi);
+ if (err) {
odi = NULL;
goto out;
}
@@ -1397,8 +1393,9 @@ int odf_remove(struct dentry *dentry, int flags)
/* remove */
current->fsuid = 0;
current->fsgid = 0;
- if (S_ISDIR(odi->dentry->d_inode->i_mode))
+ if (S_ISDIR(odi->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);
diff --git a/fs/unionfs/odf.h b/fs/unionfs/odf.h
index ece557e..4e52470 100644
--- a/fs/unionfs/odf.h
+++ b/fs/unionfs/odf.h
@@ -66,7 +66,7 @@ static inline struct odf_dentry_info *odf_lookup_name(struct
odf_sb_info *osi,
{
return __odf_lookup(osi, parent, name, len, flags, old_odi, NULL);
}
-struct odf_dentry_info *odf_getpath(struct dentry *d_odf, struct odf_sb_info
*osi, const char *name);
+struct dentry* odf_getdir(struct dentry *d_odf, const char *name, int len);
struct odf_dentry_info *odf_fill_info(struct odf_dentry_info *odi,
struct odf_sb_info *osi, struct dentry *odf_dentry);
struct odf_dentry_info *odf_alloc_info(struct odf_sb_info *osi, struct dentry
*odf_dentry);
diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h
index 47b90a8..0ae4520 100644
--- a/fs/unionfs/union.h
+++ b/fs/unionfs/union.h
@@ -105,15 +105,15 @@ struct odf_dentry_info {
/* odf sb data */
struct odf_sb_info {
struct vfsmount *mnt; /* odf vmsmount */
- struct odf_dentry_info *odi_ns; /* namespace (/ns) */
- struct odf_dentry_info *odi_rc; /* reclaim (/reclaim) */
- struct odf_dentry_info *odi_ic; /* inode cache (/ic) */
- struct odf_dentry_info *odi_sr; /* silly renamed files (/sr) */
+ struct dentry *ns; /* namespace (/odf/ns) */
+ struct dentry *rc; /* reclaim (/odf/reclaim) */
+ struct dentry *ic; /* inode cache (/odf/ic) */
+ struct dentry *sr; /* silly renamed files (/odf/sr) */
+ struct dentry *sb; /* superblock file (/odf/sb) */
+ struct dentry *whiteout; /* file whiteouts are linked to */
struct sioa_args *cleanup; /* our cleanup thread */
- char *branch_uuids; /* not null terminated string of all branch
uuids*/
+ char *branch_uuids; /* not null terminated string of all branch uuids
*/
int opaque_branch_id; /* should always be the branch id of branch 0*/
- struct dentry *sb; /* superblock (/sb) */
- struct dentry *whiteout;
};
/* unionfs inode data in memory */
_______________________________________________
unionfs-cvs mailing list: http://unionfs.filesystems.org/
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs-cvs