]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/gfs2/lops.c
[GFS2] Fix a ref count bug and other clean ups
[linux-2.6-omap-h63xx.git] / fs / gfs2 / lops.c
index 4bd89c0781e73da5aa82453ce5a1827b0a880add..4d90eb3114977372e45f855c3c7cb9119dcee02c 100644 (file)
 #include <linux/spinlock.h>
 #include <linux/completion.h>
 #include <linux/buffer_head.h>
+#include <linux/gfs2_ondisk.h>
 #include <asm/semaphore.h>
 
 #include "gfs2.h"
+#include "lm_interface.h"
+#include "incore.h"
 #include "glock.h"
 #include "log.h"
 #include "lops.h"
 #include "recovery.h"
 #include "rgrp.h"
 #include "trans.h"
+#include "util.h"
 
 static void glock_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le)
 {
        struct gfs2_glock *gl;
+       struct gfs2_trans *tr = current->journal_info;
 
-       get_transaction->tr_touched = 1;
+       tr->tr_touched = 1;
 
        if (!list_empty(&le->le_list))
                return;
@@ -68,7 +73,7 @@ static void buf_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le)
        if (!list_empty(&bd->bd_list_tr))
                return;
 
-       tr = get_transaction;
+       tr = current->journal_info;
        tr->tr_touched = 1;
        tr->tr_num_buf++;
        list_add(&bd->bd_list_tr, &tr->tr_list_buf);
@@ -125,11 +130,12 @@ static void buf_lo_before_commit(struct gfs2_sbd *sdp)
                if (total > limit)
                        num = limit;
                bh = gfs2_log_get_buf(sdp);
+               sdp->sd_log_num_hdrs++;
                ld = (struct gfs2_log_descriptor *)bh->b_data;
                ptr = (__be64 *)(bh->b_data + offset);
                ld->ld_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
-               ld->ld_header.mh_type = cpu_to_be16(GFS2_METATYPE_LD);
-               ld->ld_header.mh_format = cpu_to_be16(GFS2_FORMAT_LD);
+               ld->ld_header.mh_type = cpu_to_be32(GFS2_METATYPE_LD);
+               ld->ld_header.mh_format = cpu_to_be32(GFS2_FORMAT_LD);
                ld->ld_type = cpu_to_be32(GFS2_LOG_DESC_METADATA);
                ld->ld_length = cpu_to_be32(num + 1);
                ld->ld_data1 = cpu_to_be32(num);
@@ -179,7 +185,8 @@ static void buf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
 static void buf_lo_before_scan(struct gfs2_jdesc *jd,
                               struct gfs2_log_header *head, int pass)
 {
-       struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd;
+       struct gfs2_inode *ip = jd->jd_inode->u.generic_ip;
+       struct gfs2_sbd *sdp = ip->i_sbd;
 
        if (pass != 0)
                return;
@@ -192,8 +199,9 @@ static int buf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
                                struct gfs2_log_descriptor *ld, __be64 *ptr,
                                int pass)
 {
-       struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd;
-       struct gfs2_glock *gl = get_v2ip(jd->jd_inode)->i_gl;
+       struct gfs2_inode *ip = jd->jd_inode->u.generic_ip;
+       struct gfs2_sbd *sdp = ip->i_sbd;
+       struct gfs2_glock *gl = ip->i_gl;
        unsigned int blks = be32_to_cpu(ld->ld_data1);
        struct buffer_head *bh_log, *bh_ip;
        uint64_t blkno;
@@ -238,17 +246,18 @@ static int buf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
 
 static void buf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
 {
-       struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd;
+       struct gfs2_inode *ip = jd->jd_inode->u.generic_ip;
+       struct gfs2_sbd *sdp = ip->i_sbd;
 
        if (error) {
-               gfs2_meta_sync(get_v2ip(jd->jd_inode)->i_gl,
+               gfs2_meta_sync(ip->i_gl,
                               DIO_START | DIO_WAIT);
                return;
        }
        if (pass != 1)
                return;
 
-       gfs2_meta_sync(get_v2ip(jd->jd_inode)->i_gl, DIO_START | DIO_WAIT);
+       gfs2_meta_sync(ip->i_gl, DIO_START | DIO_WAIT);
 
        fs_info(sdp, "jid=%u: Replayed %u of %u blocks\n",
                jd->jd_jid, sdp->sd_replayed_blocks, sdp->sd_found_blocks);
@@ -258,7 +267,7 @@ static void revoke_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le)
 {
        struct gfs2_trans *tr;
 
-       tr = get_transaction;
+       tr = current->journal_info;
        tr->tr_touched = 1;
        tr->tr_num_revoke++;
 
@@ -283,8 +292,8 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp)
        bh = gfs2_log_get_buf(sdp);
        ld = (struct gfs2_log_descriptor *)bh->b_data;
        ld->ld_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
-       ld->ld_header.mh_type = cpu_to_be16(GFS2_METATYPE_LD);
-       ld->ld_header.mh_format = cpu_to_be16(GFS2_FORMAT_LD);
+       ld->ld_header.mh_type = cpu_to_be32(GFS2_METATYPE_LD);
+       ld->ld_header.mh_format = cpu_to_be32(GFS2_FORMAT_LD);
        ld->ld_type = cpu_to_be32(GFS2_LOG_DESC_REVOKE);
        ld->ld_length = cpu_to_be32(gfs2_struct2blk(sdp, sdp->sd_log_num_revoke,
                                                    sizeof(uint64_t)));
@@ -305,8 +314,8 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp)
                        bh = gfs2_log_get_buf(sdp);
                        mh = (struct gfs2_meta_header *)bh->b_data;
                        mh->mh_magic = cpu_to_be32(GFS2_MAGIC);
-                       mh->mh_type = cpu_to_be16(GFS2_METATYPE_LB);
-                       mh->mh_format = cpu_to_be16(GFS2_FORMAT_LB);
+                       mh->mh_type = cpu_to_be32(GFS2_METATYPE_LB);
+                       mh->mh_format = cpu_to_be32(GFS2_FORMAT_LB);
                        offset = sizeof(struct gfs2_meta_header);
                }
 
