commit da2c96363a7edfb81c823830703055ae09a5e6b9
Author: Yiannis Pericleous <[EMAIL PROTECTED]>
Date: Fri Feb 9 18:49:15 2007 -0500
odf_sb_info struct
diff --git a/fs/unionfs/main.c b/fs/unionfs/main.c
index ed515d3..18e8a49 100644
--- a/fs/unionfs/main.c
+++ b/fs/unionfs/main.c
@@ -576,11 +576,11 @@ static int unionfs_read_super(struct super_block *sb,
void *raw_data,
}
/* get the odf super block */
- UNIONFS_SB(sb)->odf_mnt = odf_read_super(ODF_MOUNT);
- if ( IS_ERR(UNIONFS_SB(sb)->odf_mnt) ) {
+ UNIONFS_SB(sb)->odf = odf_read_super(ODF_MOUNT);
+ if ( IS_ERR(UNIONFS_SB(sb)->odf) ) {
printk(KERN_WARNING "unionfs_read_super: odf error\n");
- err = PTR_ERR(UNIONFS_SB(sb)->odf_mnt);
- UNIONFS_SB(sb)->odf_mnt = NULL;
+ err = PTR_ERR(UNIONFS_SB(sb)->odf);
+ UNIONFS_SB(sb)->odf = NULL;
goto out_free;
}
@@ -636,12 +636,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 = odf_getns();
- if ( IS_ERR(UNIONFS_D(sb->s_root)->odf_info )) {
- err = PTR_ERR(UNIONFS_D(sb->s_root)->odf_info);
- UNIONFS_D(sb->s_root)->odf_info = NULL;
- goto out_freedpd;
- }
+ UNIONFS_D(sb->s_root)->odf_info =
+ UNIONFS_SB(sb)->odf->odi_ns;
/* 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 0340fbd..66d089c 100644
--- a/fs/unionfs/odf.c
+++ b/fs/unionfs/odf.c
@@ -3,79 +3,104 @@
/*
* Initialize any odf data we might need
*/
-struct vfsmount* odf_read_super(char *odffile)
+struct odf_sb_info* odf_read_super(char *odffile)
{
struct nameidata nd;
- struct vfsmount *odfmnt = NULL;
+ struct odf_sb_info *osi;
int err = 0;
if (odffile == NULL) {
printk(KERN_WARNING "unionfs_odf: No odf mount specified\n");
- odfmnt = ERR_PTR(-EINVAL);
+ osi = ERR_PTR(-EINVAL);
goto out;
}
err = path_lookup(odffile, LOOKUP_FOLLOW, &nd);
if (err) {
printk(KERN_WARNING "unionfs_odf: Cannot access odf mount\n");
- odfmnt = ERR_PTR(err);
+ osi = ERR_PTR(err);
goto out;
}
- odfmnt = nd.mnt;
- mntget(odfmnt);
- dget(odfmnt->mnt_sb->s_root);
- path_release(&nd);
+ osi = kzalloc(sizeof(struct odf_sb_info), GFP_KERNEL);
+
+ osi->odi_ns = odf_getpath(ODF_NS);
+ if (IS_ERR(osi->odi_ns)){
+ err = PTR_ERR(osi->odi_ns);
+ osi->odi_ns = NULL;
+ goto out_free;
+ }
+ osi->odi_sb = odf_getpath(ODF_SB);
+ if (IS_ERR(osi->odi_sb)){
+ err = PTR_ERR(osi->odi_sb);
+ osi->odi_sb = NULL;
+ goto out_free;
+ }
+ osi->odi_rc = odf_getpath(ODF_RC);
+ if (IS_ERR(osi->odi_rc)){
+ err = PTR_ERR(osi->odi_rc);
+ osi->odi_rc = NULL;
+ goto out_free;
+ }
+ osi->odi_ic = odf_getpath(ODF_IC);
+ if (IS_ERR(osi->odi_ic)){
+ err = PTR_ERR(osi->odi_ic);
+ osi->odi_ic = NULL;
+ goto out_free;
+ }
+
+ osi->mnt = nd.mnt;
+ mntget(osi->mnt);
+ dget(osi->mnt->mnt_sb->s_root);
+ path_release(&nd);
+
+ goto out;
+
+out_free:
+ odf_put_info(osi->odi_ns);
+ odf_put_info(osi->odi_rc);
+ odf_put_info(osi->odi_sb);
+ odf_put_info(osi->odi_ic);
+ kfree(osi);
+ osi = ERR_PTR(err);
out:
- return odfmnt;
+ return osi;
}
/*
* Clean any alloc'd odf data
*/
-void odf_put_super(struct super_block *sb)
+void odf_put_super(struct odf_sb_info *osi)
{
- dput(UNIONFS_SB(sb)->odf_mnt->mnt_sb->s_root);
- mntput(UNIONFS_SB(sb)->odf_mnt);
+ /* 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_sb);
+ odf_put_info(osi->odi_ic);
+ dput(osi->mnt->mnt_sb->s_root);
+ mntput(osi->mnt);
}
/*
- * Returns the dentry of /odf/ns
+ * Returns the odf_dentry_info of the given path
*/
-struct odf_dentry_info* odf_getns(void)
+struct odf_dentry_info* odf_getpath(char *path)
{
struct nameidata nd;
struct odf_dentry_info* odi = NULL;
int err = 0;
- err = path_lookup(ODF_NS, LOOKUP_FOLLOW, &nd);
+ err = path_lookup(path, LOOKUP_FOLLOW, &nd);
if (err) {
printk(KERN_WARNING "unionfs_odf: Invalid odf\n");
odi = ERR_PTR(err);
goto out;
}
- odi = odf_fill_info(NULL, nd.dentry);
- path_release(&nd);
-
-out:
- return odi;
-}
-
-/*
- * Returns the dentry of /odf/reclaim
- */
-struct odf_dentry_info* odf_getrc(void)
-{
- struct nameidata nd;
- struct odf_dentry_info* odi = NULL;
- int err = 0;
-
- err = path_lookup(ODF_RC, LOOKUP_FOLLOW, &nd);
- if (err) {
+ if (!nd.dentry->d_inode) {
printk(KERN_WARNING "unionfs_odf: Invalid odf\n");
- odi = ERR_PTR(err);
+ odi = ERR_PTR(-EINVAL);
+ path_release(&nd);
goto out;
}
odi = odf_fill_info(NULL, nd.dentry);
@@ -92,7 +117,7 @@ int odf_reclaim(struct dentry *dentry)
{
struct inode *old_dir, *new_dir;
struct dentry *old_dentry, *new_dentry;
- struct odf_dentry_info *odi = odf_getrc();
+ struct odf_dentry_info *odi = odf_getpath(ODF_RC);
char *new_name = NULL;
int err = 0;
diff --git a/fs/unionfs/odf.h b/fs/unionfs/odf.h
index 8eb89f3..2be1dc2 100644
--- a/fs/unionfs/odf.h
+++ b/fs/unionfs/odf.h
@@ -33,8 +33,8 @@
#define ODF_OPQ_BITS 5
/* super */
-struct vfsmount* odf_read_super(char *odffile);
-void odf_put_super(struct super_block *sb);
+struct odf_sb_info* odf_read_super(char *odffile);
+void odf_put_super(struct odf_sb_info *osi);
int odf_is_new(int unset);
char *odf_getoptions(void);
int odf_putoptions(struct super_block* sb_union, struct unionfs_dentry_info
*hidden_root);
@@ -42,7 +42,7 @@ int odf_putoptions(struct super_block* sb_union, struct
unionfs_dentry_info *hid
/* lookup */
int odf_lookup(struct dentry *parent, struct dentry *dentry, int flags);
struct odf_dentry_info *__odf_lookup(struct dentry *parent, const char *name,
int len, int flags, struct odf_dentry_info *old_odi);
-struct odf_dentry_info *odf_getns(void);
+struct odf_dentry_info *odf_getpath(char *path);
struct odf_dentry_info *odf_fill_info(struct odf_dentry_info *odi, struct
dentry *odf_dentry);
struct odf_dentry_info *odf_alloc_info(struct dentry *odf_dentry);
void odf_put_info(struct odf_dentry_info *odi);
diff --git a/fs/unionfs/super.c b/fs/unionfs/super.c
index 4b57b3c..287cf4d 100644
--- a/fs/unionfs/super.c
+++ b/fs/unionfs/super.c
@@ -103,7 +103,7 @@ static void unionfs_put_super(struct super_block *sb)
if (!spd)
return;
- odf_put_super(sb);
+ odf_put_super(UNIONFS_SB(sb)->odf);
bstart = sbstart(sb);
bend = sbend(sb);
diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h
index d62453d..784a17e 100644
--- a/fs/unionfs/union.h
+++ b/fs/unionfs/union.h
@@ -99,6 +99,15 @@ struct odf_dentry_info {
struct dentry *dentry;
};
+/* 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;
+};
+
/* unionfs inode data in memory */
struct unionfs_inode_info {
int bstart;
@@ -151,7 +160,7 @@ struct unionfs_sb_info {
atomic_t generation;
struct rw_semaphore rwsem; /* protects access to data+id fields */
int high_branch_id; /* last unique branch ID given */
- struct vfsmount *odf_mnt;
+ struct odf_sb_info *odf;
struct unionfs_data *data;
};
_______________________________________________
unionfs-cvs mailing list: http://unionfs.filesystems.org/
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs-cvs