]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/gfs2/glops.c
Merge branches 'sched/clock', 'sched/cleanups' and 'linus' into sched/urgent
[linux-2.6-omap-h63xx.git] / fs / gfs2 / glops.c
index 07d84d16cda4365eac465f375d22497414d0c988..8522d3aa64fc6032e81abf0cafae92a7f0e002c1 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/buffer_head.h>
 #include <linux/gfs2_ondisk.h>
 #include <linux/lm_interface.h>
+#include <linux/bio.h>
 
 #include "gfs2.h"
 #include "incore.h"
@@ -171,26 +172,6 @@ static void inode_go_sync(struct gfs2_glock *gl)
        }
 }
 
-/**
- * inode_go_xmote_bh - After promoting/demoting a glock
- * @gl: the glock
- *
- */
-
-static void inode_go_xmote_bh(struct gfs2_glock *gl)
-{
-       struct gfs2_holder *gh = gl->gl_req_gh;
-       struct buffer_head *bh;
-       int error;
-
-       if (gl->gl_state != LM_ST_UNLOCKED &&
-           (!gh || !(gh->gh_flags & GL_SKIP))) {
-               error = gfs2_meta_read(gl, gl->gl_name.ln_number, 0, &bh);
-               if (!error)
-                       brelse(bh);
-       }
-}
-
 /**
  * inode_go_inval - prepare a inode glock to be released
  * @gl: the glock
@@ -220,19 +201,12 @@ static void inode_go_inval(struct gfs2_glock *gl, int flags)
  * Returns: 1 if it's ok
  */
 
-static int inode_go_demote_ok(struct gfs2_glock *gl)
+static int inode_go_demote_ok(const struct gfs2_glock *gl)
 {
        struct gfs2_sbd *sdp = gl->gl_sbd;
-       int demote = 0;
-
-       if (!gl->gl_object && !gl->gl_aspace->i_mapping->nrpages)
-               demote = 1;
-       else if (!sdp->sd_args.ar_localcaching &&
-                time_after_eq(jiffies, gl->gl_stamp +
-                              gfs2_tune_get(sdp, gt_demote_secs) * HZ))
-               demote = 1;
-
-       return demote;
+       if (sdp->sd_jindex == gl->gl_object || sdp->sd_rindex == gl->gl_object)
+               return 0;
+       return 1;
 }
 
 /**
@@ -246,6 +220,7 @@ static int inode_go_demote_ok(struct gfs2_glock *gl)
 static int inode_go_lock(struct gfs2_holder *gh)
 {
        struct gfs2_glock *gl = gh->gh_gl;
+       struct gfs2_sbd *sdp = gl->gl_sbd;
        struct gfs2_inode *ip = gl->gl_object;
        int error = 0;
 
@@ -258,14 +233,43 @@ static int inode_go_lock(struct gfs2_holder *gh)
                        return error;
        }
 
-       if ((ip->i_di.di_flags & GFS2_DIF_TRUNC_IN_PROG) &&
+       if ((ip->i_diskflags & GFS2_DIF_TRUNC_IN_PROG) &&
            (gl->gl_state == LM_ST_EXCLUSIVE) &&
-           (gh->gh_state == LM_ST_EXCLUSIVE))
-               error = gfs2_truncatei_resume(ip);
+           (gh->gh_state == LM_ST_EXCLUSIVE)) {
+               spin_lock(&sdp->sd_trunc_lock);
+               if (list_empty(&ip->i_trunc_list))
+                       list_add(&sdp->sd_trunc_list, &ip->i_trunc_list);
+               spin_unlock(&sdp->sd_trunc_lock);
+               wake_up(&sdp->sd_quota_wait);
+               return 1;
+       }
 
        return error;
 }
 
+/**
+ * inode_go_dump - print information about an inode
+ * @seq: The iterator
+ * @ip: the inode
+ *
+ * Returns: 0 on success, -ENOBUFS when we run out of space
+ */
+
+static int inode_go_dump(struct seq_file *seq, const struct gfs2_glock *gl)
+{
+       const struct gfs2_inode *ip = gl->gl_object;
+       if (ip == NULL)
+               return 0;
+       gfs2_print_dbg(seq, " I: n:%llu/%llu t:%u f:0x%02lx d:0x%08x s:%llu/%llu\n",
+                 (unsigned long long)ip->i_no_formal_ino,
+                 (unsigned long long)ip->i_no_addr,
+                 IF2DT(ip->i_inode.i_mode), ip->i_flags,
+                 (unsigned int)ip->i_diskflags,
+                 (unsigned long long)ip->i_inode.i_size,
+                 (unsigned long long)ip->i_disksize);
+       return 0;
+}
+
 /**
  * rgrp_go_demote_ok - Check to see if it's ok to unlock a RG's glock
  * @gl: the glock
@@ -273,7 +277,7 @@ static int inode_go_lock(struct gfs2_holder *gh)
  * Returns: 1 if it's ok
  */
 
