[GFS2] Tidy up mount code.
authorSteven Whitehouse <swhiteho@redhat.com>
Wed, 1 Mar 2006 20:31:02 +0000 (15:31 -0500)
committerSteven Whitehouse <swhiteho@redhat.com>
Wed, 1 Mar 2006 20:31:02 +0000 (15:31 -0500)
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>
fs/gfs2/incore.h
fs/gfs2/inode.c
fs/gfs2/inode.h
fs/gfs2/ops_export.c
fs/gfs2/ops_fstype.c
fs/gfs2/ops_super.c
fs/gfs2/super.c
fs/gfs2/super.h

index c741016d07dc4c2afcc0762438f710996900bc61..62f109e553c4b48b8727b6e1c1efcc613a413972 100644 (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 */
 
index ea9e996f36731a09934c8a0597d358e992b3e703..cd1de61bff2f6857cce05d5fc6bc0aa835e0b0e9 100644 (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;
                }
index 069f0e21db6d0893cfebf5eb650438e914eb5420..c3fa6cfce169b1a37e29c8322956419e50f762fc 100644 (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);
index d149584cff301e304b23b045a7e90e28a74d356d..a346943363c656ab733f79652831589691b28ac2 100644 (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);
index 4c4115f9d960f780fe68c62e2861b9ffd2140e5e..c3b830bd838b546f1a47b468bd752b161b97c123 100644 (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)
index 10f70ee121613bb29692ed9fcd08e6abd3906eda..f7349c0989a9f59ccf1a38eefaa6e13150cc292e 100644 (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);
index 9ccf0b9c5980df54b612eefc4e36296af467bb81..fff5a96f4152778efe79e25a997f3e7df2c5b863 100644 (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
index cc1a3df1949a50dd3ad94db2f935552746c52565..6abb7b5c88284d871b51a404edb7020a82129539 100644 (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);
 
This page took 0.070098 seconds and 5 git commands to generate.