Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6
[linux-2.6-block.git] / fs / gfs2 / ops_super.c
index d5355d9b59262a9f6de46eea51835fb9360aad50..777783deddcb8aba814988212d34d4996dfec7e6 100644 (file)
@@ -28,7 +28,6 @@
 #include "inode.h"
 #include "log.h"
 #include "mount.h"
-#include "ops_super.h"
 #include "quota.h"
 #include "recovery.h"
 #include "rgrp.h"
@@ -143,8 +142,6 @@ static void gfs2_put_super(struct super_block *sb)
        kthread_stop(sdp->sd_quotad_process);
        kthread_stop(sdp->sd_logd_process);
        kthread_stop(sdp->sd_recoverd_process);
-       while (sdp->sd_glockd_num--)
-               kthread_stop(sdp->sd_glockd_process[sdp->sd_glockd_num]);
 
        if (!(sb->s_flags & MS_RDONLY)) {
                error = gfs2_make_fs_ro(sdp);
@@ -185,7 +182,6 @@ static void gfs2_put_super(struct super_block *sb)
 
        /*  At this point, we're through participating in the lockspace  */
        gfs2_sys_fs_del(sdp);
-       kfree(sdp);
 }
 
 /**
@@ -259,6 +255,137 @@ static void gfs2_unlockfs(struct super_block *sb)
        gfs2_unfreeze_fs(sb->s_fs_info);
 }
 
+/**
+ * statfs_fill - fill in the sg for a given RG
+ * @rgd: the RG
+ * @sc: the sc structure
+ *
+ * Returns: 0 on success, -ESTALE if the LVB is invalid
+ */
+
+static int statfs_slow_fill(struct gfs2_rgrpd *rgd,
+                           struct gfs2_statfs_change_host *sc)
+{
+       gfs2_rgrp_verify(rgd);
+       sc->sc_total += rgd->rd_data;
+       sc->sc_free += rgd->rd_free;
+       sc->sc_dinodes += rgd->rd_dinodes;
+       return 0;
+}
+
+/**
+ * gfs2_statfs_slow - Stat a filesystem using asynchronous locking
+ * @sdp: the filesystem
+ * @sc: the sc info that will be returned
+ *
+ * Any error (other than a signal) will cause this routine to fall back
+ * to the synchronous version.
+ *
+ * FIXME: This really shouldn't busy wait like this.
+ *
+ * Returns: errno
+ */
+
+static int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host *sc)
+{
+       struct gfs2_holder ri_gh;
+       struct gfs2_rgrpd *rgd_next;
+       struct gfs2_holder *gha, *gh;
+       unsigned int slots = 64;
+       unsigned int x;
+       int done;
+       int error = 0, err;
+
+       memset(sc, 0, sizeof(struct gfs2_statfs_change_host));
+       gha = kcalloc(slots, sizeof(struct gfs2_holder), GFP_KERNEL);
+       if (!gha)
+               return -ENOMEM;
+
+       error = gfs2_rindex_hold(sdp, &ri_gh);
+       if (error)
+               goto out;
+
+       rgd_next = gfs2_rgrpd_get_first(sdp);
+
+       for (;;) {
+               done = 1;
+
+               for (x = 0; x < slots; x++) {
+                       gh = gha + x;
+
+                       if (gh->gh_gl && gfs2_glock_poll(gh)) {
+                               err = gfs2_glock_wait(gh);
+                               if (err) {
+                                       gfs2_holder_uninit(gh);
+                                       error = err;
+                               } else {
+                                       if (!error)
+                                               error = statfs_slow_fill(
+                                                       gh->gh_gl->gl_object, sc);
+                                       gfs2_glock_dq_uninit(gh);
+                               }
+                       }
+
+                       if (gh->gh_gl)
+                               done = 0;
+                       else if (rgd_next && !error) {
+                               error = gfs2_glock_nq_init(rgd_next->rd_gl,
+                                                          LM_ST_SHARED,
+                                                          GL_ASYNC,
+                                                          gh);
+                               rgd_next = gfs2_rgrpd_get_next(rgd_next);
+                               done = 0;
+                       }
+
+                       if (signal_pending(current))
+                               error = -ERESTARTSYS;
+               }
+
+               if (done)
+                       break;
+
+               yield();
+       }
+
+       gfs2_glock_dq_uninit(&ri_gh);
+
+out:
+       kfree(gha);
+       return error;
+}
+
+/**
+ * gfs2_statfs_i - Do a statfs
+ * @sdp: the filesystem
+ * @sg: the sg structure
+ *
+ * Returns: errno
+ */
+
+static int gfs2_statfs_i(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host *sc)
+{
+       struct gfs2_statfs_change_host *m_sc = &sdp->sd_statfs_master;
+       struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local;
+
+       spin_lock(&sdp->sd_statfs_spin);
+
+       *sc = *m_sc;
+       sc->sc_total += l_sc->sc_total;
+       sc->sc_free += l_sc->sc_free;
+       sc->sc_dinodes += l_sc->sc_dinodes;
+
+       spin_unlock(&sdp->sd_statfs_spin);
+
+       if (sc->sc_free < 0)
+               sc->sc_free = 0;
+       if (sc->sc_free > sc->sc_total)
+               sc->sc_free = sc->sc_total;
+       if (sc->sc_dinodes < 0)
+               sc->sc_dinodes = 0;
+
+       return 0;
+}
+
 /**
  * gfs2_statfs - Gather and return stats about the filesystem
  * @sb: The superblock
@@ -370,7 +497,6 @@ static void gfs2_clear_inode(struct inode *inode)
         */
        if (test_bit(GIF_USER, &ip->i_flags)) {
                ip->i_gl->gl_object = NULL;
-               gfs2_glock_schedule_for_reclaim(ip->i_gl);
                gfs2_glock_put(ip->i_gl);
                ip->i_gl = NULL;
                if (ip->i_iopen_gh.gh_gl) {
@@ -423,8 +549,6 @@ static int gfs2_show_options(struct seq_file *s, struct vfsmount *mnt)
                seq_printf(s, ",debug");
        if (args->ar_upgrade)
                seq_printf(s, ",upgrade");
-       if (args->ar_num_glockd != GFS2_GLOCKD_DEFAULT)
-               seq_printf(s, ",num_glockd=%u", args->ar_num_glockd);
        if (args->ar_posix_acl)
                seq_printf(s, ",acl");
        if (args->ar_quota != GFS2_QUOTA_DEFAULT) {
@@ -494,16 +618,16 @@ static void gfs2_delete_inode(struct inode *inode)
        gfs2_holder_reinit(LM_ST_EXCLUSIVE, LM_FLAG_TRY_1CB | GL_NOCACHE, &ip->i_iopen_gh);
        error = gfs2_glock_nq(&ip->i_iopen_gh);
        if (error)
-               goto out_uninit;
+               goto out_truncate;
 
        if (S_ISDIR(inode->i_mode) &&
-           (ip->i_di.di_flags & GFS2_DIF_EXHASH)) {
+           (ip->i_diskflags & GFS2_DIF_EXHASH)) {
                error = gfs2_dir_exhash_dealloc(ip);
                if (error)
                        goto out_unlock;
        }
 
-       if (ip->i_di.di_eattr) {
+       if (ip->i_eattr) {
                error = gfs2_ea_dealloc(ip);
                if (error)
                        goto out_unlock;
@@ -519,6 +643,7 @@ static void gfs2_delete_inode(struct inode *inode)
        if (error)
                goto out_unlock;
 
+out_truncate:
        error = gfs2_trans_begin(sdp, 0, sdp->sd_jdesc->jd_blocks);
        if (error)
                goto out_unlock;
@@ -527,8 +652,8 @@ static void gfs2_delete_inode(struct inode *inode)
        gfs2_trans_end(sdp);
 
 out_unlock:
-       gfs2_glock_dq(&ip->i_iopen_gh);
-out_uninit:
+       if (test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags))
+               gfs2_glock_dq(&ip->i_iopen_gh);
        gfs2_holder_uninit(&ip->i_iopen_gh);
        gfs2_glock_dq_uninit(&gh);
        if (error && error != GLR_TRYFAILED)