Re: [RFC] sane access to per-fs metadata (was Re: [PATCH]

Alexander Viro (viro@math.psu.edu)
Fri, 23 Mar 2001 07:06:35 -0500 (EST)


On Thu, 22 Mar 2001, Andreas Dilger wrote:

> I look forward to seeing the ext2 code. I was just in the process of
> adding ioctls to ext3 to do online resizing within transactions. Maybe
> I'll rather use this interface if it looks good. Will it work on 2.2,
> or does it depend too much on new VFS?

Should be OK, except that with 2.2 you'll need to get hold on dentry
from original fs instead of vfsmount (unfortunately, that can't be
done same way for both - 2.2 doesn't have vfsmount tree and in 2.4
holding dentry without holding vfsmount is a one-way ticket to hell -
umount() will be unhappy). However, version-dependent part should be
very small. Something like

struct superblock *grab_super(name, p)
char *name;
void **p;
{
struct nameidata nd;
int err = 0;
*p = NULL;
if (path_init(name, 0, &nd))
err = path_walk(name, &nd);
if (err)
return ERR_PTR(err);
*p = mntget(nd.mnt);
path_release(&nd);
return (*(struct vfsmount**)p)->mnt_sb;
}

for 2.4 and

struct superblock *grab_super(name, p)
char *name;
void **p;
{
int err = 0;
struct dentry *dentry;
*p = NULL;
dentry = lookup_dentry(name, NULL, 0);
if (IS_ERR(dentry))
return (struct super_block*)dentry;
*p = dentry;
return dentry->d_sb;
}

for 2.2 should do the trick -
master_sb = grab_super(ext2root, &sb->u.ext2meta_sb.holder);
if (IS_ERR(matser_sb))
/* fail */
sb->u.ext2meta_sb.master = master_sb;
...
should be OK (to release the master sb you'll need to do dput() or mntput()
of sb->....holder in 2.2 and 2.4 resp., indeed). I wouldn't try to port
that to 2.0, though...
Cheers,
Al

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/