[GFS2] Tidy up mount code.

We no longer lookup ".gfs2_admin" in the root directory in order to
find it, but instead use the inode number given in the superblock.
Both the root directory and the admin directory are now looked up using
the same routine, so the redundant code is removed.

Also, there is no longer a reference to the root inode in the
GFS2 super block. When required this can be retreived via
sb->s_root->d_inode instead.

Assuming that we introduce a metadata filesystem type for GFS, then
this is a first step towards that goal.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
This commit is contained in:
Steven Whitehouse 2006-03-01 15:31:02 -05:00
parent e317ffcb7c
commit c9fd43078f
8 changed files with 27 additions and 54 deletions

View file

@ -532,7 +532,6 @@ struct gfs2_sbd {
struct inode *sd_qc_inode;
struct inode *sd_rindex;
struct inode *sd_quota_inode;
struct inode *sd_root_dir;
/* Inum stuff */

View file

@ -288,7 +288,7 @@ int gfs2_inode_refresh(struct gfs2_inode *ip)
* Returns: errno
*/
static int inode_create(struct gfs2_glock *i_gl, struct gfs2_inum *inum,
static int inode_create(struct gfs2_glock *i_gl, const struct gfs2_inum *inum,
struct gfs2_glock *io_gl, unsigned int io_state,
struct gfs2_inode **ipp)
{
@ -354,8 +354,8 @@ static int inode_create(struct gfs2_glock *i_gl, struct gfs2_inum *inum,
* Returns: errno
*/
int gfs2_inode_get(struct gfs2_glock *i_gl, struct gfs2_inum *inum, int create,
struct gfs2_inode **ipp)
int gfs2_inode_get(struct gfs2_glock *i_gl, const struct gfs2_inum *inum,
int create, struct gfs2_inode **ipp)
{
struct gfs2_sbd *sdp = i_gl->gl_sbd;
struct gfs2_glock *io_gl;
@ -718,6 +718,7 @@ int gfs2_change_nlink(struct gfs2_inode *ip, int diff)
int gfs2_lookupi(struct inode *dir, struct qstr *name, int is_root,
struct inode **inodep)
{
struct super_block *sb = dir->i_sb;
struct gfs2_inode *ipp;
struct gfs2_inode *dip = dir->u.generic_ip;
struct gfs2_sbd *sdp = dip->i_sbd;
@ -733,7 +734,7 @@ int gfs2_lookupi(struct inode *dir, struct qstr *name, int is_root,
return -ENAMETOOLONG;
if (gfs2_filecmp(name, ".", 1) ||
(gfs2_filecmp(name, "..", 2) && dir == sdp->sd_root_dir)) {
(gfs2_filecmp(name, "..", 2) && dir == sb->s_root->d_inode)) {
gfs2_inode_hold(dip);
ipp = dip;
goto done;
@ -1466,8 +1467,8 @@ int gfs2_unlink_ok(struct gfs2_inode *dip, struct qstr *name,
int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to)
{
struct gfs2_sbd *sdp = this->i_sbd;
struct inode *dir = to->i_vnode;
struct super_block *sb = dir->i_sb;
struct inode *tmp;
struct qstr dotdot;
int error = 0;
@ -1483,7 +1484,7 @@ int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to)
error = -EINVAL;
break;
}
if (dir == sdp->sd_root_dir) {
if (dir == sb->s_root->d_inode) {
error = 0;
break;
}

View file

@ -35,7 +35,7 @@ void gfs2_inode_min_init(struct gfs2_inode *ip, unsigned int type);
int gfs2_inode_refresh(struct gfs2_inode *ip);
int gfs2_inode_get(struct gfs2_glock *i_gl,
struct gfs2_inum *inum, int create,
const struct gfs2_inum *inum, int create,
struct gfs2_inode **ipp);
void gfs2_inode_hold(struct gfs2_inode *ip);
void gfs2_inode_put(struct gfs2_inode *ip);

View file

@ -64,8 +64,8 @@ static int gfs2_encode_fh(struct dentry *dentry, __u32 *fh, int *len,
int connectable)
{
struct inode *inode = dentry->d_inode;
struct super_block *sb = inode->i_sb;
struct gfs2_inode *ip = inode->u.generic_ip;
struct gfs2_sbd *sdp = ip->i_sbd;
if (*len < 4 || (connectable && *len < 8))
return 255;
@ -80,7 +80,7 @@ static int gfs2_encode_fh(struct dentry *dentry, __u32 *fh, int *len,
fh[3] = cpu_to_be32(fh[3]);
*len = 4;
if (!connectable || ip == sdp->sd_root_dir->u.generic_ip)
if (!connectable || inode == sb->s_root->d_inode)
return *len;
spin_lock(&dentry->d_lock);

View file

@ -280,27 +280,30 @@ static int init_locking(struct gfs2_sbd *sdp, struct gfs2_holder *mount_gh,
return error;
}
int gfs2_lookup_root(struct gfs2_sbd *sdp)
static struct inode *gfs2_lookup_root(struct gfs2_sbd *sdp,
const struct gfs2_inum *inum)
{
int error;
struct gfs2_glock *gl;
struct gfs2_inode *ip;
struct inode *inode;
error = gfs2_glock_get(sdp, sdp->sd_sb.sb_root_dir.no_addr,
error = gfs2_glock_get(sdp, inum->no_addr,
&gfs2_inode_glops, CREATE, &gl);
if (!error) {
error = gfs2_inode_get(gl, &sdp->sd_sb.sb_root_dir,
error = gfs2_inode_get(gl, inum,
CREATE, &ip);
if (!error) {
if (!error)
gfs2_inode_min_init(ip, DT_DIR);
sdp->sd_root_dir = gfs2_ip2v(ip);
inode = gfs2_ip2v(ip);
gfs2_inode_put(ip);
return inode;
}
gfs2_glock_put(gl);
}
return error;
return ERR_PTR(error);
}
static int init_sb(struct gfs2_sbd *sdp, int silent, int undo)
@ -311,7 +314,6 @@ static int init_sb(struct gfs2_sbd *sdp, int silent, int undo)
int error = 0;
if (undo) {
iput(sdp->sd_master_dir);
return 0;
}
@ -351,35 +353,24 @@ static int init_sb(struct gfs2_sbd *sdp, int silent, int undo)
sb_set_blocksize(sb, sdp->sd_sb.sb_bsize);
/* Get the root inode */
error = gfs2_lookup_root(sdp);
if (error) {
inode = gfs2_lookup_root(sdp, &sdp->sd_sb.sb_root_dir);
if (IS_ERR(inode)) {
error = PTR_ERR(inode);
fs_err(sdp, "can't read in root inode: %d\n", error);
goto out;
}
/* Get the root inode/dentry */
inode = sdp->sd_root_dir;
if (!inode) {
fs_err(sdp, "can't get root inode\n");
error = -ENOMEM;
goto out_rooti;
}
igrab(inode);
sb->s_root = d_alloc_root(inode);
if (!sb->s_root) {
fs_err(sdp, "can't get root dentry\n");
error = -ENOMEM;
goto out_rooti;
iput(inode);
}
out:
gfs2_glock_dq_uninit(&sb_gh);
return error;
out_rooti:
iput(sdp->sd_root_dir);
goto out;
}
static int init_journal(struct gfs2_sbd *sdp, int undo)
@ -529,15 +520,18 @@ static int init_inodes(struct gfs2_sbd *sdp, int undo)
{
int error = 0;
struct gfs2_inode *ip;
struct inode *inode;
if (undo)
goto fail_qinode;
error = gfs2_lookup_master_dir(sdp);
if (error) {
inode = gfs2_lookup_root(sdp, &sdp->sd_sb.sb_master_dir);
if (IS_ERR(inode)) {
error = PTR_ERR(inode);
fs_err(sdp, "can't read in master directory: %d\n", error);
goto fail;
}
sdp->sd_master_dir = inode;
error = init_journal(sdp, undo);
if (error)

View file

@ -103,7 +103,6 @@ static void gfs2_put_super(struct super_block *sb)
iput(sdp->sd_statfs_inode);
iput(sdp->sd_rindex);
iput(sdp->sd_quota_inode);
iput(sdp->sd_root_dir);
gfs2_glock_put(sdp->sd_rename_gl);
gfs2_glock_put(sdp->sd_trans_gl);

View file

@ -447,25 +447,6 @@ int gfs2_jdesc_check(struct gfs2_jdesc *jd)
return error;
}
int gfs2_lookup_master_dir(struct gfs2_sbd *sdp)
{
struct inode *inode = NULL;
struct gfs2_glock *gl;
int error;
error = gfs2_glock_get(sdp,
sdp->sd_sb.sb_master_dir.no_addr,
&gfs2_inode_glops, CREATE, &gl);
if (!error) {
error = gfs2_lookup_simple(sdp->sd_root_dir, ".gfs2_admin",
&inode);
sdp->sd_master_dir = inode;
gfs2_glock_put(gl);
}
return error;
}
/**
* gfs2_make_fs_rw - Turn a Read-Only FS into a Read-Write one
* @sdp: the filesystem

View file

@ -33,7 +33,6 @@ void gfs2_jdesc_make_dirty(struct gfs2_sbd *sdp, unsigned int jid);
struct gfs2_jdesc *gfs2_jdesc_find_dirty(struct gfs2_sbd *sdp);
int gfs2_jdesc_check(struct gfs2_jdesc *jd);
int gfs2_lookup_master_dir(struct gfs2_sbd *sdp);
int gfs2_lookup_in_master_dir(struct gfs2_sbd *sdp, char *filename,
struct gfs2_inode **ipp);