-static int rgrp_go_demote_ok(struct gfs2_glock *gl)
+static int rgrp_go_demote_ok(const struct gfs2_glock *gl)
 {
        return !gl->gl_aspace->i_mapping->nrpages;
 }
@@ -305,6 +309,24 @@ static void rgrp_go_unlock(struct gfs2_holder *gh)
        gfs2_rgrp_bh_put(gh->gh_gl->gl_object);
 }
 
+/**
+ * rgrp_go_dump - print out an rgrp
+ * @seq: The iterator
+ * @gl: The glock in question
+ *
+ */
+
+static int rgrp_go_dump(struct seq_file *seq, const struct gfs2_glock *gl)
+{
+       const struct gfs2_rgrpd *rgd = gl->gl_object;
+       if (rgd == NULL)
+               return 0;
+       gfs2_print_dbg(seq, " R: n:%llu f:%02x b:%u/%u i:%u\n",
+                      (unsigned long long)rgd->rd_addr, rgd->rd_flags,
+                      rgd->rd_free, rgd->rd_free_clone, rgd->rd_dinodes);
+       return 0;
+}
+
 /**
  * trans_go_sync - promote/demote the transaction glock
  * @gl: the glock
@@ -330,7 +352,7 @@ static void trans_go_sync(struct gfs2_glock *gl)
  *
  */
 
-static void trans_go_xmote_bh(struct gfs2_glock *gl)
+static int trans_go_xmote_bh(struct gfs2_glock *gl, struct gfs2_holder *gh)
 {
        struct gfs2_sbd *sdp = gl->gl_sbd;
        struct gfs2_inode *ip = GFS2_I(sdp->sd_jdesc->jd_inode);
@@ -338,8 +360,7 @@ static void trans_go_xmote_bh(struct gfs2_glock *gl)
        struct gfs2_log_header_host head;
        int error;
 
-       if (gl->gl_state != LM_ST_UNLOCKED &&
-           test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags)) {
+       if (test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags)) {
                j_gl->gl_ops->go_inval(j_gl, DIO_METADATA);
 
                error = gfs2_find_jhead(sdp->sd_jdesc, &head);
@@ -354,6 +375,19 @@ static void trans_go_xmote_bh(struct gfs2_glock *gl)
                        gfs2_log_pointers_init(sdp, head.lh_blkno);
                }
        }
+       return 0;
+}
+
+/**
+ * trans_go_demote_ok
+ * @gl: the glock
+ *
+ * Always returns 0
+ */
+
+static int trans_go_demote_ok(const struct gfs2_glock *gl)
+{
+       return 0;
 }
 
 /**
@@ -363,7 +397,7 @@ static void trans_go_xmote_bh(struct gfs2_glock *gl)
  * Returns: 1 if it's ok
  */
 
-static int quota_go_demote_ok(struct gfs2_glock *gl)
+static int quota_go_demote_ok(const struct gfs2_glock *gl)
 {
        return !atomic_read(&gl->gl_lvb_count);
 }
@@ -375,12 +409,12 @@ const struct gfs2_glock_operations gfs2_meta_glops = {
 
 const struct gfs2_glock_operations gfs2_inode_glops = {
        .go_xmote_th = inode_go_sync,
-       .go_xmote_bh = inode_go_xmote_bh,
        .go_inval = inode_go_inval,
        .go_demote_ok = inode_go_demote_ok,
        .go_lock = inode_go_lock,
+       .go_dump = inode_go_dump,
        .go_type = LM_TYPE_INODE,
-       .go_min_hold_time = HZ / 10,
+       .go_min_hold_time = HZ / 5,
 };
 
 const struct gfs2_glock_operations gfs2_rgrp_glops = {
@@ -389,13 +423,15 @@ const struct gfs2_glock_operations gfs2_rgrp_glops = {
        .go_demote_ok = rgrp_go_demote_ok,
        .go_lock = rgrp_go_lock,
        .go_unlock = rgrp_go_unlock,
+       .go_dump = rgrp_go_dump,
        .go_type = LM_TYPE_RGRP,
-       .go_min_hold_time = HZ / 10,
+       .go_min_hold_time = HZ / 5,
 };
 
 const struct gfs2_glock_operations gfs2_trans_glops = {
        .go_xmote_th = trans_go_sync,
        .go_xmote_bh = trans_go_xmote_bh,
+       .go_demote_ok = trans_go_demote_ok,
        .go_type = LM_TYPE_NONDISK,
 };