提交 c9fd4307 编写于 作者: S Steven Whitehouse

[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: NSteven Whitehouse <swhiteho@redhat.com>
上级 e317ffcb
...@@ -532,7 +532,6 @@ struct gfs2_sbd { ...@@ -532,7 +532,6 @@ struct gfs2_sbd {
struct inode *sd_qc_inode; struct inode *sd_qc_inode;
struct inode *sd_rindex; struct inode *sd_rindex;
struct inode *sd_quota_inode; struct inode *sd_quota_inode;
struct inode *sd_root_dir;
/* Inum stuff */ /* Inum stuff */
......
...@@ -288,7 +288,7 @@ int gfs2_inode_refresh(struct gfs2_inode *ip) ...@@ -288,7 +288,7 @@ int gfs2_inode_refresh(struct gfs2_inode *ip)
* Returns: errno * 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_glock *io_gl, unsigned int io_state,
struct gfs2_inode **ipp) struct gfs2_inode **ipp)
{ {
...@@ -354,8 +354,8 @@ static int inode_create(struct gfs2_glock *i_gl, struct gfs2_inum *inum, ...@@ -354,8 +354,8 @@ static int inode_create(struct gfs2_glock *i_gl, struct gfs2_inum *inum,
* Returns: errno * Returns: errno
*/ */
int gfs2_inode_get(struct gfs2_glock *i_gl, struct gfs2_inum *inum, int create, int gfs2_inode_get(struct gfs2_glock *i_gl, const struct gfs2_inum *inum,
struct gfs2_inode **ipp) int create, struct gfs2_inode **ipp)
{ {
struct gfs2_sbd *sdp = i_gl->gl_sbd; struct gfs2_sbd *sdp = i_gl->gl_sbd;
struct gfs2_glock *io_gl; struct gfs2_glock *io_gl;
...@@ -718,6 +718,7 @@ int gfs2_change_nlink(struct gfs2_inode *ip, int diff) ...@@ -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, int gfs2_lookupi(struct inode *dir, struct qstr *name, int is_root,
struct inode **inodep) struct inode **inodep)
{ {
struct super_block *sb = dir->i_sb;
struct gfs2_inode *ipp; struct gfs2_inode *ipp;
struct gfs2_inode *dip = dir->u.generic_ip; struct gfs2_inode *dip = dir->u.generic_ip;
struct gfs2_sbd *sdp = dip->i_sbd; struct gfs2_sbd *sdp = dip->i_sbd;
...@@ -733,7 +734,7 @@ int gfs2_lookupi(struct inode *dir, struct qstr *name, int is_root, ...@@ -733,7 +734,7 @@ int gfs2_lookupi(struct inode *dir, struct qstr *name, int is_root,
return -ENAMETOOLONG; return -ENAMETOOLONG;
if (gfs2_filecmp(name, ".", 1) || 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); gfs2_inode_hold(dip);
ipp = dip; ipp = dip;
goto done; goto done;
...@@ -1466,8 +1467,8 @@ int gfs2_unlink_ok(struct gfs2_inode *dip, struct qstr *name, ...@@ -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) 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 inode *dir = to->i_vnode;
struct super_block *sb = dir->i_sb;
struct inode *tmp; struct inode *tmp;
struct qstr dotdot; struct qstr dotdot;
int error = 0; int error = 0;
...@@ -1483,7 +1484,7 @@ int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to) ...@@ -1483,7 +1484,7 @@ int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to)
error = -EINVAL; error = -EINVAL;
break; break;
} }
if (dir == sdp->sd_root_dir) { if (dir == sb->s_root->d_inode) {
error = 0; error = 0;
break; break;
} }
......
...@@ -35,7 +35,7 @@ void gfs2_inode_min_init(struct gfs2_inode *ip, unsigned int type); ...@@ -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_refresh(struct gfs2_inode *ip);
int gfs2_inode_get(struct gfs2_glock *i_gl, 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); struct gfs2_inode **ipp);
void gfs2_inode_hold(struct gfs2_inode *ip); void gfs2_inode_hold(struct gfs2_inode *ip);
void gfs2_inode_put(struct gfs2_inode *ip); void gfs2_inode_put(struct gfs2_inode *ip);
......
...@@ -64,8 +64,8 @@ static int gfs2_encode_fh(struct dentry *dentry, __u32 *fh, int *len, ...@@ -64,8 +64,8 @@ static int gfs2_encode_fh(struct dentry *dentry, __u32 *fh, int *len,
int connectable) int connectable)
{ {
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
struct super_block *sb = inode->i_sb;
struct gfs2_inode *ip = inode->u.generic_ip; struct gfs2_inode *ip = inode->u.generic_ip;
struct gfs2_sbd *sdp = ip->i_sbd;
if (*len < 4 || (connectable && *len < 8)) if (*len < 4 || (connectable && *len < 8))
return 255; return 255;
...@@ -80,7 +80,7 @@ static int gfs2_encode_fh(struct dentry *dentry, __u32 *fh, int *len, ...@@ -80,7 +80,7 @@ static int gfs2_encode_fh(struct dentry *dentry, __u32 *fh, int *len,
fh[3] = cpu_to_be32(fh[3]); fh[3] = cpu_to_be32(fh[3]);
*len = 4; *len = 4;
if (!connectable || ip == sdp->sd_root_dir->u.generic_ip) if (!connectable || inode == sb->s_root->d_inode)
return *len; return *len;
spin_lock(&dentry->d_lock); spin_lock(&dentry->d_lock);
......
...@@ -280,27 +280,30 @@ static int init_locking(struct gfs2_sbd *sdp, struct gfs2_holder *mount_gh, ...@@ -280,27 +280,30 @@ static int init_locking(struct gfs2_sbd *sdp, struct gfs2_holder *mount_gh,
return error; 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; int error;
struct gfs2_glock *gl; struct gfs2_glock *gl;
struct gfs2_inode *ip; 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); &gfs2_inode_glops, CREATE, &gl);
if (!error) { if (!error) {
error = gfs2_inode_get(gl, &sdp->sd_sb.sb_root_dir, error = gfs2_inode_get(gl, inum,
CREATE, &ip); CREATE, &ip);
if (!error) { if (!error) {
if (!error) if (!error)
gfs2_inode_min_init(ip, DT_DIR); gfs2_inode_min_init(ip, DT_DIR);
sdp->sd_root_dir = gfs2_ip2v(ip); inode = gfs2_ip2v(ip);
gfs2_inode_put(ip); gfs2_inode_put(ip);
return inode;
} }
gfs2_glock_put(gl); gfs2_glock_put(gl);
} }
return error; return ERR_PTR(error);
} }
static int init_sb(struct gfs2_sbd *sdp, int silent, int undo) 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) ...@@ -311,7 +314,6 @@ static int init_sb(struct gfs2_sbd *sdp, int silent, int undo)
int error = 0; int error = 0;
if (undo) { if (undo) {
iput(sdp->sd_master_dir);
return 0; return 0;
} }
...@@ -351,35 +353,24 @@ static int init_sb(struct gfs2_sbd *sdp, int silent, int undo) ...@@ -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); sb_set_blocksize(sb, sdp->sd_sb.sb_bsize);
/* Get the root inode */ /* Get the root inode */
error = gfs2_lookup_root(sdp); inode = gfs2_lookup_root(sdp, &sdp->sd_sb.sb_root_dir);
if (error) { if (IS_ERR(inode)) {
error = PTR_ERR(inode);
fs_err(sdp, "can't read in root inode: %d\n", error); fs_err(sdp, "can't read in root inode: %d\n", error);
goto out; 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); sb->s_root = d_alloc_root(inode);
if (!sb->s_root) { if (!sb->s_root) {
fs_err(sdp, "can't get root dentry\n"); fs_err(sdp, "can't get root dentry\n");
error = -ENOMEM; error = -ENOMEM;
goto out_rooti; iput(inode);
} }
out: out:
gfs2_glock_dq_uninit(&sb_gh); gfs2_glock_dq_uninit(&sb_gh);
return error; return error;
out_rooti:
iput(sdp->sd_root_dir);
goto out;
} }
static int init_journal(struct gfs2_sbd *sdp, int undo) static int init_journal(struct gfs2_sbd *sdp, int undo)
...@@ -529,15 +520,18 @@ static int init_inodes(struct gfs2_sbd *sdp, int undo) ...@@ -529,15 +520,18 @@ static int init_inodes(struct gfs2_sbd *sdp, int undo)
{ {
int error = 0; int error = 0;
struct gfs2_inode *ip; struct gfs2_inode *ip;
struct inode *inode;
if (undo) if (undo)
goto fail_qinode; goto fail_qinode;
error = gfs2_lookup_master_dir(sdp); inode = gfs2_lookup_root(sdp, &sdp->sd_sb.sb_master_dir);
if (error) { if (IS_ERR(inode)) {
error = PTR_ERR(inode);
fs_err(sdp, "can't read in master directory: %d\n", error); fs_err(sdp, "can't read in master directory: %d\n", error);
goto fail; goto fail;
} }
sdp->sd_master_dir = inode;
error = init_journal(sdp, undo); error = init_journal(sdp, undo);
if (error) if (error)
......
...@@ -103,7 +103,6 @@ static void gfs2_put_super(struct super_block *sb) ...@@ -103,7 +103,6 @@ static void gfs2_put_super(struct super_block *sb)
iput(sdp->sd_statfs_inode); iput(sdp->sd_statfs_inode);
iput(sdp->sd_rindex); iput(sdp->sd_rindex);
iput(sdp->sd_quota_inode); iput(sdp->sd_quota_inode);
iput(sdp->sd_root_dir);
gfs2_glock_put(sdp->sd_rename_gl); gfs2_glock_put(sdp->sd_rename_gl);
gfs2_glock_put(sdp->sd_trans_gl); gfs2_glock_put(sdp->sd_trans_gl);
......
...@@ -447,25 +447,6 @@ int gfs2_jdesc_check(struct gfs2_jdesc *jd) ...@@ -447,25 +447,6 @@ int gfs2_jdesc_check(struct gfs2_jdesc *jd)
return error; 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 * gfs2_make_fs_rw - Turn a Read-Only FS into a Read-Write one
* @sdp: the filesystem * @sdp: the filesystem
......
...@@ -33,7 +33,6 @@ void gfs2_jdesc_make_dirty(struct gfs2_sbd *sdp, unsigned int jid); ...@@ -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); struct gfs2_jdesc *gfs2_jdesc_find_dirty(struct gfs2_sbd *sdp);
int gfs2_jdesc_check(struct gfs2_jdesc *jd); 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, int gfs2_lookup_in_master_dir(struct gfs2_sbd *sdp, char *filename,
struct gfs2_inode **ipp); struct gfs2_inode **ipp);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册