[GFS2] Fix a ref count bug and other clean ups
[powerpc.git] / fs / gfs2 / ops_super.c
index cd45ec9..80ce40c 100644 (file)
 #include <linux/spinlock.h>
 #include <linux/completion.h>
 #include <linux/buffer_head.h>
-#include <linux/vmalloc.h>
 #include <linux/statfs.h>
+#include <linux/vmalloc.h>
 #include <linux/seq_file.h>
 #include <linux/mount.h>
 #include <linux/kthread.h>
 #include <linux/delay.h>
+#include <linux/gfs2_ondisk.h>
 #include <asm/semaphore.h>
 
 #include "gfs2.h"
+#include "lm_interface.h"
+#include "incore.h"
 #include "glock.h"
 #include "inode.h"
 #include "lm.h"
@@ -33,6 +36,7 @@
 #include "rgrp.h"
 #include "super.h"
 #include "sys.h"
+#include "util.h"
 
 /**
  * gfs2_write_inode - Make sure the inode is stable on the disk
 
 static int gfs2_write_inode(struct inode *inode, int sync)
 {
-       struct gfs2_inode *ip = get_v2ip(inode);
+       struct gfs2_inode *ip = inode->u.generic_ip;
 
        if (current->flags & PF_MEMALLOC)
                return 0;
        if (ip && sync)
-               gfs2_log_flush_glock(ip->i_gl);
+               gfs2_log_flush(ip->i_gl->gl_sbd, ip->i_gl);
 
        return 0;
 }
@@ -62,7 +66,7 @@ static int gfs2_write_inode(struct inode *inode, int sync)
 
 static void gfs2_put_super(struct super_block *sb)
 {
-       struct gfs2_sbd *sdp = get_v2sdp(sb);
+       struct gfs2_sbd *sdp = sb->s_fs_info;
        int error;
 
        if (!sdp)
@@ -99,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);
@@ -118,10 +121,8 @@ static void gfs2_put_super(struct super_block *sb)
        }
 
        gfs2_glock_dq_uninit(&sdp->sd_live_gh);
-
        gfs2_clear_rgrpd(sdp);
        gfs2_jindex_free(sdp);
-
        /*  Take apart glock structures and buffer lists  */
        gfs2_gl_hash_clear(sdp, WAIT);
 
@@ -132,13 +133,9 @@ static void gfs2_put_super(struct super_block *sb)
 
        gfs2_sys_fs_del(sdp);
 
-       /*  Get rid of any extra inodes  */
-       while (invalidate_inodes(sb))
-               yield();
-
        vfree(sdp);
 
-       set_v2sdp(sb, NULL);
+       sb->s_fs_info = NULL;
 }
 
 /**
@@ -146,13 +143,13 @@ static void gfs2_put_super(struct super_block *sb)
  * @sb: the filesystem
  *
  * This function is called every time sync(2) is called.
- * After this exits, all dirty buffers and synced.
+ * After this exits, all dirty buffers are synced.
  */
 
 static void gfs2_write_super(struct super_block *sb)
 {
-       struct gfs2_sbd *sdp = get_v2sdp(sb);
-       gfs2_log_flush(sdp);
+       struct gfs2_sbd *sdp = sb->s_fs_info;
+       gfs2_log_flush(sdp, NULL);
 }
 
 /**
@@ -163,7 +160,7 @@ static void gfs2_write_super(struct super_block *sb)
 
 static void gfs2_write_super_lockfs(struct super_block *sb)
 {
-       struct gfs2_sbd *sdp = get_v2sdp(sb);
+       struct gfs2_sbd *sdp = sb->s_fs_info;
        int error;
 
        for (;;) {
@@ -194,7 +191,7 @@ static void gfs2_write_super_lockfs(struct super_block *sb)
 
 static void gfs2_unlockfs(struct super_block *sb)
 {
-       struct gfs2_sbd *sdp = get_v2sdp(sb);
+       struct gfs2_sbd *sdp = sb->s_fs_info;
        gfs2_unfreeze_fs(sdp);
 }
 
@@ -208,7 +205,7 @@ static void gfs2_unlockfs(struct super_block *sb)
 
 static int gfs2_statfs(struct super_block *sb, struct kstatfs *buf)
 {
-       struct gfs2_sbd *sdp = get_v2sdp(sb);
+       struct gfs2_sbd *sdp = sb->s_fs_info;
        struct gfs2_statfs_change sc;
        int error;
 
@@ -245,7 +242,7 @@ static int gfs2_statfs(struct super_block *sb, struct kstatfs *buf)
 
 static int gfs2_remount_fs(struct super_block *sb, int *flags, char *data)
 {
-       struct gfs2_sbd *sdp = get_v2sdp(sb);
+       struct gfs2_sbd *sdp = sb->s_fs_info;
        int error;
 
        error = gfs2_mount_args(sdp, data, 1);
@@ -283,12 +280,12 @@ static int gfs2_remount_fs(struct super_block *sb, int *flags, char *data)
 
 static void gfs2_clear_inode(struct inode *inode)
 {
-       struct gfs2_inode *ip = get_v2ip(inode);
+       struct gfs2_inode *ip = inode->u.generic_ip;
 
        if (ip) {
                spin_lock(&ip->i_spin);
                ip->i_vnode = NULL;
-               set_v2ip(inode, NULL);
+               inode->u.generic_ip = NULL;
                spin_unlock(&ip->i_spin);
 
                gfs2_glock_schedule_for_reclaim(ip->i_gl);
@@ -306,7 +303,7 @@ static void gfs2_clear_inode(struct inode *inode)
 
 static int gfs2_show_options(struct seq_file *s, struct vfsmount *mnt)
 {
-       struct gfs2_sbd *sdp = get_v2sdp(mnt->mnt_sb);
+       struct gfs2_sbd *sdp = mnt->mnt_sb->s_fs_info;
        struct gfs2_args *args = &sdp->sd_args;
 
        if (args->ar_lockproto[0])