@@ -324,7 +333,8 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp)
 static void revoke_lo_before_scan(struct gfs2_jdesc *jd,
                                  struct gfs2_log_header *head, int pass)
 {
-       struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd;
+       struct gfs2_inode *ip = jd->jd_inode->u.generic_ip;
+       struct gfs2_sbd *sdp = ip->i_sbd;
 
        if (pass != 0)
                return;
@@ -337,7 +347,8 @@ static int revoke_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
                                   struct gfs2_log_descriptor *ld, __be64 *ptr,
                                   int pass)
 {
-       struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd;
+       struct gfs2_inode *ip = jd->jd_inode->u.generic_ip;
+       struct gfs2_sbd *sdp = ip->i_sbd;
        unsigned int blks = be32_to_cpu(ld->ld_length);
        unsigned int revokes = be32_to_cpu(ld->ld_data1);
        struct buffer_head *bh;
@@ -383,7 +394,8 @@ static int revoke_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
 
 static void revoke_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
 {
-       struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd;
+       struct gfs2_inode *ip = jd->jd_inode->u.generic_ip;
+       struct gfs2_sbd *sdp = ip->i_sbd;
 
        if (error) {
                gfs2_revoke_clean(sdp);
@@ -401,8 +413,9 @@ static void revoke_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
 static void rg_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le)
 {
        struct gfs2_rgrpd *rgd;
+       struct gfs2_trans *tr = current->journal_info;
 
-       get_transaction->tr_touched = 1;
+       tr->tr_touched = 1;
 
        if (!list_empty(&le->le_list))
                return;
@@ -451,9 +464,9 @@ static void rg_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
 static void databuf_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le)
 {
        struct gfs2_bufdata *bd = container_of(le, struct gfs2_bufdata, bd_le);
-       struct gfs2_trans *tr = get_transaction;
+       struct gfs2_trans *tr = current->journal_info;
        struct address_space *mapping = bd->bd_bh->b_page->mapping;
-       struct gfs2_inode *ip = get_v2ip(mapping->host);
+       struct gfs2_inode *ip = mapping->host->u.generic_ip;
 
        tr->tr_touched = 1;
        if (!list_empty(&bd->bd_list_tr) &&
@@ -462,6 +475,7 @@ static void databuf_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le)
                gfs2_trans_add_gl(bd->bd_gl);
                list_add(&bd->bd_list_tr, &tr->tr_list_buf);
                gfs2_pin(sdp, bd->bd_bh);
+               tr->tr_num_buf_new++;
        }
        gfs2_log_lock(sdp);
        if (!list_empty(&le->le_list)) {
@@ -557,15 +571,16 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp)
                                gfs2_log_unlock(sdp);
                                if (!bh) {
                                        bh = gfs2_log_get_buf(sdp);
+                                       sdp->sd_log_num_hdrs++;
                                        ld = (struct gfs2_log_descriptor *)
                                             bh->b_data;
                                        ptr = (__be64 *)(bh->b_data + offset);
                                        ld->ld_header.mh_magic =
                                                cpu_to_be32(GFS2_MAGIC);
                                        ld->ld_header.mh_type =
-                                               cpu_to_be16(GFS2_METATYPE_LD);
+                                               cpu_to_be32(GFS2_METATYPE_LD);
                                        ld->ld_header.mh_format =
-                                               cpu_to_be16(GFS2_FORMAT_LD);
+                                               cpu_to_be32(GFS2_FORMAT_LD);
                                        ld->ld_type =
                                                cpu_to_be32(GFS2_LOG_DESC_JDATA);
                                        ld->ld_length = cpu_to_be32(num + 1);
@@ -633,7 +648,7 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp)
 
                bh = bd1->bd_bh;
                if (bh) {
-                       set_v2bd(bh, NULL);
+                       bh->b_private = NULL;
                        gfs2_log_unlock(sdp);
                        wait_on_buffer(bh);
                        brelse(bh);
@@ -651,8 +666,9 @@ static int databuf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
                                    struct gfs2_log_descriptor *ld,
                                    __be64 *ptr, int pass)
 {
-       struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd;
-       struct gfs2_glock *gl = get_v2ip(jd->jd_inode)->i_gl;
+       struct gfs2_inode *ip = jd->jd_inode->u.generic_ip;
+       struct gfs2_sbd *sdp = ip->i_sbd;
+       struct gfs2_glock *gl = ip->i_gl;
        unsigned int blks = be32_to_cpu(ld->ld_data1);
        struct buffer_head *bh_log, *bh_ip;
        uint64_t blkno;
@@ -701,10 +717,11 @@ static int databuf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
 
 static void databuf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
 {
-       struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd;
+       struct gfs2_inode *ip = jd->jd_inode->u.generic_ip;
+       struct gfs2_sbd *sdp = ip->i_sbd;
 
        if (error) {
-               gfs2_meta_sync(get_v2ip(jd->jd_inode)->i_gl,
+               gfs2_meta_sync(ip->i_gl,
                               DIO_START | DIO_WAIT);
                return;
        }
@@ -712,7 +729,7 @@ static void databuf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
                return;
 
        /* data sync? */
-       gfs2_meta_sync(get_v2ip(jd->jd_inode)->i_gl, DIO_START | DIO_WAIT);
+       gfs2_meta_sync(ip->i_gl, DIO_START | DIO_WAIT);
 
        fs_info(sdp, "jid=%u: Replayed %u of %u data blocks\n",
                jd->jd_jid, sdp->sd_replayed_blocks, sdp->sd_found_blocks);
@@ -735,13 +752,13 @@ static void databuf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
 }
 
 
-struct gfs2_log_operations gfs2_glock_lops = {
+const struct gfs2_log_operations gfs2_glock_lops = {
        .lo_add = glock_lo_add,
        .lo_after_commit = glock_lo_after_commit,
        .lo_name = "glock"
 };
 
-struct gfs2_log_operations gfs2_buf_lops = {
+const struct gfs2_log_operations gfs2_buf_lops = {
        .lo_add = buf_lo_add,
        .lo_incore_commit = buf_lo_incore_commit,
        .lo_before_commit = buf_lo_before_commit,
@@ -752,7 +769,7 @@ struct gfs2_log_operations gfs2_buf_lops = {
        .lo_name = "buf"
 };
 
-struct gfs2_log_operations gfs2_revoke_lops = {
+const struct gfs2_log_operations gfs2_revoke_lops = {
        .lo_add = revoke_lo_add,
        .lo_before_commit = revoke_lo_before_commit,
        .lo_before_scan = revoke_lo_before_scan,
@@ -761,13 +778,13 @@ struct gfs2_log_operations gfs2_revoke_lops = {
        .lo_name = "revoke"
 };
 
-struct gfs2_log_operations gfs2_rg_lops = {
+const struct gfs2_log_operations gfs2_rg_lops = {
        .lo_add = rg_lo_add,
        .lo_after_commit = rg_lo_after_commit,
        .lo_name = "rg"
 };
 
-struct gfs2_log_operations gfs2_databuf_lops = {
+const struct gfs2_log_operations gfs2_databuf_lops = {
        .lo_add = databuf_lo_add,
        .lo_incore_commit = buf_lo_incore_commit,
        .lo_before_commit = databuf_lo_before_commit,
@@ -777,7 +794,7 @@ struct gfs2_log_operations gfs2_databuf_lops = {
        .lo_name = "databuf"
 };
 
-struct gfs2_log_operations *gfs2_log_ops[] = {
+const struct gfs2_log_operations *gfs2_log_ops[] = {
        &gfs2_glock_lops,
        &gfs2_buf_lops,
        &gfs2_revoke_lops,